From 92399cb5d2b2369982b7232561eb8fbd2ac1c468 Mon Sep 17 00:00:00 2001 From: mattraykowski Date: Wed, 17 Oct 2012 08:52:01 -0500 Subject: [PATCH] merged from default --HG-- branch : gsoc2012-achievements --- .../server/src/tick_service/tick_service.cpp | 2520 ++++---- .../server/src/tick_service/tick_service.h | 752 +-- code/ryzom/tools/assoc_mem/att_tree.h | 60 +- code/ryzom/tools/assoc_mem/attribute.cpp | 62 +- code/ryzom/tools/assoc_mem/attribute.h | 130 +- code/ryzom/tools/assoc_mem/brain.cpp | 310 +- code/ryzom/tools/assoc_mem/brain.h | 138 +- code/ryzom/tools/assoc_mem/cond_node.cpp | 88 +- code/ryzom/tools/assoc_mem/cond_node.h | 272 +- code/ryzom/tools/assoc_mem/field.cpp | 306 +- code/ryzom/tools/assoc_mem/field.h | 166 +- code/ryzom/tools/assoc_mem/mood.cpp | 226 +- code/ryzom/tools/assoc_mem/mood.h | 96 +- code/ryzom/tools/assoc_mem/node.cpp | 52 +- code/ryzom/tools/assoc_mem/node.h | 58 +- code/ryzom/tools/assoc_mem/record.cpp | 142 +- code/ryzom/tools/assoc_mem/record.h | 82 +- code/ryzom/tools/assoc_mem/result_node.cpp | 74 +- code/ryzom/tools/assoc_mem/result_node.h | 64 +- code/ryzom/tools/assoc_mem/test.cpp | 500 +- code/ryzom/tools/assoc_mem/tree.cpp | 816 +-- code/ryzom/tools/assoc_mem/tree.h | 158 +- code/ryzom/tools/assoc_mem/val_nodes.h | 94 +- code/ryzom/tools/assoc_mem/value.h | 214 +- .../workspace/common/cfg/directories.py | 164 +- .../workspace/common/cfg/process.py | 74 +- .../common/characters/directories.py | 380 +- .../workspace/common/characters/process.py | 216 +- .../common/characters_maps_hr/directories.py | 156 +- .../common/characters_maps_hr/process.py | 162 +- .../common/construction/directories.py | 336 +- .../workspace/common/construction/process.py | 228 +- .../common/data_common/directories.py | 146 +- .../workspace/common/data_common/process.py | 90 +- .../workspace/common/exedll/directories.py | 172 +- .../workspace/common/exedll/process.py | 74 +- .../workspace/common/fauna/directories.py | 606 +- .../workspace/common/fauna/process.py | 226 +- .../workspace/common/fonts/directories.py | 118 +- .../workspace/common/fonts/process.py | 86 +- .../workspace/common/gamedev/directories.py | 126 +- .../workspace/common/gamedev/process.py | 82 +- .../workspace/common/interface/directories.py | 188 +- .../workspace/common/interface/process.py | 98 +- .../common/leveldesign/directories.py | 154 +- .../workspace/common/leveldesign/process.py | 88 +- .../workspace/common/objects/directories.py | 238 +- .../workspace/common/objects/process.py | 162 +- .../workspace/common/outgame/directories.py | 336 +- .../workspace/common/outgame/process.py | 228 +- .../workspace/common/sfx/directories.py | 254 +- .../workspace/common/sfx/process.py | 182 +- .../workspace/common/sky/directories.py | 376 +- .../workspace/common/sky/process.py | 242 +- .../workspace/continents/fyros/directories.py | 262 +- .../workspace/continents/fyros/process.py | 162 +- .../continents/indoors/directories.py | 524 +- .../workspace/continents/indoors/process.py | 334 +- .../workspace/continents/matis/directories.py | 248 +- .../workspace/continents/matis/process.py | 162 +- .../continents/newbieland/directories.py | 502 +- .../continents/newbieland/process.py | 338 +- .../continents/tryker/directories.py | 252 +- .../workspace/continents/tryker/process.py | 162 +- .../workspace/continents/zorai/directories.py | 248 +- .../workspace/continents/zorai/process.py | 162 +- .../ecosystems/desert/directories.py | 536 +- .../workspace/ecosystems/desert/process.py | 264 +- .../ecosystems/jungle/directories.py | 544 +- .../workspace/ecosystems/jungle/process.py | 264 +- .../ecosystems/lacustre/directories.py | 560 +- .../workspace/ecosystems/lacustre/process.py | 264 +- .../ecosystems/primes_racines/directories.py | 530 +- .../ecosystems/primes_racines/process.py | 264 +- .../build_gamedata/workspace/projects.py | 1024 +-- .../tools/client/client_config/StdAfx.cpp | 42 +- .../ryzom/tools/client/client_config/StdAfx.h | 122 +- code/ryzom/tools/client/client_config/bar.cpp | 170 +- code/ryzom/tools/client/client_config/bar.h | 130 +- .../client/client_config/base_dialog.cpp | 66 +- .../tools/client/client_config/base_dialog.h | 94 +- .../tools/client/client_config/cfg_file.cpp | 1498 ++--- .../tools/client/client_config/cfg_file.h | 182 +- .../client/client_config/client_config.cpp | 550 +- .../client/client_config/client_config.h | 166 +- .../client/client_config/client_configDlg.cpp | 1256 ++-- .../client/client_config/client_configDlg.h | 266 +- .../tools/client/client_config/database.cpp | 440 +- .../tools/client/client_config/database.h | 344 +- .../client_config/display_advanced_dlg.cpp | 190 +- .../client_config/display_advanced_dlg.h | 140 +- .../client_config/display_details_dlg.cpp | 272 +- .../client_config/display_details_dlg.h | 158 +- .../client/client_config/display_dlg.cpp | 1004 +-- .../tools/client/client_config/display_dlg.h | 332 +- .../display_information_d3d_dlg.cpp | 146 +- .../display_information_d3d_dlg.h | 132 +- .../display_information_gl_dlg.cpp | 154 +- .../display_information_gl_dlg.h | 134 +- .../client/client_config/general_dlg.cpp | 222 +- .../tools/client/client_config/general_dlg.h | 144 +- .../tools/client/client_config/preset_dlg.cpp | 348 +- .../tools/client/client_config/preset_dlg.h | 152 +- .../tools/client/client_config/resource.h | 376 +- .../tools/client/client_config/sound_dlg.cpp | 348 +- .../tools/client/client_config/sound_dlg.h | 170 +- .../client_config/system_information_dlg.cpp | 166 +- .../client_config/system_information_dlg.h | 136 +- .../tools/client/client_data_check/ReadMe.txt | 176 +- .../tools/client/client_data_check/StdAfx.cpp | 48 +- .../tools/client/client_data_check/StdAfx.h | 86 +- .../client_data_check/client_data_check.cpp | 870 +-- .../client_data_check/client_data_check.h | 214 +- .../client_data_checkDlg.cpp | 236 +- .../client_data_check/client_data_checkDlg.h | 138 +- .../client/client_data_check/data_scan.cpp | 1074 +-- .../client/client_data_check/data_scan.h | 434 +- .../tools/client/client_data_check/resource.h | 72 +- .../tools/client/client_patcher/main.cpp | 834 +-- code/ryzom/tools/connection_stats/StdAfx.cpp | 48 +- code/ryzom/tools/connection_stats/StdAfx.h | 80 +- .../connection_stats/connection_stats.cpp | 2024 +++--- .../tools/connection_stats/connection_stats.h | 82 +- .../alias_synchronizer/alias_synchronizer.cpp | 818 +-- .../leveldesign/csv_transform/CMakeLists.txt | 22 +- .../csv_transform/csv_transform.cpp | 890 +-- .../sadge_lib/include/text_input.h | 436 +- .../sadge_lib/include/text_output.h | 820 +-- .../ryzom/tools/leveldesign/export/export.cpp | 4424 ++++++------- code/ryzom/tools/leveldesign/export/export.h | 428 +- .../tools/leveldesign/export/formFlora.cpp | 186 +- .../tools/leveldesign/export/formFlora.h | 110 +- .../tools/leveldesign/export/formPlant.cpp | 82 +- .../tools/leveldesign/export/formPlant.h | 80 +- code/ryzom/tools/leveldesign/export/tools.cpp | 498 +- code/ryzom/tools/leveldesign/export/tools.h | 152 +- .../leveldesign/georges_convert/common.h | 72 +- .../leveldesign/georges_convert/form.cpp | 298 +- .../tools/leveldesign/georges_convert/form.h | 142 +- .../georges_convert/form_body_elt.cpp | 198 +- .../georges_convert/form_body_elt.h | 114 +- .../georges_convert/form_body_elt_atom.cpp | 210 +- .../georges_convert/form_body_elt_atom.h | 110 +- .../georges_convert/form_body_elt_list.cpp | 306 +- .../georges_convert/form_body_elt_list.h | 120 +- .../georges_convert/form_body_elt_struct.cpp | 570 +- .../georges_convert/form_body_elt_struct.h | 134 +- .../leveldesign/georges_convert/form_file.cpp | 196 +- .../leveldesign/georges_convert/form_file.h | 96 +- .../leveldesign/georges_convert/form_head.cpp | 192 +- .../leveldesign/georges_convert/form_head.h | 102 +- .../georges_convert/form_loader.cpp | 128 +- .../leveldesign/georges_convert/form_loader.h | 90 +- .../georges_convert/georges_convert.cpp | 1296 ++-- .../georges_convert/georges_loader.cpp | 656 +- .../georges_convert/georges_loader.h | 132 +- .../leveldesign/georges_convert/item.cpp | 950 +-- .../tools/leveldesign/georges_convert/item.h | 182 +- .../leveldesign/georges_convert/item_elt.cpp | 330 +- .../leveldesign/georges_convert/item_elt.h | 164 +- .../georges_convert/item_elt_atom.cpp | 276 +- .../georges_convert/item_elt_atom.h | 112 +- .../georges_convert/item_elt_list.cpp | 484 +- .../georges_convert/item_elt_list.h | 128 +- .../georges_convert/item_elt_struct.cpp | 534 +- .../georges_convert/item_elt_struct.h | 126 +- .../georges_convert/item_loader.cpp | 98 +- .../leveldesign/georges_convert/item_loader.h | 80 +- .../leveldesign/georges_convert/mold_elt.cpp | 184 +- .../leveldesign/georges_convert/mold_elt.h | 122 +- .../georges_convert/mold_elt_define.cpp | 166 +- .../georges_convert/mold_elt_define.h | 92 +- .../georges_convert/mold_elt_define_list.cpp | 186 +- .../georges_convert/mold_elt_define_list.h | 92 +- .../georges_convert/mold_elt_type.cpp | 646 +- .../georges_convert/mold_elt_type.h | 118 +- .../georges_convert/mold_elt_type_list.cpp | 204 +- .../georges_convert/mold_elt_type_list.h | 106 +- .../georges_convert/mold_loader.cpp | 326 +- .../leveldesign/georges_convert/mold_loader.h | 118 +- .../georges_convert/stdgeorgesconvert.cpp | 36 +- .../georges_convert/stdgeorgesconvert.h | 54 +- .../leveldesign/georges_convert/string_ex.cpp | 714 +- .../leveldesign/georges_convert/string_ex.h | 156 +- .../leveldesign/georges_convert/type_unit.cpp | 166 +- .../leveldesign/georges_convert/type_unit.h | 100 +- .../georges_convert/type_unit_double.cpp | 418 +- .../georges_convert/type_unit_double.h | 94 +- .../georges_convert/type_unit_file_name.cpp | 130 +- .../georges_convert/type_unit_file_name.h | 86 +- .../georges_convert/type_unit_int_signed.cpp | 330 +- .../georges_convert/type_unit_int_signed.h | 90 +- .../type_unit_int_unsigned.cpp | 394 +- .../georges_convert/type_unit_int_unsigned.h | 90 +- .../georges_convert/type_unit_string.cpp | 156 +- .../georges_convert/type_unit_string.h | 86 +- .../tools/leveldesign/georges_dll/Resource.h | 196 +- .../tools/leveldesign/georges_dll/action.cpp | 2462 +++---- .../tools/leveldesign/georges_dll/action.h | 370 +- .../leveldesign/georges_dll/base_dialog.cpp | 606 +- .../leveldesign/georges_dll/base_dialog.h | 334 +- .../leveldesign/georges_dll/child_frm.cpp | 486 +- .../tools/leveldesign/georges_dll/child_frm.h | 148 +- .../leveldesign/georges_dll/color_wnd.cpp | 358 +- .../tools/leveldesign/georges_dll/color_wnd.h | 174 +- .../georges_dll/cool_dialog_bar.cpp | 1292 ++-- .../leveldesign/georges_dll/cool_dialog_bar.h | 242 +- .../leveldesign/georges_dll/dfn_dialog.cpp | 1264 ++-- .../leveldesign/georges_dll/dfn_dialog.h | 264 +- .../leveldesign/georges_dll/displayer.cpp | 90 +- .../tools/leveldesign/georges_dll/displayer.h | 66 +- .../georges_dll/edit_list_ctrl.cpp | 1136 ++-- .../leveldesign/georges_dll/edit_list_ctrl.h | 270 +- .../georges_dll/file_browser_dialog.cpp | 672 +- .../georges_dll/file_browser_dialog.h | 174 +- .../georges_dll/file_tree_view.cpp | 1482 ++--- .../leveldesign/georges_dll/file_tree_view.h | 184 +- .../leveldesign/georges_dll/form_dialog.cpp | 5738 ++++++++--------- .../leveldesign/georges_dll/form_dialog.h | 1036 +-- .../leveldesign/georges_dll/georges_edit.cpp | 3260 +++++----- .../leveldesign/georges_dll/georges_edit.h | 458 +- .../georges_dll/georges_edit_doc.cpp | 3362 +++++----- .../georges_dll/georges_edit_doc.h | 844 +-- .../georges_dll/georges_edit_view.cpp | 1398 ++-- .../georges_dll/georges_edit_view.h | 282 +- .../georges_dll/georges_implementation.cpp | 1378 ++-- .../georges_dll/georges_interface.h | 282 +- .../leveldesign/georges_dll/header_dialog.cpp | 802 +-- .../leveldesign/georges_dll/header_dialog.h | 210 +- .../leveldesign/georges_dll/icon_wnd.cpp | 596 +- .../tools/leveldesign/georges_dll/icon_wnd.h | 186 +- .../leveldesign/georges_dll/imagelist_ex.cpp | 284 +- .../leveldesign/georges_dll/imagelist_ex.h | 104 +- .../leveldesign/georges_dll/left_view.cpp | 2146 +++--- .../tools/leveldesign/georges_dll/left_view.h | 266 +- .../leveldesign/georges_dll/main_frm.cpp | 1098 ++-- .../tools/leveldesign/georges_dll/main_frm.h | 228 +- .../georges_dll/memory_combo_box.cpp | 1452 ++--- .../georges_dll/memory_combo_box.h | 284 +- .../georges_dll/output_console_dlg.cpp | 228 +- .../georges_dll/output_console_dlg.h | 140 +- .../georges_dll/plugin_interface.h | 496 +- .../leveldesign/georges_dll/reg_shell_ext.cpp | 384 +- .../leveldesign/georges_dll/reg_shell_ext.h | 82 +- .../georges_dll/settings_dialog.cpp | 322 +- .../leveldesign/georges_dll/settings_dialog.h | 156 +- .../leveldesign/georges_dll/splash_screen.cpp | 154 +- .../leveldesign/georges_dll/splash_screen.h | 132 +- .../tools/leveldesign/georges_dll/stdafx.cpp | 48 +- .../tools/leveldesign/georges_dll/stdafx.h | 116 +- .../leveldesign/georges_dll/type_dialog.cpp | 1214 ++-- .../leveldesign/georges_dll/type_dialog.h | 258 +- .../georges_editor_qt/CMakeLists.txt | 38 +- .../src/completer_line_edit.cpp | 298 +- .../src/completer_line_edit.h | 76 +- .../georges_editor_qt/src/configuration.cpp | 472 +- .../georges_editor_qt/src/configuration.h | 176 +- .../georges_editor_qt/src/entity.cpp | 860 +-- .../georges_editor_qt/src/entity.h | 520 +- .../src/filesystem_model.cpp | 158 +- .../georges_editor_qt/src/filesystem_model.h | 86 +- .../georges_editor_qt/src/formdelegate.cpp | 628 +- .../georges_editor_qt/src/formdelegate.h | 90 +- .../georges_editor_qt/src/formitem.cpp | 328 +- .../georges_editor_qt/src/georges.cpp | 132 +- .../georges_editor_qt/src/georges.h | 142 +- .../src/georges_dirtree_dialog.cpp | 282 +- .../src/georges_dirtree_dialog.h | 130 +- .../georges_editor_qt/src/georges_splash.cpp | 144 +- .../georges_editor_qt/src/georges_splash.h | 112 +- .../src/georges_treeview_dialog.cpp | 846 +-- .../src/georges_treeview_dialog.h | 178 +- .../src/georgesform_model.cpp | 1284 ++-- .../georges_editor_qt/src/georgesform_model.h | 164 +- .../src/georgesform_proxy_model.cpp | 192 +- .../src/georgesform_proxy_model.h | 96 +- .../georges_editor_qt/src/log_dialog.cpp | 120 +- .../georges_editor_qt/src/log_dialog.h | 108 +- .../georges_editor_qt/src/main.cpp | 274 +- .../georges_editor_qt/src/main_window.cpp | 1082 ++-- .../georges_editor_qt/src/main_window.h | 254 +- .../georges_editor_qt/src/modules.h | 94 +- .../georges_editor_qt/src/new_dialog.cpp | 680 +- .../georges_editor_qt/src/new_dialog.h | 176 +- .../src/objectviewer_dialog.cpp | 228 +- .../src/objectviewer_dialog.h | 168 +- .../georges_editor_qt/src/progress_dialog.cpp | 132 +- .../georges_editor_qt/src/progress_dialog.h | 116 +- .../georges_editor_qt/src/qt_displayer.cpp | 252 +- .../georges_editor_qt/src/qt_displayer.h | 108 +- .../georges_editor_qt/src/settings_dialog.cpp | 416 +- .../georges_editor_qt/src/settings_dialog.h | 124 +- .../georges_editor_qt/src/stdpch.h | 66 +- .../leveldesign/georges_exe/georges_exe.cpp | 138 +- .../tools/leveldesign/georges_exe/resource.h | 76 +- .../georges_plugin_sound/PageBase.cpp | 80 +- .../georges_plugin_sound/PageBase.h | 136 +- 297 files changed, 57213 insertions(+), 57213 deletions(-) diff --git a/code/ryzom/server/src/tick_service/tick_service.cpp b/code/ryzom/server/src/tick_service/tick_service.cpp index 504eacc70..a25c1c83e 100644 --- a/code/ryzom/server/src/tick_service/tick_service.cpp +++ b/code/ryzom/server/src/tick_service/tick_service.cpp @@ -1,1260 +1,1260 @@ -// 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/command.h" -#include "nel/misc/variable.h" -#include "nel/misc/common.h" -#include "nel/misc/file.h" - -#include "game_share/ryzom_version.h" -#include "game_share/tick_event_handler.h" -#include "game_share/backup_service_interface.h" -#include "game_share/singleton_registry.h" -#include - -#include "tick_service.h" -#include - -#ifdef NL_OS_WINDOWS -# define NOMINMAX -# include -#endif // NL_OS_WINDOWS - -using namespace std; -using namespace NLMISC; -using namespace NLNET; - -// force admin module to link in -extern void admin_modules_forceLink(); -void foo() -{ - admin_modules_forceLink(); -} - - -CTickService * TS = NULL; - -NLNET::TServiceId SlowestService(0); -NLNET::TServiceId SlowestCandidate(0); -double SlowestTock = 0.0; -string WaitingForServices; - -const string GAME_CYCLE_FILE = "game_cycle.ticks"; - -const NLMISC::TGameCycle INTERVAL_FOR_SAVING_GAME_CYCLE = 300; - -// when true the tick service stops broadcasting ticks -bool Pause = false; - -// In the Tick Service, set TotalSpeedLoop to the duration of a whole tick cycle -// (between send tick and the last tock received) -extern CVariable TotalSpeedLoop; -extern CVariable TickSpeedLoop; - -static NLMISC::TTime BeginOfTickTime = 0; - -CVariable TickSendingMode( "tick", "TickSendingMode", "0=Continuous 1=StepByStep 2=Fastest", 0, - 0, true ); - -/*CVariable WaitForBSThreshold( "tick", "WaitForBSThreshold", "Threshold for BSAckDelay beyond which tick starts to slow down to wait for BS (expressed as a factor of _TickTimeStep)", 1.0f, - 0, true ); -*/ - -//----------------------------------------------- -// cbRegister -// -//----------------------------------------------- -static void cbRegister(CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId) -{ - if( serviceId.get() > 255 ) - { - nlwarning(" Service %s id is too higher than 255 : %d, this service will be not registered",serviceName.c_str(),serviceId.get()); - return; - } - - bool tocking = true; - uint16 threshold = 0; - msgin.serial( tocking ); - msgin.serial( threshold ); - TS->registerClient( serviceId, tocking, threshold ); - - CMessage msgout( "REGISTERED" ); - TGameTime gameTime = TS->getGameTime(); - TGameTime gameTimeStep = TS->getGameTimeStep(); - TGameCycle gameCycle = TS->getGameCycle(); - - msgout.serial( gameTime ); - msgout.serial( gameTimeStep ); - msgout.serial( gameCycle ); - - CUnifiedNetwork::getInstance()->send(serviceId,msgout); - - if( TS->getClientCount() == 1 ) - { - TS->FirstTime = true; - BeginOfTickTime = CTime::getLocalTime(); - TS->checkTockReceived(); - } - -} // cbRegister // - - - -//----------------------------------------------- -// cbTock -// -//----------------------------------------------- -static void cbTock(CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId) -{ - // Receive measures of client service - TS->MainTimeMeasures.CurrentMirrorMeasures.push_back( CMirrorGameCycleTimeMeasureMS() ); - CMirrorGameCycleTimeMeasureMS& mm = TS->MainTimeMeasures.CurrentMirrorMeasures.back(); - msgin.serial( mm ); - mm.MSId = serviceId; - - // Process Tock - //nlinfo( "TOCK rcvd at %.6f", CTime::ticksToSecond( CTime::getPerformanceTime() ) ); - SlowestCandidate=serviceId; - TS->addTock( serviceId ); - -} // cbTock // - - - - -//----------------------------------------------- -// cbHaltTick -// -//----------------------------------------------- -static void cbHaltTick(CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId) -{ - std::string reason = ""; - - try - { - msgin.serial(reason); - } - catch(const Exception&) - { - } - - reason = toString("service %s:%d halted: %s", serviceName.c_str(), serviceId.get(), reason.c_str()); - - TS->haltTick(reason); - -} // cbHaltTick // - -//----------------------------------------------- -// cbResumeTick -// -//----------------------------------------------- -static void cbResumeTick(CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId) -{ - TS->resumeTick(); - -} // cbHaltTick // - - -//----------------------------------------------- -// callback table for input message -// -//----------------------------------------------- -TUnifiedCallbackItem CbArray[] = -{ - { "REGISTER", cbRegister }, - { "TOCK", cbTock }, - - { "HALT_TICK", cbHaltTick }, - { "RESUME_TICK", cbResumeTick }, -}; - - -/* - * halt ticking - */ -void CTickService::haltTick(const std::string& reason) -{ - if (CurrentMode == TickHalted) - return; - - CurrentMode = TickHalted; - - nlwarning("***********************************************************"); - nlwarning("WARNING:"); - nlwarning("TICK SERVICE IS ENTERING HALTED MODE"); - nlwarning("HALT REQUEST IS '%s'", reason.c_str()); - nlwarning("***********************************************************"); - - HaltedReason = reason; - - IService::setCurrentStatus("HALTED"); -} - -/* - * resume ticking - */ -void CTickService::resumeTick() -{ - if (CurrentMode == TickRunning) - return; - - // restart ticking - CurrentMode = TickRunning; - - nlwarning("***********************************************************"); - nlwarning("WARNING:"); - nlwarning("TICK SERVICE IS RESUMED"); - nlwarning("HALT REQUEST WAS '%s'", HaltedReason.c_str()); - nlwarning("***********************************************************"); - - // check in case tocks were received during halt - checkTockReceived(); - - IService::clearCurrentStatus("HALTED"); -} - - - -//----------------------------------------------- -// registerClient -// -//----------------------------------------------- -void CTickService::registerClient( NLNET::TServiceId serviceId, bool tocking, uint16 threshold ) -{ - if( serviceId.get() < _ClientInfos.size() ) - { - if( _ClientInfos[serviceId.get()].Registered == true ) - { - nlerror(" The service %d is alredy registered",serviceId.get()); - } - - _ClientInfos[serviceId.get()].Registered = true; - _ClientInfos[serviceId.get()].Tocking = tocking; - _ClientInfos[serviceId.get()].Threshold = threshold; - _QuickLog.displayNL( "%u: +%hu", getGameCycle(), serviceId.get() ); - } - else - { - nlwarning(" Service id too high : %d (max is %d)",serviceId.get(),_ClientInfos.size()-1); - } - -} // registerClient // - - - -//----------------------------------------------- -// addTock -// -//----------------------------------------------- -void CTickService::addTock( NLNET::TServiceId serviceId ) -{ - time_t t; time( &t ); - _QuickLog.displayNL( "%s: %u: [<-%hu] TOCK-r", IDisplayer::dateToHumanString(t), getGameCycle(), serviceId.get() ); - if( serviceId.get() < _ClientInfos.size() ) - { - if( _ClientInfos[serviceId.get()].Registered ) - { - if( _ClientInfos[serviceId.get()].TockReceived ) - { - if( _ClientInfos[serviceId.get()].Threshold == 0 ) - { - nlwarning(" Tock received more than once despite a threshold null"); - } - } - else - { - _ClientInfos[serviceId.get()].TockReceived = true; - _QuickLog.displayNL( "%u: [<-%hu] TOCK-p", getGameCycle(), serviceId.get() ); - } - - if( _ClientInfos[serviceId.get()].TockMissingCount > 0 ) - { - _ClientInfos[serviceId.get()].TockMissingCount--; - } - else - { - nlwarning(" Receiving a tock, but there was no tock missing !"); - } - } - else - { - nlwarning("(TICKS) Tock received from service %d which is not registered",serviceId.get()); - } - checkTockReceived(); - } - else - { - nlwarning(" Service id too high : %d (max is %d)", serviceId.get(), _ClientInfos.size()-1); - } - -} // addTock // - - - -//----------------------------------------------- -// checkTockReceived -// -//----------------------------------------------- -void CTickService::checkTockReceived() -{ - // Do not tick if ticking is halted - if (CurrentMode == TickHalted) - return; - - // check if all the tocks have been received (or if missing is less than threshold ) - uint i; - for( i=0; i<_ClientInfos.size(); i++ ) - { - // if this client is supposed to send a tock - if( _ClientInfos[i].Registered ) - { - // if tock was not received yet - if( _ClientInfos[i].TockReceived == false ) - { - // if we have to wait for this client - if( _ClientInfos[i].Tocking == true ) - { - // we check threshold - if( _ClientInfos[i].TockMissingCount > _ClientInfos[i].Threshold ) - { - return; - } - } - } - } - } - - TotalSpeedLoop = (sint32)(CTime::getLocalTime() - BeginOfTickTime); - // set the TickSpeedLoop var to the same value - TickSpeedLoop = TotalSpeedLoop; - MainTimeMeasures.CurrentTickServiceMeasure[PrevTotalTickDuration] = (uint16)TotalSpeedLoop.get(); - //nlinfo( "End of tick at %.6f", CTime::ticksToSecond( CTime::getPerformanceTime() ) ); - - - // Step by step mode - if( TickSendingMode.get() == StepByStep ) - { - if( _StepCount > 0 ) - { - // broadcast the tick - broadcastTick(); - _StepCount--; - } - } - // Continuous or fastest mode - else - { - TLocalTime currentTime = ((double)CTime::getLocalTime())/1000.0; - - SlowestService=SlowestCandidate; - SlowestTock = currentTime - _TickSendTime; - - // if it's the first time we send a tick, we init the tick send time - if( FirstTime ) - { - _TickSendTime = currentTime - _TickTimeStep; - _LastTickTimeStep = _TickTimeStep; - FirstTime = false; - } - - // setup the default value for the time step to use - NLMISC::TLocalTime effectiveTimeStep= _TickTimeStep; - - // if the backup service is taking longer than _TickTimeStep to respond, then we need to slow down to a little slower than its pace -/* NLMISC::TLocalTime lastBSAckDelay= ((NLMISC::TLocalTime)Bsi.getLastAckDelay())/1000.0; - if ((WaitForBSThreshold>=1.0f) && (float)lastBSAckDelay>(float)_TickTimeStep*WaitForBSThreshold) - { - effectiveTimeStep= lastBSAckDelay+ (lastBSAckDelay-_TickTimeStep)/2; - } -*/ - // smooth out BS update rate fluctuations with a simple filter and store away the time step value for next time round - effectiveTimeStep= (effectiveTimeStep+3*_LastTickTimeStep)/4; - _LastTickTimeStep= effectiveTimeStep; - - // if we have to wait before sending tick - while ( ( currentTime < (_TickSendTime + effectiveTimeStep) ) && ( TickSendingMode.get() != Fastest) ) - { - if ( currentTime < _TickSendTime ) - { - nlinfo( "Backward time sync detected (about %.1f s)", _TickSendTime - currentTime ); - _TickSendTime = currentTime; - } - else - { - nlSleep( (uint32)((_TickSendTime + effectiveTimeStep - currentTime)*1000.0) ); - } - currentTime = ((double)CTime::getLocalTime())/1000.0; - } - - // increment the send time - TLocalTime oldTime = _TickSendTime; - _TickSendTime = ((double)CTime::getLocalTime())/1000.0; - double dt = _TickSendTime - oldTime; - - // round off the send time to iron out high frequency effects - if (_TickSendTime1.0) - { - dt = double(uint32(dt*1000.0)/ uint32(effectiveTimeStep*1000.0) * uint32(effectiveTimeStep*1000.0))/1000.0; - _TickSendTime = oldTime + dt; - } - - //nlinfo( " %"NL_I64"u %"NL_I64"u", (TTime)((_TickSendTime-oldTime)*1000), (TTime)((d2-oldTime)*1000) ); - - // broadcast the tick - broadcastTick(); - - // update the tick time step - //updateTickTimeStep - } - -} // checkTockReceived // - - - -//----------------------------------------------- -// broadcastTick -// -//----------------------------------------------- -void CTickService::broadcastTick() -{ - if ( Pause == true ) return; - - MainTimeMeasures.beginNewCycle(); - BeginOfTickTime = CTime::getLocalTime(); - - // increment the game time and cycle - _GameTime += _GameTimeStep; - _GameCycle++; - CTickEventHandler::setGameCycle( _GameCycle ); // to display the good value in the variable - - // we send a tick to every registered client - uint i; - for( i=0; i<_ClientInfos.size(); i++ ) - { - if( _ClientInfos[i].Registered ) - { - CMessage msgout; - if( _GameTimeStepHasChanged ) - { - msgout.setType( "STEP_TICK" ); - msgout.serial( _GameTimeStep ); - _QuickLog.displayNL( "%u: [->%u] STEP_TICK", getGameCycle(), i ); - } - else - { - msgout.setType( "TICK" ); - time_t t; time( &t ); - _QuickLog.displayNL( "%s: %u: [->%u] TICK", IDisplayer::dateToHumanString(t), getGameCycle(), i ); - } - - CUnifiedNetwork::getInstance()->send(NLNET::TServiceId(i),msgout); - TSockId host; - CCallbackNetBase *cnb; - cnb = CUnifiedNetwork::getInstance()->getNetBase(NLNET::TServiceId(i),host); - if( cnb ) - { - cnb->flush( host ); - } - // we are now waiting for a tick from this client - _ClientInfos[i].TockReceived = false; - _ClientInfos[i].TockMissingCount++; - } - } - _GameTimeStepHasChanged = false; - - CSingletonRegistry::getInstance()->tickUpdate(); -} // broadcastTick // - - - -//----------------------------------------------- -// cbClientDisconnection -// -//----------------------------------------------- -void cbClientDisconnection( const std::string &serviceName, NLNET::TServiceId serviceId, void *arg) -{ - TS->unregisterClient( serviceId ); - TS->checkTockReceived(); - -} // cbClientDisconnection // - - - -//----------------------------------------------- -// unregisterClient -// -//----------------------------------------------- -void CTickService::unregisterClient( NLNET::TServiceId serviceId ) -{ - if( serviceId.get() < _ClientInfos.size() ) - { - if ( _ClientInfos[serviceId.get()].Registered ) - { - _ClientInfos[serviceId.get()].Registered = false; - _ClientInfos[serviceId.get()].TockReceived = true; - _ClientInfos[serviceId.get()].Tocking = true; - _ClientInfos[serviceId.get()].Threshold = 0; - _ClientInfos[serviceId.get()].TockMissingCount = 0; - _QuickLog.displayNL( "%u: -%hu", getGameCycle(), serviceId.get() ); - } - else - { - nlinfo(" Service %d disconnection detected but this service is not registered : nothing to do",serviceId.get()); - } - } - else - { - nlwarning(" Service %d : service id too big ! (max is %d)",serviceId.get(),_ClientInfos.size()-1); - } - -} // unregisterClient // - - - -//----------------------------------------------- -// getClientCount -// -//----------------------------------------------- -uint16 CTickService::getClientCount() -{ - uint16 clientCount = 0; - - uint i; - for( i=0; i<_ClientInfos.size(); i++ ) - { - if( _ClientInfos[i].Registered ) - { - clientCount++; - } - } - - return clientCount; - -} // getClientCount // - - - -//----------------------------------------------- -// displayGameTime() -// -//----------------------------------------------- -void CTickService::displayGameTime() const -{ - CMessage msgout( "DISPLAY_TIME" ); - uint i; - for( i=0; i<_ClientInfos.size(); i++ ) - { - if( _ClientInfos[i].Registered ) - { - CUnifiedNetwork::getInstance()->send(NLNET::TServiceId(i),msgout); - } - } - - nlinfo("(TICKS) : Game time in the Tick Service : %f sec (local: %f ms)", (double)_GameTime,(double)CTime::getLocalTime()); - -} // displayGameTime // - - - - - -/* - * Initialise the service - */ -void CTickService::init() -{ - setVersion (RYZOM_VERSION); - - CurrentMode = TickRunning; - - CSingletonRegistry::getInstance()->init(); - - // keep pointer on class - TS = this; - - _StepCount = 1; - - // maximum 256 clients can be connected - _ClientInfos.resize(256); - - - try - { - _GameTime = ConfigFile.getVar("GameTime").asFloat(); - } - catch(const Exception &) - { - // init the game time - _GameTime = 0.0f; - } - - try - { - _GameCycle = ConfigFile.getVar("GameCycle").asInt(); - _SavedGameCycle = _GameCycle; - } - catch(const Exception &) - { - // init the game cycle from file - loadGameCycle(); - } - CTickEventHandler::setGameCycle( _GameCycle ); // to display the good value in the variable - - try - { - _TickTimeStep = ConfigFile.getVar("TickTimeStep").asFloat(); - } - catch(const Exception &) - { - // tick service time step between two ticks - _TickTimeStep = 0.1f; - } - - try - { - _GameTimeStep = ConfigFile.getVar("GameTimeStep").asFloat(); - } - catch(const Exception &) - { - // game time between two ticks - _GameTimeStep = 0.1f; - } - - // thus the time step will be sent along with the first tick - _GameTimeStepHasChanged = true; - - // local time when last tick was sent - _TickSendTime = 0; - FirstTime = true; - - CUnifiedNetwork::getInstance()->setServiceDownCallback("*", cbClientDisconnection, NULL); - - RecentHistory.setParam( 20 ); - _QuickLog.addDisplayer( &RecentHistory, false ); - - _RangeMirrorManager.init(); - -} // init // - - -/* - * Release - */ -void CTickService::release() -{ - - if ( saveGameCycle() ) - { -// nlinfo( "Game cycle %u saved to %s", _GameCycle, GAME_CYCLE_FILE.c_str() ); - } - - CSingletonRegistry::getInstance()->release(); -} - - -/* - * Update - */ -bool CTickService::update() -{ - CSingletonRegistry::getInstance()->serviceUpdate(); - - if (CurrentMode == TickHalted) - { - WaitingForServices = "TICK HALTED: "+HaltedReason; - } - else - { - WaitingForServices = ""; - // check if all the tocks have been received (or if missing is less than threshold ) - uint i; - for( i=0; i<_ClientInfos.size(); i++ ) - { - // if this client is supposed to send a tock - if( _ClientInfos[i].Registered ) - { - // if tock was not received yet - if( _ClientInfos[i].TockReceived == false ) - { - // if we have to wait for this client - if( _ClientInfos[i].Tocking == true ) - { - // we check threshold - if( _ClientInfos[i].TockMissingCount > _ClientInfos[i].Threshold ) - { - WaitingForServices += toString(i) + " "; - } - } - } - } - } - - // don't saveGameCycle if tick halted - // because BS probably sent an error report, and it would be hazardous - // to send BS new commands!! - if ( _GameCycle > _SavedGameCycle + INTERVAL_FOR_SAVING_GAME_CYCLE ) - { - saveGameCycle(); - } - } - - return true; -} - - -/* - * Save to file - */ -bool CTickService::saveGameCycle() -{ - _SavedGameCycle = _GameCycle; // do it anyway - try - { - CBackupMsgSaveFile msg( GAME_CYCLE_FILE, CBackupMsgSaveFile::SaveFile, Bsi ); - msg.DataMsg.serialVersion( 0 ); - msg.DataMsg.serial( _GameCycle ); - Bsi.sendFile(msg); - -/* - COFile file; - if ( file.open( SaveShardRoot.get() + IService::getInstance()->SaveFilesDirectory.toString() + GAME_CYCLE_FILE ) ) - { - file.serialVersion( 0 ); - file.serial( _GameCycle ); - file.close(); - } - else - throw EFileNotOpened( SaveShardRoot.get() + IService::getInstance()->SaveFilesDirectory.toString() + GAME_CYCLE_FILE ); - return true; -*/ - return true; - } - catch (const Exception &e) - { - nlwarning( "Can't save game cycle: %s", e.what() ); - return false; - } -} - -struct TTickFileCallback : public IBackupFileReceiveCallback -{ - CTickService *TickService; - TTickFileCallback(CTickService *tickService) - : TickService(tickService) - { - } - - virtual void callback(const CFileDescription& fileDescription, NLMISC::IStream& dataStream) - { - TickService->tickFileCallback(fileDescription, dataStream); - } - -}; - -void CTickService::tickFileCallback(const CFileDescription& fileDescription, NLMISC::IStream& dataStream) -{ - if (!fileDescription.FileName.empty()) - { - dataStream.serialVersion( 0 ); - dataStream.serial( _GameCycle ); - _SavedGameCycle = _GameCycle; - } - else - { - _GameCycle = 0; - _SavedGameCycle = 0; - nlwarning("No tick file found, starting with fresh tick"); - } -} - -/* - * Load from file - */ -bool CTickService::loadGameCycle() -{ - TTickFileCallback *cb = new TTickFileCallback(this); - Bsi.syncLoadFile(GAME_CYCLE_FILE, cb); - - return true; - -// try -// { -// CIFile file; -// if ( file.open( Bsi.getLocalPath() + GAME_CYCLE_FILE ) ) -// { -// file.serialVersion( 0 ); -// file.serial( _GameCycle ); -// file.close(); -// _SavedGameCycle = _GameCycle; -// } -// else -// throw EFileNotOpened( Bsi.getLocalPath() + GAME_CYCLE_FILE ); -// nlinfo( "Loaded game cycle %u from %s, will be saved every %u game cycles", _GameCycle, (CPath::standardizePath(IService::getInstance()->SaveFilesDirectory.toString()) + GAME_CYCLE_FILE).c_str(), INTERVAL_FOR_SAVING_GAME_CYCLE ); -// return true; -// } -// catch (const Exception &e) -// { -// nlwarning( "Can't load game cycle: %s", e.what() ); -// _GameCycle = 0; -// _SavedGameCycle = _GameCycle; -// return false; -// } -} - - -/* - * - */ -CTickServiceGameCycleTimeMeasure::CTickServiceGameCycleTimeMeasure() : HistoryMain( CTickService::getInstance()->getServiceId(), NLNET::TServiceId(~0), false ) {} - - -/* - * - */ -void CTickServiceGameCycleTimeMeasure::beginNewCycle() -{ - if ( ! CurrentMirrorMeasures.empty() ) - { - // Update stats - for ( TMirrorMeasures::const_iterator imm=CurrentMirrorMeasures.begin(); imm!=CurrentMirrorMeasures.end(); ++imm ) - { - storeMeasureToHistory( HistoryByMirror, imm->MirrorMeasure, imm->MSId, TServiceId(0) ); - - for ( std::vector::const_iterator ism=(*imm).ServiceMeasures.begin(); ism!=(*imm).ServiceMeasures.end(); ++ism ) - { - storeMeasureToHistory( HistoryByService, (*ism).ServiceMeasure, (*ism).ClientServiceId, (*imm).MSId ); - } - } - - //nlinfo( "AV: C=%hu H=%hu", CurrentTickServiceMeasure[0], HistoryMain.Stats[MHTMax][0] ); - HistoryMain.updateStats( CurrentTickServiceMeasure ); - //nlinfo( "AP: C=%hu H=%hu", CurrentTickServiceMeasure[0], HistoryMain.Stats[MHTMax][0] ); - - // Clear current - CurrentMirrorMeasures.clear(); - } -} - - - -/* - * - */ -void CTickServiceGameCycleTimeMeasure::resetMeasures() -{ - HistoryByMirror.clear(); - HistoryByService.clear(); - HistoryMain.reset( false ); -} - - -/* - * - */ -void CTickServiceGameCycleTimeMeasure::displayStats( NLMISC::CLog *log ) -{ - log->displayNL( "Shard timings at GC %u:", CTickEventHandler::getGameCycle() ); - log->displayRawNL( "___AVG__" ); - displayStat( log, MHTSum ); - log->displayRawNL( "___MAX___" ); - displayStat( log, MHTMax ); - log->displayRawNL( "___MIN___" ); - displayStat( log, MHTMin ); -} - - - - -const char * ServiceTimeMeasureTypeToCString [NbServiceTimeMeasureTypes] = -{ "TickTockInterval", "TickUpdateDuration", "PrevProcessMirrorUpdateDuration", "PrevReceiveMsgsViaMirrorDuration", "PrevTotalGameCycleDuration" }; - -const char * MirrorTimeMeasureTypeToCString [NbMirrorTimeMeasureTypes] = -{ "WaitAllReceivedDeltaDuration", "BuildAndSendDeltaDuration", "PrevApplyReceivedDeltaDuration", "PrevSendUMMDuration" }; - -const char * TickServiceTimeMeasureTypeToCString [NbTickServiceTimeMeasureTypes] = -{ "PrevTotalTickDuration" }; - - -/* - * - */ -void CTickServiceGameCycleTimeMeasure::displayStat( NLMISC::CLog *log, TTimeMeasureHistoryStat stat ) -{ - log->displayRawNL( "\tTICKS, %u measures:", HistoryMain.NbMeasures ); - uint divideBy = (HistoryMain.NbMeasures==0) ? 0 : ((stat==MHTSum) ? HistoryMain.NbMeasures : 1); - HistoryMain.Stats[stat].displayStat( log, TickServiceTimeMeasureTypeToCString, divideBy ); - { - CMirrorTimeMeasure gatheredStats [NbTimeMeasureHistoryStats] = { 0, ~0, 0 }; - for ( std::vector::const_iterator ihm=HistoryByMirror.begin(); ihm!=HistoryByMirror.end(); ++ihm ) - { - log->displayRawNL( "\tMS-%hu, %u measures:", (*ihm).ServiceId.get(), (*ihm).NbMeasures ); - divideBy = (stat==MHTSum) ? (*ihm).NbMeasures : 1; - (*ihm).Stats[stat].displayStat( log, MirrorTimeMeasureTypeToCString, divideBy ); - gatheredStats[MHTSum] += (*ihm).Stats[stat] / (*ihm).NbMeasures; - gatheredStats[MHTMin].copyLowerValues( (*ihm).Stats[stat] ); - gatheredStats[MHTMax].copyHigherValues( (*ihm).Stats[stat] ); - } - if ( HistoryByMirror.size() > 1 ) - { - log->displayRawNL( "\tAll mirror services:" ); - gatheredStats[stat].displayStat( log, MirrorTimeMeasureTypeToCString, (stat==MHTSum) ? (uint)HistoryByMirror.size() : 1 ); // not displaying the 3 stats - } - } - { - CServiceTimeMeasure gatheredStats [NbTimeMeasureHistoryStats] = { 0, ~0, 0 }; - for ( std::vector::const_iterator ihs=HistoryByService.begin(); ihs!=HistoryByService.end(); ++ihs ) - { - log->displayRawNL( "\t%s (on MS-%hu), %u measures:", CUnifiedNetwork::getInstance()->getServiceUnifiedName( (*ihs).ServiceId ).c_str(), (*ihs).ParentServiceId.get(), (*ihs).NbMeasures ); - divideBy = (stat==MHTSum) ? (*ihs).NbMeasures : 1; - (*ihs).Stats[stat].displayStat( log, ServiceTimeMeasureTypeToCString, divideBy ); - gatheredStats[MHTSum] += (*ihs).Stats[stat] / (*ihs).NbMeasures; - gatheredStats[MHTMin].copyLowerValues( (*ihs).Stats[stat] ); - gatheredStats[MHTMax].copyHigherValues( (*ihs).Stats[stat] ); - } - if ( HistoryByService.size() > 1 ) - { - log->displayRawNL( "\tAll client services:" ); - gatheredStats[stat].displayStat( log, ServiceTimeMeasureTypeToCString, (stat==MHTSum) ? (uint)HistoryByService.size() : 1 ); // not displaying the 3 stats - } - } -} - - -//----------------------------------------------- -// NLNET_SERVICE_MAIN -//----------------------------------------------- -NLNET_SERVICE_MAIN( CTickService, "TICKS", "tick_service", 0, CbArray, "", "" ); - - -// -// Variables -// - -NLMISC_VARIABLE(NLNET::TServiceId, SlowestService, "SId of the slowest service"); - -NLMISC_VARIABLE(double, SlowestTock, "Time in millisecond to receive the slowest tock"); - -NLMISC_VARIABLE(string, WaitingForServices, "Services that haven't tocked yet"); - -NLMISC_DYNVARIABLE(TGameTime, GameTime, "Current game time in second") -{ - if (get) *pointer = TS->getGameTime(); -} - -NLMISC_DYNVARIABLE(TLocalTime, TickTimeStep, "Current tick time step in second") -{ - if (get) *pointer = TS->getTickTimeStep(); - else TS->setTickTimeStep(*pointer); -} - -NLMISC_DYNVARIABLE(string, TickMode, "Current ticking mode") -{ - if (get) - { - if (TS->CurrentMode == CTickService::TickRunning) - *pointer = "Normal"; - else - *pointer = "HALTED: "+TS->HaltedReason; - } -} - - -// -// Commands -// - -NLMISC_COMMAND(haltTick, "Halt tick server", "[reason]" ) -{ - if (args.size() > 1) - return false; - - log.displayNL("TICK SERVICE HALTED MANUALLY."); - log.displayNL("PLEASE RESTART TICK SERVICE USING resumeTick COMMAND."); - - std::string reason = "MANUAL HALT"; - if (args.size() == 1) - reason += ": "+args[0]; - - TS->haltTick(reason); - return true; -} - -NLMISC_COMMAND(resumeTick, "Resume tick server", "" ) -{ - log.displayNL("TICK SERVICE RESUMED MANUALLY."); - TS->resumeTick(); - return true; -} - - -NLMISC_COMMAND(displayTimingsOfShard, "Display all timings", "" ) -{ - TS->MainTimeMeasures.displayStats( &log ); - return true; -} - -NLMISC_COMMAND(resetTimingsOfShard, "Reset all timings", "" ) -{ - TS->MainTimeMeasures.resetMeasures(); - return true; -} - -NLMISC_COMMAND(displayGameTime, "The tick service and all connected services display its current game time", "") -{ - TS->displayGameTime(); - return true; - -} - -NLMISC_COMMAND(send,"enable send (in the step by step mode)"," ") -{ - TS->enableSend(); - return true; - -} - -NLMISC_COMMAND(clients,"Give the number of clients"," ") -{ - log.displayNL("Number of connected client : %d", TS->getClientCount()); - return true; - -} - -/* -NLMISC_COMMAND(getServicesState,"Give the current state of all services"," ") -{ -// todo end the code - uint i; - for( i=0; i<_ClientInfos.size(); i++ ) - { - // if this client is supposed to send a tock - if( _ClientInfos[i].Registered ) - { - // if tock was not received yet - if( _ClientInfos[i].TockReceived == false ) - { - // if we have to wait for this client - if( _ClientInfos[i].Tocking == true ) - { - // we check threshold - if( _ClientInfos[i].TockMissingCount > _ClientInfos[i].Threshold ) - { - return; - } - } - } - } - } - return true; -} -*/ - - -NLMISC_COMMAND(displayRecentHistory,"Display the history of tick events","") -{ - TS->RecentHistory.write( &log ); - return true; -} - -NLMISC_COMMAND( pause, "Pause the tick service", "" ) -{ - Pause = !Pause; - if( Pause ) - nlinfo("Pause On"); - else - { - nlinfo("Pause Off"); - TS->checkTockReceived(); - } - return true; -} - - - - -/* - */ - -/* -// ADDED by ben: BS test purpose, you can remove this -NLMISC_COMMAND( sendFileBS, "send file to BS", " ") -{ - if (args.size() != 2) - return false; - - CIFile fi; - - if (!fi.open(args[0])) - return false; - - std::vector buffer(fi.getFileSize()); - fi.serialBuffer(&(buffer[0]), buffer.size()); - - CBackupMsgSaveFile msgSave; - msgSave.Data.serialBuffer(&(buffer[0]), buffer.size()); - msgSave.FileName = args[1]; - - Bsi.sendFile(msgSave); - - return true; -} - -NLMISC_COMMAND( sendFileAndCheckBS, "send file to BS", " ") -{ - if (args.size() != 2) - return false; - - CIFile fi; - - if (!fi.open(args[0])) - return false; - - std::vector buffer(fi.getFileSize()); - fi.serialBuffer(&(buffer[0]), buffer.size()); - - CBackupMsgSaveFile msgSave; - msgSave.Data.serialBuffer(&(buffer[0]), buffer.size()); - msgSave.FileName = args[1]; - - Bsi.sendFile(msgSave, true); - - return true; -} - -NLMISC_COMMAND( appendFileBS, "append file to BS", " ") -{ - if (args.size() != 2) - return false; - - CIFile fi; - - if (!fi.open(args[0])) - return false; - - std::vector buffer(fi.getFileSize()); - fi.serialBuffer(&(buffer[0]), buffer.size()); - - CBackupMsgSaveFile msgSave; - msgSave.Data.serialBuffer(&(buffer[0]), buffer.size()); - msgSave.FileName = args[1]; - - Bsi.append(msgSave); - - return true; -} - -NLMISC_COMMAND( appendLineBS, "append line to file via BS", " ") -{ - if (args.size() != 2) - return false; - - Bsi.append(args[0], args[1]); - - return true; -} - -NLMISC_COMMAND( deleteFileBS, "delete file via BS", " [backup file]") -{ - if (args.size() < 1 || args.size() > 2) - return false; - - bool backupFile = false; - - if (args.size() == 2) - { - NLMISC::fromString(args[1], backupFile); - } - - Bsi.deleteFile(args[0], backupFile); - - return true; -} - - -class CFileReceiveCb: public IBackupFileReceiveCallback -{ -public: - - virtual void callback(const CFileDescription& fileDescription, NLMISC::IStream& dataStream) - { - nlinfo("received file '%s'", fileDescription.FileName.c_str()); - } - -}; - -NLMISC_COMMAND( loadFileBS, "load a file from BS", "") -{ - if (args.size() != 1) - return false; - - Bsi.requestFile(args[0], new CFileReceiveCb()); - - return true; -} -*/ - - -class CFileClassReceiveCb: public IBackupFileClassReceiveCallback -{ -public: - - virtual void callback(const CFileDescriptionContainer& list) - { - nlinfo("received fileclass"); - uint i; - for (i=0; i ") -{ - if (args.size() <= 1) - return false; - - std::string directory; - std::vector classes; - CBackupFileClass bclass; - - directory = args[0]; - - uint i; - for (i=1; i +// 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/command.h" +#include "nel/misc/variable.h" +#include "nel/misc/common.h" +#include "nel/misc/file.h" + +#include "game_share/ryzom_version.h" +#include "game_share/tick_event_handler.h" +#include "game_share/backup_service_interface.h" +#include "game_share/singleton_registry.h" +#include + +#include "tick_service.h" +#include + +#ifdef NL_OS_WINDOWS +# define NOMINMAX +# include +#endif // NL_OS_WINDOWS + +using namespace std; +using namespace NLMISC; +using namespace NLNET; + +// force admin module to link in +extern void admin_modules_forceLink(); +void foo() +{ + admin_modules_forceLink(); +} + + +CTickService * TS = NULL; + +NLNET::TServiceId SlowestService(0); +NLNET::TServiceId SlowestCandidate(0); +double SlowestTock = 0.0; +string WaitingForServices; + +const string GAME_CYCLE_FILE = "game_cycle.ticks"; + +const NLMISC::TGameCycle INTERVAL_FOR_SAVING_GAME_CYCLE = 300; + +// when true the tick service stops broadcasting ticks +bool Pause = false; + +// In the Tick Service, set TotalSpeedLoop to the duration of a whole tick cycle +// (between send tick and the last tock received) +extern CVariable TotalSpeedLoop; +extern CVariable TickSpeedLoop; + +static NLMISC::TTime BeginOfTickTime = 0; + +CVariable TickSendingMode( "tick", "TickSendingMode", "0=Continuous 1=StepByStep 2=Fastest", 0, + 0, true ); + +/*CVariable WaitForBSThreshold( "tick", "WaitForBSThreshold", "Threshold for BSAckDelay beyond which tick starts to slow down to wait for BS (expressed as a factor of _TickTimeStep)", 1.0f, + 0, true ); +*/ + +//----------------------------------------------- +// cbRegister +// +//----------------------------------------------- +static void cbRegister(CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId) +{ + if( serviceId.get() > 255 ) + { + nlwarning(" Service %s id is too higher than 255 : %d, this service will be not registered",serviceName.c_str(),serviceId.get()); + return; + } + + bool tocking = true; + uint16 threshold = 0; + msgin.serial( tocking ); + msgin.serial( threshold ); + TS->registerClient( serviceId, tocking, threshold ); + + CMessage msgout( "REGISTERED" ); + TGameTime gameTime = TS->getGameTime(); + TGameTime gameTimeStep = TS->getGameTimeStep(); + TGameCycle gameCycle = TS->getGameCycle(); + + msgout.serial( gameTime ); + msgout.serial( gameTimeStep ); + msgout.serial( gameCycle ); + + CUnifiedNetwork::getInstance()->send(serviceId,msgout); + + if( TS->getClientCount() == 1 ) + { + TS->FirstTime = true; + BeginOfTickTime = CTime::getLocalTime(); + TS->checkTockReceived(); + } + +} // cbRegister // + + + +//----------------------------------------------- +// cbTock +// +//----------------------------------------------- +static void cbTock(CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId) +{ + // Receive measures of client service + TS->MainTimeMeasures.CurrentMirrorMeasures.push_back( CMirrorGameCycleTimeMeasureMS() ); + CMirrorGameCycleTimeMeasureMS& mm = TS->MainTimeMeasures.CurrentMirrorMeasures.back(); + msgin.serial( mm ); + mm.MSId = serviceId; + + // Process Tock + //nlinfo( "TOCK rcvd at %.6f", CTime::ticksToSecond( CTime::getPerformanceTime() ) ); + SlowestCandidate=serviceId; + TS->addTock( serviceId ); + +} // cbTock // + + + + +//----------------------------------------------- +// cbHaltTick +// +//----------------------------------------------- +static void cbHaltTick(CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId) +{ + std::string reason = ""; + + try + { + msgin.serial(reason); + } + catch(const Exception&) + { + } + + reason = toString("service %s:%d halted: %s", serviceName.c_str(), serviceId.get(), reason.c_str()); + + TS->haltTick(reason); + +} // cbHaltTick // + +//----------------------------------------------- +// cbResumeTick +// +//----------------------------------------------- +static void cbResumeTick(CMessage& msgin, const string &serviceName, NLNET::TServiceId serviceId) +{ + TS->resumeTick(); + +} // cbHaltTick // + + +//----------------------------------------------- +// callback table for input message +// +//----------------------------------------------- +TUnifiedCallbackItem CbArray[] = +{ + { "REGISTER", cbRegister }, + { "TOCK", cbTock }, + + { "HALT_TICK", cbHaltTick }, + { "RESUME_TICK", cbResumeTick }, +}; + + +/* + * halt ticking + */ +void CTickService::haltTick(const std::string& reason) +{ + if (CurrentMode == TickHalted) + return; + + CurrentMode = TickHalted; + + nlwarning("***********************************************************"); + nlwarning("WARNING:"); + nlwarning("TICK SERVICE IS ENTERING HALTED MODE"); + nlwarning("HALT REQUEST IS '%s'", reason.c_str()); + nlwarning("***********************************************************"); + + HaltedReason = reason; + + IService::setCurrentStatus("HALTED"); +} + +/* + * resume ticking + */ +void CTickService::resumeTick() +{ + if (CurrentMode == TickRunning) + return; + + // restart ticking + CurrentMode = TickRunning; + + nlwarning("***********************************************************"); + nlwarning("WARNING:"); + nlwarning("TICK SERVICE IS RESUMED"); + nlwarning("HALT REQUEST WAS '%s'", HaltedReason.c_str()); + nlwarning("***********************************************************"); + + // check in case tocks were received during halt + checkTockReceived(); + + IService::clearCurrentStatus("HALTED"); +} + + + +//----------------------------------------------- +// registerClient +// +//----------------------------------------------- +void CTickService::registerClient( NLNET::TServiceId serviceId, bool tocking, uint16 threshold ) +{ + if( serviceId.get() < _ClientInfos.size() ) + { + if( _ClientInfos[serviceId.get()].Registered == true ) + { + nlerror(" The service %d is alredy registered",serviceId.get()); + } + + _ClientInfos[serviceId.get()].Registered = true; + _ClientInfos[serviceId.get()].Tocking = tocking; + _ClientInfos[serviceId.get()].Threshold = threshold; + _QuickLog.displayNL( "%u: +%hu", getGameCycle(), serviceId.get() ); + } + else + { + nlwarning(" Service id too high : %d (max is %d)",serviceId.get(),_ClientInfos.size()-1); + } + +} // registerClient // + + + +//----------------------------------------------- +// addTock +// +//----------------------------------------------- +void CTickService::addTock( NLNET::TServiceId serviceId ) +{ + time_t t; time( &t ); + _QuickLog.displayNL( "%s: %u: [<-%hu] TOCK-r", IDisplayer::dateToHumanString(t), getGameCycle(), serviceId.get() ); + if( serviceId.get() < _ClientInfos.size() ) + { + if( _ClientInfos[serviceId.get()].Registered ) + { + if( _ClientInfos[serviceId.get()].TockReceived ) + { + if( _ClientInfos[serviceId.get()].Threshold == 0 ) + { + nlwarning(" Tock received more than once despite a threshold null"); + } + } + else + { + _ClientInfos[serviceId.get()].TockReceived = true; + _QuickLog.displayNL( "%u: [<-%hu] TOCK-p", getGameCycle(), serviceId.get() ); + } + + if( _ClientInfos[serviceId.get()].TockMissingCount > 0 ) + { + _ClientInfos[serviceId.get()].TockMissingCount--; + } + else + { + nlwarning(" Receiving a tock, but there was no tock missing !"); + } + } + else + { + nlwarning("(TICKS) Tock received from service %d which is not registered",serviceId.get()); + } + checkTockReceived(); + } + else + { + nlwarning(" Service id too high : %d (max is %d)", serviceId.get(), _ClientInfos.size()-1); + } + +} // addTock // + + + +//----------------------------------------------- +// checkTockReceived +// +//----------------------------------------------- +void CTickService::checkTockReceived() +{ + // Do not tick if ticking is halted + if (CurrentMode == TickHalted) + return; + + // check if all the tocks have been received (or if missing is less than threshold ) + uint i; + for( i=0; i<_ClientInfos.size(); i++ ) + { + // if this client is supposed to send a tock + if( _ClientInfos[i].Registered ) + { + // if tock was not received yet + if( _ClientInfos[i].TockReceived == false ) + { + // if we have to wait for this client + if( _ClientInfos[i].Tocking == true ) + { + // we check threshold + if( _ClientInfos[i].TockMissingCount > _ClientInfos[i].Threshold ) + { + return; + } + } + } + } + } + + TotalSpeedLoop = (sint32)(CTime::getLocalTime() - BeginOfTickTime); + // set the TickSpeedLoop var to the same value + TickSpeedLoop = TotalSpeedLoop; + MainTimeMeasures.CurrentTickServiceMeasure[PrevTotalTickDuration] = (uint16)TotalSpeedLoop.get(); + //nlinfo( "End of tick at %.6f", CTime::ticksToSecond( CTime::getPerformanceTime() ) ); + + + // Step by step mode + if( TickSendingMode.get() == StepByStep ) + { + if( _StepCount > 0 ) + { + // broadcast the tick + broadcastTick(); + _StepCount--; + } + } + // Continuous or fastest mode + else + { + TLocalTime currentTime = ((double)CTime::getLocalTime())/1000.0; + + SlowestService=SlowestCandidate; + SlowestTock = currentTime - _TickSendTime; + + // if it's the first time we send a tick, we init the tick send time + if( FirstTime ) + { + _TickSendTime = currentTime - _TickTimeStep; + _LastTickTimeStep = _TickTimeStep; + FirstTime = false; + } + + // setup the default value for the time step to use + NLMISC::TLocalTime effectiveTimeStep= _TickTimeStep; + + // if the backup service is taking longer than _TickTimeStep to respond, then we need to slow down to a little slower than its pace +/* NLMISC::TLocalTime lastBSAckDelay= ((NLMISC::TLocalTime)Bsi.getLastAckDelay())/1000.0; + if ((WaitForBSThreshold>=1.0f) && (float)lastBSAckDelay>(float)_TickTimeStep*WaitForBSThreshold) + { + effectiveTimeStep= lastBSAckDelay+ (lastBSAckDelay-_TickTimeStep)/2; + } +*/ + // smooth out BS update rate fluctuations with a simple filter and store away the time step value for next time round + effectiveTimeStep= (effectiveTimeStep+3*_LastTickTimeStep)/4; + _LastTickTimeStep= effectiveTimeStep; + + // if we have to wait before sending tick + while ( ( currentTime < (_TickSendTime + effectiveTimeStep) ) && ( TickSendingMode.get() != Fastest) ) + { + if ( currentTime < _TickSendTime ) + { + nlinfo( "Backward time sync detected (about %.1f s)", _TickSendTime - currentTime ); + _TickSendTime = currentTime; + } + else + { + nlSleep( (uint32)((_TickSendTime + effectiveTimeStep - currentTime)*1000.0) ); + } + currentTime = ((double)CTime::getLocalTime())/1000.0; + } + + // increment the send time + TLocalTime oldTime = _TickSendTime; + _TickSendTime = ((double)CTime::getLocalTime())/1000.0; + double dt = _TickSendTime - oldTime; + + // round off the send time to iron out high frequency effects + if (_TickSendTime1.0) + { + dt = double(uint32(dt*1000.0)/ uint32(effectiveTimeStep*1000.0) * uint32(effectiveTimeStep*1000.0))/1000.0; + _TickSendTime = oldTime + dt; + } + + //nlinfo( " %"NL_I64"u %"NL_I64"u", (TTime)((_TickSendTime-oldTime)*1000), (TTime)((d2-oldTime)*1000) ); + + // broadcast the tick + broadcastTick(); + + // update the tick time step + //updateTickTimeStep + } + +} // checkTockReceived // + + + +//----------------------------------------------- +// broadcastTick +// +//----------------------------------------------- +void CTickService::broadcastTick() +{ + if ( Pause == true ) return; + + MainTimeMeasures.beginNewCycle(); + BeginOfTickTime = CTime::getLocalTime(); + + // increment the game time and cycle + _GameTime += _GameTimeStep; + _GameCycle++; + CTickEventHandler::setGameCycle( _GameCycle ); // to display the good value in the variable + + // we send a tick to every registered client + uint i; + for( i=0; i<_ClientInfos.size(); i++ ) + { + if( _ClientInfos[i].Registered ) + { + CMessage msgout; + if( _GameTimeStepHasChanged ) + { + msgout.setType( "STEP_TICK" ); + msgout.serial( _GameTimeStep ); + _QuickLog.displayNL( "%u: [->%u] STEP_TICK", getGameCycle(), i ); + } + else + { + msgout.setType( "TICK" ); + time_t t; time( &t ); + _QuickLog.displayNL( "%s: %u: [->%u] TICK", IDisplayer::dateToHumanString(t), getGameCycle(), i ); + } + + CUnifiedNetwork::getInstance()->send(NLNET::TServiceId(i),msgout); + TSockId host; + CCallbackNetBase *cnb; + cnb = CUnifiedNetwork::getInstance()->getNetBase(NLNET::TServiceId(i),host); + if( cnb ) + { + cnb->flush( host ); + } + // we are now waiting for a tick from this client + _ClientInfos[i].TockReceived = false; + _ClientInfos[i].TockMissingCount++; + } + } + _GameTimeStepHasChanged = false; + + CSingletonRegistry::getInstance()->tickUpdate(); +} // broadcastTick // + + + +//----------------------------------------------- +// cbClientDisconnection +// +//----------------------------------------------- +void cbClientDisconnection( const std::string &serviceName, NLNET::TServiceId serviceId, void *arg) +{ + TS->unregisterClient( serviceId ); + TS->checkTockReceived(); + +} // cbClientDisconnection // + + + +//----------------------------------------------- +// unregisterClient +// +//----------------------------------------------- +void CTickService::unregisterClient( NLNET::TServiceId serviceId ) +{ + if( serviceId.get() < _ClientInfos.size() ) + { + if ( _ClientInfos[serviceId.get()].Registered ) + { + _ClientInfos[serviceId.get()].Registered = false; + _ClientInfos[serviceId.get()].TockReceived = true; + _ClientInfos[serviceId.get()].Tocking = true; + _ClientInfos[serviceId.get()].Threshold = 0; + _ClientInfos[serviceId.get()].TockMissingCount = 0; + _QuickLog.displayNL( "%u: -%hu", getGameCycle(), serviceId.get() ); + } + else + { + nlinfo(" Service %d disconnection detected but this service is not registered : nothing to do",serviceId.get()); + } + } + else + { + nlwarning(" Service %d : service id too big ! (max is %d)",serviceId.get(),_ClientInfos.size()-1); + } + +} // unregisterClient // + + + +//----------------------------------------------- +// getClientCount +// +//----------------------------------------------- +uint16 CTickService::getClientCount() +{ + uint16 clientCount = 0; + + uint i; + for( i=0; i<_ClientInfos.size(); i++ ) + { + if( _ClientInfos[i].Registered ) + { + clientCount++; + } + } + + return clientCount; + +} // getClientCount // + + + +//----------------------------------------------- +// displayGameTime() +// +//----------------------------------------------- +void CTickService::displayGameTime() const +{ + CMessage msgout( "DISPLAY_TIME" ); + uint i; + for( i=0; i<_ClientInfos.size(); i++ ) + { + if( _ClientInfos[i].Registered ) + { + CUnifiedNetwork::getInstance()->send(NLNET::TServiceId(i),msgout); + } + } + + nlinfo("(TICKS) : Game time in the Tick Service : %f sec (local: %f ms)", (double)_GameTime,(double)CTime::getLocalTime()); + +} // displayGameTime // + + + + + +/* + * Initialise the service + */ +void CTickService::init() +{ + setVersion (RYZOM_VERSION); + + CurrentMode = TickRunning; + + CSingletonRegistry::getInstance()->init(); + + // keep pointer on class + TS = this; + + _StepCount = 1; + + // maximum 256 clients can be connected + _ClientInfos.resize(256); + + + try + { + _GameTime = ConfigFile.getVar("GameTime").asFloat(); + } + catch(const Exception &) + { + // init the game time + _GameTime = 0.0f; + } + + try + { + _GameCycle = ConfigFile.getVar("GameCycle").asInt(); + _SavedGameCycle = _GameCycle; + } + catch(const Exception &) + { + // init the game cycle from file + loadGameCycle(); + } + CTickEventHandler::setGameCycle( _GameCycle ); // to display the good value in the variable + + try + { + _TickTimeStep = ConfigFile.getVar("TickTimeStep").asFloat(); + } + catch(const Exception &) + { + // tick service time step between two ticks + _TickTimeStep = 0.1f; + } + + try + { + _GameTimeStep = ConfigFile.getVar("GameTimeStep").asFloat(); + } + catch(const Exception &) + { + // game time between two ticks + _GameTimeStep = 0.1f; + } + + // thus the time step will be sent along with the first tick + _GameTimeStepHasChanged = true; + + // local time when last tick was sent + _TickSendTime = 0; + FirstTime = true; + + CUnifiedNetwork::getInstance()->setServiceDownCallback("*", cbClientDisconnection, NULL); + + RecentHistory.setParam( 20 ); + _QuickLog.addDisplayer( &RecentHistory, false ); + + _RangeMirrorManager.init(); + +} // init // + + +/* + * Release + */ +void CTickService::release() +{ + + if ( saveGameCycle() ) + { +// nlinfo( "Game cycle %u saved to %s", _GameCycle, GAME_CYCLE_FILE.c_str() ); + } + + CSingletonRegistry::getInstance()->release(); +} + + +/* + * Update + */ +bool CTickService::update() +{ + CSingletonRegistry::getInstance()->serviceUpdate(); + + if (CurrentMode == TickHalted) + { + WaitingForServices = "TICK HALTED: "+HaltedReason; + } + else + { + WaitingForServices = ""; + // check if all the tocks have been received (or if missing is less than threshold ) + uint i; + for( i=0; i<_ClientInfos.size(); i++ ) + { + // if this client is supposed to send a tock + if( _ClientInfos[i].Registered ) + { + // if tock was not received yet + if( _ClientInfos[i].TockReceived == false ) + { + // if we have to wait for this client + if( _ClientInfos[i].Tocking == true ) + { + // we check threshold + if( _ClientInfos[i].TockMissingCount > _ClientInfos[i].Threshold ) + { + WaitingForServices += toString(i) + " "; + } + } + } + } + } + + // don't saveGameCycle if tick halted + // because BS probably sent an error report, and it would be hazardous + // to send BS new commands!! + if ( _GameCycle > _SavedGameCycle + INTERVAL_FOR_SAVING_GAME_CYCLE ) + { + saveGameCycle(); + } + } + + return true; +} + + +/* + * Save to file + */ +bool CTickService::saveGameCycle() +{ + _SavedGameCycle = _GameCycle; // do it anyway + try + { + CBackupMsgSaveFile msg( GAME_CYCLE_FILE, CBackupMsgSaveFile::SaveFile, Bsi ); + msg.DataMsg.serialVersion( 0 ); + msg.DataMsg.serial( _GameCycle ); + Bsi.sendFile(msg); + +/* + COFile file; + if ( file.open( SaveShardRoot.get() + IService::getInstance()->SaveFilesDirectory.toString() + GAME_CYCLE_FILE ) ) + { + file.serialVersion( 0 ); + file.serial( _GameCycle ); + file.close(); + } + else + throw EFileNotOpened( SaveShardRoot.get() + IService::getInstance()->SaveFilesDirectory.toString() + GAME_CYCLE_FILE ); + return true; +*/ + return true; + } + catch (const Exception &e) + { + nlwarning( "Can't save game cycle: %s", e.what() ); + return false; + } +} + +struct TTickFileCallback : public IBackupFileReceiveCallback +{ + CTickService *TickService; + TTickFileCallback(CTickService *tickService) + : TickService(tickService) + { + } + + virtual void callback(const CFileDescription& fileDescription, NLMISC::IStream& dataStream) + { + TickService->tickFileCallback(fileDescription, dataStream); + } + +}; + +void CTickService::tickFileCallback(const CFileDescription& fileDescription, NLMISC::IStream& dataStream) +{ + if (!fileDescription.FileName.empty()) + { + dataStream.serialVersion( 0 ); + dataStream.serial( _GameCycle ); + _SavedGameCycle = _GameCycle; + } + else + { + _GameCycle = 0; + _SavedGameCycle = 0; + nlwarning("No tick file found, starting with fresh tick"); + } +} + +/* + * Load from file + */ +bool CTickService::loadGameCycle() +{ + TTickFileCallback *cb = new TTickFileCallback(this); + Bsi.syncLoadFile(GAME_CYCLE_FILE, cb); + + return true; + +// try +// { +// CIFile file; +// if ( file.open( Bsi.getLocalPath() + GAME_CYCLE_FILE ) ) +// { +// file.serialVersion( 0 ); +// file.serial( _GameCycle ); +// file.close(); +// _SavedGameCycle = _GameCycle; +// } +// else +// throw EFileNotOpened( Bsi.getLocalPath() + GAME_CYCLE_FILE ); +// nlinfo( "Loaded game cycle %u from %s, will be saved every %u game cycles", _GameCycle, (CPath::standardizePath(IService::getInstance()->SaveFilesDirectory.toString()) + GAME_CYCLE_FILE).c_str(), INTERVAL_FOR_SAVING_GAME_CYCLE ); +// return true; +// } +// catch (const Exception &e) +// { +// nlwarning( "Can't load game cycle: %s", e.what() ); +// _GameCycle = 0; +// _SavedGameCycle = _GameCycle; +// return false; +// } +} + + +/* + * + */ +CTickServiceGameCycleTimeMeasure::CTickServiceGameCycleTimeMeasure() : HistoryMain( CTickService::getInstance()->getServiceId(), NLNET::TServiceId(~0), false ) {} + + +/* + * + */ +void CTickServiceGameCycleTimeMeasure::beginNewCycle() +{ + if ( ! CurrentMirrorMeasures.empty() ) + { + // Update stats + for ( TMirrorMeasures::const_iterator imm=CurrentMirrorMeasures.begin(); imm!=CurrentMirrorMeasures.end(); ++imm ) + { + storeMeasureToHistory( HistoryByMirror, imm->MirrorMeasure, imm->MSId, TServiceId(0) ); + + for ( std::vector::const_iterator ism=(*imm).ServiceMeasures.begin(); ism!=(*imm).ServiceMeasures.end(); ++ism ) + { + storeMeasureToHistory( HistoryByService, (*ism).ServiceMeasure, (*ism).ClientServiceId, (*imm).MSId ); + } + } + + //nlinfo( "AV: C=%hu H=%hu", CurrentTickServiceMeasure[0], HistoryMain.Stats[MHTMax][0] ); + HistoryMain.updateStats( CurrentTickServiceMeasure ); + //nlinfo( "AP: C=%hu H=%hu", CurrentTickServiceMeasure[0], HistoryMain.Stats[MHTMax][0] ); + + // Clear current + CurrentMirrorMeasures.clear(); + } +} + + + +/* + * + */ +void CTickServiceGameCycleTimeMeasure::resetMeasures() +{ + HistoryByMirror.clear(); + HistoryByService.clear(); + HistoryMain.reset( false ); +} + + +/* + * + */ +void CTickServiceGameCycleTimeMeasure::displayStats( NLMISC::CLog *log ) +{ + log->displayNL( "Shard timings at GC %u:", CTickEventHandler::getGameCycle() ); + log->displayRawNL( "___AVG__" ); + displayStat( log, MHTSum ); + log->displayRawNL( "___MAX___" ); + displayStat( log, MHTMax ); + log->displayRawNL( "___MIN___" ); + displayStat( log, MHTMin ); +} + + + + +const char * ServiceTimeMeasureTypeToCString [NbServiceTimeMeasureTypes] = +{ "TickTockInterval", "TickUpdateDuration", "PrevProcessMirrorUpdateDuration", "PrevReceiveMsgsViaMirrorDuration", "PrevTotalGameCycleDuration" }; + +const char * MirrorTimeMeasureTypeToCString [NbMirrorTimeMeasureTypes] = +{ "WaitAllReceivedDeltaDuration", "BuildAndSendDeltaDuration", "PrevApplyReceivedDeltaDuration", "PrevSendUMMDuration" }; + +const char * TickServiceTimeMeasureTypeToCString [NbTickServiceTimeMeasureTypes] = +{ "PrevTotalTickDuration" }; + + +/* + * + */ +void CTickServiceGameCycleTimeMeasure::displayStat( NLMISC::CLog *log, TTimeMeasureHistoryStat stat ) +{ + log->displayRawNL( "\tTICKS, %u measures:", HistoryMain.NbMeasures ); + uint divideBy = (HistoryMain.NbMeasures==0) ? 0 : ((stat==MHTSum) ? HistoryMain.NbMeasures : 1); + HistoryMain.Stats[stat].displayStat( log, TickServiceTimeMeasureTypeToCString, divideBy ); + { + CMirrorTimeMeasure gatheredStats [NbTimeMeasureHistoryStats] = { 0, ~0, 0 }; + for ( std::vector::const_iterator ihm=HistoryByMirror.begin(); ihm!=HistoryByMirror.end(); ++ihm ) + { + log->displayRawNL( "\tMS-%hu, %u measures:", (*ihm).ServiceId.get(), (*ihm).NbMeasures ); + divideBy = (stat==MHTSum) ? (*ihm).NbMeasures : 1; + (*ihm).Stats[stat].displayStat( log, MirrorTimeMeasureTypeToCString, divideBy ); + gatheredStats[MHTSum] += (*ihm).Stats[stat] / (*ihm).NbMeasures; + gatheredStats[MHTMin].copyLowerValues( (*ihm).Stats[stat] ); + gatheredStats[MHTMax].copyHigherValues( (*ihm).Stats[stat] ); + } + if ( HistoryByMirror.size() > 1 ) + { + log->displayRawNL( "\tAll mirror services:" ); + gatheredStats[stat].displayStat( log, MirrorTimeMeasureTypeToCString, (stat==MHTSum) ? (uint)HistoryByMirror.size() : 1 ); // not displaying the 3 stats + } + } + { + CServiceTimeMeasure gatheredStats [NbTimeMeasureHistoryStats] = { 0, ~0, 0 }; + for ( std::vector::const_iterator ihs=HistoryByService.begin(); ihs!=HistoryByService.end(); ++ihs ) + { + log->displayRawNL( "\t%s (on MS-%hu), %u measures:", CUnifiedNetwork::getInstance()->getServiceUnifiedName( (*ihs).ServiceId ).c_str(), (*ihs).ParentServiceId.get(), (*ihs).NbMeasures ); + divideBy = (stat==MHTSum) ? (*ihs).NbMeasures : 1; + (*ihs).Stats[stat].displayStat( log, ServiceTimeMeasureTypeToCString, divideBy ); + gatheredStats[MHTSum] += (*ihs).Stats[stat] / (*ihs).NbMeasures; + gatheredStats[MHTMin].copyLowerValues( (*ihs).Stats[stat] ); + gatheredStats[MHTMax].copyHigherValues( (*ihs).Stats[stat] ); + } + if ( HistoryByService.size() > 1 ) + { + log->displayRawNL( "\tAll client services:" ); + gatheredStats[stat].displayStat( log, ServiceTimeMeasureTypeToCString, (stat==MHTSum) ? (uint)HistoryByService.size() : 1 ); // not displaying the 3 stats + } + } +} + + +//----------------------------------------------- +// NLNET_SERVICE_MAIN +//----------------------------------------------- +NLNET_SERVICE_MAIN( CTickService, "TICKS", "tick_service", 0, CbArray, "", "" ); + + +// +// Variables +// + +NLMISC_VARIABLE(NLNET::TServiceId, SlowestService, "SId of the slowest service"); + +NLMISC_VARIABLE(double, SlowestTock, "Time in millisecond to receive the slowest tock"); + +NLMISC_VARIABLE(string, WaitingForServices, "Services that haven't tocked yet"); + +NLMISC_DYNVARIABLE(TGameTime, GameTime, "Current game time in second") +{ + if (get) *pointer = TS->getGameTime(); +} + +NLMISC_DYNVARIABLE(TLocalTime, TickTimeStep, "Current tick time step in second") +{ + if (get) *pointer = TS->getTickTimeStep(); + else TS->setTickTimeStep(*pointer); +} + +NLMISC_DYNVARIABLE(string, TickMode, "Current ticking mode") +{ + if (get) + { + if (TS->CurrentMode == CTickService::TickRunning) + *pointer = "Normal"; + else + *pointer = "HALTED: "+TS->HaltedReason; + } +} + + +// +// Commands +// + +NLMISC_COMMAND(haltTick, "Halt tick server", "[reason]" ) +{ + if (args.size() > 1) + return false; + + log.displayNL("TICK SERVICE HALTED MANUALLY."); + log.displayNL("PLEASE RESTART TICK SERVICE USING resumeTick COMMAND."); + + std::string reason = "MANUAL HALT"; + if (args.size() == 1) + reason += ": "+args[0]; + + TS->haltTick(reason); + return true; +} + +NLMISC_COMMAND(resumeTick, "Resume tick server", "" ) +{ + log.displayNL("TICK SERVICE RESUMED MANUALLY."); + TS->resumeTick(); + return true; +} + + +NLMISC_COMMAND(displayTimingsOfShard, "Display all timings", "" ) +{ + TS->MainTimeMeasures.displayStats( &log ); + return true; +} + +NLMISC_COMMAND(resetTimingsOfShard, "Reset all timings", "" ) +{ + TS->MainTimeMeasures.resetMeasures(); + return true; +} + +NLMISC_COMMAND(displayGameTime, "The tick service and all connected services display its current game time", "") +{ + TS->displayGameTime(); + return true; + +} + +NLMISC_COMMAND(send,"enable send (in the step by step mode)"," ") +{ + TS->enableSend(); + return true; + +} + +NLMISC_COMMAND(clients,"Give the number of clients"," ") +{ + log.displayNL("Number of connected client : %d", TS->getClientCount()); + return true; + +} + +/* +NLMISC_COMMAND(getServicesState,"Give the current state of all services"," ") +{ +// todo end the code + uint i; + for( i=0; i<_ClientInfos.size(); i++ ) + { + // if this client is supposed to send a tock + if( _ClientInfos[i].Registered ) + { + // if tock was not received yet + if( _ClientInfos[i].TockReceived == false ) + { + // if we have to wait for this client + if( _ClientInfos[i].Tocking == true ) + { + // we check threshold + if( _ClientInfos[i].TockMissingCount > _ClientInfos[i].Threshold ) + { + return; + } + } + } + } + } + return true; +} +*/ + + +NLMISC_COMMAND(displayRecentHistory,"Display the history of tick events","") +{ + TS->RecentHistory.write( &log ); + return true; +} + +NLMISC_COMMAND( pause, "Pause the tick service", "" ) +{ + Pause = !Pause; + if( Pause ) + nlinfo("Pause On"); + else + { + nlinfo("Pause Off"); + TS->checkTockReceived(); + } + return true; +} + + + + +/* + */ + +/* +// ADDED by ben: BS test purpose, you can remove this +NLMISC_COMMAND( sendFileBS, "send file to BS", " ") +{ + if (args.size() != 2) + return false; + + CIFile fi; + + if (!fi.open(args[0])) + return false; + + std::vector buffer(fi.getFileSize()); + fi.serialBuffer(&(buffer[0]), buffer.size()); + + CBackupMsgSaveFile msgSave; + msgSave.Data.serialBuffer(&(buffer[0]), buffer.size()); + msgSave.FileName = args[1]; + + Bsi.sendFile(msgSave); + + return true; +} + +NLMISC_COMMAND( sendFileAndCheckBS, "send file to BS", " ") +{ + if (args.size() != 2) + return false; + + CIFile fi; + + if (!fi.open(args[0])) + return false; + + std::vector buffer(fi.getFileSize()); + fi.serialBuffer(&(buffer[0]), buffer.size()); + + CBackupMsgSaveFile msgSave; + msgSave.Data.serialBuffer(&(buffer[0]), buffer.size()); + msgSave.FileName = args[1]; + + Bsi.sendFile(msgSave, true); + + return true; +} + +NLMISC_COMMAND( appendFileBS, "append file to BS", " ") +{ + if (args.size() != 2) + return false; + + CIFile fi; + + if (!fi.open(args[0])) + return false; + + std::vector buffer(fi.getFileSize()); + fi.serialBuffer(&(buffer[0]), buffer.size()); + + CBackupMsgSaveFile msgSave; + msgSave.Data.serialBuffer(&(buffer[0]), buffer.size()); + msgSave.FileName = args[1]; + + Bsi.append(msgSave); + + return true; +} + +NLMISC_COMMAND( appendLineBS, "append line to file via BS", " ") +{ + if (args.size() != 2) + return false; + + Bsi.append(args[0], args[1]); + + return true; +} + +NLMISC_COMMAND( deleteFileBS, "delete file via BS", " [backup file]") +{ + if (args.size() < 1 || args.size() > 2) + return false; + + bool backupFile = false; + + if (args.size() == 2) + { + NLMISC::fromString(args[1], backupFile); + } + + Bsi.deleteFile(args[0], backupFile); + + return true; +} + + +class CFileReceiveCb: public IBackupFileReceiveCallback +{ +public: + + virtual void callback(const CFileDescription& fileDescription, NLMISC::IStream& dataStream) + { + nlinfo("received file '%s'", fileDescription.FileName.c_str()); + } + +}; + +NLMISC_COMMAND( loadFileBS, "load a file from BS", "") +{ + if (args.size() != 1) + return false; + + Bsi.requestFile(args[0], new CFileReceiveCb()); + + return true; +} +*/ + + +class CFileClassReceiveCb: public IBackupFileClassReceiveCallback +{ +public: + + virtual void callback(const CFileDescriptionContainer& list) + { + nlinfo("received fileclass"); + uint i; + for (i=0; i ") +{ + if (args.size() <= 1) + return false; + + std::string directory; + std::vector classes; + CBackupFileClass bclass; + + directory = args[0]; + + uint i; + for (i=1; i -// 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 TICK_S_H -#define TICK_S_H - -#include "nel/misc/types_nl.h" -#include "nel/misc/time_nl.h" -#include "nel/misc/common.h" - -#include "nel/net/service.h" -#include "range_mirror_manager.h" -#include "game_share/tick_proxy_time_measure.h" - - -/** - * CClientInfos - * - * \author Stephane Coutelas - * \author Nevrax France - * \date 2001 - */ -class CClientInfos -{ -public : - - /// true if the tock has been received since the last tick - bool TockReceived; - - /// true if this client is supposed to send a tock - bool Registered; - - /// true if a tock from this client is not necessary to send a new tick - bool Tocking; - - /// number of non received tock from this client allowed before freezing time service - uint16 Threshold; - - /// count of missing tocks - uint16 TockMissingCount; - - /** - * default constructor - */ - CClientInfos() : TockReceived(true),Registered(false),Tocking(true),Threshold(0),TockMissingCount(0) - {} -}; - - - - -/// -class CMirrorGameCycleTimeMeasureMS : public CMirrorGameCycleTimeMeasure -{ -public: - - NLNET::TServiceId MSId; // not serialised -}; - - -enum TTickServiceTimeMeasureType { PrevTotalTickDuration, NbTickServiceTimeMeasureTypes }; - -typedef CTimeMeasure CTickServiceTimeMeasure; - - -enum TTimeMeasureHistoryStat { MHTSum, MHTMin, MHTMax, NbTimeMeasureHistoryStats }; - -/* - * - */ -template -class CTimeMeasureHistory -{ -public: - NLNET::TServiceId ServiceId; - NLNET::TServiceId ParentServiceId; - uint16 NbMeasures; - std::vector< T > Stats; // indexed by NbTimeMeasureHistoryTypes - - /// - CTimeMeasureHistory( NLNET::TServiceId serviceId, NLNET::TServiceId parentServiceId, bool setFirst, const T *newMeasure=NULL ) - { - ServiceId = serviceId; - ParentServiceId = parentServiceId; - reset( setFirst, newMeasure ); - } - - /// - void reset( bool setFirst, const T *newMeasure=NULL ) - { - if ( setFirst ) - { - NbMeasures = 1; - Stats.resize( NbTimeMeasureHistoryStats, *newMeasure ); - } - else - { - NbMeasures = 0; - Stats.resize( NbTimeMeasureHistoryStats ); - Stats[MHTSum] = 0; - Stats[MHTMin] = ~0; - Stats[MHTMax] = 0; - } - } - - /// - void updateStats( const T& newMeasure ) - { - ++NbMeasures; - for ( uint i=0; i!=newMeasure.size(); ++i ) - { - Stats[MHTSum][i] += newMeasure[i]; - if ( newMeasure[i] < Stats[MHTMin][i] ) Stats[MHTMin][i] = newMeasure[i]; - - //ldebug( "1. NEW: %hu MAX: %hu", newMeasure[i], Stats[MHTMax][i] ); - if ( newMeasure[i] > Stats[MHTMax][i] ) Stats[MHTMax][i] = newMeasure[i]; - //nldebug( "2. NEW: %hu MAX: %hu", newMeasure[i], Stats[MHTMax][i] ); - } - } -}; - -typedef CTimeMeasureHistory CMirrorTimeMeasureHistory; -typedef CTimeMeasureHistory CServiceTimeMeasureHistory; -typedef CTimeMeasureHistory CTickServiceMeasureHistory; - -/** - * - */ -class CTickServiceGameCycleTimeMeasure -{ -public: - - typedef std::vector TMirrorMeasures; - TMirrorMeasures CurrentMirrorMeasures; - CTickServiceTimeMeasure CurrentTickServiceMeasure; - - std::vector< CMirrorTimeMeasureHistory > HistoryByMirror; - std::vector< CServiceTimeMeasureHistory > HistoryByService; - CTickServiceMeasureHistory HistoryMain; - - /// - CTickServiceGameCycleTimeMeasure(); - - /// - void beginNewCycle(); - - /// - void resetMeasures(); - - /// - void displayStats( NLMISC::CLog *log ); - - /// - void displayStat( NLMISC::CLog *log, TTimeMeasureHistoryStat stat ); - -protected: - - template - void storeMeasureToHistory( std::vector& history, const Measure& newMeasure, NLNET::TServiceId serviceId, NLNET::TServiceId parentServiceId ) - { - typename std::vector::iterator ihm; - - // Find the right history item - for ( ihm=history.begin(); ihm!=history.end(); ++ihm ) - { - if ( (*ihm).ServiceId == serviceId ) - break; - } - if ( ihm == history.end() ) - { - // New in history => add it - HistoryItem hist( serviceId, parentServiceId, true, &newMeasure ); - history.push_back( hist ); - } - else - { - // Already in history => update stats - (*ihm).updateStats( newMeasure ); - } - } -}; - - -/** - * CTickService - * - * \author Stephane Coutelas - * \author Nevrax France - * \date 2001 - */ -class CTickService : public NLNET::IService -{ -public : - - /** - * Execution mode : continuous or step by step(user chooses when to send a tick) - */ - enum TTickSendingMode { Continuous = 0, StepByStep, Fastest }; - - /** - * State Mode - */ - enum TTickStateMode { TickRunning = 0, TickHalted }; - - /// Initialise the service - void init(); - - /// Update - bool update(); - - /// Release - void release(); - - /** - * Register a client - * \param serviceId is the unique id of the client service - * \param tocking true if we have to wait a tock from this client before to send another tick - * \param threshold is the max missing tock allowed - */ - void registerClient( NLNET::TServiceId serviceId, bool tocking, uint16 threshold ); - - /** - * Unregister a client - * \param serviceId is the unique id of the client service - */ - void unregisterClient( NLNET::TServiceId serviceId ); - - /** - * halt ticking - */ - void haltTick(const std::string& reason); - - /** - * resume ticking - */ - void resumeTick(); - - /** - * broadcastTick - */ - void broadcastTick(); - - /** - * A registered service sent a tock - */ - void addTock( NLNET::TServiceId serviceId ); - - /** - * Check if all tock have been received, broadcast a new tick if yes - */ - void checkTockReceived(); - - /** - * give permission to send time in the step by step mode - */ - inline void enableSend() { _StepCount++; } - - /** - * Get the current game time step - */ - inline NLMISC::TGameTime getGameTimeStep() const { return _GameTimeStep; } - - /** - * set the game time step - * \param gameTimeStep is the game time step - */ - inline void setGameTimeStep( NLMISC::TGameTime gameTimeStep ) { _GameTimeStep = gameTimeStep; } - - /** - * Get the time step between two ticks - * \return the time step between 2 ticks - */ - inline NLMISC::TLocalTime getTickTimeStep() const { return _TickTimeStep; } - - /** - * set the time step between two ticks - * \param timeStep is the time step between 2 ticks - */ - inline void setTickTimeStep( NLMISC::TLocalTime timeStep ) { _TickTimeStep = timeStep; } - - /** - * Get the current game time - * \return current game time - */ - inline NLMISC::TGameTime getGameTime() const { return _GameTime; } - - /** - * number of game cycle elapsed - */ - inline NLMISC::TGameCycle getGameCycle() const { return _GameCycle; } - - /** - * The tick service and all connected services display its current time - */ - void displayGameTime() const; - - /** - * Get the number of registered clients - * \return number of registered clients - */ - uint16 getClientCount(); - - /// Save to file - bool saveGameCycle(); - - /// Load from file - bool loadGameCycle(); - void tickFileCallback(const CFileDescription& fileDescription, NLMISC::IStream& dataStream); - - bool FirstTime; - - TTickStateMode CurrentMode; - std::string HaltedReason; - - /// Displayer of recent history - NLMISC::CLightMemDisplayer RecentHistory; - - /// Shard timings - CTickServiceGameCycleTimeMeasure MainTimeMeasures; - -private : - - /// infos about the connected clients - std::vector< CClientInfos > _ClientInfos; - - /// different from 0 if the service is allowed to send one or multiple ticks ( note : used in step by step only ) - uint16 _StepCount; - - /// time increment value (diff time between two ticks) - NLMISC::TLocalTime _TickTimeStep; - - /// the value of the time step used in the last tick - NLMISC::TLocalTime _LastTickTimeStep; - - /// number of game cycle elapsed - NLMISC::TGameCycle _GameCycle; - - /// Saved game cycle - NLMISC::TGameCycle _SavedGameCycle; - - /// game time - NLMISC::TGameTime _GameTime; - - /// delta game time - NLMISC::TGameTime _GameTimeStep; - - /// true if the value of the game timestep has changed since last tick send - bool _GameTimeStepHasChanged; - - /// time when the last tick was sent - NLMISC::TLocalTime _TickSendTime; - - /// Log to recent history - NLMISC::CLog _QuickLog; - - /// Row range manager for mirror system - CRangeMirrorManager _RangeMirrorManager; -}; - - -#endif //TICK_S_H +// 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 TICK_S_H +#define TICK_S_H + +#include "nel/misc/types_nl.h" +#include "nel/misc/time_nl.h" +#include "nel/misc/common.h" + +#include "nel/net/service.h" +#include "range_mirror_manager.h" +#include "game_share/tick_proxy_time_measure.h" + + +/** + * CClientInfos + * + * \author Stephane Coutelas + * \author Nevrax France + * \date 2001 + */ +class CClientInfos +{ +public : + + /// true if the tock has been received since the last tick + bool TockReceived; + + /// true if this client is supposed to send a tock + bool Registered; + + /// true if a tock from this client is not necessary to send a new tick + bool Tocking; + + /// number of non received tock from this client allowed before freezing time service + uint16 Threshold; + + /// count of missing tocks + uint16 TockMissingCount; + + /** + * default constructor + */ + CClientInfos() : TockReceived(true),Registered(false),Tocking(true),Threshold(0),TockMissingCount(0) + {} +}; + + + + +/// +class CMirrorGameCycleTimeMeasureMS : public CMirrorGameCycleTimeMeasure +{ +public: + + NLNET::TServiceId MSId; // not serialised +}; + + +enum TTickServiceTimeMeasureType { PrevTotalTickDuration, NbTickServiceTimeMeasureTypes }; + +typedef CTimeMeasure CTickServiceTimeMeasure; + + +enum TTimeMeasureHistoryStat { MHTSum, MHTMin, MHTMax, NbTimeMeasureHistoryStats }; + +/* + * + */ +template +class CTimeMeasureHistory +{ +public: + NLNET::TServiceId ServiceId; + NLNET::TServiceId ParentServiceId; + uint16 NbMeasures; + std::vector< T > Stats; // indexed by NbTimeMeasureHistoryTypes + + /// + CTimeMeasureHistory( NLNET::TServiceId serviceId, NLNET::TServiceId parentServiceId, bool setFirst, const T *newMeasure=NULL ) + { + ServiceId = serviceId; + ParentServiceId = parentServiceId; + reset( setFirst, newMeasure ); + } + + /// + void reset( bool setFirst, const T *newMeasure=NULL ) + { + if ( setFirst ) + { + NbMeasures = 1; + Stats.resize( NbTimeMeasureHistoryStats, *newMeasure ); + } + else + { + NbMeasures = 0; + Stats.resize( NbTimeMeasureHistoryStats ); + Stats[MHTSum] = 0; + Stats[MHTMin] = ~0; + Stats[MHTMax] = 0; + } + } + + /// + void updateStats( const T& newMeasure ) + { + ++NbMeasures; + for ( uint i=0; i!=newMeasure.size(); ++i ) + { + Stats[MHTSum][i] += newMeasure[i]; + if ( newMeasure[i] < Stats[MHTMin][i] ) Stats[MHTMin][i] = newMeasure[i]; + + //ldebug( "1. NEW: %hu MAX: %hu", newMeasure[i], Stats[MHTMax][i] ); + if ( newMeasure[i] > Stats[MHTMax][i] ) Stats[MHTMax][i] = newMeasure[i]; + //nldebug( "2. NEW: %hu MAX: %hu", newMeasure[i], Stats[MHTMax][i] ); + } + } +}; + +typedef CTimeMeasureHistory CMirrorTimeMeasureHistory; +typedef CTimeMeasureHistory CServiceTimeMeasureHistory; +typedef CTimeMeasureHistory CTickServiceMeasureHistory; + +/** + * + */ +class CTickServiceGameCycleTimeMeasure +{ +public: + + typedef std::vector TMirrorMeasures; + TMirrorMeasures CurrentMirrorMeasures; + CTickServiceTimeMeasure CurrentTickServiceMeasure; + + std::vector< CMirrorTimeMeasureHistory > HistoryByMirror; + std::vector< CServiceTimeMeasureHistory > HistoryByService; + CTickServiceMeasureHistory HistoryMain; + + /// + CTickServiceGameCycleTimeMeasure(); + + /// + void beginNewCycle(); + + /// + void resetMeasures(); + + /// + void displayStats( NLMISC::CLog *log ); + + /// + void displayStat( NLMISC::CLog *log, TTimeMeasureHistoryStat stat ); + +protected: + + template + void storeMeasureToHistory( std::vector& history, const Measure& newMeasure, NLNET::TServiceId serviceId, NLNET::TServiceId parentServiceId ) + { + typename std::vector::iterator ihm; + + // Find the right history item + for ( ihm=history.begin(); ihm!=history.end(); ++ihm ) + { + if ( (*ihm).ServiceId == serviceId ) + break; + } + if ( ihm == history.end() ) + { + // New in history => add it + HistoryItem hist( serviceId, parentServiceId, true, &newMeasure ); + history.push_back( hist ); + } + else + { + // Already in history => update stats + (*ihm).updateStats( newMeasure ); + } + } +}; + + +/** + * CTickService + * + * \author Stephane Coutelas + * \author Nevrax France + * \date 2001 + */ +class CTickService : public NLNET::IService +{ +public : + + /** + * Execution mode : continuous or step by step(user chooses when to send a tick) + */ + enum TTickSendingMode { Continuous = 0, StepByStep, Fastest }; + + /** + * State Mode + */ + enum TTickStateMode { TickRunning = 0, TickHalted }; + + /// Initialise the service + void init(); + + /// Update + bool update(); + + /// Release + void release(); + + /** + * Register a client + * \param serviceId is the unique id of the client service + * \param tocking true if we have to wait a tock from this client before to send another tick + * \param threshold is the max missing tock allowed + */ + void registerClient( NLNET::TServiceId serviceId, bool tocking, uint16 threshold ); + + /** + * Unregister a client + * \param serviceId is the unique id of the client service + */ + void unregisterClient( NLNET::TServiceId serviceId ); + + /** + * halt ticking + */ + void haltTick(const std::string& reason); + + /** + * resume ticking + */ + void resumeTick(); + + /** + * broadcastTick + */ + void broadcastTick(); + + /** + * A registered service sent a tock + */ + void addTock( NLNET::TServiceId serviceId ); + + /** + * Check if all tock have been received, broadcast a new tick if yes + */ + void checkTockReceived(); + + /** + * give permission to send time in the step by step mode + */ + inline void enableSend() { _StepCount++; } + + /** + * Get the current game time step + */ + inline NLMISC::TGameTime getGameTimeStep() const { return _GameTimeStep; } + + /** + * set the game time step + * \param gameTimeStep is the game time step + */ + inline void setGameTimeStep( NLMISC::TGameTime gameTimeStep ) { _GameTimeStep = gameTimeStep; } + + /** + * Get the time step between two ticks + * \return the time step between 2 ticks + */ + inline NLMISC::TLocalTime getTickTimeStep() const { return _TickTimeStep; } + + /** + * set the time step between two ticks + * \param timeStep is the time step between 2 ticks + */ + inline void setTickTimeStep( NLMISC::TLocalTime timeStep ) { _TickTimeStep = timeStep; } + + /** + * Get the current game time + * \return current game time + */ + inline NLMISC::TGameTime getGameTime() const { return _GameTime; } + + /** + * number of game cycle elapsed + */ + inline NLMISC::TGameCycle getGameCycle() const { return _GameCycle; } + + /** + * The tick service and all connected services display its current time + */ + void displayGameTime() const; + + /** + * Get the number of registered clients + * \return number of registered clients + */ + uint16 getClientCount(); + + /// Save to file + bool saveGameCycle(); + + /// Load from file + bool loadGameCycle(); + void tickFileCallback(const CFileDescription& fileDescription, NLMISC::IStream& dataStream); + + bool FirstTime; + + TTickStateMode CurrentMode; + std::string HaltedReason; + + /// Displayer of recent history + NLMISC::CLightMemDisplayer RecentHistory; + + /// Shard timings + CTickServiceGameCycleTimeMeasure MainTimeMeasures; + +private : + + /// infos about the connected clients + std::vector< CClientInfos > _ClientInfos; + + /// different from 0 if the service is allowed to send one or multiple ticks ( note : used in step by step only ) + uint16 _StepCount; + + /// time increment value (diff time between two ticks) + NLMISC::TLocalTime _TickTimeStep; + + /// the value of the time step used in the last tick + NLMISC::TLocalTime _LastTickTimeStep; + + /// number of game cycle elapsed + NLMISC::TGameCycle _GameCycle; + + /// Saved game cycle + NLMISC::TGameCycle _SavedGameCycle; + + /// game time + NLMISC::TGameTime _GameTime; + + /// delta game time + NLMISC::TGameTime _GameTimeStep; + + /// true if the value of the game timestep has changed since last tick send + bool _GameTimeStepHasChanged; + + /// time when the last tick was sent + NLMISC::TLocalTime _TickSendTime; + + /// Log to recent history + NLMISC::CLog _QuickLog; + + /// Row range manager for mirror system + CRangeMirrorManager _RangeMirrorManager; +}; + + +#endif //TICK_S_H diff --git a/code/ryzom/tools/assoc_mem/att_tree.h b/code/ryzom/tools/assoc_mem/att_tree.h index c853b189c..70bc697e8 100644 --- a/code/ryzom/tools/assoc_mem/att_tree.h +++ b/code/ryzom/tools/assoc_mem/att_tree.h @@ -1,31 +1,31 @@ -// 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_ATT_TREE_H_ -#define NL_ATT_TREE_H_ - -#include -#include -#include "record.h" -#include "node.h" -#include "field.h" - -class AttTree -{ - -} - +// 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_ATT_TREE_H_ +#define NL_ATT_TREE_H_ + +#include +#include +#include "record.h" +#include "node.h" +#include "field.h" + +class AttTree +{ + +} + #endif \ No newline at end of file diff --git a/code/ryzom/tools/assoc_mem/attribute.cpp b/code/ryzom/tools/assoc_mem/attribute.cpp index f953ea311..d69dab49c 100644 --- a/code/ryzom/tools/assoc_mem/attribute.cpp +++ b/code/ryzom/tools/assoc_mem/attribute.cpp @@ -1,32 +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 "attribute.h" - -IAttribute::IAttribute(std::string name) -{ - _Name = name; -} - -std::string &IAttribute::getName() -{ - return _Name; -} - -void IAttribute::setName(std::string name) -{ - _Name = name; +// 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 "attribute.h" + +IAttribute::IAttribute(std::string name) +{ + _Name = name; +} + +std::string &IAttribute::getName() +{ + return _Name; +} + +void IAttribute::setName(std::string name) +{ + _Name = name; } \ No newline at end of file diff --git a/code/ryzom/tools/assoc_mem/attribute.h b/code/ryzom/tools/assoc_mem/attribute.h index 5c55177aa..f59e8902c 100644 --- a/code/ryzom/tools/assoc_mem/attribute.h +++ b/code/ryzom/tools/assoc_mem/attribute.h @@ -1,66 +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 . - -#ifndef NL_ATTRIBUTE_H_ -#define NL_ATTRIBUTE_H_ - -#include - -class IAttribute -{ - private: - std::string _Name; - public: - IAttribute(std::string); - std::string &getName(); - void setName(std::string); -}; - -template class CAttribute : public IAttribute -{ - private: - T _Value; - public: - CAttribute(); - CAttribute(std::string); - CAttribute(std::string,T); - T &getValue(); - void setValue(T &); -}; - -template CAttribute::CAttribute() : IAttribute("") -{ -} - -template CAttribute::CAttribute(std::string name) : IAttribute(name) -{ -} - -template CAttribute::CAttribute(std::string name, T value) : IAttribute(name) -{ - _Value = value; -} - -template T &CAttribute::getValue() -{ - return _Value; -} -template void CAttribute::setValue(T &value) -{ - _Value = value; -} - +// 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_ATTRIBUTE_H_ +#define NL_ATTRIBUTE_H_ + +#include + +class IAttribute +{ + private: + std::string _Name; + public: + IAttribute(std::string); + std::string &getName(); + void setName(std::string); +}; + +template class CAttribute : public IAttribute +{ + private: + T _Value; + public: + CAttribute(); + CAttribute(std::string); + CAttribute(std::string,T); + T &getValue(); + void setValue(T &); +}; + +template CAttribute::CAttribute() : IAttribute("") +{ +} + +template CAttribute::CAttribute(std::string name) : IAttribute(name) +{ +} + +template CAttribute::CAttribute(std::string name, T value) : IAttribute(name) +{ + _Value = value; +} + +template T &CAttribute::getValue() +{ + return _Value; +} +template void CAttribute::setValue(T &value) +{ + _Value = value; +} + #endif \ No newline at end of file diff --git a/code/ryzom/tools/assoc_mem/brain.cpp b/code/ryzom/tools/assoc_mem/brain.cpp index 711366043..c9665174f 100644 --- a/code/ryzom/tools/assoc_mem/brain.cpp +++ b/code/ryzom/tools/assoc_mem/brain.cpp @@ -1,155 +1,155 @@ -// 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 "brain.h" - -CBrain::CBrain(float f,float a,float e,float ha,float hu) : CMood(f,a,e,ha,hu) -{ - _UpdateEvery = 0; -} - -CBrain::CBrain(CMood &personality) : CMood(personality) -{ - _UpdateEvery = 0; -} - -CBrain::CBrain(const CBrain &c) : CMood() -{ - _Personality = c._Personality; - _RealTime = c._RealTime; - _UpdateEvery = c._UpdateEvery; - _LastUpdate = c._LastUpdate; -} - -void CBrain::setUpdateEvery(int nb_cycles) -{ - _UpdateEvery = nb_cycles; -} - -float CBrain::getFear() -{ - if ( _Personality.getFear() > _RealTime.getFear() ) - return _Personality.getFear(); - else - return _RealTime.getFear(); -} - -float CBrain::getAgressivity() -{ - if ( _Personality.getAgressivity() > _RealTime.getAgressivity() ) - return _Personality.getAgressivity(); - else - return _RealTime.getAgressivity(); -} - -float CBrain::getEmpathy() -{ - if ( _Personality.getEmpathy() > _RealTime.getEmpathy() ) - return _Personality.getEmpathy(); - else - return _RealTime.getEmpathy(); -} - -float CBrain::getHappiness() -{ - if ( _Personality.getHappiness() > _RealTime.getHappiness() ) - return _Personality.getHappiness(); - else - return _RealTime.getHappiness(); - -} - -float CBrain::getHunger() -{ - if ( _Personality.getHunger() > _RealTime.getHunger() ) - return _Personality.getHunger(); - else - return _RealTime.getHunger(); -} - -void CBrain::setInput(CRecord *input) -{ - std::vector::iterator it_t = _Trees.begin(); - while ( it_t != _Trees.end() ) - { - (*it_t)->getOutput( input ); - it_t++; - } -} - - -void CBrain::addField(CField *field) -{ - _Fields.push_back( field ); -} - -void CBrain::addTree(CTree *tree) -{ - _Trees.push_back( tree ); -} - -std::vector CBrain::getOutputs() -{ - std::vector outputs; - std::vector::iterator it_t = _Trees.begin(); - while ( it_t != _Trees.end() ) - { - outputs.push_back( _Fields[ (*it_t)->getKey() ]->getName() ); - it_t++; - } - return outputs; -} - -void CBrain::build() -{ - std::vector::iterator it_tree = _Trees.begin(); - while ( it_tree != _Trees.end() ) - { - (*it_tree)->rebuild( _Records, _Fields ); - it_tree++; - } - _LastUpdate = 0; -} - -std::string CBrain::getDebugString() -{ - std::string debug_string; - std::vector::iterator it_tree = _Trees.begin(); - while ( it_tree != _Trees.end() ) - { - debug_string += (*it_tree)->getDebugString( _Records, _Fields ); - debug_string += "\n"; - it_tree++; - } - return debug_string; -} - -void CBrain::forget() -{ - while ( !_Records.empty() ) - { - delete _Records.front(); - _Records.erase( _Records.begin() ); - } -} - -void CBrain::addRecord(CRecord *record) -{ - _Records.push_back( record ); - _LastUpdate++; - if ( _LastUpdate > _UpdateEvery ) - build(); -} +// 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 "brain.h" + +CBrain::CBrain(float f,float a,float e,float ha,float hu) : CMood(f,a,e,ha,hu) +{ + _UpdateEvery = 0; +} + +CBrain::CBrain(CMood &personality) : CMood(personality) +{ + _UpdateEvery = 0; +} + +CBrain::CBrain(const CBrain &c) : CMood() +{ + _Personality = c._Personality; + _RealTime = c._RealTime; + _UpdateEvery = c._UpdateEvery; + _LastUpdate = c._LastUpdate; +} + +void CBrain::setUpdateEvery(int nb_cycles) +{ + _UpdateEvery = nb_cycles; +} + +float CBrain::getFear() +{ + if ( _Personality.getFear() > _RealTime.getFear() ) + return _Personality.getFear(); + else + return _RealTime.getFear(); +} + +float CBrain::getAgressivity() +{ + if ( _Personality.getAgressivity() > _RealTime.getAgressivity() ) + return _Personality.getAgressivity(); + else + return _RealTime.getAgressivity(); +} + +float CBrain::getEmpathy() +{ + if ( _Personality.getEmpathy() > _RealTime.getEmpathy() ) + return _Personality.getEmpathy(); + else + return _RealTime.getEmpathy(); +} + +float CBrain::getHappiness() +{ + if ( _Personality.getHappiness() > _RealTime.getHappiness() ) + return _Personality.getHappiness(); + else + return _RealTime.getHappiness(); + +} + +float CBrain::getHunger() +{ + if ( _Personality.getHunger() > _RealTime.getHunger() ) + return _Personality.getHunger(); + else + return _RealTime.getHunger(); +} + +void CBrain::setInput(CRecord *input) +{ + std::vector::iterator it_t = _Trees.begin(); + while ( it_t != _Trees.end() ) + { + (*it_t)->getOutput( input ); + it_t++; + } +} + + +void CBrain::addField(CField *field) +{ + _Fields.push_back( field ); +} + +void CBrain::addTree(CTree *tree) +{ + _Trees.push_back( tree ); +} + +std::vector CBrain::getOutputs() +{ + std::vector outputs; + std::vector::iterator it_t = _Trees.begin(); + while ( it_t != _Trees.end() ) + { + outputs.push_back( _Fields[ (*it_t)->getKey() ]->getName() ); + it_t++; + } + return outputs; +} + +void CBrain::build() +{ + std::vector::iterator it_tree = _Trees.begin(); + while ( it_tree != _Trees.end() ) + { + (*it_tree)->rebuild( _Records, _Fields ); + it_tree++; + } + _LastUpdate = 0; +} + +std::string CBrain::getDebugString() +{ + std::string debug_string; + std::vector::iterator it_tree = _Trees.begin(); + while ( it_tree != _Trees.end() ) + { + debug_string += (*it_tree)->getDebugString( _Records, _Fields ); + debug_string += "\n"; + it_tree++; + } + return debug_string; +} + +void CBrain::forget() +{ + while ( !_Records.empty() ) + { + delete _Records.front(); + _Records.erase( _Records.begin() ); + } +} + +void CBrain::addRecord(CRecord *record) +{ + _Records.push_back( record ); + _LastUpdate++; + if ( _LastUpdate > _UpdateEvery ) + build(); +} diff --git a/code/ryzom/tools/assoc_mem/brain.h b/code/ryzom/tools/assoc_mem/brain.h index 45670e626..70a3e3f00 100644 --- a/code/ryzom/tools/assoc_mem/brain.h +++ b/code/ryzom/tools/assoc_mem/brain.h @@ -1,69 +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 . - -#ifndef NL_BRAIN_H_ -#define NL_BRAIN_H_ - -#include "mood.h" -#include "attribute.h" -#include "tree.h" -#include "field.h" -#include - -class CBrain : public CMood -{ - private: - - enum eType { - - }; - - CMood _Personality; - CMood _RealTime; - std::vector _Trees; - std::vector _Fields; - std::vector _Records; - int _UpdateEvery; - int _LastUpdate; - public: - CBrain(float,float,float,float,float); - CBrain(CMood &); - CBrain(const CBrain &); - - std::vector getOutputs(); - - void addField(CField *); - void addTree(CTree *); - - void setUpdateEvery(int); - - virtual float getFear(); - virtual float getAgressivity(); - virtual float getEmpathy(); - virtual float getHappiness(); - virtual float getHunger(); - - - void addRecord(CRecord *); - void setInput(CRecord *); - void build(); - - std::string getDebugString(); - - void forget(); -}; - -#endif +// 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_BRAIN_H_ +#define NL_BRAIN_H_ + +#include "mood.h" +#include "attribute.h" +#include "tree.h" +#include "field.h" +#include + +class CBrain : public CMood +{ + private: + + enum eType { + + }; + + CMood _Personality; + CMood _RealTime; + std::vector _Trees; + std::vector _Fields; + std::vector _Records; + int _UpdateEvery; + int _LastUpdate; + public: + CBrain(float,float,float,float,float); + CBrain(CMood &); + CBrain(const CBrain &); + + std::vector getOutputs(); + + void addField(CField *); + void addTree(CTree *); + + void setUpdateEvery(int); + + virtual float getFear(); + virtual float getAgressivity(); + virtual float getEmpathy(); + virtual float getHappiness(); + virtual float getHunger(); + + + void addRecord(CRecord *); + void setInput(CRecord *); + void build(); + + std::string getDebugString(); + + void forget(); +}; + +#endif diff --git a/code/ryzom/tools/assoc_mem/cond_node.cpp b/code/ryzom/tools/assoc_mem/cond_node.cpp index e4e626fff..7c0705e13 100644 --- a/code/ryzom/tools/assoc_mem/cond_node.cpp +++ b/code/ryzom/tools/assoc_mem/cond_node.cpp @@ -1,45 +1,45 @@ -// 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 "cond_node.h" - - -ICondNode::ICondNode() -{ -} - -ICondNode::ICondNode(CField *field, int key) -{ - _Field = field; - _Key = key; -} - - -ICondNode::~ICondNode() -{ - std::vector::iterator it_n = _Nodes.begin(); - //........ -} - -void ICondNode::setKey(int key) -{ - _Key = key; -} - -void ICondNode::addNode(INode *node) -{ - _Nodes.push_back( node ); +// 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 "cond_node.h" + + +ICondNode::ICondNode() +{ +} + +ICondNode::ICondNode(CField *field, int key) +{ + _Field = field; + _Key = key; +} + + +ICondNode::~ICondNode() +{ + std::vector::iterator it_n = _Nodes.begin(); + //........ +} + +void ICondNode::setKey(int key) +{ + _Key = key; +} + +void ICondNode::addNode(INode *node) +{ + _Nodes.push_back( node ); } \ No newline at end of file diff --git a/code/ryzom/tools/assoc_mem/cond_node.h b/code/ryzom/tools/assoc_mem/cond_node.h index 385c979c7..60a9aa742 100644 --- a/code/ryzom/tools/assoc_mem/cond_node.h +++ b/code/ryzom/tools/assoc_mem/cond_node.h @@ -1,136 +1,136 @@ -// 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_COND_NODE_H_ -#define NL_COND_NODE_H_ - -#include - -#include "field.h" -#include "node.h" -#include "record.h" - -class ICondNode : public INode -{ - protected: - int _Key; - CField *_Field; - std::vector _Nodes; - public: - ICondNode(); - ICondNode(CField *, int); - ~ICondNode(); - - void setKey(int); - void addNode(INode *); -}; - -template class CEqualNode : public ICondNode { - private: - std::vector _Values; - public: - CEqualNode(); - CEqualNode(CField *, int); - ~CEqualNode(); - - virtual bool propagRecord(CRecord *); -}; - -template CEqualNode::CEqualNode() : ICondNode() -{ -} - -template CEqualNode::CEqualNode(CField *field, int key) : ICondNode(field, key) -{ -} - -template CEqualNode::~CEqualNode() -{ -} - -template bool CEqualNode::propagRecord(CRecord *record) -{ - std::vector::const_iterator it_val = _Field->getPossibleValues().begin(); - std::vector::const_iterator it_end = _Field->getPossibleValues().end(); - int id_node = 0; - while ( it_val != it_end ) - { - if ( ( (CValue *) (*record)[ _Key ] )->getValue() == ( (CValue *) (*it_val))->getValue() ) - { - std::cout << std::endl << "EQUAL_NODE (" << _Field->getName() << _Key << " = " << ((CValue *)(*it_val))->getValue() << " ) -> Node " << id_node << std::endl; - return _Nodes[id_node]->propagRecord( record ); - } - id_node++; - it_val++; - } - return false; -} - -/* -template class CInfNode : public ICondNode { - private: - T _Value; - public: - CInfNode(); - ~CInfNode(); - - virtual bool propagRecord(CRecord *); -}; - -template CInfNode::CInfNode() : ICondNode() -{ -} - -template CInfNode::~CInfNode() -{ -} - -template bool CInfNode::propagRecord(CRecord *record) -{ - if ( ( (CValue *) (*record)[ _Key ] )->getValue() <= _Value ) - return _TrueNode->propagRecord( record ); - else - return _FalseNode->propagRecord( record ); -} - -template class CSupNode : public ICondNode { - private: - T _Value; - public: - CSupNode(); - ~CSupNode(); - - virtual bool propagRecord(CRecord *); -}; - -template CSupNode::CSupNode() : ICondNode() -{ -} - -template CSupNode::~CSupNode() -{ -} - -template bool CSupNode::propagRecord(CRecord *record) -{ - if ( ( (CValue *) (*record)[ _Key ] )->getValue() >= _Value ) - return _TrueNode->propagRecord( record ); - else - return _FalseNode->propagRecord( record ); -} -*/ - -#endif +// 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_COND_NODE_H_ +#define NL_COND_NODE_H_ + +#include + +#include "field.h" +#include "node.h" +#include "record.h" + +class ICondNode : public INode +{ + protected: + int _Key; + CField *_Field; + std::vector _Nodes; + public: + ICondNode(); + ICondNode(CField *, int); + ~ICondNode(); + + void setKey(int); + void addNode(INode *); +}; + +template class CEqualNode : public ICondNode { + private: + std::vector _Values; + public: + CEqualNode(); + CEqualNode(CField *, int); + ~CEqualNode(); + + virtual bool propagRecord(CRecord *); +}; + +template CEqualNode::CEqualNode() : ICondNode() +{ +} + +template CEqualNode::CEqualNode(CField *field, int key) : ICondNode(field, key) +{ +} + +template CEqualNode::~CEqualNode() +{ +} + +template bool CEqualNode::propagRecord(CRecord *record) +{ + std::vector::const_iterator it_val = _Field->getPossibleValues().begin(); + std::vector::const_iterator it_end = _Field->getPossibleValues().end(); + int id_node = 0; + while ( it_val != it_end ) + { + if ( ( (CValue *) (*record)[ _Key ] )->getValue() == ( (CValue *) (*it_val))->getValue() ) + { + std::cout << std::endl << "EQUAL_NODE (" << _Field->getName() << _Key << " = " << ((CValue *)(*it_val))->getValue() << " ) -> Node " << id_node << std::endl; + return _Nodes[id_node]->propagRecord( record ); + } + id_node++; + it_val++; + } + return false; +} + +/* +template class CInfNode : public ICondNode { + private: + T _Value; + public: + CInfNode(); + ~CInfNode(); + + virtual bool propagRecord(CRecord *); +}; + +template CInfNode::CInfNode() : ICondNode() +{ +} + +template CInfNode::~CInfNode() +{ +} + +template bool CInfNode::propagRecord(CRecord *record) +{ + if ( ( (CValue *) (*record)[ _Key ] )->getValue() <= _Value ) + return _TrueNode->propagRecord( record ); + else + return _FalseNode->propagRecord( record ); +} + +template class CSupNode : public ICondNode { + private: + T _Value; + public: + CSupNode(); + ~CSupNode(); + + virtual bool propagRecord(CRecord *); +}; + +template CSupNode::CSupNode() : ICondNode() +{ +} + +template CSupNode::~CSupNode() +{ +} + +template bool CSupNode::propagRecord(CRecord *record) +{ + if ( ( (CValue *) (*record)[ _Key ] )->getValue() >= _Value ) + return _TrueNode->propagRecord( record ); + else + return _FalseNode->propagRecord( record ); +} +*/ + +#endif diff --git a/code/ryzom/tools/assoc_mem/field.cpp b/code/ryzom/tools/assoc_mem/field.cpp index bc18edf48..ca5fa6b3a 100644 --- a/code/ryzom/tools/assoc_mem/field.cpp +++ b/code/ryzom/tools/assoc_mem/field.cpp @@ -1,154 +1,154 @@ -// 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 "field.h" -#include "cond_node.h" - -CField::CField() -{ - _Name = std::string(""); -} - -CField::CField(std::string name) -{ - _Name = name; -} - -const std::vector &CField::getPossibleValues() const -{ - return _PossibleValues; -} - -void CField::addPossibleValue(IValue *value) -{ - _PossibleValues.push_back( value ); -} - -CField::~CField() -{ - std::vector::iterator it_val = _PossibleValues.begin(); - while ( ! _PossibleValues.empty() ) - { - delete _PossibleValues.front(); - _PossibleValues.erase( _PossibleValues.begin() ); - - } -} - -const std::string &CField::getName() const -{ - return _Name; -} - -///////////////////////////////////////////////////////////////////////////////////////////// - -CBoolField::CBoolField() : CField() -{ - _PossibleValues.push_back( new CValue(true) ); - _PossibleValues.push_back( new CValue(false) ); -} - -CBoolField::CBoolField(std::string name) : CField( name ) -{ - _PossibleValues.push_back( new CValue(true) ); - _PossibleValues.push_back( new CValue(false) ); -} - -ICondNode *CBoolField::createNode(int key, int pos, std::vector &) -{ - ICondNode *node = new CEqualNode(this, pos); - return node; -} - -///////////////////////////////////////////////////////////////////////////////////////////// - -CStringField::CStringField() : CField() -{ -} - -CStringField::CStringField(std::string name, std::vector &values) : CField(name) -{ - std::vector::iterator it_val = values.begin(); - while ( it_val != values.end() ) - { - _PossibleValues.push_back( new CValue( *it_val ) ); - it_val++; - } -} - -ICondNode *CStringField::createNode(int key, int pos, std::vector &) -{ - return new CEqualNode(this, pos); -} - - -///////////////////////////////////////////////////////////////////////////////////////////// - -CIntField::CIntField() : CField() -{ -} - -CIntField::CIntField(std::string name, std::vector &values) : CField( name ) -{ - std::vector::iterator it_val = values.begin(); - while ( it_val != values.end() ) - { - _PossibleValues.push_back( new CValue( *it_val ) ); - it_val++; - } -} - -ICondNode *CIntField::createNode(int key, int pos, std::vector &) -{ - return new CEqualNode(this, pos); -} - - -///////////////////////////////////////////////////////////////////////////////////////////// - -/* -CRealField::CRealField() : CField() -{ -} - -CRealField::CRealField(std::string name, std::vector &values) : CField( name ) -{ - std::vector::iterator it_val = values.begin(); - while ( it_val != values.end() ) - { - _PossibleValues.push_back( new CValue( *it_val ) ); - it_val++; - } -} - -ICondNode *CRealField::createNode(int key, int pos, std::vector &) -{ - return new CEqualNode(this, pos); -} - -void CRealField::computeRanges(int key, int pos, std::vector &records) -{ - int max_gain_attrib = -1; - double max_gain = 0; - - std::vector::iterator it_r = records.begin(); - while ( it_r != records.end() ) - { - - it_r++; - } -} +// 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 "field.h" +#include "cond_node.h" + +CField::CField() +{ + _Name = std::string(""); +} + +CField::CField(std::string name) +{ + _Name = name; +} + +const std::vector &CField::getPossibleValues() const +{ + return _PossibleValues; +} + +void CField::addPossibleValue(IValue *value) +{ + _PossibleValues.push_back( value ); +} + +CField::~CField() +{ + std::vector::iterator it_val = _PossibleValues.begin(); + while ( ! _PossibleValues.empty() ) + { + delete _PossibleValues.front(); + _PossibleValues.erase( _PossibleValues.begin() ); + + } +} + +const std::string &CField::getName() const +{ + return _Name; +} + +///////////////////////////////////////////////////////////////////////////////////////////// + +CBoolField::CBoolField() : CField() +{ + _PossibleValues.push_back( new CValue(true) ); + _PossibleValues.push_back( new CValue(false) ); +} + +CBoolField::CBoolField(std::string name) : CField( name ) +{ + _PossibleValues.push_back( new CValue(true) ); + _PossibleValues.push_back( new CValue(false) ); +} + +ICondNode *CBoolField::createNode(int key, int pos, std::vector &) +{ + ICondNode *node = new CEqualNode(this, pos); + return node; +} + +///////////////////////////////////////////////////////////////////////////////////////////// + +CStringField::CStringField() : CField() +{ +} + +CStringField::CStringField(std::string name, std::vector &values) : CField(name) +{ + std::vector::iterator it_val = values.begin(); + while ( it_val != values.end() ) + { + _PossibleValues.push_back( new CValue( *it_val ) ); + it_val++; + } +} + +ICondNode *CStringField::createNode(int key, int pos, std::vector &) +{ + return new CEqualNode(this, pos); +} + + +///////////////////////////////////////////////////////////////////////////////////////////// + +CIntField::CIntField() : CField() +{ +} + +CIntField::CIntField(std::string name, std::vector &values) : CField( name ) +{ + std::vector::iterator it_val = values.begin(); + while ( it_val != values.end() ) + { + _PossibleValues.push_back( new CValue( *it_val ) ); + it_val++; + } +} + +ICondNode *CIntField::createNode(int key, int pos, std::vector &) +{ + return new CEqualNode(this, pos); +} + + +///////////////////////////////////////////////////////////////////////////////////////////// + +/* +CRealField::CRealField() : CField() +{ +} + +CRealField::CRealField(std::string name, std::vector &values) : CField( name ) +{ + std::vector::iterator it_val = values.begin(); + while ( it_val != values.end() ) + { + _PossibleValues.push_back( new CValue( *it_val ) ); + it_val++; + } +} + +ICondNode *CRealField::createNode(int key, int pos, std::vector &) +{ + return new CEqualNode(this, pos); +} + +void CRealField::computeRanges(int key, int pos, std::vector &records) +{ + int max_gain_attrib = -1; + double max_gain = 0; + + std::vector::iterator it_r = records.begin(); + while ( it_r != records.end() ) + { + + it_r++; + } +} */ \ No newline at end of file diff --git a/code/ryzom/tools/assoc_mem/field.h b/code/ryzom/tools/assoc_mem/field.h index 9ceaf88f2..25e201aa1 100644 --- a/code/ryzom/tools/assoc_mem/field.h +++ b/code/ryzom/tools/assoc_mem/field.h @@ -1,83 +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 NL_FIELD_H_ -#define NL_FIELD_H_ - -#include - -#include "value.h" - -class INode; -class ICondNode; -class CRecord; - -class CField { - protected: - std::string _Name; - std::vector _PossibleValues; - public: - CField(); - CField(std::string); - ~CField(); - virtual const std::vector &getPossibleValues() const; - virtual void addPossibleValue(IValue *); - virtual ICondNode *createNode(int, int, std::vector &) = 0; - const std::string &getName() const; -}; - -////////////////////////////////////////////////////////////////// - -class CBoolField : public CField { - public: - CBoolField(); - CBoolField(std::string); - virtual ICondNode *createNode(int, int, std::vector &); -}; - - -////////////////////////////////////////////////////////////////// - -class CStringField : public CField { - public: - CStringField(); - CStringField(std::string, std::vector &); - virtual ICondNode *createNode(int, int, std::vector &); -}; - - -////////////////////////////////////////////////////////////////// - -class CIntField : public CField { - public: - CIntField(); - CIntField(std::string, std::vector &); - virtual ICondNode *createNode(int, int, std::vector &); -}; - -////////////////////////////////////////////////////////////////// - -class CRealField : public CField { - private: - std::vector _Ranges; - void computeRanges(); - public: - CRealField(); - CRealField(std::string, std::vector &); - virtual ICondNode *createNode(int, int, std::vector &); -}; - -#endif +// 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_FIELD_H_ +#define NL_FIELD_H_ + +#include + +#include "value.h" + +class INode; +class ICondNode; +class CRecord; + +class CField { + protected: + std::string _Name; + std::vector _PossibleValues; + public: + CField(); + CField(std::string); + ~CField(); + virtual const std::vector &getPossibleValues() const; + virtual void addPossibleValue(IValue *); + virtual ICondNode *createNode(int, int, std::vector &) = 0; + const std::string &getName() const; +}; + +////////////////////////////////////////////////////////////////// + +class CBoolField : public CField { + public: + CBoolField(); + CBoolField(std::string); + virtual ICondNode *createNode(int, int, std::vector &); +}; + + +////////////////////////////////////////////////////////////////// + +class CStringField : public CField { + public: + CStringField(); + CStringField(std::string, std::vector &); + virtual ICondNode *createNode(int, int, std::vector &); +}; + + +////////////////////////////////////////////////////////////////// + +class CIntField : public CField { + public: + CIntField(); + CIntField(std::string, std::vector &); + virtual ICondNode *createNode(int, int, std::vector &); +}; + +////////////////////////////////////////////////////////////////// + +class CRealField : public CField { + private: + std::vector _Ranges; + void computeRanges(); + public: + CRealField(); + CRealField(std::string, std::vector &); + virtual ICondNode *createNode(int, int, std::vector &); +}; + +#endif diff --git a/code/ryzom/tools/assoc_mem/mood.cpp b/code/ryzom/tools/assoc_mem/mood.cpp index 9c03ccb0b..a0e9f894e 100644 --- a/code/ryzom/tools/assoc_mem/mood.cpp +++ b/code/ryzom/tools/assoc_mem/mood.cpp @@ -1,113 +1,113 @@ -// 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 "mood.h" - - -CMood::CMood() -{ - _Fear = 0; - _Agressivity = 0; - _Empathy = 0; - _Happiness = 0; - _Hunger = 0; -} - -CMood::CMood(float f,float a,float e,float ha,float hu) -{ - _Fear = f; - _Agressivity = a; - _Empathy = e; - _Happiness = ha; - _Hunger = hu; -} - -CMood::CMood(const CMood &mood) -{ - _Fear = mood._Fear; - _Agressivity = mood._Agressivity; - _Empathy = mood._Empathy; - _Happiness = mood._Happiness; - _Hunger = mood._Hunger; - -} - -CMood::~CMood() -{ -} - - - -CMood CMood::operator=(const CMood &mood) -{ - _Fear = mood._Fear; - _Agressivity = mood._Agressivity; - _Empathy = mood._Empathy; - _Happiness = mood._Happiness; - _Hunger = mood._Hunger; - return *this; -} - -float CMood::getFear() -{ - return _Fear; -} - -float CMood::getAgressivity() -{ - return _Agressivity; -} - -float CMood::getEmpathy() -{ - return _Empathy; -} - -float CMood::getHappiness() -{ - return _Happiness; -} - -float CMood::getHunger() -{ - return _Hunger; -} - -void CMood::setFear(float f) -{ - _Fear = f; -} - -void CMood::setAgressivity(float a) -{ - _Agressivity = a; -} - -void CMood::setEmpathy(float e) -{ - _Empathy = e; -} - -void CMood::setHappiness(float ha) -{ - _Happiness = ha; -} - -void CMood::setHunger(float hu) -{ - _Hunger = hu; -} - +// 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 "mood.h" + + +CMood::CMood() +{ + _Fear = 0; + _Agressivity = 0; + _Empathy = 0; + _Happiness = 0; + _Hunger = 0; +} + +CMood::CMood(float f,float a,float e,float ha,float hu) +{ + _Fear = f; + _Agressivity = a; + _Empathy = e; + _Happiness = ha; + _Hunger = hu; +} + +CMood::CMood(const CMood &mood) +{ + _Fear = mood._Fear; + _Agressivity = mood._Agressivity; + _Empathy = mood._Empathy; + _Happiness = mood._Happiness; + _Hunger = mood._Hunger; + +} + +CMood::~CMood() +{ +} + + + +CMood CMood::operator=(const CMood &mood) +{ + _Fear = mood._Fear; + _Agressivity = mood._Agressivity; + _Empathy = mood._Empathy; + _Happiness = mood._Happiness; + _Hunger = mood._Hunger; + return *this; +} + +float CMood::getFear() +{ + return _Fear; +} + +float CMood::getAgressivity() +{ + return _Agressivity; +} + +float CMood::getEmpathy() +{ + return _Empathy; +} + +float CMood::getHappiness() +{ + return _Happiness; +} + +float CMood::getHunger() +{ + return _Hunger; +} + +void CMood::setFear(float f) +{ + _Fear = f; +} + +void CMood::setAgressivity(float a) +{ + _Agressivity = a; +} + +void CMood::setEmpathy(float e) +{ + _Empathy = e; +} + +void CMood::setHappiness(float ha) +{ + _Happiness = ha; +} + +void CMood::setHunger(float hu) +{ + _Hunger = hu; +} + diff --git a/code/ryzom/tools/assoc_mem/mood.h b/code/ryzom/tools/assoc_mem/mood.h index cea2eaf35..b3fca0090 100644 --- a/code/ryzom/tools/assoc_mem/mood.h +++ b/code/ryzom/tools/assoc_mem/mood.h @@ -1,49 +1,49 @@ -// 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_MOOD_H_ -#define NL_MOOD_H_ - - -class CMood { - private: - float _Fear; - float _Agressivity; - float _Empathy; - float _Happiness; - float _Hunger; - public: - CMood(); - CMood(float,float,float,float,float); - CMood(const CMood &); - ~CMood(); - - CMood operator=(const CMood &); - - virtual float getFear(); - virtual float getAgressivity(); - virtual float getEmpathy(); - virtual float getHappiness(); - virtual float getHunger(); - - void setFear(float); - void setAgressivity(float); - void setEmpathy(float); - void setHappiness(float); - void setHunger(float); -}; - +// 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_MOOD_H_ +#define NL_MOOD_H_ + + +class CMood { + private: + float _Fear; + float _Agressivity; + float _Empathy; + float _Happiness; + float _Hunger; + public: + CMood(); + CMood(float,float,float,float,float); + CMood(const CMood &); + ~CMood(); + + CMood operator=(const CMood &); + + virtual float getFear(); + virtual float getAgressivity(); + virtual float getEmpathy(); + virtual float getHappiness(); + virtual float getHunger(); + + void setFear(float); + void setAgressivity(float); + void setEmpathy(float); + void setHappiness(float); + void setHunger(float); +}; + #endif \ No newline at end of file diff --git a/code/ryzom/tools/assoc_mem/node.cpp b/code/ryzom/tools/assoc_mem/node.cpp index 629a390d1..de46a17fa 100644 --- a/code/ryzom/tools/assoc_mem/node.cpp +++ b/code/ryzom/tools/assoc_mem/node.cpp @@ -1,26 +1,26 @@ -// 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 "record.h" -#include "node.h" - -INode::INode() -{ -} - -INode::~INode() -{ -} +// 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 "record.h" +#include "node.h" + +INode::INode() +{ +} + +INode::~INode() +{ +} diff --git a/code/ryzom/tools/assoc_mem/node.h b/code/ryzom/tools/assoc_mem/node.h index c35176da7..e740c6fad 100644 --- a/code/ryzom/tools/assoc_mem/node.h +++ b/code/ryzom/tools/assoc_mem/node.h @@ -1,30 +1,30 @@ -// 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_NODE_H_ -#define NL_NODE_H_ - -class CRecord; - -class INode -{ - public: - INode(); - ~INode(); - virtual bool propagRecord(CRecord *) = 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_NODE_H_ +#define NL_NODE_H_ + +class CRecord; + +class INode +{ + public: + INode(); + ~INode(); + virtual bool propagRecord(CRecord *) = 0; +}; + #endif \ No newline at end of file diff --git a/code/ryzom/tools/assoc_mem/record.cpp b/code/ryzom/tools/assoc_mem/record.cpp index 08b6d9ac3..338fd5686 100644 --- a/code/ryzom/tools/assoc_mem/record.cpp +++ b/code/ryzom/tools/assoc_mem/record.cpp @@ -1,72 +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 . - -#include "record.h" - -CRecord::CRecord() -{ -} - -CRecord::CRecord(std::vector &) -{ -} - -CRecord::~CRecord() -{ -/* std::vector::iterator it_val = _Values.begin(); - while ( it_val != _Values.end() ) - { - IValue *val = *it_val; - it_val++; - delete val; - } -*/ -} - -void CRecord::addValue(IValue *value) -{ - _Values.push_back( value ); -} - -void CRecord::addValue(std::string &str) -{ - _Values.push_back( new CValue(str) ); -} - -void CRecord::addValue(bool b) -{ - _Values.push_back( new CValue(b) ); -} - -void CRecord::addValue(int val) -{ - _Values.push_back( new CValue(val) ); -} - -const std::vector &CRecord::getValues() -{ - return _Values; -} - -const IValue *CRecord::operator[](int index) -{ - return _Values[index]; -} - -int CRecord::size() -{ - return (int)_Values.size(); +// 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 "record.h" + +CRecord::CRecord() +{ +} + +CRecord::CRecord(std::vector &) +{ +} + +CRecord::~CRecord() +{ +/* std::vector::iterator it_val = _Values.begin(); + while ( it_val != _Values.end() ) + { + IValue *val = *it_val; + it_val++; + delete val; + } +*/ +} + +void CRecord::addValue(IValue *value) +{ + _Values.push_back( value ); +} + +void CRecord::addValue(std::string &str) +{ + _Values.push_back( new CValue(str) ); +} + +void CRecord::addValue(bool b) +{ + _Values.push_back( new CValue(b) ); +} + +void CRecord::addValue(int val) +{ + _Values.push_back( new CValue(val) ); +} + +const std::vector &CRecord::getValues() +{ + return _Values; +} + +const IValue *CRecord::operator[](int index) +{ + return _Values[index]; +} + +int CRecord::size() +{ + return (int)_Values.size(); } \ No newline at end of file diff --git a/code/ryzom/tools/assoc_mem/record.h b/code/ryzom/tools/assoc_mem/record.h index f46c08e80..259ee6567 100644 --- a/code/ryzom/tools/assoc_mem/record.h +++ b/code/ryzom/tools/assoc_mem/record.h @@ -1,42 +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 . - -#include -#include "value.h" - -#ifndef NL_RECORD_H_ -#define NL_RECORD_H_ - -class CRecord { - private: - std::vector _Values; - - public: - CRecord(); - CRecord(std::vector &); - ~CRecord(); - const std::vector &getValues(); - void addValue(IValue *); - void addValue(std::string &); - void addValue(bool); - void addValue(int); - - int size(); - - virtual const IValue *operator[](int); -}; - +// 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 "value.h" + +#ifndef NL_RECORD_H_ +#define NL_RECORD_H_ + +class CRecord { + private: + std::vector _Values; + + public: + CRecord(); + CRecord(std::vector &); + ~CRecord(); + const std::vector &getValues(); + void addValue(IValue *); + void addValue(std::string &); + void addValue(bool); + void addValue(int); + + int size(); + + virtual const IValue *operator[](int); +}; + #endif \ No newline at end of file diff --git a/code/ryzom/tools/assoc_mem/result_node.cpp b/code/ryzom/tools/assoc_mem/result_node.cpp index 751b0d531..4e4e0370c 100644 --- a/code/ryzom/tools/assoc_mem/result_node.cpp +++ b/code/ryzom/tools/assoc_mem/result_node.cpp @@ -1,37 +1,37 @@ -// 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 "result_node.h" -#include - -CResultNode::CResultNode() -{ -} - -CResultNode::CResultNode(bool value) -{ - _Value = value; -} - -CResultNode::~CResultNode() -{ -} - -bool CResultNode::propagRecord(CRecord *record) -{ - std::cout << "RESULTNODE: " << _Value << std::endl; - return _Value; -} +// 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 "result_node.h" +#include + +CResultNode::CResultNode() +{ +} + +CResultNode::CResultNode(bool value) +{ + _Value = value; +} + +CResultNode::~CResultNode() +{ +} + +bool CResultNode::propagRecord(CRecord *record) +{ + std::cout << "RESULTNODE: " << _Value << std::endl; + return _Value; +} diff --git a/code/ryzom/tools/assoc_mem/result_node.h b/code/ryzom/tools/assoc_mem/result_node.h index 44a258347..35cffbd8e 100644 --- a/code/ryzom/tools/assoc_mem/result_node.h +++ b/code/ryzom/tools/assoc_mem/result_node.h @@ -1,32 +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 . - -#ifndef NL_RESULT_NODE_H_ -#define NL_RESULT_NODE_H_ - -#include "node.h" - -class CResultNode : public INode { - private: - bool _Value; - public: - CResultNode(); - CResultNode(bool); - ~CResultNode(); - virtual bool propagRecord(CRecord *); -}; - -#endif +// 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_RESULT_NODE_H_ +#define NL_RESULT_NODE_H_ + +#include "node.h" + +class CResultNode : public INode { + private: + bool _Value; + public: + CResultNode(); + CResultNode(bool); + ~CResultNode(); + virtual bool propagRecord(CRecord *); +}; + +#endif diff --git a/code/ryzom/tools/assoc_mem/test.cpp b/code/ryzom/tools/assoc_mem/test.cpp index 749ab4580..e789cd6ed 100644 --- a/code/ryzom/tools/assoc_mem/test.cpp +++ b/code/ryzom/tools/assoc_mem/test.cpp @@ -1,250 +1,250 @@ -// 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 "attribute.h" -#include "node.h" -#include "brain.h" -#include "tree.h" -#include "value.h" -#include "cond_node.h" -#include "result_node.h" - -#include -#include -#include - -void test1() -{ - CBrain brain(10,10,10,10,10); - CTree tree; - - CBoolField viande("Viande"); - CBoolField grand("Grand"); - CBoolField bon("Bon"); - std::vector vals_couleur; - vals_couleur.push_back(std::string("Vert")); - vals_couleur.push_back(std::string("Rouge")); - CStringField couleur(std::string("Couleur"), vals_couleur); - - brain.addField(&viande); - brain.addField(&grand); - brain.addField(&bon); - brain.addField( (CField *) &couleur); - - tree.setKey(2); - brain.addTree( &tree ); - - CValue val1(true); - CValue val2(false); - CValue val3("Vert"); - CValue val4("Rouge"); - CValue val5("Orange"); - - CRecord r1; - r1.addValue( &val1); - r1.addValue( &val1); - r1.addValue( &val1 ); - r1.addValue( &val4 ); - - CRecord r2; - r2.addValue( &val2); - r2.addValue( &val2); - r2.addValue( &val2 ); - r2.addValue( &val4 ); - - CRecord r3; - r3.addValue( &val1 ); - r3.addValue( &val1 ); - r3.addValue( &val1 ); - r3.addValue( &val3 ); - - CRecord r4; - r4.addValue( &val2); - r4.addValue( &val2); - r4.addValue( &val2); - r4.addValue( &val5); - - CRecord r5; - r5.addValue( &val2 ); - r5.addValue( &val2 ); - r5.addValue( &val2 ); - r5.addValue( &val3); - - CRecord r6; - r6.addValue( &val2 ); - r6.addValue( &val1 ); - r6.addValue( &val2 ); - r6.addValue( &val4 ); - - CRecord r7; - r7.addValue( &val1 ); - r7.addValue( &val2 ); - r7.addValue( &val2 ); - r7.addValue( &val3 ); - - CRecord r8; - r8.addValue( &val1 ); - r8.addValue( &val1 ); - r8.addValue( &val1 ); - r8.addValue( &val3 ); - - CRecord r9; - r9.addValue( &val1 ); - r9.addValue( &val1 ); - r9.addValue( &val1 ); - r9.addValue( &val3 ); - - CRecord r10; - r10.addValue( &val2 ); - r10.addValue( &val1 ); - r10.addValue( &val2 ); - r10.addValue( &val4 ); - - brain.setInput(&r1); - brain.setInput(&r2); - brain.setInput(&r3); - brain.setInput(&r4); - brain.setInput(&r5); - brain.setInput(&r6); - brain.setInput(&r7); - brain.setInput(&r8); - brain.setInput(&r9); - brain.setInput(&r10); - - brain.build(); - std::cout << brain.getDebugString(); - - brain.setInput(&r7); -} - - -void test2() -{ - std::string age_old("old"); - std::string age_mid("mid"); - std::string age_new("new"); - - std::vector vals_age; - vals_age.push_back( age_old ); - vals_age.push_back( age_mid ); - vals_age.push_back( age_new ); - CStringField age(std::string("AGE"), vals_age); - - CValue val_true(true); - CValue val_false(false); - - - CBoolField competition(std::string("Competition")); - - std::string type_swr("swr"); - std::string type_hwr("hwr"); - - std::vector vals_type; - vals_type.push_back( type_swr ); - vals_type.push_back( type_hwr ); - CStringField type(std::string("TYPE"), vals_type); - - CBoolField profit("Profit"); - - CBrain brain(10,10,10,10,10); - CTree tree; - - brain.addField( &age ); - brain.addField( &competition ); - brain.addField( &type ); - brain.addField( &profit ); - - tree.setKey( 3 ); - brain.addTree( &tree ); - - CRecord r1; - r1.addValue( age_old ); - r1.addValue( &val_true ); - r1.addValue( type_swr ); - r1.addValue( &val_false ); - brain.addRecord( &r1 ); - - CRecord r2; - r2.addValue( age_old ); - r2.addValue( &val_false ); - r2.addValue( type_swr ); - r2.addValue( &val_false ); - brain.addRecord( &r2 ); - - CRecord r3; - r3.addValue( age_old ); - r3.addValue( &val_false ); - r3.addValue( type_hwr ); - r3.addValue( &val_false ); - brain.addRecord( &r3 ); - - CRecord r4; - r4.addValue( age_mid ); - r4.addValue( &val_true ); - r4.addValue( type_swr ); - r4.addValue( &val_false ); - brain.addRecord( &r4 ); - - CRecord r5; - r5.addValue( age_mid ); - r5.addValue( &val_true ); - r5.addValue( type_hwr ); - r5.addValue( &val_false ); - brain.addRecord( &r5 ); - - CRecord r6; - r6.addValue( age_mid ); - r6.addValue( &val_false ); - r6.addValue( type_hwr ); - r6.addValue( &val_true ); - brain.addRecord( &r6 ); - - CRecord r7; - r7.addValue( age_mid ); - r7.addValue( &val_false ); - r7.addValue( type_swr ); - r7.addValue( &val_true ); - brain.addRecord( &r7 ); - - CRecord r8; - r8.addValue( age_new ); - r8.addValue( &val_true ); - r8.addValue( type_swr ); - r8.addValue( &val_true ); - brain.addRecord( &r8 ); - - CRecord r9; - r9.addValue( age_new ); - r9.addValue( &val_false ); - r9.addValue( type_hwr ); - r9.addValue( &val_true ); - brain.addRecord( &r9 ); - - CRecord r10; - r10.addValue( age_new ); - r10.addValue( &val_false ); - r10.addValue( type_swr ); - r10.addValue( &val_true ); - brain.addRecord( &r10 ); - - brain.build(); - brain.setInput( &r5 ); -} - -int main(int, char *[]) -{ - test2(); -} +// 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 "attribute.h" +#include "node.h" +#include "brain.h" +#include "tree.h" +#include "value.h" +#include "cond_node.h" +#include "result_node.h" + +#include +#include +#include + +void test1() +{ + CBrain brain(10,10,10,10,10); + CTree tree; + + CBoolField viande("Viande"); + CBoolField grand("Grand"); + CBoolField bon("Bon"); + std::vector vals_couleur; + vals_couleur.push_back(std::string("Vert")); + vals_couleur.push_back(std::string("Rouge")); + CStringField couleur(std::string("Couleur"), vals_couleur); + + brain.addField(&viande); + brain.addField(&grand); + brain.addField(&bon); + brain.addField( (CField *) &couleur); + + tree.setKey(2); + brain.addTree( &tree ); + + CValue val1(true); + CValue val2(false); + CValue val3("Vert"); + CValue val4("Rouge"); + CValue val5("Orange"); + + CRecord r1; + r1.addValue( &val1); + r1.addValue( &val1); + r1.addValue( &val1 ); + r1.addValue( &val4 ); + + CRecord r2; + r2.addValue( &val2); + r2.addValue( &val2); + r2.addValue( &val2 ); + r2.addValue( &val4 ); + + CRecord r3; + r3.addValue( &val1 ); + r3.addValue( &val1 ); + r3.addValue( &val1 ); + r3.addValue( &val3 ); + + CRecord r4; + r4.addValue( &val2); + r4.addValue( &val2); + r4.addValue( &val2); + r4.addValue( &val5); + + CRecord r5; + r5.addValue( &val2 ); + r5.addValue( &val2 ); + r5.addValue( &val2 ); + r5.addValue( &val3); + + CRecord r6; + r6.addValue( &val2 ); + r6.addValue( &val1 ); + r6.addValue( &val2 ); + r6.addValue( &val4 ); + + CRecord r7; + r7.addValue( &val1 ); + r7.addValue( &val2 ); + r7.addValue( &val2 ); + r7.addValue( &val3 ); + + CRecord r8; + r8.addValue( &val1 ); + r8.addValue( &val1 ); + r8.addValue( &val1 ); + r8.addValue( &val3 ); + + CRecord r9; + r9.addValue( &val1 ); + r9.addValue( &val1 ); + r9.addValue( &val1 ); + r9.addValue( &val3 ); + + CRecord r10; + r10.addValue( &val2 ); + r10.addValue( &val1 ); + r10.addValue( &val2 ); + r10.addValue( &val4 ); + + brain.setInput(&r1); + brain.setInput(&r2); + brain.setInput(&r3); + brain.setInput(&r4); + brain.setInput(&r5); + brain.setInput(&r6); + brain.setInput(&r7); + brain.setInput(&r8); + brain.setInput(&r9); + brain.setInput(&r10); + + brain.build(); + std::cout << brain.getDebugString(); + + brain.setInput(&r7); +} + + +void test2() +{ + std::string age_old("old"); + std::string age_mid("mid"); + std::string age_new("new"); + + std::vector vals_age; + vals_age.push_back( age_old ); + vals_age.push_back( age_mid ); + vals_age.push_back( age_new ); + CStringField age(std::string("AGE"), vals_age); + + CValue val_true(true); + CValue val_false(false); + + + CBoolField competition(std::string("Competition")); + + std::string type_swr("swr"); + std::string type_hwr("hwr"); + + std::vector vals_type; + vals_type.push_back( type_swr ); + vals_type.push_back( type_hwr ); + CStringField type(std::string("TYPE"), vals_type); + + CBoolField profit("Profit"); + + CBrain brain(10,10,10,10,10); + CTree tree; + + brain.addField( &age ); + brain.addField( &competition ); + brain.addField( &type ); + brain.addField( &profit ); + + tree.setKey( 3 ); + brain.addTree( &tree ); + + CRecord r1; + r1.addValue( age_old ); + r1.addValue( &val_true ); + r1.addValue( type_swr ); + r1.addValue( &val_false ); + brain.addRecord( &r1 ); + + CRecord r2; + r2.addValue( age_old ); + r2.addValue( &val_false ); + r2.addValue( type_swr ); + r2.addValue( &val_false ); + brain.addRecord( &r2 ); + + CRecord r3; + r3.addValue( age_old ); + r3.addValue( &val_false ); + r3.addValue( type_hwr ); + r3.addValue( &val_false ); + brain.addRecord( &r3 ); + + CRecord r4; + r4.addValue( age_mid ); + r4.addValue( &val_true ); + r4.addValue( type_swr ); + r4.addValue( &val_false ); + brain.addRecord( &r4 ); + + CRecord r5; + r5.addValue( age_mid ); + r5.addValue( &val_true ); + r5.addValue( type_hwr ); + r5.addValue( &val_false ); + brain.addRecord( &r5 ); + + CRecord r6; + r6.addValue( age_mid ); + r6.addValue( &val_false ); + r6.addValue( type_hwr ); + r6.addValue( &val_true ); + brain.addRecord( &r6 ); + + CRecord r7; + r7.addValue( age_mid ); + r7.addValue( &val_false ); + r7.addValue( type_swr ); + r7.addValue( &val_true ); + brain.addRecord( &r7 ); + + CRecord r8; + r8.addValue( age_new ); + r8.addValue( &val_true ); + r8.addValue( type_swr ); + r8.addValue( &val_true ); + brain.addRecord( &r8 ); + + CRecord r9; + r9.addValue( age_new ); + r9.addValue( &val_false ); + r9.addValue( type_hwr ); + r9.addValue( &val_true ); + brain.addRecord( &r9 ); + + CRecord r10; + r10.addValue( age_new ); + r10.addValue( &val_false ); + r10.addValue( type_swr ); + r10.addValue( &val_true ); + brain.addRecord( &r10 ); + + brain.build(); + brain.setInput( &r5 ); +} + +int main(int, char *[]) +{ + test2(); +} diff --git a/code/ryzom/tools/assoc_mem/tree.cpp b/code/ryzom/tools/assoc_mem/tree.cpp index 3753a147c..30d936a4c 100644 --- a/code/ryzom/tools/assoc_mem/tree.cpp +++ b/code/ryzom/tools/assoc_mem/tree.cpp @@ -1,408 +1,408 @@ -// 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 -#include -#include - -#include "tree.h" -#include "cond_node.h" -#include "result_node.h" - -CTree::CTree() -{ - _RootNode = NULL; -} - -CTree::~CTree() -{ - if ( _RootNode != NULL ) - delete _RootNode; -} - -void CTree::setKey(int key) -{ - _Key = key; -} - -int CTree::getKey() -{ - return _Key; -} - - -bool CTree::getOutput(CRecord *input) -{ - if ( _RootNode != NULL ) - return _RootNode->propagRecord( input ); - else - return false; -} - -int CTree::getNbRecords(std::vector &records,int key, IValue *value) // -{ - int nb = 0; - std::vector::iterator it_r = records.begin(); - while ( it_r != records.end() ) - { - if ( *((**it_r)[key]) == value ) - nb++; - it_r++; - } - return nb; -} - -double CTree::log2(double val) const -{ - return (log(val) / log(2.0)); -} - -double CTree::entropy(double a, double b) const -{ - double p1; - double p2; - - if ( a > 0 ) - p1 = a * log2(a); - else - p1 = 0; - - if ( b > 0 ) - p2 = b * log2(b); - else - p2 = 0; - - return ( p1 + p2 ) * -1; -} - -double CTree::entropy(std::vector &p) const -{ - double result = 0; - std::vector::iterator it_p = p.begin(); - while ( it_p != p.end() ) - { - double val = *it_p; - - if ( val > 0 ) - result = result + val * log2( val ); - - it_p++; - } - return result * -1; -} - -double CTree::gain(std::vector &records, int attrib, CField *field) -{ - int nb_values = (int)field->getPossibleValues().size(); - int nb_records = (int)records.size(); - - CValue bool_true(true); - - double nb_key_true = getNbRecords(records, _Key, &bool_true ); - double nb_key_false = nb_records - nb_key_true; - - double entropy_records = entropy( nb_key_true / nb_records, nb_key_false / nb_records ); - - double gain = entropy_records; - - int i; - for ( i = 0; i < nb_values; i++ ) - { - IValue *val = field->getPossibleValues()[i]; - - int nb_records_val, nb_records_notval; - splitRecords(records, attrib, val, nb_records_val, nb_records_notval ); - - int nb_records_val_key, nb_records_val_notkey; - splitRecords(records, attrib, val, true, nb_records_val_key, nb_records_val_notkey ); - - double entropy_val = entropy( ((double)nb_records_val_key) / ((double)nb_records_val), ((double)nb_records_val_notkey) / ((double)nb_records_val) ); - - gain = gain - ( ( (double)nb_records_val ) / ( (double) nb_records ) * entropy_val ); - } - return gain; -} - -std::vector > CTree::getSortedFields( std::vector &attributes, std::vector &records, std::vector &fields ) -{ - std::vector > attribs; - - if ( ! records.empty() ) - { - std::vector::iterator it_a = attributes.begin(); - while ( it_a != attributes.end() ) - { - if ( (*it_a) != _Key ) - attribs.push_back( std::pair( gain(records, (*it_a), fields[*it_a] ) , (*it_a) ) ); - it_a++; - } - } - - // Sorts the records by gain - std::sort(attribs.begin(), attribs.end(), greater() ); - - std::vector >::iterator it_f = attribs.begin(); - - std::cout << "Attributes(gain) :" << std::endl; - while ( it_f != attribs.end() ) - { - std::cout << " " << fields[ (*it_f).second ]->getName() << " (" << (*it_f).first << ") " << std::endl; - it_f++; - } - std::cout << std::endl; - - return attribs; -} - -// Looks for the attrib with the most gain -int CTree::getBestAttrib( std::vector &attributes, std::vector &records, std::vector &fields ) -{ - double tmp_gain; - double max_gain = 0; - int best_attrib = -1; - - std::cout << "Attributes(gain) :" << std::endl; - if ( ! records.empty() ) - { - std::vector::iterator it_a = attributes.begin(); - while ( it_a != attributes.end() ) - { - if ( (*it_a) != _Key ) - { - - tmp_gain = gain( records, *it_a, fields[ *it_a ] ); - std::cout << " " << fields[ *it_a ]->getName() << " (" << tmp_gain << ") " << std::endl; - if ( tmp_gain >= max_gain ) - { - max_gain = tmp_gain; - best_attrib = *it_a; - } - } - it_a++; - } - } - return best_attrib; -} - - -void CTree::rebuild(std::vector &records, std::vector &fields) -{ - std::vector left_fields; - CRecord *first = *records.begin(); - - for (int i = 0; i < first->size(); i++ ) - if ( i != _Key ) - left_fields.push_back( i ); - - _RootNode = ID3( left_fields, records, fields ); -} - -float CTree::findNumKeyValue(std::vector &records, int key) -{ - float sum_true = 0; - float nb_true = 0; - float sum_false = 0; - float nb_false = 0; - - std::vector::iterator it_r = records.begin(); - while ( it_r != records.end() ) - { - bool result = ((CValue *)(**it_r)[ _Key ])->getValue(); - if ( result == true ) - { - sum_true += ((CValue *)(**it_r)[ key ])->getValue(); - nb_true ++; - } - else - { - sum_false += ((CValue *)(**it_r)[ key ])->getValue(); - nb_false ++; - } - it_r++; - } - - return ( sum_true / nb_true + sum_false / nb_false ) / 2; -} - -std::string CTree::getDebugString(std::vector &records, std::vector &fields) -{ - std::string output; - output += "CTree KEY = "; - output += fields[ _Key ]->getName(); - return output; -} - -INode *CTree::ID3(std::vector &attributes, std::vector &records, std::vector &fields) -{ - if ( records.empty() ) - { - return new CResultNode( false ); - } - else - { - // If there is no attribute left and the records don't have the same key value, - // returns a result node with the most frequent key value - if ( attributes.empty() ) - { - int nb_key_true; - int nb_key_false; - splitRecords( records, _Key , nb_key_true, nb_key_false ); - - if ( nb_key_true > nb_key_false ) - return new CResultNode( true ); - else - return new CResultNode( false ); - } - - - // Tests if all records have the same key value, if so returns a result node with this key value. - int nb_records = (int)records.size(); - int nb_key_true; - int nb_key_false; - - splitRecords( records, _Key , nb_key_true, nb_key_false ); - - if ( nb_key_true == nb_records ) - return new CResultNode( true ); - - if ( nb_key_false == nb_records ) - return new CResultNode( false ); - - - // Gets the attribute with the most gain for the current record set, - // and recursively builds the subnodes corresponding to each - // possible value for this attribute. - int best_gain_attrib = getBestAttrib( attributes, records, fields ); - - std::vector< std::vector > sorted_records; - splitRecords( records, best_gain_attrib, fields, sorted_records ); // classifies the records depending on the value of the best gain attribute - - std::vector new_attribs; - for ( int i = 0; i < (int) attributes.size(); i++ ) // Creates a new attributes list from the current attributes list with the best gain attribute removed - if ( attributes[i] != best_gain_attrib ) - new_attribs.push_back( attributes[i] ); - - ICondNode *root_node = fields[best_gain_attrib]->createNode(_Key, best_gain_attrib, records); - - std::vector< std::vector >::iterator it = sorted_records.begin(); // Constructs subnodes recursively - while ( it != sorted_records.end() ) - { - root_node->addNode( ID3( new_attribs, *it, fields ) ); - it++; - } - return root_node; - } -} - -std::vector CTree::getRecords(std::vector &records, int attrib, bool value) -{ - std::vector result; - std::vector::iterator it_r = records.begin(); - while ( it_r != records.end() ) - { - if ( ((CValue *)(**it_r)[attrib])->getValue() == value ) - result.push_back( *it_r ); - it_r++; - } - return result; -} - -void CTree::splitRecords(std::vector &records, int attrib, int &true_records, int &false_records) // -{ - true_records = 0; - false_records = 0; - - std::vector::iterator it_r = records.begin(); - while ( it_r != records.end() ) - { - if ( ((CValue *)(**it_r)[attrib])->getValue() == true ) - true_records++; - else - false_records++; - it_r++; - } -} - -void CTree::splitRecords(std::vector &records, int attrib, IValue *val, int &true_records, int &false_records) // -{ - true_records = 0; - false_records = 0; - - std::vector::iterator it_r = records.begin(); - while ( it_r != records.end() ) - { - const IValue *left_val = (**it_r)[ attrib ]; - if ( ( *left_val ) == val ) - true_records++; - else - false_records++; - it_r++; - } -} - -// count records with a certain value for an attrib and true or false for the key attrib -void CTree::splitRecords(std::vector &records, int attrib, IValue *val, bool key, int &true_records, int &false_records) // -{ - true_records = 0; - false_records = 0; - - std::vector::iterator it_r = records.begin(); - while ( it_r != records.end() ) - { - if ( (* ( (**it_r)[attrib] ) ) == val ) - { - if ( ( (CValue *) (**it_r)[ _Key ] )->getValue() == key ) - true_records++; - else - false_records++; - } - it_r++; - } -} - - -// Sorts records according to the possibles values for an attribute. -void CTree::splitRecords( std::vector &records, int attrib, std::vector &fields, std::vector< std::vector > &result) // -{ - if ( result.size() < fields[attrib]->getPossibleValues().size() ) - { - int nb_missing = (int)(fields[attrib]->getPossibleValues().size() - result.size()); - for (int i = 0; i <= nb_missing; i++ ) - { - result.push_back( std::vector() ); - } - } - - std::vector::iterator it_r = records.begin(); - while ( it_r != records.end() ) - { - std::vector::const_iterator it_vp = fields[attrib]->getPossibleValues().begin(); - std::vector< std::vector >::iterator it = result.begin(); - int id_val = 0; - while ( it_vp != fields[attrib]->getPossibleValues().end() ) - { - const IValue *left_value = (**it_r)[attrib]; - IValue *right_value = *it_vp; - if ( (*left_value) == right_value ) - (*it).push_back( *it_r ); - it_vp++; - it++; - } - it_r++; - } -} +// 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 +#include +#include + +#include "tree.h" +#include "cond_node.h" +#include "result_node.h" + +CTree::CTree() +{ + _RootNode = NULL; +} + +CTree::~CTree() +{ + if ( _RootNode != NULL ) + delete _RootNode; +} + +void CTree::setKey(int key) +{ + _Key = key; +} + +int CTree::getKey() +{ + return _Key; +} + + +bool CTree::getOutput(CRecord *input) +{ + if ( _RootNode != NULL ) + return _RootNode->propagRecord( input ); + else + return false; +} + +int CTree::getNbRecords(std::vector &records,int key, IValue *value) // +{ + int nb = 0; + std::vector::iterator it_r = records.begin(); + while ( it_r != records.end() ) + { + if ( *((**it_r)[key]) == value ) + nb++; + it_r++; + } + return nb; +} + +double CTree::log2(double val) const +{ + return (log(val) / log(2.0)); +} + +double CTree::entropy(double a, double b) const +{ + double p1; + double p2; + + if ( a > 0 ) + p1 = a * log2(a); + else + p1 = 0; + + if ( b > 0 ) + p2 = b * log2(b); + else + p2 = 0; + + return ( p1 + p2 ) * -1; +} + +double CTree::entropy(std::vector &p) const +{ + double result = 0; + std::vector::iterator it_p = p.begin(); + while ( it_p != p.end() ) + { + double val = *it_p; + + if ( val > 0 ) + result = result + val * log2( val ); + + it_p++; + } + return result * -1; +} + +double CTree::gain(std::vector &records, int attrib, CField *field) +{ + int nb_values = (int)field->getPossibleValues().size(); + int nb_records = (int)records.size(); + + CValue bool_true(true); + + double nb_key_true = getNbRecords(records, _Key, &bool_true ); + double nb_key_false = nb_records - nb_key_true; + + double entropy_records = entropy( nb_key_true / nb_records, nb_key_false / nb_records ); + + double gain = entropy_records; + + int i; + for ( i = 0; i < nb_values; i++ ) + { + IValue *val = field->getPossibleValues()[i]; + + int nb_records_val, nb_records_notval; + splitRecords(records, attrib, val, nb_records_val, nb_records_notval ); + + int nb_records_val_key, nb_records_val_notkey; + splitRecords(records, attrib, val, true, nb_records_val_key, nb_records_val_notkey ); + + double entropy_val = entropy( ((double)nb_records_val_key) / ((double)nb_records_val), ((double)nb_records_val_notkey) / ((double)nb_records_val) ); + + gain = gain - ( ( (double)nb_records_val ) / ( (double) nb_records ) * entropy_val ); + } + return gain; +} + +std::vector > CTree::getSortedFields( std::vector &attributes, std::vector &records, std::vector &fields ) +{ + std::vector > attribs; + + if ( ! records.empty() ) + { + std::vector::iterator it_a = attributes.begin(); + while ( it_a != attributes.end() ) + { + if ( (*it_a) != _Key ) + attribs.push_back( std::pair( gain(records, (*it_a), fields[*it_a] ) , (*it_a) ) ); + it_a++; + } + } + + // Sorts the records by gain + std::sort(attribs.begin(), attribs.end(), greater() ); + + std::vector >::iterator it_f = attribs.begin(); + + std::cout << "Attributes(gain) :" << std::endl; + while ( it_f != attribs.end() ) + { + std::cout << " " << fields[ (*it_f).second ]->getName() << " (" << (*it_f).first << ") " << std::endl; + it_f++; + } + std::cout << std::endl; + + return attribs; +} + +// Looks for the attrib with the most gain +int CTree::getBestAttrib( std::vector &attributes, std::vector &records, std::vector &fields ) +{ + double tmp_gain; + double max_gain = 0; + int best_attrib = -1; + + std::cout << "Attributes(gain) :" << std::endl; + if ( ! records.empty() ) + { + std::vector::iterator it_a = attributes.begin(); + while ( it_a != attributes.end() ) + { + if ( (*it_a) != _Key ) + { + + tmp_gain = gain( records, *it_a, fields[ *it_a ] ); + std::cout << " " << fields[ *it_a ]->getName() << " (" << tmp_gain << ") " << std::endl; + if ( tmp_gain >= max_gain ) + { + max_gain = tmp_gain; + best_attrib = *it_a; + } + } + it_a++; + } + } + return best_attrib; +} + + +void CTree::rebuild(std::vector &records, std::vector &fields) +{ + std::vector left_fields; + CRecord *first = *records.begin(); + + for (int i = 0; i < first->size(); i++ ) + if ( i != _Key ) + left_fields.push_back( i ); + + _RootNode = ID3( left_fields, records, fields ); +} + +float CTree::findNumKeyValue(std::vector &records, int key) +{ + float sum_true = 0; + float nb_true = 0; + float sum_false = 0; + float nb_false = 0; + + std::vector::iterator it_r = records.begin(); + while ( it_r != records.end() ) + { + bool result = ((CValue *)(**it_r)[ _Key ])->getValue(); + if ( result == true ) + { + sum_true += ((CValue *)(**it_r)[ key ])->getValue(); + nb_true ++; + } + else + { + sum_false += ((CValue *)(**it_r)[ key ])->getValue(); + nb_false ++; + } + it_r++; + } + + return ( sum_true / nb_true + sum_false / nb_false ) / 2; +} + +std::string CTree::getDebugString(std::vector &records, std::vector &fields) +{ + std::string output; + output += "CTree KEY = "; + output += fields[ _Key ]->getName(); + return output; +} + +INode *CTree::ID3(std::vector &attributes, std::vector &records, std::vector &fields) +{ + if ( records.empty() ) + { + return new CResultNode( false ); + } + else + { + // If there is no attribute left and the records don't have the same key value, + // returns a result node with the most frequent key value + if ( attributes.empty() ) + { + int nb_key_true; + int nb_key_false; + splitRecords( records, _Key , nb_key_true, nb_key_false ); + + if ( nb_key_true > nb_key_false ) + return new CResultNode( true ); + else + return new CResultNode( false ); + } + + + // Tests if all records have the same key value, if so returns a result node with this key value. + int nb_records = (int)records.size(); + int nb_key_true; + int nb_key_false; + + splitRecords( records, _Key , nb_key_true, nb_key_false ); + + if ( nb_key_true == nb_records ) + return new CResultNode( true ); + + if ( nb_key_false == nb_records ) + return new CResultNode( false ); + + + // Gets the attribute with the most gain for the current record set, + // and recursively builds the subnodes corresponding to each + // possible value for this attribute. + int best_gain_attrib = getBestAttrib( attributes, records, fields ); + + std::vector< std::vector > sorted_records; + splitRecords( records, best_gain_attrib, fields, sorted_records ); // classifies the records depending on the value of the best gain attribute + + std::vector new_attribs; + for ( int i = 0; i < (int) attributes.size(); i++ ) // Creates a new attributes list from the current attributes list with the best gain attribute removed + if ( attributes[i] != best_gain_attrib ) + new_attribs.push_back( attributes[i] ); + + ICondNode *root_node = fields[best_gain_attrib]->createNode(_Key, best_gain_attrib, records); + + std::vector< std::vector >::iterator it = sorted_records.begin(); // Constructs subnodes recursively + while ( it != sorted_records.end() ) + { + root_node->addNode( ID3( new_attribs, *it, fields ) ); + it++; + } + return root_node; + } +} + +std::vector CTree::getRecords(std::vector &records, int attrib, bool value) +{ + std::vector result; + std::vector::iterator it_r = records.begin(); + while ( it_r != records.end() ) + { + if ( ((CValue *)(**it_r)[attrib])->getValue() == value ) + result.push_back( *it_r ); + it_r++; + } + return result; +} + +void CTree::splitRecords(std::vector &records, int attrib, int &true_records, int &false_records) // +{ + true_records = 0; + false_records = 0; + + std::vector::iterator it_r = records.begin(); + while ( it_r != records.end() ) + { + if ( ((CValue *)(**it_r)[attrib])->getValue() == true ) + true_records++; + else + false_records++; + it_r++; + } +} + +void CTree::splitRecords(std::vector &records, int attrib, IValue *val, int &true_records, int &false_records) // +{ + true_records = 0; + false_records = 0; + + std::vector::iterator it_r = records.begin(); + while ( it_r != records.end() ) + { + const IValue *left_val = (**it_r)[ attrib ]; + if ( ( *left_val ) == val ) + true_records++; + else + false_records++; + it_r++; + } +} + +// count records with a certain value for an attrib and true or false for the key attrib +void CTree::splitRecords(std::vector &records, int attrib, IValue *val, bool key, int &true_records, int &false_records) // +{ + true_records = 0; + false_records = 0; + + std::vector::iterator it_r = records.begin(); + while ( it_r != records.end() ) + { + if ( (* ( (**it_r)[attrib] ) ) == val ) + { + if ( ( (CValue *) (**it_r)[ _Key ] )->getValue() == key ) + true_records++; + else + false_records++; + } + it_r++; + } +} + + +// Sorts records according to the possibles values for an attribute. +void CTree::splitRecords( std::vector &records, int attrib, std::vector &fields, std::vector< std::vector > &result) // +{ + if ( result.size() < fields[attrib]->getPossibleValues().size() ) + { + int nb_missing = (int)(fields[attrib]->getPossibleValues().size() - result.size()); + for (int i = 0; i <= nb_missing; i++ ) + { + result.push_back( std::vector() ); + } + } + + std::vector::iterator it_r = records.begin(); + while ( it_r != records.end() ) + { + std::vector::const_iterator it_vp = fields[attrib]->getPossibleValues().begin(); + std::vector< std::vector >::iterator it = result.begin(); + int id_val = 0; + while ( it_vp != fields[attrib]->getPossibleValues().end() ) + { + const IValue *left_value = (**it_r)[attrib]; + IValue *right_value = *it_vp; + if ( (*left_value) == right_value ) + (*it).push_back( *it_r ); + it_vp++; + it++; + } + it_r++; + } +} diff --git a/code/ryzom/tools/assoc_mem/tree.h b/code/ryzom/tools/assoc_mem/tree.h index c3ebace4e..1fbf0a68e 100644 --- a/code/ryzom/tools/assoc_mem/tree.h +++ b/code/ryzom/tools/assoc_mem/tree.h @@ -1,79 +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 NL_TREE_H_ -#define NL_TREE_H_ - -#include -#include -#include "record.h" -#include "node.h" -#include "field.h" - - -class CTree -{ - private: - //std::vector _Fields; - int _Key; - INode *_RootNode; - - public: - - struct greater : public std::binary_function , std::pair , bool> { - bool operator()(std::pair x, std::pair y) const - { - return x.first > y.first; - } - }; - - public: - CTree(); - ~CTree(); - void setKey(int); - int getKey(); - - bool getOutput(CRecord *); - - int getNbRecords(std::vector &,int,IValue *); - - std::vector getRecords(std::vector &, int , bool); - - void splitRecords(std::vector &, int, int &, int &); - void splitRecords(std::vector &, int, std::vector &, std::vector< std::vector > &); - - void splitRecords(std::vector &, int, IValue *, int &, int &); - void splitRecords(std::vector &, int, IValue *, bool, int &, int &); - - float findNumKeyValue(std::vector &, int); - - double log2(double) const; - - double entropy(double, double) const; - double entropy(std::vector &) const; - double gain(std::vector &, int, CField *); - - std::vector > getSortedFields(std::vector &, std::vector &, std::vector &); - int getBestAttrib( std::vector &, std::vector &, std::vector &); - void rebuild(std::vector &, std::vector &); - - std::string getDebugString(std::vector &, std::vector &); - - // returns the root node of a decision tree built with the ID3 algorithm - INode *ID3(std::vector &, std::vector &, std::vector &); -}; - -#endif +// 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_TREE_H_ +#define NL_TREE_H_ + +#include +#include +#include "record.h" +#include "node.h" +#include "field.h" + + +class CTree +{ + private: + //std::vector _Fields; + int _Key; + INode *_RootNode; + + public: + + struct greater : public std::binary_function , std::pair , bool> { + bool operator()(std::pair x, std::pair y) const + { + return x.first > y.first; + } + }; + + public: + CTree(); + ~CTree(); + void setKey(int); + int getKey(); + + bool getOutput(CRecord *); + + int getNbRecords(std::vector &,int,IValue *); + + std::vector getRecords(std::vector &, int , bool); + + void splitRecords(std::vector &, int, int &, int &); + void splitRecords(std::vector &, int, std::vector &, std::vector< std::vector > &); + + void splitRecords(std::vector &, int, IValue *, int &, int &); + void splitRecords(std::vector &, int, IValue *, bool, int &, int &); + + float findNumKeyValue(std::vector &, int); + + double log2(double) const; + + double entropy(double, double) const; + double entropy(std::vector &) const; + double gain(std::vector &, int, CField *); + + std::vector > getSortedFields(std::vector &, std::vector &, std::vector &); + int getBestAttrib( std::vector &, std::vector &, std::vector &); + void rebuild(std::vector &, std::vector &); + + std::string getDebugString(std::vector &, std::vector &); + + // returns the root node of a decision tree built with the ID3 algorithm + INode *ID3(std::vector &, std::vector &, std::vector &); +}; + +#endif diff --git a/code/ryzom/tools/assoc_mem/val_nodes.h b/code/ryzom/tools/assoc_mem/val_nodes.h index e7b75b8ab..56e806420 100644 --- a/code/ryzom/tools/assoc_mem/val_nodes.h +++ b/code/ryzom/tools/assoc_mem/val_nodes.h @@ -1,48 +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 NL_VAL_NODES_H_ -#define NL_VAL_NODES_H_ - -template class CInfValNode : public INode -{ - private: - T *_Val - public: - INode(); - virtual const INode *getTrueNode(); - virtual const INode *getFalseNode(); - virtual bool propagRecord(CRecord *); -}; - - -template const INode *INode *CInfValNode::getTrueNode() -{ - return _TrueNode; -} - -template const INode *INode *CInfValNode::getFalseNode() -{ - return _FalseNode; -} - -virtual template bool CInfValNode::propagRecord(CRecord *) -{ - return false; -} - +// 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_VAL_NODES_H_ +#define NL_VAL_NODES_H_ + +template class CInfValNode : public INode +{ + private: + T *_Val + public: + INode(); + virtual const INode *getTrueNode(); + virtual const INode *getFalseNode(); + virtual bool propagRecord(CRecord *); +}; + + +template const INode *INode *CInfValNode::getTrueNode() +{ + return _TrueNode; +} + +template const INode *INode *CInfValNode::getFalseNode() +{ + return _FalseNode; +} + +virtual template bool CInfValNode::propagRecord(CRecord *) +{ + return false; +} + #endif \ No newline at end of file diff --git a/code/ryzom/tools/assoc_mem/value.h b/code/ryzom/tools/assoc_mem/value.h index 1a38e95d5..321d47a14 100644 --- a/code/ryzom/tools/assoc_mem/value.h +++ b/code/ryzom/tools/assoc_mem/value.h @@ -1,107 +1,107 @@ -// 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_VALUE_H_ -#define NL_VALUE_H_ - -#include - -class IValue { - public: - virtual void getValue(IValue &) = 0; - virtual void setValue(IValue &) = 0; - - virtual bool operator==(IValue *) const = 0 ; - virtual bool operator<(IValue &) = 0; - virtual bool operator>(IValue &) = 0; -}; - -template class CValue : public IValue { - private: - T _Value; - public: - CValue(); - CValue(T); - CValue(const CValue &); - virtual void getValue(IValue &); - virtual void setValue(IValue &); - -// virtual CValue &operator=(T); - - virtual bool operator==(IValue *) const; - bool operator<(IValue &); - bool operator>(IValue &); - - virtual T getValue(); - virtual void setValue(T); -}; - -template CValue::CValue() -{ -} - -template CValue::CValue(T value) -{ - _Value = value; -} - -template CValue::CValue(const CValue &value) -{ - _Value = value.getValue(); -} - -template void CValue::getValue(IValue &value) -{ - ( (CValue &)value)._Value = _Value; -} - -template void CValue::setValue(IValue &value) -{ - _Value = ( ( (CValue &)value ).getValue() ); -} - -template bool CValue::operator==(IValue *value) const -{ - return ( _Value == ( ( (CValue *)value )->getValue() ) ); -} - -template bool CValue::operator<(IValue &value) -{ - if ( _Value < ( ( (CValue &)value ).getValue() ) ) - return true; - else - return false; -} - -template bool CValue::operator>(IValue &value) -{ - if ( _Value > ( ( (CValue &)value ).getValue() ) ) - return true; - else - return false; -} - -template void CValue::setValue(T value) -{ - _Value = value; -} - -template T CValue::getValue() -{ - return _Value; -} - -#endif +// 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_VALUE_H_ +#define NL_VALUE_H_ + +#include + +class IValue { + public: + virtual void getValue(IValue &) = 0; + virtual void setValue(IValue &) = 0; + + virtual bool operator==(IValue *) const = 0 ; + virtual bool operator<(IValue &) = 0; + virtual bool operator>(IValue &) = 0; +}; + +template class CValue : public IValue { + private: + T _Value; + public: + CValue(); + CValue(T); + CValue(const CValue &); + virtual void getValue(IValue &); + virtual void setValue(IValue &); + +// virtual CValue &operator=(T); + + virtual bool operator==(IValue *) const; + bool operator<(IValue &); + bool operator>(IValue &); + + virtual T getValue(); + virtual void setValue(T); +}; + +template CValue::CValue() +{ +} + +template CValue::CValue(T value) +{ + _Value = value; +} + +template CValue::CValue(const CValue &value) +{ + _Value = value.getValue(); +} + +template void CValue::getValue(IValue &value) +{ + ( (CValue &)value)._Value = _Value; +} + +template void CValue::setValue(IValue &value) +{ + _Value = ( ( (CValue &)value ).getValue() ); +} + +template bool CValue::operator==(IValue *value) const +{ + return ( _Value == ( ( (CValue *)value )->getValue() ) ); +} + +template bool CValue::operator<(IValue &value) +{ + if ( _Value < ( ( (CValue &)value ).getValue() ) ) + return true; + else + return false; +} + +template bool CValue::operator>(IValue &value) +{ + if ( _Value > ( ( (CValue &)value ).getValue() ) ) + return true; + else + return false; +} + +template void CValue::setValue(T value) +{ + _Value = value; +} + +template T CValue::getValue() +{ + return _Value; +} + +#endif diff --git a/code/ryzom/tools/build_gamedata/workspace/common/cfg/directories.py b/code/ryzom/tools/build_gamedata/workspace/common/cfg/directories.py index 7ed25452c..f5bcc766a 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/cfg/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/cfg/directories.py @@ -1,82 +1,82 @@ -#!/usr/bin/python -# -# \file directories.py -# \brief Directories configuration -# \date 2010-08-27 17:13GMT -# \author Jan Boon (Kaetemi) -# \date 2001-2005 -# \author Nevrax -# Python port of game data build pipeline. -# Directories configuration. -# -# NeL - 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 . -# - - -# *** COMMON NAMES AND PATHS *** -CommonName = "cfg" -CommonPath = "common/" + CommonName - - -# *** DIRECT SOURCE DIRECTORIES *** - -# Copy dir directories -CopyDirectSourceDirectories = [ ] -CopyDirectSourceFiles = [ ] - - -# *** SOURCE DIRECTORIES IN LEVELDESIGN *** -CopyLeveldesignSourceDirectories = [ ] -CopyLeveldesignSourceFiles = [ ] -CopyLeveldesignWorldSourceDirectories = [ ] -CopyLeveldesignWorldSourceFiles = [ ] -CopyLeveldesignDfnSourceDirectories = [ ] -CopyLeveldesignDfnSourceFiles = [ ] - - -# *** SOURCE DIRECTORIES IN THE DATABASE *** - -# Copy dir directories -CopyDatabaseSourceDirectories = [ ] -CopyDatabaseSourceFiles = [ ] - - -# *** SPECIAL SOURCES *** - -# Copy dir directories -CopyWindowsExeDllCfgSourceFiles = [ ] - -CopyWindowsExeDllCfgSourceFiles += [ "client_cpu_1.cfg" ] -CopyWindowsExeDllCfgSourceFiles += [ "client_cpu_2.cfg" ] -CopyWindowsExeDllCfgSourceFiles += [ "client_cpu_3.cfg" ] -CopyWindowsExeDllCfgSourceFiles += [ "client_cpu_4.cfg" ] -CopyWindowsExeDllCfgSourceFiles += [ "client_gpu_1.cfg" ] -CopyWindowsExeDllCfgSourceFiles += [ "client_gpu_2.cfg" ] -CopyWindowsExeDllCfgSourceFiles += [ "client_gpu_3.cfg" ] -CopyWindowsExeDllCfgSourceFiles += [ "client_gpu_4.cfg" ] -CopyWindowsExeDllCfgSourceFiles += [ "client_ram_256.cfg" ] -CopyWindowsExeDllCfgSourceFiles += [ "client_ram_512.cfg" ] -CopyWindowsExeDllCfgSourceFiles += [ "client_sound_buffer.cfg" ] -CopyWindowsExeDllCfgSourceFiles += [ "client_vram_32.cfg" ] -CopyWindowsExeDllCfgSourceFiles += [ "client_vram_64.cfg" ] -CopyWindowsExeDllCfgSourceFiles += [ "client_vram_128.cfg" ] - - -# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** - -# Copy -CopyInstallDirectory = CommonName +#!/usr/bin/python +# +# \file directories.py +# \brief Directories configuration +# \date 2010-08-27 17:13GMT +# \author Jan Boon (Kaetemi) +# \date 2001-2005 +# \author Nevrax +# Python port of game data build pipeline. +# Directories configuration. +# +# NeL - 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 . +# + + +# *** COMMON NAMES AND PATHS *** +CommonName = "cfg" +CommonPath = "common/" + CommonName + + +# *** DIRECT SOURCE DIRECTORIES *** + +# Copy dir directories +CopyDirectSourceDirectories = [ ] +CopyDirectSourceFiles = [ ] + + +# *** SOURCE DIRECTORIES IN LEVELDESIGN *** +CopyLeveldesignSourceDirectories = [ ] +CopyLeveldesignSourceFiles = [ ] +CopyLeveldesignWorldSourceDirectories = [ ] +CopyLeveldesignWorldSourceFiles = [ ] +CopyLeveldesignDfnSourceDirectories = [ ] +CopyLeveldesignDfnSourceFiles = [ ] + + +# *** SOURCE DIRECTORIES IN THE DATABASE *** + +# Copy dir directories +CopyDatabaseSourceDirectories = [ ] +CopyDatabaseSourceFiles = [ ] + + +# *** SPECIAL SOURCES *** + +# Copy dir directories +CopyWindowsExeDllCfgSourceFiles = [ ] + +CopyWindowsExeDllCfgSourceFiles += [ "client_cpu_1.cfg" ] +CopyWindowsExeDllCfgSourceFiles += [ "client_cpu_2.cfg" ] +CopyWindowsExeDllCfgSourceFiles += [ "client_cpu_3.cfg" ] +CopyWindowsExeDllCfgSourceFiles += [ "client_cpu_4.cfg" ] +CopyWindowsExeDllCfgSourceFiles += [ "client_gpu_1.cfg" ] +CopyWindowsExeDllCfgSourceFiles += [ "client_gpu_2.cfg" ] +CopyWindowsExeDllCfgSourceFiles += [ "client_gpu_3.cfg" ] +CopyWindowsExeDllCfgSourceFiles += [ "client_gpu_4.cfg" ] +CopyWindowsExeDllCfgSourceFiles += [ "client_ram_256.cfg" ] +CopyWindowsExeDllCfgSourceFiles += [ "client_ram_512.cfg" ] +CopyWindowsExeDllCfgSourceFiles += [ "client_sound_buffer.cfg" ] +CopyWindowsExeDllCfgSourceFiles += [ "client_vram_32.cfg" ] +CopyWindowsExeDllCfgSourceFiles += [ "client_vram_64.cfg" ] +CopyWindowsExeDllCfgSourceFiles += [ "client_vram_128.cfg" ] + + +# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** + +# Copy +CopyInstallDirectory = CommonName diff --git a/code/ryzom/tools/build_gamedata/workspace/common/cfg/process.py b/code/ryzom/tools/build_gamedata/workspace/common/cfg/process.py index 5a8279c05..4e3b52ab0 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/cfg/process.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/cfg/process.py @@ -1,37 +1,37 @@ -#!/usr/bin/python -# -# \file config.py -# \brief Process configuration -# \date 2010-08-27 17:02GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Process configuration. -# -# NeL - 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 . -# - -# *** PROCESS CONFIGURATION *** - -# *** PROCESS CONFIG *** -ProcessToComplete = [ ] -ProcessToComplete += [ "copy" ] - - -# *** COMMON NAMES AND PATHS *** -CommonName = "cfg" -CommonPath = "common/" + CommonName - +#!/usr/bin/python +# +# \file config.py +# \brief Process configuration +# \date 2010-08-27 17:02GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Process configuration. +# +# NeL - 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 . +# + +# *** PROCESS CONFIGURATION *** + +# *** PROCESS CONFIG *** +ProcessToComplete = [ ] +ProcessToComplete += [ "copy" ] + + +# *** COMMON NAMES AND PATHS *** +CommonName = "cfg" +CommonPath = "common/" + CommonName + diff --git a/code/ryzom/tools/build_gamedata/workspace/common/characters/directories.py b/code/ryzom/tools/build_gamedata/workspace/common/characters/directories.py index c5db38fd3..0751eb523 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/characters/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/characters/directories.py @@ -1,190 +1,190 @@ -#!/usr/bin/python -# -# \file directories.py -# \brief Directories configuration -# \date 2010-08-27 17:13GMT -# \author Jan Boon (Kaetemi) -# \date 2001-2005 -# \author Nevrax -# Python port of game data build pipeline. -# Directories configuration. -# -# NeL - 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 . -# - - -# *** COMMON NAMES AND PATHS *** -EcosystemName = "characters" -EcosystemPath = "common/" + EcosystemName -ContinentName = EcosystemName -ContinentPath = EcosystemPath -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** SOURCE DIRECTORIES IN THE DATABASE *** - -# Skeleton directories -SkelSourceDirectories = [ ] -SkelSourceDirectories += [ "stuff/fyros/agents/actors/male/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/fyros/agents/actors/female/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/actors/male/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/actors/female/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/zorai/agents/actors/male/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/zorai/agents/actors/female/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/matis/agents/actors/male/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/matis/agents/actors/female/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/matis/agents/actors/roadsign/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/caravan/agents/actors/male/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/caravan/agents/actors/female/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/caravan/agents/actors/ship/animation/skeletons" ] - -# Skeleton template weight directories -SwtSourceDirectories = [ ] -SwtSourceDirectories += [ "stuff/fyros/agents/actors/male/animation/swt" ] -SwtSourceDirectories += [ "stuff/fyros/agents/actors/female/animation/swt" ] -SwtSourceDirectories += [ "stuff/tryker/agents/actors/male/animation/swt" ] -SwtSourceDirectories += [ "stuff/tryker/agents/actors/female/animation/swt" ] -SwtSourceDirectories += [ "stuff/matis/agents/actors/male/animation/swt" ] -SwtSourceDirectories += [ "stuff/matis/agents/actors/female/animation/swt" ] -SwtSourceDirectories += [ "stuff/zorai/agents/actors/male/animation/swt" ] -SwtSourceDirectories += [ "stuff/zorai/agents/actors/female/animation/swt" ] -SwtSourceDirectories += [ "stuff/caravan/agents/actors/male/animation/swt" ] -SwtSourceDirectories += [ "stuff/caravan/agents/actors/female/animation/swt" ] - -# Shape directories -ShapeSourceDirectories = [ ] -ShapeSourceDirectories += [ "stuff/fyros/agents/actors/male" ] -ShapeSourceDirectories += [ "stuff/fyros/agents/actors/female" ] -ShapeSourceDirectories += [ "stuff/fyros/agents/actors/visages" ] -ShapeSourceDirectories += [ "stuff/fyros/agents/actors/bots" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/actors/male" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/actors/female" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/actors/visages" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/actors/bots" ] -ShapeSourceDirectories += [ "stuff/matis/agents/actors/male" ] -ShapeSourceDirectories += [ "stuff/matis/agents/actors/female" ] -ShapeSourceDirectories += [ "stuff/matis/agents/actors/visages" ] -ShapeSourceDirectories += [ "stuff/matis/agents/actors/bots" ] -ShapeSourceDirectories += [ "stuff/matis/agents/actors/roadsign" ] -ShapeSourceDirectories += [ "stuff/zorai/agents/actors/male" ] -ShapeSourceDirectories += [ "stuff/zorai/agents/actors/female" ] -ShapeSourceDirectories += [ "stuff/zorai/agents/actors/visages" ] -ShapeSourceDirectories += [ "stuff/zorai/agents/actors/bots" ] -ShapeSourceDirectories += [ "stuff/caravan/agents/actors/female" ] -ShapeSourceDirectories += [ "stuff/caravan/agents/actors/male" ] -ShapeSourceDirectories += [ "stuff/caravan/agents/actors/visages" ] -ShapeSourceDirectories += [ "stuff/caravan/agents/actors/ship" ] -ShapeSourceDirectories += [ "stuff/generique/agents/actors/female" ] -ShapeSourceDirectories += [ "stuff/generique/agents/actors/male" ] -ShapeSourceDirectories += [ "stuff/generique/agents/actors/visages" ] - -# Animation directories -AnimSourceDirectories = [ ] -AnimSourceDirectories += [ "stuff/fyros/agents/actors/male/animation/anims" ] -AnimSourceDirectories += [ "stuff/fyros/agents/actors/female/animation/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/actors/male/animation/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/actors/female/animation/anims" ] -AnimSourceDirectories += [ "stuff/matis/agents/actors/male/animation/anims" ] -AnimSourceDirectories += [ "stuff/matis/agents/actors/female/animation/anims" ] -AnimSourceDirectories += [ "stuff/matis/agents/actors/roadsign/animation/anims" ] -AnimSourceDirectories += [ "stuff/zorai/agents/actors/male/animation/anims" ] -AnimSourceDirectories += [ "stuff/zorai/agents/actors/female/animation/anims" ] -AnimSourceDirectories += [ "stuff/caravan/agents/actors/male/animation/anims" ] -AnimSourceDirectories += [ "stuff/caravan/agents/actors/female/animation/anims" ] -AnimSourceDirectories += [ "stuff/caravan/agents/actors/ship/animation/anims" ] - -# cLoD shape directories -ClodSourceDirectories = [ ] -ClodSourceDirectories += [ "stuff/lod_actors/lod_" + CommonName ] - - -# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) - -# Ig lookup directories used by rbank -IgLookupDirectories = [ ] - -# Shape lookup directories used by rbank -ShapeLookupDirectories = [ ] -ShapeLookupDirectories += [ CommonPath + "/shape_clodtex_build" ] -ShapeLookupDirectories += [ CommonPath + "/shape_with_coarse_mesh" ] - -# Map lookup directories used by shape -MapLookupDirectories = [ ] - - -# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** - -# Skeleton directories -SkelExportDirectory = CommonPath + "/skel" - -# Skeleton template weight directories -SwtExportDirectory = CommonPath + "/swt" - -# Shape directories -ShapeTagExportDirectory = CommonPath + "/shape_tag" -ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" -ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" -ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" -ShapeAnimExportDirectory = CommonPath + "/shape_anim" - -# Animation directories -AnimExportDirectory = CommonPath + "/anim_export" -AnimTagExportDirectory = CommonPath + "/anim_tag" - -# cLoD directories -ClodExportDirectory = CommonPath + "/clod_export" -ClodTagExportDirectory = CommonPath + "/clod_tag_export" - - -# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapBuildDirectory = CommonPath + "/map" -MapPanoplyBuildDirectory = CommonPath + "/map_panoply" -MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" -MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" -MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" -MapTagBuildDirectory = CommonPath + "/map_tag" - -# Shape directories -ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" -ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" -ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" -ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" - -# Animation directories -AnimBuildDirectory = CommonPath + "/anim" - -# cLoD directories -ClodBankBuildDirectory = CommonPath + "/clod_bank" - - -# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** - -# Shape directory -ShapeInstallDirectory = CommonName + "_shapes" -LightmapInstallDirectory = ShapeInstallDirectory - -# Animation directory -AnimInstallDirectory = CommonName + "_animations" - -# Skeleton directory -SkelInstallDirectory = CommonName + "_skeletons" - -# Skeleton directory -SwtInstallDirectory = CommonName + "_swt" +#!/usr/bin/python +# +# \file directories.py +# \brief Directories configuration +# \date 2010-08-27 17:13GMT +# \author Jan Boon (Kaetemi) +# \date 2001-2005 +# \author Nevrax +# Python port of game data build pipeline. +# Directories configuration. +# +# NeL - 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 . +# + + +# *** COMMON NAMES AND PATHS *** +EcosystemName = "characters" +EcosystemPath = "common/" + EcosystemName +ContinentName = EcosystemName +ContinentPath = EcosystemPath +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** SOURCE DIRECTORIES IN THE DATABASE *** + +# Skeleton directories +SkelSourceDirectories = [ ] +SkelSourceDirectories += [ "stuff/fyros/agents/actors/male/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/fyros/agents/actors/female/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/actors/male/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/actors/female/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/zorai/agents/actors/male/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/zorai/agents/actors/female/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/matis/agents/actors/male/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/matis/agents/actors/female/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/matis/agents/actors/roadsign/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/caravan/agents/actors/male/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/caravan/agents/actors/female/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/caravan/agents/actors/ship/animation/skeletons" ] + +# Skeleton template weight directories +SwtSourceDirectories = [ ] +SwtSourceDirectories += [ "stuff/fyros/agents/actors/male/animation/swt" ] +SwtSourceDirectories += [ "stuff/fyros/agents/actors/female/animation/swt" ] +SwtSourceDirectories += [ "stuff/tryker/agents/actors/male/animation/swt" ] +SwtSourceDirectories += [ "stuff/tryker/agents/actors/female/animation/swt" ] +SwtSourceDirectories += [ "stuff/matis/agents/actors/male/animation/swt" ] +SwtSourceDirectories += [ "stuff/matis/agents/actors/female/animation/swt" ] +SwtSourceDirectories += [ "stuff/zorai/agents/actors/male/animation/swt" ] +SwtSourceDirectories += [ "stuff/zorai/agents/actors/female/animation/swt" ] +SwtSourceDirectories += [ "stuff/caravan/agents/actors/male/animation/swt" ] +SwtSourceDirectories += [ "stuff/caravan/agents/actors/female/animation/swt" ] + +# Shape directories +ShapeSourceDirectories = [ ] +ShapeSourceDirectories += [ "stuff/fyros/agents/actors/male" ] +ShapeSourceDirectories += [ "stuff/fyros/agents/actors/female" ] +ShapeSourceDirectories += [ "stuff/fyros/agents/actors/visages" ] +ShapeSourceDirectories += [ "stuff/fyros/agents/actors/bots" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/actors/male" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/actors/female" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/actors/visages" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/actors/bots" ] +ShapeSourceDirectories += [ "stuff/matis/agents/actors/male" ] +ShapeSourceDirectories += [ "stuff/matis/agents/actors/female" ] +ShapeSourceDirectories += [ "stuff/matis/agents/actors/visages" ] +ShapeSourceDirectories += [ "stuff/matis/agents/actors/bots" ] +ShapeSourceDirectories += [ "stuff/matis/agents/actors/roadsign" ] +ShapeSourceDirectories += [ "stuff/zorai/agents/actors/male" ] +ShapeSourceDirectories += [ "stuff/zorai/agents/actors/female" ] +ShapeSourceDirectories += [ "stuff/zorai/agents/actors/visages" ] +ShapeSourceDirectories += [ "stuff/zorai/agents/actors/bots" ] +ShapeSourceDirectories += [ "stuff/caravan/agents/actors/female" ] +ShapeSourceDirectories += [ "stuff/caravan/agents/actors/male" ] +ShapeSourceDirectories += [ "stuff/caravan/agents/actors/visages" ] +ShapeSourceDirectories += [ "stuff/caravan/agents/actors/ship" ] +ShapeSourceDirectories += [ "stuff/generique/agents/actors/female" ] +ShapeSourceDirectories += [ "stuff/generique/agents/actors/male" ] +ShapeSourceDirectories += [ "stuff/generique/agents/actors/visages" ] + +# Animation directories +AnimSourceDirectories = [ ] +AnimSourceDirectories += [ "stuff/fyros/agents/actors/male/animation/anims" ] +AnimSourceDirectories += [ "stuff/fyros/agents/actors/female/animation/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/actors/male/animation/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/actors/female/animation/anims" ] +AnimSourceDirectories += [ "stuff/matis/agents/actors/male/animation/anims" ] +AnimSourceDirectories += [ "stuff/matis/agents/actors/female/animation/anims" ] +AnimSourceDirectories += [ "stuff/matis/agents/actors/roadsign/animation/anims" ] +AnimSourceDirectories += [ "stuff/zorai/agents/actors/male/animation/anims" ] +AnimSourceDirectories += [ "stuff/zorai/agents/actors/female/animation/anims" ] +AnimSourceDirectories += [ "stuff/caravan/agents/actors/male/animation/anims" ] +AnimSourceDirectories += [ "stuff/caravan/agents/actors/female/animation/anims" ] +AnimSourceDirectories += [ "stuff/caravan/agents/actors/ship/animation/anims" ] + +# cLoD shape directories +ClodSourceDirectories = [ ] +ClodSourceDirectories += [ "stuff/lod_actors/lod_" + CommonName ] + + +# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) + +# Ig lookup directories used by rbank +IgLookupDirectories = [ ] + +# Shape lookup directories used by rbank +ShapeLookupDirectories = [ ] +ShapeLookupDirectories += [ CommonPath + "/shape_clodtex_build" ] +ShapeLookupDirectories += [ CommonPath + "/shape_with_coarse_mesh" ] + +# Map lookup directories used by shape +MapLookupDirectories = [ ] + + +# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** + +# Skeleton directories +SkelExportDirectory = CommonPath + "/skel" + +# Skeleton template weight directories +SwtExportDirectory = CommonPath + "/swt" + +# Shape directories +ShapeTagExportDirectory = CommonPath + "/shape_tag" +ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" +ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" +ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" +ShapeAnimExportDirectory = CommonPath + "/shape_anim" + +# Animation directories +AnimExportDirectory = CommonPath + "/anim_export" +AnimTagExportDirectory = CommonPath + "/anim_tag" + +# cLoD directories +ClodExportDirectory = CommonPath + "/clod_export" +ClodTagExportDirectory = CommonPath + "/clod_tag_export" + + +# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapBuildDirectory = CommonPath + "/map" +MapPanoplyBuildDirectory = CommonPath + "/map_panoply" +MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" +MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" +MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" +MapTagBuildDirectory = CommonPath + "/map_tag" + +# Shape directories +ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" +ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" +ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" +ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" + +# Animation directories +AnimBuildDirectory = CommonPath + "/anim" + +# cLoD directories +ClodBankBuildDirectory = CommonPath + "/clod_bank" + + +# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** + +# Shape directory +ShapeInstallDirectory = CommonName + "_shapes" +LightmapInstallDirectory = ShapeInstallDirectory + +# Animation directory +AnimInstallDirectory = CommonName + "_animations" + +# Skeleton directory +SkelInstallDirectory = CommonName + "_skeletons" + +# Skeleton directory +SwtInstallDirectory = CommonName + "_swt" diff --git a/code/ryzom/tools/build_gamedata/workspace/common/characters/process.py b/code/ryzom/tools/build_gamedata/workspace/common/characters/process.py index 89dbf1d89..1250ae387 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/characters/process.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/characters/process.py @@ -1,108 +1,108 @@ -#!/usr/bin/python -# -# \file config.py -# \brief Process configuration -# \date 2010-08-27 17:02GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Process configuration. -# -# NeL - 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 . -# - -# *** PROCESS CONFIGURATION *** - -# *** PROCESS CONFIG *** -ProcessToComplete = [ ] -ProcessToComplete += [ "skel" ] -ProcessToComplete += [ "swt" ] -ProcessToComplete += [ "shape" ] -ProcessToComplete += [ "anim" ] -ProcessToComplete += [ "clodbank" ] - - -# *** COMMON NAMES AND PATHS *** -EcosystemName = "characters" -EcosystemPath = "common/" + EcosystemName -ContinentName = EcosystemName -ContinentPath = EcosystemPath -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** SHAPE EXPORT OPTIONS *** - -# Compute lightmaps ? -ShapeExportOptExportLighting = "true" - -# Cast shadow in lightmap ? -ShapeExportOptShadow = "true" - -# Lighting limits. 0 : normal, 1 : soft shadows -ShapeExportOptLightingLimit = 0 - -# Lightmap lumel size -ShapeExportOptLumelSize = "0.25" - -# Oversampling value. Can be 1, 2, 4 or 8 -ShapeExportOptOversampling = 1 - -# Does the lightmap must be generated in 8 bits format ? -ShapeExportOpt8BitsLightmap = "false" - -# Does the lightmaps export must generate logs ? -ShapeExportOptLightmapLog = "true" - -# Coarse mesh texture mul size -TextureMulSizeValue = "1.5" - -DoBuildShadowSkin = 0 - - -#panoply_file_list = panoply_files.txt ??? -#hls_bank_file_name = characters.hlsbank ??? - - - -# *** CLODBANK OPTIONS *** - -ClodConfigFile = "stuff/lod_actors/lod_" + CommonName + "/clod_char_script.cfg" -ClodBankFileName = CommonName + ".clodbank" - - -# *** COARSE MESH TEXTURE NAME *** -CoarseMeshTextureNames = [ ] - - -# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** -MultipleTilesPostfix = [ ] -MultipleTilesPostfix += [ "_sp" ] -MultipleTilesPostfix += [ "_su" ] -MultipleTilesPostfix += [ "_au" ] -MultipleTilesPostfix += [ "_wi" ] - - -# *** SHADOW SKIN OPTIONS *** -# Characters are made of approx 4000 polys with multiple Skins binded (legs, short, torso...). 35% => 1400 polys. -BuildShadowSkin = 1 -BuildShadowSkinRatio = 35 -BuildShadowSkinMaxface = 2000 - - -# *** ANIMATIONS OPTIONS *** - -DoOptimizeAnimations = 1 +#!/usr/bin/python +# +# \file config.py +# \brief Process configuration +# \date 2010-08-27 17:02GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Process configuration. +# +# NeL - 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 . +# + +# *** PROCESS CONFIGURATION *** + +# *** PROCESS CONFIG *** +ProcessToComplete = [ ] +ProcessToComplete += [ "skel" ] +ProcessToComplete += [ "swt" ] +ProcessToComplete += [ "shape" ] +ProcessToComplete += [ "anim" ] +ProcessToComplete += [ "clodbank" ] + + +# *** COMMON NAMES AND PATHS *** +EcosystemName = "characters" +EcosystemPath = "common/" + EcosystemName +ContinentName = EcosystemName +ContinentPath = EcosystemPath +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** SHAPE EXPORT OPTIONS *** + +# Compute lightmaps ? +ShapeExportOptExportLighting = "true" + +# Cast shadow in lightmap ? +ShapeExportOptShadow = "true" + +# Lighting limits. 0 : normal, 1 : soft shadows +ShapeExportOptLightingLimit = 0 + +# Lightmap lumel size +ShapeExportOptLumelSize = "0.25" + +# Oversampling value. Can be 1, 2, 4 or 8 +ShapeExportOptOversampling = 1 + +# Does the lightmap must be generated in 8 bits format ? +ShapeExportOpt8BitsLightmap = "false" + +# Does the lightmaps export must generate logs ? +ShapeExportOptLightmapLog = "true" + +# Coarse mesh texture mul size +TextureMulSizeValue = "1.5" + +DoBuildShadowSkin = 0 + + +#panoply_file_list = panoply_files.txt ??? +#hls_bank_file_name = characters.hlsbank ??? + + + +# *** CLODBANK OPTIONS *** + +ClodConfigFile = "stuff/lod_actors/lod_" + CommonName + "/clod_char_script.cfg" +ClodBankFileName = CommonName + ".clodbank" + + +# *** COARSE MESH TEXTURE NAME *** +CoarseMeshTextureNames = [ ] + + +# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** +MultipleTilesPostfix = [ ] +MultipleTilesPostfix += [ "_sp" ] +MultipleTilesPostfix += [ "_su" ] +MultipleTilesPostfix += [ "_au" ] +MultipleTilesPostfix += [ "_wi" ] + + +# *** SHADOW SKIN OPTIONS *** +# Characters are made of approx 4000 polys with multiple Skins binded (legs, short, torso...). 35% => 1400 polys. +BuildShadowSkin = 1 +BuildShadowSkinRatio = 35 +BuildShadowSkinMaxface = 2000 + + +# *** ANIMATIONS OPTIONS *** + +DoOptimizeAnimations = 1 diff --git a/code/ryzom/tools/build_gamedata/workspace/common/characters_maps_hr/directories.py b/code/ryzom/tools/build_gamedata/workspace/common/characters_maps_hr/directories.py index 2e516872f..e58a3e0a6 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/characters_maps_hr/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/characters_maps_hr/directories.py @@ -1,78 +1,78 @@ -#!/usr/bin/python -# -# \file directories.py -# \brief Directories configuration -# \date 2010-08-27 17:13GMT -# \author Jan Boon (Kaetemi) -# \date 2001-2005 -# \author Nevrax -# Python port of game data build pipeline. -# Directories configuration. -# -# NeL - 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 . -# - - -# *** COMMON NAMES AND PATHS *** -EcosystemName = "characters_maps_hr" -EcosystemPath = "common/" + EcosystemName -ContinentName = EcosystemName -ContinentPath = EcosystemPath -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** SOURCE DIRECTORIES IN THE DATABASE *** - -# Maps directories -MapSourceDirectories = [ ] -MapSourceDirectories += [ "stuff/caravan/agents/_textures/actors" ] -MapSourceDirectories += [ "stuff/caravan/agents/_textures/actors/visages" ] - -MapUncompressedSourceDirectories = [ ] - -MapPanoplySourceDirectories = [ ] -MapPanoplySourceDirectories += [ [ "panoply_common.cfg" ] + [ "panoply_matis.cfg" ] + [ "stuff/matis/agents/_textures/actors" ] + [ "stuff/matis/agents/_textures/actors/mask" ] ] -MapPanoplySourceDirectories += [ [ "panoply_common.cfg" ] + [ "panoply_tryker.cfg" ] + [ "stuff/tryker/agents/_textures/actors" ] + [ "stuff/tryker/agents/_textures/actors/mask" ] ] -MapPanoplySourceDirectories += [ [ "panoply_common.cfg" ] + [ "panoply_fyros.cfg" ] + [ "stuff/fyros/agents/_textures/actors" ] + [ "stuff/fyros/agents/_textures/actors/mask" ] ] -MapPanoplySourceDirectories += [ [ "panoply_common.cfg" ] + [ "panoply_zorai.cfg" ] + [ "stuff/zorai/agents/_textures/actors" ] + [ "stuff/zorai/agents/_textures/actors/mask" ] ] -MapPanoplySourceDirectories += [ [ "panoply_common.cfg" ] + [ "panoply_generique.cfg" ] + [ "stuff/generique/agents/_textures/actors" ] + [ "stuff/generique/agents/_textures/actors/mask" ] ] - - -# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapExportDirectory = CommonPath + "/map_export" -MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" - - -# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapBuildDirectory = CommonPath + "/map" -MapPanoplyBuildDirectory = CommonPath + "/map_panoply" -MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" -MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" -MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" -MapTagBuildDirectory = CommonPath + "/map_tag" - - -# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** - -# Map directory -MapInstallDirectory = CommonName -BitmapInstallDirectory = MapInstallDirectory +#!/usr/bin/python +# +# \file directories.py +# \brief Directories configuration +# \date 2010-08-27 17:13GMT +# \author Jan Boon (Kaetemi) +# \date 2001-2005 +# \author Nevrax +# Python port of game data build pipeline. +# Directories configuration. +# +# NeL - 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 . +# + + +# *** COMMON NAMES AND PATHS *** +EcosystemName = "characters_maps_hr" +EcosystemPath = "common/" + EcosystemName +ContinentName = EcosystemName +ContinentPath = EcosystemPath +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** SOURCE DIRECTORIES IN THE DATABASE *** + +# Maps directories +MapSourceDirectories = [ ] +MapSourceDirectories += [ "stuff/caravan/agents/_textures/actors" ] +MapSourceDirectories += [ "stuff/caravan/agents/_textures/actors/visages" ] + +MapUncompressedSourceDirectories = [ ] + +MapPanoplySourceDirectories = [ ] +MapPanoplySourceDirectories += [ [ "panoply_common.cfg" ] + [ "panoply_matis.cfg" ] + [ "stuff/matis/agents/_textures/actors" ] + [ "stuff/matis/agents/_textures/actors/mask" ] ] +MapPanoplySourceDirectories += [ [ "panoply_common.cfg" ] + [ "panoply_tryker.cfg" ] + [ "stuff/tryker/agents/_textures/actors" ] + [ "stuff/tryker/agents/_textures/actors/mask" ] ] +MapPanoplySourceDirectories += [ [ "panoply_common.cfg" ] + [ "panoply_fyros.cfg" ] + [ "stuff/fyros/agents/_textures/actors" ] + [ "stuff/fyros/agents/_textures/actors/mask" ] ] +MapPanoplySourceDirectories += [ [ "panoply_common.cfg" ] + [ "panoply_zorai.cfg" ] + [ "stuff/zorai/agents/_textures/actors" ] + [ "stuff/zorai/agents/_textures/actors/mask" ] ] +MapPanoplySourceDirectories += [ [ "panoply_common.cfg" ] + [ "panoply_generique.cfg" ] + [ "stuff/generique/agents/_textures/actors" ] + [ "stuff/generique/agents/_textures/actors/mask" ] ] + + +# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapExportDirectory = CommonPath + "/map_export" +MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" + + +# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapBuildDirectory = CommonPath + "/map" +MapPanoplyBuildDirectory = CommonPath + "/map_panoply" +MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" +MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" +MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" +MapTagBuildDirectory = CommonPath + "/map_tag" + + +# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** + +# Map directory +MapInstallDirectory = CommonName +BitmapInstallDirectory = MapInstallDirectory diff --git a/code/ryzom/tools/build_gamedata/workspace/common/characters_maps_hr/process.py b/code/ryzom/tools/build_gamedata/workspace/common/characters_maps_hr/process.py index 7ce7af501..c15ea5d24 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/characters_maps_hr/process.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/characters_maps_hr/process.py @@ -1,81 +1,81 @@ -#!/usr/bin/python -# -# \file config.py -# \brief Process configuration -# \date 2010-08-27 17:02GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Process configuration. -# -# NeL - 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 . -# - -# *** PROCESS CONFIGURATION *** - - -# *** PROCESS CONFIG *** -ProcessToComplete = [ ] -ProcessToComplete += [ "map" ] - - -# *** COMMON NAMES AND PATHS *** -EcosystemName = "characters_maps_hr" -EcosystemPath = "common/" + EcosystemName -ContinentName = EcosystemName -ContinentPath = EcosystemPath -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** SHAPE EXPORT OPTIONS *** - -# Compute lightmaps ? -ShapeExportOptExportLighting = "true" -# Cast shadow in lightmap ? -ShapeExportOptShadow = "true" -# Lighting limits. 0 : normal, 1 : soft shadows -ShapeExportOptLightingLimit = 0 -# Lightmap lumel size -ShapeExportOptLumelSize = "0.25" -# Oversampling value. Can be 1, 2, 4 or 8 -ShapeExportOptOversampling = 1 -# Does the lightmap must be generated in 8 bits format ? -ShapeExportOpt8BitsLightmap = "false" -# Does the lightmaps export must generate logs ? -ShapeExportOptLightmapLog = "true" -# Coarse mesh texture mul size -TextureMulSizeValue = "1.5" - -DoBuildShadowSkin = 0 -ClodConfigFile = "" - -# *** COARSE MESH TEXTURE NAME *** -CoarseMeshTextureNames = [ ] - -# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** -MultipleTilesPostfix = [ ] -MultipleTilesPostfix += [ "_sp" ] -MultipleTilesPostfix += [ "_su" ] -MultipleTilesPostfix += [ "_au" ] -MultipleTilesPostfix += [ "_wi" ] - -# *** MAPS OPTIONS *** -ReduceBitmapFactor = 0 -# list all panoply files -MapPanoplyFileList = "panoply_files.txt" -# name of the .hlsbank to build. -MapHlsBankFileName = "characters.hlsbank" +#!/usr/bin/python +# +# \file config.py +# \brief Process configuration +# \date 2010-08-27 17:02GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Process configuration. +# +# NeL - 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 . +# + +# *** PROCESS CONFIGURATION *** + + +# *** PROCESS CONFIG *** +ProcessToComplete = [ ] +ProcessToComplete += [ "map" ] + + +# *** COMMON NAMES AND PATHS *** +EcosystemName = "characters_maps_hr" +EcosystemPath = "common/" + EcosystemName +ContinentName = EcosystemName +ContinentPath = EcosystemPath +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** SHAPE EXPORT OPTIONS *** + +# Compute lightmaps ? +ShapeExportOptExportLighting = "true" +# Cast shadow in lightmap ? +ShapeExportOptShadow = "true" +# Lighting limits. 0 : normal, 1 : soft shadows +ShapeExportOptLightingLimit = 0 +# Lightmap lumel size +ShapeExportOptLumelSize = "0.25" +# Oversampling value. Can be 1, 2, 4 or 8 +ShapeExportOptOversampling = 1 +# Does the lightmap must be generated in 8 bits format ? +ShapeExportOpt8BitsLightmap = "false" +# Does the lightmaps export must generate logs ? +ShapeExportOptLightmapLog = "true" +# Coarse mesh texture mul size +TextureMulSizeValue = "1.5" + +DoBuildShadowSkin = 0 +ClodConfigFile = "" + +# *** COARSE MESH TEXTURE NAME *** +CoarseMeshTextureNames = [ ] + +# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** +MultipleTilesPostfix = [ ] +MultipleTilesPostfix += [ "_sp" ] +MultipleTilesPostfix += [ "_su" ] +MultipleTilesPostfix += [ "_au" ] +MultipleTilesPostfix += [ "_wi" ] + +# *** MAPS OPTIONS *** +ReduceBitmapFactor = 0 +# list all panoply files +MapPanoplyFileList = "panoply_files.txt" +# name of the .hlsbank to build. +MapHlsBankFileName = "characters.hlsbank" diff --git a/code/ryzom/tools/build_gamedata/workspace/common/construction/directories.py b/code/ryzom/tools/build_gamedata/workspace/common/construction/directories.py index 68bf17aa7..8228ac9b4 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/construction/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/construction/directories.py @@ -1,168 +1,168 @@ -#!/usr/bin/python -# -# \file directories.py -# \brief Directories configuration -# \date 2010-08-27 17:13GMT -# \author Jan Boon (Kaetemi) -# \date 2001-2005 -# \author Nevrax -# Python port of game data build pipeline. -# Directories configuration. -# -# NeL - 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 . -# - - -# *** COMMON NAMES AND PATHS *** -EcosystemName = "construction" -EcosystemPath = "common/" + EcosystemName -ContinentName = EcosystemName -ContinentPath = EcosystemPath -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** SOURCE DIRECTORIES LEVELDESIGN/WORLD *** -ContinentLeveldesignWorldDirectory = "" # DISABLED - - -# *** SOURCE DIRECTORIES IN THE DATABASE *** - -# Shape directories -ShapeSourceDirectories = [ ] -ShapeSourceDirectories += [ "stuff/Generique/Decors/Constructions" ] - -# Maps directories -MapSourceDirectories = [ ] -MapSourceDirectories += [ "stuff/Generique/Decors/_Textures/Batiments" ] - -MapUncompressedSourceDirectories = [ ] - -# Ligo directories -LigoBaseSourceDirectory = "landscape/ligo" - -# Ig directories -IgLandSourceDirectories = [ ] -IgOtherSourceDirectories = [ ] -IgOtherSourceDirectories += [ "stuff/Generique/Decors/Constructions" ] -IgPrimitiveSourceDirectories = [ ] - -# Tiles root directory -TileRootSourceDirectory = "landscape/_texture_tiles" - -# Displace directory -DisplaceSourceDirectory = "landscape/_texture_tiles/displace" - - -# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) - -# Ig lookup directories used by rbank -IgLookupDirectories = [ ] -IgLookupDirectories += [ CommonPath + "/ig_land" ] -IgLookupDirectories += [ CommonPath + "/ig_other" ] - -# Shape lookup directories used by rbank -ShapeLookupDirectories = [ ] -# ShapeLookupDirectories += [ CommonPath + "/ps" ] -ShapeLookupDirectories += [ CommonPath + "/shape_clodtex_build" ] -ShapeLookupDirectories += [ CommonPath + "/shape_with_coarse_mesh" ] - -# Map lookup directories not yet used -MapLookupDirectories = [ ] -MapLookupDirectories += [ CommonPath + "/map_export" ] -MapLookupDirectories += [ CommonPath + "/map_uncompressed" ] - - -# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapExportDirectory = CommonPath + "/map_export" -MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" - -# Shape directories -ShapeTagExportDirectory = CommonPath + "/shape_tag" -ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" -ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" -ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" -ShapeAnimExportDirectory = CommonPath + "/shape_anim" - -# Ig directories -IgStaticLandExportDirectory = CommonPath + "/ig_static_land" # Landscape IG eported from 3dsmax not elevated by the heightmap -IgStaticOtherExportDirectory = CommonPath + "/ig_static_other" # Village or construction IGs exported from 3dsmax -IgStaticTagExportDirectory = CommonPath + "/ig_static_tag" # Tag for exported 3dsmax files - -# Zone directories -ZoneWeldBuildDirectory = CommonPath + "/zone_weld" -ZoneDependBuildDirectory = CommonPath + "/zone_depend" -ZoneLightWaterShapesLightedExportDirectory = CommonPath + "/zone_lwsl_temp" #fixme -ZoneLightBuildDirectory = CommonPath + "/zone_lighted" #fixme -ZoneLightDependBuildDirectory = CommonPath + "/zone_lighted_depend" #fixme -ZoneLightIgLandBuildDirectory = CommonPath + "/zone_lighted_ig_land" #fixme - - -# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapBuildDirectory = CommonPath + "/map" -MapPanoplyBuildDirectory = CommonPath + "/map_panoply" -MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" -MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" -MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" -MapTagBuildDirectory = CommonPath + "/map_tag" - -# Shape directories -ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" -ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" -ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" -ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" - -# Ig directories -IgElevLandPrimBuildDirectory = CommonPath + "/ig_elev_land_prim" # landscape IG generated by the prim exporter (already elevated by the land exporter) -IgElevLandLigoBuildDirectory = CommonPath + "/ig_elev_land_ligo" # Landscape IG found in ligo bricks from 3dsmax elevated by the heightmap -IgElevLandStaticBuildDirectory = CommonPath + "/ig_elev_land_static" # Landscape IG eported from 3dsmax elevated by the heightmap -IgTempLandMergeBuildDirectory = CommonPath + "/ig_temp_land_merge" -IgTempLandCompareBuildDirectory = CommonPath + "/ig_temp_land_compare" # Tmp final IG directory for landscape IGs before comparison -IgLandBuildDirectory = CommonPath + "/ig_land" # Final IG directory for landscape IGs -IgOtherBuildDirectory = CommonPath + "/ig_other" # Final IG directory for village or construction IGs -IgOtherLightedBuildDirectory = CommonPath + "/ig_other_lighted" - -# Farbank directories -FarbankBuildDirectory = CommonPath + "/farbank" - -# Ligo directories -LigoZoneBuildDirectory = CommonPath + "/ligo_zones" -LigoIgLandBuildDirectory = CommonPath + "/ligo_ig_land" # Landscape IG found in ligo bricks not elevated by the heightmap -LigoIgOtherBuildDirectory = CommonPath + "/ligo_ig_other" # Village or construction IGs exported from ligo landscape - - -# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** - -# Map directory -MapInstallDirectory = CommonName -BitmapInstallDirectory = MapInstallDirectory - -# Shape directory -ShapeInstallDirectory = CommonName - -# Lightmap directory -LightmapInstallDirectory = CommonName - -# Animation directory -AnimInstallDirectory = CommonName - -# Ig directory -IgInstallDirectory = CommonName +#!/usr/bin/python +# +# \file directories.py +# \brief Directories configuration +# \date 2010-08-27 17:13GMT +# \author Jan Boon (Kaetemi) +# \date 2001-2005 +# \author Nevrax +# Python port of game data build pipeline. +# Directories configuration. +# +# NeL - 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 . +# + + +# *** COMMON NAMES AND PATHS *** +EcosystemName = "construction" +EcosystemPath = "common/" + EcosystemName +ContinentName = EcosystemName +ContinentPath = EcosystemPath +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** SOURCE DIRECTORIES LEVELDESIGN/WORLD *** +ContinentLeveldesignWorldDirectory = "" # DISABLED + + +# *** SOURCE DIRECTORIES IN THE DATABASE *** + +# Shape directories +ShapeSourceDirectories = [ ] +ShapeSourceDirectories += [ "stuff/Generique/Decors/Constructions" ] + +# Maps directories +MapSourceDirectories = [ ] +MapSourceDirectories += [ "stuff/Generique/Decors/_Textures/Batiments" ] + +MapUncompressedSourceDirectories = [ ] + +# Ligo directories +LigoBaseSourceDirectory = "landscape/ligo" + +# Ig directories +IgLandSourceDirectories = [ ] +IgOtherSourceDirectories = [ ] +IgOtherSourceDirectories += [ "stuff/Generique/Decors/Constructions" ] +IgPrimitiveSourceDirectories = [ ] + +# Tiles root directory +TileRootSourceDirectory = "landscape/_texture_tiles" + +# Displace directory +DisplaceSourceDirectory = "landscape/_texture_tiles/displace" + + +# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) + +# Ig lookup directories used by rbank +IgLookupDirectories = [ ] +IgLookupDirectories += [ CommonPath + "/ig_land" ] +IgLookupDirectories += [ CommonPath + "/ig_other" ] + +# Shape lookup directories used by rbank +ShapeLookupDirectories = [ ] +# ShapeLookupDirectories += [ CommonPath + "/ps" ] +ShapeLookupDirectories += [ CommonPath + "/shape_clodtex_build" ] +ShapeLookupDirectories += [ CommonPath + "/shape_with_coarse_mesh" ] + +# Map lookup directories not yet used +MapLookupDirectories = [ ] +MapLookupDirectories += [ CommonPath + "/map_export" ] +MapLookupDirectories += [ CommonPath + "/map_uncompressed" ] + + +# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapExportDirectory = CommonPath + "/map_export" +MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" + +# Shape directories +ShapeTagExportDirectory = CommonPath + "/shape_tag" +ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" +ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" +ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" +ShapeAnimExportDirectory = CommonPath + "/shape_anim" + +# Ig directories +IgStaticLandExportDirectory = CommonPath + "/ig_static_land" # Landscape IG eported from 3dsmax not elevated by the heightmap +IgStaticOtherExportDirectory = CommonPath + "/ig_static_other" # Village or construction IGs exported from 3dsmax +IgStaticTagExportDirectory = CommonPath + "/ig_static_tag" # Tag for exported 3dsmax files + +# Zone directories +ZoneWeldBuildDirectory = CommonPath + "/zone_weld" +ZoneDependBuildDirectory = CommonPath + "/zone_depend" +ZoneLightWaterShapesLightedExportDirectory = CommonPath + "/zone_lwsl_temp" #fixme +ZoneLightBuildDirectory = CommonPath + "/zone_lighted" #fixme +ZoneLightDependBuildDirectory = CommonPath + "/zone_lighted_depend" #fixme +ZoneLightIgLandBuildDirectory = CommonPath + "/zone_lighted_ig_land" #fixme + + +# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapBuildDirectory = CommonPath + "/map" +MapPanoplyBuildDirectory = CommonPath + "/map_panoply" +MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" +MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" +MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" +MapTagBuildDirectory = CommonPath + "/map_tag" + +# Shape directories +ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" +ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" +ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" +ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" + +# Ig directories +IgElevLandPrimBuildDirectory = CommonPath + "/ig_elev_land_prim" # landscape IG generated by the prim exporter (already elevated by the land exporter) +IgElevLandLigoBuildDirectory = CommonPath + "/ig_elev_land_ligo" # Landscape IG found in ligo bricks from 3dsmax elevated by the heightmap +IgElevLandStaticBuildDirectory = CommonPath + "/ig_elev_land_static" # Landscape IG eported from 3dsmax elevated by the heightmap +IgTempLandMergeBuildDirectory = CommonPath + "/ig_temp_land_merge" +IgTempLandCompareBuildDirectory = CommonPath + "/ig_temp_land_compare" # Tmp final IG directory for landscape IGs before comparison +IgLandBuildDirectory = CommonPath + "/ig_land" # Final IG directory for landscape IGs +IgOtherBuildDirectory = CommonPath + "/ig_other" # Final IG directory for village or construction IGs +IgOtherLightedBuildDirectory = CommonPath + "/ig_other_lighted" + +# Farbank directories +FarbankBuildDirectory = CommonPath + "/farbank" + +# Ligo directories +LigoZoneBuildDirectory = CommonPath + "/ligo_zones" +LigoIgLandBuildDirectory = CommonPath + "/ligo_ig_land" # Landscape IG found in ligo bricks not elevated by the heightmap +LigoIgOtherBuildDirectory = CommonPath + "/ligo_ig_other" # Village or construction IGs exported from ligo landscape + + +# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** + +# Map directory +MapInstallDirectory = CommonName +BitmapInstallDirectory = MapInstallDirectory + +# Shape directory +ShapeInstallDirectory = CommonName + +# Lightmap directory +LightmapInstallDirectory = CommonName + +# Animation directory +AnimInstallDirectory = CommonName + +# Ig directory +IgInstallDirectory = CommonName diff --git a/code/ryzom/tools/build_gamedata/workspace/common/construction/process.py b/code/ryzom/tools/build_gamedata/workspace/common/construction/process.py index 4a72136e3..f2259fa4b 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/construction/process.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/construction/process.py @@ -1,114 +1,114 @@ -#!/usr/bin/python -# -# \file config.py -# \brief Process configuration -# \date 2010-08-27 17:02GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Process configuration. -# -# NeL - 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 . -# - -# *** PROCESS CONFIGURATION *** - - -# *** PROCESS CONFIG *** -ProcessToComplete = [ ] -ProcessToComplete += [ "properties" ] -ProcessToComplete += [ "shape" ] -ProcessToComplete += [ "map" ] -ProcessToComplete += [ "ig" ] -ProcessToComplete += [ "ig_light" ] - - -# *** COMMON NAMES AND PATHS *** -EcosystemName = "construction" -EcosystemPath = "common/" + EcosystemName -ContinentName = EcosystemName -ContinentPath = EcosystemPath -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** SHAPE EXPORT OPTIONS *** - -# Compute lightmaps ? -ShapeExportOptExportLighting = "true" - -# Cast shadow in lightmap ? -ShapeExportOptShadow = "true" - -# Lighting limits. 0 : normal, 1 : soft shadows -ShapeExportOptLightingLimit = 0 - -# Lightmap lumel size -ShapeExportOptLumelSize = "0.25" - -# Oversampling value. Can be 1, 2, 4 or 8 -ShapeExportOptOversampling = 1 - -# Does the lightmap must be generated in 8 bits format ? -ShapeExportOpt8BitsLightmap = "false" - -# Does the lightmaps export must generate logs ? -ShapeExportOptLightmapLog = "true" - -# Coarse mesh texture mul size -TextureMulSizeValue = "1.5" - -DoBuildShadowSkin = 0 - -ClodConfigFile = "" - -# *** COARSE MESH TEXTURE NAME *** -CoarseMeshTextureNames = [ ] - -# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** -MultipleTilesPostfix = [ ] -MultipleTilesPostfix += [ "_sp" ] -MultipleTilesPostfix += [ "_su" ] -MultipleTilesPostfix += [ "_au" ] -MultipleTilesPostfix += [ "_wi" ] - -# Name of the tilebank to use -BankTileBankName = "" - -# *** LANDSCAPE NAME *** -LandscapeName = "" - -# *** LIGO OPTIONS *** -LigoExportLand = "" -LigoExportOnePass = 0 -LigoExportColormap = "colormap_invalid.png" -LigoExportHeightmap1 = "big_invalid.png" -LigoExportZFactor1 = "1.0" -LigoExportHeightmap2 = "noise_invalid.png" -LigoExportZFactor2 = "0.5" -LigoTileBankFile = "" - -# *** MAPS OPTIONS *** - -ReduceBitmapFactor = 0 -# list all panoply files -MapPanoplyFileList = None -# name of the .hlsbank to build. -MapHlsBankFileName = None - -# *** ANIMATIONS OPTIONS *** - -DoOptimizeAnimations = 0 +#!/usr/bin/python +# +# \file config.py +# \brief Process configuration +# \date 2010-08-27 17:02GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Process configuration. +# +# NeL - 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 . +# + +# *** PROCESS CONFIGURATION *** + + +# *** PROCESS CONFIG *** +ProcessToComplete = [ ] +ProcessToComplete += [ "properties" ] +ProcessToComplete += [ "shape" ] +ProcessToComplete += [ "map" ] +ProcessToComplete += [ "ig" ] +ProcessToComplete += [ "ig_light" ] + + +# *** COMMON NAMES AND PATHS *** +EcosystemName = "construction" +EcosystemPath = "common/" + EcosystemName +ContinentName = EcosystemName +ContinentPath = EcosystemPath +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** SHAPE EXPORT OPTIONS *** + +# Compute lightmaps ? +ShapeExportOptExportLighting = "true" + +# Cast shadow in lightmap ? +ShapeExportOptShadow = "true" + +# Lighting limits. 0 : normal, 1 : soft shadows +ShapeExportOptLightingLimit = 0 + +# Lightmap lumel size +ShapeExportOptLumelSize = "0.25" + +# Oversampling value. Can be 1, 2, 4 or 8 +ShapeExportOptOversampling = 1 + +# Does the lightmap must be generated in 8 bits format ? +ShapeExportOpt8BitsLightmap = "false" + +# Does the lightmaps export must generate logs ? +ShapeExportOptLightmapLog = "true" + +# Coarse mesh texture mul size +TextureMulSizeValue = "1.5" + +DoBuildShadowSkin = 0 + +ClodConfigFile = "" + +# *** COARSE MESH TEXTURE NAME *** +CoarseMeshTextureNames = [ ] + +# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** +MultipleTilesPostfix = [ ] +MultipleTilesPostfix += [ "_sp" ] +MultipleTilesPostfix += [ "_su" ] +MultipleTilesPostfix += [ "_au" ] +MultipleTilesPostfix += [ "_wi" ] + +# Name of the tilebank to use +BankTileBankName = "" + +# *** LANDSCAPE NAME *** +LandscapeName = "" + +# *** LIGO OPTIONS *** +LigoExportLand = "" +LigoExportOnePass = 0 +LigoExportColormap = "colormap_invalid.png" +LigoExportHeightmap1 = "big_invalid.png" +LigoExportZFactor1 = "1.0" +LigoExportHeightmap2 = "noise_invalid.png" +LigoExportZFactor2 = "0.5" +LigoTileBankFile = "" + +# *** MAPS OPTIONS *** + +ReduceBitmapFactor = 0 +# list all panoply files +MapPanoplyFileList = None +# name of the .hlsbank to build. +MapHlsBankFileName = None + +# *** ANIMATIONS OPTIONS *** + +DoOptimizeAnimations = 0 diff --git a/code/ryzom/tools/build_gamedata/workspace/common/data_common/directories.py b/code/ryzom/tools/build_gamedata/workspace/common/data_common/directories.py index c2399a190..5fc0be432 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/data_common/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/data_common/directories.py @@ -1,73 +1,73 @@ -#!/usr/bin/python -# -# \file directories.py -# \brief Directories configuration -# \date 2010-08-27 17:13GMT -# \author Jan Boon (Kaetemi) -# \date 2001-2005 -# \author Nevrax -# Python port of game data build pipeline. -# Directories configuration. -# -# NeL - 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 . -# - -from buildsite import * - -# *** COMMON NAMES AND PATHS *** -CommonName = "data_common" -CommonPath = "common/" + CommonName - - -# *** DIRECT SOURCE DIRECTORIES *** - -# Copy dir directories -CopyDirectSourceDirectories = [ ] -CopyDirectSourceDirectories += [ DataCommonDirectory ] -CopyDirectSourceFiles = [ ] - - -# *** SOURCE DIRECTORIES IN LEVELDESIGN *** -CopyLeveldesignSourceDirectories = [ ] -CopyLeveldesignSourceFiles = [ ] -CopyLeveldesignWorldSourceDirectories = [ ] -CopyLeveldesignWorldSourceFiles = [ ] -CopyLeveldesignDfnSourceDirectories = [ ] -CopyLeveldesignDfnSourceFiles = [ ] - - -# *** SOURCE DIRECTORIES IN THE DATABASE *** - -# Copy dir directories -CopyDatabaseSourceDirectories = [ ] -CopyDatabaseSourceFiles = [ ] - - -# *** SOURCE DIRECTORIES IN THE EXPORT/BUILD *** - -# Pacs prim list source directories -PacsPrimExportSourceDirectories = [ ] -PacsPrimExportSourceDirectories += [ "ecosystems/desert/pacs_prim" ] -PacsPrimExportSourceDirectories += [ "ecosystems/jungle/pacs_prim" ] -PacsPrimExportSourceDirectories += [ "ecosystems/lacustre/pacs_prim" ] -PacsPrimExportSourceDirectories += [ "ecosystems/primes_racines/pacs_prim" ] - - -# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** - -# Common data install directory -CopyInstallDirectory = CommonName +#!/usr/bin/python +# +# \file directories.py +# \brief Directories configuration +# \date 2010-08-27 17:13GMT +# \author Jan Boon (Kaetemi) +# \date 2001-2005 +# \author Nevrax +# Python port of game data build pipeline. +# Directories configuration. +# +# NeL - 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 . +# + +from buildsite import * + +# *** COMMON NAMES AND PATHS *** +CommonName = "data_common" +CommonPath = "common/" + CommonName + + +# *** DIRECT SOURCE DIRECTORIES *** + +# Copy dir directories +CopyDirectSourceDirectories = [ ] +CopyDirectSourceDirectories += [ DataCommonDirectory ] +CopyDirectSourceFiles = [ ] + + +# *** SOURCE DIRECTORIES IN LEVELDESIGN *** +CopyLeveldesignSourceDirectories = [ ] +CopyLeveldesignSourceFiles = [ ] +CopyLeveldesignWorldSourceDirectories = [ ] +CopyLeveldesignWorldSourceFiles = [ ] +CopyLeveldesignDfnSourceDirectories = [ ] +CopyLeveldesignDfnSourceFiles = [ ] + + +# *** SOURCE DIRECTORIES IN THE DATABASE *** + +# Copy dir directories +CopyDatabaseSourceDirectories = [ ] +CopyDatabaseSourceFiles = [ ] + + +# *** SOURCE DIRECTORIES IN THE EXPORT/BUILD *** + +# Pacs prim list source directories +PacsPrimExportSourceDirectories = [ ] +PacsPrimExportSourceDirectories += [ "ecosystems/desert/pacs_prim" ] +PacsPrimExportSourceDirectories += [ "ecosystems/jungle/pacs_prim" ] +PacsPrimExportSourceDirectories += [ "ecosystems/lacustre/pacs_prim" ] +PacsPrimExportSourceDirectories += [ "ecosystems/primes_racines/pacs_prim" ] + + +# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** + +# Common data install directory +CopyInstallDirectory = CommonName diff --git a/code/ryzom/tools/build_gamedata/workspace/common/data_common/process.py b/code/ryzom/tools/build_gamedata/workspace/common/data_common/process.py index d00d44e8a..99ed076e3 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/data_common/process.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/data_common/process.py @@ -1,45 +1,45 @@ -#!/usr/bin/python -# -# \file config.py -# \brief Process configuration -# \date 2010-08-27 17:02GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Process configuration. -# -# NeL - 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 . -# - -# *** PROCESS CONFIGURATION *** - -# *** PROCESS CONFIG *** -ProcessToComplete = [ ] -ProcessToComplete += [ "pacs_prim_list" ] -ProcessToComplete += [ "copy" ] - - -# *** COMMON NAMES AND PATHS *** -CommonName = "data_common" -CommonPath = "common/" + CommonName - - -# *** PACS PRIM LIST OPTIONS *** - - -# *** COPY DIR OPTIONS *** - - +#!/usr/bin/python +# +# \file config.py +# \brief Process configuration +# \date 2010-08-27 17:02GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Process configuration. +# +# NeL - 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 . +# + +# *** PROCESS CONFIGURATION *** + +# *** PROCESS CONFIG *** +ProcessToComplete = [ ] +ProcessToComplete += [ "pacs_prim_list" ] +ProcessToComplete += [ "copy" ] + + +# *** COMMON NAMES AND PATHS *** +CommonName = "data_common" +CommonPath = "common/" + CommonName + + +# *** PACS PRIM LIST OPTIONS *** + + +# *** COPY DIR OPTIONS *** + + diff --git a/code/ryzom/tools/build_gamedata/workspace/common/exedll/directories.py b/code/ryzom/tools/build_gamedata/workspace/common/exedll/directories.py index dddf60ec8..3c5042899 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/exedll/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/exedll/directories.py @@ -1,86 +1,86 @@ -#!/usr/bin/python -# -# \file directories.py -# \brief Directories configuration -# \date 2010-08-27 17:13GMT -# \author Jan Boon (Kaetemi) -# \date 2001-2005 -# \author Nevrax -# Python port of game data build pipeline. -# Directories configuration. -# -# NeL - 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 . -# - - -# *** COMMON NAMES AND PATHS *** -CommonName = "exedll" -CommonPath = "common/" + CommonName - - -# *** DIRECT SOURCE DIRECTORIES *** - -# Copy dir directories -CopyDirectSourceDirectories = [ ] -CopyDirectSourceFiles = [ ] - - -# *** SOURCE DIRECTORIES IN LEVELDESIGN *** -CopyLeveldesignSourceDirectories = [ ] -CopyLeveldesignSourceFiles = [ ] -CopyLeveldesignWorldSourceDirectories = [ ] -CopyLeveldesignWorldSourceFiles = [ ] -CopyLeveldesignDfnSourceDirectories = [ ] -CopyLeveldesignDfnSourceFiles = [ ] - - -# *** SOURCE DIRECTORIES IN THE DATABASE *** - -# Copy dir directories -CopyDatabaseSourceDirectories = [ ] -CopyDatabaseSourceFiles = [ ] - - -# *** SPECIAL SOURCES *** - -# Copy dir directories -CopyWindowsExeDllCfgSourceFiles = [ ] - -CopyWindowsExeDllCfgSourceFiles += [ "Microsoft.VC90.CRT.manifest" ] -CopyWindowsExeDllCfgSourceFiles += [ "msvcp90.dll" ] -CopyWindowsExeDllCfgSourceFiles += [ "msvcr90.dll" ] - -CopyWindowsExeDllCfgSourceFiles += [ "fmod.dll" ] - -CopyWindowsExeDllCfgSourceFiles += [ "client_default.cfg" ] - -CopyWindowsExeDllCfgSourceFiles += [ "nel_drv_direct3d_win_r.dll" ] -CopyWindowsExeDllCfgSourceFiles += [ "nel_drv_dsound_win_r.dll" ] -CopyWindowsExeDllCfgSourceFiles += [ "nel_drv_fmod_win_r.dll" ] -CopyWindowsExeDllCfgSourceFiles += [ "nel_drv_openal_win_r.dll" ] -CopyWindowsExeDllCfgSourceFiles += [ "nel_drv_opengl_win_r.dll" ] -CopyWindowsExeDllCfgSourceFiles += [ "nel_drv_xaudio2_win_r.dll" ] - -CopyWindowsExeDllCfgSourceFiles += [ "client_ryzom_r.exe" ] -CopyWindowsExeDllCfgSourceFiles += [ "ryzom_client_r.exe" ] # i blame sfb -CopyWindowsExeDllCfgSourceFiles += [ "ryzom_configuration_r.exe" ] - - -# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** - -# Copy -CopyInstallDirectory = CommonName +#!/usr/bin/python +# +# \file directories.py +# \brief Directories configuration +# \date 2010-08-27 17:13GMT +# \author Jan Boon (Kaetemi) +# \date 2001-2005 +# \author Nevrax +# Python port of game data build pipeline. +# Directories configuration. +# +# NeL - 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 . +# + + +# *** COMMON NAMES AND PATHS *** +CommonName = "exedll" +CommonPath = "common/" + CommonName + + +# *** DIRECT SOURCE DIRECTORIES *** + +# Copy dir directories +CopyDirectSourceDirectories = [ ] +CopyDirectSourceFiles = [ ] + + +# *** SOURCE DIRECTORIES IN LEVELDESIGN *** +CopyLeveldesignSourceDirectories = [ ] +CopyLeveldesignSourceFiles = [ ] +CopyLeveldesignWorldSourceDirectories = [ ] +CopyLeveldesignWorldSourceFiles = [ ] +CopyLeveldesignDfnSourceDirectories = [ ] +CopyLeveldesignDfnSourceFiles = [ ] + + +# *** SOURCE DIRECTORIES IN THE DATABASE *** + +# Copy dir directories +CopyDatabaseSourceDirectories = [ ] +CopyDatabaseSourceFiles = [ ] + + +# *** SPECIAL SOURCES *** + +# Copy dir directories +CopyWindowsExeDllCfgSourceFiles = [ ] + +CopyWindowsExeDllCfgSourceFiles += [ "Microsoft.VC90.CRT.manifest" ] +CopyWindowsExeDllCfgSourceFiles += [ "msvcp90.dll" ] +CopyWindowsExeDllCfgSourceFiles += [ "msvcr90.dll" ] + +CopyWindowsExeDllCfgSourceFiles += [ "fmod.dll" ] + +CopyWindowsExeDllCfgSourceFiles += [ "client_default.cfg" ] + +CopyWindowsExeDllCfgSourceFiles += [ "nel_drv_direct3d_win_r.dll" ] +CopyWindowsExeDllCfgSourceFiles += [ "nel_drv_dsound_win_r.dll" ] +CopyWindowsExeDllCfgSourceFiles += [ "nel_drv_fmod_win_r.dll" ] +CopyWindowsExeDllCfgSourceFiles += [ "nel_drv_openal_win_r.dll" ] +CopyWindowsExeDllCfgSourceFiles += [ "nel_drv_opengl_win_r.dll" ] +CopyWindowsExeDllCfgSourceFiles += [ "nel_drv_xaudio2_win_r.dll" ] + +CopyWindowsExeDllCfgSourceFiles += [ "client_ryzom_r.exe" ] +CopyWindowsExeDllCfgSourceFiles += [ "ryzom_client_r.exe" ] # i blame sfb +CopyWindowsExeDllCfgSourceFiles += [ "ryzom_configuration_r.exe" ] + + +# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** + +# Copy +CopyInstallDirectory = CommonName diff --git a/code/ryzom/tools/build_gamedata/workspace/common/exedll/process.py b/code/ryzom/tools/build_gamedata/workspace/common/exedll/process.py index 7503248ee..5cc7f4439 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/exedll/process.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/exedll/process.py @@ -1,37 +1,37 @@ -#!/usr/bin/python -# -# \file config.py -# \brief Process configuration -# \date 2010-08-27 17:02GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Process configuration. -# -# NeL - 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 . -# - -# *** PROCESS CONFIGURATION *** - -# *** PROCESS CONFIG *** -ProcessToComplete = [ ] -ProcessToComplete += [ "copy" ] - - -# *** COMMON NAMES AND PATHS *** -CommonName = "exedll" -CommonPath = "common/" + CommonName - +#!/usr/bin/python +# +# \file config.py +# \brief Process configuration +# \date 2010-08-27 17:02GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Process configuration. +# +# NeL - 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 . +# + +# *** PROCESS CONFIGURATION *** + +# *** PROCESS CONFIG *** +ProcessToComplete = [ ] +ProcessToComplete += [ "copy" ] + + +# *** COMMON NAMES AND PATHS *** +CommonName = "exedll" +CommonPath = "common/" + CommonName + diff --git a/code/ryzom/tools/build_gamedata/workspace/common/fauna/directories.py b/code/ryzom/tools/build_gamedata/workspace/common/fauna/directories.py index dc4d5c568..1ece714c3 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/fauna/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/fauna/directories.py @@ -1,303 +1,303 @@ -#!/usr/bin/python -# -# \file directories.py -# \brief Directories configuration -# \date 2010-08-27 17:13GMT -# \author Jan Boon (Kaetemi) -# \date 2001-2005 -# \author Nevrax -# Python port of game data build pipeline. -# Directories configuration. -# -# NeL - 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 . -# - - -# *** COMMON NAMES AND PATHS *** -EcosystemName = "fauna" -EcosystemPath = "common/" + EcosystemName -ContinentName = EcosystemName -ContinentPath = EcosystemPath -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** SOURCE DIRECTORIES IN THE DATABASE *** - -# Skeleton directories -SkelSourceDirectories = [ ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/aquatique/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/aquatique_monture/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/cheval/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/chien/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/coureur/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/crustace/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/familier/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/grand_ryzomien/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kamiforet/animations/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kamiguard/animations/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/kitin/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/kitin_volant/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/oiseau/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/pachyderme/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/ryzomien/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/carnitree/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/electroalg/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/endrobouchea/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/phytopsy/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/sapenslaver/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/swarmplant/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_guide_2/animations/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_guide_3/animations/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_guide_4/animations/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_preacher_2/animations/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_preacher_3/animations/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_preacher_4/animations/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/homins_degeneres/cute/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/homins_degeneres/frahar/animation/skeletons" ] -SkelSourceDirectories += [ "stuff/tryker/agents/monsters/homins_degeneres/gibbai/animation/skeletons" ] - -# Skeleton template weight directories -SwtSourceDirectories = [ ] - -# Shape directories -ShapeSourceDirectories = [ ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/aquatique/clapclap" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/aquatique/ryzetacee" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/aquatique_monture/sagass_selle" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/cheval/mektoub" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/cheval/mektoubselle" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/cheval/mektoubpack" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/chien/chorani" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/chien/jungler" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/chien/regus" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/chien/varinx" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/coureur/capryni" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/coureur/filin" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/crustace/cococlaw" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/crustace/estrasson" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/crustace/hachtaha" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/crustace/diranak" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/familier/dag" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/grand_ryzomien/ryzerb" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/grand_ryzomien/ryzoholok" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kamiforet" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kamiguard" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_guide_2" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_guide_3" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_guide_4" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_preacher_2" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_preacher_3" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_preacher_4" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kitin/kitihank" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kitin/kitinagan" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kitin/kitinarak" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kitin/kitinega" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kitin/kitinokto" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kitin/kitimandib" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kitin/pucetron" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kitin_volant/kitifly" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kitin_volant/kitikil" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/oiseau/kazoar" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/oiseau/lightbird" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/oiseau/yber" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/pachyderme/arma" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/pachyderme/bul" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/pachyderme/vampignon" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/ryzomien/kakty" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/ryzomien/ryzoholo" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/ryzomien/zerx" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/carnitree" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/electroalg" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/endrobouchea" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/phytopsy" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/sapenslaver" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/swarmplant" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/homins_degeneres/cute" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/homins_degeneres/frahar" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/homins_degeneres/gibbai" ] -ShapeSourceDirectories += [ "stuff/goo/agents/monsters/aquatique" ] -ShapeSourceDirectories += [ "stuff/goo/agents/monsters/chiens" ] -ShapeSourceDirectories += [ "stuff/goo/agents/monsters/coureur" ] -ShapeSourceDirectories += [ "stuff/goo/agents/monsters/crustaces" ] -ShapeSourceDirectories += [ "stuff/goo/agents/monsters/grand_ryzomien" ] -ShapeSourceDirectories += [ "stuff/goo/agents/monsters/kitin" ] -ShapeSourceDirectories += [ "stuff/goo/agents/monsters/kitin_volant" ] -ShapeSourceDirectories += [ "stuff/goo/agents/monsters/oiseau" ] -ShapeSourceDirectories += [ "stuff/goo/agents/monsters/pachyderme/vampignon" ] -ShapeSourceDirectories += [ "stuff/goo/agents/monsters/ryzomien/kakty" ] -ShapeSourceDirectories += [ "stuff/goo/agents/monsters/ryzomien/ryzoholo" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/cheval/c03" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/cheval/h05" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/cheval/h12" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/chien/c02" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/chien/c07" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/coureur/h01" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/coureur/h04" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/crustace/c05" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/grand_ryzomien/c06" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/grand_ryzomien/h07" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/grand_ryzomien/h11" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/oiseau/c01" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/pachyderme/h08" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/pachyderme/h10" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/ryzomien/c04" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/ryzomien/h02" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/ryzomien/h06" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/ryzomien/h09" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/familier/h03" ] -ShapeSourceDirectories += [ "stuff/goo/agents/monsters/ryzomien/c04" ] -ShapeSourceDirectories += [ "stuff/goo/agents/monsters/familier/h03" ] -ShapeSourceDirectories += [ "stuff/goo/agents/monsters/homins_degeneres/cute" ] -ShapeSourceDirectories += [ "stuff/goo/agents/monsters/homins_degeneres/frahar" ] -ShapeSourceDirectories += [ "stuff/goo/agents/monsters/homins_degeneres/gibbai" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kitin/kitin_queen" ] - -# Maps directories -MapSourceDirectories = [ ] -MapSourceDirectories += [ "stuff/fyros/agents/_textures/monster" ] -MapSourceDirectories += [ "stuff/tryker/agents/_textures/monster" ] -MapSourceDirectories += [ "stuff/jungle/agents/_textures/monster" ] -MapSourceDirectories += [ "stuff/primes_racines/agents/_textures/monster" ] -MapSourceDirectories += [ "stuff/goo/agents/_textures/monster" ] - -MapUncompressedSourceDirectories = [ ] - -# Animation directories -AnimSourceDirectories = [ ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/aquatique/animation/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/aquatique_monture/animation/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/cheval/animation/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/chien/animation/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/coureur/animation/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/crustace/animation/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/familier/animation/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/grand_ryzomien/animation/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kamiforet/animations/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kamiguard/animations/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/kitin/animation/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/kitin_volant/animation/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/oiseau/animation/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/pachyderme/animation/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/ryzomien/animation/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/carnitree/animation/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/electroalg/animation/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/endrobouchea/animation/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/phytopsy/animation/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/sapenslaver/animation/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/swarmplant/animation/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_guide_2/animations/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_guide_3/animations/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_guide_4/animations/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_preacher_2/animations/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_preacher_3/animations/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_preacher_4/animations/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/homins_degeneres/cute/animation/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/homins_degeneres/frahar/animation/anims" ] -AnimSourceDirectories += [ "stuff/tryker/agents/monsters/homins_degeneres/gibbai/animation/anims" ] - -# cLoD shape directories -ClodSourceDirectories = [ ] -ClodSourceDirectories += [ "stuff/lod_actors/lod_fauna" ] - - -# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) - -# Ig lookup directories used by rbank -IgLookupDirectories = [ ] - -# Shape lookup directories used by rbank -ShapeLookupDirectories = [ ] -# ShapeLookupDirectories += [ CommonPath + "/ps" ] -ShapeLookupDirectories += [ CommonPath + "/shape_clodtex_build" ] -ShapeLookupDirectories += [ CommonPath + "/shape_with_coarse_mesh" ] - -# Map lookup directories not yet used -MapLookupDirectories = [ ] -MapLookupDirectories += [ CommonPath + "/map_export" ] -MapLookupDirectories += [ CommonPath + "/map_uncompressed" ] - - -# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapExportDirectory = CommonPath + "/map_export" -MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" - -# Skeleton directories -SkelExportDirectory = CommonPath + "/skel" - -# Skeleton template weight directories -SwtExportDirectory = CommonPath + "/swt" - -# Shape directories -ShapeTagExportDirectory = CommonPath + "/shape_tag" -ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" -ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" -ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" -ShapeAnimExportDirectory = CommonPath + "/shape_anim" - -# Animation directories -AnimExportDirectory = CommonPath + "/anim_export" -AnimTagExportDirectory = CommonPath + "/anim_tag" - -# cLoD directories -ClodExportDirectory = CommonPath + "/clod_export" -ClodTagExportDirectory = CommonPath + "/clod_tag_export" - - -# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapBuildDirectory = CommonPath + "/map" -MapPanoplyBuildDirectory = CommonPath + "/map_panoply" -MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" -MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" -MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" -MapTagBuildDirectory = CommonPath + "/map_tag" - -# Shape directories -ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" -ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" -ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" -ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" - -# Animation directories -AnimBuildDirectory = CommonPath + "/anim" - -# cLoD directories -ClodBankBuildDirectory = CommonPath + "/clod_bank" - - -# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** - -# Map directory -MapInstallDirectory = CommonName + "_maps" -BitmapInstallDirectory = MapInstallDirectory - -# Shape directory -ShapeInstallDirectory = CommonName + "_shapes" -LightmapInstallDirectory = ShapeInstallDirectory - -# Animation directory -AnimInstallDirectory = CommonName + "_animations" - -# Skeleton directory -SkelInstallDirectory = CommonName + "_skeletons" - -# Skeleton directory -SwtInstallDirectory = CommonName + "_swt" +#!/usr/bin/python +# +# \file directories.py +# \brief Directories configuration +# \date 2010-08-27 17:13GMT +# \author Jan Boon (Kaetemi) +# \date 2001-2005 +# \author Nevrax +# Python port of game data build pipeline. +# Directories configuration. +# +# NeL - 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 . +# + + +# *** COMMON NAMES AND PATHS *** +EcosystemName = "fauna" +EcosystemPath = "common/" + EcosystemName +ContinentName = EcosystemName +ContinentPath = EcosystemPath +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** SOURCE DIRECTORIES IN THE DATABASE *** + +# Skeleton directories +SkelSourceDirectories = [ ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/aquatique/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/aquatique_monture/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/cheval/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/chien/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/coureur/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/crustace/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/familier/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/grand_ryzomien/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kamiforet/animations/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kamiguard/animations/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/kitin/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/kitin_volant/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/oiseau/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/pachyderme/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/ryzomien/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/carnitree/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/electroalg/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/endrobouchea/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/phytopsy/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/sapenslaver/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/swarmplant/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_guide_2/animations/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_guide_3/animations/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_guide_4/animations/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_preacher_2/animations/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_preacher_3/animations/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_preacher_4/animations/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/homins_degeneres/cute/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/homins_degeneres/frahar/animation/skeletons" ] +SkelSourceDirectories += [ "stuff/tryker/agents/monsters/homins_degeneres/gibbai/animation/skeletons" ] + +# Skeleton template weight directories +SwtSourceDirectories = [ ] + +# Shape directories +ShapeSourceDirectories = [ ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/aquatique/clapclap" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/aquatique/ryzetacee" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/aquatique_monture/sagass_selle" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/cheval/mektoub" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/cheval/mektoubselle" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/cheval/mektoubpack" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/chien/chorani" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/chien/jungler" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/chien/regus" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/chien/varinx" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/coureur/capryni" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/coureur/filin" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/crustace/cococlaw" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/crustace/estrasson" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/crustace/hachtaha" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/crustace/diranak" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/familier/dag" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/grand_ryzomien/ryzerb" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/grand_ryzomien/ryzoholok" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kamiforet" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kamiguard" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_guide_2" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_guide_3" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_guide_4" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_preacher_2" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_preacher_3" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_preacher_4" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kitin/kitihank" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kitin/kitinagan" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kitin/kitinarak" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kitin/kitinega" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kitin/kitinokto" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kitin/kitimandib" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kitin/pucetron" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kitin_volant/kitifly" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kitin_volant/kitikil" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/oiseau/kazoar" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/oiseau/lightbird" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/oiseau/yber" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/pachyderme/arma" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/pachyderme/bul" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/pachyderme/vampignon" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/ryzomien/kakty" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/ryzomien/ryzoholo" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/ryzomien/zerx" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/carnitree" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/electroalg" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/endrobouchea" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/phytopsy" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/sapenslaver" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/swarmplant" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/homins_degeneres/cute" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/homins_degeneres/frahar" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/homins_degeneres/gibbai" ] +ShapeSourceDirectories += [ "stuff/goo/agents/monsters/aquatique" ] +ShapeSourceDirectories += [ "stuff/goo/agents/monsters/chiens" ] +ShapeSourceDirectories += [ "stuff/goo/agents/monsters/coureur" ] +ShapeSourceDirectories += [ "stuff/goo/agents/monsters/crustaces" ] +ShapeSourceDirectories += [ "stuff/goo/agents/monsters/grand_ryzomien" ] +ShapeSourceDirectories += [ "stuff/goo/agents/monsters/kitin" ] +ShapeSourceDirectories += [ "stuff/goo/agents/monsters/kitin_volant" ] +ShapeSourceDirectories += [ "stuff/goo/agents/monsters/oiseau" ] +ShapeSourceDirectories += [ "stuff/goo/agents/monsters/pachyderme/vampignon" ] +ShapeSourceDirectories += [ "stuff/goo/agents/monsters/ryzomien/kakty" ] +ShapeSourceDirectories += [ "stuff/goo/agents/monsters/ryzomien/ryzoholo" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/cheval/c03" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/cheval/h05" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/cheval/h12" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/chien/c02" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/chien/c07" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/coureur/h01" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/coureur/h04" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/crustace/c05" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/grand_ryzomien/c06" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/grand_ryzomien/h07" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/grand_ryzomien/h11" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/oiseau/c01" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/pachyderme/h08" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/pachyderme/h10" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/ryzomien/c04" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/ryzomien/h02" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/ryzomien/h06" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/ryzomien/h09" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/familier/h03" ] +ShapeSourceDirectories += [ "stuff/goo/agents/monsters/ryzomien/c04" ] +ShapeSourceDirectories += [ "stuff/goo/agents/monsters/familier/h03" ] +ShapeSourceDirectories += [ "stuff/goo/agents/monsters/homins_degeneres/cute" ] +ShapeSourceDirectories += [ "stuff/goo/agents/monsters/homins_degeneres/frahar" ] +ShapeSourceDirectories += [ "stuff/goo/agents/monsters/homins_degeneres/gibbai" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/monsters/kitin/kitin_queen" ] + +# Maps directories +MapSourceDirectories = [ ] +MapSourceDirectories += [ "stuff/fyros/agents/_textures/monster" ] +MapSourceDirectories += [ "stuff/tryker/agents/_textures/monster" ] +MapSourceDirectories += [ "stuff/jungle/agents/_textures/monster" ] +MapSourceDirectories += [ "stuff/primes_racines/agents/_textures/monster" ] +MapSourceDirectories += [ "stuff/goo/agents/_textures/monster" ] + +MapUncompressedSourceDirectories = [ ] + +# Animation directories +AnimSourceDirectories = [ ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/aquatique/animation/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/aquatique_monture/animation/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/cheval/animation/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/chien/animation/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/coureur/animation/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/crustace/animation/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/familier/animation/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/grand_ryzomien/animation/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kamiforet/animations/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kamiguard/animations/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/kitin/animation/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/kitin_volant/animation/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/oiseau/animation/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/pachyderme/animation/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/ryzomien/animation/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/carnitree/animation/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/electroalg/animation/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/endrobouchea/animation/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/phytopsy/animation/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/sapenslaver/animation/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/plante_carnivore/swarmplant/animation/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_guide_2/animations/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_guide_3/animations/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_guide_4/animations/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_preacher_2/animations/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_preacher_3/animations/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/kami/kami_preacher_4/animations/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/homins_degeneres/cute/animation/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/homins_degeneres/frahar/animation/anims" ] +AnimSourceDirectories += [ "stuff/tryker/agents/monsters/homins_degeneres/gibbai/animation/anims" ] + +# cLoD shape directories +ClodSourceDirectories = [ ] +ClodSourceDirectories += [ "stuff/lod_actors/lod_fauna" ] + + +# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) + +# Ig lookup directories used by rbank +IgLookupDirectories = [ ] + +# Shape lookup directories used by rbank +ShapeLookupDirectories = [ ] +# ShapeLookupDirectories += [ CommonPath + "/ps" ] +ShapeLookupDirectories += [ CommonPath + "/shape_clodtex_build" ] +ShapeLookupDirectories += [ CommonPath + "/shape_with_coarse_mesh" ] + +# Map lookup directories not yet used +MapLookupDirectories = [ ] +MapLookupDirectories += [ CommonPath + "/map_export" ] +MapLookupDirectories += [ CommonPath + "/map_uncompressed" ] + + +# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapExportDirectory = CommonPath + "/map_export" +MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" + +# Skeleton directories +SkelExportDirectory = CommonPath + "/skel" + +# Skeleton template weight directories +SwtExportDirectory = CommonPath + "/swt" + +# Shape directories +ShapeTagExportDirectory = CommonPath + "/shape_tag" +ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" +ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" +ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" +ShapeAnimExportDirectory = CommonPath + "/shape_anim" + +# Animation directories +AnimExportDirectory = CommonPath + "/anim_export" +AnimTagExportDirectory = CommonPath + "/anim_tag" + +# cLoD directories +ClodExportDirectory = CommonPath + "/clod_export" +ClodTagExportDirectory = CommonPath + "/clod_tag_export" + + +# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapBuildDirectory = CommonPath + "/map" +MapPanoplyBuildDirectory = CommonPath + "/map_panoply" +MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" +MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" +MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" +MapTagBuildDirectory = CommonPath + "/map_tag" + +# Shape directories +ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" +ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" +ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" +ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" + +# Animation directories +AnimBuildDirectory = CommonPath + "/anim" + +# cLoD directories +ClodBankBuildDirectory = CommonPath + "/clod_bank" + + +# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** + +# Map directory +MapInstallDirectory = CommonName + "_maps" +BitmapInstallDirectory = MapInstallDirectory + +# Shape directory +ShapeInstallDirectory = CommonName + "_shapes" +LightmapInstallDirectory = ShapeInstallDirectory + +# Animation directory +AnimInstallDirectory = CommonName + "_animations" + +# Skeleton directory +SkelInstallDirectory = CommonName + "_skeletons" + +# Skeleton directory +SwtInstallDirectory = CommonName + "_swt" diff --git a/code/ryzom/tools/build_gamedata/workspace/common/fauna/process.py b/code/ryzom/tools/build_gamedata/workspace/common/fauna/process.py index bf59b3165..9a17071c2 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/fauna/process.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/fauna/process.py @@ -1,113 +1,113 @@ -#!/usr/bin/python -# -# \file config.py -# \brief Process configuration -# \date 2010-08-27 17:02GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Process configuration. -# -# NeL - 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 . -# - -# *** PROCESS CONFIGURATION *** - -# *** PROCESS CONFIG *** -ProcessToComplete = [ ] -ProcessToComplete += [ "skel" ] -ProcessToComplete += [ "swt" ] -ProcessToComplete += [ "shape" ] -ProcessToComplete += [ "map" ] -ProcessToComplete += [ "anim" ] -ProcessToComplete += [ "clodbank" ] - - -# *** COMMON NAMES AND PATHS *** -EcosystemName = "fauna" -EcosystemPath = "common/" + EcosystemName -ContinentName = EcosystemName -ContinentPath = EcosystemPath -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** SHAPE EXPORT OPTIONS *** - -# Compute lightmaps ? -ShapeExportOptExportLighting = "true" - -# Cast shadow in lightmap ? -ShapeExportOptShadow = "true" - -# Lighting limits. 0 : normal, 1 : soft shadows -ShapeExportOptLightingLimit = 0 - -# Lightmap lumel size -ShapeExportOptLumelSize = "0.25" - -# Oversampling value. Can be 1, 2, 4 or 8 -ShapeExportOptOversampling = 1 - -# Does the lightmap must be generated in 8 bits format ? -ShapeExportOpt8BitsLightmap = "false" - -# Does the lightmaps export must generate logs ? -ShapeExportOptLightmapLog = "true" - -# Coarse mesh texture mul size -TextureMulSizeValue = "1.5" - -DoBuildShadowSkin = 0 - - -# *** CLODBANK OPTIONS *** - -ClodConfigFile = "stuff/lod_actors/lod_" + CommonName + "/clod_" + CommonName + "_script.cfg" -ClodBankFileName = CommonName + ".clodbank" - - -# *** COARSE MESH TEXTURE NAME *** -CoarseMeshTextureNames = [ ] - - -# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** -MultipleTilesPostfix = [ ] -MultipleTilesPostfix += [ "_sp" ] -MultipleTilesPostfix += [ "_su" ] -MultipleTilesPostfix += [ "_au" ] -MultipleTilesPostfix += [ "_wi" ] - - -# *** MAPS OPTIONS *** - -ReduceBitmapFactor = 0 -# list all panoply files -MapPanoplyFileList = None -# name of the .hlsbank to build. -MapHlsBankFileName = None - - -# *** SHADOW SKIN OPTIONS *** -# Fauna are made of a single skin. Allow only 1000 faces for each monster (whatever the original nb faces) -BuildShadowSkin = 1 -BuildShadowSkinRatio = 100 -BuildShadowSkinMaxface = 1000 - - -# *** ANIMATIONS OPTIONS *** - -DoOptimizeAnimations = 1 +#!/usr/bin/python +# +# \file config.py +# \brief Process configuration +# \date 2010-08-27 17:02GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Process configuration. +# +# NeL - 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 . +# + +# *** PROCESS CONFIGURATION *** + +# *** PROCESS CONFIG *** +ProcessToComplete = [ ] +ProcessToComplete += [ "skel" ] +ProcessToComplete += [ "swt" ] +ProcessToComplete += [ "shape" ] +ProcessToComplete += [ "map" ] +ProcessToComplete += [ "anim" ] +ProcessToComplete += [ "clodbank" ] + + +# *** COMMON NAMES AND PATHS *** +EcosystemName = "fauna" +EcosystemPath = "common/" + EcosystemName +ContinentName = EcosystemName +ContinentPath = EcosystemPath +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** SHAPE EXPORT OPTIONS *** + +# Compute lightmaps ? +ShapeExportOptExportLighting = "true" + +# Cast shadow in lightmap ? +ShapeExportOptShadow = "true" + +# Lighting limits. 0 : normal, 1 : soft shadows +ShapeExportOptLightingLimit = 0 + +# Lightmap lumel size +ShapeExportOptLumelSize = "0.25" + +# Oversampling value. Can be 1, 2, 4 or 8 +ShapeExportOptOversampling = 1 + +# Does the lightmap must be generated in 8 bits format ? +ShapeExportOpt8BitsLightmap = "false" + +# Does the lightmaps export must generate logs ? +ShapeExportOptLightmapLog = "true" + +# Coarse mesh texture mul size +TextureMulSizeValue = "1.5" + +DoBuildShadowSkin = 0 + + +# *** CLODBANK OPTIONS *** + +ClodConfigFile = "stuff/lod_actors/lod_" + CommonName + "/clod_" + CommonName + "_script.cfg" +ClodBankFileName = CommonName + ".clodbank" + + +# *** COARSE MESH TEXTURE NAME *** +CoarseMeshTextureNames = [ ] + + +# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** +MultipleTilesPostfix = [ ] +MultipleTilesPostfix += [ "_sp" ] +MultipleTilesPostfix += [ "_su" ] +MultipleTilesPostfix += [ "_au" ] +MultipleTilesPostfix += [ "_wi" ] + + +# *** MAPS OPTIONS *** + +ReduceBitmapFactor = 0 +# list all panoply files +MapPanoplyFileList = None +# name of the .hlsbank to build. +MapHlsBankFileName = None + + +# *** SHADOW SKIN OPTIONS *** +# Fauna are made of a single skin. Allow only 1000 faces for each monster (whatever the original nb faces) +BuildShadowSkin = 1 +BuildShadowSkinRatio = 100 +BuildShadowSkinMaxface = 1000 + + +# *** ANIMATIONS OPTIONS *** + +DoOptimizeAnimations = 1 diff --git a/code/ryzom/tools/build_gamedata/workspace/common/fonts/directories.py b/code/ryzom/tools/build_gamedata/workspace/common/fonts/directories.py index b8c3f0110..da99a9d16 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/fonts/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/fonts/directories.py @@ -1,59 +1,59 @@ -#!/usr/bin/python -# -# \file directories.py -# \brief Directories configuration -# \date 2010-08-27 17:13GMT -# \author Jan Boon (Kaetemi) -# \date 2001-2005 -# \author Nevrax -# Python port of game data build pipeline. -# Directories configuration. -# -# NeL - 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 . -# - - -# *** COMMON NAMES AND PATHS *** -EcosystemName = "fonts" -EcosystemPath = "common/" + EcosystemName -ContinentName = EcosystemName -ContinentPath = EcosystemPath -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** SOURCE DIRECTORIES IN THE DATABASE *** - -# Font directories -FontSourceDirectories = [ ] -FontSourceDirectories += [ "fonts" ] - - -# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** - -# Font directories -FontExportDirectory = CommonPath + "/font" - - -# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** - -# Font directory -FontInstallDirectory = CommonName - - -# end of file - +#!/usr/bin/python +# +# \file directories.py +# \brief Directories configuration +# \date 2010-08-27 17:13GMT +# \author Jan Boon (Kaetemi) +# \date 2001-2005 +# \author Nevrax +# Python port of game data build pipeline. +# Directories configuration. +# +# NeL - 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 . +# + + +# *** COMMON NAMES AND PATHS *** +EcosystemName = "fonts" +EcosystemPath = "common/" + EcosystemName +ContinentName = EcosystemName +ContinentPath = EcosystemPath +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** SOURCE DIRECTORIES IN THE DATABASE *** + +# Font directories +FontSourceDirectories = [ ] +FontSourceDirectories += [ "fonts" ] + + +# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** + +# Font directories +FontExportDirectory = CommonPath + "/font" + + +# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** + +# Font directory +FontInstallDirectory = CommonName + + +# end of file + diff --git a/code/ryzom/tools/build_gamedata/workspace/common/fonts/process.py b/code/ryzom/tools/build_gamedata/workspace/common/fonts/process.py index e1e6d4824..e5e00cb5c 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/fonts/process.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/fonts/process.py @@ -1,43 +1,43 @@ -#!/usr/bin/python -# -# \file config.py -# \brief Process configuration -# \date 2010-08-27 17:02GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Process configuration. -# -# NeL - 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 . -# - -# *** PROCESS CONFIGURATION *** - -# *** PROCESS CONFIG *** -ProcessToComplete = [ ] -ProcessToComplete += [ "font" ] - - -# *** COMMON NAMES AND PATHS *** -EcosystemName = "fonts" -EcosystemPath = "common/" + EcosystemName -ContinentName = EcosystemName -ContinentPath = EcosystemPath -CommonName = ContinentName -CommonPath = ContinentPath - - -# end of file +#!/usr/bin/python +# +# \file config.py +# \brief Process configuration +# \date 2010-08-27 17:02GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Process configuration. +# +# NeL - 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 . +# + +# *** PROCESS CONFIGURATION *** + +# *** PROCESS CONFIG *** +ProcessToComplete = [ ] +ProcessToComplete += [ "font" ] + + +# *** COMMON NAMES AND PATHS *** +EcosystemName = "fonts" +EcosystemPath = "common/" + EcosystemName +ContinentName = EcosystemName +ContinentPath = EcosystemPath +CommonName = ContinentName +CommonPath = ContinentPath + + +# end of file diff --git a/code/ryzom/tools/build_gamedata/workspace/common/gamedev/directories.py b/code/ryzom/tools/build_gamedata/workspace/common/gamedev/directories.py index cc8af2ee0..b16723e76 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/gamedev/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/gamedev/directories.py @@ -1,63 +1,63 @@ -#!/usr/bin/python -# -# \file directories.py -# \brief Directories configuration -# \date 2010-08-27 17:13GMT -# \author Jan Boon (Kaetemi) -# \date 2001-2005 -# \author Nevrax -# Python port of game data build pipeline. -# Directories configuration. -# -# NeL - 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 . -# - -from buildsite import * - -# *** COMMON NAMES AND PATHS *** -CommonName = "gamedev" -CommonPath = "common/" + CommonName - - -# *** DIRECT SOURCE DIRECTORIES *** - -# Copy dir directories -CopyDirectSourceDirectories = [ ] -CopyDirectSourceDirectories += [ GamedevDirectory ] -CopyDirectSourceFiles = [ ] - - -# *** SOURCE DIRECTORIES IN LEVELDESIGN *** -CopyLeveldesignSourceDirectories = [ ] -CopyLeveldesignSourceFiles = [ ] -CopyLeveldesignWorldSourceDirectories = [ ] -CopyLeveldesignWorldSourceFiles = [ ] -CopyLeveldesignDfnSourceDirectories = [ ] -CopyLeveldesignDfnSourceFiles = [ ] - - -# *** SOURCE DIRECTORIES IN THE DATABASE *** - -# Copy dir directories -CopyDatabaseSourceDirectories = [ ] -CopyDatabaseSourceFiles = [ ] - - -# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** - -# Particule system directory -CopyInstallDirectory = CommonName +#!/usr/bin/python +# +# \file directories.py +# \brief Directories configuration +# \date 2010-08-27 17:13GMT +# \author Jan Boon (Kaetemi) +# \date 2001-2005 +# \author Nevrax +# Python port of game data build pipeline. +# Directories configuration. +# +# NeL - 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 . +# + +from buildsite import * + +# *** COMMON NAMES AND PATHS *** +CommonName = "gamedev" +CommonPath = "common/" + CommonName + + +# *** DIRECT SOURCE DIRECTORIES *** + +# Copy dir directories +CopyDirectSourceDirectories = [ ] +CopyDirectSourceDirectories += [ GamedevDirectory ] +CopyDirectSourceFiles = [ ] + + +# *** SOURCE DIRECTORIES IN LEVELDESIGN *** +CopyLeveldesignSourceDirectories = [ ] +CopyLeveldesignSourceFiles = [ ] +CopyLeveldesignWorldSourceDirectories = [ ] +CopyLeveldesignWorldSourceFiles = [ ] +CopyLeveldesignDfnSourceDirectories = [ ] +CopyLeveldesignDfnSourceFiles = [ ] + + +# *** SOURCE DIRECTORIES IN THE DATABASE *** + +# Copy dir directories +CopyDatabaseSourceDirectories = [ ] +CopyDatabaseSourceFiles = [ ] + + +# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** + +# Particule system directory +CopyInstallDirectory = CommonName diff --git a/code/ryzom/tools/build_gamedata/workspace/common/gamedev/process.py b/code/ryzom/tools/build_gamedata/workspace/common/gamedev/process.py index adf040877..7f7d1c363 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/gamedev/process.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/gamedev/process.py @@ -1,41 +1,41 @@ -#!/usr/bin/python -# -# \file config.py -# \brief Process configuration -# \date 2010-08-27 17:02GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Process configuration. -# -# NeL - 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 . -# - -# *** PROCESS CONFIGURATION *** - -# *** PROCESS CONFIG *** -ProcessToComplete = [ ] -ProcessToComplete += [ "copy" ] - - -# *** COMMON NAMES AND PATHS *** -CommonName = "gamedev" -CommonPath = "common/" + CommonName - - -# *** COPY DIR OPTIONS *** - - +#!/usr/bin/python +# +# \file config.py +# \brief Process configuration +# \date 2010-08-27 17:02GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Process configuration. +# +# NeL - 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 . +# + +# *** PROCESS CONFIGURATION *** + +# *** PROCESS CONFIG *** +ProcessToComplete = [ ] +ProcessToComplete += [ "copy" ] + + +# *** COMMON NAMES AND PATHS *** +CommonName = "gamedev" +CommonPath = "common/" + CommonName + + +# *** COPY DIR OPTIONS *** + + diff --git a/code/ryzom/tools/build_gamedata/workspace/common/interface/directories.py b/code/ryzom/tools/build_gamedata/workspace/common/interface/directories.py index 3ecf20b5d..f8c1226b4 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/interface/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/interface/directories.py @@ -1,94 +1,94 @@ -#!/usr/bin/python -# -# \file directories.py -# \brief Directories configuration -# \date 2010-08-27 17:13GMT -# \author Jan Boon (Kaetemi) -# \date 2001-2005 -# \author Nevrax -# Python port of game data build pipeline. -# Directories configuration. -# -# NeL - 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 . -# - - -# *** COMMON NAMES AND PATHS *** -EcosystemName = "interface" -EcosystemPath = "common/" + EcosystemName -ContinentName = EcosystemName -ContinentPath = EcosystemPath -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** SOURCE DIRECTORIES IN THE DATABASE *** - -#Interface directories -InterfaceSourceDirectories = [ ] -InterfaceSourceDirectories += [ [ "interfaces/v3" ] + [ "interfaces/r2_interface" ] ] -InterfaceSourceDirectories += [ [ "interfaces/v3_outgame/ui" ] ] -InterfaceSourceDirectories += [ [ "interfaces/v3_login" ] ] - -InterfaceDxtcSourceDirectories = [ ] -InterfaceDxtcSourceDirectories += [ "interfaces/v3_bricks" ] -InterfaceDxtcSourceDirectories += [ "interfaces/v3_items" ] -InterfaceDxtcSourceDirectories += [ "interfaces/v3_dxtc_misc" ] - -InterfaceFullscreenSourceDirectories = [ ] -InterfaceFullscreenSourceDirectories += [ "interfaces/v3_fullscreen" ] -InterfaceFullscreenSourceDirectories += [ "interfaces/v3_outgame/fullscreen" ] -InterfaceFullscreenSourceDirectories += [ "interfaces/v3_doc/graph/abilities_items" ] -InterfaceFullscreenSourceDirectories += [ "interfaces/v3_doc/graph/buy_sell" ] -InterfaceFullscreenSourceDirectories += [ "interfaces/v3_doc/graph/camera_character" ] -InterfaceFullscreenSourceDirectories += [ "interfaces/v3_doc/graph/create_perso" ] -InterfaceFullscreenSourceDirectories += [ "interfaces/v3_doc/graph/fight" ] -InterfaceFullscreenSourceDirectories += [ "interfaces/v3_doc/graph/MatisTown" ] -InterfaceFullscreenSourceDirectories += [ "interfaces/v3_doc/graph/spell" ] -InterfaceFullscreenSourceDirectories += [ "interfaces/v3_doc/graph/talk_bot" ] -InterfaceFullscreenSourceDirectories += [ "interfaces/v3_doc/graph/abilities_items" ] -InterfaceFullscreenSourceDirectories += [ "interfaces/v3_quick_help/graph" ] -InterfaceFullscreenSourceDirectories += [ "interfaces/r2_decals" ] - -Interface3DSourceDirectories = [ ] -Interface3DSourceDirectories += [ "interfaces/v3_outgame/3d" ] -Interface3DSourceDirectories += [ "interfaces/v3_doc/htm" ] -Interface3DSourceDirectories += [ "interfaces/v3_doc" ] -Interface3DSourceDirectories += [ "interfaces/v3_quick_help" ] -Interface3DSourceDirectories += [ "interfaces/r2_3d" ] - - -# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** - -# Interface directories -InterfaceExportDirectory = CommonPath + "/interface_export" -InterfaceDxtcExportDirectory = CommonPath + "/interface_dxtc_export" -InterfaceFullscreenExportDirectory = CommonPath + "/interface_fullscreen_export" -Interface3DExportDirectory = CommonPath + "/interface_3d_export" - - -# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** - -# Interface directories -InterfaceBuildDirectory = CommonPath + "/interface_build" -InterfaceDxtcBuildDirectory = CommonPath + "/interface_dxtc_build" - - -# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** - -# Lightmap directory -InterfaceInstallDirectory = "interfaces" +#!/usr/bin/python +# +# \file directories.py +# \brief Directories configuration +# \date 2010-08-27 17:13GMT +# \author Jan Boon (Kaetemi) +# \date 2001-2005 +# \author Nevrax +# Python port of game data build pipeline. +# Directories configuration. +# +# NeL - 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 . +# + + +# *** COMMON NAMES AND PATHS *** +EcosystemName = "interface" +EcosystemPath = "common/" + EcosystemName +ContinentName = EcosystemName +ContinentPath = EcosystemPath +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** SOURCE DIRECTORIES IN THE DATABASE *** + +#Interface directories +InterfaceSourceDirectories = [ ] +InterfaceSourceDirectories += [ [ "interfaces/v3" ] + [ "interfaces/r2_interface" ] ] +InterfaceSourceDirectories += [ [ "interfaces/v3_outgame/ui" ] ] +InterfaceSourceDirectories += [ [ "interfaces/v3_login" ] ] + +InterfaceDxtcSourceDirectories = [ ] +InterfaceDxtcSourceDirectories += [ "interfaces/v3_bricks" ] +InterfaceDxtcSourceDirectories += [ "interfaces/v3_items" ] +InterfaceDxtcSourceDirectories += [ "interfaces/v3_dxtc_misc" ] + +InterfaceFullscreenSourceDirectories = [ ] +InterfaceFullscreenSourceDirectories += [ "interfaces/v3_fullscreen" ] +InterfaceFullscreenSourceDirectories += [ "interfaces/v3_outgame/fullscreen" ] +InterfaceFullscreenSourceDirectories += [ "interfaces/v3_doc/graph/abilities_items" ] +InterfaceFullscreenSourceDirectories += [ "interfaces/v3_doc/graph/buy_sell" ] +InterfaceFullscreenSourceDirectories += [ "interfaces/v3_doc/graph/camera_character" ] +InterfaceFullscreenSourceDirectories += [ "interfaces/v3_doc/graph/create_perso" ] +InterfaceFullscreenSourceDirectories += [ "interfaces/v3_doc/graph/fight" ] +InterfaceFullscreenSourceDirectories += [ "interfaces/v3_doc/graph/MatisTown" ] +InterfaceFullscreenSourceDirectories += [ "interfaces/v3_doc/graph/spell" ] +InterfaceFullscreenSourceDirectories += [ "interfaces/v3_doc/graph/talk_bot" ] +InterfaceFullscreenSourceDirectories += [ "interfaces/v3_doc/graph/abilities_items" ] +InterfaceFullscreenSourceDirectories += [ "interfaces/v3_quick_help/graph" ] +InterfaceFullscreenSourceDirectories += [ "interfaces/r2_decals" ] + +Interface3DSourceDirectories = [ ] +Interface3DSourceDirectories += [ "interfaces/v3_outgame/3d" ] +Interface3DSourceDirectories += [ "interfaces/v3_doc/htm" ] +Interface3DSourceDirectories += [ "interfaces/v3_doc" ] +Interface3DSourceDirectories += [ "interfaces/v3_quick_help" ] +Interface3DSourceDirectories += [ "interfaces/r2_3d" ] + + +# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** + +# Interface directories +InterfaceExportDirectory = CommonPath + "/interface_export" +InterfaceDxtcExportDirectory = CommonPath + "/interface_dxtc_export" +InterfaceFullscreenExportDirectory = CommonPath + "/interface_fullscreen_export" +Interface3DExportDirectory = CommonPath + "/interface_3d_export" + + +# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** + +# Interface directories +InterfaceBuildDirectory = CommonPath + "/interface_build" +InterfaceDxtcBuildDirectory = CommonPath + "/interface_dxtc_build" + + +# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** + +# Lightmap directory +InterfaceInstallDirectory = "interfaces" diff --git a/code/ryzom/tools/build_gamedata/workspace/common/interface/process.py b/code/ryzom/tools/build_gamedata/workspace/common/interface/process.py index 5e6b2fd0c..488765891 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/interface/process.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/interface/process.py @@ -1,49 +1,49 @@ -#!/usr/bin/python -# -# \file config.py -# \brief Process configuration -# \date 2010-08-27 17:02GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Process configuration. -# -# NeL - 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 . -# - -# *** PROCESS CONFIGURATION *** - -# *** PROCESS CONFIG *** -ProcessToComplete = [ ] -ProcessToComplete += [ "interface" ] - - -# *** COMMON NAMES AND PATHS *** -EcosystemName = "interface" -EcosystemPath = "common/" + EcosystemName -ContinentName = EcosystemName -ContinentPath = EcosystemPath -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** MAPS OPTIONS *** - -ReduceBitmapFactor = 0 -# list all panoply files -MapPanoplyFileList = None -# name of the .hlsbank to build. -MapHlsBankFileName = None +#!/usr/bin/python +# +# \file config.py +# \brief Process configuration +# \date 2010-08-27 17:02GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Process configuration. +# +# NeL - 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 . +# + +# *** PROCESS CONFIGURATION *** + +# *** PROCESS CONFIG *** +ProcessToComplete = [ ] +ProcessToComplete += [ "interface" ] + + +# *** COMMON NAMES AND PATHS *** +EcosystemName = "interface" +EcosystemPath = "common/" + EcosystemName +ContinentName = EcosystemName +ContinentPath = EcosystemPath +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** MAPS OPTIONS *** + +ReduceBitmapFactor = 0 +# list all panoply files +MapPanoplyFileList = None +# name of the .hlsbank to build. +MapHlsBankFileName = None diff --git a/code/ryzom/tools/build_gamedata/workspace/common/leveldesign/directories.py b/code/ryzom/tools/build_gamedata/workspace/common/leveldesign/directories.py index b8ca09aa3..2765af7b1 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/leveldesign/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/leveldesign/directories.py @@ -1,77 +1,77 @@ -#!/usr/bin/python -# -# \file directories.py -# \brief Directories configuration -# \date 2010-08-27 17:13GMT -# \author Jan Boon (Kaetemi) -# \date 2001-2005 -# \author Nevrax -# Python port of game data build pipeline. -# Directories configuration. -# -# NeL - 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 . -# - - -# *** COMMON NAMES AND PATHS *** -CommonName = "leveldesign" -CommonPath = "common/" + CommonName - - -# *** DIRECT SOURCE DIRECTORIES *** - -# Copy dir directories -CopyDirectSourceDirectories = [ ] -CopyDirectSourceFiles = [ ] - - -# *** SOURCE DIRECTORIES IN LEVELDESIGN *** -CopyLeveldesignSourceDirectories = [ ] -CopyLeveldesignSourceFiles = [ ] -CopyLeveldesignSourceFiles += [ "game_element/anim/mode2animset.string_array" ] -CopyLeveldesignSourceFiles += [ "game_elem/sheet_id.bin" ] -CopyLeveldesignWorldSourceDirectories = [ ] -CopyLeveldesignWorldSourceFiles = [ ] -CopyLeveldesignWorldSourceFiles += [ "static_fame.txt" ] -CopyLeveldesignDfnSourceDirectories = [ ] -CopyLeveldesignDfnSourceFiles = [ ] -CopyLeveldesignDfnSourceFiles += [ "game_elem/_creature/_creature_3d_eyes_color.typ" ] -CopyLeveldesignDfnSourceFiles += [ "game_elem/_creature/_creature_3d_hair_color.typ" ] -CopyLeveldesignDfnSourceFiles += [ "basics/string.typ" ] -CopyLeveldesignDfnSourceFiles += [ "game_elem/_anim/string_array.dfn" ] - - -# *** SOURCE DIRECTORIES IN THE DATABASE *** - -# Copy dir directories -CopyDatabaseSourceDirectories = [ ] -CopyDatabaseSourceFiles = [ ] - - -# *** BUILD DIRECTORIES *** - -# Sheets -SheetsBuildDirectory = CommonPath + "/sheets" - - -# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** - -# Stuff -CopyInstallDirectory = CommonName - -# Sheets -SheetsInstallDirectory = "packedsheets" +#!/usr/bin/python +# +# \file directories.py +# \brief Directories configuration +# \date 2010-08-27 17:13GMT +# \author Jan Boon (Kaetemi) +# \date 2001-2005 +# \author Nevrax +# Python port of game data build pipeline. +# Directories configuration. +# +# NeL - 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 . +# + + +# *** COMMON NAMES AND PATHS *** +CommonName = "leveldesign" +CommonPath = "common/" + CommonName + + +# *** DIRECT SOURCE DIRECTORIES *** + +# Copy dir directories +CopyDirectSourceDirectories = [ ] +CopyDirectSourceFiles = [ ] + + +# *** SOURCE DIRECTORIES IN LEVELDESIGN *** +CopyLeveldesignSourceDirectories = [ ] +CopyLeveldesignSourceFiles = [ ] +CopyLeveldesignSourceFiles += [ "game_element/anim/mode2animset.string_array" ] +CopyLeveldesignSourceFiles += [ "game_elem/sheet_id.bin" ] +CopyLeveldesignWorldSourceDirectories = [ ] +CopyLeveldesignWorldSourceFiles = [ ] +CopyLeveldesignWorldSourceFiles += [ "static_fame.txt" ] +CopyLeveldesignDfnSourceDirectories = [ ] +CopyLeveldesignDfnSourceFiles = [ ] +CopyLeveldesignDfnSourceFiles += [ "game_elem/_creature/_creature_3d_eyes_color.typ" ] +CopyLeveldesignDfnSourceFiles += [ "game_elem/_creature/_creature_3d_hair_color.typ" ] +CopyLeveldesignDfnSourceFiles += [ "basics/string.typ" ] +CopyLeveldesignDfnSourceFiles += [ "game_elem/_anim/string_array.dfn" ] + + +# *** SOURCE DIRECTORIES IN THE DATABASE *** + +# Copy dir directories +CopyDatabaseSourceDirectories = [ ] +CopyDatabaseSourceFiles = [ ] + + +# *** BUILD DIRECTORIES *** + +# Sheets +SheetsBuildDirectory = CommonPath + "/sheets" + + +# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** + +# Stuff +CopyInstallDirectory = CommonName + +# Sheets +SheetsInstallDirectory = "packedsheets" diff --git a/code/ryzom/tools/build_gamedata/workspace/common/leveldesign/process.py b/code/ryzom/tools/build_gamedata/workspace/common/leveldesign/process.py index bdc196c7e..529a6c393 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/leveldesign/process.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/leveldesign/process.py @@ -1,44 +1,44 @@ -#!/usr/bin/python -# -# \file config.py -# \brief Process configuration -# \date 2010-08-27 17:02GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Process configuration. -# -# NeL - 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 . -# - -# *** PROCESS CONFIGURATION *** - -# *** PROCESS CONFIG *** -ProcessToComplete = [ ] -ProcessToComplete += [ "sheet_id" ] -ProcessToComplete += [ "sheets" ] -ProcessToComplete += [ "copy" ] - - -# *** COMMON NAMES AND PATHS *** -CommonName = "leveldesign" -CommonPath = "common/" + CommonName - - -# *** SHEETS OPTIONS *** -WorldSheet = "ryzom.world" -LigoPrimitiveClass = "world_editor_classes.xml" - +#!/usr/bin/python +# +# \file config.py +# \brief Process configuration +# \date 2010-08-27 17:02GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Process configuration. +# +# NeL - 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 . +# + +# *** PROCESS CONFIGURATION *** + +# *** PROCESS CONFIG *** +ProcessToComplete = [ ] +ProcessToComplete += [ "sheet_id" ] +ProcessToComplete += [ "sheets" ] +ProcessToComplete += [ "copy" ] + + +# *** COMMON NAMES AND PATHS *** +CommonName = "leveldesign" +CommonPath = "common/" + CommonName + + +# *** SHEETS OPTIONS *** +WorldSheet = "ryzom.world" +LigoPrimitiveClass = "world_editor_classes.xml" + diff --git a/code/ryzom/tools/build_gamedata/workspace/common/objects/directories.py b/code/ryzom/tools/build_gamedata/workspace/common/objects/directories.py index 109ba59f7..47527175c 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/objects/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/objects/directories.py @@ -1,119 +1,119 @@ -#!/usr/bin/python -# -# \file directories.py -# \brief Directories configuration -# \date 2010-08-27 17:13GMT -# \author Jan Boon (Kaetemi) -# \date 2001-2005 -# \author Nevrax -# Python port of game data build pipeline. -# Directories configuration. -# -# NeL - 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 . -# - - -# *** COMMON PATH *** - -CommonPath = "common/objects" - - -# *** SOURCE DIRECTORIES IN THE DATABASE *** - -# Shape directories -ShapeSourceDirectories = [ ] -ShapeSourceDirectories += [ "stuff/fyros/agents/accessories" ] -ShapeSourceDirectories += [ "stuff/tryker/agents/accessories" ] -ShapeSourceDirectories += [ "stuff/matis/agents/accessories" ] -ShapeSourceDirectories += [ "stuff/zorai/agents/accessories" ] -ShapeSourceDirectories += [ "stuff/generique/agents/accessories" ] -ShapeSourceDirectories += [ "stuff/caravan/agents/accessories" ] -ShapeSourceDirectories += [ "stuff/animated_light" ] - -# Maps directories -MapSourceDirectories = [ ] -MapSourceDirectories += [ "stuff/fyros/agents/_textures/accessories" ] -MapSourceDirectories += [ "stuff/tryker/agents/_textures/accessories" ] -MapSourceDirectories += [ "stuff/matis/agents/_textures/accessories" ] -MapSourceDirectories += [ "stuff/zorai/agents/_textures/accessories" ] -MapSourceDirectories += [ "stuff/generique/agents/_textures/accessories" ] -MapSourceDirectories += [ "stuff/caravan/agents/_textures/accessories" ] - -MapUncompressedSourceDirectories = [ ] - - -# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) - -# Ig lookup directories used by rbank -IgLookupDirectories = [ ] - -# Shape lookup directories used by rbank -ShapeLookupDirectories = [ ] -# ShapeLookupDirectories += [ CommonPath + "/ps" ] -ShapeLookupDirectories += [ CommonPath + "/shape_clodtex_build" ] -ShapeLookupDirectories += [ CommonPath + "/shape_with_coarse_mesh" ] - -# Map lookup directories not yet used -MapLookupDirectories = [ ] -MapLookupDirectories += [ CommonPath + "/map_export" ] -MapLookupDirectories += [ CommonPath + "/map_uncompressed" ] - - -# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapExportDirectory = CommonPath + "/map_export" -MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" - -# Shape directories -ShapeTagExportDirectory = CommonPath + "/shape_tag" -ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" -ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" -ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" -ShapeAnimExportDirectory = CommonPath + "/shape_anim" - - -# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapBuildDirectory = CommonPath + "/map" -MapPanoplyBuildDirectory = CommonPath + "/map_panoply" -MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" -MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" -MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" -MapTagBuildDirectory = CommonPath + "/map_tag" - -# Shape directories -ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" -ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" -ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" -ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" - - -# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** - -# Map directory -MapInstallDirectory = "objects" - -# Map directory -BitmapInstallDirectory = MapInstallDirectory - -# Shape directory -ShapeInstallDirectory = "objects" - -# Lightmap directory -LightmapInstallDirectory = "objects" +#!/usr/bin/python +# +# \file directories.py +# \brief Directories configuration +# \date 2010-08-27 17:13GMT +# \author Jan Boon (Kaetemi) +# \date 2001-2005 +# \author Nevrax +# Python port of game data build pipeline. +# Directories configuration. +# +# NeL - 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 . +# + + +# *** COMMON PATH *** + +CommonPath = "common/objects" + + +# *** SOURCE DIRECTORIES IN THE DATABASE *** + +# Shape directories +ShapeSourceDirectories = [ ] +ShapeSourceDirectories += [ "stuff/fyros/agents/accessories" ] +ShapeSourceDirectories += [ "stuff/tryker/agents/accessories" ] +ShapeSourceDirectories += [ "stuff/matis/agents/accessories" ] +ShapeSourceDirectories += [ "stuff/zorai/agents/accessories" ] +ShapeSourceDirectories += [ "stuff/generique/agents/accessories" ] +ShapeSourceDirectories += [ "stuff/caravan/agents/accessories" ] +ShapeSourceDirectories += [ "stuff/animated_light" ] + +# Maps directories +MapSourceDirectories = [ ] +MapSourceDirectories += [ "stuff/fyros/agents/_textures/accessories" ] +MapSourceDirectories += [ "stuff/tryker/agents/_textures/accessories" ] +MapSourceDirectories += [ "stuff/matis/agents/_textures/accessories" ] +MapSourceDirectories += [ "stuff/zorai/agents/_textures/accessories" ] +MapSourceDirectories += [ "stuff/generique/agents/_textures/accessories" ] +MapSourceDirectories += [ "stuff/caravan/agents/_textures/accessories" ] + +MapUncompressedSourceDirectories = [ ] + + +# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) + +# Ig lookup directories used by rbank +IgLookupDirectories = [ ] + +# Shape lookup directories used by rbank +ShapeLookupDirectories = [ ] +# ShapeLookupDirectories += [ CommonPath + "/ps" ] +ShapeLookupDirectories += [ CommonPath + "/shape_clodtex_build" ] +ShapeLookupDirectories += [ CommonPath + "/shape_with_coarse_mesh" ] + +# Map lookup directories not yet used +MapLookupDirectories = [ ] +MapLookupDirectories += [ CommonPath + "/map_export" ] +MapLookupDirectories += [ CommonPath + "/map_uncompressed" ] + + +# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapExportDirectory = CommonPath + "/map_export" +MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" + +# Shape directories +ShapeTagExportDirectory = CommonPath + "/shape_tag" +ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" +ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" +ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" +ShapeAnimExportDirectory = CommonPath + "/shape_anim" + + +# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapBuildDirectory = CommonPath + "/map" +MapPanoplyBuildDirectory = CommonPath + "/map_panoply" +MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" +MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" +MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" +MapTagBuildDirectory = CommonPath + "/map_tag" + +# Shape directories +ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" +ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" +ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" +ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" + + +# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** + +# Map directory +MapInstallDirectory = "objects" + +# Map directory +BitmapInstallDirectory = MapInstallDirectory + +# Shape directory +ShapeInstallDirectory = "objects" + +# Lightmap directory +LightmapInstallDirectory = "objects" diff --git a/code/ryzom/tools/build_gamedata/workspace/common/objects/process.py b/code/ryzom/tools/build_gamedata/workspace/common/objects/process.py index 4134bfc80..ed38da5a4 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/objects/process.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/objects/process.py @@ -1,81 +1,81 @@ -#!/usr/bin/python -# -# \file config.py -# \brief Process configuration -# \date 2010-08-27 17:02GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Process configuration. -# -# NeL - 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 . -# - -# *** PROCESS CONFIGURATION *** - -# *** PROCESS CONFIG *** -ProcessToComplete = [ ] -ProcessToComplete += [ "shape" ] # not fully implemented, but works for this process -ProcessToComplete += [ "map" ] # not fully implemented, but works for this process - - -# *** SHAPE EXPORT OPTIONS *** - -# Compute lightmaps ? -ShapeExportOptExportLighting = "true" - -# Cast shadow in lightmap ? -ShapeExportOptShadow = "true" - -# Lighting limits. 0 : normal, 1 : soft shadows -ShapeExportOptLightingLimit = 0 - -# Lightmap lumel size -ShapeExportOptLumelSize = "0.25" - -# Oversampling value. Can be 1, 2, 4 or 8 -ShapeExportOptOversampling = 1 - -# Does the lightmap must be generated in 8 bits format ? -ShapeExportOpt8BitsLightmap = "false" - -# Does the lightmaps export must generate logs ? -ShapeExportOptLightmapLog = "true" - -# Coarse mesh texture mul size -TextureMulSizeValue = "1.5" - -DoBuildShadowSkin = 0 - -ClodConfigFile = "" - -# *** COARSE MESH TEXTURE NAME *** -CoarseMeshTextureNames = [ ] - -# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** -MultipleTilesPostfix = [ ] -MultipleTilesPostfix += [ "_sp" ] -MultipleTilesPostfix += [ "_su" ] -MultipleTilesPostfix += [ "_au" ] -MultipleTilesPostfix += [ "_wi" ] - -# *** MAPS OPTIONS *** - -ReduceBitmapFactor = 0 -# list all panoply files -MapPanoplyFileList = None -# name of the .hlsbank to build. -MapHlsBankFileName = None +#!/usr/bin/python +# +# \file config.py +# \brief Process configuration +# \date 2010-08-27 17:02GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Process configuration. +# +# NeL - 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 . +# + +# *** PROCESS CONFIGURATION *** + +# *** PROCESS CONFIG *** +ProcessToComplete = [ ] +ProcessToComplete += [ "shape" ] # not fully implemented, but works for this process +ProcessToComplete += [ "map" ] # not fully implemented, but works for this process + + +# *** SHAPE EXPORT OPTIONS *** + +# Compute lightmaps ? +ShapeExportOptExportLighting = "true" + +# Cast shadow in lightmap ? +ShapeExportOptShadow = "true" + +# Lighting limits. 0 : normal, 1 : soft shadows +ShapeExportOptLightingLimit = 0 + +# Lightmap lumel size +ShapeExportOptLumelSize = "0.25" + +# Oversampling value. Can be 1, 2, 4 or 8 +ShapeExportOptOversampling = 1 + +# Does the lightmap must be generated in 8 bits format ? +ShapeExportOpt8BitsLightmap = "false" + +# Does the lightmaps export must generate logs ? +ShapeExportOptLightmapLog = "true" + +# Coarse mesh texture mul size +TextureMulSizeValue = "1.5" + +DoBuildShadowSkin = 0 + +ClodConfigFile = "" + +# *** COARSE MESH TEXTURE NAME *** +CoarseMeshTextureNames = [ ] + +# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** +MultipleTilesPostfix = [ ] +MultipleTilesPostfix += [ "_sp" ] +MultipleTilesPostfix += [ "_su" ] +MultipleTilesPostfix += [ "_au" ] +MultipleTilesPostfix += [ "_wi" ] + +# *** MAPS OPTIONS *** + +ReduceBitmapFactor = 0 +# list all panoply files +MapPanoplyFileList = None +# name of the .hlsbank to build. +MapHlsBankFileName = None diff --git a/code/ryzom/tools/build_gamedata/workspace/common/outgame/directories.py b/code/ryzom/tools/build_gamedata/workspace/common/outgame/directories.py index e0b643561..ef02c93f6 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/outgame/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/outgame/directories.py @@ -1,168 +1,168 @@ -#!/usr/bin/python -# -# \file directories.py -# \brief Directories configuration -# \date 2010-08-27 17:13GMT -# \author Jan Boon (Kaetemi) -# \date 2001-2005 -# \author Nevrax -# Python port of game data build pipeline. -# Directories configuration. -# -# NeL - 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 . -# - - -# *** COMMON NAMES AND PATHS *** -EcosystemName = "outgame" -EcosystemPath = "common/" + EcosystemName -ContinentName = EcosystemName -ContinentPath = EcosystemPath -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** SOURCE DIRECTORIES LEVELDESIGN/WORLD *** -ContinentLeveldesignWorldDirectory = "" # DISABLED - - -# *** SOURCE DIRECTORIES IN THE DATABASE *** - -# Shape directories -ShapeSourceDirectories = [ ] -ShapeSourceDirectories += [ "stuff/outgame/appart_crea" ] - -# Maps directories -MapSourceDirectories = [ ] -MapSourceDirectories += [ "stuff/outgame/_textures" ] - -MapUncompressedSourceDirectories = [ ] - -# Ligo directories -LigoBaseSourceDirectory = "landscape/ligo" - -# Ig directories -IgLandSourceDirectories = [ ] -IgOtherSourceDirectories = [ ] -IgOtherSourceDirectories += [ "stuff/outgame/appart_crea" ] -IgPrimitiveSourceDirectories = [ ] - -# Tiles root directory -TileRootSourceDirectory = "landscape/_texture_tiles" - -# Displace directory -DisplaceSourceDirectory = "landscape/_texture_tiles/displace" - - -# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) - -# Ig lookup directories used by rbank -IgLookupDirectories = [ ] -IgLookupDirectories += [ CommonPath + "/ig_land" ] -IgLookupDirectories += [ CommonPath + "/ig_other" ] - -# Shape lookup directories used by rbank -ShapeLookupDirectories = [ ] -# ShapeLookupDirectories += [ CommonPath + "/ps" ] -ShapeLookupDirectories += [ CommonPath + "/shape_clodtex_build" ] -ShapeLookupDirectories += [ CommonPath + "/shape_with_coarse_mesh" ] - -# Map lookup directories not yet used -MapLookupDirectories = [ ] -MapLookupDirectories += [ CommonPath + "/map_export" ] -MapLookupDirectories += [ CommonPath + "/map_uncompressed" ] - - -# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapExportDirectory = CommonPath + "/map_export" -MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" - -# Shape directories -ShapeTagExportDirectory = CommonPath + "/shape_tag" -ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" -ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" -ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" -ShapeAnimExportDirectory = CommonPath + "/shape_anim" - -# Ig directories -IgStaticLandExportDirectory = CommonPath + "/ig_static_land" # Landscape IG eported from 3dsmax not elevated by the heightmap -IgStaticOtherExportDirectory = CommonPath + "/ig_static_other" # Village or construction IGs exported from 3dsmax -IgStaticTagExportDirectory = CommonPath + "/ig_static_tag" # Tag for exported 3dsmax files - -# Zone directories -ZoneWeldBuildDirectory = CommonPath + "/zone_weld" -ZoneDependBuildDirectory = CommonPath + "/zone_depend" -ZoneLightWaterShapesLightedExportDirectory = CommonPath + "/zone_lwsl_temp" #fixme -ZoneLightBuildDirectory = CommonPath + "/zone_lighted" #fixme -ZoneLightDependBuildDirectory = CommonPath + "/zone_lighted_depend" #fixme -ZoneLightIgLandBuildDirectory = CommonPath + "/zone_lighted_ig_land" #fixme - - -# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapBuildDirectory = CommonPath + "/map" -MapPanoplyBuildDirectory = CommonPath + "/map_panoply" -MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" -MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" -MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" -MapTagBuildDirectory = CommonPath + "/map_tag" - -# Shape directories -ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" -ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" -ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" -ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" - -# Ig directories -IgElevLandPrimBuildDirectory = CommonPath + "/ig_elev_land_prim" # landscape IG generated by the prim exporter (already elevated by the land exporter) -IgElevLandLigoBuildDirectory = CommonPath + "/ig_elev_land_ligo" # Landscape IG found in ligo bricks from 3dsmax elevated by the heightmap -IgElevLandStaticBuildDirectory = CommonPath + "/ig_elev_land_static" # Landscape IG eported from 3dsmax elevated by the heightmap -IgTempLandMergeBuildDirectory = CommonPath + "/ig_temp_land_merge" -IgTempLandCompareBuildDirectory = CommonPath + "/ig_temp_land_compare" # Tmp final IG directory for landscape IGs before comparison -IgLandBuildDirectory = CommonPath + "/ig_land" # Final IG directory for landscape IGs -IgOtherBuildDirectory = CommonPath + "/ig_other" # Final IG directory for village or construction IGs -IgOtherLightedBuildDirectory = CommonPath + "/ig_other_lighted" - -# Farbank directories -FarbankBuildDirectory = CommonPath + "/farbank" - -# Ligo directories -LigoZoneBuildDirectory = CommonPath + "/ligo_zones" -LigoIgLandBuildDirectory = CommonPath + "/ligo_ig_land" # Landscape IG found in ligo bricks not elevated by the heightmap -LigoIgOtherBuildDirectory = CommonPath + "/ligo_ig_other" # Village or construction IGs exported from ligo landscape - - -# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** - -# Map directory -MapInstallDirectory = CommonName -BitmapInstallDirectory = MapInstallDirectory - -# Shape directory -ShapeInstallDirectory = CommonName - -# Lightmap directory -LightmapInstallDirectory = CommonName - -# Animation directory -AnimInstallDirectory = CommonName - -# Ig directory -IgInstallDirectory = CommonName +#!/usr/bin/python +# +# \file directories.py +# \brief Directories configuration +# \date 2010-08-27 17:13GMT +# \author Jan Boon (Kaetemi) +# \date 2001-2005 +# \author Nevrax +# Python port of game data build pipeline. +# Directories configuration. +# +# NeL - 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 . +# + + +# *** COMMON NAMES AND PATHS *** +EcosystemName = "outgame" +EcosystemPath = "common/" + EcosystemName +ContinentName = EcosystemName +ContinentPath = EcosystemPath +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** SOURCE DIRECTORIES LEVELDESIGN/WORLD *** +ContinentLeveldesignWorldDirectory = "" # DISABLED + + +# *** SOURCE DIRECTORIES IN THE DATABASE *** + +# Shape directories +ShapeSourceDirectories = [ ] +ShapeSourceDirectories += [ "stuff/outgame/appart_crea" ] + +# Maps directories +MapSourceDirectories = [ ] +MapSourceDirectories += [ "stuff/outgame/_textures" ] + +MapUncompressedSourceDirectories = [ ] + +# Ligo directories +LigoBaseSourceDirectory = "landscape/ligo" + +# Ig directories +IgLandSourceDirectories = [ ] +IgOtherSourceDirectories = [ ] +IgOtherSourceDirectories += [ "stuff/outgame/appart_crea" ] +IgPrimitiveSourceDirectories = [ ] + +# Tiles root directory +TileRootSourceDirectory = "landscape/_texture_tiles" + +# Displace directory +DisplaceSourceDirectory = "landscape/_texture_tiles/displace" + + +# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) + +# Ig lookup directories used by rbank +IgLookupDirectories = [ ] +IgLookupDirectories += [ CommonPath + "/ig_land" ] +IgLookupDirectories += [ CommonPath + "/ig_other" ] + +# Shape lookup directories used by rbank +ShapeLookupDirectories = [ ] +# ShapeLookupDirectories += [ CommonPath + "/ps" ] +ShapeLookupDirectories += [ CommonPath + "/shape_clodtex_build" ] +ShapeLookupDirectories += [ CommonPath + "/shape_with_coarse_mesh" ] + +# Map lookup directories not yet used +MapLookupDirectories = [ ] +MapLookupDirectories += [ CommonPath + "/map_export" ] +MapLookupDirectories += [ CommonPath + "/map_uncompressed" ] + + +# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapExportDirectory = CommonPath + "/map_export" +MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" + +# Shape directories +ShapeTagExportDirectory = CommonPath + "/shape_tag" +ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" +ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" +ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" +ShapeAnimExportDirectory = CommonPath + "/shape_anim" + +# Ig directories +IgStaticLandExportDirectory = CommonPath + "/ig_static_land" # Landscape IG eported from 3dsmax not elevated by the heightmap +IgStaticOtherExportDirectory = CommonPath + "/ig_static_other" # Village or construction IGs exported from 3dsmax +IgStaticTagExportDirectory = CommonPath + "/ig_static_tag" # Tag for exported 3dsmax files + +# Zone directories +ZoneWeldBuildDirectory = CommonPath + "/zone_weld" +ZoneDependBuildDirectory = CommonPath + "/zone_depend" +ZoneLightWaterShapesLightedExportDirectory = CommonPath + "/zone_lwsl_temp" #fixme +ZoneLightBuildDirectory = CommonPath + "/zone_lighted" #fixme +ZoneLightDependBuildDirectory = CommonPath + "/zone_lighted_depend" #fixme +ZoneLightIgLandBuildDirectory = CommonPath + "/zone_lighted_ig_land" #fixme + + +# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapBuildDirectory = CommonPath + "/map" +MapPanoplyBuildDirectory = CommonPath + "/map_panoply" +MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" +MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" +MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" +MapTagBuildDirectory = CommonPath + "/map_tag" + +# Shape directories +ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" +ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" +ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" +ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" + +# Ig directories +IgElevLandPrimBuildDirectory = CommonPath + "/ig_elev_land_prim" # landscape IG generated by the prim exporter (already elevated by the land exporter) +IgElevLandLigoBuildDirectory = CommonPath + "/ig_elev_land_ligo" # Landscape IG found in ligo bricks from 3dsmax elevated by the heightmap +IgElevLandStaticBuildDirectory = CommonPath + "/ig_elev_land_static" # Landscape IG eported from 3dsmax elevated by the heightmap +IgTempLandMergeBuildDirectory = CommonPath + "/ig_temp_land_merge" +IgTempLandCompareBuildDirectory = CommonPath + "/ig_temp_land_compare" # Tmp final IG directory for landscape IGs before comparison +IgLandBuildDirectory = CommonPath + "/ig_land" # Final IG directory for landscape IGs +IgOtherBuildDirectory = CommonPath + "/ig_other" # Final IG directory for village or construction IGs +IgOtherLightedBuildDirectory = CommonPath + "/ig_other_lighted" + +# Farbank directories +FarbankBuildDirectory = CommonPath + "/farbank" + +# Ligo directories +LigoZoneBuildDirectory = CommonPath + "/ligo_zones" +LigoIgLandBuildDirectory = CommonPath + "/ligo_ig_land" # Landscape IG found in ligo bricks not elevated by the heightmap +LigoIgOtherBuildDirectory = CommonPath + "/ligo_ig_other" # Village or construction IGs exported from ligo landscape + + +# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** + +# Map directory +MapInstallDirectory = CommonName +BitmapInstallDirectory = MapInstallDirectory + +# Shape directory +ShapeInstallDirectory = CommonName + +# Lightmap directory +LightmapInstallDirectory = CommonName + +# Animation directory +AnimInstallDirectory = CommonName + +# Ig directory +IgInstallDirectory = CommonName diff --git a/code/ryzom/tools/build_gamedata/workspace/common/outgame/process.py b/code/ryzom/tools/build_gamedata/workspace/common/outgame/process.py index d6fd63919..ae6b3f5a0 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/outgame/process.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/outgame/process.py @@ -1,114 +1,114 @@ -#!/usr/bin/python -# -# \file config.py -# \brief Process configuration -# \date 2010-08-27 17:02GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Process configuration. -# -# NeL - 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 . -# - -# *** PROCESS CONFIGURATION *** - - -# *** PROCESS CONFIG *** -ProcessToComplete = [ ] -ProcessToComplete += [ "properties" ] -ProcessToComplete += [ "shape" ] -ProcessToComplete += [ "map" ] -ProcessToComplete += [ "ig" ] -ProcessToComplete += [ "ig_light" ] - - -# *** COMMON NAMES AND PATHS *** -EcosystemName = "outgame" -EcosystemPath = "common/" + EcosystemName -ContinentName = EcosystemName -ContinentPath = EcosystemPath -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** SHAPE EXPORT OPTIONS *** - -# Compute lightmaps ? -ShapeExportOptExportLighting = "true" - -# Cast shadow in lightmap ? -ShapeExportOptShadow = "true" - -# Lighting limits. 0 : normal, 1 : soft shadows -ShapeExportOptLightingLimit = 0 - -# Lightmap lumel size -ShapeExportOptLumelSize = "0.25" - -# Oversampling value. Can be 1, 2, 4 or 8 -ShapeExportOptOversampling = 1 - -# Does the lightmap must be generated in 8 bits format ? -ShapeExportOpt8BitsLightmap = "false" - -# Does the lightmaps export must generate logs ? -ShapeExportOptLightmapLog = "true" - -# Coarse mesh texture mul size -TextureMulSizeValue = "1.5" - -DoBuildShadowSkin = 0 - -ClodConfigFile = "" - -# *** COARSE MESH TEXTURE NAME *** -CoarseMeshTextureNames = [ ] - -# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** -MultipleTilesPostfix = [ ] -MultipleTilesPostfix += [ "_sp" ] -MultipleTilesPostfix += [ "_su" ] -MultipleTilesPostfix += [ "_au" ] -MultipleTilesPostfix += [ "_wi" ] - -# Name of the tilebank to use -BankTileBankName = "" - -# *** LANDSCAPE NAME *** -LandscapeName = "" - -# *** LIGO OPTIONS *** -LigoExportLand = "" -LigoExportOnePass = 0 -LigoExportColormap = "colormap_invalid.png" -LigoExportHeightmap1 = "big_invalid.png" -LigoExportZFactor1 = "1.0" -LigoExportHeightmap2 = "noise_invalid.png" -LigoExportZFactor2 = "0.5" -LigoTileBankFile = "" - -# *** MAPS OPTIONS *** - -ReduceBitmapFactor = 0 -# list all panoply files -MapPanoplyFileList = None -# name of the .hlsbank to build. -MapHlsBankFileName = None - -# *** ANIMATIONS OPTIONS *** - -DoOptimizeAnimations = 0 +#!/usr/bin/python +# +# \file config.py +# \brief Process configuration +# \date 2010-08-27 17:02GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Process configuration. +# +# NeL - 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 . +# + +# *** PROCESS CONFIGURATION *** + + +# *** PROCESS CONFIG *** +ProcessToComplete = [ ] +ProcessToComplete += [ "properties" ] +ProcessToComplete += [ "shape" ] +ProcessToComplete += [ "map" ] +ProcessToComplete += [ "ig" ] +ProcessToComplete += [ "ig_light" ] + + +# *** COMMON NAMES AND PATHS *** +EcosystemName = "outgame" +EcosystemPath = "common/" + EcosystemName +ContinentName = EcosystemName +ContinentPath = EcosystemPath +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** SHAPE EXPORT OPTIONS *** + +# Compute lightmaps ? +ShapeExportOptExportLighting = "true" + +# Cast shadow in lightmap ? +ShapeExportOptShadow = "true" + +# Lighting limits. 0 : normal, 1 : soft shadows +ShapeExportOptLightingLimit = 0 + +# Lightmap lumel size +ShapeExportOptLumelSize = "0.25" + +# Oversampling value. Can be 1, 2, 4 or 8 +ShapeExportOptOversampling = 1 + +# Does the lightmap must be generated in 8 bits format ? +ShapeExportOpt8BitsLightmap = "false" + +# Does the lightmaps export must generate logs ? +ShapeExportOptLightmapLog = "true" + +# Coarse mesh texture mul size +TextureMulSizeValue = "1.5" + +DoBuildShadowSkin = 0 + +ClodConfigFile = "" + +# *** COARSE MESH TEXTURE NAME *** +CoarseMeshTextureNames = [ ] + +# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** +MultipleTilesPostfix = [ ] +MultipleTilesPostfix += [ "_sp" ] +MultipleTilesPostfix += [ "_su" ] +MultipleTilesPostfix += [ "_au" ] +MultipleTilesPostfix += [ "_wi" ] + +# Name of the tilebank to use +BankTileBankName = "" + +# *** LANDSCAPE NAME *** +LandscapeName = "" + +# *** LIGO OPTIONS *** +LigoExportLand = "" +LigoExportOnePass = 0 +LigoExportColormap = "colormap_invalid.png" +LigoExportHeightmap1 = "big_invalid.png" +LigoExportZFactor1 = "1.0" +LigoExportHeightmap2 = "noise_invalid.png" +LigoExportZFactor2 = "0.5" +LigoTileBankFile = "" + +# *** MAPS OPTIONS *** + +ReduceBitmapFactor = 0 +# list all panoply files +MapPanoplyFileList = None +# name of the .hlsbank to build. +MapHlsBankFileName = None + +# *** ANIMATIONS OPTIONS *** + +DoOptimizeAnimations = 0 diff --git a/code/ryzom/tools/build_gamedata/workspace/common/sfx/directories.py b/code/ryzom/tools/build_gamedata/workspace/common/sfx/directories.py index d2397ce50..82df2c783 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/sfx/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/sfx/directories.py @@ -1,127 +1,127 @@ -#!/usr/bin/python -# -# \file directories.py -# \brief Directories configuration -# \date 2010-08-27 17:13GMT -# \author Jan Boon (Kaetemi) -# \date 2001-2005 -# \author Nevrax -# Python port of game data build pipeline. -# Directories configuration. -# -# NeL - 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 . -# - - -# *** COMMON NAMES AND PATHS *** -EcosystemName = "sfx" -EcosystemPath = "common/" + EcosystemName -ContinentName = EcosystemName -ContinentPath = EcosystemPath -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** SOURCE DIRECTORIES IN THE DATABASE *** - -# PS directories -PsSourceDirectories = [ ] -PsSourceDirectories += [ "sfx/buildings" ] -PsSourceDirectories += [ "sfx/environment" ] -PsSourceDirectories += [ "sfx/fighting" ] -PsSourceDirectories += [ "sfx/magic" ] -PsSourceDirectories += [ "sfx/moving" ] -PsSourceDirectories += [ "sfx/teaser" ] -PsSourceDirectories += [ "sfx/forage" ] -PsSourceDirectories += [ "sfx/monsters" ] - -# Maps directories -MapSourceDirectories = [ ] -MapSourceDirectories += [ "sfx/maps" ] - -# Shape directories -ShapeSourceDirectories = [ ] -ShapeSourceDirectories += [ "sfx/meshtoparticle" ] - -MapUncompressedSourceDirectories = [ ] - - -# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) - -# Ig lookup directories used by rbank -IgLookupDirectories = [ ] - -# Shape lookup directories used by rbank -ShapeLookupDirectories = [ ] -ShapeLookupDirectories += [ CommonPath + "/ps" ] -ShapeLookupDirectories += [ CommonPath + "/shape_clodtex_build" ] -ShapeLookupDirectories += [ CommonPath + "/shape_with_coarse_mesh" ] - -# Map lookup directories not yet used -MapLookupDirectories = [ ] -MapLookupDirectories += [ CommonPath + "/map_export" ] -MapLookupDirectories += [ CommonPath + "/map_uncompressed" ] - - -# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapExportDirectory = CommonPath + "/map_export" -MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" - -# Shape directories -ShapeTagExportDirectory = CommonPath + "/shape_tag" -ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" -ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" -ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" -ShapeAnimExportDirectory = CommonPath + "/shape_anim" - -# PS directories -PsExportDirectory = CommonPath + "/ps" - - -# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapBuildDirectory = CommonPath + "/map" -MapPanoplyBuildDirectory = CommonPath + "/map_panoply" -MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" -MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" -MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" -MapTagBuildDirectory = CommonPath + "/map_tag" - -# Shape directories -ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" -ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" -ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" -ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" - - -# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** - -# Particule system directory -PsInstallDirectory = "sfx" - -# Map directory -MapInstallDirectory = "sfx" -BitmapInstallDirectory = MapInstallDirectory - -# Shape directory -ShapeInstallDirectory = "sfx" - -# Lightmap directory -LightmapInstallDirectory = "sfx" +#!/usr/bin/python +# +# \file directories.py +# \brief Directories configuration +# \date 2010-08-27 17:13GMT +# \author Jan Boon (Kaetemi) +# \date 2001-2005 +# \author Nevrax +# Python port of game data build pipeline. +# Directories configuration. +# +# NeL - 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 . +# + + +# *** COMMON NAMES AND PATHS *** +EcosystemName = "sfx" +EcosystemPath = "common/" + EcosystemName +ContinentName = EcosystemName +ContinentPath = EcosystemPath +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** SOURCE DIRECTORIES IN THE DATABASE *** + +# PS directories +PsSourceDirectories = [ ] +PsSourceDirectories += [ "sfx/buildings" ] +PsSourceDirectories += [ "sfx/environment" ] +PsSourceDirectories += [ "sfx/fighting" ] +PsSourceDirectories += [ "sfx/magic" ] +PsSourceDirectories += [ "sfx/moving" ] +PsSourceDirectories += [ "sfx/teaser" ] +PsSourceDirectories += [ "sfx/forage" ] +PsSourceDirectories += [ "sfx/monsters" ] + +# Maps directories +MapSourceDirectories = [ ] +MapSourceDirectories += [ "sfx/maps" ] + +# Shape directories +ShapeSourceDirectories = [ ] +ShapeSourceDirectories += [ "sfx/meshtoparticle" ] + +MapUncompressedSourceDirectories = [ ] + + +# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) + +# Ig lookup directories used by rbank +IgLookupDirectories = [ ] + +# Shape lookup directories used by rbank +ShapeLookupDirectories = [ ] +ShapeLookupDirectories += [ CommonPath + "/ps" ] +ShapeLookupDirectories += [ CommonPath + "/shape_clodtex_build" ] +ShapeLookupDirectories += [ CommonPath + "/shape_with_coarse_mesh" ] + +# Map lookup directories not yet used +MapLookupDirectories = [ ] +MapLookupDirectories += [ CommonPath + "/map_export" ] +MapLookupDirectories += [ CommonPath + "/map_uncompressed" ] + + +# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapExportDirectory = CommonPath + "/map_export" +MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" + +# Shape directories +ShapeTagExportDirectory = CommonPath + "/shape_tag" +ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" +ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" +ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" +ShapeAnimExportDirectory = CommonPath + "/shape_anim" + +# PS directories +PsExportDirectory = CommonPath + "/ps" + + +# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapBuildDirectory = CommonPath + "/map" +MapPanoplyBuildDirectory = CommonPath + "/map_panoply" +MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" +MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" +MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" +MapTagBuildDirectory = CommonPath + "/map_tag" + +# Shape directories +ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" +ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" +ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" +ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" + + +# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** + +# Particule system directory +PsInstallDirectory = "sfx" + +# Map directory +MapInstallDirectory = "sfx" +BitmapInstallDirectory = MapInstallDirectory + +# Shape directory +ShapeInstallDirectory = "sfx" + +# Lightmap directory +LightmapInstallDirectory = "sfx" diff --git a/code/ryzom/tools/build_gamedata/workspace/common/sfx/process.py b/code/ryzom/tools/build_gamedata/workspace/common/sfx/process.py index ccbecb9b7..c18ca4534 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/sfx/process.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/sfx/process.py @@ -1,91 +1,91 @@ -#!/usr/bin/python -# -# \file config.py -# \brief Process configuration -# \date 2010-08-27 17:02GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Process configuration. -# -# NeL - 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 . -# - -# *** PROCESS CONFIGURATION *** - -# *** PROCESS CONFIG *** -ProcessToComplete = [ ] -ProcessToComplete += [ "ps" ] -ProcessToComplete += [ "map" ] -ProcessToComplete += [ "shape" ] - - -# *** COMMON NAMES AND PATHS *** -EcosystemName = "sfx" -EcosystemPath = "common/" + EcosystemName -ContinentName = EcosystemName -ContinentPath = EcosystemPath -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** SHAPE EXPORT OPTIONS *** - -# Compute lightmaps ? -ShapeExportOptExportLighting = "true" - -# Cast shadow in lightmap ? -ShapeExportOptShadow = "true" - -# Lighting limits. 0 : normal, 1 : soft shadows -ShapeExportOptLightingLimit = 0 - -# Lightmap lumel size -ShapeExportOptLumelSize = "0.25" - -# Oversampling value. Can be 1, 2, 4 or 8 -ShapeExportOptOversampling = 1 - -# Does the lightmap must be generated in 8 bits format ? -ShapeExportOpt8BitsLightmap = "false" - -# Does the lightmaps export must generate logs ? -ShapeExportOptLightmapLog = "true" - -# Coarse mesh texture mul size -TextureMulSizeValue = "1.5" - -DoBuildShadowSkin = 0 - -ClodConfigFile = "" - -# *** COARSE MESH TEXTURE NAME *** -CoarseMeshTextureNames = [ ] - -# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** -MultipleTilesPostfix = [ ] -MultipleTilesPostfix += [ "_sp" ] -MultipleTilesPostfix += [ "_su" ] -MultipleTilesPostfix += [ "_au" ] -MultipleTilesPostfix += [ "_wi" ] - -# *** MAPS OPTIONS *** - -ReduceBitmapFactor = 0 -# list all panoply files -MapPanoplyFileList = None -# name of the .hlsbank to build. -MapHlsBankFileName = None +#!/usr/bin/python +# +# \file config.py +# \brief Process configuration +# \date 2010-08-27 17:02GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Process configuration. +# +# NeL - 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 . +# + +# *** PROCESS CONFIGURATION *** + +# *** PROCESS CONFIG *** +ProcessToComplete = [ ] +ProcessToComplete += [ "ps" ] +ProcessToComplete += [ "map" ] +ProcessToComplete += [ "shape" ] + + +# *** COMMON NAMES AND PATHS *** +EcosystemName = "sfx" +EcosystemPath = "common/" + EcosystemName +ContinentName = EcosystemName +ContinentPath = EcosystemPath +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** SHAPE EXPORT OPTIONS *** + +# Compute lightmaps ? +ShapeExportOptExportLighting = "true" + +# Cast shadow in lightmap ? +ShapeExportOptShadow = "true" + +# Lighting limits. 0 : normal, 1 : soft shadows +ShapeExportOptLightingLimit = 0 + +# Lightmap lumel size +ShapeExportOptLumelSize = "0.25" + +# Oversampling value. Can be 1, 2, 4 or 8 +ShapeExportOptOversampling = 1 + +# Does the lightmap must be generated in 8 bits format ? +ShapeExportOpt8BitsLightmap = "false" + +# Does the lightmaps export must generate logs ? +ShapeExportOptLightmapLog = "true" + +# Coarse mesh texture mul size +TextureMulSizeValue = "1.5" + +DoBuildShadowSkin = 0 + +ClodConfigFile = "" + +# *** COARSE MESH TEXTURE NAME *** +CoarseMeshTextureNames = [ ] + +# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** +MultipleTilesPostfix = [ ] +MultipleTilesPostfix += [ "_sp" ] +MultipleTilesPostfix += [ "_su" ] +MultipleTilesPostfix += [ "_au" ] +MultipleTilesPostfix += [ "_wi" ] + +# *** MAPS OPTIONS *** + +ReduceBitmapFactor = 0 +# list all panoply files +MapPanoplyFileList = None +# name of the .hlsbank to build. +MapHlsBankFileName = None diff --git a/code/ryzom/tools/build_gamedata/workspace/common/sky/directories.py b/code/ryzom/tools/build_gamedata/workspace/common/sky/directories.py index f6babc6bc..a770548ce 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/sky/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/sky/directories.py @@ -1,188 +1,188 @@ -#!/usr/bin/python -# -# \file directories.py -# \brief Directories configuration -# \date 2010-08-27 17:13GMT -# \author Jan Boon (Kaetemi) -# \date 2001-2005 -# \author Nevrax -# Python port of game data build pipeline. -# Directories configuration. -# -# NeL - 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 . -# - - -# *** COMMON NAMES AND PATHS *** -EcosystemName = "sky" -EcosystemPath = "common/" + EcosystemName -ContinentName = EcosystemName -ContinentPath = EcosystemPath -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** SOURCE DIRECTORIES LEVELDESIGN/WORLD *** -ContinentLeveldesignWorldDirectory = "" # DISABLED - - -# *** SOURCE DIRECTORIES IN THE DATABASE *** - -# Shape directories -ShapeSourceDirectories = [ ] -ShapeSourceDirectories += [ "sky_v2/max" ] - -# Maps directories -MapSourceDirectories = [ ] -MapSourceDirectories += [ "sky_v2/textures/textures" ] - -MapUncompressedSourceDirectories = [ ] -MapUncompressedSourceDirectories += [ "sky_v2/textures/textures/desert" ] -MapUncompressedSourceDirectories += [ "sky_v2/textures/textures/forest" ] -MapUncompressedSourceDirectories += [ "sky_v2/textures/textures/jungle" ] -MapUncompressedSourceDirectories += [ "sky_v2/textures/textures/lacustre" ] -MapUncompressedSourceDirectories += [ "sky_v2/textures/setup/desert" ] -MapUncompressedSourceDirectories += [ "sky_v2/textures/setup/forest" ] -MapUncompressedSourceDirectories += [ "sky_v2/textures/setup/jungle" ] -MapUncompressedSourceDirectories += [ "sky_v2/textures/setup/lacustre" ] -MapUncompressedSourceDirectories += [ "sky_v2/textures/textures/nodds" ] - -# Ligo directories -LigoBaseSourceDirectory = "landscape/ligo" - -# Ig directories -IgLandSourceDirectories = [ ] -IgOtherSourceDirectories = [ ] -IgOtherSourceDirectories += [ "sky_v2/max" ] -IgPrimitiveSourceDirectories = [ ] - -# Tiles root directory -TileRootSourceDirectory = "landscape/_texture_tiles" - -# Displace directory -DisplaceSourceDirectory = "landscape/_texture_tiles/displace" - -# Animation directories -AnimSourceDirectories = [ ] -AnimSourceDirectories += [ "sky_v2/max" ] - - -# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) - -# Ig lookup directories used by rbank -IgLookupDirectories = [ ] -IgLookupDirectories += [ CommonPath + "/ig_land" ] -IgLookupDirectories += [ CommonPath + "/ig_other" ] - -# Shape lookup directories used by rbank -ShapeLookupDirectories = [ ] -# ShapeLookupDirectories += [ CommonPath + "/ps" ] -ShapeLookupDirectories += [ CommonPath + "/shape_clodtex_build" ] -ShapeLookupDirectories += [ CommonPath + "/shape_with_coarse_mesh" ] - -# Map lookup directories not yet used -MapLookupDirectories = [ ] -MapLookupDirectories += [ CommonPath + "/map_export" ] -MapLookupDirectories += [ CommonPath + "/map_uncompressed" ] - - -# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapExportDirectory = CommonPath + "/map_export" -MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" - -# Shape directories -ShapeTagExportDirectory = CommonPath + "/shape_tag" -ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" -ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" -ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" -ShapeAnimExportDirectory = CommonPath + "/shape_anim" - -# Ig directories -IgStaticLandExportDirectory = CommonPath + "/ig_static_land" # Landscape IG eported from 3dsmax not elevated by the heightmap -IgStaticOtherExportDirectory = CommonPath + "/ig_static_other" # Village or construction IGs exported from 3dsmax -IgStaticTagExportDirectory = CommonPath + "/ig_static_tag" # Tag for exported 3dsmax files - -# Zone directories -ZoneWeldBuildDirectory = CommonPath + "/zone_weld" -ZoneDependBuildDirectory = CommonPath + "/zone_depend" -ZoneLightWaterShapesLightedExportDirectory = CommonPath + "/zone_lwsl_temp" #fixme -ZoneLightBuildDirectory = CommonPath + "/zone_lighted" #fixme -ZoneLightDependBuildDirectory = CommonPath + "/zone_lighted_depend" #fixme -ZoneLightIgLandBuildDirectory = CommonPath + "/zone_lighted_ig_land" #fixme - -# Animation directories -AnimExportDirectory = CommonPath + "/anim_export" -AnimTagExportDirectory = CommonPath + "/anim_tag" - - -# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapBuildDirectory = CommonPath + "/map" -MapPanoplyBuildDirectory = CommonPath + "/map_panoply" -MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" -MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" -MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" -MapTagBuildDirectory = CommonPath + "/map_tag" - -# Shape directories -ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" -ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" -ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" -ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" - -# Ig directories -IgElevLandPrimBuildDirectory = CommonPath + "/ig_elev_land_prim" # landscape IG generated by the prim exporter (already elevated by the land exporter) -IgElevLandLigoBuildDirectory = CommonPath + "/ig_elev_land_ligo" # Landscape IG found in ligo bricks from 3dsmax elevated by the heightmap -IgElevLandStaticBuildDirectory = CommonPath + "/ig_elev_land_static" # Landscape IG eported from 3dsmax elevated by the heightmap -IgTempLandMergeBuildDirectory = CommonPath + "/ig_temp_land_merge" -IgTempLandCompareBuildDirectory = CommonPath + "/ig_temp_land_compare" # Tmp final IG directory for landscape IGs before comparison -IgLandBuildDirectory = CommonPath + "/ig_land" # Final IG directory for landscape IGs -IgOtherBuildDirectory = CommonPath + "/ig_other" # Final IG directory for village or construction IGs -IgOtherLightedBuildDirectory = CommonPath + "/ig_other_lighted" - -# Farbank directories -FarbankBuildDirectory = CommonPath + "/farbank" - -# Ligo directories -LigoZoneBuildDirectory = CommonPath + "/ligo_zones" -LigoIgLandBuildDirectory = CommonPath + "/ligo_ig_land" # Landscape IG found in ligo bricks not elevated by the heightmap -LigoIgOtherBuildDirectory = CommonPath + "/ligo_ig_other" # Village or construction IGs exported from ligo landscape - -# Animation directories -AnimBuildDirectory = CommonPath + "/anim" - - -# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** - -# Map directory -MapInstallDirectory = CommonName -BitmapInstallDirectory = MapInstallDirectory - -# Shape directory -ShapeInstallDirectory = CommonName - -# Lightmap directory -LightmapInstallDirectory = CommonName - -# Animation directory -AnimInstallDirectory = CommonName - -# Ig directory -IgInstallDirectory = CommonName +#!/usr/bin/python +# +# \file directories.py +# \brief Directories configuration +# \date 2010-08-27 17:13GMT +# \author Jan Boon (Kaetemi) +# \date 2001-2005 +# \author Nevrax +# Python port of game data build pipeline. +# Directories configuration. +# +# NeL - 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 . +# + + +# *** COMMON NAMES AND PATHS *** +EcosystemName = "sky" +EcosystemPath = "common/" + EcosystemName +ContinentName = EcosystemName +ContinentPath = EcosystemPath +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** SOURCE DIRECTORIES LEVELDESIGN/WORLD *** +ContinentLeveldesignWorldDirectory = "" # DISABLED + + +# *** SOURCE DIRECTORIES IN THE DATABASE *** + +# Shape directories +ShapeSourceDirectories = [ ] +ShapeSourceDirectories += [ "sky_v2/max" ] + +# Maps directories +MapSourceDirectories = [ ] +MapSourceDirectories += [ "sky_v2/textures/textures" ] + +MapUncompressedSourceDirectories = [ ] +MapUncompressedSourceDirectories += [ "sky_v2/textures/textures/desert" ] +MapUncompressedSourceDirectories += [ "sky_v2/textures/textures/forest" ] +MapUncompressedSourceDirectories += [ "sky_v2/textures/textures/jungle" ] +MapUncompressedSourceDirectories += [ "sky_v2/textures/textures/lacustre" ] +MapUncompressedSourceDirectories += [ "sky_v2/textures/setup/desert" ] +MapUncompressedSourceDirectories += [ "sky_v2/textures/setup/forest" ] +MapUncompressedSourceDirectories += [ "sky_v2/textures/setup/jungle" ] +MapUncompressedSourceDirectories += [ "sky_v2/textures/setup/lacustre" ] +MapUncompressedSourceDirectories += [ "sky_v2/textures/textures/nodds" ] + +# Ligo directories +LigoBaseSourceDirectory = "landscape/ligo" + +# Ig directories +IgLandSourceDirectories = [ ] +IgOtherSourceDirectories = [ ] +IgOtherSourceDirectories += [ "sky_v2/max" ] +IgPrimitiveSourceDirectories = [ ] + +# Tiles root directory +TileRootSourceDirectory = "landscape/_texture_tiles" + +# Displace directory +DisplaceSourceDirectory = "landscape/_texture_tiles/displace" + +# Animation directories +AnimSourceDirectories = [ ] +AnimSourceDirectories += [ "sky_v2/max" ] + + +# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) + +# Ig lookup directories used by rbank +IgLookupDirectories = [ ] +IgLookupDirectories += [ CommonPath + "/ig_land" ] +IgLookupDirectories += [ CommonPath + "/ig_other" ] + +# Shape lookup directories used by rbank +ShapeLookupDirectories = [ ] +# ShapeLookupDirectories += [ CommonPath + "/ps" ] +ShapeLookupDirectories += [ CommonPath + "/shape_clodtex_build" ] +ShapeLookupDirectories += [ CommonPath + "/shape_with_coarse_mesh" ] + +# Map lookup directories not yet used +MapLookupDirectories = [ ] +MapLookupDirectories += [ CommonPath + "/map_export" ] +MapLookupDirectories += [ CommonPath + "/map_uncompressed" ] + + +# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapExportDirectory = CommonPath + "/map_export" +MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" + +# Shape directories +ShapeTagExportDirectory = CommonPath + "/shape_tag" +ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" +ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" +ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" +ShapeAnimExportDirectory = CommonPath + "/shape_anim" + +# Ig directories +IgStaticLandExportDirectory = CommonPath + "/ig_static_land" # Landscape IG eported from 3dsmax not elevated by the heightmap +IgStaticOtherExportDirectory = CommonPath + "/ig_static_other" # Village or construction IGs exported from 3dsmax +IgStaticTagExportDirectory = CommonPath + "/ig_static_tag" # Tag for exported 3dsmax files + +# Zone directories +ZoneWeldBuildDirectory = CommonPath + "/zone_weld" +ZoneDependBuildDirectory = CommonPath + "/zone_depend" +ZoneLightWaterShapesLightedExportDirectory = CommonPath + "/zone_lwsl_temp" #fixme +ZoneLightBuildDirectory = CommonPath + "/zone_lighted" #fixme +ZoneLightDependBuildDirectory = CommonPath + "/zone_lighted_depend" #fixme +ZoneLightIgLandBuildDirectory = CommonPath + "/zone_lighted_ig_land" #fixme + +# Animation directories +AnimExportDirectory = CommonPath + "/anim_export" +AnimTagExportDirectory = CommonPath + "/anim_tag" + + +# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapBuildDirectory = CommonPath + "/map" +MapPanoplyBuildDirectory = CommonPath + "/map_panoply" +MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" +MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" +MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" +MapTagBuildDirectory = CommonPath + "/map_tag" + +# Shape directories +ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" +ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" +ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" +ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" + +# Ig directories +IgElevLandPrimBuildDirectory = CommonPath + "/ig_elev_land_prim" # landscape IG generated by the prim exporter (already elevated by the land exporter) +IgElevLandLigoBuildDirectory = CommonPath + "/ig_elev_land_ligo" # Landscape IG found in ligo bricks from 3dsmax elevated by the heightmap +IgElevLandStaticBuildDirectory = CommonPath + "/ig_elev_land_static" # Landscape IG eported from 3dsmax elevated by the heightmap +IgTempLandMergeBuildDirectory = CommonPath + "/ig_temp_land_merge" +IgTempLandCompareBuildDirectory = CommonPath + "/ig_temp_land_compare" # Tmp final IG directory for landscape IGs before comparison +IgLandBuildDirectory = CommonPath + "/ig_land" # Final IG directory for landscape IGs +IgOtherBuildDirectory = CommonPath + "/ig_other" # Final IG directory for village or construction IGs +IgOtherLightedBuildDirectory = CommonPath + "/ig_other_lighted" + +# Farbank directories +FarbankBuildDirectory = CommonPath + "/farbank" + +# Ligo directories +LigoZoneBuildDirectory = CommonPath + "/ligo_zones" +LigoIgLandBuildDirectory = CommonPath + "/ligo_ig_land" # Landscape IG found in ligo bricks not elevated by the heightmap +LigoIgOtherBuildDirectory = CommonPath + "/ligo_ig_other" # Village or construction IGs exported from ligo landscape + +# Animation directories +AnimBuildDirectory = CommonPath + "/anim" + + +# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** + +# Map directory +MapInstallDirectory = CommonName +BitmapInstallDirectory = MapInstallDirectory + +# Shape directory +ShapeInstallDirectory = CommonName + +# Lightmap directory +LightmapInstallDirectory = CommonName + +# Animation directory +AnimInstallDirectory = CommonName + +# Ig directory +IgInstallDirectory = CommonName diff --git a/code/ryzom/tools/build_gamedata/workspace/common/sky/process.py b/code/ryzom/tools/build_gamedata/workspace/common/sky/process.py index e32a883d9..efa18316b 100644 --- a/code/ryzom/tools/build_gamedata/workspace/common/sky/process.py +++ b/code/ryzom/tools/build_gamedata/workspace/common/sky/process.py @@ -1,121 +1,121 @@ -#!/usr/bin/python -# -# \file config.py -# \brief Process configuration -# \date 2010-08-27 17:02GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Process configuration. -# -# NeL - 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 . -# - -# *** PROCESS CONFIGURATION *** - - -# *** PROCESS CONFIG *** -ProcessToComplete = [ ] -ProcessToComplete += [ "properties" ] -ProcessToComplete += [ "shape" ] -ProcessToComplete += [ "map" ] -ProcessToComplete += [ "anim" ] -ProcessToComplete += [ "ig" ] -ProcessToComplete += [ "ig_light" ] - - -# *** COMMON NAMES AND PATHS *** -EcosystemName = "sky" -EcosystemPath = "common/" + EcosystemName -ContinentName = EcosystemName -ContinentPath = EcosystemPath -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** SHAPE EXPORT OPTIONS *** - -# Compute lightmaps ? -ShapeExportOptExportLighting = "true" - -# Cast shadow in lightmap ? -ShapeExportOptShadow = "true" - -# Lighting limits. 0 : normal, 1 : soft shadows -ShapeExportOptLightingLimit = 0 - -# Lightmap lumel size -ShapeExportOptLumelSize = "0.25" - -# Oversampling value. Can be 1, 2, 4 or 8 -ShapeExportOptOversampling = 1 - -# Does the lightmap must be generated in 8 bits format ? -ShapeExportOpt8BitsLightmap = "false" - -# Does the lightmaps export must generate logs ? -ShapeExportOptLightmapLog = "true" - -# Coarse mesh texture mul size -TextureMulSizeValue = "1.5" - -DoBuildShadowSkin = 0 - -ClodConfigFile = "" - - -# *** COARSE MESH TEXTURE NAME *** -CoarseMeshTextureNames = [ ] - - -# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** -MultipleTilesPostfix = [ ] -MultipleTilesPostfix += [ "_sp" ] -MultipleTilesPostfix += [ "_su" ] -MultipleTilesPostfix += [ "_au" ] -MultipleTilesPostfix += [ "_wi" ] - -# Name of the tilebank to use -BankTileBankName = "" - - -# *** LANDSCAPE NAME *** -LandscapeName = "" - - -# *** LIGO OPTIONS *** -LigoExportLand = "" -LigoExportOnePass = 0 -LigoExportColormap = "colormap_invalid.png" -LigoExportHeightmap1 = "big_invalid.png" -LigoExportZFactor1 = "1.0" -LigoExportHeightmap2 = "noise_invalid.png" -LigoExportZFactor2 = "0.5" -LigoTileBankFile = "" - - -# *** MAPS OPTIONS *** - -ReduceBitmapFactor = 0 -# list all panoply files -MapPanoplyFileList = None -# name of the .hlsbank to build. -MapHlsBankFileName = None - - -# *** ANIMATIONS OPTIONS *** - -DoOptimizeAnimations = 0 +#!/usr/bin/python +# +# \file config.py +# \brief Process configuration +# \date 2010-08-27 17:02GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Process configuration. +# +# NeL - 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 . +# + +# *** PROCESS CONFIGURATION *** + + +# *** PROCESS CONFIG *** +ProcessToComplete = [ ] +ProcessToComplete += [ "properties" ] +ProcessToComplete += [ "shape" ] +ProcessToComplete += [ "map" ] +ProcessToComplete += [ "anim" ] +ProcessToComplete += [ "ig" ] +ProcessToComplete += [ "ig_light" ] + + +# *** COMMON NAMES AND PATHS *** +EcosystemName = "sky" +EcosystemPath = "common/" + EcosystemName +ContinentName = EcosystemName +ContinentPath = EcosystemPath +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** SHAPE EXPORT OPTIONS *** + +# Compute lightmaps ? +ShapeExportOptExportLighting = "true" + +# Cast shadow in lightmap ? +ShapeExportOptShadow = "true" + +# Lighting limits. 0 : normal, 1 : soft shadows +ShapeExportOptLightingLimit = 0 + +# Lightmap lumel size +ShapeExportOptLumelSize = "0.25" + +# Oversampling value. Can be 1, 2, 4 or 8 +ShapeExportOptOversampling = 1 + +# Does the lightmap must be generated in 8 bits format ? +ShapeExportOpt8BitsLightmap = "false" + +# Does the lightmaps export must generate logs ? +ShapeExportOptLightmapLog = "true" + +# Coarse mesh texture mul size +TextureMulSizeValue = "1.5" + +DoBuildShadowSkin = 0 + +ClodConfigFile = "" + + +# *** COARSE MESH TEXTURE NAME *** +CoarseMeshTextureNames = [ ] + + +# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** +MultipleTilesPostfix = [ ] +MultipleTilesPostfix += [ "_sp" ] +MultipleTilesPostfix += [ "_su" ] +MultipleTilesPostfix += [ "_au" ] +MultipleTilesPostfix += [ "_wi" ] + +# Name of the tilebank to use +BankTileBankName = "" + + +# *** LANDSCAPE NAME *** +LandscapeName = "" + + +# *** LIGO OPTIONS *** +LigoExportLand = "" +LigoExportOnePass = 0 +LigoExportColormap = "colormap_invalid.png" +LigoExportHeightmap1 = "big_invalid.png" +LigoExportZFactor1 = "1.0" +LigoExportHeightmap2 = "noise_invalid.png" +LigoExportZFactor2 = "0.5" +LigoTileBankFile = "" + + +# *** MAPS OPTIONS *** + +ReduceBitmapFactor = 0 +# list all panoply files +MapPanoplyFileList = None +# name of the .hlsbank to build. +MapHlsBankFileName = None + + +# *** ANIMATIONS OPTIONS *** + +DoOptimizeAnimations = 0 diff --git a/code/ryzom/tools/build_gamedata/workspace/continents/fyros/directories.py b/code/ryzom/tools/build_gamedata/workspace/continents/fyros/directories.py index 7ca2c5eea..6c9134593 100644 --- a/code/ryzom/tools/build_gamedata/workspace/continents/fyros/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/continents/fyros/directories.py @@ -1,131 +1,131 @@ -#!/usr/bin/python -# -# \file directories.py -# \brief Directories configuration -# \date 2010-05-24 06:34GMT -# \author Jan Boon (Kaetemi) -# \date 2001-2005 -# \author Nevrax -# Python port of game data build pipeline. -# Directories configuration. -# -# NeL - 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 . -# - - -# *** ECOSYSTEM AND CONTINENT NAMES *** - -EcosystemName = "desert" -EcosystemPath = "ecosystems/" + EcosystemName -ContinentName = "fyros" -ContinentPath = "continents/" + ContinentName -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** SOURCE DIRECTORIES LEVELDESIGN/WORLD *** -ContinentLeveldesignWorldDirectory = ContinentName - - -# *** SOURCE DIRECTORIES IN THE DATABASE *** - -# Shape directories -ShapeSourceDirectories = [ ] -ShapeSourceDirectories += [ "stuff/fyros/decors/constructions" ] -ShapeSourceDirectories += [ "stuff/fyros/city" ] -ShapeSourceDirectories += [ "stuff/fyros/sky" ] -ShapeSourceDirectories += [ "landscape/water/meshes/desert" ] -ShapeSourceDirectories += [ "stuff/fyros/decors/constructions/fy_cn_mairie" ] - -# Maps directories -MapSourceDirectories = [ ] -MapSourceDirectories += [ "stuff/fyros/decors/_textures/batiments" ] -MapSourceDirectories += [ "stuff/fyros/city/_textures" ] -MapSourceDirectories += [ "stuff/fyros/sky" ] -MapSourceDirectories += [ "landscape/water/meshes/desert" ] -MapUncompressedSourceDirectories = [ ] - - -# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) - -# Shape lookup directories used by rbank -ShapeLookupDirectories = [ ] -ShapeLookupDirectories += [ "common/sfx/ps" ] -ShapeLookupDirectories += [ "common/sfx/shape_clodtex_build" ] -ShapeLookupDirectories += [ "common/sfx/shape_with_coarse_mesh" ] -ShapeLookupDirectories += [ "common/construction/shape_clodtex_build" ] -ShapeLookupDirectories += [ "common/construction/shape_with_coarse_mesh" ] -ShapeLookupDirectories += [ EcosystemPath + "/shape_clodtex_build" ] -ShapeLookupDirectories += [ EcosystemPath + "/shape_with_coarse_mesh" ] -ShapeLookupDirectories += [ ContinentPath + "/shape_clodtex_build" ] -ShapeLookupDirectories += [ ContinentPath + "/shape_with_coarse_mesh" ] -# ShapeLookupDirectories += [ ContinentName + "/zone_light/water_shapes_lighted" ] huh? - -# Map lookup directories used by shape -MapLookupDirectories = [ ] -MapLookupDirectories += [ "common/sfx/map_export" ] -MapLookupDirectories += [ "common/sfx/map_uncompressed" ] -MapLookupDirectories += [ "common/construction/map_export" ] -MapLookupDirectories += [ "common/construction/map_uncompressed" ] -MapLookupDirectories += [ EcosystemPath + "/map_export" ] -MapLookupDirectories += [ EcosystemPath + "/map_uncompressed" ] -MapLookupDirectories += [ ContinentPath + "/map_export" ] -MapLookupDirectories += [ ContinentPath + "/map_uncompressed" ] - - -# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapExportDirectory = CommonPath + "/map_export" -MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" - -# Shape directories -ShapeTagExportDirectory = CommonPath + "/shape_tag" -ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" -ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" -ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" -ShapeAnimExportDirectory = CommonPath + "/shape_anim" - - -# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapBuildDirectory = CommonPath + "/map" -MapPanoplyBuildDirectory = CommonPath + "/map_panoply" -MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" -MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" -MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" -MapTagBuildDirectory = CommonPath + "/map_tag" - -# Shape directories -ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" -ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" -ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" -ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" - - -# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** - -# Map directory -MapInstallDirectory = CommonName + "_maps" -BitmapInstallDirectory = MapInstallDirectory - -# Shape directory -ShapeInstallDirectory = CommonName + "_shapes" - -# Shape lightmaps directory -LightmapInstallDirectory = ShapeInstallDirectory +#!/usr/bin/python +# +# \file directories.py +# \brief Directories configuration +# \date 2010-05-24 06:34GMT +# \author Jan Boon (Kaetemi) +# \date 2001-2005 +# \author Nevrax +# Python port of game data build pipeline. +# Directories configuration. +# +# NeL - 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 . +# + + +# *** ECOSYSTEM AND CONTINENT NAMES *** + +EcosystemName = "desert" +EcosystemPath = "ecosystems/" + EcosystemName +ContinentName = "fyros" +ContinentPath = "continents/" + ContinentName +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** SOURCE DIRECTORIES LEVELDESIGN/WORLD *** +ContinentLeveldesignWorldDirectory = ContinentName + + +# *** SOURCE DIRECTORIES IN THE DATABASE *** + +# Shape directories +ShapeSourceDirectories = [ ] +ShapeSourceDirectories += [ "stuff/fyros/decors/constructions" ] +ShapeSourceDirectories += [ "stuff/fyros/city" ] +ShapeSourceDirectories += [ "stuff/fyros/sky" ] +ShapeSourceDirectories += [ "landscape/water/meshes/desert" ] +ShapeSourceDirectories += [ "stuff/fyros/decors/constructions/fy_cn_mairie" ] + +# Maps directories +MapSourceDirectories = [ ] +MapSourceDirectories += [ "stuff/fyros/decors/_textures/batiments" ] +MapSourceDirectories += [ "stuff/fyros/city/_textures" ] +MapSourceDirectories += [ "stuff/fyros/sky" ] +MapSourceDirectories += [ "landscape/water/meshes/desert" ] +MapUncompressedSourceDirectories = [ ] + + +# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) + +# Shape lookup directories used by rbank +ShapeLookupDirectories = [ ] +ShapeLookupDirectories += [ "common/sfx/ps" ] +ShapeLookupDirectories += [ "common/sfx/shape_clodtex_build" ] +ShapeLookupDirectories += [ "common/sfx/shape_with_coarse_mesh" ] +ShapeLookupDirectories += [ "common/construction/shape_clodtex_build" ] +ShapeLookupDirectories += [ "common/construction/shape_with_coarse_mesh" ] +ShapeLookupDirectories += [ EcosystemPath + "/shape_clodtex_build" ] +ShapeLookupDirectories += [ EcosystemPath + "/shape_with_coarse_mesh" ] +ShapeLookupDirectories += [ ContinentPath + "/shape_clodtex_build" ] +ShapeLookupDirectories += [ ContinentPath + "/shape_with_coarse_mesh" ] +# ShapeLookupDirectories += [ ContinentName + "/zone_light/water_shapes_lighted" ] huh? + +# Map lookup directories used by shape +MapLookupDirectories = [ ] +MapLookupDirectories += [ "common/sfx/map_export" ] +MapLookupDirectories += [ "common/sfx/map_uncompressed" ] +MapLookupDirectories += [ "common/construction/map_export" ] +MapLookupDirectories += [ "common/construction/map_uncompressed" ] +MapLookupDirectories += [ EcosystemPath + "/map_export" ] +MapLookupDirectories += [ EcosystemPath + "/map_uncompressed" ] +MapLookupDirectories += [ ContinentPath + "/map_export" ] +MapLookupDirectories += [ ContinentPath + "/map_uncompressed" ] + + +# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapExportDirectory = CommonPath + "/map_export" +MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" + +# Shape directories +ShapeTagExportDirectory = CommonPath + "/shape_tag" +ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" +ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" +ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" +ShapeAnimExportDirectory = CommonPath + "/shape_anim" + + +# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapBuildDirectory = CommonPath + "/map" +MapPanoplyBuildDirectory = CommonPath + "/map_panoply" +MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" +MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" +MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" +MapTagBuildDirectory = CommonPath + "/map_tag" + +# Shape directories +ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" +ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" +ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" +ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" + + +# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** + +# Map directory +MapInstallDirectory = CommonName + "_maps" +BitmapInstallDirectory = MapInstallDirectory + +# Shape directory +ShapeInstallDirectory = CommonName + "_shapes" + +# Shape lightmaps directory +LightmapInstallDirectory = ShapeInstallDirectory diff --git a/code/ryzom/tools/build_gamedata/workspace/continents/fyros/process.py b/code/ryzom/tools/build_gamedata/workspace/continents/fyros/process.py index 570c4d04f..5a31ce7c2 100644 --- a/code/ryzom/tools/build_gamedata/workspace/continents/fyros/process.py +++ b/code/ryzom/tools/build_gamedata/workspace/continents/fyros/process.py @@ -1,81 +1,81 @@ -#!/usr/bin/python -# -# \file config.py -# \brief Process configuration -# \date 2010-05-24 06:30GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Process configuration. -# -# NeL - 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 . -# - -# *** PROCESS CONFIGURATION *** - - -# *** PROCESS CONFIG *** -ProcessToComplete = [ ] -ProcessToComplete += [ "map" ] -ProcessToComplete += [ "shape" ] - - -# *** ECOSYSTEM AND CONTINENT NAMES *** - -EcosystemName = "desert" -EcosystemPath = "ecosystems/" + EcosystemName -ContinentName = "fyros" -ContinentPath = "continents/" + ContinentName -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** SHAPE EXPORT OPTIONS *** -# Compute lightmaps ? -ShapeExportOptExportLighting = "true" -# Cast shadow in lightmap ? -ShapeExportOptShadow = "true" -# Lighting limits. 0 : normal, 1 : soft shadows -ShapeExportOptLightingLimit = 1 -# Lightmap lumel size -ShapeExportOptLumelSize = "0.25" -# Oversampling value. Can be 1, 2, 4 or 8 -ShapeExportOptOversampling = 1 -# Does the lightmap must be generated in 8 bits format ? -ShapeExportOpt8BitsLightmap = "false" -# Does the lightmaps export must generate logs ? -ShapeExportOptLightmapLog = "true" -# Coarse mesh texture mul size -TextureMulSizeValue = "1.5" -DoBuildShadowSkin = 0 -ClodConfigFile = "" - -# *** COARSE MESH TEXTURE NAME *** -CoarseMeshTextureNames = [ ] - -# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** -MultipleTilesPostfix = [ ] -MultipleTilesPostfix += [ "_sp" ] -MultipleTilesPostfix += [ "_su" ] -MultipleTilesPostfix += [ "_au" ] -MultipleTilesPostfix += [ "_wi" ] - -# *** MAPS OPTIONS *** -ReduceBitmapFactor = 0 -# list all panoply files -MapPanoplyFileList = None -# name of the .hlsbank to build. -MapHlsBankFileName = None +#!/usr/bin/python +# +# \file config.py +# \brief Process configuration +# \date 2010-05-24 06:30GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Process configuration. +# +# NeL - 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 . +# + +# *** PROCESS CONFIGURATION *** + + +# *** PROCESS CONFIG *** +ProcessToComplete = [ ] +ProcessToComplete += [ "map" ] +ProcessToComplete += [ "shape" ] + + +# *** ECOSYSTEM AND CONTINENT NAMES *** + +EcosystemName = "desert" +EcosystemPath = "ecosystems/" + EcosystemName +ContinentName = "fyros" +ContinentPath = "continents/" + ContinentName +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** SHAPE EXPORT OPTIONS *** +# Compute lightmaps ? +ShapeExportOptExportLighting = "true" +# Cast shadow in lightmap ? +ShapeExportOptShadow = "true" +# Lighting limits. 0 : normal, 1 : soft shadows +ShapeExportOptLightingLimit = 1 +# Lightmap lumel size +ShapeExportOptLumelSize = "0.25" +# Oversampling value. Can be 1, 2, 4 or 8 +ShapeExportOptOversampling = 1 +# Does the lightmap must be generated in 8 bits format ? +ShapeExportOpt8BitsLightmap = "false" +# Does the lightmaps export must generate logs ? +ShapeExportOptLightmapLog = "true" +# Coarse mesh texture mul size +TextureMulSizeValue = "1.5" +DoBuildShadowSkin = 0 +ClodConfigFile = "" + +# *** COARSE MESH TEXTURE NAME *** +CoarseMeshTextureNames = [ ] + +# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** +MultipleTilesPostfix = [ ] +MultipleTilesPostfix += [ "_sp" ] +MultipleTilesPostfix += [ "_su" ] +MultipleTilesPostfix += [ "_au" ] +MultipleTilesPostfix += [ "_wi" ] + +# *** MAPS OPTIONS *** +ReduceBitmapFactor = 0 +# list all panoply files +MapPanoplyFileList = None +# name of the .hlsbank to build. +MapHlsBankFileName = None diff --git a/code/ryzom/tools/build_gamedata/workspace/continents/indoors/directories.py b/code/ryzom/tools/build_gamedata/workspace/continents/indoors/directories.py index 778567df8..ae098d437 100644 --- a/code/ryzom/tools/build_gamedata/workspace/continents/indoors/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/continents/indoors/directories.py @@ -1,262 +1,262 @@ -#!/usr/bin/python -# -# \file directories.py -# \brief Directories configuration -# \date 2010-05-24 06:34GMT -# \author Jan Boon (Kaetemi) -# \date 2001-2005 -# \author Nevrax -# Python port of game data build pipeline. -# Directories configuration. -# -# NeL - 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 . -# - - -# *** ECOSYSTEM AND CONTINENT NAMES *** - -EcosystemName = "desert" -EcosystemPath = "ecosystems/" + EcosystemName -ContinentName = "indoors" -ContinentPath = "continents/" + ContinentName -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** SOURCE DIRECTORIES LEVELDESIGN/WORLD *** -ContinentLeveldesignWorldDirectory = ContinentName - - -# *** SOURCE DIRECTORIES IN THE DATABASE *** - -# Shape directories -ShapeSourceDirectories = [ ] -ShapeSourceDirectories += [ "stuff/fyros/decors/constructions/fy_cn_appart_joueur" ] -ShapeSourceDirectories += [ "stuff/fyros/decors/constructions/fy_cn_hall_conseil" ] -ShapeSourceDirectories += [ "stuff/fyros/decors/constructions/fy_cn_hall_reunion_vitrine" ] -ShapeSourceDirectories += [ "stuff/fyros/decors/constructions/fy_cn_salle_npc" ] -ShapeSourceDirectories += [ "stuff/matis/decors/constructions/appart_joueur" ] -ShapeSourceDirectories += [ "stuff/matis/decors/constructions/hall_du_conseil" ] -ShapeSourceDirectories += [ "stuff/matis/decors/constructions/hall_vitrine_hall_reunion" ] -ShapeSourceDirectories += [ "stuff/matis/decors/constructions/salle_npc" ] -ShapeSourceDirectories += [ "stuff/tryker/decors/constructions/hall_conseil" ] -ShapeSourceDirectories += [ "stuff/tryker/decors/constructions/hall_vitrine_reunion" ] -ShapeSourceDirectories += [ "stuff/tryker/decors/constructions/piece_npc" ] -ShapeSourceDirectories += [ "stuff/tryker/decors/constructions/tr_appart" ] -ShapeSourceDirectories += [ "stuff/zorai/decors/constructions/Appart_joueur" ] -ShapeSourceDirectories += [ "stuff/zorai/decors/constructions/hall_conseil" ] -ShapeSourceDirectories += [ "stuff/zorai/decors/constructions/hall_reunion_vitrine" ] -ShapeSourceDirectories += [ "stuff/zorai/decors/constructions/salle_npc" ] - -# Ligo directories -LigoBaseSourceDirectory = "landscape/ligo/" + EcosystemName -LigoMaxSourceDirectory = LigoBaseSourceDirectory + "/max" - -# Zone directories -ZoneSourceDirectory = [ "landscape/zones/" + ContinentName ] # For old snowballs style landscape when not using ligo - -# Ig directories -IgLandSourceDirectories = [ ] -IgOtherSourceDirectories = [ ] -for dir in ShapeSourceDirectories: - IgOtherSourceDirectories += [ dir ] -IgPrimitiveSourceDirectories = [ ] - -# RBank directories -RBankCmbSourceDirectories = [ ] -for dir in ShapeSourceDirectories: - RBankCmbSourceDirectories += [ dir ] - -# Tiles root directory -TileRootSourceDirectory = "landscape/_texture_tiles/" + EcosystemName - -# Displace directory -DisplaceSourceDirectory = "landscape/_texture_tiles/" + EcosystemName + "/displace" - -# Ligo primitive directory used in the client -PsSourceDirectories = [ ] -PsSourceDirectories += [ "primitive_microlife/" + ContinentName ] - - -# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) - -# Ig lookup directories used by rbank -IgLookupDirectories = [ ] -IgLookupDirectories += [ ContinentPath + "/ig_land" ] -IgLookupDirectories += [ ContinentPath + "/ig_other" ] - -# Shape lookup directories used by rbank -ShapeLookupDirectories = [ ] -ShapeLookupDirectories += [ "common/sfx/ps" ] -ShapeLookupDirectories += [ "common/sfx/shape_clodtex_build" ] -ShapeLookupDirectories += [ "common/sfx/shape_with_coarse_mesh" ] -ShapeLookupDirectories += [ "common/construction/shape_clodtex_build" ] -ShapeLookupDirectories += [ "common/construction/shape_with_coarse_mesh" ] -ShapeLookupDirectories += [ "ecosystems/desert/shape_clodtex_build" ] -ShapeLookupDirectories += [ "ecosystems/desert/shape_with_coarse_mesh" ] -ShapeLookupDirectories += [ "ecosystems/jungle/shape_clodtex_build" ] -ShapeLookupDirectories += [ "ecosystems/jungle/shape_with_coarse_mesh" ] -ShapeLookupDirectories += [ "ecosystems/lacustre/shape_clodtex_build" ] -ShapeLookupDirectories += [ "ecosystems/lacustre/shape_with_coarse_mesh" ] -ShapeLookupDirectories += [ ContinentPath + "/shape_clodtex_build" ] -ShapeLookupDirectories += [ ContinentPath + "/shape_with_coarse_mesh" ] -ShapeLookupDirectories += [ "continents/fyros/shape_clodtex_build" ] -ShapeLookupDirectories += [ "continents/fyros/shape_with_coarse_mesh" ] -ShapeLookupDirectories += [ "continents/matis/shape_clodtex_build" ] -ShapeLookupDirectories += [ "continents/matis/shape_with_coarse_mesh" ] -ShapeLookupDirectories += [ "continents/zorai/shape_clodtex_build" ] -ShapeLookupDirectories += [ "continents/zorai/shape_with_coarse_mesh" ] -ShapeLookupDirectories += [ "continents/tryker/shape_clodtex_build" ] -ShapeLookupDirectories += [ "continents/tryker/shape_with_coarse_mesh" ] - -# Map lookup directories not yet used -MapLookupDirectories = [ ] -MapLookupDirectories += [ "common/sfx/map_export" ] -MapLookupDirectories += [ "common/sfx/map_uncompressed" ] -MapLookupDirectories += [ "common/construction/map_export" ] -MapLookupDirectories += [ "common/construction/map_uncompressed" ] -MapLookupDirectories += [ "ecosystems/desert/map_export" ] -MapLookupDirectories += [ "ecosystems/desert/map_uncompressed" ] -MapLookupDirectories += [ "ecosystems/jungle/map_export" ] -MapLookupDirectories += [ "ecosystems/jungle/map_uncompressed" ] -MapLookupDirectories += [ "ecosystems/lacustre/map_export" ] -MapLookupDirectories += [ "ecosystems/lacustre/map_uncompressed" ] -MapLookupDirectories += [ ContinentPath + "/map_export" ] -MapLookupDirectories += [ ContinentPath + "/map_uncompressed" ] -MapLookupDirectories += [ "continents/fyros/map_export" ] -MapLookupDirectories += [ "continents/fyros/map_uncompressed" ] -MapLookupDirectories += [ "continents/matis/map_export" ] -MapLookupDirectories += [ "continents/matis/map_uncompressed" ] -MapLookupDirectories += [ "continents/zorai/map_export" ] -MapLookupDirectories += [ "continents/zorai/map_uncompressed" ] -MapLookupDirectories += [ "continents/tryker/map_export" ] -MapLookupDirectories += [ "continents/tryker/map_uncompressed" ] - -# PacsPrim lookup directories used by ai_wmap -PacsPrimLookupDirectories = [ ] -PacsPrimLookupDirectories += [ "ecosystems/desert/pacs_prim" ] -PacsPrimLookupDirectories += [ "ecosystems/jungle/pacs_prim" ] -PacsPrimLookupDirectories += [ "ecosystems/lacustre/pacs_prim" ] - - -# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** - -# Shape directories -ShapeTagExportDirectory = CommonPath + "/shape_tag" -ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" -ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" -ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" -ShapeAnimExportDirectory = CommonPath + "/shape_anim" - -# Ligo directories -LigoDatabaseExportDirectory = "landscape/ligo/" + EcosystemName -LigoDatabaseIgExportDirectory = LigoDatabaseExportDirectory + "/igs" -LigoDatabaseZoneExportDirectory = LigoDatabaseExportDirectory + "/zones" -LigoDatabaseZoneLigoExportDirectory = LigoDatabaseExportDirectory + "/zoneligos" -LigoDatabaseCmbExportDirectory = LigoDatabaseExportDirectory + "/cmb" -LigoTagExportDirectory = "ecosystems/" + EcosystemName + "/ligo_tag" - -# Zone directories -ZoneExportDirectory = ContinentPath + "/zone" -WaterMapSourceDirectories = [ ] - -# RBank directories -RBankCmbExportDirectory = CommonPath + "/rbank_cmb_export" -RBankCmbTagExportDirectory = CommonPath + "/rbank_cmb_tag_export" - -# Smallbank directories -SmallbankExportDirectory = EcosystemPath + "/smallbank" - -# Tiles directories -DisplaceExportDirectory = EcosystemPath + "/diplace" - -# Ig directories -IgStaticLandExportDirectory = ContinentPath + "/ig_static_land" # Landscape IG eported from 3dsmax not elevated by the heightmap -IgStaticOtherExportDirectory = ContinentPath + "/ig_static_other" # Village or construction IGs exported from 3dsmax -IgStaticTagExportDirectory = ContinentPath + "/ig_static_tag" # Tag for exported 3dsmax files - -# PS directories -PsExportDirectory = CommonPath + "/ps" - - -# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** - -# Shape directories -ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" -ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" -ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" -ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" - -# Ligo directories -LigoZoneBuildDirectory = CommonPath + "/ligo_zones" -LigoIgLandBuildDirectory = CommonPath + "/ligo_ig_land" # Landscape IG found in ligo bricks not elevated by the heightmap -LigoIgOtherBuildDirectory = CommonPath + "/ligo_ig_other" # Village or construction IGs exported from ligo landscape - -# Zone directories -ZoneWeldBuildDirectory = CommonPath + "/zone_weld" -ZoneDependBuildDirectory = CommonPath + "/zone_depend" -ZoneLightWaterShapesLightedExportDirectory = CommonPath + "/zone_lwsl_temp" #fixme -ZoneLightBuildDirectory = CommonPath + "/zone_lighted" #fixme -ZoneLightDependBuildDirectory = CommonPath + "/zone_lighted_depend" #fixme -ZoneLightIgLandBuildDirectory = CommonPath + "/zone_lighted_ig_land" #fixme - -# Farbank directories -FarbankBuildDirectory = EcosystemPath + "/farbank" - -# Ig directories -IgElevLandPrimBuildDirectory = CommonPath + "/ig_elev_land_prim" # landscape IG generated by the prim exporter (already elevated by the land exporter) -IgElevLandLigoBuildDirectory = CommonPath + "/ig_elev_land_ligo" # Landscape IG found in ligo bricks from 3dsmax elevated by the heightmap -IgElevLandStaticBuildDirectory = CommonPath + "/ig_elev_land_static" # Landscape IG eported from 3dsmax elevated by the heightmap -IgTempLandMergeBuildDirectory = CommonPath + "/ig_temp_land_merge" -IgTempLandCompareBuildDirectory = CommonPath + "/ig_temp_land_compare" # Tmp final IG directory for landscape IGs before comparison -IgLandBuildDirectory = CommonPath + "/ig_land" # Final IG directory for landscape IGs -IgOtherBuildDirectory = CommonPath + "/ig_other" # Final IG directory for village or construction IGs -IgOtherLightedBuildDirectory = CommonPath + "/ig_other_lighted" - -# Rbank directories -RbankBboxBuildDirectory = CommonPath + "/rbank_bbox" -RbankTessellationBuildDirectory = CommonPath + "/rbank_tessellation" -RbankSmoothBuildDirectory = CommonPath + "/rbank_smooth" -RbankRawBuildDirectory = CommonPath + "/rbank_raw" -RbankPreprocBuildDirectory = CommonPath + "/rbank_preproc" -RbankRetrieversBuildDirectory = CommonPath + "/rbank_retrievers" -RbankOutputBuildDirectory = CommonPath + "/rbank_output" - -# AI Wmap directories -AiWmapBuildDirectory = CommonPath + "/ai_wmap" -AiWmapBuildTagDirectory = CommonPath + "/ai_wmap_tag" - - -# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** - -# Shape directory -ShapeInstallDirectory = CommonName + "_shapes" - -# Shape lightmaps directory -LightmapInstallDirectory = CommonName + "_lightmaps" - -# Ig directory -IgInstallDirectory = CommonName + "_ig" - -# PACS directory -PacsInstallDirectory = CommonName + "_pacs" - -# PS directory -PsInstallDirectory = CommonName + "_ig" - -# AI Wmap directory -AiWmapInstallDirectory = CommonName + "_ai" +#!/usr/bin/python +# +# \file directories.py +# \brief Directories configuration +# \date 2010-05-24 06:34GMT +# \author Jan Boon (Kaetemi) +# \date 2001-2005 +# \author Nevrax +# Python port of game data build pipeline. +# Directories configuration. +# +# NeL - 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 . +# + + +# *** ECOSYSTEM AND CONTINENT NAMES *** + +EcosystemName = "desert" +EcosystemPath = "ecosystems/" + EcosystemName +ContinentName = "indoors" +ContinentPath = "continents/" + ContinentName +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** SOURCE DIRECTORIES LEVELDESIGN/WORLD *** +ContinentLeveldesignWorldDirectory = ContinentName + + +# *** SOURCE DIRECTORIES IN THE DATABASE *** + +# Shape directories +ShapeSourceDirectories = [ ] +ShapeSourceDirectories += [ "stuff/fyros/decors/constructions/fy_cn_appart_joueur" ] +ShapeSourceDirectories += [ "stuff/fyros/decors/constructions/fy_cn_hall_conseil" ] +ShapeSourceDirectories += [ "stuff/fyros/decors/constructions/fy_cn_hall_reunion_vitrine" ] +ShapeSourceDirectories += [ "stuff/fyros/decors/constructions/fy_cn_salle_npc" ] +ShapeSourceDirectories += [ "stuff/matis/decors/constructions/appart_joueur" ] +ShapeSourceDirectories += [ "stuff/matis/decors/constructions/hall_du_conseil" ] +ShapeSourceDirectories += [ "stuff/matis/decors/constructions/hall_vitrine_hall_reunion" ] +ShapeSourceDirectories += [ "stuff/matis/decors/constructions/salle_npc" ] +ShapeSourceDirectories += [ "stuff/tryker/decors/constructions/hall_conseil" ] +ShapeSourceDirectories += [ "stuff/tryker/decors/constructions/hall_vitrine_reunion" ] +ShapeSourceDirectories += [ "stuff/tryker/decors/constructions/piece_npc" ] +ShapeSourceDirectories += [ "stuff/tryker/decors/constructions/tr_appart" ] +ShapeSourceDirectories += [ "stuff/zorai/decors/constructions/Appart_joueur" ] +ShapeSourceDirectories += [ "stuff/zorai/decors/constructions/hall_conseil" ] +ShapeSourceDirectories += [ "stuff/zorai/decors/constructions/hall_reunion_vitrine" ] +ShapeSourceDirectories += [ "stuff/zorai/decors/constructions/salle_npc" ] + +# Ligo directories +LigoBaseSourceDirectory = "landscape/ligo/" + EcosystemName +LigoMaxSourceDirectory = LigoBaseSourceDirectory + "/max" + +# Zone directories +ZoneSourceDirectory = [ "landscape/zones/" + ContinentName ] # For old snowballs style landscape when not using ligo + +# Ig directories +IgLandSourceDirectories = [ ] +IgOtherSourceDirectories = [ ] +for dir in ShapeSourceDirectories: + IgOtherSourceDirectories += [ dir ] +IgPrimitiveSourceDirectories = [ ] + +# RBank directories +RBankCmbSourceDirectories = [ ] +for dir in ShapeSourceDirectories: + RBankCmbSourceDirectories += [ dir ] + +# Tiles root directory +TileRootSourceDirectory = "landscape/_texture_tiles/" + EcosystemName + +# Displace directory +DisplaceSourceDirectory = "landscape/_texture_tiles/" + EcosystemName + "/displace" + +# Ligo primitive directory used in the client +PsSourceDirectories = [ ] +PsSourceDirectories += [ "primitive_microlife/" + ContinentName ] + + +# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) + +# Ig lookup directories used by rbank +IgLookupDirectories = [ ] +IgLookupDirectories += [ ContinentPath + "/ig_land" ] +IgLookupDirectories += [ ContinentPath + "/ig_other" ] + +# Shape lookup directories used by rbank +ShapeLookupDirectories = [ ] +ShapeLookupDirectories += [ "common/sfx/ps" ] +ShapeLookupDirectories += [ "common/sfx/shape_clodtex_build" ] +ShapeLookupDirectories += [ "common/sfx/shape_with_coarse_mesh" ] +ShapeLookupDirectories += [ "common/construction/shape_clodtex_build" ] +ShapeLookupDirectories += [ "common/construction/shape_with_coarse_mesh" ] +ShapeLookupDirectories += [ "ecosystems/desert/shape_clodtex_build" ] +ShapeLookupDirectories += [ "ecosystems/desert/shape_with_coarse_mesh" ] +ShapeLookupDirectories += [ "ecosystems/jungle/shape_clodtex_build" ] +ShapeLookupDirectories += [ "ecosystems/jungle/shape_with_coarse_mesh" ] +ShapeLookupDirectories += [ "ecosystems/lacustre/shape_clodtex_build" ] +ShapeLookupDirectories += [ "ecosystems/lacustre/shape_with_coarse_mesh" ] +ShapeLookupDirectories += [ ContinentPath + "/shape_clodtex_build" ] +ShapeLookupDirectories += [ ContinentPath + "/shape_with_coarse_mesh" ] +ShapeLookupDirectories += [ "continents/fyros/shape_clodtex_build" ] +ShapeLookupDirectories += [ "continents/fyros/shape_with_coarse_mesh" ] +ShapeLookupDirectories += [ "continents/matis/shape_clodtex_build" ] +ShapeLookupDirectories += [ "continents/matis/shape_with_coarse_mesh" ] +ShapeLookupDirectories += [ "continents/zorai/shape_clodtex_build" ] +ShapeLookupDirectories += [ "continents/zorai/shape_with_coarse_mesh" ] +ShapeLookupDirectories += [ "continents/tryker/shape_clodtex_build" ] +ShapeLookupDirectories += [ "continents/tryker/shape_with_coarse_mesh" ] + +# Map lookup directories not yet used +MapLookupDirectories = [ ] +MapLookupDirectories += [ "common/sfx/map_export" ] +MapLookupDirectories += [ "common/sfx/map_uncompressed" ] +MapLookupDirectories += [ "common/construction/map_export" ] +MapLookupDirectories += [ "common/construction/map_uncompressed" ] +MapLookupDirectories += [ "ecosystems/desert/map_export" ] +MapLookupDirectories += [ "ecosystems/desert/map_uncompressed" ] +MapLookupDirectories += [ "ecosystems/jungle/map_export" ] +MapLookupDirectories += [ "ecosystems/jungle/map_uncompressed" ] +MapLookupDirectories += [ "ecosystems/lacustre/map_export" ] +MapLookupDirectories += [ "ecosystems/lacustre/map_uncompressed" ] +MapLookupDirectories += [ ContinentPath + "/map_export" ] +MapLookupDirectories += [ ContinentPath + "/map_uncompressed" ] +MapLookupDirectories += [ "continents/fyros/map_export" ] +MapLookupDirectories += [ "continents/fyros/map_uncompressed" ] +MapLookupDirectories += [ "continents/matis/map_export" ] +MapLookupDirectories += [ "continents/matis/map_uncompressed" ] +MapLookupDirectories += [ "continents/zorai/map_export" ] +MapLookupDirectories += [ "continents/zorai/map_uncompressed" ] +MapLookupDirectories += [ "continents/tryker/map_export" ] +MapLookupDirectories += [ "continents/tryker/map_uncompressed" ] + +# PacsPrim lookup directories used by ai_wmap +PacsPrimLookupDirectories = [ ] +PacsPrimLookupDirectories += [ "ecosystems/desert/pacs_prim" ] +PacsPrimLookupDirectories += [ "ecosystems/jungle/pacs_prim" ] +PacsPrimLookupDirectories += [ "ecosystems/lacustre/pacs_prim" ] + + +# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** + +# Shape directories +ShapeTagExportDirectory = CommonPath + "/shape_tag" +ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" +ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" +ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" +ShapeAnimExportDirectory = CommonPath + "/shape_anim" + +# Ligo directories +LigoDatabaseExportDirectory = "landscape/ligo/" + EcosystemName +LigoDatabaseIgExportDirectory = LigoDatabaseExportDirectory + "/igs" +LigoDatabaseZoneExportDirectory = LigoDatabaseExportDirectory + "/zones" +LigoDatabaseZoneLigoExportDirectory = LigoDatabaseExportDirectory + "/zoneligos" +LigoDatabaseCmbExportDirectory = LigoDatabaseExportDirectory + "/cmb" +LigoTagExportDirectory = "ecosystems/" + EcosystemName + "/ligo_tag" + +# Zone directories +ZoneExportDirectory = ContinentPath + "/zone" +WaterMapSourceDirectories = [ ] + +# RBank directories +RBankCmbExportDirectory = CommonPath + "/rbank_cmb_export" +RBankCmbTagExportDirectory = CommonPath + "/rbank_cmb_tag_export" + +# Smallbank directories +SmallbankExportDirectory = EcosystemPath + "/smallbank" + +# Tiles directories +DisplaceExportDirectory = EcosystemPath + "/diplace" + +# Ig directories +IgStaticLandExportDirectory = ContinentPath + "/ig_static_land" # Landscape IG eported from 3dsmax not elevated by the heightmap +IgStaticOtherExportDirectory = ContinentPath + "/ig_static_other" # Village or construction IGs exported from 3dsmax +IgStaticTagExportDirectory = ContinentPath + "/ig_static_tag" # Tag for exported 3dsmax files + +# PS directories +PsExportDirectory = CommonPath + "/ps" + + +# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** + +# Shape directories +ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" +ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" +ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" +ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" + +# Ligo directories +LigoZoneBuildDirectory = CommonPath + "/ligo_zones" +LigoIgLandBuildDirectory = CommonPath + "/ligo_ig_land" # Landscape IG found in ligo bricks not elevated by the heightmap +LigoIgOtherBuildDirectory = CommonPath + "/ligo_ig_other" # Village or construction IGs exported from ligo landscape + +# Zone directories +ZoneWeldBuildDirectory = CommonPath + "/zone_weld" +ZoneDependBuildDirectory = CommonPath + "/zone_depend" +ZoneLightWaterShapesLightedExportDirectory = CommonPath + "/zone_lwsl_temp" #fixme +ZoneLightBuildDirectory = CommonPath + "/zone_lighted" #fixme +ZoneLightDependBuildDirectory = CommonPath + "/zone_lighted_depend" #fixme +ZoneLightIgLandBuildDirectory = CommonPath + "/zone_lighted_ig_land" #fixme + +# Farbank directories +FarbankBuildDirectory = EcosystemPath + "/farbank" + +# Ig directories +IgElevLandPrimBuildDirectory = CommonPath + "/ig_elev_land_prim" # landscape IG generated by the prim exporter (already elevated by the land exporter) +IgElevLandLigoBuildDirectory = CommonPath + "/ig_elev_land_ligo" # Landscape IG found in ligo bricks from 3dsmax elevated by the heightmap +IgElevLandStaticBuildDirectory = CommonPath + "/ig_elev_land_static" # Landscape IG eported from 3dsmax elevated by the heightmap +IgTempLandMergeBuildDirectory = CommonPath + "/ig_temp_land_merge" +IgTempLandCompareBuildDirectory = CommonPath + "/ig_temp_land_compare" # Tmp final IG directory for landscape IGs before comparison +IgLandBuildDirectory = CommonPath + "/ig_land" # Final IG directory for landscape IGs +IgOtherBuildDirectory = CommonPath + "/ig_other" # Final IG directory for village or construction IGs +IgOtherLightedBuildDirectory = CommonPath + "/ig_other_lighted" + +# Rbank directories +RbankBboxBuildDirectory = CommonPath + "/rbank_bbox" +RbankTessellationBuildDirectory = CommonPath + "/rbank_tessellation" +RbankSmoothBuildDirectory = CommonPath + "/rbank_smooth" +RbankRawBuildDirectory = CommonPath + "/rbank_raw" +RbankPreprocBuildDirectory = CommonPath + "/rbank_preproc" +RbankRetrieversBuildDirectory = CommonPath + "/rbank_retrievers" +RbankOutputBuildDirectory = CommonPath + "/rbank_output" + +# AI Wmap directories +AiWmapBuildDirectory = CommonPath + "/ai_wmap" +AiWmapBuildTagDirectory = CommonPath + "/ai_wmap_tag" + + +# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** + +# Shape directory +ShapeInstallDirectory = CommonName + "_shapes" + +# Shape lightmaps directory +LightmapInstallDirectory = CommonName + "_lightmaps" + +# Ig directory +IgInstallDirectory = CommonName + "_ig" + +# PACS directory +PacsInstallDirectory = CommonName + "_pacs" + +# PS directory +PsInstallDirectory = CommonName + "_ig" + +# AI Wmap directory +AiWmapInstallDirectory = CommonName + "_ai" diff --git a/code/ryzom/tools/build_gamedata/workspace/continents/indoors/process.py b/code/ryzom/tools/build_gamedata/workspace/continents/indoors/process.py index 5b8f2a309..b8c3b7225 100644 --- a/code/ryzom/tools/build_gamedata/workspace/continents/indoors/process.py +++ b/code/ryzom/tools/build_gamedata/workspace/continents/indoors/process.py @@ -1,167 +1,167 @@ -#!/usr/bin/python -# -# \file config.py -# \brief Process configuration -# \date 2010-05-24 06:30GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Process configuration. -# -# NeL - 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 . -# - -# *** PROCESS CONFIGURATION *** - - -# *** PROCESS CONFIG *** -ProcessToComplete = [ ] -ProcessToComplete += [ "properties" ] -ProcessToComplete += [ "shape" ] -ProcessToComplete += [ "ig" ] -ProcessToComplete += [ "rbank" ] -ProcessToComplete += [ "ig_light" ] -ProcessToComplete += [ "ps" ] -ProcessToComplete += [ "ai_wmap" ] - - -# *** ECOSYSTEM AND CONTINENT NAMES *** - -EcosystemName = "desert" -EcosystemPath = "ecosystems/" + EcosystemName -ContinentName = "indoors" -ContinentPath = "continents/" + ContinentName -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** LANDSCAPE NAME *** -LandscapeName = ContinentName - -# *** CONTINENT FILE *** -ContinentFile = ContinentName + "/" + ContinentName + ".continent" - - - -# *** SHAPE EXPORT OPTIONS *** - -# Compute lightmaps ? -ShapeExportOptExportLighting = "true" - -# Cast shadow in lightmap ? -ShapeExportOptShadow = "true" - -# Lighting limits. 0 : normal, 1 : soft shadows -ShapeExportOptLightingLimit = 0 - -# Lightmap lumel size -ShapeExportOptLumelSize = "0.25" - -# Oversampling value. Can be 1, 2, 4 or 8 -ShapeExportOptOversampling = 1 - -# Does the lightmap must be generated in 8 bits format ? -ShapeExportOpt8BitsLightmap = "false" - -# Does the lightmaps export must generate logs ? -ShapeExportOptLightmapLog = "true" - -# Coarse mesh texture mul size -TextureMulSizeValue = "1.5" - -DoBuildShadowSkin = 0 - -ClodConfigFile = "" - -# *** COARSE MESH TEXTURE NAME *** -CoarseMeshTextureNames = [ ] - -# *** BANK EXPORT OPTIONS *** - -# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** -MultipleTilesPostfix = [ ] -MultipleTilesPostfix += [ "_sp" ] -MultipleTilesPostfix += [ "_su" ] -MultipleTilesPostfix += [ "_au" ] -MultipleTilesPostfix += [ "_wi" ] - -# Name of the tilebank to use -BankTileBankName = EcosystemName - - -# *** LIGO OPTIONS *** -LigoExportLand = "" -LigoExportOnePass = 0 -LigoExportColormap = "colormap_" + ContinentName + ".png" -LigoExportHeightmap1 = "big_" + ContinentName + ".png" -LigoExportZFactor1 = "1.0" -LigoExportHeightmap2 = "noise_" + ContinentName + ".png" -LigoExportZFactor2 = "0.5" -LigoTileBankFile = "landscape/_texture_tiles/" + EcosystemName + "/" + EcosystemName + ".bank" - -# *** ZONE REGIONS ( up-left, down-right ) *** -#ZoneRegions = [ ] -#ZoneRegions += [ [ "1_aa" ] + [ "2_ai" ] ] - -# *** RBANK OPTIONS *** - -# Options -RBankVerbose = 0 -RBankConsistencyCheck = 0 -RbankReduceSurfaces = 1 -RbankSmoothBorders = 1 -RbankComputeElevation = 0 -RbankComputeLevels = 1 -RbankLinkElements = 1 -RbankCutEdges = 1 -RbankUseZoneSquare = 0 - -# Region to compute ( ALPHA UPPER CASE! ) -RbankZoneUl = "1_AA" -RbankZoneDr = "2_AI" - -# Output names -RbankRbankName = LandscapeName - - -# *** AI WMAP OPTIONS *** -AiWmapContinentName = ContinentName -AiWmapVerbose = 0 -AiWmapStartPoints = [ ] - -# matis -AiWmapStartPoints += [ ContinentName + " 20025 -432" ] # player room -AiWmapStartPoints += [ ContinentName + " 20120 -439" ] # hall room -AiWmapStartPoints += [ ContinentName + " 20190 -454" ] # guild room -AiWmapStartPoints += [ ContinentName + " 20281 -439" ] # role master/npc room - -# zorai -AiWmapStartPoints += [ ContinentName + " 20363 -439" ] # player room -AiWmapStartPoints += [ ContinentName + " 20440 -444" ] # hall room -AiWmapStartPoints += [ ContinentName + " 20519 -466" ] # guild room -AiWmapStartPoints += [ ContinentName + " 20591 -442" ] # role master/npc room - -# tryker -AiWmapStartPoints += [ ContinentName + " 20682 -439" ] # player room -AiWmapStartPoints += [ ContinentName + " 20755 -440" ] # hall room -# AiWmapStartPoints += [ ContinentName + " 20833 -439" ] # guild room -AiWmapStartPoints += [ ContinentName + " 20920 -439" ] # role master/npc room - -# fyros -AiWmapStartPoints += [ ContinentName + " 20998 -441" ] # player room -AiWmapStartPoints += [ ContinentName + " 21079 -443" ] # hall room -AiWmapStartPoints += [ ContinentName + " 21162 -443" ] # guild room -AiWmapStartPoints += [ ContinentName + " 21239 -439" ] # role master/npc room +#!/usr/bin/python +# +# \file config.py +# \brief Process configuration +# \date 2010-05-24 06:30GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Process configuration. +# +# NeL - 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 . +# + +# *** PROCESS CONFIGURATION *** + + +# *** PROCESS CONFIG *** +ProcessToComplete = [ ] +ProcessToComplete += [ "properties" ] +ProcessToComplete += [ "shape" ] +ProcessToComplete += [ "ig" ] +ProcessToComplete += [ "rbank" ] +ProcessToComplete += [ "ig_light" ] +ProcessToComplete += [ "ps" ] +ProcessToComplete += [ "ai_wmap" ] + + +# *** ECOSYSTEM AND CONTINENT NAMES *** + +EcosystemName = "desert" +EcosystemPath = "ecosystems/" + EcosystemName +ContinentName = "indoors" +ContinentPath = "continents/" + ContinentName +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** LANDSCAPE NAME *** +LandscapeName = ContinentName + +# *** CONTINENT FILE *** +ContinentFile = ContinentName + "/" + ContinentName + ".continent" + + + +# *** SHAPE EXPORT OPTIONS *** + +# Compute lightmaps ? +ShapeExportOptExportLighting = "true" + +# Cast shadow in lightmap ? +ShapeExportOptShadow = "true" + +# Lighting limits. 0 : normal, 1 : soft shadows +ShapeExportOptLightingLimit = 0 + +# Lightmap lumel size +ShapeExportOptLumelSize = "0.25" + +# Oversampling value. Can be 1, 2, 4 or 8 +ShapeExportOptOversampling = 1 + +# Does the lightmap must be generated in 8 bits format ? +ShapeExportOpt8BitsLightmap = "false" + +# Does the lightmaps export must generate logs ? +ShapeExportOptLightmapLog = "true" + +# Coarse mesh texture mul size +TextureMulSizeValue = "1.5" + +DoBuildShadowSkin = 0 + +ClodConfigFile = "" + +# *** COARSE MESH TEXTURE NAME *** +CoarseMeshTextureNames = [ ] + +# *** BANK EXPORT OPTIONS *** + +# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** +MultipleTilesPostfix = [ ] +MultipleTilesPostfix += [ "_sp" ] +MultipleTilesPostfix += [ "_su" ] +MultipleTilesPostfix += [ "_au" ] +MultipleTilesPostfix += [ "_wi" ] + +# Name of the tilebank to use +BankTileBankName = EcosystemName + + +# *** LIGO OPTIONS *** +LigoExportLand = "" +LigoExportOnePass = 0 +LigoExportColormap = "colormap_" + ContinentName + ".png" +LigoExportHeightmap1 = "big_" + ContinentName + ".png" +LigoExportZFactor1 = "1.0" +LigoExportHeightmap2 = "noise_" + ContinentName + ".png" +LigoExportZFactor2 = "0.5" +LigoTileBankFile = "landscape/_texture_tiles/" + EcosystemName + "/" + EcosystemName + ".bank" + +# *** ZONE REGIONS ( up-left, down-right ) *** +#ZoneRegions = [ ] +#ZoneRegions += [ [ "1_aa" ] + [ "2_ai" ] ] + +# *** RBANK OPTIONS *** + +# Options +RBankVerbose = 0 +RBankConsistencyCheck = 0 +RbankReduceSurfaces = 1 +RbankSmoothBorders = 1 +RbankComputeElevation = 0 +RbankComputeLevels = 1 +RbankLinkElements = 1 +RbankCutEdges = 1 +RbankUseZoneSquare = 0 + +# Region to compute ( ALPHA UPPER CASE! ) +RbankZoneUl = "1_AA" +RbankZoneDr = "2_AI" + +# Output names +RbankRbankName = LandscapeName + + +# *** AI WMAP OPTIONS *** +AiWmapContinentName = ContinentName +AiWmapVerbose = 0 +AiWmapStartPoints = [ ] + +# matis +AiWmapStartPoints += [ ContinentName + " 20025 -432" ] # player room +AiWmapStartPoints += [ ContinentName + " 20120 -439" ] # hall room +AiWmapStartPoints += [ ContinentName + " 20190 -454" ] # guild room +AiWmapStartPoints += [ ContinentName + " 20281 -439" ] # role master/npc room + +# zorai +AiWmapStartPoints += [ ContinentName + " 20363 -439" ] # player room +AiWmapStartPoints += [ ContinentName + " 20440 -444" ] # hall room +AiWmapStartPoints += [ ContinentName + " 20519 -466" ] # guild room +AiWmapStartPoints += [ ContinentName + " 20591 -442" ] # role master/npc room + +# tryker +AiWmapStartPoints += [ ContinentName + " 20682 -439" ] # player room +AiWmapStartPoints += [ ContinentName + " 20755 -440" ] # hall room +# AiWmapStartPoints += [ ContinentName + " 20833 -439" ] # guild room +AiWmapStartPoints += [ ContinentName + " 20920 -439" ] # role master/npc room + +# fyros +AiWmapStartPoints += [ ContinentName + " 20998 -441" ] # player room +AiWmapStartPoints += [ ContinentName + " 21079 -443" ] # hall room +AiWmapStartPoints += [ ContinentName + " 21162 -443" ] # guild room +AiWmapStartPoints += [ ContinentName + " 21239 -439" ] # role master/npc room diff --git a/code/ryzom/tools/build_gamedata/workspace/continents/matis/directories.py b/code/ryzom/tools/build_gamedata/workspace/continents/matis/directories.py index d6acd91fc..496f4b134 100644 --- a/code/ryzom/tools/build_gamedata/workspace/continents/matis/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/continents/matis/directories.py @@ -1,124 +1,124 @@ -#!/usr/bin/python -# -# \file directories.py -# \brief Directories configuration -# \date 2010-05-24 06:34GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Directories configuration. -# -# NeL - 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 . -# - - -# *** ECOSYSTEM AND CONTINENT NAMES *** - -EcosystemName = "jungle" -EcosystemPath = "ecosystems/" + EcosystemName -ContinentName = "matis" -ContinentPath = "continents/" + ContinentName -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** SOURCE DIRECTORIES LEVELDESIGN/WORLD *** -ContinentLeveldesignWorldDirectory = ContinentName - - -# *** SOURCE DIRECTORIES IN THE DATABASE *** - -# Shape directories -ShapeSourceDirectories = [ ] -ShapeSourceDirectories += [ "stuff/matis/decors/constructions" ] -ShapeSourceDirectories += [ "stuff/matis/sky" ] - -# Maps directories -MapSourceDirectories = [ ] -MapSourceDirectories += [ "stuff/matis/decors/_textures/batiments" ] -MapSourceDirectories += [ "stuff/matis/sky" ] -MapUncompressedSourceDirectories = [ ] - - -# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) - -# Shape lookup directories used by rbank -ShapeLookupDirectories = [ ] -ShapeLookupDirectories += [ "common/sfx/ps" ] -ShapeLookupDirectories += [ "common/sfx/shape_clodtex_build" ] -ShapeLookupDirectories += [ "common/sfx/shape_with_coarse_mesh" ] -ShapeLookupDirectories += [ "common/construction/shape_clodtex_build" ] -ShapeLookupDirectories += [ "common/construction/shape_with_coarse_mesh" ] -ShapeLookupDirectories += [ EcosystemPath + "/shape_clodtex_build" ] -ShapeLookupDirectories += [ EcosystemPath + "/shape_with_coarse_mesh" ] -ShapeLookupDirectories += [ ContinentPath + "/shape_clodtex_build" ] -ShapeLookupDirectories += [ ContinentPath + "/shape_with_coarse_mesh" ] -# ShapeLookupDirectories += [ ContinentName + "/zone_light/water_shapes_lighted" ] huh? - -# Map lookup directories used by shape -MapLookupDirectories = [ ] -MapLookupDirectories += [ "common/sfx/map_export" ] -MapLookupDirectories += [ "common/sfx/map_uncompressed" ] -MapLookupDirectories += [ "common/construction/map_export" ] -MapLookupDirectories += [ "common/construction/map_uncompressed" ] -MapLookupDirectories += [ EcosystemPath + "/map_export" ] -MapLookupDirectories += [ EcosystemPath + "/map_uncompressed" ] -MapLookupDirectories += [ ContinentPath + "/map_export" ] -MapLookupDirectories += [ ContinentPath + "/map_uncompressed" ] - - -# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapExportDirectory = CommonPath + "/map_export" -MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" - -# Shape directories -ShapeTagExportDirectory = CommonPath + "/shape_tag" -ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" -ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" -ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" -ShapeAnimExportDirectory = CommonPath + "/shape_anim" - - -# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapBuildDirectory = CommonPath + "/map" -MapPanoplyBuildDirectory = CommonPath + "/map_panoply" -MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" -MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" -MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" -MapTagBuildDirectory = CommonPath + "/map_tag" - -# Shape directories -ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" -ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" -ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" -ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" - - -# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** - -# Map directory -MapInstallDirectory = CommonName + "_maps" -BitmapInstallDirectory = MapInstallDirectory - -# Shape directory -ShapeInstallDirectory = CommonName + "_shapes" - -# Shape lightmaps directory -LightmapInstallDirectory = ShapeInstallDirectory +#!/usr/bin/python +# +# \file directories.py +# \brief Directories configuration +# \date 2010-05-24 06:34GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Directories configuration. +# +# NeL - 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 . +# + + +# *** ECOSYSTEM AND CONTINENT NAMES *** + +EcosystemName = "jungle" +EcosystemPath = "ecosystems/" + EcosystemName +ContinentName = "matis" +ContinentPath = "continents/" + ContinentName +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** SOURCE DIRECTORIES LEVELDESIGN/WORLD *** +ContinentLeveldesignWorldDirectory = ContinentName + + +# *** SOURCE DIRECTORIES IN THE DATABASE *** + +# Shape directories +ShapeSourceDirectories = [ ] +ShapeSourceDirectories += [ "stuff/matis/decors/constructions" ] +ShapeSourceDirectories += [ "stuff/matis/sky" ] + +# Maps directories +MapSourceDirectories = [ ] +MapSourceDirectories += [ "stuff/matis/decors/_textures/batiments" ] +MapSourceDirectories += [ "stuff/matis/sky" ] +MapUncompressedSourceDirectories = [ ] + + +# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) + +# Shape lookup directories used by rbank +ShapeLookupDirectories = [ ] +ShapeLookupDirectories += [ "common/sfx/ps" ] +ShapeLookupDirectories += [ "common/sfx/shape_clodtex_build" ] +ShapeLookupDirectories += [ "common/sfx/shape_with_coarse_mesh" ] +ShapeLookupDirectories += [ "common/construction/shape_clodtex_build" ] +ShapeLookupDirectories += [ "common/construction/shape_with_coarse_mesh" ] +ShapeLookupDirectories += [ EcosystemPath + "/shape_clodtex_build" ] +ShapeLookupDirectories += [ EcosystemPath + "/shape_with_coarse_mesh" ] +ShapeLookupDirectories += [ ContinentPath + "/shape_clodtex_build" ] +ShapeLookupDirectories += [ ContinentPath + "/shape_with_coarse_mesh" ] +# ShapeLookupDirectories += [ ContinentName + "/zone_light/water_shapes_lighted" ] huh? + +# Map lookup directories used by shape +MapLookupDirectories = [ ] +MapLookupDirectories += [ "common/sfx/map_export" ] +MapLookupDirectories += [ "common/sfx/map_uncompressed" ] +MapLookupDirectories += [ "common/construction/map_export" ] +MapLookupDirectories += [ "common/construction/map_uncompressed" ] +MapLookupDirectories += [ EcosystemPath + "/map_export" ] +MapLookupDirectories += [ EcosystemPath + "/map_uncompressed" ] +MapLookupDirectories += [ ContinentPath + "/map_export" ] +MapLookupDirectories += [ ContinentPath + "/map_uncompressed" ] + + +# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapExportDirectory = CommonPath + "/map_export" +MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" + +# Shape directories +ShapeTagExportDirectory = CommonPath + "/shape_tag" +ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" +ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" +ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" +ShapeAnimExportDirectory = CommonPath + "/shape_anim" + + +# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapBuildDirectory = CommonPath + "/map" +MapPanoplyBuildDirectory = CommonPath + "/map_panoply" +MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" +MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" +MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" +MapTagBuildDirectory = CommonPath + "/map_tag" + +# Shape directories +ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" +ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" +ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" +ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" + + +# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** + +# Map directory +MapInstallDirectory = CommonName + "_maps" +BitmapInstallDirectory = MapInstallDirectory + +# Shape directory +ShapeInstallDirectory = CommonName + "_shapes" + +# Shape lightmaps directory +LightmapInstallDirectory = ShapeInstallDirectory diff --git a/code/ryzom/tools/build_gamedata/workspace/continents/matis/process.py b/code/ryzom/tools/build_gamedata/workspace/continents/matis/process.py index fabc58b4f..3ac1dc6b2 100644 --- a/code/ryzom/tools/build_gamedata/workspace/continents/matis/process.py +++ b/code/ryzom/tools/build_gamedata/workspace/continents/matis/process.py @@ -1,81 +1,81 @@ -#!/usr/bin/python -# -# \file config.py -# \brief Process configuration -# \date 2010-05-24 06:30GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Process configuration. -# -# NeL - 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 . -# - -# *** PROCESS CONFIGURATION *** - - -# *** PROCESS CONFIG *** -ProcessToComplete = [ ] -ProcessToComplete += [ "map" ] -ProcessToComplete += [ "shape" ] - - -# *** ECOSYSTEM AND CONTINENT NAMES *** - -EcosystemName = "jungle" -EcosystemPath = "ecosystems/" + EcosystemName -ContinentName = "matis" -ContinentPath = "continents/" + ContinentName -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** SHAPE EXPORT OPTIONS *** -# Compute lightmaps ? -ShapeExportOptExportLighting = "true" -# Cast shadow in lightmap ? -ShapeExportOptShadow = "true" -# Lighting limits. 0 : normal, 1 : soft shadows -ShapeExportOptLightingLimit = 0 -# Lightmap lumel size -ShapeExportOptLumelSize = "0.25" -# Oversampling value. Can be 1, 2, 4 or 8 -ShapeExportOptOversampling = 1 -# Does the lightmap must be generated in 8 bits format ? -ShapeExportOpt8BitsLightmap = "false" -# Does the lightmaps export must generate logs ? -ShapeExportOptLightmapLog = "true" -# Coarse mesh texture mul size -TextureMulSizeValue = "1.5" -DoBuildShadowSkin = 0 -ClodConfigFile = "" - -# *** COARSE MESH TEXTURE NAME *** -CoarseMeshTextureNames = [ ] - -# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** -MultipleTilesPostfix = [ ] -MultipleTilesPostfix += [ "_sp" ] -MultipleTilesPostfix += [ "_su" ] -MultipleTilesPostfix += [ "_au" ] -MultipleTilesPostfix += [ "_wi" ] - -# *** MAPS OPTIONS *** -ReduceBitmapFactor = 0 -# list all panoply files -MapPanoplyFileList = None -# name of the .hlsbank to build. -MapHlsBankFileName = None +#!/usr/bin/python +# +# \file config.py +# \brief Process configuration +# \date 2010-05-24 06:30GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Process configuration. +# +# NeL - 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 . +# + +# *** PROCESS CONFIGURATION *** + + +# *** PROCESS CONFIG *** +ProcessToComplete = [ ] +ProcessToComplete += [ "map" ] +ProcessToComplete += [ "shape" ] + + +# *** ECOSYSTEM AND CONTINENT NAMES *** + +EcosystemName = "jungle" +EcosystemPath = "ecosystems/" + EcosystemName +ContinentName = "matis" +ContinentPath = "continents/" + ContinentName +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** SHAPE EXPORT OPTIONS *** +# Compute lightmaps ? +ShapeExportOptExportLighting = "true" +# Cast shadow in lightmap ? +ShapeExportOptShadow = "true" +# Lighting limits. 0 : normal, 1 : soft shadows +ShapeExportOptLightingLimit = 0 +# Lightmap lumel size +ShapeExportOptLumelSize = "0.25" +# Oversampling value. Can be 1, 2, 4 or 8 +ShapeExportOptOversampling = 1 +# Does the lightmap must be generated in 8 bits format ? +ShapeExportOpt8BitsLightmap = "false" +# Does the lightmaps export must generate logs ? +ShapeExportOptLightmapLog = "true" +# Coarse mesh texture mul size +TextureMulSizeValue = "1.5" +DoBuildShadowSkin = 0 +ClodConfigFile = "" + +# *** COARSE MESH TEXTURE NAME *** +CoarseMeshTextureNames = [ ] + +# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** +MultipleTilesPostfix = [ ] +MultipleTilesPostfix += [ "_sp" ] +MultipleTilesPostfix += [ "_su" ] +MultipleTilesPostfix += [ "_au" ] +MultipleTilesPostfix += [ "_wi" ] + +# *** MAPS OPTIONS *** +ReduceBitmapFactor = 0 +# list all panoply files +MapPanoplyFileList = None +# name of the .hlsbank to build. +MapHlsBankFileName = None diff --git a/code/ryzom/tools/build_gamedata/workspace/continents/newbieland/directories.py b/code/ryzom/tools/build_gamedata/workspace/continents/newbieland/directories.py index 35cf3b286..111acb560 100644 --- a/code/ryzom/tools/build_gamedata/workspace/continents/newbieland/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/continents/newbieland/directories.py @@ -1,251 +1,251 @@ -#!/usr/bin/python -# -# \file directories.py -# \brief Directories configuration -# \date 2010-05-24 06:34GMT -# \author Jan Boon (Kaetemi) -# \date 2001-2005 -# \author Nevrax -# Python port of game data build pipeline. -# Directories configuration. -# -# NeL - 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 . -# - - -# *** ECOSYSTEM AND CONTINENT NAMES *** - -EcosystemName = "jungle" -EcosystemPath = "ecosystems/" + EcosystemName -ContinentName = "newbieland" -ContinentPath = "continents/" + ContinentName -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** SOURCE DIRECTORIES LEVELDESIGN/WORLD *** -ContinentLeveldesignWorldDirectory = ContinentName - - -# *** SOURCE DIRECTORIES IN THE DATABASE *** - -# Shape directories -ShapeSourceDirectories = [ ] -ShapeSourceDirectories += [ "stuff/" + ContinentName + "/sky" ] - -# Maps directories -MapSourceDirectories = [ ] -MapSourceDirectories += [ "stuff/" + ContinentName + "/sky" ] - -MapUncompressedSourceDirectories = [ ] - -# Ligo directories -LigoBaseSourceDirectory = "landscape/ligo/" + EcosystemName -LigoMaxSourceDirectory = LigoBaseSourceDirectory + "/max" - -# Zone directories -ZoneSourceDirectory = [ "landscape/zones/" + ContinentName ] # For old snowballs style landscape when not using ligo - -# RBank directories -RBankCmbSourceDirectories = [ ] - -# Ig directories -IgLandSourceDirectories = [ ] -# IgLandSourceDirectories += [ "landscape/zones/" + ContinentName ] # For old snowballs style landscape when not using ligo -IgOtherSourceDirectories = [ ] -IgOtherSourceDirectories += [ "stuff/" + ContinentName + "/sky" ] # The canopee in the sky -IgPrimitiveSourceDirectories = [ ] -IgPrimitiveSourceDirectories += [ "primitive/" + ContinentName ] # Contains plants (trees, etc) primitive made with world editor - -# Tiles root directory -TileRootSourceDirectory = "landscape/_texture_tiles/" + EcosystemName - -# Displace directory -DisplaceSourceDirectory = "landscape/_texture_tiles/" + EcosystemName + "/displace" - -# Ligo primitive directory used in the client -PsSourceDirectories = [ ] -PsSourceDirectories += [ "primitive_microlife/" + ContinentName ] - - -# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) - -# Ig lookup directories used by rbank -IgLookupDirectories = [ ] -IgLookupDirectories += [ ContinentPath + "/ig_land" ] -IgLookupDirectories += [ ContinentPath + "/ig_other" ] - -# Shape lookup directories used by rbank -ShapeLookupDirectories = [ ] -ShapeLookupDirectories += [ "common/sfx/ps" ] -ShapeLookupDirectories += [ "common/sfx/shape_clodtex_build" ] -ShapeLookupDirectories += [ "common/sfx/shape_with_coarse_mesh" ] -ShapeLookupDirectories += [ "common/construction/shape_clodtex_build" ] -ShapeLookupDirectories += [ "common/construction/shape_with_coarse_mesh" ] -ShapeLookupDirectories += [ EcosystemPath + "/shape_clodtex_build" ] -ShapeLookupDirectories += [ EcosystemPath + "/shape_with_coarse_mesh" ] -ShapeLookupDirectories += [ ContinentPath + "/shape_clodtex_build" ] -ShapeLookupDirectories += [ ContinentPath + "/shape_with_coarse_mesh" ] -# ShapeLookupDirectories += [ ContinentName + "/zone_light/water_shapes_lighted" ] huh? -ShapeLookupDirectories += [ "ecosystems/lacustre/shape_clodtex_build" ] # additional -ShapeLookupDirectories += [ "ecosystems/lacustre/shape_with_coarse_mesh" ] # additional - -# Map lookup directories used by shape -MapLookupDirectories = [ ] -MapLookupDirectories += [ "common/sfx/map_export" ] -MapLookupDirectories += [ "common/sfx/map_uncompressed" ] -MapLookupDirectories += [ "common/construction/map_export" ] -MapLookupDirectories += [ "common/construction/map_uncompressed" ] -MapLookupDirectories += [ EcosystemPath + "/map_export" ] -MapLookupDirectories += [ EcosystemPath + "/map_uncompressed" ] -MapLookupDirectories += [ ContinentPath + "/map_export" ] -MapLookupDirectories += [ ContinentPath + "/map_uncompressed" ] -MapLookupDirectories += [ "ecosystems/lacustre/map_export" ] # additional -MapLookupDirectories += [ "ecosystems/lacustre/map_uncompressed" ] # additional - -# PacsPrim lookup directories used by ai_wmap -PacsPrimLookupDirectories = [ ] -PacsPrimLookupDirectories += [ EcosystemPath + "/pacs_prim" ] - - -# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapExportDirectory = CommonPath + "/map_export" -MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" - -# Shape directories -ShapeTagExportDirectory = CommonPath + "/shape_tag" -ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" -ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" -ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" -ShapeAnimExportDirectory = CommonPath + "/shape_anim" - -# Ligo directories -LigoDatabaseExportDirectory = "landscape/ligo/" + EcosystemName -LigoDatabaseIgExportDirectory = LigoDatabaseExportDirectory + "/igs" -LigoDatabaseZoneExportDirectory = LigoDatabaseExportDirectory + "/zones" -LigoDatabaseZoneLigoExportDirectory = LigoDatabaseExportDirectory + "/zoneligos" -LigoDatabaseCmbExportDirectory = LigoDatabaseExportDirectory + "/cmb" -LigoTagExportDirectory = "ecosystems/" + EcosystemName + "/ligo_tag" - -# Zone directories -ZoneExportDirectory = ContinentPath + "/zone" -WaterMapSourceDirectories = [ ] - -# RBank directories -RBankCmbExportDirectory = CommonPath + "/rbank_cmb_export" -RBankCmbTagExportDirectory = CommonPath + "/rbank_cmb_tag_export" - -# Smallbank directories -SmallbankExportDirectory = EcosystemPath + "/smallbank" - -# Tiles directories -DisplaceExportDirectory = EcosystemPath + "/diplace" - -# Ig directories -IgStaticLandExportDirectory = ContinentPath + "/ig_static_land" # Landscape IG eported from 3dsmax not elevated by the heightmap -IgStaticOtherExportDirectory = ContinentPath + "/ig_static_other" # Village or construction IGs exported from 3dsmax -IgStaticTagExportDirectory = ContinentPath + "/ig_static_tag" # Tag for exported 3dsmax files - -# PS directories -PsExportDirectory = CommonPath + "/ps" - - -# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapBuildDirectory = CommonPath + "/map" -MapPanoplyBuildDirectory = CommonPath + "/map_panoply" -MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" -MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" -MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" -MapTagBuildDirectory = CommonPath + "/map_tag" - -# Shape directories -ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" -ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" -ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" -ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" - -# Ligo directories -LigoZoneBuildDirectory = CommonPath + "/ligo_zones" -LigoIgLandBuildDirectory = CommonPath + "/ligo_ig_land" # Landscape IG found in ligo bricks not elevated by the heightmap -LigoIgOtherBuildDirectory = CommonPath + "/ligo_ig_other" # Village or construction IGs exported from ligo landscape - -# Zone directories -ZoneWeldBuildDirectory = CommonPath + "/zone_weld" -ZoneDependBuildDirectory = CommonPath + "/zone_depend" -ZoneLightWaterShapesLightedExportDirectory = CommonPath + "/zone_lwsl_temp" #fixme -ZoneLightBuildDirectory = CommonPath + "/zone_lighted" #fixme -ZoneLightDependBuildDirectory = CommonPath + "/zone_lighted_depend" #fixme -ZoneLightIgLandBuildDirectory = CommonPath + "/zone_lighted_ig_land" #fixme - -# Farbank directories -FarbankBuildDirectory = EcosystemPath + "/farbank" - -# Ig directories -IgElevLandPrimBuildDirectory = CommonPath + "/ig_elev_land_prim" # landscape IG generated by the prim exporter (already elevated by the land exporter) -IgElevLandLigoBuildDirectory = CommonPath + "/ig_elev_land_ligo" # Landscape IG found in ligo bricks from 3dsmax elevated by the heightmap -IgElevLandStaticBuildDirectory = CommonPath + "/ig_elev_land_static" # Landscape IG eported from 3dsmax elevated by the heightmap -IgTempLandMergeBuildDirectory = CommonPath + "/ig_temp_land_merge" -IgTempLandCompareBuildDirectory = CommonPath + "/ig_temp_land_compare" # Tmp final IG directory for landscape IGs before comparison -IgLandBuildDirectory = CommonPath + "/ig_land" # Final IG directory for landscape IGs -IgOtherBuildDirectory = CommonPath + "/ig_other" # Final IG directory for village or construction IGs -IgOtherLightedBuildDirectory = CommonPath + "/ig_other_lighted" - -# Rbank directories -RbankBboxBuildDirectory = CommonPath + "/rbank_bbox" -RbankTessellationBuildDirectory = CommonPath + "/rbank_tessellation" -RbankSmoothBuildDirectory = CommonPath + "/rbank_smooth" -RbankRawBuildDirectory = CommonPath + "/rbank_raw" -RbankPreprocBuildDirectory = CommonPath + "/rbank_preproc" -RbankRetrieversBuildDirectory = CommonPath + "/rbank_retrievers" -RbankOutputBuildDirectory = CommonPath + "/rbank_output" - -# AI Wmap directories -AiWmapBuildDirectory = CommonPath + "/ai_wmap" -AiWmapBuildTagDirectory = CommonPath + "/ai_wmap_tag" - - -# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** - -# Map directory -MapInstallDirectory = CommonName + "_maps" -BitmapInstallDirectory = MapInstallDirectory - -# Shape directory -ShapeInstallDirectory = CommonName + "_shapes" - -# Shape lightmaps directory -LightmapInstallDirectory = ShapeInstallDirectory - -# Ig directory -IgInstallDirectory = CommonName + "_ig" - -# Zone directory -ZoneInstallDirectory = CommonName + "_zones" -WaterMapsInstallDirectory = ZoneInstallDirectory - -# PACS directory -PacsInstallDirectory = CommonName + "_pacs" - -# PS directory -PsInstallDirectory = CommonName + "_ig" - -# AI Wmap directory -AiWmapInstallDirectory = CommonName + "_ai" +#!/usr/bin/python +# +# \file directories.py +# \brief Directories configuration +# \date 2010-05-24 06:34GMT +# \author Jan Boon (Kaetemi) +# \date 2001-2005 +# \author Nevrax +# Python port of game data build pipeline. +# Directories configuration. +# +# NeL - 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 . +# + + +# *** ECOSYSTEM AND CONTINENT NAMES *** + +EcosystemName = "jungle" +EcosystemPath = "ecosystems/" + EcosystemName +ContinentName = "newbieland" +ContinentPath = "continents/" + ContinentName +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** SOURCE DIRECTORIES LEVELDESIGN/WORLD *** +ContinentLeveldesignWorldDirectory = ContinentName + + +# *** SOURCE DIRECTORIES IN THE DATABASE *** + +# Shape directories +ShapeSourceDirectories = [ ] +ShapeSourceDirectories += [ "stuff/" + ContinentName + "/sky" ] + +# Maps directories +MapSourceDirectories = [ ] +MapSourceDirectories += [ "stuff/" + ContinentName + "/sky" ] + +MapUncompressedSourceDirectories = [ ] + +# Ligo directories +LigoBaseSourceDirectory = "landscape/ligo/" + EcosystemName +LigoMaxSourceDirectory = LigoBaseSourceDirectory + "/max" + +# Zone directories +ZoneSourceDirectory = [ "landscape/zones/" + ContinentName ] # For old snowballs style landscape when not using ligo + +# RBank directories +RBankCmbSourceDirectories = [ ] + +# Ig directories +IgLandSourceDirectories = [ ] +# IgLandSourceDirectories += [ "landscape/zones/" + ContinentName ] # For old snowballs style landscape when not using ligo +IgOtherSourceDirectories = [ ] +IgOtherSourceDirectories += [ "stuff/" + ContinentName + "/sky" ] # The canopee in the sky +IgPrimitiveSourceDirectories = [ ] +IgPrimitiveSourceDirectories += [ "primitive/" + ContinentName ] # Contains plants (trees, etc) primitive made with world editor + +# Tiles root directory +TileRootSourceDirectory = "landscape/_texture_tiles/" + EcosystemName + +# Displace directory +DisplaceSourceDirectory = "landscape/_texture_tiles/" + EcosystemName + "/displace" + +# Ligo primitive directory used in the client +PsSourceDirectories = [ ] +PsSourceDirectories += [ "primitive_microlife/" + ContinentName ] + + +# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) + +# Ig lookup directories used by rbank +IgLookupDirectories = [ ] +IgLookupDirectories += [ ContinentPath + "/ig_land" ] +IgLookupDirectories += [ ContinentPath + "/ig_other" ] + +# Shape lookup directories used by rbank +ShapeLookupDirectories = [ ] +ShapeLookupDirectories += [ "common/sfx/ps" ] +ShapeLookupDirectories += [ "common/sfx/shape_clodtex_build" ] +ShapeLookupDirectories += [ "common/sfx/shape_with_coarse_mesh" ] +ShapeLookupDirectories += [ "common/construction/shape_clodtex_build" ] +ShapeLookupDirectories += [ "common/construction/shape_with_coarse_mesh" ] +ShapeLookupDirectories += [ EcosystemPath + "/shape_clodtex_build" ] +ShapeLookupDirectories += [ EcosystemPath + "/shape_with_coarse_mesh" ] +ShapeLookupDirectories += [ ContinentPath + "/shape_clodtex_build" ] +ShapeLookupDirectories += [ ContinentPath + "/shape_with_coarse_mesh" ] +# ShapeLookupDirectories += [ ContinentName + "/zone_light/water_shapes_lighted" ] huh? +ShapeLookupDirectories += [ "ecosystems/lacustre/shape_clodtex_build" ] # additional +ShapeLookupDirectories += [ "ecosystems/lacustre/shape_with_coarse_mesh" ] # additional + +# Map lookup directories used by shape +MapLookupDirectories = [ ] +MapLookupDirectories += [ "common/sfx/map_export" ] +MapLookupDirectories += [ "common/sfx/map_uncompressed" ] +MapLookupDirectories += [ "common/construction/map_export" ] +MapLookupDirectories += [ "common/construction/map_uncompressed" ] +MapLookupDirectories += [ EcosystemPath + "/map_export" ] +MapLookupDirectories += [ EcosystemPath + "/map_uncompressed" ] +MapLookupDirectories += [ ContinentPath + "/map_export" ] +MapLookupDirectories += [ ContinentPath + "/map_uncompressed" ] +MapLookupDirectories += [ "ecosystems/lacustre/map_export" ] # additional +MapLookupDirectories += [ "ecosystems/lacustre/map_uncompressed" ] # additional + +# PacsPrim lookup directories used by ai_wmap +PacsPrimLookupDirectories = [ ] +PacsPrimLookupDirectories += [ EcosystemPath + "/pacs_prim" ] + + +# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapExportDirectory = CommonPath + "/map_export" +MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" + +# Shape directories +ShapeTagExportDirectory = CommonPath + "/shape_tag" +ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" +ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" +ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" +ShapeAnimExportDirectory = CommonPath + "/shape_anim" + +# Ligo directories +LigoDatabaseExportDirectory = "landscape/ligo/" + EcosystemName +LigoDatabaseIgExportDirectory = LigoDatabaseExportDirectory + "/igs" +LigoDatabaseZoneExportDirectory = LigoDatabaseExportDirectory + "/zones" +LigoDatabaseZoneLigoExportDirectory = LigoDatabaseExportDirectory + "/zoneligos" +LigoDatabaseCmbExportDirectory = LigoDatabaseExportDirectory + "/cmb" +LigoTagExportDirectory = "ecosystems/" + EcosystemName + "/ligo_tag" + +# Zone directories +ZoneExportDirectory = ContinentPath + "/zone" +WaterMapSourceDirectories = [ ] + +# RBank directories +RBankCmbExportDirectory = CommonPath + "/rbank_cmb_export" +RBankCmbTagExportDirectory = CommonPath + "/rbank_cmb_tag_export" + +# Smallbank directories +SmallbankExportDirectory = EcosystemPath + "/smallbank" + +# Tiles directories +DisplaceExportDirectory = EcosystemPath + "/diplace" + +# Ig directories +IgStaticLandExportDirectory = ContinentPath + "/ig_static_land" # Landscape IG eported from 3dsmax not elevated by the heightmap +IgStaticOtherExportDirectory = ContinentPath + "/ig_static_other" # Village or construction IGs exported from 3dsmax +IgStaticTagExportDirectory = ContinentPath + "/ig_static_tag" # Tag for exported 3dsmax files + +# PS directories +PsExportDirectory = CommonPath + "/ps" + + +# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapBuildDirectory = CommonPath + "/map" +MapPanoplyBuildDirectory = CommonPath + "/map_panoply" +MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" +MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" +MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" +MapTagBuildDirectory = CommonPath + "/map_tag" + +# Shape directories +ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" +ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" +ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" +ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" + +# Ligo directories +LigoZoneBuildDirectory = CommonPath + "/ligo_zones" +LigoIgLandBuildDirectory = CommonPath + "/ligo_ig_land" # Landscape IG found in ligo bricks not elevated by the heightmap +LigoIgOtherBuildDirectory = CommonPath + "/ligo_ig_other" # Village or construction IGs exported from ligo landscape + +# Zone directories +ZoneWeldBuildDirectory = CommonPath + "/zone_weld" +ZoneDependBuildDirectory = CommonPath + "/zone_depend" +ZoneLightWaterShapesLightedExportDirectory = CommonPath + "/zone_lwsl_temp" #fixme +ZoneLightBuildDirectory = CommonPath + "/zone_lighted" #fixme +ZoneLightDependBuildDirectory = CommonPath + "/zone_lighted_depend" #fixme +ZoneLightIgLandBuildDirectory = CommonPath + "/zone_lighted_ig_land" #fixme + +# Farbank directories +FarbankBuildDirectory = EcosystemPath + "/farbank" + +# Ig directories +IgElevLandPrimBuildDirectory = CommonPath + "/ig_elev_land_prim" # landscape IG generated by the prim exporter (already elevated by the land exporter) +IgElevLandLigoBuildDirectory = CommonPath + "/ig_elev_land_ligo" # Landscape IG found in ligo bricks from 3dsmax elevated by the heightmap +IgElevLandStaticBuildDirectory = CommonPath + "/ig_elev_land_static" # Landscape IG eported from 3dsmax elevated by the heightmap +IgTempLandMergeBuildDirectory = CommonPath + "/ig_temp_land_merge" +IgTempLandCompareBuildDirectory = CommonPath + "/ig_temp_land_compare" # Tmp final IG directory for landscape IGs before comparison +IgLandBuildDirectory = CommonPath + "/ig_land" # Final IG directory for landscape IGs +IgOtherBuildDirectory = CommonPath + "/ig_other" # Final IG directory for village or construction IGs +IgOtherLightedBuildDirectory = CommonPath + "/ig_other_lighted" + +# Rbank directories +RbankBboxBuildDirectory = CommonPath + "/rbank_bbox" +RbankTessellationBuildDirectory = CommonPath + "/rbank_tessellation" +RbankSmoothBuildDirectory = CommonPath + "/rbank_smooth" +RbankRawBuildDirectory = CommonPath + "/rbank_raw" +RbankPreprocBuildDirectory = CommonPath + "/rbank_preproc" +RbankRetrieversBuildDirectory = CommonPath + "/rbank_retrievers" +RbankOutputBuildDirectory = CommonPath + "/rbank_output" + +# AI Wmap directories +AiWmapBuildDirectory = CommonPath + "/ai_wmap" +AiWmapBuildTagDirectory = CommonPath + "/ai_wmap_tag" + + +# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** + +# Map directory +MapInstallDirectory = CommonName + "_maps" +BitmapInstallDirectory = MapInstallDirectory + +# Shape directory +ShapeInstallDirectory = CommonName + "_shapes" + +# Shape lightmaps directory +LightmapInstallDirectory = ShapeInstallDirectory + +# Ig directory +IgInstallDirectory = CommonName + "_ig" + +# Zone directory +ZoneInstallDirectory = CommonName + "_zones" +WaterMapsInstallDirectory = ZoneInstallDirectory + +# PACS directory +PacsInstallDirectory = CommonName + "_pacs" + +# PS directory +PsInstallDirectory = CommonName + "_ig" + +# AI Wmap directory +AiWmapInstallDirectory = CommonName + "_ai" diff --git a/code/ryzom/tools/build_gamedata/workspace/continents/newbieland/process.py b/code/ryzom/tools/build_gamedata/workspace/continents/newbieland/process.py index 0473db765..14e7ca8d1 100644 --- a/code/ryzom/tools/build_gamedata/workspace/continents/newbieland/process.py +++ b/code/ryzom/tools/build_gamedata/workspace/continents/newbieland/process.py @@ -1,169 +1,169 @@ -#!/usr/bin/python -# -# \file config.py -# \brief Process configuration -# \date 2010-05-24 06:30GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Process configuration. -# -# NeL - 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 . -# - -# *** PROCESS CONFIGURATION *** - - -# *** PROCESS CONFIG *** -ProcessToComplete = [ ] -ProcessToComplete += [ "properties" ] -ProcessToComplete += [ "map" ] -ProcessToComplete += [ "shape" ] -ProcessToComplete += [ "ligo" ] -ProcessToComplete += [ "zone" ] -ProcessToComplete += [ "ig" ] # fully implemented -ProcessToComplete += [ "zone_light" ] # works, need to check completeness -ProcessToComplete += [ "rbank" ] -ProcessToComplete += [ "ig_light" ] # fully implemented -ProcessToComplete += [ "ps" ] -ProcessToComplete += [ "ai_wmap" ] - - -# *** ECOSYSTEM AND CONTINENT NAMES *** - -EcosystemName = "jungle" -EcosystemPath = "ecosystems/" + EcosystemName -ContinentName = "newbieland" -ContinentPath = "continents/" + ContinentName -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** LANDSCAPE NAME *** -LandscapeName = ContinentName - -# *** CONTINENT FILE *** -ContinentFile = ContinentName + "/" + ContinentName + ".continent" - - - -# *** SHAPE EXPORT OPTIONS *** - -# Compute lightmaps ? -ShapeExportOptExportLighting = "true" - -# Cast shadow in lightmap ? -ShapeExportOptShadow = "true" - -# Lighting limits. 0 : normal, 1 : soft shadows -ShapeExportOptLightingLimit = 0 - -# Lightmap lumel size -ShapeExportOptLumelSize = "0.25" - -# Oversampling value. Can be 1, 2, 4 or 8 -ShapeExportOptOversampling = 1 - -# Does the lightmap must be generated in 8 bits format ? -ShapeExportOpt8BitsLightmap = "false" - -# Does the lightmaps export must generate logs ? -ShapeExportOptLightmapLog = "true" - -# Coarse mesh texture mul size -TextureMulSizeValue = "1.5" - -DoBuildShadowSkin = 0 - -ClodConfigFile = "" - -# *** COARSE MESH TEXTURE NAME *** -CoarseMeshTextureNames = [ ] - -# *** BANK EXPORT OPTIONS *** - -# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** -MultipleTilesPostfix = [ ] -MultipleTilesPostfix += [ "_sp" ] -MultipleTilesPostfix += [ "_su" ] -MultipleTilesPostfix += [ "_au" ] -MultipleTilesPostfix += [ "_wi" ] - -# Name of the tilebank to use -BankTileBankName = EcosystemName - - -# *** LIGO OPTIONS *** -LigoExportLand = ContinentName + ".land" -LigoExportOnePass = 0 -LigoExportColormap = "colormap_" + ContinentName + ".png" -LigoExportHeightmap1 = "big_" + ContinentName + ".png" -LigoExportZFactor1 = "1.0" -LigoExportHeightmap2 = "noise_" + ContinentName + ".png" -LigoExportZFactor2 = "0.5" -LigoTileBankFile = "landscape/_texture_tiles/" + EcosystemName + "/" + EcosystemName + ".bank" - -# *** ZONE REGIONS ( up-left, down-right ) *** -ZoneRegions = [ ] -ZoneRegions += [ [ "65_bz" ] + [ "77_cs" ] ] - -# *** RBANK OPTIONS *** - -# Options -RBankVerbose = 0 -RBankConsistencyCheck = 0 -RbankReduceSurfaces = 1 -RbankSmoothBorders = 1 -RbankComputeElevation = 0 -RbankComputeLevels = 1 -RbankLinkElements = 1 -RbankCutEdges = 1 -RbankUseZoneSquare = 0 - -# Region to compute ( ALPHA UPPER CASE! ) -RbankZoneUl = "65_BZ" -RbankZoneDr = "77_CS" - -# Output names -RbankRbankName = LandscapeName - -# Import ig pathes -#RbankIgPaths = [ ] # ExportBuildDirectory/... -#RbankIgPaths += [ "continents/" + ContinentName + "/ig_other" ] -#RbankIgPaths += [ "continents/" + ContinentName + "/ig_land" ] - -# Import shape pathes -#RbankShapePaths = [ ] # ExportBuildDirectory/... -#RbankShapePaths += [ "continents/" + ContinentName + "/shape" ] -#RbankShapePaths += [ "continents/" + ContinentName + "/shape_with_coarse_mesh_builded" ] -#RbankShapePaths += [ "ecosystems/" + EcosystemName + "/shape" ] -#RbankShapePaths += [ "ecosystems/" + EcosystemName + "/shape_with_coarse_mesh_builded" ] -#RbankShapePaths += [ "common/sfx/ps" ] -# RbankShapePaths += [ "l:/leveldesign/world_edit_files" ] - -# *** MAPS OPTIONS *** -ReduceBitmapFactor = 0 -# list all panoply files -MapPanoplyFileList = None -# name of the .hlsbank to build. -MapHlsBankFileName = None - -# *** AI WMAP OPTIONS *** -AiWmapContinentName = ContinentName -AiWmapVerbose = 0 -AiWmapStartPoints = [ ] -AiWmapStartPoints += [ ContinentName + " 8523 -10846" ] -AiWmapStartPoints += [ ContinentName + " 10314 -11743" ] +#!/usr/bin/python +# +# \file config.py +# \brief Process configuration +# \date 2010-05-24 06:30GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Process configuration. +# +# NeL - 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 . +# + +# *** PROCESS CONFIGURATION *** + + +# *** PROCESS CONFIG *** +ProcessToComplete = [ ] +ProcessToComplete += [ "properties" ] +ProcessToComplete += [ "map" ] +ProcessToComplete += [ "shape" ] +ProcessToComplete += [ "ligo" ] +ProcessToComplete += [ "zone" ] +ProcessToComplete += [ "ig" ] # fully implemented +ProcessToComplete += [ "zone_light" ] # works, need to check completeness +ProcessToComplete += [ "rbank" ] +ProcessToComplete += [ "ig_light" ] # fully implemented +ProcessToComplete += [ "ps" ] +ProcessToComplete += [ "ai_wmap" ] + + +# *** ECOSYSTEM AND CONTINENT NAMES *** + +EcosystemName = "jungle" +EcosystemPath = "ecosystems/" + EcosystemName +ContinentName = "newbieland" +ContinentPath = "continents/" + ContinentName +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** LANDSCAPE NAME *** +LandscapeName = ContinentName + +# *** CONTINENT FILE *** +ContinentFile = ContinentName + "/" + ContinentName + ".continent" + + + +# *** SHAPE EXPORT OPTIONS *** + +# Compute lightmaps ? +ShapeExportOptExportLighting = "true" + +# Cast shadow in lightmap ? +ShapeExportOptShadow = "true" + +# Lighting limits. 0 : normal, 1 : soft shadows +ShapeExportOptLightingLimit = 0 + +# Lightmap lumel size +ShapeExportOptLumelSize = "0.25" + +# Oversampling value. Can be 1, 2, 4 or 8 +ShapeExportOptOversampling = 1 + +# Does the lightmap must be generated in 8 bits format ? +ShapeExportOpt8BitsLightmap = "false" + +# Does the lightmaps export must generate logs ? +ShapeExportOptLightmapLog = "true" + +# Coarse mesh texture mul size +TextureMulSizeValue = "1.5" + +DoBuildShadowSkin = 0 + +ClodConfigFile = "" + +# *** COARSE MESH TEXTURE NAME *** +CoarseMeshTextureNames = [ ] + +# *** BANK EXPORT OPTIONS *** + +# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** +MultipleTilesPostfix = [ ] +MultipleTilesPostfix += [ "_sp" ] +MultipleTilesPostfix += [ "_su" ] +MultipleTilesPostfix += [ "_au" ] +MultipleTilesPostfix += [ "_wi" ] + +# Name of the tilebank to use +BankTileBankName = EcosystemName + + +# *** LIGO OPTIONS *** +LigoExportLand = ContinentName + ".land" +LigoExportOnePass = 0 +LigoExportColormap = "colormap_" + ContinentName + ".png" +LigoExportHeightmap1 = "big_" + ContinentName + ".png" +LigoExportZFactor1 = "1.0" +LigoExportHeightmap2 = "noise_" + ContinentName + ".png" +LigoExportZFactor2 = "0.5" +LigoTileBankFile = "landscape/_texture_tiles/" + EcosystemName + "/" + EcosystemName + ".bank" + +# *** ZONE REGIONS ( up-left, down-right ) *** +ZoneRegions = [ ] +ZoneRegions += [ [ "65_bz" ] + [ "77_cs" ] ] + +# *** RBANK OPTIONS *** + +# Options +RBankVerbose = 0 +RBankConsistencyCheck = 0 +RbankReduceSurfaces = 1 +RbankSmoothBorders = 1 +RbankComputeElevation = 0 +RbankComputeLevels = 1 +RbankLinkElements = 1 +RbankCutEdges = 1 +RbankUseZoneSquare = 0 + +# Region to compute ( ALPHA UPPER CASE! ) +RbankZoneUl = "65_BZ" +RbankZoneDr = "77_CS" + +# Output names +RbankRbankName = LandscapeName + +# Import ig pathes +#RbankIgPaths = [ ] # ExportBuildDirectory/... +#RbankIgPaths += [ "continents/" + ContinentName + "/ig_other" ] +#RbankIgPaths += [ "continents/" + ContinentName + "/ig_land" ] + +# Import shape pathes +#RbankShapePaths = [ ] # ExportBuildDirectory/... +#RbankShapePaths += [ "continents/" + ContinentName + "/shape" ] +#RbankShapePaths += [ "continents/" + ContinentName + "/shape_with_coarse_mesh_builded" ] +#RbankShapePaths += [ "ecosystems/" + EcosystemName + "/shape" ] +#RbankShapePaths += [ "ecosystems/" + EcosystemName + "/shape_with_coarse_mesh_builded" ] +#RbankShapePaths += [ "common/sfx/ps" ] +# RbankShapePaths += [ "l:/leveldesign/world_edit_files" ] + +# *** MAPS OPTIONS *** +ReduceBitmapFactor = 0 +# list all panoply files +MapPanoplyFileList = None +# name of the .hlsbank to build. +MapHlsBankFileName = None + +# *** AI WMAP OPTIONS *** +AiWmapContinentName = ContinentName +AiWmapVerbose = 0 +AiWmapStartPoints = [ ] +AiWmapStartPoints += [ ContinentName + " 8523 -10846" ] +AiWmapStartPoints += [ ContinentName + " 10314 -11743" ] diff --git a/code/ryzom/tools/build_gamedata/workspace/continents/tryker/directories.py b/code/ryzom/tools/build_gamedata/workspace/continents/tryker/directories.py index 5a7ebfef1..5d4024e61 100644 --- a/code/ryzom/tools/build_gamedata/workspace/continents/tryker/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/continents/tryker/directories.py @@ -1,126 +1,126 @@ -#!/usr/bin/python -# -# \file directories.py -# \brief Directories configuration -# \date 2010-05-24 06:34GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Directories configuration. -# -# NeL - 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 . -# - - -# *** ECOSYSTEM AND CONTINENT NAMES *** - -EcosystemName = "lacustre" -EcosystemPath = "ecosystems/" + EcosystemName -ContinentName = "tryker" -ContinentPath = "continents/" + ContinentName -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** SOURCE DIRECTORIES LEVELDESIGN/WORLD *** -ContinentLeveldesignWorldDirectory = ContinentName - - -# *** SOURCE DIRECTORIES IN THE DATABASE *** - -# Shape directories -ShapeSourceDirectories = [ ] -ShapeSourceDirectories += [ "stuff/tryker/decors/constructions" ] -ShapeSourceDirectories += [ "stuff/tryker/sky" ] -ShapeSourceDirectories += [ "landscape/water/Meshes/lacustre" ] - -# Maps directories -MapSourceDirectories = [ ] -MapSourceDirectories += [ "stuff/tryker/decors/_textures/batiments" ] -MapSourceDirectories += [ "stuff/tryker/sky" ] -MapSourceDirectories += [ "landscape/water/Meshes/lacustre" ] -MapUncompressedSourceDirectories = [ ] - - -# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) - -# Shape lookup directories used by rbank -ShapeLookupDirectories = [ ] -ShapeLookupDirectories += [ "common/sfx/ps" ] -ShapeLookupDirectories += [ "common/sfx/shape_clodtex_build" ] -ShapeLookupDirectories += [ "common/sfx/shape_with_coarse_mesh" ] -ShapeLookupDirectories += [ "common/construction/shape_clodtex_build" ] -ShapeLookupDirectories += [ "common/construction/shape_with_coarse_mesh" ] -ShapeLookupDirectories += [ EcosystemPath + "/shape_clodtex_build" ] -ShapeLookupDirectories += [ EcosystemPath + "/shape_with_coarse_mesh" ] -ShapeLookupDirectories += [ ContinentPath + "/shape_clodtex_build" ] -ShapeLookupDirectories += [ ContinentPath + "/shape_with_coarse_mesh" ] -# ShapeLookupDirectories += [ ContinentName + "/zone_light/water_shapes_lighted" ] huh? - -# Map lookup directories used by shape -MapLookupDirectories = [ ] -MapLookupDirectories += [ "common/sfx/map_export" ] -MapLookupDirectories += [ "common/sfx/map_uncompressed" ] -MapLookupDirectories += [ "common/construction/map_export" ] -MapLookupDirectories += [ "common/construction/map_uncompressed" ] -MapLookupDirectories += [ EcosystemPath + "/map_export" ] -MapLookupDirectories += [ EcosystemPath + "/map_uncompressed" ] -MapLookupDirectories += [ ContinentPath + "/map_export" ] -MapLookupDirectories += [ ContinentPath + "/map_uncompressed" ] - - -# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapExportDirectory = CommonPath + "/map_export" -MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" - -# Shape directories -ShapeTagExportDirectory = CommonPath + "/shape_tag" -ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" -ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" -ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" -ShapeAnimExportDirectory = CommonPath + "/shape_anim" - - -# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapBuildDirectory = CommonPath + "/map" -MapPanoplyBuildDirectory = CommonPath + "/map_panoply" -MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" -MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" -MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" -MapTagBuildDirectory = CommonPath + "/map_tag" - -# Shape directories -ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" -ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" -ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" -ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" - - -# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** - -# Map directory -MapInstallDirectory = CommonName + "_maps" -BitmapInstallDirectory = MapInstallDirectory - -# Shape directory -ShapeInstallDirectory = CommonName + "_shapes" - -# Shape lightmaps directory -LightmapInstallDirectory = ShapeInstallDirectory +#!/usr/bin/python +# +# \file directories.py +# \brief Directories configuration +# \date 2010-05-24 06:34GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Directories configuration. +# +# NeL - 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 . +# + + +# *** ECOSYSTEM AND CONTINENT NAMES *** + +EcosystemName = "lacustre" +EcosystemPath = "ecosystems/" + EcosystemName +ContinentName = "tryker" +ContinentPath = "continents/" + ContinentName +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** SOURCE DIRECTORIES LEVELDESIGN/WORLD *** +ContinentLeveldesignWorldDirectory = ContinentName + + +# *** SOURCE DIRECTORIES IN THE DATABASE *** + +# Shape directories +ShapeSourceDirectories = [ ] +ShapeSourceDirectories += [ "stuff/tryker/decors/constructions" ] +ShapeSourceDirectories += [ "stuff/tryker/sky" ] +ShapeSourceDirectories += [ "landscape/water/Meshes/lacustre" ] + +# Maps directories +MapSourceDirectories = [ ] +MapSourceDirectories += [ "stuff/tryker/decors/_textures/batiments" ] +MapSourceDirectories += [ "stuff/tryker/sky" ] +MapSourceDirectories += [ "landscape/water/Meshes/lacustre" ] +MapUncompressedSourceDirectories = [ ] + + +# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) + +# Shape lookup directories used by rbank +ShapeLookupDirectories = [ ] +ShapeLookupDirectories += [ "common/sfx/ps" ] +ShapeLookupDirectories += [ "common/sfx/shape_clodtex_build" ] +ShapeLookupDirectories += [ "common/sfx/shape_with_coarse_mesh" ] +ShapeLookupDirectories += [ "common/construction/shape_clodtex_build" ] +ShapeLookupDirectories += [ "common/construction/shape_with_coarse_mesh" ] +ShapeLookupDirectories += [ EcosystemPath + "/shape_clodtex_build" ] +ShapeLookupDirectories += [ EcosystemPath + "/shape_with_coarse_mesh" ] +ShapeLookupDirectories += [ ContinentPath + "/shape_clodtex_build" ] +ShapeLookupDirectories += [ ContinentPath + "/shape_with_coarse_mesh" ] +# ShapeLookupDirectories += [ ContinentName + "/zone_light/water_shapes_lighted" ] huh? + +# Map lookup directories used by shape +MapLookupDirectories = [ ] +MapLookupDirectories += [ "common/sfx/map_export" ] +MapLookupDirectories += [ "common/sfx/map_uncompressed" ] +MapLookupDirectories += [ "common/construction/map_export" ] +MapLookupDirectories += [ "common/construction/map_uncompressed" ] +MapLookupDirectories += [ EcosystemPath + "/map_export" ] +MapLookupDirectories += [ EcosystemPath + "/map_uncompressed" ] +MapLookupDirectories += [ ContinentPath + "/map_export" ] +MapLookupDirectories += [ ContinentPath + "/map_uncompressed" ] + + +# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapExportDirectory = CommonPath + "/map_export" +MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" + +# Shape directories +ShapeTagExportDirectory = CommonPath + "/shape_tag" +ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" +ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" +ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" +ShapeAnimExportDirectory = CommonPath + "/shape_anim" + + +# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapBuildDirectory = CommonPath + "/map" +MapPanoplyBuildDirectory = CommonPath + "/map_panoply" +MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" +MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" +MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" +MapTagBuildDirectory = CommonPath + "/map_tag" + +# Shape directories +ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" +ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" +ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" +ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" + + +# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** + +# Map directory +MapInstallDirectory = CommonName + "_maps" +BitmapInstallDirectory = MapInstallDirectory + +# Shape directory +ShapeInstallDirectory = CommonName + "_shapes" + +# Shape lightmaps directory +LightmapInstallDirectory = ShapeInstallDirectory diff --git a/code/ryzom/tools/build_gamedata/workspace/continents/tryker/process.py b/code/ryzom/tools/build_gamedata/workspace/continents/tryker/process.py index bffdb684b..d277c2030 100644 --- a/code/ryzom/tools/build_gamedata/workspace/continents/tryker/process.py +++ b/code/ryzom/tools/build_gamedata/workspace/continents/tryker/process.py @@ -1,81 +1,81 @@ -#!/usr/bin/python -# -# \file config.py -# \brief Process configuration -# \date 2010-05-24 06:30GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Process configuration. -# -# NeL - 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 . -# - -# *** PROCESS CONFIGURATION *** - - -# *** PROCESS CONFIG *** -ProcessToComplete = [ ] -ProcessToComplete += [ "map" ] -ProcessToComplete += [ "shape" ] - - -# *** ECOSYSTEM AND CONTINENT NAMES *** - -EcosystemName = "lacustre" -EcosystemPath = "ecosystems/" + EcosystemName -ContinentName = "tryker" -ContinentPath = "continents/" + ContinentName -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** SHAPE EXPORT OPTIONS *** -# Compute lightmaps ? -ShapeExportOptExportLighting = "true" -# Cast shadow in lightmap ? -ShapeExportOptShadow = "true" -# Lighting limits. 0 : normal, 1 : soft shadows -ShapeExportOptLightingLimit = 0 -# Lightmap lumel size -ShapeExportOptLumelSize = "0.25" -# Oversampling value. Can be 1, 2, 4 or 8 -ShapeExportOptOversampling = 1 -# Does the lightmap must be generated in 8 bits format ? -ShapeExportOpt8BitsLightmap = "false" -# Does the lightmaps export must generate logs ? -ShapeExportOptLightmapLog = "true" -# Coarse mesh texture mul size -TextureMulSizeValue = "1.5" -DoBuildShadowSkin = 0 -ClodConfigFile = "" - -# *** COARSE MESH TEXTURE NAME *** -CoarseMeshTextureNames = [ ] - -# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** -MultipleTilesPostfix = [ ] -MultipleTilesPostfix += [ "_sp" ] -MultipleTilesPostfix += [ "_su" ] -MultipleTilesPostfix += [ "_au" ] -MultipleTilesPostfix += [ "_wi" ] - -# *** MAPS OPTIONS *** -ReduceBitmapFactor = 0 -# list all panoply files -MapPanoplyFileList = None -# name of the .hlsbank to build. -MapHlsBankFileName = None +#!/usr/bin/python +# +# \file config.py +# \brief Process configuration +# \date 2010-05-24 06:30GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Process configuration. +# +# NeL - 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 . +# + +# *** PROCESS CONFIGURATION *** + + +# *** PROCESS CONFIG *** +ProcessToComplete = [ ] +ProcessToComplete += [ "map" ] +ProcessToComplete += [ "shape" ] + + +# *** ECOSYSTEM AND CONTINENT NAMES *** + +EcosystemName = "lacustre" +EcosystemPath = "ecosystems/" + EcosystemName +ContinentName = "tryker" +ContinentPath = "continents/" + ContinentName +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** SHAPE EXPORT OPTIONS *** +# Compute lightmaps ? +ShapeExportOptExportLighting = "true" +# Cast shadow in lightmap ? +ShapeExportOptShadow = "true" +# Lighting limits. 0 : normal, 1 : soft shadows +ShapeExportOptLightingLimit = 0 +# Lightmap lumel size +ShapeExportOptLumelSize = "0.25" +# Oversampling value. Can be 1, 2, 4 or 8 +ShapeExportOptOversampling = 1 +# Does the lightmap must be generated in 8 bits format ? +ShapeExportOpt8BitsLightmap = "false" +# Does the lightmaps export must generate logs ? +ShapeExportOptLightmapLog = "true" +# Coarse mesh texture mul size +TextureMulSizeValue = "1.5" +DoBuildShadowSkin = 0 +ClodConfigFile = "" + +# *** COARSE MESH TEXTURE NAME *** +CoarseMeshTextureNames = [ ] + +# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** +MultipleTilesPostfix = [ ] +MultipleTilesPostfix += [ "_sp" ] +MultipleTilesPostfix += [ "_su" ] +MultipleTilesPostfix += [ "_au" ] +MultipleTilesPostfix += [ "_wi" ] + +# *** MAPS OPTIONS *** +ReduceBitmapFactor = 0 +# list all panoply files +MapPanoplyFileList = None +# name of the .hlsbank to build. +MapHlsBankFileName = None diff --git a/code/ryzom/tools/build_gamedata/workspace/continents/zorai/directories.py b/code/ryzom/tools/build_gamedata/workspace/continents/zorai/directories.py index e8951ba70..cc0596f10 100644 --- a/code/ryzom/tools/build_gamedata/workspace/continents/zorai/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/continents/zorai/directories.py @@ -1,124 +1,124 @@ -#!/usr/bin/python -# -# \file directories.py -# \brief Directories configuration -# \date 2010-05-24 06:34GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Directories configuration. -# -# NeL - 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 . -# - - -# *** ECOSYSTEM AND CONTINENT NAMES *** - -EcosystemName = "jungle" -EcosystemPath = "ecosystems/" + EcosystemName -ContinentName = "zorai" -ContinentPath = "continents/" + ContinentName -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** SOURCE DIRECTORIES LEVELDESIGN/WORLD *** -ContinentLeveldesignWorldDirectory = ContinentName - - -# *** SOURCE DIRECTORIES IN THE DATABASE *** - -# Shape directories -ShapeSourceDirectories = [ ] -ShapeSourceDirectories += [ "stuff/zorai/decors/constructions" ] -ShapeSourceDirectories += [ "stuff/zorai/sky" ] - -# Maps directories -MapSourceDirectories = [ ] -MapSourceDirectories += [ "stuff/zorai/decors/_textures/batiments" ] -MapSourceDirectories += [ "stuff/zorai/sky" ] -MapUncompressedSourceDirectories = [ ] - - -# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) - -# Shape lookup directories used by rbank -ShapeLookupDirectories = [ ] -ShapeLookupDirectories += [ "common/sfx/ps" ] -ShapeLookupDirectories += [ "common/sfx/shape_clodtex_build" ] -ShapeLookupDirectories += [ "common/sfx/shape_with_coarse_mesh" ] -ShapeLookupDirectories += [ "common/construction/shape_clodtex_build" ] -ShapeLookupDirectories += [ "common/construction/shape_with_coarse_mesh" ] -ShapeLookupDirectories += [ EcosystemPath + "/shape_clodtex_build" ] -ShapeLookupDirectories += [ EcosystemPath + "/shape_with_coarse_mesh" ] -ShapeLookupDirectories += [ ContinentPath + "/shape_clodtex_build" ] -ShapeLookupDirectories += [ ContinentPath + "/shape_with_coarse_mesh" ] -# ShapeLookupDirectories += [ ContinentName + "/zone_light/water_shapes_lighted" ] huh? - -# Map lookup directories used by shape -MapLookupDirectories = [ ] -MapLookupDirectories += [ "common/sfx/map_export" ] -MapLookupDirectories += [ "common/sfx/map_uncompressed" ] -MapLookupDirectories += [ "common/construction/map_export" ] -MapLookupDirectories += [ "common/construction/map_uncompressed" ] -MapLookupDirectories += [ EcosystemPath + "/map_export" ] -MapLookupDirectories += [ EcosystemPath + "/map_uncompressed" ] -MapLookupDirectories += [ ContinentPath + "/map_export" ] -MapLookupDirectories += [ ContinentPath + "/map_uncompressed" ] - - -# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapExportDirectory = CommonPath + "/map_export" -MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" - -# Shape directories -ShapeTagExportDirectory = CommonPath + "/shape_tag" -ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" -ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" -ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" -ShapeAnimExportDirectory = CommonPath + "/shape_anim" - - -# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapBuildDirectory = CommonPath + "/map" -MapPanoplyBuildDirectory = CommonPath + "/map_panoply" -MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" -MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" -MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" -MapTagBuildDirectory = CommonPath + "/map_tag" - -# Shape directories -ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" -ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" -ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" -ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" - - -# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** - -# Map directory -MapInstallDirectory = CommonName + "_maps" -BitmapInstallDirectory = MapInstallDirectory - -# Shape directory -ShapeInstallDirectory = CommonName + "_shapes" - -# Shape lightmaps directory -LightmapInstallDirectory = ShapeInstallDirectory +#!/usr/bin/python +# +# \file directories.py +# \brief Directories configuration +# \date 2010-05-24 06:34GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Directories configuration. +# +# NeL - 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 . +# + + +# *** ECOSYSTEM AND CONTINENT NAMES *** + +EcosystemName = "jungle" +EcosystemPath = "ecosystems/" + EcosystemName +ContinentName = "zorai" +ContinentPath = "continents/" + ContinentName +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** SOURCE DIRECTORIES LEVELDESIGN/WORLD *** +ContinentLeveldesignWorldDirectory = ContinentName + + +# *** SOURCE DIRECTORIES IN THE DATABASE *** + +# Shape directories +ShapeSourceDirectories = [ ] +ShapeSourceDirectories += [ "stuff/zorai/decors/constructions" ] +ShapeSourceDirectories += [ "stuff/zorai/sky" ] + +# Maps directories +MapSourceDirectories = [ ] +MapSourceDirectories += [ "stuff/zorai/decors/_textures/batiments" ] +MapSourceDirectories += [ "stuff/zorai/sky" ] +MapUncompressedSourceDirectories = [ ] + + +# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) + +# Shape lookup directories used by rbank +ShapeLookupDirectories = [ ] +ShapeLookupDirectories += [ "common/sfx/ps" ] +ShapeLookupDirectories += [ "common/sfx/shape_clodtex_build" ] +ShapeLookupDirectories += [ "common/sfx/shape_with_coarse_mesh" ] +ShapeLookupDirectories += [ "common/construction/shape_clodtex_build" ] +ShapeLookupDirectories += [ "common/construction/shape_with_coarse_mesh" ] +ShapeLookupDirectories += [ EcosystemPath + "/shape_clodtex_build" ] +ShapeLookupDirectories += [ EcosystemPath + "/shape_with_coarse_mesh" ] +ShapeLookupDirectories += [ ContinentPath + "/shape_clodtex_build" ] +ShapeLookupDirectories += [ ContinentPath + "/shape_with_coarse_mesh" ] +# ShapeLookupDirectories += [ ContinentName + "/zone_light/water_shapes_lighted" ] huh? + +# Map lookup directories used by shape +MapLookupDirectories = [ ] +MapLookupDirectories += [ "common/sfx/map_export" ] +MapLookupDirectories += [ "common/sfx/map_uncompressed" ] +MapLookupDirectories += [ "common/construction/map_export" ] +MapLookupDirectories += [ "common/construction/map_uncompressed" ] +MapLookupDirectories += [ EcosystemPath + "/map_export" ] +MapLookupDirectories += [ EcosystemPath + "/map_uncompressed" ] +MapLookupDirectories += [ ContinentPath + "/map_export" ] +MapLookupDirectories += [ ContinentPath + "/map_uncompressed" ] + + +# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapExportDirectory = CommonPath + "/map_export" +MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" + +# Shape directories +ShapeTagExportDirectory = CommonPath + "/shape_tag" +ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" +ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" +ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" +ShapeAnimExportDirectory = CommonPath + "/shape_anim" + + +# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapBuildDirectory = CommonPath + "/map" +MapPanoplyBuildDirectory = CommonPath + "/map_panoply" +MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" +MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" +MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" +MapTagBuildDirectory = CommonPath + "/map_tag" + +# Shape directories +ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" +ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" +ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" +ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" + + +# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** + +# Map directory +MapInstallDirectory = CommonName + "_maps" +BitmapInstallDirectory = MapInstallDirectory + +# Shape directory +ShapeInstallDirectory = CommonName + "_shapes" + +# Shape lightmaps directory +LightmapInstallDirectory = ShapeInstallDirectory diff --git a/code/ryzom/tools/build_gamedata/workspace/continents/zorai/process.py b/code/ryzom/tools/build_gamedata/workspace/continents/zorai/process.py index c32cffd5a..1c2df1cc6 100644 --- a/code/ryzom/tools/build_gamedata/workspace/continents/zorai/process.py +++ b/code/ryzom/tools/build_gamedata/workspace/continents/zorai/process.py @@ -1,81 +1,81 @@ -#!/usr/bin/python -# -# \file config.py -# \brief Process configuration -# \date 2010-05-24 06:30GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Process configuration. -# -# NeL - 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 . -# - -# *** PROCESS CONFIGURATION *** - - -# *** PROCESS CONFIG *** -ProcessToComplete = [ ] -ProcessToComplete += [ "map" ] -ProcessToComplete += [ "shape" ] - - -# *** ECOSYSTEM AND CONTINENT NAMES *** - -EcosystemName = "jungle" -EcosystemPath = "ecosystems/" + EcosystemName -ContinentName = "zorai" -ContinentPath = "continents/" + ContinentName -CommonName = ContinentName -CommonPath = ContinentPath - - -# *** SHAPE EXPORT OPTIONS *** -# Compute lightmaps ? -ShapeExportOptExportLighting = "true" -# Cast shadow in lightmap ? -ShapeExportOptShadow = "true" -# Lighting limits. 0 : normal, 1 : soft shadows -ShapeExportOptLightingLimit = 0 -# Lightmap lumel size -ShapeExportOptLumelSize = "0.25" -# Oversampling value. Can be 1, 2, 4 or 8 -ShapeExportOptOversampling = 1 -# Does the lightmap must be generated in 8 bits format ? -ShapeExportOpt8BitsLightmap = "false" -# Does the lightmaps export must generate logs ? -ShapeExportOptLightmapLog = "true" -# Coarse mesh texture mul size -TextureMulSizeValue = "1.5" -DoBuildShadowSkin = 0 -ClodConfigFile = "" - -# *** COARSE MESH TEXTURE NAME *** -CoarseMeshTextureNames = [ ] - -# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** -MultipleTilesPostfix = [ ] -MultipleTilesPostfix += [ "_sp" ] -MultipleTilesPostfix += [ "_su" ] -MultipleTilesPostfix += [ "_au" ] -MultipleTilesPostfix += [ "_wi" ] - -# *** MAPS OPTIONS *** -ReduceBitmapFactor = 0 -# list all panoply files -MapPanoplyFileList = None -# name of the .hlsbank to build. -MapHlsBankFileName = None +#!/usr/bin/python +# +# \file config.py +# \brief Process configuration +# \date 2010-05-24 06:30GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Process configuration. +# +# NeL - 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 . +# + +# *** PROCESS CONFIGURATION *** + + +# *** PROCESS CONFIG *** +ProcessToComplete = [ ] +ProcessToComplete += [ "map" ] +ProcessToComplete += [ "shape" ] + + +# *** ECOSYSTEM AND CONTINENT NAMES *** + +EcosystemName = "jungle" +EcosystemPath = "ecosystems/" + EcosystemName +ContinentName = "zorai" +ContinentPath = "continents/" + ContinentName +CommonName = ContinentName +CommonPath = ContinentPath + + +# *** SHAPE EXPORT OPTIONS *** +# Compute lightmaps ? +ShapeExportOptExportLighting = "true" +# Cast shadow in lightmap ? +ShapeExportOptShadow = "true" +# Lighting limits. 0 : normal, 1 : soft shadows +ShapeExportOptLightingLimit = 0 +# Lightmap lumel size +ShapeExportOptLumelSize = "0.25" +# Oversampling value. Can be 1, 2, 4 or 8 +ShapeExportOptOversampling = 1 +# Does the lightmap must be generated in 8 bits format ? +ShapeExportOpt8BitsLightmap = "false" +# Does the lightmaps export must generate logs ? +ShapeExportOptLightmapLog = "true" +# Coarse mesh texture mul size +TextureMulSizeValue = "1.5" +DoBuildShadowSkin = 0 +ClodConfigFile = "" + +# *** COARSE MESH TEXTURE NAME *** +CoarseMeshTextureNames = [ ] + +# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** +MultipleTilesPostfix = [ ] +MultipleTilesPostfix += [ "_sp" ] +MultipleTilesPostfix += [ "_su" ] +MultipleTilesPostfix += [ "_au" ] +MultipleTilesPostfix += [ "_wi" ] + +# *** MAPS OPTIONS *** +ReduceBitmapFactor = 0 +# list all panoply files +MapPanoplyFileList = None +# name of the .hlsbank to build. +MapHlsBankFileName = None diff --git a/code/ryzom/tools/build_gamedata/workspace/ecosystems/desert/directories.py b/code/ryzom/tools/build_gamedata/workspace/ecosystems/desert/directories.py index b378249a2..e15b856f2 100644 --- a/code/ryzom/tools/build_gamedata/workspace/ecosystems/desert/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/ecosystems/desert/directories.py @@ -1,268 +1,268 @@ -#!/usr/bin/python -# -# ################################################################# -# ## WARNING : this is a generated file, don't change it ! -# ################################################################# -# -# \file directories.py -# \brief Directories configuration -# \date 2010-09-19-14-19-GMT -# \author Jan Boon (Kaetemi) -# \date 2001-2005 -# \author Nevrax -# Python port of game data build pipeline. -# Directories configuration for 'desert' ecosystem. -# -# NeL - 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 . -# - - -# *** ECOSYSTEM AND CONTINENT NAMES *** - -EcosystemName = "desert" -EcosystemPath = "ecosystems/" + EcosystemName -CommonName = EcosystemName -CommonPath = EcosystemPath - -DatabaseRootName = "fyros" -DatabaseRootPath = "stuff/" + DatabaseRootName - - -# *** SOURCE DIRECTORIES IN THE DATABASE *** - -# Shape directories -ShapeSourceDirectories = [ ] -ShapeSourceDirectories += [ DatabaseRootPath + "/decors/vegetations" ] -ShapeSourceDirectories += [ "landscape/ligo/" + EcosystemName + "/max" ] - -# Maps directories -MapSourceDirectories = [ ] -MapSourceDirectories += [ DatabaseRootPath + "/decors/_textures" ] -MapSourceDirectories += [ DatabaseRootPath + "/decors/_textures/vegetations" ] -MapSourceDirectories += [ "landscape/microveget/" + EcosystemName + "" ] -MapSourceDirectories += [ "landscape/water/meshes/" + EcosystemName + "" ] - -MapUncompressedSourceDirectories = [ ] - -# Tiles directories -TilesSourceDirectories = [ ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/1.5-marecage_profond" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/1-marecages" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/2-citees" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/3-fond_canyon" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/4.2-boisbandeclair" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/4.5-desert2boisbande" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/4-falaise_bois_bande" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/5-falaise_normales" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/6.5-desertalternatif" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/6-desert" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/7-routes" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/8-foretbrule" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/1.5-marecage_profond" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/1-marecages" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/2-citees" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/3-fond_canyon" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/4.2-boisbandeclair" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/4.5-desert2boisbande" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/4-falaise_bois_bande" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/5-falaise_normales" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/6.5-desertalternatif" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/6-desert" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/7-routes" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/8-foretbrule" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/1.5-marecage_profond" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/1-marecages" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/2-citees" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/3-fond_canyon" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/4.2-boisbandeclair" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/4.5-desert2boisbande" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/4-falaise_bois_bande" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/5-falaise_normales" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/6.5-desertalternatif" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/6-desert" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/7-routes" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/8-foretbrule" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/1.5-marecage_profond" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/1-marecages" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/2-citees" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/3-fond_canyon" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/4.2-boisbandeclair" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/4.5-desert2boisbande" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/4-falaise_bois_bande" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/5-falaise_normales" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/6.5-desertalternatif" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/6-desert" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/7-routes" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/8-foretbrule" ] - -# Tiles root directory -TileRootSourceDirectory = "landscape/_texture_tiles/" + EcosystemName - -# Displace directory -DisplaceSourceDirectory = "landscape/_texture_tiles/" + EcosystemName + "/displace" - -# Do not use, needs to be removed and fixed in processes -DisplaceSourceDirectories = [ ] -DisplaceSourceDirectories += [ DisplaceSourceDirectory ] - -# Bank directory -BankSourceDirectory = "landscape/_texture_tiles/" + EcosystemName - -# Vegetable set directories -VegetSetSourceDirectories = [ ] -VegetSetSourceDirectories += [ "landscape/microveget/" + EcosystemName ] - -# Veget directories -VegetSourceDirectories = [ ] -VegetSourceDirectories += [ "landscape/microveget/" + EcosystemName ] - -# Ligo directories -LigoBaseSourceDirectory = "landscape/ligo/" + EcosystemName -LigoMaxSourceDirectory = LigoBaseSourceDirectory + "/max" - -# Zone directories -ZoneSourceDirectory = [ "landscape/zones/" + EcosystemName ] # For old snowballs style landscape when not using ligo - -# Ig landscape directories -IgLandSourceDirectory = "_invalid" - -# Ig other directories -IgOtherSourceDirectory = "_invalid" - -# PACS primitives directories -PacsPrimSourceDirectories = [ ] -PacsPrimSourceDirectories += [ DatabaseRootPath + "/decors/vegetations" ] - - -# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) - -# Ig lookup directories used by rbank -IgLookupDirectories = [ ] - -# Shape lookup directories used by rbank -ShapeLookupDirectories = [ ] -ShapeLookupDirectories += [ EcosystemPath + "/shape_clodtex_build" ] -ShapeLookupDirectories += [ EcosystemPath + "/shape_with_coarse_mesh" ] - -# Map lookup directories not yet used -MapLookupDirectories = [ ] -MapLookupDirectories += [ EcosystemPath + "/map_export" ] -MapLookupDirectories += [ EcosystemPath + "/map_uncompressed" ] - - -# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapExportDirectory = CommonPath + "/map_export" -MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" - -# Shape directories -ShapeTagExportDirectory = CommonPath + "/shape_tag" -ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" -ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" -ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" -ShapeAnimExportDirectory = CommonPath + "/shape_anim" - -# Smallbank directories -SmallbankExportDirectory = CommonPath + "/smallbank" - -# Tiles directories -TilesExportDirectory = CommonPath + "/tiles" - -# Tiles directories -DisplaceExportDirectory = CommonPath + "/diplace" - -# Veget directories -VegetExportDirectory = CommonPath + "/veget" -VegetTagExportDirectory = CommonPath + "/veget_tag" - -# Veget Set directories -VegetSetExportDirectory = CommonPath + "/veget_set" - -# Ligo directories -LigoDatabaseExportDirectory = "landscape/ligo/" + EcosystemName -LigoDatabaseIgExportDirectory = LigoDatabaseExportDirectory + "/igs" -LigoDatabaseZoneExportDirectory = LigoDatabaseExportDirectory + "/zones" -LigoDatabaseZoneLigoExportDirectory = LigoDatabaseExportDirectory + "/zoneligos" -LigoDatabaseCmbExportDirectory = LigoDatabaseExportDirectory + "/cmb" -LigoTagExportDirectory = CommonPath + "/ligo_tag" - -# Zone directories -ZoneExportDirectory = CommonPath + "/zone" - -# PACS primitives directories -PacsPrimExportDirectory = CommonPath + "/pacs_prim" - - -# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapBuildDirectory = CommonPath + "/map" -MapPanoplyBuildDirectory = CommonPath + "/map_panoply" -MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" -MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" -MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" -MapTagBuildDirectory = CommonPath + "/map_tag" - -# Shape directories -ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" -ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" -ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" -ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" - -# Farbank directories -FarbankBuildDirectory = CommonPath + "/farbank" - -# Ig directories ************** TODO CONFIRM IN IG BUILD PROCESS ************ FIX RBANK IF NEEDED *********** -IgLandBuildDirectory = "_invalid" -IgOtherBuildDirectory = "_invalid" - -# Rbank directories -RbankOutputBuildDirectory = "_invalid" - -# Ligo directories - - -# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** - -# Map directory -MapInstallDirectory = CommonName + "_maps" -BitmapInstallDirectory = MapInstallDirectory - -# Shape directory -ShapeInstallDirectory = CommonName + "_shapes" - -# Lightmap directory -LightmapInstallDirectory = CommonName + "_lightmaps" - -# Tile directory -TilesInstallDirectory = CommonName + "_tiles" - -# Displace directory -DisplaceInstallDirectory = CommonName + "_displaces" - -# Bank directory -BankInstallDirectory = CommonName + "_bank" - -# Vegetable set directory -VegetSetInstallDirectory = CommonName + "_vegetable_sets" - -# Vegetable shape directory -VegetInstallDirectory = CommonName + "_vegetables" - -# PACS primitives directories -PacsPrimInstallDirectory = CommonName + "_pacs_prim" +#!/usr/bin/python +# +# ################################################################# +# ## WARNING : this is a generated file, don't change it ! +# ################################################################# +# +# \file directories.py +# \brief Directories configuration +# \date 2010-09-19-14-19-GMT +# \author Jan Boon (Kaetemi) +# \date 2001-2005 +# \author Nevrax +# Python port of game data build pipeline. +# Directories configuration for 'desert' ecosystem. +# +# NeL - 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 . +# + + +# *** ECOSYSTEM AND CONTINENT NAMES *** + +EcosystemName = "desert" +EcosystemPath = "ecosystems/" + EcosystemName +CommonName = EcosystemName +CommonPath = EcosystemPath + +DatabaseRootName = "fyros" +DatabaseRootPath = "stuff/" + DatabaseRootName + + +# *** SOURCE DIRECTORIES IN THE DATABASE *** + +# Shape directories +ShapeSourceDirectories = [ ] +ShapeSourceDirectories += [ DatabaseRootPath + "/decors/vegetations" ] +ShapeSourceDirectories += [ "landscape/ligo/" + EcosystemName + "/max" ] + +# Maps directories +MapSourceDirectories = [ ] +MapSourceDirectories += [ DatabaseRootPath + "/decors/_textures" ] +MapSourceDirectories += [ DatabaseRootPath + "/decors/_textures/vegetations" ] +MapSourceDirectories += [ "landscape/microveget/" + EcosystemName + "" ] +MapSourceDirectories += [ "landscape/water/meshes/" + EcosystemName + "" ] + +MapUncompressedSourceDirectories = [ ] + +# Tiles directories +TilesSourceDirectories = [ ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/1.5-marecage_profond" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/1-marecages" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/2-citees" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/3-fond_canyon" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/4.2-boisbandeclair" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/4.5-desert2boisbande" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/4-falaise_bois_bande" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/5-falaise_normales" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/6.5-desertalternatif" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/6-desert" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/7-routes" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/8-foretbrule" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/1.5-marecage_profond" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/1-marecages" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/2-citees" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/3-fond_canyon" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/4.2-boisbandeclair" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/4.5-desert2boisbande" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/4-falaise_bois_bande" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/5-falaise_normales" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/6.5-desertalternatif" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/6-desert" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/7-routes" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/8-foretbrule" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/1.5-marecage_profond" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/1-marecages" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/2-citees" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/3-fond_canyon" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/4.2-boisbandeclair" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/4.5-desert2boisbande" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/4-falaise_bois_bande" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/5-falaise_normales" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/6.5-desertalternatif" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/6-desert" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/7-routes" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/8-foretbrule" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/1.5-marecage_profond" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/1-marecages" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/2-citees" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/3-fond_canyon" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/4.2-boisbandeclair" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/4.5-desert2boisbande" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/4-falaise_bois_bande" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/5-falaise_normales" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/6.5-desertalternatif" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/6-desert" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/7-routes" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/8-foretbrule" ] + +# Tiles root directory +TileRootSourceDirectory = "landscape/_texture_tiles/" + EcosystemName + +# Displace directory +DisplaceSourceDirectory = "landscape/_texture_tiles/" + EcosystemName + "/displace" + +# Do not use, needs to be removed and fixed in processes +DisplaceSourceDirectories = [ ] +DisplaceSourceDirectories += [ DisplaceSourceDirectory ] + +# Bank directory +BankSourceDirectory = "landscape/_texture_tiles/" + EcosystemName + +# Vegetable set directories +VegetSetSourceDirectories = [ ] +VegetSetSourceDirectories += [ "landscape/microveget/" + EcosystemName ] + +# Veget directories +VegetSourceDirectories = [ ] +VegetSourceDirectories += [ "landscape/microveget/" + EcosystemName ] + +# Ligo directories +LigoBaseSourceDirectory = "landscape/ligo/" + EcosystemName +LigoMaxSourceDirectory = LigoBaseSourceDirectory + "/max" + +# Zone directories +ZoneSourceDirectory = [ "landscape/zones/" + EcosystemName ] # For old snowballs style landscape when not using ligo + +# Ig landscape directories +IgLandSourceDirectory = "_invalid" + +# Ig other directories +IgOtherSourceDirectory = "_invalid" + +# PACS primitives directories +PacsPrimSourceDirectories = [ ] +PacsPrimSourceDirectories += [ DatabaseRootPath + "/decors/vegetations" ] + + +# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) + +# Ig lookup directories used by rbank +IgLookupDirectories = [ ] + +# Shape lookup directories used by rbank +ShapeLookupDirectories = [ ] +ShapeLookupDirectories += [ EcosystemPath + "/shape_clodtex_build" ] +ShapeLookupDirectories += [ EcosystemPath + "/shape_with_coarse_mesh" ] + +# Map lookup directories not yet used +MapLookupDirectories = [ ] +MapLookupDirectories += [ EcosystemPath + "/map_export" ] +MapLookupDirectories += [ EcosystemPath + "/map_uncompressed" ] + + +# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapExportDirectory = CommonPath + "/map_export" +MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" + +# Shape directories +ShapeTagExportDirectory = CommonPath + "/shape_tag" +ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" +ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" +ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" +ShapeAnimExportDirectory = CommonPath + "/shape_anim" + +# Smallbank directories +SmallbankExportDirectory = CommonPath + "/smallbank" + +# Tiles directories +TilesExportDirectory = CommonPath + "/tiles" + +# Tiles directories +DisplaceExportDirectory = CommonPath + "/diplace" + +# Veget directories +VegetExportDirectory = CommonPath + "/veget" +VegetTagExportDirectory = CommonPath + "/veget_tag" + +# Veget Set directories +VegetSetExportDirectory = CommonPath + "/veget_set" + +# Ligo directories +LigoDatabaseExportDirectory = "landscape/ligo/" + EcosystemName +LigoDatabaseIgExportDirectory = LigoDatabaseExportDirectory + "/igs" +LigoDatabaseZoneExportDirectory = LigoDatabaseExportDirectory + "/zones" +LigoDatabaseZoneLigoExportDirectory = LigoDatabaseExportDirectory + "/zoneligos" +LigoDatabaseCmbExportDirectory = LigoDatabaseExportDirectory + "/cmb" +LigoTagExportDirectory = CommonPath + "/ligo_tag" + +# Zone directories +ZoneExportDirectory = CommonPath + "/zone" + +# PACS primitives directories +PacsPrimExportDirectory = CommonPath + "/pacs_prim" + + +# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapBuildDirectory = CommonPath + "/map" +MapPanoplyBuildDirectory = CommonPath + "/map_panoply" +MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" +MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" +MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" +MapTagBuildDirectory = CommonPath + "/map_tag" + +# Shape directories +ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" +ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" +ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" +ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" + +# Farbank directories +FarbankBuildDirectory = CommonPath + "/farbank" + +# Ig directories ************** TODO CONFIRM IN IG BUILD PROCESS ************ FIX RBANK IF NEEDED *********** +IgLandBuildDirectory = "_invalid" +IgOtherBuildDirectory = "_invalid" + +# Rbank directories +RbankOutputBuildDirectory = "_invalid" + +# Ligo directories + + +# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** + +# Map directory +MapInstallDirectory = CommonName + "_maps" +BitmapInstallDirectory = MapInstallDirectory + +# Shape directory +ShapeInstallDirectory = CommonName + "_shapes" + +# Lightmap directory +LightmapInstallDirectory = CommonName + "_lightmaps" + +# Tile directory +TilesInstallDirectory = CommonName + "_tiles" + +# Displace directory +DisplaceInstallDirectory = CommonName + "_displaces" + +# Bank directory +BankInstallDirectory = CommonName + "_bank" + +# Vegetable set directory +VegetSetInstallDirectory = CommonName + "_vegetable_sets" + +# Vegetable shape directory +VegetInstallDirectory = CommonName + "_vegetables" + +# PACS primitives directories +PacsPrimInstallDirectory = CommonName + "_pacs_prim" diff --git a/code/ryzom/tools/build_gamedata/workspace/ecosystems/desert/process.py b/code/ryzom/tools/build_gamedata/workspace/ecosystems/desert/process.py index 99c7d5d5b..316d4f58e 100644 --- a/code/ryzom/tools/build_gamedata/workspace/ecosystems/desert/process.py +++ b/code/ryzom/tools/build_gamedata/workspace/ecosystems/desert/process.py @@ -1,132 +1,132 @@ -#!/usr/bin/python -# -# ################################################################# -# ## WARNING : this is a generated file, don't change it ! -# ################################################################# -# -# \file config.py -# \brief Process configuration -# \date 2010-09-19-14-19-GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Process configuration for 'desert' ecosystem. -# -# NeL - 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 . -# - -# *** PROCESS CONFIGURATION *** - -# *** PROCESS CONFIG *** -ProcessToComplete = [ ] -ProcessToComplete += [ "shape" ] -ProcessToComplete += [ "map" ] -ProcessToComplete += [ "smallbank" ] -ProcessToComplete += [ "farbank" ] -ProcessToComplete += [ "tiles" ] -ProcessToComplete += [ "displace" ] -ProcessToComplete += [ "veget" ] -ProcessToComplete += [ "vegetset" ] -ProcessToComplete += [ "ligo" ] -ProcessToComplete += [ "pacs_prim" ] - - -# *** ECOSYSTEM AND CONTINENT NAMES *** - -EcosystemName = "desert" -EcosystemPath = "ecosystems/" + EcosystemName -CommonName = EcosystemName -CommonPath = EcosystemPath - - -# *** MAP EXPORT OPTIONS *** -PanoplyFileList = [ ] -HlsBankFileName = "" - -# *** SHAPE EXPORT OPTIONS *** - -# Compute lightmaps ? -ShapeExportOptExportLighting = "true" - -# Cast shadow in lightmap ? -ShapeExportOptShadow = "true" - -# Lighting limits. 0 : normal, 1 : soft shadows -ShapeExportOptLightingLimit = 1 - -# Lightmap lumel size -ShapeExportOptLumelSize = "0.25" - -# Oversampling value. Can be 1, 2, 4 or 8 -ShapeExportOptOversampling = 1 - -# Does the lightmap must be generated in 8 bits format ? -ShapeExportOpt8BitsLightmap = "true" - -# Does the lightmaps export must generate logs ? -ShapeExportOptLightmapLog = "true" - -# Coarse mesh texture mul size -TextureMulSizeValue = "1.5" - -DoBuildShadowSkin = 0 - -ClodConfigFile = "" - -# *** COARSE MESH TEXTURE NAME *** -CoarseMeshTextureNames = [ ] -CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_sp" ] -CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_su" ] -CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_au" ] -CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_wi" ] - -# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** -MultipleTilesPostfix = [ ] -MultipleTilesPostfix += [ "_sp" ] -MultipleTilesPostfix += [ "_su" ] -MultipleTilesPostfix += [ "_au" ] -MultipleTilesPostfix += [ "_wi" ] - -# *** BANK EXPORT OPTIONS *** - -# Name of the tilebank to use -BankTileBankName = EcosystemName - -# *** RBANK EXPORT OPTIONS *** - -# Output names -RbankRbankName = "_invalid" - -# *** LIGO OPTIONS *** - -LigoExportLand = "" -LigoExportOnePass = 0 - -# *** MAPS OPTIONS *** - -ReduceBitmapFactor = 0 -# list all panoply files -MapPanoplyFileList = None -# name of the .hlsbank to build. -MapHlsBankFileName = None - -# *** SHAPE BUILD OPTIONS * - -DoBuildShadowSkin = False -ClodConfigFile = "" - -# *** PACS_PRIM OPTIONS *** -WantLandscapeColPrimPacsList = True +#!/usr/bin/python +# +# ################################################################# +# ## WARNING : this is a generated file, don't change it ! +# ################################################################# +# +# \file config.py +# \brief Process configuration +# \date 2010-09-19-14-19-GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Process configuration for 'desert' ecosystem. +# +# NeL - 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 . +# + +# *** PROCESS CONFIGURATION *** + +# *** PROCESS CONFIG *** +ProcessToComplete = [ ] +ProcessToComplete += [ "shape" ] +ProcessToComplete += [ "map" ] +ProcessToComplete += [ "smallbank" ] +ProcessToComplete += [ "farbank" ] +ProcessToComplete += [ "tiles" ] +ProcessToComplete += [ "displace" ] +ProcessToComplete += [ "veget" ] +ProcessToComplete += [ "vegetset" ] +ProcessToComplete += [ "ligo" ] +ProcessToComplete += [ "pacs_prim" ] + + +# *** ECOSYSTEM AND CONTINENT NAMES *** + +EcosystemName = "desert" +EcosystemPath = "ecosystems/" + EcosystemName +CommonName = EcosystemName +CommonPath = EcosystemPath + + +# *** MAP EXPORT OPTIONS *** +PanoplyFileList = [ ] +HlsBankFileName = "" + +# *** SHAPE EXPORT OPTIONS *** + +# Compute lightmaps ? +ShapeExportOptExportLighting = "true" + +# Cast shadow in lightmap ? +ShapeExportOptShadow = "true" + +# Lighting limits. 0 : normal, 1 : soft shadows +ShapeExportOptLightingLimit = 1 + +# Lightmap lumel size +ShapeExportOptLumelSize = "0.25" + +# Oversampling value. Can be 1, 2, 4 or 8 +ShapeExportOptOversampling = 1 + +# Does the lightmap must be generated in 8 bits format ? +ShapeExportOpt8BitsLightmap = "true" + +# Does the lightmaps export must generate logs ? +ShapeExportOptLightmapLog = "true" + +# Coarse mesh texture mul size +TextureMulSizeValue = "1.5" + +DoBuildShadowSkin = 0 + +ClodConfigFile = "" + +# *** COARSE MESH TEXTURE NAME *** +CoarseMeshTextureNames = [ ] +CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_sp" ] +CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_su" ] +CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_au" ] +CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_wi" ] + +# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** +MultipleTilesPostfix = [ ] +MultipleTilesPostfix += [ "_sp" ] +MultipleTilesPostfix += [ "_su" ] +MultipleTilesPostfix += [ "_au" ] +MultipleTilesPostfix += [ "_wi" ] + +# *** BANK EXPORT OPTIONS *** + +# Name of the tilebank to use +BankTileBankName = EcosystemName + +# *** RBANK EXPORT OPTIONS *** + +# Output names +RbankRbankName = "_invalid" + +# *** LIGO OPTIONS *** + +LigoExportLand = "" +LigoExportOnePass = 0 + +# *** MAPS OPTIONS *** + +ReduceBitmapFactor = 0 +# list all panoply files +MapPanoplyFileList = None +# name of the .hlsbank to build. +MapHlsBankFileName = None + +# *** SHAPE BUILD OPTIONS * + +DoBuildShadowSkin = False +ClodConfigFile = "" + +# *** PACS_PRIM OPTIONS *** +WantLandscapeColPrimPacsList = True diff --git a/code/ryzom/tools/build_gamedata/workspace/ecosystems/jungle/directories.py b/code/ryzom/tools/build_gamedata/workspace/ecosystems/jungle/directories.py index f5bad0f9a..1ceface1c 100644 --- a/code/ryzom/tools/build_gamedata/workspace/ecosystems/jungle/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/ecosystems/jungle/directories.py @@ -1,272 +1,272 @@ -#!/usr/bin/python -# -# ################################################################# -# ## WARNING : this is a generated file, don't change it ! -# ################################################################# -# -# \file directories.py -# \brief Directories configuration -# \date 2010-09-19-14-19-GMT -# \author Jan Boon (Kaetemi) -# \date 2001-2005 -# \author Nevrax -# Python port of game data build pipeline. -# Directories configuration for 'jungle' ecosystem. -# -# NeL - 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 . -# - - -# *** ECOSYSTEM AND CONTINENT NAMES *** - -EcosystemName = "jungle" -EcosystemPath = "ecosystems/" + EcosystemName -CommonName = EcosystemName -CommonPath = EcosystemPath - -DatabaseRootName = "jungle" -DatabaseRootPath = "stuff/" + DatabaseRootName - - -# *** SOURCE DIRECTORIES IN THE DATABASE *** - -# Shape directories -ShapeSourceDirectories = [ ] -ShapeSourceDirectories += [ DatabaseRootPath + "/decors/vegetations" ] -ShapeSourceDirectories += [ "landscape/ligo/" + EcosystemName + "/max" ] - -# Maps directories -MapSourceDirectories = [ ] -MapSourceDirectories += [ DatabaseRootPath + "/decors/_textures" ] -MapSourceDirectories += [ DatabaseRootPath + "/decors/_textures/vegetations" ] -MapSourceDirectories += [ "landscape/microveget/" + EcosystemName + "" ] -MapSourceDirectories += [ "landscape/water/meshes/" + EcosystemName + "" ] - -MapUncompressedSourceDirectories = [ ] - -# Tiles directories -TilesSourceDirectories = [ ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/10-crevassejungle" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/11-paroisjungle" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/12-vasejungle" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/1-junglemousse" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/2-junglefeuilles" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/3-jungleherbesseche" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/4-jungleherbevieille" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/5-jungleterreaux" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/6-junglegoo" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/7-sciurejungle" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/8-terrejungle" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/9-falaisejungle" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/Transitions" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/10-crevassejungle" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/11-paroisjungle" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/12-vasejungle" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/1-junglemousse" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/2-junglefeuilles" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/3-jungleherbesseche" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/4-jungleherbevieille" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/5-jungleterreaux" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/6-junglegoo" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/7-sciurejungle" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/8-terrejungle" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/9-falaisejungle" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/Transitions" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/10-crevassejungle" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/11-paroisjungle" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/12-vasejungle" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/1-junglemousse" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/2-junglefeuilles" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/3-jungleherbesseche" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/4-jungleherbevieille" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/5-jungleterreaux" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/6-junglegoo" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/7-sciurejungle" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/8-terrejungle" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/9-falaisejungle" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/Transitions" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/10-crevassejungle" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/11-paroisjungle" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/12-vasejungle" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/1-junglemousse" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/2-junglefeuilles" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/3-jungleherbesseche" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/4-jungleherbevieille" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/5-jungleterreaux" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/6-junglegoo" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/7-sciurejungle" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/8-terrejungle" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/9-falaisejungle" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/Transitions" ] - -# Tiles root directory -TileRootSourceDirectory = "landscape/_texture_tiles/" + EcosystemName - -# Displace directory -DisplaceSourceDirectory = "landscape/_texture_tiles/" + EcosystemName + "/displace" - -# Do not use, needs to be removed and fixed in processes -DisplaceSourceDirectories = [ ] -DisplaceSourceDirectories += [ DisplaceSourceDirectory ] - -# Bank directory -BankSourceDirectory = "landscape/_texture_tiles/" + EcosystemName - -# Vegetable set directories -VegetSetSourceDirectories = [ ] -VegetSetSourceDirectories += [ "landscape/microveget/" + EcosystemName ] - -# Veget directories -VegetSourceDirectories = [ ] -VegetSourceDirectories += [ "landscape/microveget/" + EcosystemName ] - -# Ligo directories -LigoBaseSourceDirectory = "landscape/ligo/" + EcosystemName -LigoMaxSourceDirectory = LigoBaseSourceDirectory + "/max" - -# Zone directories -ZoneSourceDirectory = [ "landscape/zones/" + EcosystemName ] # For old snowballs style landscape when not using ligo - -# Ig landscape directories -IgLandSourceDirectory = "_invalid" - -# Ig other directories -IgOtherSourceDirectory = "_invalid" - -# PACS primitives directories -PacsPrimSourceDirectories = [ ] -PacsPrimSourceDirectories += [ DatabaseRootPath + "/decors/vegetations" ] - - -# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) - -# Ig lookup directories used by rbank -IgLookupDirectories = [ ] - -# Shape lookup directories used by rbank -ShapeLookupDirectories = [ ] -ShapeLookupDirectories += [ EcosystemPath + "/shape_clodtex_build" ] -ShapeLookupDirectories += [ EcosystemPath + "/shape_with_coarse_mesh" ] - -# Map lookup directories not yet used -MapLookupDirectories = [ ] -MapLookupDirectories += [ EcosystemPath + "/map_export" ] -MapLookupDirectories += [ EcosystemPath + "/map_uncompressed" ] - - -# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapExportDirectory = CommonPath + "/map_export" -MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" - -# Shape directories -ShapeTagExportDirectory = CommonPath + "/shape_tag" -ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" -ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" -ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" -ShapeAnimExportDirectory = CommonPath + "/shape_anim" - -# Smallbank directories -SmallbankExportDirectory = CommonPath + "/smallbank" - -# Tiles directories -TilesExportDirectory = CommonPath + "/tiles" - -# Tiles directories -DisplaceExportDirectory = CommonPath + "/diplace" - -# Veget directories -VegetExportDirectory = CommonPath + "/veget" -VegetTagExportDirectory = CommonPath + "/veget_tag" - -# Veget Set directories -VegetSetExportDirectory = CommonPath + "/veget_set" - -# Ligo directories -LigoDatabaseExportDirectory = "landscape/ligo/" + EcosystemName -LigoDatabaseIgExportDirectory = LigoDatabaseExportDirectory + "/igs" -LigoDatabaseZoneExportDirectory = LigoDatabaseExportDirectory + "/zones" -LigoDatabaseZoneLigoExportDirectory = LigoDatabaseExportDirectory + "/zoneligos" -LigoDatabaseCmbExportDirectory = LigoDatabaseExportDirectory + "/cmb" -LigoTagExportDirectory = CommonPath + "/ligo_tag" - -# Zone directories -ZoneExportDirectory = CommonPath + "/zone" - -# PACS primitives directories -PacsPrimExportDirectory = CommonPath + "/pacs_prim" - - -# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapBuildDirectory = CommonPath + "/map" -MapPanoplyBuildDirectory = CommonPath + "/map_panoply" -MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" -MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" -MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" -MapTagBuildDirectory = CommonPath + "/map_tag" - -# Shape directories -ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" -ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" -ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" -ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" - -# Farbank directories -FarbankBuildDirectory = CommonPath + "/farbank" - -# Ig directories ************** TODO CONFIRM IN IG BUILD PROCESS ************ FIX RBANK IF NEEDED *********** -IgLandBuildDirectory = "_invalid" -IgOtherBuildDirectory = "_invalid" - -# Rbank directories -RbankOutputBuildDirectory = "_invalid" - -# Ligo directories - - -# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** - -# Map directory -MapInstallDirectory = CommonName + "_maps" -BitmapInstallDirectory = MapInstallDirectory - -# Shape directory -ShapeInstallDirectory = CommonName + "_shapes" - -# Lightmap directory -LightmapInstallDirectory = CommonName + "_lightmaps" - -# Tile directory -TilesInstallDirectory = CommonName + "_tiles" - -# Displace directory -DisplaceInstallDirectory = CommonName + "_displaces" - -# Bank directory -BankInstallDirectory = CommonName + "_bank" - -# Vegetable set directory -VegetSetInstallDirectory = CommonName + "_vegetable_sets" - -# Vegetable shape directory -VegetInstallDirectory = CommonName + "_vegetables" - -# PACS primitives directories -PacsPrimInstallDirectory = CommonName + "_pacs_prim" +#!/usr/bin/python +# +# ################################################################# +# ## WARNING : this is a generated file, don't change it ! +# ################################################################# +# +# \file directories.py +# \brief Directories configuration +# \date 2010-09-19-14-19-GMT +# \author Jan Boon (Kaetemi) +# \date 2001-2005 +# \author Nevrax +# Python port of game data build pipeline. +# Directories configuration for 'jungle' ecosystem. +# +# NeL - 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 . +# + + +# *** ECOSYSTEM AND CONTINENT NAMES *** + +EcosystemName = "jungle" +EcosystemPath = "ecosystems/" + EcosystemName +CommonName = EcosystemName +CommonPath = EcosystemPath + +DatabaseRootName = "jungle" +DatabaseRootPath = "stuff/" + DatabaseRootName + + +# *** SOURCE DIRECTORIES IN THE DATABASE *** + +# Shape directories +ShapeSourceDirectories = [ ] +ShapeSourceDirectories += [ DatabaseRootPath + "/decors/vegetations" ] +ShapeSourceDirectories += [ "landscape/ligo/" + EcosystemName + "/max" ] + +# Maps directories +MapSourceDirectories = [ ] +MapSourceDirectories += [ DatabaseRootPath + "/decors/_textures" ] +MapSourceDirectories += [ DatabaseRootPath + "/decors/_textures/vegetations" ] +MapSourceDirectories += [ "landscape/microveget/" + EcosystemName + "" ] +MapSourceDirectories += [ "landscape/water/meshes/" + EcosystemName + "" ] + +MapUncompressedSourceDirectories = [ ] + +# Tiles directories +TilesSourceDirectories = [ ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/10-crevassejungle" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/11-paroisjungle" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/12-vasejungle" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/1-junglemousse" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/2-junglefeuilles" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/3-jungleherbesseche" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/4-jungleherbevieille" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/5-jungleterreaux" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/6-junglegoo" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/7-sciurejungle" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/8-terrejungle" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/9-falaisejungle" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/Transitions" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/10-crevassejungle" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/11-paroisjungle" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/12-vasejungle" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/1-junglemousse" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/2-junglefeuilles" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/3-jungleherbesseche" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/4-jungleherbevieille" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/5-jungleterreaux" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/6-junglegoo" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/7-sciurejungle" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/8-terrejungle" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/9-falaisejungle" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/Transitions" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/10-crevassejungle" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/11-paroisjungle" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/12-vasejungle" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/1-junglemousse" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/2-junglefeuilles" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/3-jungleherbesseche" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/4-jungleherbevieille" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/5-jungleterreaux" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/6-junglegoo" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/7-sciurejungle" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/8-terrejungle" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/9-falaisejungle" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/Transitions" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/10-crevassejungle" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/11-paroisjungle" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/12-vasejungle" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/1-junglemousse" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/2-junglefeuilles" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/3-jungleherbesseche" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/4-jungleherbevieille" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/5-jungleterreaux" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/6-junglegoo" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/7-sciurejungle" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/8-terrejungle" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/9-falaisejungle" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/Transitions" ] + +# Tiles root directory +TileRootSourceDirectory = "landscape/_texture_tiles/" + EcosystemName + +# Displace directory +DisplaceSourceDirectory = "landscape/_texture_tiles/" + EcosystemName + "/displace" + +# Do not use, needs to be removed and fixed in processes +DisplaceSourceDirectories = [ ] +DisplaceSourceDirectories += [ DisplaceSourceDirectory ] + +# Bank directory +BankSourceDirectory = "landscape/_texture_tiles/" + EcosystemName + +# Vegetable set directories +VegetSetSourceDirectories = [ ] +VegetSetSourceDirectories += [ "landscape/microveget/" + EcosystemName ] + +# Veget directories +VegetSourceDirectories = [ ] +VegetSourceDirectories += [ "landscape/microveget/" + EcosystemName ] + +# Ligo directories +LigoBaseSourceDirectory = "landscape/ligo/" + EcosystemName +LigoMaxSourceDirectory = LigoBaseSourceDirectory + "/max" + +# Zone directories +ZoneSourceDirectory = [ "landscape/zones/" + EcosystemName ] # For old snowballs style landscape when not using ligo + +# Ig landscape directories +IgLandSourceDirectory = "_invalid" + +# Ig other directories +IgOtherSourceDirectory = "_invalid" + +# PACS primitives directories +PacsPrimSourceDirectories = [ ] +PacsPrimSourceDirectories += [ DatabaseRootPath + "/decors/vegetations" ] + + +# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) + +# Ig lookup directories used by rbank +IgLookupDirectories = [ ] + +# Shape lookup directories used by rbank +ShapeLookupDirectories = [ ] +ShapeLookupDirectories += [ EcosystemPath + "/shape_clodtex_build" ] +ShapeLookupDirectories += [ EcosystemPath + "/shape_with_coarse_mesh" ] + +# Map lookup directories not yet used +MapLookupDirectories = [ ] +MapLookupDirectories += [ EcosystemPath + "/map_export" ] +MapLookupDirectories += [ EcosystemPath + "/map_uncompressed" ] + + +# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapExportDirectory = CommonPath + "/map_export" +MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" + +# Shape directories +ShapeTagExportDirectory = CommonPath + "/shape_tag" +ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" +ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" +ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" +ShapeAnimExportDirectory = CommonPath + "/shape_anim" + +# Smallbank directories +SmallbankExportDirectory = CommonPath + "/smallbank" + +# Tiles directories +TilesExportDirectory = CommonPath + "/tiles" + +# Tiles directories +DisplaceExportDirectory = CommonPath + "/diplace" + +# Veget directories +VegetExportDirectory = CommonPath + "/veget" +VegetTagExportDirectory = CommonPath + "/veget_tag" + +# Veget Set directories +VegetSetExportDirectory = CommonPath + "/veget_set" + +# Ligo directories +LigoDatabaseExportDirectory = "landscape/ligo/" + EcosystemName +LigoDatabaseIgExportDirectory = LigoDatabaseExportDirectory + "/igs" +LigoDatabaseZoneExportDirectory = LigoDatabaseExportDirectory + "/zones" +LigoDatabaseZoneLigoExportDirectory = LigoDatabaseExportDirectory + "/zoneligos" +LigoDatabaseCmbExportDirectory = LigoDatabaseExportDirectory + "/cmb" +LigoTagExportDirectory = CommonPath + "/ligo_tag" + +# Zone directories +ZoneExportDirectory = CommonPath + "/zone" + +# PACS primitives directories +PacsPrimExportDirectory = CommonPath + "/pacs_prim" + + +# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapBuildDirectory = CommonPath + "/map" +MapPanoplyBuildDirectory = CommonPath + "/map_panoply" +MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" +MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" +MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" +MapTagBuildDirectory = CommonPath + "/map_tag" + +# Shape directories +ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" +ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" +ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" +ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" + +# Farbank directories +FarbankBuildDirectory = CommonPath + "/farbank" + +# Ig directories ************** TODO CONFIRM IN IG BUILD PROCESS ************ FIX RBANK IF NEEDED *********** +IgLandBuildDirectory = "_invalid" +IgOtherBuildDirectory = "_invalid" + +# Rbank directories +RbankOutputBuildDirectory = "_invalid" + +# Ligo directories + + +# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** + +# Map directory +MapInstallDirectory = CommonName + "_maps" +BitmapInstallDirectory = MapInstallDirectory + +# Shape directory +ShapeInstallDirectory = CommonName + "_shapes" + +# Lightmap directory +LightmapInstallDirectory = CommonName + "_lightmaps" + +# Tile directory +TilesInstallDirectory = CommonName + "_tiles" + +# Displace directory +DisplaceInstallDirectory = CommonName + "_displaces" + +# Bank directory +BankInstallDirectory = CommonName + "_bank" + +# Vegetable set directory +VegetSetInstallDirectory = CommonName + "_vegetable_sets" + +# Vegetable shape directory +VegetInstallDirectory = CommonName + "_vegetables" + +# PACS primitives directories +PacsPrimInstallDirectory = CommonName + "_pacs_prim" diff --git a/code/ryzom/tools/build_gamedata/workspace/ecosystems/jungle/process.py b/code/ryzom/tools/build_gamedata/workspace/ecosystems/jungle/process.py index 5bdc3b982..1e3e6c677 100644 --- a/code/ryzom/tools/build_gamedata/workspace/ecosystems/jungle/process.py +++ b/code/ryzom/tools/build_gamedata/workspace/ecosystems/jungle/process.py @@ -1,132 +1,132 @@ -#!/usr/bin/python -# -# ################################################################# -# ## WARNING : this is a generated file, don't change it ! -# ################################################################# -# -# \file config.py -# \brief Process configuration -# \date 2010-09-19-14-19-GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Process configuration for 'jungle' ecosystem. -# -# NeL - 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 . -# - -# *** PROCESS CONFIGURATION *** - -# *** PROCESS CONFIG *** -ProcessToComplete = [ ] -ProcessToComplete += [ "shape" ] -ProcessToComplete += [ "map" ] -ProcessToComplete += [ "smallbank" ] -ProcessToComplete += [ "farbank" ] -ProcessToComplete += [ "tiles" ] -ProcessToComplete += [ "displace" ] -ProcessToComplete += [ "veget" ] -ProcessToComplete += [ "vegetset" ] -ProcessToComplete += [ "ligo" ] -ProcessToComplete += [ "pacs_prim" ] - - -# *** ECOSYSTEM AND CONTINENT NAMES *** - -EcosystemName = "jungle" -EcosystemPath = "ecosystems/" + EcosystemName -CommonName = EcosystemName -CommonPath = EcosystemPath - - -# *** MAP EXPORT OPTIONS *** -PanoplyFileList = [ ] -HlsBankFileName = "" - -# *** SHAPE EXPORT OPTIONS *** - -# Compute lightmaps ? -ShapeExportOptExportLighting = "true" - -# Cast shadow in lightmap ? -ShapeExportOptShadow = "true" - -# Lighting limits. 0 : normal, 1 : soft shadows -ShapeExportOptLightingLimit = 1 - -# Lightmap lumel size -ShapeExportOptLumelSize = "0.25" - -# Oversampling value. Can be 1, 2, 4 or 8 -ShapeExportOptOversampling = 1 - -# Does the lightmap must be generated in 8 bits format ? -ShapeExportOpt8BitsLightmap = "false" - -# Does the lightmaps export must generate logs ? -ShapeExportOptLightmapLog = "true" - -# Coarse mesh texture mul size -TextureMulSizeValue = "1.5" - -DoBuildShadowSkin = 0 - -ClodConfigFile = "" - -# *** COARSE MESH TEXTURE NAME *** -CoarseMeshTextureNames = [ ] -CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_sp" ] -CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_su" ] -CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_au" ] -CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_wi" ] - -# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** -MultipleTilesPostfix = [ ] -MultipleTilesPostfix += [ "_sp" ] -MultipleTilesPostfix += [ "_su" ] -MultipleTilesPostfix += [ "_au" ] -MultipleTilesPostfix += [ "_wi" ] - -# *** BANK EXPORT OPTIONS *** - -# Name of the tilebank to use -BankTileBankName = EcosystemName - -# *** RBANK EXPORT OPTIONS *** - -# Output names -RbankRbankName = "_invalid" - -# *** LIGO OPTIONS *** - -LigoExportLand = "" -LigoExportOnePass = 0 - -# *** MAPS OPTIONS *** - -ReduceBitmapFactor = 0 -# list all panoply files -MapPanoplyFileList = None -# name of the .hlsbank to build. -MapHlsBankFileName = None - -# *** SHAPE BUILD OPTIONS * - -DoBuildShadowSkin = False -ClodConfigFile = "" - -# *** PACS_PRIM OPTIONS *** -WantLandscapeColPrimPacsList = True +#!/usr/bin/python +# +# ################################################################# +# ## WARNING : this is a generated file, don't change it ! +# ################################################################# +# +# \file config.py +# \brief Process configuration +# \date 2010-09-19-14-19-GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Process configuration for 'jungle' ecosystem. +# +# NeL - 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 . +# + +# *** PROCESS CONFIGURATION *** + +# *** PROCESS CONFIG *** +ProcessToComplete = [ ] +ProcessToComplete += [ "shape" ] +ProcessToComplete += [ "map" ] +ProcessToComplete += [ "smallbank" ] +ProcessToComplete += [ "farbank" ] +ProcessToComplete += [ "tiles" ] +ProcessToComplete += [ "displace" ] +ProcessToComplete += [ "veget" ] +ProcessToComplete += [ "vegetset" ] +ProcessToComplete += [ "ligo" ] +ProcessToComplete += [ "pacs_prim" ] + + +# *** ECOSYSTEM AND CONTINENT NAMES *** + +EcosystemName = "jungle" +EcosystemPath = "ecosystems/" + EcosystemName +CommonName = EcosystemName +CommonPath = EcosystemPath + + +# *** MAP EXPORT OPTIONS *** +PanoplyFileList = [ ] +HlsBankFileName = "" + +# *** SHAPE EXPORT OPTIONS *** + +# Compute lightmaps ? +ShapeExportOptExportLighting = "true" + +# Cast shadow in lightmap ? +ShapeExportOptShadow = "true" + +# Lighting limits. 0 : normal, 1 : soft shadows +ShapeExportOptLightingLimit = 1 + +# Lightmap lumel size +ShapeExportOptLumelSize = "0.25" + +# Oversampling value. Can be 1, 2, 4 or 8 +ShapeExportOptOversampling = 1 + +# Does the lightmap must be generated in 8 bits format ? +ShapeExportOpt8BitsLightmap = "false" + +# Does the lightmaps export must generate logs ? +ShapeExportOptLightmapLog = "true" + +# Coarse mesh texture mul size +TextureMulSizeValue = "1.5" + +DoBuildShadowSkin = 0 + +ClodConfigFile = "" + +# *** COARSE MESH TEXTURE NAME *** +CoarseMeshTextureNames = [ ] +CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_sp" ] +CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_su" ] +CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_au" ] +CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_wi" ] + +# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** +MultipleTilesPostfix = [ ] +MultipleTilesPostfix += [ "_sp" ] +MultipleTilesPostfix += [ "_su" ] +MultipleTilesPostfix += [ "_au" ] +MultipleTilesPostfix += [ "_wi" ] + +# *** BANK EXPORT OPTIONS *** + +# Name of the tilebank to use +BankTileBankName = EcosystemName + +# *** RBANK EXPORT OPTIONS *** + +# Output names +RbankRbankName = "_invalid" + +# *** LIGO OPTIONS *** + +LigoExportLand = "" +LigoExportOnePass = 0 + +# *** MAPS OPTIONS *** + +ReduceBitmapFactor = 0 +# list all panoply files +MapPanoplyFileList = None +# name of the .hlsbank to build. +MapHlsBankFileName = None + +# *** SHAPE BUILD OPTIONS * + +DoBuildShadowSkin = False +ClodConfigFile = "" + +# *** PACS_PRIM OPTIONS *** +WantLandscapeColPrimPacsList = True diff --git a/code/ryzom/tools/build_gamedata/workspace/ecosystems/lacustre/directories.py b/code/ryzom/tools/build_gamedata/workspace/ecosystems/lacustre/directories.py index d1f388c66..af2e15e29 100644 --- a/code/ryzom/tools/build_gamedata/workspace/ecosystems/lacustre/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/ecosystems/lacustre/directories.py @@ -1,280 +1,280 @@ -#!/usr/bin/python -# -# ################################################################# -# ## WARNING : this is a generated file, don't change it ! -# ################################################################# -# -# \file directories.py -# \brief Directories configuration -# \date 2010-09-19-14-19-GMT -# \author Jan Boon (Kaetemi) -# \date 2001-2005 -# \author Nevrax -# Python port of game data build pipeline. -# Directories configuration for 'lacustre' ecosystem. -# -# NeL - 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 . -# - - -# *** ECOSYSTEM AND CONTINENT NAMES *** - -EcosystemName = "lacustre" -EcosystemPath = "ecosystems/" + EcosystemName -CommonName = EcosystemName -CommonPath = EcosystemPath - -DatabaseRootName = "tryker" -DatabaseRootPath = "stuff/" + DatabaseRootName - - -# *** SOURCE DIRECTORIES IN THE DATABASE *** - -# Shape directories -ShapeSourceDirectories = [ ] -ShapeSourceDirectories += [ DatabaseRootPath + "/decors/vegetations" ] -ShapeSourceDirectories += [ "landscape/ligo/" + EcosystemName + "/max" ] - -# Maps directories -MapSourceDirectories = [ ] -MapSourceDirectories += [ DatabaseRootPath + "/decors/_textures" ] -MapSourceDirectories += [ DatabaseRootPath + "/decors/_textures/vegetations" ] -MapSourceDirectories += [ "landscape/microveget/" + EcosystemName + "" ] -MapSourceDirectories += [ "landscape/water/meshes/" + EcosystemName + "" ] - -MapUncompressedSourceDirectories = [ ] - -# Tiles directories -TilesSourceDirectories = [ ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/1a-sable-marin" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/1-plages" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/2-iles" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/2-ilesa" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/2-iles-marines" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/3-fondmarin2plage" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/4-marecages" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/5-marecages" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/5-parois-marine" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/6-fond_marin" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/7-bassesiles" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/7-mousseter" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/7-racines" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/8-mousse_marine" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/constructible" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/1a-sable-marin" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/1-plages" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/2-iles" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/2-ilesa" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/2-iles-marines" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/3-fondmarin2plage" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/4-marecages" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/5-marecages" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/5-parois-marine" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/6-fond_marin" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/7-bassesiles" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/7-mousseter" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/7-racines" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/8-mousse_marine" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/constructible" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/1a-sable-marin" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/1-plages" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/2-iles" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/2-ilesa" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/2-iles-marines" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/3-fondmarin2plage" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/4-marecages" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/5-marecages" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/5-parois-marine" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/6-fond_marin" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/7-bassesiles" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/7-mousseter" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/7-racines" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/8-mousse_marine" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/constructible" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/1a-sable-marin" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/1-plages" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/2-iles" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/2-ilesa" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/2-iles-marines" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/3-fondmarin2plage" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/4-marecages" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/5-marecages" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/5-parois-marine" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/6-fond_marin" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/7-bassesiles" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/7-mousseter" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/7-racines" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/8-mousse_marine" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/constructible" ] - -# Tiles root directory -TileRootSourceDirectory = "landscape/_texture_tiles/" + EcosystemName - -# Displace directory -DisplaceSourceDirectory = "landscape/_texture_tiles/" + EcosystemName + "/displace" - -# Do not use, needs to be removed and fixed in processes -DisplaceSourceDirectories = [ ] -DisplaceSourceDirectories += [ DisplaceSourceDirectory ] - -# Bank directory -BankSourceDirectory = "landscape/_texture_tiles/" + EcosystemName - -# Vegetable set directories -VegetSetSourceDirectories = [ ] -VegetSetSourceDirectories += [ "landscape/microveget/" + EcosystemName ] - -# Veget directories -VegetSourceDirectories = [ ] -VegetSourceDirectories += [ "landscape/microveget/" + EcosystemName ] - -# Ligo directories -LigoBaseSourceDirectory = "landscape/ligo/" + EcosystemName -LigoMaxSourceDirectory = LigoBaseSourceDirectory + "/max" - -# Zone directories -ZoneSourceDirectory = [ "landscape/zones/" + EcosystemName ] # For old snowballs style landscape when not using ligo - -# Ig landscape directories -IgLandSourceDirectory = "_invalid" - -# Ig other directories -IgOtherSourceDirectory = "_invalid" - -# PACS primitives directories -PacsPrimSourceDirectories = [ ] -PacsPrimSourceDirectories += [ DatabaseRootPath + "/decors/vegetations" ] - - -# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) - -# Ig lookup directories used by rbank -IgLookupDirectories = [ ] - -# Shape lookup directories used by rbank -ShapeLookupDirectories = [ ] -ShapeLookupDirectories += [ EcosystemPath + "/shape_clodtex_build" ] -ShapeLookupDirectories += [ EcosystemPath + "/shape_with_coarse_mesh" ] - -# Map lookup directories not yet used -MapLookupDirectories = [ ] -MapLookupDirectories += [ EcosystemPath + "/map_export" ] -MapLookupDirectories += [ EcosystemPath + "/map_uncompressed" ] - - -# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapExportDirectory = CommonPath + "/map_export" -MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" - -# Shape directories -ShapeTagExportDirectory = CommonPath + "/shape_tag" -ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" -ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" -ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" -ShapeAnimExportDirectory = CommonPath + "/shape_anim" - -# Smallbank directories -SmallbankExportDirectory = CommonPath + "/smallbank" - -# Tiles directories -TilesExportDirectory = CommonPath + "/tiles" - -# Tiles directories -DisplaceExportDirectory = CommonPath + "/diplace" - -# Veget directories -VegetExportDirectory = CommonPath + "/veget" -VegetTagExportDirectory = CommonPath + "/veget_tag" - -# Veget Set directories -VegetSetExportDirectory = CommonPath + "/veget_set" - -# Ligo directories -LigoDatabaseExportDirectory = "landscape/ligo/" + EcosystemName -LigoDatabaseIgExportDirectory = LigoDatabaseExportDirectory + "/igs" -LigoDatabaseZoneExportDirectory = LigoDatabaseExportDirectory + "/zones" -LigoDatabaseZoneLigoExportDirectory = LigoDatabaseExportDirectory + "/zoneligos" -LigoDatabaseCmbExportDirectory = LigoDatabaseExportDirectory + "/cmb" -LigoTagExportDirectory = CommonPath + "/ligo_tag" - -# Zone directories -ZoneExportDirectory = CommonPath + "/zone" - -# PACS primitives directories -PacsPrimExportDirectory = CommonPath + "/pacs_prim" - - -# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapBuildDirectory = CommonPath + "/map" -MapPanoplyBuildDirectory = CommonPath + "/map_panoply" -MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" -MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" -MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" -MapTagBuildDirectory = CommonPath + "/map_tag" - -# Shape directories -ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" -ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" -ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" -ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" - -# Farbank directories -FarbankBuildDirectory = CommonPath + "/farbank" - -# Ig directories ************** TODO CONFIRM IN IG BUILD PROCESS ************ FIX RBANK IF NEEDED *********** -IgLandBuildDirectory = "_invalid" -IgOtherBuildDirectory = "_invalid" - -# Rbank directories -RbankOutputBuildDirectory = "_invalid" - -# Ligo directories - - -# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** - -# Map directory -MapInstallDirectory = CommonName + "_maps" -BitmapInstallDirectory = MapInstallDirectory - -# Shape directory -ShapeInstallDirectory = CommonName + "_shapes" - -# Lightmap directory -LightmapInstallDirectory = CommonName + "_lightmaps" - -# Tile directory -TilesInstallDirectory = CommonName + "_tiles" - -# Displace directory -DisplaceInstallDirectory = CommonName + "_displaces" - -# Bank directory -BankInstallDirectory = CommonName + "_bank" - -# Vegetable set directory -VegetSetInstallDirectory = CommonName + "_vegetable_sets" - -# Vegetable shape directory -VegetInstallDirectory = CommonName + "_vegetables" - -# PACS primitives directories -PacsPrimInstallDirectory = CommonName + "_pacs_prim" +#!/usr/bin/python +# +# ################################################################# +# ## WARNING : this is a generated file, don't change it ! +# ################################################################# +# +# \file directories.py +# \brief Directories configuration +# \date 2010-09-19-14-19-GMT +# \author Jan Boon (Kaetemi) +# \date 2001-2005 +# \author Nevrax +# Python port of game data build pipeline. +# Directories configuration for 'lacustre' ecosystem. +# +# NeL - 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 . +# + + +# *** ECOSYSTEM AND CONTINENT NAMES *** + +EcosystemName = "lacustre" +EcosystemPath = "ecosystems/" + EcosystemName +CommonName = EcosystemName +CommonPath = EcosystemPath + +DatabaseRootName = "tryker" +DatabaseRootPath = "stuff/" + DatabaseRootName + + +# *** SOURCE DIRECTORIES IN THE DATABASE *** + +# Shape directories +ShapeSourceDirectories = [ ] +ShapeSourceDirectories += [ DatabaseRootPath + "/decors/vegetations" ] +ShapeSourceDirectories += [ "landscape/ligo/" + EcosystemName + "/max" ] + +# Maps directories +MapSourceDirectories = [ ] +MapSourceDirectories += [ DatabaseRootPath + "/decors/_textures" ] +MapSourceDirectories += [ DatabaseRootPath + "/decors/_textures/vegetations" ] +MapSourceDirectories += [ "landscape/microveget/" + EcosystemName + "" ] +MapSourceDirectories += [ "landscape/water/meshes/" + EcosystemName + "" ] + +MapUncompressedSourceDirectories = [ ] + +# Tiles directories +TilesSourceDirectories = [ ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/1a-sable-marin" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/1-plages" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/2-iles" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/2-ilesa" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/2-iles-marines" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/3-fondmarin2plage" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/4-marecages" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/5-marecages" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/5-parois-marine" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/6-fond_marin" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/7-bassesiles" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/7-mousseter" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/7-racines" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/8-mousse_marine" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/constructible" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/1a-sable-marin" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/1-plages" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/2-iles" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/2-ilesa" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/2-iles-marines" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/3-fondmarin2plage" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/4-marecages" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/5-marecages" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/5-parois-marine" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/6-fond_marin" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/7-bassesiles" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/7-mousseter" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/7-racines" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/8-mousse_marine" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/constructible" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/1a-sable-marin" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/1-plages" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/2-iles" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/2-ilesa" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/2-iles-marines" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/3-fondmarin2plage" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/4-marecages" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/5-marecages" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/5-parois-marine" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/6-fond_marin" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/7-bassesiles" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/7-mousseter" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/7-racines" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/8-mousse_marine" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/constructible" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/1a-sable-marin" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/1-plages" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/2-iles" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/2-ilesa" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/2-iles-marines" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/3-fondmarin2plage" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/4-marecages" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/5-marecages" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/5-parois-marine" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/6-fond_marin" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/7-bassesiles" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/7-mousseter" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/7-racines" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/8-mousse_marine" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/constructible" ] + +# Tiles root directory +TileRootSourceDirectory = "landscape/_texture_tiles/" + EcosystemName + +# Displace directory +DisplaceSourceDirectory = "landscape/_texture_tiles/" + EcosystemName + "/displace" + +# Do not use, needs to be removed and fixed in processes +DisplaceSourceDirectories = [ ] +DisplaceSourceDirectories += [ DisplaceSourceDirectory ] + +# Bank directory +BankSourceDirectory = "landscape/_texture_tiles/" + EcosystemName + +# Vegetable set directories +VegetSetSourceDirectories = [ ] +VegetSetSourceDirectories += [ "landscape/microveget/" + EcosystemName ] + +# Veget directories +VegetSourceDirectories = [ ] +VegetSourceDirectories += [ "landscape/microveget/" + EcosystemName ] + +# Ligo directories +LigoBaseSourceDirectory = "landscape/ligo/" + EcosystemName +LigoMaxSourceDirectory = LigoBaseSourceDirectory + "/max" + +# Zone directories +ZoneSourceDirectory = [ "landscape/zones/" + EcosystemName ] # For old snowballs style landscape when not using ligo + +# Ig landscape directories +IgLandSourceDirectory = "_invalid" + +# Ig other directories +IgOtherSourceDirectory = "_invalid" + +# PACS primitives directories +PacsPrimSourceDirectories = [ ] +PacsPrimSourceDirectories += [ DatabaseRootPath + "/decors/vegetations" ] + + +# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) + +# Ig lookup directories used by rbank +IgLookupDirectories = [ ] + +# Shape lookup directories used by rbank +ShapeLookupDirectories = [ ] +ShapeLookupDirectories += [ EcosystemPath + "/shape_clodtex_build" ] +ShapeLookupDirectories += [ EcosystemPath + "/shape_with_coarse_mesh" ] + +# Map lookup directories not yet used +MapLookupDirectories = [ ] +MapLookupDirectories += [ EcosystemPath + "/map_export" ] +MapLookupDirectories += [ EcosystemPath + "/map_uncompressed" ] + + +# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapExportDirectory = CommonPath + "/map_export" +MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" + +# Shape directories +ShapeTagExportDirectory = CommonPath + "/shape_tag" +ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" +ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" +ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" +ShapeAnimExportDirectory = CommonPath + "/shape_anim" + +# Smallbank directories +SmallbankExportDirectory = CommonPath + "/smallbank" + +# Tiles directories +TilesExportDirectory = CommonPath + "/tiles" + +# Tiles directories +DisplaceExportDirectory = CommonPath + "/diplace" + +# Veget directories +VegetExportDirectory = CommonPath + "/veget" +VegetTagExportDirectory = CommonPath + "/veget_tag" + +# Veget Set directories +VegetSetExportDirectory = CommonPath + "/veget_set" + +# Ligo directories +LigoDatabaseExportDirectory = "landscape/ligo/" + EcosystemName +LigoDatabaseIgExportDirectory = LigoDatabaseExportDirectory + "/igs" +LigoDatabaseZoneExportDirectory = LigoDatabaseExportDirectory + "/zones" +LigoDatabaseZoneLigoExportDirectory = LigoDatabaseExportDirectory + "/zoneligos" +LigoDatabaseCmbExportDirectory = LigoDatabaseExportDirectory + "/cmb" +LigoTagExportDirectory = CommonPath + "/ligo_tag" + +# Zone directories +ZoneExportDirectory = CommonPath + "/zone" + +# PACS primitives directories +PacsPrimExportDirectory = CommonPath + "/pacs_prim" + + +# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapBuildDirectory = CommonPath + "/map" +MapPanoplyBuildDirectory = CommonPath + "/map_panoply" +MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" +MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" +MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" +MapTagBuildDirectory = CommonPath + "/map_tag" + +# Shape directories +ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" +ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" +ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" +ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" + +# Farbank directories +FarbankBuildDirectory = CommonPath + "/farbank" + +# Ig directories ************** TODO CONFIRM IN IG BUILD PROCESS ************ FIX RBANK IF NEEDED *********** +IgLandBuildDirectory = "_invalid" +IgOtherBuildDirectory = "_invalid" + +# Rbank directories +RbankOutputBuildDirectory = "_invalid" + +# Ligo directories + + +# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** + +# Map directory +MapInstallDirectory = CommonName + "_maps" +BitmapInstallDirectory = MapInstallDirectory + +# Shape directory +ShapeInstallDirectory = CommonName + "_shapes" + +# Lightmap directory +LightmapInstallDirectory = CommonName + "_lightmaps" + +# Tile directory +TilesInstallDirectory = CommonName + "_tiles" + +# Displace directory +DisplaceInstallDirectory = CommonName + "_displaces" + +# Bank directory +BankInstallDirectory = CommonName + "_bank" + +# Vegetable set directory +VegetSetInstallDirectory = CommonName + "_vegetable_sets" + +# Vegetable shape directory +VegetInstallDirectory = CommonName + "_vegetables" + +# PACS primitives directories +PacsPrimInstallDirectory = CommonName + "_pacs_prim" diff --git a/code/ryzom/tools/build_gamedata/workspace/ecosystems/lacustre/process.py b/code/ryzom/tools/build_gamedata/workspace/ecosystems/lacustre/process.py index 3d040f956..5ff7e22b0 100644 --- a/code/ryzom/tools/build_gamedata/workspace/ecosystems/lacustre/process.py +++ b/code/ryzom/tools/build_gamedata/workspace/ecosystems/lacustre/process.py @@ -1,132 +1,132 @@ -#!/usr/bin/python -# -# ################################################################# -# ## WARNING : this is a generated file, don't change it ! -# ################################################################# -# -# \file config.py -# \brief Process configuration -# \date 2010-09-19-14-19-GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Process configuration for 'lacustre' ecosystem. -# -# NeL - 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 . -# - -# *** PROCESS CONFIGURATION *** - -# *** PROCESS CONFIG *** -ProcessToComplete = [ ] -ProcessToComplete += [ "shape" ] -ProcessToComplete += [ "map" ] -ProcessToComplete += [ "smallbank" ] -ProcessToComplete += [ "farbank" ] -ProcessToComplete += [ "tiles" ] -ProcessToComplete += [ "displace" ] -ProcessToComplete += [ "veget" ] -ProcessToComplete += [ "vegetset" ] -ProcessToComplete += [ "ligo" ] -ProcessToComplete += [ "pacs_prim" ] - - -# *** ECOSYSTEM AND CONTINENT NAMES *** - -EcosystemName = "lacustre" -EcosystemPath = "ecosystems/" + EcosystemName -CommonName = EcosystemName -CommonPath = EcosystemPath - - -# *** MAP EXPORT OPTIONS *** -PanoplyFileList = [ ] -HlsBankFileName = "" - -# *** SHAPE EXPORT OPTIONS *** - -# Compute lightmaps ? -ShapeExportOptExportLighting = "true" - -# Cast shadow in lightmap ? -ShapeExportOptShadow = "true" - -# Lighting limits. 0 : normal, 1 : soft shadows -ShapeExportOptLightingLimit = 0 - -# Lightmap lumel size -ShapeExportOptLumelSize = "0.25" - -# Oversampling value. Can be 1, 2, 4 or 8 -ShapeExportOptOversampling = 8 - -# Does the lightmap must be generated in 8 bits format ? -ShapeExportOpt8BitsLightmap = "false" - -# Does the lightmaps export must generate logs ? -ShapeExportOptLightmapLog = "true" - -# Coarse mesh texture mul size -TextureMulSizeValue = "1.5" - -DoBuildShadowSkin = 0 - -ClodConfigFile = "" - -# *** COARSE MESH TEXTURE NAME *** -CoarseMeshTextureNames = [ ] -CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_sp" ] -CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_su" ] -CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_au" ] -CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_wi" ] - -# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** -MultipleTilesPostfix = [ ] -MultipleTilesPostfix += [ "_sp" ] -MultipleTilesPostfix += [ "_su" ] -MultipleTilesPostfix += [ "_au" ] -MultipleTilesPostfix += [ "_wi" ] - -# *** BANK EXPORT OPTIONS *** - -# Name of the tilebank to use -BankTileBankName = EcosystemName - -# *** RBANK EXPORT OPTIONS *** - -# Output names -RbankRbankName = "_invalid" - -# *** LIGO OPTIONS *** - -LigoExportLand = "" -LigoExportOnePass = 0 - -# *** MAPS OPTIONS *** - -ReduceBitmapFactor = 0 -# list all panoply files -MapPanoplyFileList = None -# name of the .hlsbank to build. -MapHlsBankFileName = None - -# *** SHAPE BUILD OPTIONS * - -DoBuildShadowSkin = False -ClodConfigFile = "" - -# *** PACS_PRIM OPTIONS *** -WantLandscapeColPrimPacsList = True +#!/usr/bin/python +# +# ################################################################# +# ## WARNING : this is a generated file, don't change it ! +# ################################################################# +# +# \file config.py +# \brief Process configuration +# \date 2010-09-19-14-19-GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Process configuration for 'lacustre' ecosystem. +# +# NeL - 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 . +# + +# *** PROCESS CONFIGURATION *** + +# *** PROCESS CONFIG *** +ProcessToComplete = [ ] +ProcessToComplete += [ "shape" ] +ProcessToComplete += [ "map" ] +ProcessToComplete += [ "smallbank" ] +ProcessToComplete += [ "farbank" ] +ProcessToComplete += [ "tiles" ] +ProcessToComplete += [ "displace" ] +ProcessToComplete += [ "veget" ] +ProcessToComplete += [ "vegetset" ] +ProcessToComplete += [ "ligo" ] +ProcessToComplete += [ "pacs_prim" ] + + +# *** ECOSYSTEM AND CONTINENT NAMES *** + +EcosystemName = "lacustre" +EcosystemPath = "ecosystems/" + EcosystemName +CommonName = EcosystemName +CommonPath = EcosystemPath + + +# *** MAP EXPORT OPTIONS *** +PanoplyFileList = [ ] +HlsBankFileName = "" + +# *** SHAPE EXPORT OPTIONS *** + +# Compute lightmaps ? +ShapeExportOptExportLighting = "true" + +# Cast shadow in lightmap ? +ShapeExportOptShadow = "true" + +# Lighting limits. 0 : normal, 1 : soft shadows +ShapeExportOptLightingLimit = 0 + +# Lightmap lumel size +ShapeExportOptLumelSize = "0.25" + +# Oversampling value. Can be 1, 2, 4 or 8 +ShapeExportOptOversampling = 8 + +# Does the lightmap must be generated in 8 bits format ? +ShapeExportOpt8BitsLightmap = "false" + +# Does the lightmaps export must generate logs ? +ShapeExportOptLightmapLog = "true" + +# Coarse mesh texture mul size +TextureMulSizeValue = "1.5" + +DoBuildShadowSkin = 0 + +ClodConfigFile = "" + +# *** COARSE MESH TEXTURE NAME *** +CoarseMeshTextureNames = [ ] +CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_sp" ] +CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_su" ] +CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_au" ] +CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_wi" ] + +# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** +MultipleTilesPostfix = [ ] +MultipleTilesPostfix += [ "_sp" ] +MultipleTilesPostfix += [ "_su" ] +MultipleTilesPostfix += [ "_au" ] +MultipleTilesPostfix += [ "_wi" ] + +# *** BANK EXPORT OPTIONS *** + +# Name of the tilebank to use +BankTileBankName = EcosystemName + +# *** RBANK EXPORT OPTIONS *** + +# Output names +RbankRbankName = "_invalid" + +# *** LIGO OPTIONS *** + +LigoExportLand = "" +LigoExportOnePass = 0 + +# *** MAPS OPTIONS *** + +ReduceBitmapFactor = 0 +# list all panoply files +MapPanoplyFileList = None +# name of the .hlsbank to build. +MapHlsBankFileName = None + +# *** SHAPE BUILD OPTIONS * + +DoBuildShadowSkin = False +ClodConfigFile = "" + +# *** PACS_PRIM OPTIONS *** +WantLandscapeColPrimPacsList = True diff --git a/code/ryzom/tools/build_gamedata/workspace/ecosystems/primes_racines/directories.py b/code/ryzom/tools/build_gamedata/workspace/ecosystems/primes_racines/directories.py index efcfc2465..d49e8d06b 100644 --- a/code/ryzom/tools/build_gamedata/workspace/ecosystems/primes_racines/directories.py +++ b/code/ryzom/tools/build_gamedata/workspace/ecosystems/primes_racines/directories.py @@ -1,265 +1,265 @@ -#!/usr/bin/python -# -# ################################################################# -# ## WARNING : this is a generated file, don't change it ! -# ################################################################# -# -# \file directories.py -# \brief Directories configuration -# \date 2010-09-19-14-19-GMT -# \author Jan Boon (Kaetemi) -# \date 2001-2005 -# \author Nevrax -# Python port of game data build pipeline. -# Directories configuration for 'primes_racines' ecosystem. -# -# NeL - 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 . -# - - -# *** ECOSYSTEM AND CONTINENT NAMES *** - -EcosystemName = "primes_racines" -EcosystemPath = "ecosystems/" + EcosystemName -CommonName = EcosystemName -CommonPath = EcosystemPath - -DatabaseRootName = "primes_racines" -DatabaseRootPath = "stuff/" + DatabaseRootName - - -# *** SOURCE DIRECTORIES IN THE DATABASE *** - -# Shape directories -ShapeSourceDirectories = [ ] -ShapeSourceDirectories += [ DatabaseRootPath + "/decors/vegetations" ] -ShapeSourceDirectories += [ "landscape/ligo/" + EcosystemName + "/max" ] - -# Maps directories -MapSourceDirectories = [ ] -MapSourceDirectories += [ DatabaseRootPath + "/decors/_textures" ] -MapSourceDirectories += [ DatabaseRootPath + "/decors/_textures/vegetations" ] -MapSourceDirectories += [ DatabaseRootPath + "/decors/_textures/batiments" ] -MapSourceDirectories += [ "landscape/microveget/" + EcosystemName + "" ] -MapSourceDirectories += [ "landscape/water/meshes/" + EcosystemName + "" ] - -MapUncompressedSourceDirectories = [ ] - -# Tiles directories -TilesSourceDirectories = [ ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/PR-creux" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/PR-dome-moussu" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/PR-kitiniere" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/PR-mousse-licken" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/PR-mousse-spongieus" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/PR-parois" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/PR-sol-mousse" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/PR-souche" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/PR-stalagmite" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/PR-terre" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/aditif" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/PR-creux" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/PR-dome-moussu" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/PR-kitiniere" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/PR-mousse-licken" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/PR-mousse-spongieus" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/PR-parois" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/PR-sol-mousse" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/PR-souche" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/PR-stalagmite" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/PR-terre" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/aditif" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/PR-creux" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/PR-dome-moussu" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/PR-kitiniere" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/PR-mousse-licken" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/PR-mousse-spongieus" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/PR-parois" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/PR-sol-mousse" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/PR-souche" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/PR-stalagmite" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/PR-terre" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/aditif" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/PR-creux" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/PR-dome-moussu" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/PR-kitiniere" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/PR-mousse-licken" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/PR-mousse-spongieus" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/PR-parois" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/PR-sol-mousse" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/PR-souche" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/PR-stalagmite" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/PR-terre" ] -TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/aditif" ] - -# Tiles root directory -TileRootSourceDirectory = "landscape/_texture_tiles/" + EcosystemName - -# Displace directory -DisplaceSourceDirectory = "landscape/_texture_tiles/" + EcosystemName + "/displace" - -# Do not use, needs to be removed and fixed in processes -DisplaceSourceDirectories = [ ] -DisplaceSourceDirectories += [ DisplaceSourceDirectory ] - -# Bank directory -BankSourceDirectory = "landscape/_texture_tiles/" + EcosystemName - -# Vegetable set directories -VegetSetSourceDirectories = [ ] -VegetSetSourceDirectories += [ "landscape/microveget/" + EcosystemName ] - -# Veget directories -VegetSourceDirectories = [ ] -VegetSourceDirectories += [ "landscape/microveget/" + EcosystemName ] - -# Ligo directories -LigoBaseSourceDirectory = "landscape/ligo/" + EcosystemName -LigoMaxSourceDirectory = LigoBaseSourceDirectory + "/max" - -# Zone directories -ZoneSourceDirectory = [ "landscape/zones/" + EcosystemName ] # For old snowballs style landscape when not using ligo - -# Ig landscape directories -IgLandSourceDirectory = "_invalid" - -# Ig other directories -IgOtherSourceDirectory = "_invalid" - -# PACS primitives directories -PacsPrimSourceDirectories = [ ] -PacsPrimSourceDirectories += [ DatabaseRootPath + "/decors/vegetations" ] - - -# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) - -# Ig lookup directories used by rbank -IgLookupDirectories = [ ] - -# Shape lookup directories used by rbank -ShapeLookupDirectories = [ ] -ShapeLookupDirectories += [ EcosystemPath + "/shape_clodtex_build" ] -ShapeLookupDirectories += [ EcosystemPath + "/shape_with_coarse_mesh" ] - -# Map lookup directories not yet used -MapLookupDirectories = [ ] -MapLookupDirectories += [ EcosystemPath + "/map_export" ] -MapLookupDirectories += [ EcosystemPath + "/map_uncompressed" ] - - -# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapExportDirectory = CommonPath + "/map_export" -MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" - -# Shape directories -ShapeTagExportDirectory = CommonPath + "/shape_tag" -ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" -ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" -ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" -ShapeAnimExportDirectory = CommonPath + "/shape_anim" - -# Smallbank directories -SmallbankExportDirectory = CommonPath + "/smallbank" - -# Tiles directories -TilesExportDirectory = CommonPath + "/tiles" - -# Tiles directories -DisplaceExportDirectory = CommonPath + "/diplace" - -# Veget directories -VegetExportDirectory = CommonPath + "/veget" -VegetTagExportDirectory = CommonPath + "/veget_tag" - -# Veget Set directories -VegetSetExportDirectory = CommonPath + "/veget_set" - -# Ligo directories -LigoDatabaseExportDirectory = "landscape/ligo/" + EcosystemName -LigoDatabaseIgExportDirectory = LigoDatabaseExportDirectory + "/igs" -LigoDatabaseZoneExportDirectory = LigoDatabaseExportDirectory + "/zones" -LigoDatabaseZoneLigoExportDirectory = LigoDatabaseExportDirectory + "/zoneligos" -LigoDatabaseCmbExportDirectory = LigoDatabaseExportDirectory + "/cmb" -LigoTagExportDirectory = CommonPath + "/ligo_tag" - -# Zone directories -ZoneExportDirectory = CommonPath + "/zone" - -# PACS primitives directories -PacsPrimExportDirectory = CommonPath + "/pacs_prim" - - -# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** - -# Map directories -MapBuildDirectory = CommonPath + "/map" -MapPanoplyBuildDirectory = CommonPath + "/map_panoply" -MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" -MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" -MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" -MapTagBuildDirectory = CommonPath + "/map_tag" - -# Shape directories -ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" -ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" -ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" -ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" - -# Farbank directories -FarbankBuildDirectory = CommonPath + "/farbank" - -# Ig directories ************** TODO CONFIRM IN IG BUILD PROCESS ************ FIX RBANK IF NEEDED *********** -IgLandBuildDirectory = "_invalid" -IgOtherBuildDirectory = "_invalid" - -# Rbank directories -RbankOutputBuildDirectory = "_invalid" - -# Ligo directories - - -# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** - -# Map directory -MapInstallDirectory = CommonName + "_maps" -BitmapInstallDirectory = MapInstallDirectory - -# Shape directory -ShapeInstallDirectory = CommonName + "_shapes" - -# Lightmap directory -LightmapInstallDirectory = CommonName + "_lightmaps" - -# Tile directory -TilesInstallDirectory = CommonName + "_tiles" - -# Displace directory -DisplaceInstallDirectory = CommonName + "_displaces" - -# Bank directory -BankInstallDirectory = CommonName + "_bank" - -# Vegetable set directory -VegetSetInstallDirectory = CommonName + "_vegetable_sets" - -# Vegetable shape directory -VegetInstallDirectory = CommonName + "_vegetables" - -# PACS primitives directories -PacsPrimInstallDirectory = CommonName + "_pacs_prim" +#!/usr/bin/python +# +# ################################################################# +# ## WARNING : this is a generated file, don't change it ! +# ################################################################# +# +# \file directories.py +# \brief Directories configuration +# \date 2010-09-19-14-19-GMT +# \author Jan Boon (Kaetemi) +# \date 2001-2005 +# \author Nevrax +# Python port of game data build pipeline. +# Directories configuration for 'primes_racines' ecosystem. +# +# NeL - 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 . +# + + +# *** ECOSYSTEM AND CONTINENT NAMES *** + +EcosystemName = "primes_racines" +EcosystemPath = "ecosystems/" + EcosystemName +CommonName = EcosystemName +CommonPath = EcosystemPath + +DatabaseRootName = "primes_racines" +DatabaseRootPath = "stuff/" + DatabaseRootName + + +# *** SOURCE DIRECTORIES IN THE DATABASE *** + +# Shape directories +ShapeSourceDirectories = [ ] +ShapeSourceDirectories += [ DatabaseRootPath + "/decors/vegetations" ] +ShapeSourceDirectories += [ "landscape/ligo/" + EcosystemName + "/max" ] + +# Maps directories +MapSourceDirectories = [ ] +MapSourceDirectories += [ DatabaseRootPath + "/decors/_textures" ] +MapSourceDirectories += [ DatabaseRootPath + "/decors/_textures/vegetations" ] +MapSourceDirectories += [ DatabaseRootPath + "/decors/_textures/batiments" ] +MapSourceDirectories += [ "landscape/microveget/" + EcosystemName + "" ] +MapSourceDirectories += [ "landscape/water/meshes/" + EcosystemName + "" ] + +MapUncompressedSourceDirectories = [ ] + +# Tiles directories +TilesSourceDirectories = [ ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/PR-creux" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/PR-dome-moussu" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/PR-kitiniere" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/PR-mousse-licken" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/PR-mousse-spongieus" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/PR-parois" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/PR-sol-mousse" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/PR-souche" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/PR-stalagmite" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/PR-terre" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_sp/aditif" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/PR-creux" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/PR-dome-moussu" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/PR-kitiniere" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/PR-mousse-licken" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/PR-mousse-spongieus" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/PR-parois" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/PR-sol-mousse" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/PR-souche" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/PR-stalagmite" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/PR-terre" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_su/aditif" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/PR-creux" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/PR-dome-moussu" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/PR-kitiniere" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/PR-mousse-licken" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/PR-mousse-spongieus" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/PR-parois" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/PR-sol-mousse" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/PR-souche" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/PR-stalagmite" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/PR-terre" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_au/aditif" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/PR-creux" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/PR-dome-moussu" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/PR-kitiniere" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/PR-mousse-licken" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/PR-mousse-spongieus" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/PR-parois" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/PR-sol-mousse" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/PR-souche" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/PR-stalagmite" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/PR-terre" ] +TilesSourceDirectories += [ "landscape/_texture_tiles/" + EcosystemName + "_wi/aditif" ] + +# Tiles root directory +TileRootSourceDirectory = "landscape/_texture_tiles/" + EcosystemName + +# Displace directory +DisplaceSourceDirectory = "landscape/_texture_tiles/" + EcosystemName + "/displace" + +# Do not use, needs to be removed and fixed in processes +DisplaceSourceDirectories = [ ] +DisplaceSourceDirectories += [ DisplaceSourceDirectory ] + +# Bank directory +BankSourceDirectory = "landscape/_texture_tiles/" + EcosystemName + +# Vegetable set directories +VegetSetSourceDirectories = [ ] +VegetSetSourceDirectories += [ "landscape/microveget/" + EcosystemName ] + +# Veget directories +VegetSourceDirectories = [ ] +VegetSourceDirectories += [ "landscape/microveget/" + EcosystemName ] + +# Ligo directories +LigoBaseSourceDirectory = "landscape/ligo/" + EcosystemName +LigoMaxSourceDirectory = LigoBaseSourceDirectory + "/max" + +# Zone directories +ZoneSourceDirectory = [ "landscape/zones/" + EcosystemName ] # For old snowballs style landscape when not using ligo + +# Ig landscape directories +IgLandSourceDirectory = "_invalid" + +# Ig other directories +IgOtherSourceDirectory = "_invalid" + +# PACS primitives directories +PacsPrimSourceDirectories = [ ] +PacsPrimSourceDirectories += [ DatabaseRootPath + "/decors/vegetations" ] + + +# *** LOOKUP DIRECTORIES WITHIN THE BUILD PIPELINE *** (TODO: use these instead of search_pathes in properties(_base).cfg) + +# Ig lookup directories used by rbank +IgLookupDirectories = [ ] + +# Shape lookup directories used by rbank +ShapeLookupDirectories = [ ] +ShapeLookupDirectories += [ EcosystemPath + "/shape_clodtex_build" ] +ShapeLookupDirectories += [ EcosystemPath + "/shape_with_coarse_mesh" ] + +# Map lookup directories not yet used +MapLookupDirectories = [ ] +MapLookupDirectories += [ EcosystemPath + "/map_export" ] +MapLookupDirectories += [ EcosystemPath + "/map_uncompressed" ] + + +# *** EXPORT DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapExportDirectory = CommonPath + "/map_export" +MapUncompressedExportDirectory = CommonPath + "/map_uncompressed" + +# Shape directories +ShapeTagExportDirectory = CommonPath + "/shape_tag" +ShapeNotOptimizedExportDirectory = CommonPath + "/shape_not_optimized" +ShapeWithCoarseMeshExportDirectory = CommonPath + "/shape_with_coarse_mesh" +ShapeLightmapNotOptimizedExportDirectory = CommonPath + "/shape_lightmap_not_optimized" +ShapeAnimExportDirectory = CommonPath + "/shape_anim" + +# Smallbank directories +SmallbankExportDirectory = CommonPath + "/smallbank" + +# Tiles directories +TilesExportDirectory = CommonPath + "/tiles" + +# Tiles directories +DisplaceExportDirectory = CommonPath + "/diplace" + +# Veget directories +VegetExportDirectory = CommonPath + "/veget" +VegetTagExportDirectory = CommonPath + "/veget_tag" + +# Veget Set directories +VegetSetExportDirectory = CommonPath + "/veget_set" + +# Ligo directories +LigoDatabaseExportDirectory = "landscape/ligo/" + EcosystemName +LigoDatabaseIgExportDirectory = LigoDatabaseExportDirectory + "/igs" +LigoDatabaseZoneExportDirectory = LigoDatabaseExportDirectory + "/zones" +LigoDatabaseZoneLigoExportDirectory = LigoDatabaseExportDirectory + "/zoneligos" +LigoDatabaseCmbExportDirectory = LigoDatabaseExportDirectory + "/cmb" +LigoTagExportDirectory = CommonPath + "/ligo_tag" + +# Zone directories +ZoneExportDirectory = CommonPath + "/zone" + +# PACS primitives directories +PacsPrimExportDirectory = CommonPath + "/pacs_prim" + + +# *** BUILD DIRECTORIES FOR THE BUILD PIPELINE *** + +# Map directories +MapBuildDirectory = CommonPath + "/map" +MapPanoplyBuildDirectory = CommonPath + "/map_panoply" +MapPanoplyHlsInfoBuildDirectory = CommonPath + "/map_panoply_hls_info" +MapPanoplyHlsBankBuildDirectory = CommonPath + "/map_panoply_hls_bank" +MapPanoplyCacheBuildDirectory = CommonPath + "/map_panoply_cache" +MapTagBuildDirectory = CommonPath + "/map_tag" + +# Shape directories +ShapeClodtexBuildDirectory = CommonPath + "/shape_clodtex_build" +ShapeWithCoarseMeshBuildDirectory = CommonPath + "/shape_with_coarse_mesh_builded" +ShapeLightmapBuildDirectory = CommonPath + "/shape_lightmap" +ShapeLightmap16BitsBuildDirectory = CommonPath + "/shape_lightmap_16_bits" + +# Farbank directories +FarbankBuildDirectory = CommonPath + "/farbank" + +# Ig directories ************** TODO CONFIRM IN IG BUILD PROCESS ************ FIX RBANK IF NEEDED *********** +IgLandBuildDirectory = "_invalid" +IgOtherBuildDirectory = "_invalid" + +# Rbank directories +RbankOutputBuildDirectory = "_invalid" + +# Ligo directories + + +# *** INSTALL DIRECTORIES IN THE CLIENT DATA *** + +# Map directory +MapInstallDirectory = CommonName + "_maps" +BitmapInstallDirectory = MapInstallDirectory + +# Shape directory +ShapeInstallDirectory = CommonName + "_shapes" + +# Lightmap directory +LightmapInstallDirectory = CommonName + "_lightmaps" + +# Tile directory +TilesInstallDirectory = CommonName + "_tiles" + +# Displace directory +DisplaceInstallDirectory = CommonName + "_displaces" + +# Bank directory +BankInstallDirectory = CommonName + "_bank" + +# Vegetable set directory +VegetSetInstallDirectory = CommonName + "_vegetable_sets" + +# Vegetable shape directory +VegetInstallDirectory = CommonName + "_vegetables" + +# PACS primitives directories +PacsPrimInstallDirectory = CommonName + "_pacs_prim" diff --git a/code/ryzom/tools/build_gamedata/workspace/ecosystems/primes_racines/process.py b/code/ryzom/tools/build_gamedata/workspace/ecosystems/primes_racines/process.py index cc237589a..38a7de394 100644 --- a/code/ryzom/tools/build_gamedata/workspace/ecosystems/primes_racines/process.py +++ b/code/ryzom/tools/build_gamedata/workspace/ecosystems/primes_racines/process.py @@ -1,132 +1,132 @@ -#!/usr/bin/python -# -# ################################################################# -# ## WARNING : this is a generated file, don't change it ! -# ################################################################# -# -# \file config.py -# \brief Process configuration -# \date 2010-09-19-14-19-GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Process configuration for 'primes_racines' ecosystem. -# -# NeL - 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 . -# - -# *** PROCESS CONFIGURATION *** - -# *** PROCESS CONFIG *** -ProcessToComplete = [ ] -ProcessToComplete += [ "shape" ] -ProcessToComplete += [ "map" ] -ProcessToComplete += [ "smallbank" ] -ProcessToComplete += [ "farbank" ] -ProcessToComplete += [ "tiles" ] -ProcessToComplete += [ "displace" ] -ProcessToComplete += [ "veget" ] -ProcessToComplete += [ "vegetset" ] -ProcessToComplete += [ "ligo" ] -ProcessToComplete += [ "pacs_prim" ] - - -# *** ECOSYSTEM AND CONTINENT NAMES *** - -EcosystemName = "primes_racines" -EcosystemPath = "ecosystems/" + EcosystemName -CommonName = EcosystemName -CommonPath = EcosystemPath - - -# *** MAP EXPORT OPTIONS *** -PanoplyFileList = [ ] -HlsBankFileName = "" - -# *** SHAPE EXPORT OPTIONS *** - -# Compute lightmaps ? -ShapeExportOptExportLighting = "true" - -# Cast shadow in lightmap ? -ShapeExportOptShadow = "true" - -# Lighting limits. 0 : normal, 1 : soft shadows -ShapeExportOptLightingLimit = 1 - -# Lightmap lumel size -ShapeExportOptLumelSize = "0.25" - -# Oversampling value. Can be 1, 2, 4 or 8 -ShapeExportOptOversampling = 1 - -# Does the lightmap must be generated in 8 bits format ? -ShapeExportOpt8BitsLightmap = "false" - -# Does the lightmaps export must generate logs ? -ShapeExportOptLightmapLog = "true" - -# Coarse mesh texture mul size -TextureMulSizeValue = "1.5" - -DoBuildShadowSkin = 0 - -ClodConfigFile = "" - -# *** COARSE MESH TEXTURE NAME *** -CoarseMeshTextureNames = [ ] -CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_sp" ] -CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_su" ] -CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_au" ] -CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_wi" ] - -# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** -MultipleTilesPostfix = [ ] -MultipleTilesPostfix += [ "_sp" ] -MultipleTilesPostfix += [ "_su" ] -MultipleTilesPostfix += [ "_au" ] -MultipleTilesPostfix += [ "_wi" ] - -# *** BANK EXPORT OPTIONS *** - -# Name of the tilebank to use -BankTileBankName = EcosystemName - -# *** RBANK EXPORT OPTIONS *** - -# Output names -RbankRbankName = "_invalid" - -# *** LIGO OPTIONS *** - -LigoExportLand = "" -LigoExportOnePass = 0 - -# *** MAPS OPTIONS *** - -ReduceBitmapFactor = 0 -# list all panoply files -MapPanoplyFileList = None -# name of the .hlsbank to build. -MapHlsBankFileName = None - -# *** SHAPE BUILD OPTIONS * - -DoBuildShadowSkin = False -ClodConfigFile = "" - -# *** PACS_PRIM OPTIONS *** -WantLandscapeColPrimPacsList = True +#!/usr/bin/python +# +# ################################################################# +# ## WARNING : this is a generated file, don't change it ! +# ################################################################# +# +# \file config.py +# \brief Process configuration +# \date 2010-09-19-14-19-GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Process configuration for 'primes_racines' ecosystem. +# +# NeL - 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 . +# + +# *** PROCESS CONFIGURATION *** + +# *** PROCESS CONFIG *** +ProcessToComplete = [ ] +ProcessToComplete += [ "shape" ] +ProcessToComplete += [ "map" ] +ProcessToComplete += [ "smallbank" ] +ProcessToComplete += [ "farbank" ] +ProcessToComplete += [ "tiles" ] +ProcessToComplete += [ "displace" ] +ProcessToComplete += [ "veget" ] +ProcessToComplete += [ "vegetset" ] +ProcessToComplete += [ "ligo" ] +ProcessToComplete += [ "pacs_prim" ] + + +# *** ECOSYSTEM AND CONTINENT NAMES *** + +EcosystemName = "primes_racines" +EcosystemPath = "ecosystems/" + EcosystemName +CommonName = EcosystemName +CommonPath = EcosystemPath + + +# *** MAP EXPORT OPTIONS *** +PanoplyFileList = [ ] +HlsBankFileName = "" + +# *** SHAPE EXPORT OPTIONS *** + +# Compute lightmaps ? +ShapeExportOptExportLighting = "true" + +# Cast shadow in lightmap ? +ShapeExportOptShadow = "true" + +# Lighting limits. 0 : normal, 1 : soft shadows +ShapeExportOptLightingLimit = 1 + +# Lightmap lumel size +ShapeExportOptLumelSize = "0.25" + +# Oversampling value. Can be 1, 2, 4 or 8 +ShapeExportOptOversampling = 1 + +# Does the lightmap must be generated in 8 bits format ? +ShapeExportOpt8BitsLightmap = "false" + +# Does the lightmaps export must generate logs ? +ShapeExportOptLightmapLog = "true" + +# Coarse mesh texture mul size +TextureMulSizeValue = "1.5" + +DoBuildShadowSkin = 0 + +ClodConfigFile = "" + +# *** COARSE MESH TEXTURE NAME *** +CoarseMeshTextureNames = [ ] +CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_sp" ] +CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_su" ] +CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_au" ] +CoarseMeshTextureNames += [ "nel_coarse_mesh_" + EcosystemName + "_wi" ] + +# *** POSTFIX USED BY THE MULTIPLE TILES SYSTEM *** +MultipleTilesPostfix = [ ] +MultipleTilesPostfix += [ "_sp" ] +MultipleTilesPostfix += [ "_su" ] +MultipleTilesPostfix += [ "_au" ] +MultipleTilesPostfix += [ "_wi" ] + +# *** BANK EXPORT OPTIONS *** + +# Name of the tilebank to use +BankTileBankName = EcosystemName + +# *** RBANK EXPORT OPTIONS *** + +# Output names +RbankRbankName = "_invalid" + +# *** LIGO OPTIONS *** + +LigoExportLand = "" +LigoExportOnePass = 0 + +# *** MAPS OPTIONS *** + +ReduceBitmapFactor = 0 +# list all panoply files +MapPanoplyFileList = None +# name of the .hlsbank to build. +MapHlsBankFileName = None + +# *** SHAPE BUILD OPTIONS * + +DoBuildShadowSkin = False +ClodConfigFile = "" + +# *** PACS_PRIM OPTIONS *** +WantLandscapeColPrimPacsList = True diff --git a/code/ryzom/tools/build_gamedata/workspace/projects.py b/code/ryzom/tools/build_gamedata/workspace/projects.py index d5c000732..bb0a835de 100644 --- a/code/ryzom/tools/build_gamedata/workspace/projects.py +++ b/code/ryzom/tools/build_gamedata/workspace/projects.py @@ -1,512 +1,512 @@ -#!/usr/bin/python -# -# \file projects.py -# \brief Projects configuration -# \date 2010-05-24-09-19-GMT -# \author Jan Boon (Kaetemi) -# Python port of game data build pipeline. -# Projects configuration. -# -# NeL - 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 . -# - - -ProductName = "ryzom" - - -ProjectsToProcess = [ ] - -# Common asset export and build projects -ProjectsToProcess += [ "common/interface" ] -ProjectsToProcess += [ "common/objects" ] -ProjectsToProcess += [ "common/sfx" ] -ProjectsToProcess += [ "common/fauna" ] -ProjectsToProcess += [ "common/construction" ] -ProjectsToProcess += [ "common/outgame" ] -ProjectsToProcess += [ "common/sky" ] -ProjectsToProcess += [ "common/characters" ] -ProjectsToProcess += [ "common/characters_maps_hr" ] - -# Common client data and leveldesign projects -ProjectsToProcess += [ "common/fonts" ] -ProjectsToProcess += [ "common/gamedev" ] -ProjectsToProcess += [ "common/leveldesign" ] -ProjectsToProcess += [ "common/data_common" ] -ProjectsToProcess += [ "common/exedll" ] -ProjectsToProcess += [ "common/cfg" ] - -# Ecosystem projects -ProjectsToProcess += [ "ecosystems/desert" ] -ProjectsToProcess += [ "ecosystems/jungle" ] -ProjectsToProcess += [ "ecosystems/primes_racines" ] -ProjectsToProcess += [ "ecosystems/lacustre" ] - -# Continent projects -ProjectsToProcess += [ "continents/fyros" ] # Note: dummy for shape and map export -ProjectsToProcess += [ "continents/matis" ] # Note: dummy for shape and map export -ProjectsToProcess += [ "continents/zorai" ] # Note: dummy for shape and map export -ProjectsToProcess += [ "continents/tryker" ] # Note: dummy for shape and map export -ProjectsToProcess += [ "continents/newbieland" ] # Note: must be after other continents due to dependencies on fy/ma/zo/tr -ProjectsToProcess += [ "continents/indoors" ] # Note: must be after other continents due to dependencies on fy/ma/zo/tr - - -InstallShardDataDirectories = [ ] - -InstallShardDataCollisionsDirectories = [ ] -InstallShardDataCollisionsDirectories += [ "newbieland_ai" ] -InstallShardDataCollisionsDirectories += [ "newbieland_ig" ] -InstallShardDataCollisionsDirectories += [ "newbieland_pacs" ] -InstallShardDataCollisionsDirectories += [ "indoors_ai" ] -InstallShardDataCollisionsDirectories += [ "indoors_ig" ] -InstallShardDataCollisionsDirectories += [ "indoors_pacs" ] - - -InstallClientData = [ ] - -ICMainCfg = { } -ICMainCfg["Name"] = "main_cfg" -ICMainCfg["UnpackTo"] = "cfg" # -> = "./cfg/" -ICMainCfg["IsOptional"] = 0 -ICMainCfg["IsIncremental"] = 0 -ICMainCfg["Packages"] = [ [ "cfg", [ ] ] ] -InstallClientData += [ ICMainCfg ] - -ICMainExedll = { } -ICMainExedll["Name"] = "main_exedll" -ICMainExedll["UnpackTo"] = "" # -> "./", to not unpack set to None -ICMainExedll["IsOptional"] = 0 -ICMainExedll["IsIncremental"] = 0 -ICMainExedll["Packages"] = [ [ "exedll", [ ] ] ] -InstallClientData += [ ICMainExedll ] - -ICMainFonts = { } -ICMainFonts["Name"] = "main_fonts" -ICMainFonts["UnpackTo"] = "data/fonts" -ICMainFonts["IsOptional"] = 0 -ICMainFonts["IsIncremental"] = 0 -ICMainFonts["Packages"] = [ [ "fonts", [ ] ] ] -InstallClientData += [ ICMainFonts ] - -ICMainPacked = { } -ICMainPacked["Name"] = "main_packed" -ICMainPacked["UnpackTo"] = "data" -ICMainPacked["IsOptional"] = 0 -ICMainPacked["IsIncremental"] = 0 -ICMainPacked["Packages"] = [ [ "packedsheets", [ ] ] ] -InstallClientData += [ ICMainPacked ] - -ICUser = { } -ICUser["Name"] = "user" -ICUser["UnpackTo"] = "user" -ICUser["IsOptional"] = 0 -ICUser["IsIncremental"] = 0 -ICUser["Packages"] = [ [ "user", [ ] ] ] -InstallClientData += [ ICUser ] - -ICExamples = { } -ICExamples["Name"] = "examples" -ICExamples["UnpackTo"] = "examples" -ICExamples["IsOptional"] = 0 -ICExamples["IsIncremental"] = 0 -ICExamples["Packages"] = [ [ "examples", [ ] ] ] -InstallClientData += [ ICExamples ] - -ICCommon = { } -ICCommon["Name"] = "common" -ICCommon["UnpackTo"] = None -ICCommon["IsOptional"] = 0 -ICCommon["IsIncremental"] = 1 -ICCommon["Packages"] = [ ] -ICCommon["Packages"] += [ [ "sound", [ ] ] ] -ICCommon["Packages"] += [ [ "sky", [ ] ] ] -ICCommon["Packages"] += [ [ "sfx", [ ] ] ] -ICCommon["Packages"] += [ [ "objects", [ ] ] ] -ICCommon["Packages"] += [ [ "construction", [ ] ] ] -ICCommon["Packages"] += [ [ "outgame", [ ] ] ] -ICCommon["Packages"] += [ [ "leveldesign", [ ] ] ] -ICCommon["Packages"] += [ [ "interfaces", [ ] ] ] -ICCommon["Packages"] += [ [ "gamedev", [ ] ] ] -ICCommon["Packages"] += [ [ "data_common", [ ] ] ] -ICCommon["Packages"] += [ [ "fauna_swt", [ ] ] ] -ICCommon["Packages"] += [ [ "fauna_skeletons", [ ] ] ] -ICCommon["Packages"] += [ [ "fauna_shapes", [ ] ] ] -ICCommon["Packages"] += [ [ "fauna_maps", [ ] ] ] -ICCommon["Packages"] += [ [ "fauna_animations", [ ] ] ] -InstallClientData += [ ICCommon ] - -ICCharacterArmors = [ ] -ICCharacterArmors += [ "zo_hom_visage" ] -ICCharacterArmors += [ "zo_hom_underwear" ] -ICCharacterArmors += [ "zo_hom_civil01" ] -ICCharacterArmors += [ "zo_hom_cheveux" ] -ICCharacterArmors += [ "zo_hom_caster01" ] -ICCharacterArmors += [ "zo_hom_armor01" ] -ICCharacterArmors += [ "zo_hom_armor00" ] -ICCharacterArmors += [ "zo_hof_visage" ] -ICCharacterArmors += [ "zo_hof_underwear" ] -ICCharacterArmors += [ "zo_hof_civil01" ] -ICCharacterArmors += [ "zo_hof_cheveux" ] -ICCharacterArmors += [ "zo_hof_caster01" ] -ICCharacterArmors += [ "zo_hof_armor01" ] -ICCharacterArmors += [ "zo_hof_armor00" ] -ICCharacterArmors += [ "zo_casque01" ] -ICCharacterArmors += [ "tr_hom_visage" ] -ICCharacterArmors += [ "tr_hom_underwear" ] -ICCharacterArmors += [ "tr_hom_refugee" ] -ICCharacterArmors += [ "tr_hom_civil01" ] -ICCharacterArmors += [ "tr_hom_cheveux" ] -ICCharacterArmors += [ "tr_hom_caster01" ] -ICCharacterArmors += [ "tr_hom_armor01" ] -ICCharacterArmors += [ "tr_hom_armor00" ] -ICCharacterArmors += [ "tr_hof_visage" ] -ICCharacterArmors += [ "tr_hof_underwear" ] -ICCharacterArmors += [ "tr_hof_refugee" ] -ICCharacterArmors += [ "tr_hof_civil01" ] -ICCharacterArmors += [ "tr_hof_cheveux" ] -ICCharacterArmors += [ "tr_hof_caster01" ] -ICCharacterArmors += [ "tr_hof_armor01" ] -ICCharacterArmors += [ "tr_hof_armor00" ] -ICCharacterArmors += [ "tr_casque01" ] -ICCharacterArmors += [ "ma_hom_visage" ] -ICCharacterArmors += [ "ma_hom_underwear" ] -ICCharacterArmors += [ "ma_hom_civil01" ] -ICCharacterArmors += [ "ma_hom_cheveux" ] -ICCharacterArmors += [ "ma_hom_caster01" ] -ICCharacterArmors += [ "ma_hom_armor01" ] -ICCharacterArmors += [ "ma_hom_armor00" ] -ICCharacterArmors += [ "ma_hof_visage" ] -ICCharacterArmors += [ "ma_hof_underwear" ] -ICCharacterArmors += [ "ma_hof_civil01" ] -ICCharacterArmors += [ "ma_hof_cheveux" ] -ICCharacterArmors += [ "ma_hof_caster01" ] -ICCharacterArmors += [ "ma_hof_casque01" ] -ICCharacterArmors += [ "ma_hof_armor04" ] -ICCharacterArmors += [ "ma_hof_armor01" ] -ICCharacterArmors += [ "ma_hof_armor00" ] -ICCharacterArmors += [ "fy_hom_visage" ] -ICCharacterArmors += [ "fy_hom_underwear" ] -ICCharacterArmors += [ "fy_hom_ruflaket" ] -ICCharacterArmors += [ "fy_hom_civil01" ] -ICCharacterArmors += [ "fy_hom_cheveux" ] -ICCharacterArmors += [ "fy_hom_caster01" ] -ICCharacterArmors += [ "fy_hom_barman" ] -ICCharacterArmors += [ "fy_hom_armor01" ] -ICCharacterArmors += [ "fy_hom_armor00" ] -ICCharacterArmors += [ "fy_hof_visage" ] -ICCharacterArmors += [ "fy_hof_underwear" ] -ICCharacterArmors += [ "fy_hof_civil01" ] -ICCharacterArmors += [ "fy_hof_cheveux" ] -ICCharacterArmors += [ "fy_hof_caster01" ] -ICCharacterArmors += [ "fy_hof_armor01" ] -ICCharacterArmors += [ "fy_hof_armor00" ] -ICCharacterArmors += [ "ge_hof_armor02" ] -ICCharacterArmors += [ "ge_hof_armor03" ] -ICCharacterArmors += [ "ge_hof_armor04" ] -ICCharacterArmors += [ "ge_hof_caster00" ] -ICCharacterArmors += [ "ge_hom_armor02" ] -ICCharacterArmors += [ "ge_hom_armor03" ] -ICCharacterArmors += [ "ge_hom_armor04" ] -ICCharacterArmors += [ "ge_hom_caster00" ] -ICCharacter = { } -ICCharacter["Name"] = "character" -ICCharacter["UnpackTo"] = None -ICCharacter["IsOptional"] = 0 -ICCharacter["IsIncremental"] = 1 -ICCharacter["Packages"] = [ ] -ICCharacter["Packages"] += [ [ "characters_swt", [ ] ] ] -ICCharacter["Packages"] += [ [ "characters_skeletons", [ ] ] ] -ICCharacter["Packages"] += [ [ "characters_shapes", [ ] ] ] -ICCharacter["Packages"] += [ [ "characters_animations", [ ] ] ] -ICCharacterMapsConditions = [ ] -for armor in ICCharacterArmors: - ICCharacterMapsConditions += [ "-ifnot" ] - ICCharacterMapsConditions += [ armor + "*" ] -ICCharacter["Packages"] += [ [ "characters_maps_hr", [ "characters_maps_hr.bnp" ] + ICCharacterMapsConditions, "characters.hlsbank" ] ] -for armor in ICCharacterArmors: - ICCharacter["Packages"] += [ [ "characters_maps_hr", [ "characters_maps_" + armor + "_hr.bnp", "-if", armor + "*" ], "characters.hlsbank" ] ] -InstallClientData += [ ICCharacter ] - -ICEsPrimesRacines = { } -ICEsPrimesRacines["Name"] = "es_primes_racines" -ICEsPrimesRacines["UnpackTo"] = None -ICEsPrimesRacines["IsOptional"] = 0 -ICEsPrimesRacines["IsIncremental"] = 1 -ICEsPrimesRacines["Packages"] = [ ] -ICEsPrimesRacines["Packages"] += [ [ "primes_racines_vegetable_sets", [ ] ] ] -ICEsPrimesRacines["Packages"] += [ [ "primes_racines_vegetables", [ ] ] ] -ICEsPrimesRacines["Packages"] += [ [ "primes_racines_tiles", [ ] ] ] -ICEsPrimesRacines["Packages"] += [ [ "primes_racines_shapes", [ ] ] ] -ICEsPrimesRacines["Packages"] += [ [ "primes_racines_pacs_prim", [ ] ] ] -ICEsPrimesRacines["Packages"] += [ [ "primes_racines_maps", [ ] ] ] -ICEsPrimesRacines["Packages"] += [ [ "primes_racines_lightmaps", [ ] ] ] -ICEsPrimesRacines["Packages"] += [ [ "primes_racines_displaces", [ ] ] ] -ICEsPrimesRacines["Packages"] += [ [ "primes_racines_bank", [ ] ] ] -InstallClientData += [ ICEsPrimesRacines ] - -ICEsDesert = { } -ICEsDesert["Name"] = "es_desert" -ICEsDesert["UnpackTo"] = None -ICEsDesert["IsOptional"] = 1 -ICEsDesert["IsIncremental"] = 1 -ICEsDesert["Packages"] = [ ] -ICEsDesert["Packages"] += [ [ "desert_vegetable_sets", [ ] ] ] -ICEsDesert["Packages"] += [ [ "desert_vegetables", [ ] ] ] -ICEsDesert["Packages"] += [ [ "desert_tiles", [ ] ] ] -ICEsDesert["Packages"] += [ [ "desert_shapes", [ ] ] ] -ICEsDesert["Packages"] += [ [ "desert_pacs_prim", [ ] ] ] -ICEsDesert["Packages"] += [ [ "desert_maps", [ ] ] ] -ICEsDesert["Packages"] += [ [ "desert_lightmaps", [ ] ] ] -ICEsDesert["Packages"] += [ [ "desert_displaces", [ ] ] ] -ICEsDesert["Packages"] += [ [ "desert_bank", [ ] ] ] -InstallClientData += [ ICEsDesert ] - -ICEsLacustre = { } -ICEsLacustre["Name"] = "es_lacustre" -ICEsLacustre["UnpackTo"] = None -ICEsLacustre["IsOptional"] = 1 -ICEsLacustre["IsIncremental"] = 1 -ICEsLacustre["Packages"] = [ ] -ICEsLacustre["Packages"] += [ [ "lacustre_vegetable_sets", [ ] ] ] -ICEsLacustre["Packages"] += [ [ "lacustre_vegetables", [ ] ] ] -ICEsLacustre["Packages"] += [ [ "lacustre_tiles", [ ] ] ] -ICEsLacustre["Packages"] += [ [ "lacustre_shapes", [ ] ] ] -ICEsLacustre["Packages"] += [ [ "lacustre_pacs_prim", [ ] ] ] -ICEsLacustre["Packages"] += [ [ "lacustre_maps", [ ] ] ] -ICEsLacustre["Packages"] += [ [ "lacustre_lightmaps", [ ] ] ] -ICEsLacustre["Packages"] += [ [ "lacustre_displaces", [ ] ] ] -ICEsLacustre["Packages"] += [ [ "lacustre_bank", [ ] ] ] -InstallClientData += [ ICEsLacustre ] - -ICEsJungle = { } -ICEsJungle["Name"] = "es_jungle" -ICEsJungle["UnpackTo"] = None -ICEsJungle["IsOptional"] = 1 -ICEsJungle["IsIncremental"] = 1 -ICEsJungle["Packages"] = [ ] -ICEsJungle["Packages"] += [ [ "jungle_vegetable_sets", [ ] ] ] -ICEsJungle["Packages"] += [ [ "jungle_vegetables", [ ] ] ] -ICEsJungle["Packages"] += [ [ "jungle_tiles", [ ] ] ] -ICEsJungle["Packages"] += [ [ "jungle_shapes", [ ] ] ] -ICEsJungle["Packages"] += [ [ "jungle_pacs_prim", [ ] ] ] -ICEsJungle["Packages"] += [ [ "jungle_maps", [ ] ] ] -ICEsJungle["Packages"] += [ [ "jungle_lightmaps", [ ] ] ] -ICEsJungle["Packages"] += [ [ "jungle_displaces", [ ] ] ] -ICEsJungle["Packages"] += [ [ "jungle_bank", [ ] ] ] -InstallClientData += [ ICEsJungle ] - -ICFyros = { } -ICFyros["Name"] = "fyros" -ICFyros["UnpackTo"] = None -ICFyros["IsOptional"] = 1 -ICFyros["IsIncremental"] = 1 -ICFyros["Packages"] = [ ] -ICFyros["Packages"] += [ [ "fyros_zones", [ ] ] ] -ICFyros["Packages"] += [ [ "fyros_shapes", [ ] ] ] -ICFyros["Packages"] += [ [ "fyros_pacs", [ ] ] ] -ICFyros["Packages"] += [ [ "fyros_maps", [ ] ] ] -ICFyros["Packages"] += [ [ "fyros_lightmaps", [ ] ] ] -ICFyros["Packages"] += [ [ "fyros_ig", [ ] ] ] -ICFyros["Packages"] += [ [ "fyros_newbie_zones", [ ] ] ] -ICFyros["Packages"] += [ [ "fyros_newbie_pacs", [ ] ] ] -ICFyros["Packages"] += [ [ "fyros_newbie_ig", [ ] ] ] -ICFyros["Packages"] += [ [ "fyros_island_zones", [ ] ] ] -ICFyros["Packages"] += [ [ "fyros_island_pacs", [ ] ] ] -ICFyros["Packages"] += [ [ "fyros_island_ig", [ ] ] ] -InstallClientData += [ ICFyros ] - -ICMatis = { } -ICMatis["Name"] = "matis" -ICMatis["UnpackTo"] = None -ICMatis["IsOptional"] = 1 -ICMatis["IsIncremental"] = 1 -ICMatis["Packages"] = [ ] -ICMatis["Packages"] += [ [ "matis_zones", [ ] ] ] -ICMatis["Packages"] += [ [ "matis_shapes", [ ] ] ] -ICMatis["Packages"] += [ [ "matis_pacs", [ ] ] ] -ICMatis["Packages"] += [ [ "matis_maps", [ ] ] ] -ICMatis["Packages"] += [ [ "matis_lightmaps", [ ] ] ] -ICMatis["Packages"] += [ [ "matis_ig", [ ] ] ] -ICMatis["Packages"] += [ [ "matis_island_zones", [ ] ] ] -ICMatis["Packages"] += [ [ "matis_island_pacs", [ ] ] ] -ICMatis["Packages"] += [ [ "matis_island_ig", [ ] ] ] -InstallClientData += [ ICMatis ] - -ICZorai = { } -ICZorai["Name"] = "zorai" -ICZorai["UnpackTo"] = None -ICZorai["IsOptional"] = 1 -ICZorai["IsIncremental"] = 1 -ICZorai["Packages"] = [ ] -ICZorai["Packages"] += [ [ "zorai_zones", [ ] ] ] -ICZorai["Packages"] += [ [ "zorai_shapes", [ ] ] ] -ICZorai["Packages"] += [ [ "zorai_pacs", [ ] ] ] -ICZorai["Packages"] += [ [ "zorai_maps", [ ] ] ] -ICZorai["Packages"] += [ [ "zorai_lightmaps", [ ] ] ] -ICZorai["Packages"] += [ [ "zorai_ig", [ ] ] ] -ICZorai["Packages"] += [ [ "zorai_island_zones", [ ] ] ] -ICZorai["Packages"] += [ [ "zorai_island_pacs", [ ] ] ] -ICZorai["Packages"] += [ [ "zorai_island_ig", [ ] ] ] -InstallClientData += [ ICZorai ] - -ICTryker = { } -ICTryker["Name"] = "tryker" -ICTryker["UnpackTo"] = None -ICTryker["IsOptional"] = 1 -ICTryker["IsIncremental"] = 1 -ICTryker["Packages"] = [ ] -ICTryker["Packages"] += [ [ "tryker_zones", [ ] ] ] -ICTryker["Packages"] += [ [ "tryker_shapes", [ ] ] ] -ICTryker["Packages"] += [ [ "tryker_pacs", [ ] ] ] -ICTryker["Packages"] += [ [ "tryker_maps", [ ] ] ] -ICTryker["Packages"] += [ [ "tryker_lightmaps", [ ] ] ] -ICTryker["Packages"] += [ [ "tryker_ig", [ ] ] ] -ICTryker["Packages"] += [ [ "tryker_newbie_zones", [ ] ] ] -ICTryker["Packages"] += [ [ "tryker_newbie_shapes", [ ] ] ] -ICTryker["Packages"] += [ [ "tryker_newbie_pacs", [ ] ] ] -ICTryker["Packages"] += [ [ "tryker_newbie_ig", [ ] ] ] -ICTryker["Packages"] += [ [ "tryker_island_zones", [ ] ] ] -ICTryker["Packages"] += [ [ "tryker_island_shapes", [ ] ] ] -ICTryker["Packages"] += [ [ "tryker_island_pacs", [ ] ] ] -ICTryker["Packages"] += [ [ "tryker_island_ig", [ ] ] ] -InstallClientData += [ ICTryker ] - -ICSources = { } -ICSources["Name"] = "sources" -ICSources["UnpackTo"] = None -ICSources["IsOptional"] = 1 -ICSources["IsIncremental"] = 1 -ICSources["Packages"] = [ ] -ICSources["Packages"] += [ [ "sources_zones", [ ] ] ] -ICSources["Packages"] += [ [ "sources_shapes", [ ] ] ] -ICSources["Packages"] += [ [ "sources_pacs", [ ] ] ] -ICSources["Packages"] += [ [ "sources_maps", [ ] ] ] -ICSources["Packages"] += [ [ "sources_lightmaps", [ ] ] ] -ICSources["Packages"] += [ [ "sources_ig", [ ] ] ] -InstallClientData += [ ICSources ] - -ICRouteGouffre = { } -ICRouteGouffre["Name"] = "route_gouffre" -ICRouteGouffre["UnpackTo"] = None -ICRouteGouffre["IsOptional"] = 1 -ICRouteGouffre["IsIncremental"] = 1 -ICRouteGouffre["Packages"] = [ ] -ICRouteGouffre["Packages"] += [ [ "route_gouffre_zones", [ ] ] ] -ICRouteGouffre["Packages"] += [ [ "route_gouffre_shapes", [ ] ] ] -ICRouteGouffre["Packages"] += [ [ "route_gouffre_pacs", [ ] ] ] -ICRouteGouffre["Packages"] += [ [ "route_gouffre_maps", [ ] ] ] -ICRouteGouffre["Packages"] += [ [ "route_gouffre_lightmaps", [ ] ] ] -ICRouteGouffre["Packages"] += [ [ "route_gouffre_ig", [ ] ] ] -InstallClientData += [ ICRouteGouffre ] - -ICBagne = { } -ICBagne["Name"] = "bagne" -ICBagne["UnpackTo"] = None -ICBagne["IsOptional"] = 1 -ICBagne["IsIncremental"] = 1 -ICBagne["Packages"] = [ ] -ICBagne["Packages"] += [ [ "bagne_zones", [ ] ] ] -ICBagne["Packages"] += [ [ "bagne_shapes", [ ] ] ] -ICBagne["Packages"] += [ [ "bagne_pacs", [ ] ] ] -ICBagne["Packages"] += [ [ "bagne_maps", [ ] ] ] -ICBagne["Packages"] += [ [ "bagne_lightmaps", [ ] ] ] -ICBagne["Packages"] += [ [ "bagne_ig", [ ] ] ] -InstallClientData += [ ICBagne ] - -ICTerre = { } -ICTerre["Name"] = "terre" -ICTerre["UnpackTo"] = None -ICTerre["IsOptional"] = 1 -ICTerre["IsIncremental"] = 1 -ICTerre["Packages"] = [ ] -ICTerre["Packages"] += [ [ "terre_zones", [ ] ] ] -ICTerre["Packages"] += [ [ "terre_shapes", [ ] ] ] -ICTerre["Packages"] += [ [ "terre_pacs", [ ] ] ] -ICTerre["Packages"] += [ [ "terre_maps", [ ] ] ] -ICTerre["Packages"] += [ [ "terre_lightmaps", [ ] ] ] -ICTerre["Packages"] += [ [ "terre_ig", [ ] ] ] -InstallClientData += [ ICTerre ] - -ICNexus = { } -ICNexus["Name"] = "nexus" -ICNexus["UnpackTo"] = None -ICNexus["IsOptional"] = 1 -ICNexus["IsIncremental"] = 1 -ICNexus["Packages"] = [ ] -ICNexus["Packages"] += [ [ "nexus_zones", [ ] ] ] -ICNexus["Packages"] += [ [ "nexus_shapes", [ ] ] ] -ICNexus["Packages"] += [ [ "nexus_pacs", [ ] ] ] -ICNexus["Packages"] += [ [ "nexus_maps", [ ] ] ] -ICNexus["Packages"] += [ [ "nexus_lightmaps", [ ] ] ] -ICNexus["Packages"] += [ [ "nexus_ig", [ ] ] ] -InstallClientData += [ ICNexus ] - -ICNewbieland = { } -ICNewbieland["Name"] = "newbieland" -ICNewbieland["UnpackTo"] = None -ICNewbieland["IsOptional"] = 1 -ICNewbieland["IsIncremental"] = 1 -ICNewbieland["Packages"] = [ ] -ICNewbieland["Packages"] += [ [ "newbieland_zones", [ ] ] ] -ICNewbieland["Packages"] += [ [ "newbieland_shapes", [ ] ] ] -ICNewbieland["Packages"] += [ [ "newbieland_pacs", [ ] ] ] -ICNewbieland["Packages"] += [ [ "newbieland_maps", [ ] ] ] -ICNewbieland["Packages"] += [ [ "newbieland_ig", [ ] ] ] -InstallClientData += [ ICNewbieland ] - -ICIndoors = { } -ICIndoors["Name"] = "indoors" -ICIndoors["UnpackTo"] = None -ICIndoors["IsOptional"] = 1 -ICIndoors["IsIncremental"] = 1 -ICIndoors["Packages"] = [ ] -ICIndoors["Packages"] += [ [ "indoors_shapes", [ ] ] ] -ICIndoors["Packages"] += [ [ "indoors_pacs", [ ] ] ] -ICIndoors["Packages"] += [ [ "indoors_lightmaps", [ ] ] ] -ICIndoors["Packages"] += [ [ "indoors_ig", [ ] ] ] -InstallClientData += [ ICIndoors ] - -ICR2 = { } -ICR2["Name"] = "r2" -ICR2["UnpackTo"] = None -ICR2["IsOptional"] = 1 -ICR2["IsIncremental"] = 1 -ICR2["Packages"] = [ ] -ICR2["Packages"] += [ [ "r2_misc", [ ] ] ] -ICR2["Packages"] += [ [ "r2_jungle", [ ] ] ] -ICR2["Packages"] += [ [ "r2_lakes", [ ] ] ] -ICR2["Packages"] += [ [ "r2_desert", [ ] ] ] -ICR2["Packages"] += [ [ "r2_roots", [ ] ] ] -ICR2["Packages"] += [ [ "r2_forest", [ ] ] ] -ICR2["Packages"] += [ [ "r2_lakes2", [ ] ] ] -ICR2["Packages"] += [ [ "r2_jungle2", [ ] ] ] -ICR2["Packages"] += [ [ "r2_forest2", [ ] ] ] -ICR2["Packages"] += [ [ "r2_desert2", [ ] ] ] -ICR2["Packages"] += [ [ "r2_roots2", [ ] ] ] -ICR2["Packages"] += [ [ "r2_forest_maps", [ ] ] ] -ICR2["Packages"] += [ [ "r2_desert_maps", [ ] ] ] -ICR2["Packages"] += [ [ "r2_roots_maps", [ ] ] ] -ICR2["Packages"] += [ [ "r2_lakes_maps", [ ] ] ] -ICR2["Packages"] += [ [ "r2_jungle_maps", [ ] ] ] -ICR2["Packages"] += [ [ "r2_roots_pz", [ ] ] ] -ICR2["Packages"] += [ [ "r2_lakes_pz", [ ] ] ] -ICR2["Packages"] += [ [ "r2_jungle_pz", [ ] ] ] -ICR2["Packages"] += [ [ "r2_forest_pz", [ ] ] ] -ICR2["Packages"] += [ [ "r2_desert_pz", [ ] ] ] -InstallClientData += [ ICR2 ] - - -# end of file +#!/usr/bin/python +# +# \file projects.py +# \brief Projects configuration +# \date 2010-05-24-09-19-GMT +# \author Jan Boon (Kaetemi) +# Python port of game data build pipeline. +# Projects configuration. +# +# NeL - 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 . +# + + +ProductName = "ryzom" + + +ProjectsToProcess = [ ] + +# Common asset export and build projects +ProjectsToProcess += [ "common/interface" ] +ProjectsToProcess += [ "common/objects" ] +ProjectsToProcess += [ "common/sfx" ] +ProjectsToProcess += [ "common/fauna" ] +ProjectsToProcess += [ "common/construction" ] +ProjectsToProcess += [ "common/outgame" ] +ProjectsToProcess += [ "common/sky" ] +ProjectsToProcess += [ "common/characters" ] +ProjectsToProcess += [ "common/characters_maps_hr" ] + +# Common client data and leveldesign projects +ProjectsToProcess += [ "common/fonts" ] +ProjectsToProcess += [ "common/gamedev" ] +ProjectsToProcess += [ "common/leveldesign" ] +ProjectsToProcess += [ "common/data_common" ] +ProjectsToProcess += [ "common/exedll" ] +ProjectsToProcess += [ "common/cfg" ] + +# Ecosystem projects +ProjectsToProcess += [ "ecosystems/desert" ] +ProjectsToProcess += [ "ecosystems/jungle" ] +ProjectsToProcess += [ "ecosystems/primes_racines" ] +ProjectsToProcess += [ "ecosystems/lacustre" ] + +# Continent projects +ProjectsToProcess += [ "continents/fyros" ] # Note: dummy for shape and map export +ProjectsToProcess += [ "continents/matis" ] # Note: dummy for shape and map export +ProjectsToProcess += [ "continents/zorai" ] # Note: dummy for shape and map export +ProjectsToProcess += [ "continents/tryker" ] # Note: dummy for shape and map export +ProjectsToProcess += [ "continents/newbieland" ] # Note: must be after other continents due to dependencies on fy/ma/zo/tr +ProjectsToProcess += [ "continents/indoors" ] # Note: must be after other continents due to dependencies on fy/ma/zo/tr + + +InstallShardDataDirectories = [ ] + +InstallShardDataCollisionsDirectories = [ ] +InstallShardDataCollisionsDirectories += [ "newbieland_ai" ] +InstallShardDataCollisionsDirectories += [ "newbieland_ig" ] +InstallShardDataCollisionsDirectories += [ "newbieland_pacs" ] +InstallShardDataCollisionsDirectories += [ "indoors_ai" ] +InstallShardDataCollisionsDirectories += [ "indoors_ig" ] +InstallShardDataCollisionsDirectories += [ "indoors_pacs" ] + + +InstallClientData = [ ] + +ICMainCfg = { } +ICMainCfg["Name"] = "main_cfg" +ICMainCfg["UnpackTo"] = "cfg" # -> = "./cfg/" +ICMainCfg["IsOptional"] = 0 +ICMainCfg["IsIncremental"] = 0 +ICMainCfg["Packages"] = [ [ "cfg", [ ] ] ] +InstallClientData += [ ICMainCfg ] + +ICMainExedll = { } +ICMainExedll["Name"] = "main_exedll" +ICMainExedll["UnpackTo"] = "" # -> "./", to not unpack set to None +ICMainExedll["IsOptional"] = 0 +ICMainExedll["IsIncremental"] = 0 +ICMainExedll["Packages"] = [ [ "exedll", [ ] ] ] +InstallClientData += [ ICMainExedll ] + +ICMainFonts = { } +ICMainFonts["Name"] = "main_fonts" +ICMainFonts["UnpackTo"] = "data/fonts" +ICMainFonts["IsOptional"] = 0 +ICMainFonts["IsIncremental"] = 0 +ICMainFonts["Packages"] = [ [ "fonts", [ ] ] ] +InstallClientData += [ ICMainFonts ] + +ICMainPacked = { } +ICMainPacked["Name"] = "main_packed" +ICMainPacked["UnpackTo"] = "data" +ICMainPacked["IsOptional"] = 0 +ICMainPacked["IsIncremental"] = 0 +ICMainPacked["Packages"] = [ [ "packedsheets", [ ] ] ] +InstallClientData += [ ICMainPacked ] + +ICUser = { } +ICUser["Name"] = "user" +ICUser["UnpackTo"] = "user" +ICUser["IsOptional"] = 0 +ICUser["IsIncremental"] = 0 +ICUser["Packages"] = [ [ "user", [ ] ] ] +InstallClientData += [ ICUser ] + +ICExamples = { } +ICExamples["Name"] = "examples" +ICExamples["UnpackTo"] = "examples" +ICExamples["IsOptional"] = 0 +ICExamples["IsIncremental"] = 0 +ICExamples["Packages"] = [ [ "examples", [ ] ] ] +InstallClientData += [ ICExamples ] + +ICCommon = { } +ICCommon["Name"] = "common" +ICCommon["UnpackTo"] = None +ICCommon["IsOptional"] = 0 +ICCommon["IsIncremental"] = 1 +ICCommon["Packages"] = [ ] +ICCommon["Packages"] += [ [ "sound", [ ] ] ] +ICCommon["Packages"] += [ [ "sky", [ ] ] ] +ICCommon["Packages"] += [ [ "sfx", [ ] ] ] +ICCommon["Packages"] += [ [ "objects", [ ] ] ] +ICCommon["Packages"] += [ [ "construction", [ ] ] ] +ICCommon["Packages"] += [ [ "outgame", [ ] ] ] +ICCommon["Packages"] += [ [ "leveldesign", [ ] ] ] +ICCommon["Packages"] += [ [ "interfaces", [ ] ] ] +ICCommon["Packages"] += [ [ "gamedev", [ ] ] ] +ICCommon["Packages"] += [ [ "data_common", [ ] ] ] +ICCommon["Packages"] += [ [ "fauna_swt", [ ] ] ] +ICCommon["Packages"] += [ [ "fauna_skeletons", [ ] ] ] +ICCommon["Packages"] += [ [ "fauna_shapes", [ ] ] ] +ICCommon["Packages"] += [ [ "fauna_maps", [ ] ] ] +ICCommon["Packages"] += [ [ "fauna_animations", [ ] ] ] +InstallClientData += [ ICCommon ] + +ICCharacterArmors = [ ] +ICCharacterArmors += [ "zo_hom_visage" ] +ICCharacterArmors += [ "zo_hom_underwear" ] +ICCharacterArmors += [ "zo_hom_civil01" ] +ICCharacterArmors += [ "zo_hom_cheveux" ] +ICCharacterArmors += [ "zo_hom_caster01" ] +ICCharacterArmors += [ "zo_hom_armor01" ] +ICCharacterArmors += [ "zo_hom_armor00" ] +ICCharacterArmors += [ "zo_hof_visage" ] +ICCharacterArmors += [ "zo_hof_underwear" ] +ICCharacterArmors += [ "zo_hof_civil01" ] +ICCharacterArmors += [ "zo_hof_cheveux" ] +ICCharacterArmors += [ "zo_hof_caster01" ] +ICCharacterArmors += [ "zo_hof_armor01" ] +ICCharacterArmors += [ "zo_hof_armor00" ] +ICCharacterArmors += [ "zo_casque01" ] +ICCharacterArmors += [ "tr_hom_visage" ] +ICCharacterArmors += [ "tr_hom_underwear" ] +ICCharacterArmors += [ "tr_hom_refugee" ] +ICCharacterArmors += [ "tr_hom_civil01" ] +ICCharacterArmors += [ "tr_hom_cheveux" ] +ICCharacterArmors += [ "tr_hom_caster01" ] +ICCharacterArmors += [ "tr_hom_armor01" ] +ICCharacterArmors += [ "tr_hom_armor00" ] +ICCharacterArmors += [ "tr_hof_visage" ] +ICCharacterArmors += [ "tr_hof_underwear" ] +ICCharacterArmors += [ "tr_hof_refugee" ] +ICCharacterArmors += [ "tr_hof_civil01" ] +ICCharacterArmors += [ "tr_hof_cheveux" ] +ICCharacterArmors += [ "tr_hof_caster01" ] +ICCharacterArmors += [ "tr_hof_armor01" ] +ICCharacterArmors += [ "tr_hof_armor00" ] +ICCharacterArmors += [ "tr_casque01" ] +ICCharacterArmors += [ "ma_hom_visage" ] +ICCharacterArmors += [ "ma_hom_underwear" ] +ICCharacterArmors += [ "ma_hom_civil01" ] +ICCharacterArmors += [ "ma_hom_cheveux" ] +ICCharacterArmors += [ "ma_hom_caster01" ] +ICCharacterArmors += [ "ma_hom_armor01" ] +ICCharacterArmors += [ "ma_hom_armor00" ] +ICCharacterArmors += [ "ma_hof_visage" ] +ICCharacterArmors += [ "ma_hof_underwear" ] +ICCharacterArmors += [ "ma_hof_civil01" ] +ICCharacterArmors += [ "ma_hof_cheveux" ] +ICCharacterArmors += [ "ma_hof_caster01" ] +ICCharacterArmors += [ "ma_hof_casque01" ] +ICCharacterArmors += [ "ma_hof_armor04" ] +ICCharacterArmors += [ "ma_hof_armor01" ] +ICCharacterArmors += [ "ma_hof_armor00" ] +ICCharacterArmors += [ "fy_hom_visage" ] +ICCharacterArmors += [ "fy_hom_underwear" ] +ICCharacterArmors += [ "fy_hom_ruflaket" ] +ICCharacterArmors += [ "fy_hom_civil01" ] +ICCharacterArmors += [ "fy_hom_cheveux" ] +ICCharacterArmors += [ "fy_hom_caster01" ] +ICCharacterArmors += [ "fy_hom_barman" ] +ICCharacterArmors += [ "fy_hom_armor01" ] +ICCharacterArmors += [ "fy_hom_armor00" ] +ICCharacterArmors += [ "fy_hof_visage" ] +ICCharacterArmors += [ "fy_hof_underwear" ] +ICCharacterArmors += [ "fy_hof_civil01" ] +ICCharacterArmors += [ "fy_hof_cheveux" ] +ICCharacterArmors += [ "fy_hof_caster01" ] +ICCharacterArmors += [ "fy_hof_armor01" ] +ICCharacterArmors += [ "fy_hof_armor00" ] +ICCharacterArmors += [ "ge_hof_armor02" ] +ICCharacterArmors += [ "ge_hof_armor03" ] +ICCharacterArmors += [ "ge_hof_armor04" ] +ICCharacterArmors += [ "ge_hof_caster00" ] +ICCharacterArmors += [ "ge_hom_armor02" ] +ICCharacterArmors += [ "ge_hom_armor03" ] +ICCharacterArmors += [ "ge_hom_armor04" ] +ICCharacterArmors += [ "ge_hom_caster00" ] +ICCharacter = { } +ICCharacter["Name"] = "character" +ICCharacter["UnpackTo"] = None +ICCharacter["IsOptional"] = 0 +ICCharacter["IsIncremental"] = 1 +ICCharacter["Packages"] = [ ] +ICCharacter["Packages"] += [ [ "characters_swt", [ ] ] ] +ICCharacter["Packages"] += [ [ "characters_skeletons", [ ] ] ] +ICCharacter["Packages"] += [ [ "characters_shapes", [ ] ] ] +ICCharacter["Packages"] += [ [ "characters_animations", [ ] ] ] +ICCharacterMapsConditions = [ ] +for armor in ICCharacterArmors: + ICCharacterMapsConditions += [ "-ifnot" ] + ICCharacterMapsConditions += [ armor + "*" ] +ICCharacter["Packages"] += [ [ "characters_maps_hr", [ "characters_maps_hr.bnp" ] + ICCharacterMapsConditions, "characters.hlsbank" ] ] +for armor in ICCharacterArmors: + ICCharacter["Packages"] += [ [ "characters_maps_hr", [ "characters_maps_" + armor + "_hr.bnp", "-if", armor + "*" ], "characters.hlsbank" ] ] +InstallClientData += [ ICCharacter ] + +ICEsPrimesRacines = { } +ICEsPrimesRacines["Name"] = "es_primes_racines" +ICEsPrimesRacines["UnpackTo"] = None +ICEsPrimesRacines["IsOptional"] = 0 +ICEsPrimesRacines["IsIncremental"] = 1 +ICEsPrimesRacines["Packages"] = [ ] +ICEsPrimesRacines["Packages"] += [ [ "primes_racines_vegetable_sets", [ ] ] ] +ICEsPrimesRacines["Packages"] += [ [ "primes_racines_vegetables", [ ] ] ] +ICEsPrimesRacines["Packages"] += [ [ "primes_racines_tiles", [ ] ] ] +ICEsPrimesRacines["Packages"] += [ [ "primes_racines_shapes", [ ] ] ] +ICEsPrimesRacines["Packages"] += [ [ "primes_racines_pacs_prim", [ ] ] ] +ICEsPrimesRacines["Packages"] += [ [ "primes_racines_maps", [ ] ] ] +ICEsPrimesRacines["Packages"] += [ [ "primes_racines_lightmaps", [ ] ] ] +ICEsPrimesRacines["Packages"] += [ [ "primes_racines_displaces", [ ] ] ] +ICEsPrimesRacines["Packages"] += [ [ "primes_racines_bank", [ ] ] ] +InstallClientData += [ ICEsPrimesRacines ] + +ICEsDesert = { } +ICEsDesert["Name"] = "es_desert" +ICEsDesert["UnpackTo"] = None +ICEsDesert["IsOptional"] = 1 +ICEsDesert["IsIncremental"] = 1 +ICEsDesert["Packages"] = [ ] +ICEsDesert["Packages"] += [ [ "desert_vegetable_sets", [ ] ] ] +ICEsDesert["Packages"] += [ [ "desert_vegetables", [ ] ] ] +ICEsDesert["Packages"] += [ [ "desert_tiles", [ ] ] ] +ICEsDesert["Packages"] += [ [ "desert_shapes", [ ] ] ] +ICEsDesert["Packages"] += [ [ "desert_pacs_prim", [ ] ] ] +ICEsDesert["Packages"] += [ [ "desert_maps", [ ] ] ] +ICEsDesert["Packages"] += [ [ "desert_lightmaps", [ ] ] ] +ICEsDesert["Packages"] += [ [ "desert_displaces", [ ] ] ] +ICEsDesert["Packages"] += [ [ "desert_bank", [ ] ] ] +InstallClientData += [ ICEsDesert ] + +ICEsLacustre = { } +ICEsLacustre["Name"] = "es_lacustre" +ICEsLacustre["UnpackTo"] = None +ICEsLacustre["IsOptional"] = 1 +ICEsLacustre["IsIncremental"] = 1 +ICEsLacustre["Packages"] = [ ] +ICEsLacustre["Packages"] += [ [ "lacustre_vegetable_sets", [ ] ] ] +ICEsLacustre["Packages"] += [ [ "lacustre_vegetables", [ ] ] ] +ICEsLacustre["Packages"] += [ [ "lacustre_tiles", [ ] ] ] +ICEsLacustre["Packages"] += [ [ "lacustre_shapes", [ ] ] ] +ICEsLacustre["Packages"] += [ [ "lacustre_pacs_prim", [ ] ] ] +ICEsLacustre["Packages"] += [ [ "lacustre_maps", [ ] ] ] +ICEsLacustre["Packages"] += [ [ "lacustre_lightmaps", [ ] ] ] +ICEsLacustre["Packages"] += [ [ "lacustre_displaces", [ ] ] ] +ICEsLacustre["Packages"] += [ [ "lacustre_bank", [ ] ] ] +InstallClientData += [ ICEsLacustre ] + +ICEsJungle = { } +ICEsJungle["Name"] = "es_jungle" +ICEsJungle["UnpackTo"] = None +ICEsJungle["IsOptional"] = 1 +ICEsJungle["IsIncremental"] = 1 +ICEsJungle["Packages"] = [ ] +ICEsJungle["Packages"] += [ [ "jungle_vegetable_sets", [ ] ] ] +ICEsJungle["Packages"] += [ [ "jungle_vegetables", [ ] ] ] +ICEsJungle["Packages"] += [ [ "jungle_tiles", [ ] ] ] +ICEsJungle["Packages"] += [ [ "jungle_shapes", [ ] ] ] +ICEsJungle["Packages"] += [ [ "jungle_pacs_prim", [ ] ] ] +ICEsJungle["Packages"] += [ [ "jungle_maps", [ ] ] ] +ICEsJungle["Packages"] += [ [ "jungle_lightmaps", [ ] ] ] +ICEsJungle["Packages"] += [ [ "jungle_displaces", [ ] ] ] +ICEsJungle["Packages"] += [ [ "jungle_bank", [ ] ] ] +InstallClientData += [ ICEsJungle ] + +ICFyros = { } +ICFyros["Name"] = "fyros" +ICFyros["UnpackTo"] = None +ICFyros["IsOptional"] = 1 +ICFyros["IsIncremental"] = 1 +ICFyros["Packages"] = [ ] +ICFyros["Packages"] += [ [ "fyros_zones", [ ] ] ] +ICFyros["Packages"] += [ [ "fyros_shapes", [ ] ] ] +ICFyros["Packages"] += [ [ "fyros_pacs", [ ] ] ] +ICFyros["Packages"] += [ [ "fyros_maps", [ ] ] ] +ICFyros["Packages"] += [ [ "fyros_lightmaps", [ ] ] ] +ICFyros["Packages"] += [ [ "fyros_ig", [ ] ] ] +ICFyros["Packages"] += [ [ "fyros_newbie_zones", [ ] ] ] +ICFyros["Packages"] += [ [ "fyros_newbie_pacs", [ ] ] ] +ICFyros["Packages"] += [ [ "fyros_newbie_ig", [ ] ] ] +ICFyros["Packages"] += [ [ "fyros_island_zones", [ ] ] ] +ICFyros["Packages"] += [ [ "fyros_island_pacs", [ ] ] ] +ICFyros["Packages"] += [ [ "fyros_island_ig", [ ] ] ] +InstallClientData += [ ICFyros ] + +ICMatis = { } +ICMatis["Name"] = "matis" +ICMatis["UnpackTo"] = None +ICMatis["IsOptional"] = 1 +ICMatis["IsIncremental"] = 1 +ICMatis["Packages"] = [ ] +ICMatis["Packages"] += [ [ "matis_zones", [ ] ] ] +ICMatis["Packages"] += [ [ "matis_shapes", [ ] ] ] +ICMatis["Packages"] += [ [ "matis_pacs", [ ] ] ] +ICMatis["Packages"] += [ [ "matis_maps", [ ] ] ] +ICMatis["Packages"] += [ [ "matis_lightmaps", [ ] ] ] +ICMatis["Packages"] += [ [ "matis_ig", [ ] ] ] +ICMatis["Packages"] += [ [ "matis_island_zones", [ ] ] ] +ICMatis["Packages"] += [ [ "matis_island_pacs", [ ] ] ] +ICMatis["Packages"] += [ [ "matis_island_ig", [ ] ] ] +InstallClientData += [ ICMatis ] + +ICZorai = { } +ICZorai["Name"] = "zorai" +ICZorai["UnpackTo"] = None +ICZorai["IsOptional"] = 1 +ICZorai["IsIncremental"] = 1 +ICZorai["Packages"] = [ ] +ICZorai["Packages"] += [ [ "zorai_zones", [ ] ] ] +ICZorai["Packages"] += [ [ "zorai_shapes", [ ] ] ] +ICZorai["Packages"] += [ [ "zorai_pacs", [ ] ] ] +ICZorai["Packages"] += [ [ "zorai_maps", [ ] ] ] +ICZorai["Packages"] += [ [ "zorai_lightmaps", [ ] ] ] +ICZorai["Packages"] += [ [ "zorai_ig", [ ] ] ] +ICZorai["Packages"] += [ [ "zorai_island_zones", [ ] ] ] +ICZorai["Packages"] += [ [ "zorai_island_pacs", [ ] ] ] +ICZorai["Packages"] += [ [ "zorai_island_ig", [ ] ] ] +InstallClientData += [ ICZorai ] + +ICTryker = { } +ICTryker["Name"] = "tryker" +ICTryker["UnpackTo"] = None +ICTryker["IsOptional"] = 1 +ICTryker["IsIncremental"] = 1 +ICTryker["Packages"] = [ ] +ICTryker["Packages"] += [ [ "tryker_zones", [ ] ] ] +ICTryker["Packages"] += [ [ "tryker_shapes", [ ] ] ] +ICTryker["Packages"] += [ [ "tryker_pacs", [ ] ] ] +ICTryker["Packages"] += [ [ "tryker_maps", [ ] ] ] +ICTryker["Packages"] += [ [ "tryker_lightmaps", [ ] ] ] +ICTryker["Packages"] += [ [ "tryker_ig", [ ] ] ] +ICTryker["Packages"] += [ [ "tryker_newbie_zones", [ ] ] ] +ICTryker["Packages"] += [ [ "tryker_newbie_shapes", [ ] ] ] +ICTryker["Packages"] += [ [ "tryker_newbie_pacs", [ ] ] ] +ICTryker["Packages"] += [ [ "tryker_newbie_ig", [ ] ] ] +ICTryker["Packages"] += [ [ "tryker_island_zones", [ ] ] ] +ICTryker["Packages"] += [ [ "tryker_island_shapes", [ ] ] ] +ICTryker["Packages"] += [ [ "tryker_island_pacs", [ ] ] ] +ICTryker["Packages"] += [ [ "tryker_island_ig", [ ] ] ] +InstallClientData += [ ICTryker ] + +ICSources = { } +ICSources["Name"] = "sources" +ICSources["UnpackTo"] = None +ICSources["IsOptional"] = 1 +ICSources["IsIncremental"] = 1 +ICSources["Packages"] = [ ] +ICSources["Packages"] += [ [ "sources_zones", [ ] ] ] +ICSources["Packages"] += [ [ "sources_shapes", [ ] ] ] +ICSources["Packages"] += [ [ "sources_pacs", [ ] ] ] +ICSources["Packages"] += [ [ "sources_maps", [ ] ] ] +ICSources["Packages"] += [ [ "sources_lightmaps", [ ] ] ] +ICSources["Packages"] += [ [ "sources_ig", [ ] ] ] +InstallClientData += [ ICSources ] + +ICRouteGouffre = { } +ICRouteGouffre["Name"] = "route_gouffre" +ICRouteGouffre["UnpackTo"] = None +ICRouteGouffre["IsOptional"] = 1 +ICRouteGouffre["IsIncremental"] = 1 +ICRouteGouffre["Packages"] = [ ] +ICRouteGouffre["Packages"] += [ [ "route_gouffre_zones", [ ] ] ] +ICRouteGouffre["Packages"] += [ [ "route_gouffre_shapes", [ ] ] ] +ICRouteGouffre["Packages"] += [ [ "route_gouffre_pacs", [ ] ] ] +ICRouteGouffre["Packages"] += [ [ "route_gouffre_maps", [ ] ] ] +ICRouteGouffre["Packages"] += [ [ "route_gouffre_lightmaps", [ ] ] ] +ICRouteGouffre["Packages"] += [ [ "route_gouffre_ig", [ ] ] ] +InstallClientData += [ ICRouteGouffre ] + +ICBagne = { } +ICBagne["Name"] = "bagne" +ICBagne["UnpackTo"] = None +ICBagne["IsOptional"] = 1 +ICBagne["IsIncremental"] = 1 +ICBagne["Packages"] = [ ] +ICBagne["Packages"] += [ [ "bagne_zones", [ ] ] ] +ICBagne["Packages"] += [ [ "bagne_shapes", [ ] ] ] +ICBagne["Packages"] += [ [ "bagne_pacs", [ ] ] ] +ICBagne["Packages"] += [ [ "bagne_maps", [ ] ] ] +ICBagne["Packages"] += [ [ "bagne_lightmaps", [ ] ] ] +ICBagne["Packages"] += [ [ "bagne_ig", [ ] ] ] +InstallClientData += [ ICBagne ] + +ICTerre = { } +ICTerre["Name"] = "terre" +ICTerre["UnpackTo"] = None +ICTerre["IsOptional"] = 1 +ICTerre["IsIncremental"] = 1 +ICTerre["Packages"] = [ ] +ICTerre["Packages"] += [ [ "terre_zones", [ ] ] ] +ICTerre["Packages"] += [ [ "terre_shapes", [ ] ] ] +ICTerre["Packages"] += [ [ "terre_pacs", [ ] ] ] +ICTerre["Packages"] += [ [ "terre_maps", [ ] ] ] +ICTerre["Packages"] += [ [ "terre_lightmaps", [ ] ] ] +ICTerre["Packages"] += [ [ "terre_ig", [ ] ] ] +InstallClientData += [ ICTerre ] + +ICNexus = { } +ICNexus["Name"] = "nexus" +ICNexus["UnpackTo"] = None +ICNexus["IsOptional"] = 1 +ICNexus["IsIncremental"] = 1 +ICNexus["Packages"] = [ ] +ICNexus["Packages"] += [ [ "nexus_zones", [ ] ] ] +ICNexus["Packages"] += [ [ "nexus_shapes", [ ] ] ] +ICNexus["Packages"] += [ [ "nexus_pacs", [ ] ] ] +ICNexus["Packages"] += [ [ "nexus_maps", [ ] ] ] +ICNexus["Packages"] += [ [ "nexus_lightmaps", [ ] ] ] +ICNexus["Packages"] += [ [ "nexus_ig", [ ] ] ] +InstallClientData += [ ICNexus ] + +ICNewbieland = { } +ICNewbieland["Name"] = "newbieland" +ICNewbieland["UnpackTo"] = None +ICNewbieland["IsOptional"] = 1 +ICNewbieland["IsIncremental"] = 1 +ICNewbieland["Packages"] = [ ] +ICNewbieland["Packages"] += [ [ "newbieland_zones", [ ] ] ] +ICNewbieland["Packages"] += [ [ "newbieland_shapes", [ ] ] ] +ICNewbieland["Packages"] += [ [ "newbieland_pacs", [ ] ] ] +ICNewbieland["Packages"] += [ [ "newbieland_maps", [ ] ] ] +ICNewbieland["Packages"] += [ [ "newbieland_ig", [ ] ] ] +InstallClientData += [ ICNewbieland ] + +ICIndoors = { } +ICIndoors["Name"] = "indoors" +ICIndoors["UnpackTo"] = None +ICIndoors["IsOptional"] = 1 +ICIndoors["IsIncremental"] = 1 +ICIndoors["Packages"] = [ ] +ICIndoors["Packages"] += [ [ "indoors_shapes", [ ] ] ] +ICIndoors["Packages"] += [ [ "indoors_pacs", [ ] ] ] +ICIndoors["Packages"] += [ [ "indoors_lightmaps", [ ] ] ] +ICIndoors["Packages"] += [ [ "indoors_ig", [ ] ] ] +InstallClientData += [ ICIndoors ] + +ICR2 = { } +ICR2["Name"] = "r2" +ICR2["UnpackTo"] = None +ICR2["IsOptional"] = 1 +ICR2["IsIncremental"] = 1 +ICR2["Packages"] = [ ] +ICR2["Packages"] += [ [ "r2_misc", [ ] ] ] +ICR2["Packages"] += [ [ "r2_jungle", [ ] ] ] +ICR2["Packages"] += [ [ "r2_lakes", [ ] ] ] +ICR2["Packages"] += [ [ "r2_desert", [ ] ] ] +ICR2["Packages"] += [ [ "r2_roots", [ ] ] ] +ICR2["Packages"] += [ [ "r2_forest", [ ] ] ] +ICR2["Packages"] += [ [ "r2_lakes2", [ ] ] ] +ICR2["Packages"] += [ [ "r2_jungle2", [ ] ] ] +ICR2["Packages"] += [ [ "r2_forest2", [ ] ] ] +ICR2["Packages"] += [ [ "r2_desert2", [ ] ] ] +ICR2["Packages"] += [ [ "r2_roots2", [ ] ] ] +ICR2["Packages"] += [ [ "r2_forest_maps", [ ] ] ] +ICR2["Packages"] += [ [ "r2_desert_maps", [ ] ] ] +ICR2["Packages"] += [ [ "r2_roots_maps", [ ] ] ] +ICR2["Packages"] += [ [ "r2_lakes_maps", [ ] ] ] +ICR2["Packages"] += [ [ "r2_jungle_maps", [ ] ] ] +ICR2["Packages"] += [ [ "r2_roots_pz", [ ] ] ] +ICR2["Packages"] += [ [ "r2_lakes_pz", [ ] ] ] +ICR2["Packages"] += [ [ "r2_jungle_pz", [ ] ] ] +ICR2["Packages"] += [ [ "r2_forest_pz", [ ] ] ] +ICR2["Packages"] += [ [ "r2_desert_pz", [ ] ] ] +InstallClientData += [ ICR2 ] + + +# end of file diff --git a/code/ryzom/tools/client/client_config/StdAfx.cpp b/code/ryzom/tools/client/client_config/StdAfx.cpp index 448eeb2bf..cb1bfa6d6 100644 --- a/code/ryzom/tools/client/client_config/StdAfx.cpp +++ b/code/ryzom/tools/client/client_config/StdAfx.cpp @@ -1,21 +1,21 @@ -// 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 . - -// stdafx.cpp : source file that includes just the standard includes -// client_config.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" +// 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 . + +// stdafx.cpp : source file that includes just the standard includes +// client_config.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" diff --git a/code/ryzom/tools/client/client_config/StdAfx.h b/code/ryzom/tools/client/client_config/StdAfx.h index 32cf5815f..ae8b23f92 100644 --- a/code/ryzom/tools/client/client_config/StdAfx.h +++ b/code/ryzom/tools/client/client_config/StdAfx.h @@ -1,61 +1,61 @@ -// 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 . - -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#if !defined(AFX_STDAFX_H__DD0A8599_6A9E_47AE_BE5E_50A017C1FA9C__INCLUDED_) -#define AFX_STDAFX_H__DD0A8599_6A9E_47AE_BE5E_50A017C1FA9C__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers - -#include "nel/misc/types_nl.h" - -#include // MFC core and standard components -#include // MFC extensions -#include // MFC Automation classes -#include // MFC support for Internet Explorer 4 Common Controls -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#undef min -#undef max - -#include -#include - -#include "nel/misc/config_file.h" -#include "nel/misc/system_info.h" -#include "nel/misc/path.h" -#include "nel/misc/i18n.h" -#include "nel/misc/diff_tool.h" -#include "nel/3d/dru.h" -#include -#include -#include -#include - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__DD0A8599_6A9E_47AE_BE5E_50A017C1FA9C__INCLUDED_) +// 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 . + +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__DD0A8599_6A9E_47AE_BE5E_50A017C1FA9C__INCLUDED_) +#define AFX_STDAFX_H__DD0A8599_6A9E_47AE_BE5E_50A017C1FA9C__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers + +#include "nel/misc/types_nl.h" + +#include // MFC core and standard components +#include // MFC extensions +#include // MFC Automation classes +#include // MFC support for Internet Explorer 4 Common Controls +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC support for Windows Common Controls +#endif // _AFX_NO_AFXCMN_SUPPORT + +#undef min +#undef max + +#include +#include + +#include "nel/misc/config_file.h" +#include "nel/misc/system_info.h" +#include "nel/misc/path.h" +#include "nel/misc/i18n.h" +#include "nel/misc/diff_tool.h" +#include "nel/3d/dru.h" +#include +#include +#include +#include + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__DD0A8599_6A9E_47AE_BE5E_50A017C1FA9C__INCLUDED_) diff --git a/code/ryzom/tools/client/client_config/bar.cpp b/code/ryzom/tools/client/client_config/bar.cpp index d0ef68ec8..cfd87abf6 100644 --- a/code/ryzom/tools/client/client_config/bar.cpp +++ b/code/ryzom/tools/client/client_config/bar.cpp @@ -1,85 +1,85 @@ -// 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 . - -// bar.cpp : implementation file -// - -#include "stdafx.h" -#include "client_config.h" -#include "bar.h" - -// *************************************************************************** -// CBar -// *************************************************************************** - -CBar::CBar() -{ -} - -CBar::~CBar() -{ -} - - -BEGIN_MESSAGE_MAP(CBar, CWnd) - //{{AFX_MSG_MAP(CBar) - ON_WM_PAINT() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - -// *************************************************************************** -// CBar message handlers -// *************************************************************************** - -void CBar::OnPaint() -{ - CPaintDC dc(this); // device context for painting - - RECT client; - GetClientRect (&client); - - CPen hilight (PS_SOLID, 1, GetSysColor (COLOR_3DHILIGHT)); - CPen shadow (PS_SOLID, 1, GetSysColor (COLOR_3DSHADOW)); - - if (client.right - client.left > client.bottom - client.top) - { - dc.SelectObject (shadow); - dc.MoveTo (client.left, client.top); - dc.LineTo (client.right, client.top); - dc.SelectObject (hilight); - dc.MoveTo (client.left, client.bottom); - dc.LineTo (client.right, client.bottom); - } - else - { - dc.SelectObject (hilight); - dc.MoveTo (client.left, client.top); - dc.LineTo (client.left, client.bottom); - dc.SelectObject (shadow); - dc.MoveTo (client.right, client.top); - dc.LineTo (client.right, client.bottom); - } - - // Do not call CWnd::OnPaint() for painting messages -} - -// *************************************************************************** - -BOOL CBar::Create (CRect &rect, CWnd *parent) -{ - return CWnd::Create ("Static", "", WS_CHILD|WS_VISIBLE, rect, parent, 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 . + +// bar.cpp : implementation file +// + +#include "stdafx.h" +#include "client_config.h" +#include "bar.h" + +// *************************************************************************** +// CBar +// *************************************************************************** + +CBar::CBar() +{ +} + +CBar::~CBar() +{ +} + + +BEGIN_MESSAGE_MAP(CBar, CWnd) + //{{AFX_MSG_MAP(CBar) + ON_WM_PAINT() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + + +// *************************************************************************** +// CBar message handlers +// *************************************************************************** + +void CBar::OnPaint() +{ + CPaintDC dc(this); // device context for painting + + RECT client; + GetClientRect (&client); + + CPen hilight (PS_SOLID, 1, GetSysColor (COLOR_3DHILIGHT)); + CPen shadow (PS_SOLID, 1, GetSysColor (COLOR_3DSHADOW)); + + if (client.right - client.left > client.bottom - client.top) + { + dc.SelectObject (shadow); + dc.MoveTo (client.left, client.top); + dc.LineTo (client.right, client.top); + dc.SelectObject (hilight); + dc.MoveTo (client.left, client.bottom); + dc.LineTo (client.right, client.bottom); + } + else + { + dc.SelectObject (hilight); + dc.MoveTo (client.left, client.top); + dc.LineTo (client.left, client.bottom); + dc.SelectObject (shadow); + dc.MoveTo (client.right, client.top); + dc.LineTo (client.right, client.bottom); + } + + // Do not call CWnd::OnPaint() for painting messages +} + +// *************************************************************************** + +BOOL CBar::Create (CRect &rect, CWnd *parent) +{ + return CWnd::Create ("Static", "", WS_CHILD|WS_VISIBLE, rect, parent, 0); +} diff --git a/code/ryzom/tools/client/client_config/bar.h b/code/ryzom/tools/client/client_config/bar.h index 0b73738b8..1b50b291f 100644 --- a/code/ryzom/tools/client/client_config/bar.h +++ b/code/ryzom/tools/client/client_config/bar.h @@ -1,65 +1,65 @@ -// 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 . - -#if !defined(AFX_BAR_H__1AEEE6F6_7AE1_49AC_A3CB_576C63140C06__INCLUDED_) -#define AFX_BAR_H__1AEEE6F6_7AE1_49AC_A3CB_576C63140C06__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// bar.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// CBar window - -class CBar : public CWnd -{ -// Construction -public: - CBar(); - -// Attributes -public: - - BOOL Create (CRect &rect, CWnd *parent); - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CBar) - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CBar(); - - // Generated message map functions -protected: - //{{AFX_MSG(CBar) - afx_msg void OnPaint(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_BAR_H__1AEEE6F6_7AE1_49AC_A3CB_576C63140C06__INCLUDED_) +// 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 . + +#if !defined(AFX_BAR_H__1AEEE6F6_7AE1_49AC_A3CB_576C63140C06__INCLUDED_) +#define AFX_BAR_H__1AEEE6F6_7AE1_49AC_A3CB_576C63140C06__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// bar.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CBar window + +class CBar : public CWnd +{ +// Construction +public: + CBar(); + +// Attributes +public: + + BOOL Create (CRect &rect, CWnd *parent); + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CBar) + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CBar(); + + // Generated message map functions +protected: + //{{AFX_MSG(CBar) + afx_msg void OnPaint(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_BAR_H__1AEEE6F6_7AE1_49AC_A3CB_576C63140C06__INCLUDED_) diff --git a/code/ryzom/tools/client/client_config/base_dialog.cpp b/code/ryzom/tools/client/client_config/base_dialog.cpp index b8008dae1..96bba0e4c 100644 --- a/code/ryzom/tools/client/client_config/base_dialog.cpp +++ b/code/ryzom/tools/client/client_config/base_dialog.cpp @@ -1,33 +1,33 @@ -// 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 "stdafx.h" -#include "base_dialog.h" -#include "client_config.h" -#include "client_configDlg.h" - -void CBaseDialog::OnOK () -{ - ((CClient_configDlg*)theApp.m_pMainWnd)->OnOK (); -} - -void CBaseDialog::OnCancel () -{ - ((CClient_configDlg*)theApp.m_pMainWnd)->OnCancel (); -} - +// 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 "stdafx.h" +#include "base_dialog.h" +#include "client_config.h" +#include "client_configDlg.h" + +void CBaseDialog::OnOK () +{ + ((CClient_configDlg*)theApp.m_pMainWnd)->OnOK (); +} + +void CBaseDialog::OnCancel () +{ + ((CClient_configDlg*)theApp.m_pMainWnd)->OnCancel (); +} + diff --git a/code/ryzom/tools/client/client_config/base_dialog.h b/code/ryzom/tools/client/client_config/base_dialog.h index 4082968b4..a99711cfe 100644 --- a/code/ryzom/tools/client/client_config/base_dialog.h +++ b/code/ryzom/tools/client/client_config/base_dialog.h @@ -1,47 +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 NL_BASE_DIALOG_H -#define NL_BASE_DIALOG_H - -#include "nel/misc/types_nl.h" - - -/** - * Base dialog for option dialogs - * - * \author Cyril 'Hulud' Corvazier - * \author Nevrax France - * \date 2003 - */ -class CBaseDialog : public CDialog -{ -public: - - /// Constructor - CBaseDialog (uint id, CWnd* pParent = NULL) : CDialog(id, pParent) {} - - /// On ok - virtual void OnOK (); - virtual void OnCancel (); -}; - - -#endif // NL_BASE_DIALOG_H - -/* End of base_dialog.h */ +// 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_BASE_DIALOG_H +#define NL_BASE_DIALOG_H + +#include "nel/misc/types_nl.h" + + +/** + * Base dialog for option dialogs + * + * \author Cyril 'Hulud' Corvazier + * \author Nevrax France + * \date 2003 + */ +class CBaseDialog : public CDialog +{ +public: + + /// Constructor + CBaseDialog (uint id, CWnd* pParent = NULL) : CDialog(id, pParent) {} + + /// On ok + virtual void OnOK (); + virtual void OnCancel (); +}; + + +#endif // NL_BASE_DIALOG_H + +/* End of base_dialog.h */ diff --git a/code/ryzom/tools/client/client_config/cfg_file.cpp b/code/ryzom/tools/client/client_config/cfg_file.cpp index 6c7e13768..8d66ff4f9 100644 --- a/code/ryzom/tools/client/client_config/cfg_file.cpp +++ b/code/ryzom/tools/client/client_config/cfg_file.cpp @@ -1,749 +1,749 @@ -// 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 "stdafx.h" -#include "cfg_file.h" -#include "client_config.h" -#include "client_configDlg.h" -#include "display_dlg.h" - -using namespace std; -using namespace NLMISC; - -CConfigFile ConfigFile; - -// Translation windows map -std::map HwndMap; - -// *************************************************************************** - -string GetString (const char *var) -{ - // Get the variable pointer - CConfigFile::CVar *variable = ConfigFile.getVarPtr (var); - - // Available ? - if (variable) - { - return variable->asString (); - } - else - { - theApp.error ("Can't find the variable "+(ucstring)var+" in "CONFIG_FILE_NAME); - return ""; - } -} - -// *************************************************************************** - -sint GetInt (const char *var) -{ - // Get the variable pointer - CConfigFile::CVar *variable = ConfigFile.getVarPtr (var); - - // Available ? - if (variable) - { - return variable->asInt (); - } - else - { - theApp.error ("Can't find the variable "+(ucstring)var+" in "CONFIG_FILE_NAME); - return -1; - } -} - -// *************************************************************************** - -float GetFloat (const char *var) -{ - // Get the variable pointer - CConfigFile::CVar *variable = ConfigFile.getVarPtr (var); - - // Available ? - if (variable) - { - return variable->asFloat (); - } - else - { - theApp.error ("Can't find the variable "+(ucstring)var+" in "CONFIG_FILE_NAME); - return -1; - } -} - -// *************************************************************************** - -bool GetBool (const char *var) -{ - // Get the variable pointer - CConfigFile::CVar *variable = ConfigFile.getVarPtr (var); - - // Available ? - if (variable) - { - string _bool = toLower (variable->asString ()); - if (_bool == "true") - return true; - if (_bool == "false") - return false; - theApp.error ("The variable "+(ucstring)var+" is not a boolean "CONFIG_FILE_NAME); - return false; - } - else - { - theApp.error ("Can't find the variable "+(ucstring)var+" in "CONFIG_FILE_NAME); - return false; - } -} - -// *************************************************************************** - -void SetString (const char *var, const char *value) -{ - // Get the variable pointer - CConfigFile::CVar *variable = ConfigFile.getVarPtr (var); - - // Available ? - if (variable) - { - if (variable->Type == CConfigFile::CVar::T_STRING) - { - if (variable->asString () != value) - variable->setAsString (value); - } - else - { - theApp.error ("The variable "+(ucstring)var+" is not a string "CONFIG_FILE_NAME); - } - } - else - { - theApp.error ("Can't find the variable "+(ucstring)var+" in "CONFIG_FILE_NAME); - } -} - -// *************************************************************************** - -void SetBool (const char *var, bool value) -{ - // Get the variable pointer - CConfigFile::CVar *variable = ConfigFile.getVarPtr (var); - - // Available ? - if (variable) - { - if (variable->Type == CConfigFile::CVar::T_STRING) - { - const char *valueToSet = value?"true":"false"; - if (variable->asString () != valueToSet) - variable->setAsString (valueToSet); - } - else - { - theApp.error ("The variable "+(ucstring)var+" is not a string "CONFIG_FILE_NAME); - } - } - else - { - theApp.error ("Can't find the variable "+(ucstring)var+" in "CONFIG_FILE_NAME); - } -} - -// *************************************************************************** - -void SetInt (const char *var, sint value) -{ - // Get the variable pointer - CConfigFile::CVar *variable = ConfigFile.getVarPtr (var); - - // Available ? - if (variable) - { - if (variable->Type == CConfigFile::CVar::T_INT) - { - if (variable->asInt () != value) - variable->setAsInt (value); - } - else - { - theApp.error ("The variable "+(ucstring)var+" is not an integer "CONFIG_FILE_NAME); - } - } - else - { - theApp.error ("Can't find the variable "+(ucstring)var+" in "CONFIG_FILE_NAME); - } -} - -// *************************************************************************** - -void SetFloat (const char *var, float value) -{ - // Get the variable pointer - CConfigFile::CVar *variable = ConfigFile.getVarPtr (var); - - // Available ? - if (variable) - { - if (variable->Type == CConfigFile::CVar::T_REAL) - { - if (fabs (variable->asFloat () - value) > 0.000001f) - variable->setAsFloat (value); - } - else - { - theApp.error ("The variable "+(ucstring)var+" is not a float "CONFIG_FILE_NAME); - } - } - else - { - theApp.error ("Can't find the variable "+(ucstring)var+" in "CONFIG_FILE_NAME); - } -} - -// *************************************************************************** - -void SetToConfigFile () -{ - // Get the window pointer - CClient_configDlg *dlg = (CClient_configDlg*)theApp.m_pMainWnd; - dlg->UpdateData (TRUE); - - // *** General dialog - - // Get the dialog - CGeneralDlg &general = dlg->GeneralDlg; - SetInt ("SaveConfig", (int)general.SaveConfig); - SetString ("LanguageCode", (general.Language==2)?"de":(general.Language==1)?"fr":"en"); - if (general.Sleep) - SetInt ("ProcessPriority", -1); - else - SetInt ("ProcessPriority", 0); - - // *** Display dialog - - // Get the dialog - CDisplayDlg &display = dlg->DisplayDlg; - SetInt ("PositionX", display.PositionX); - SetInt ("PositionY", display.PositionY); - SetInt ("FullScreen", !display.Windowed); - switch(display.DriverChoiceMode) - { - case CDisplayDlg::DrvChooseDirect3D: SetString("Driver3D", "Direct3D"); break; - case CDisplayDlg::DrvChooseOpenGL: SetString("Driver3D", "OpenGL"); break; - case CDisplayDlg::DrvChooseAuto: SetString("Driver3D", "Auto"); break; - } - if (display.Windowed) - { - SetInt ("Width", display.Width); - SetInt ("Height", display.Height); - SetInt ("Depth", 32); - } - else - { - // Mode valid ? - if (display.DriverChoiceMode != CDisplayDlg::DrvChooseUnknwown) - { - const CVideoMode &videoMode = VideoModes[display.getActualDriver()][display.Mode]; - SetInt ("Width", videoMode.Width); - SetInt ("Height", videoMode.Height); - SetInt ("Depth", 32); - SetInt ("Frequency", videoMode.Frequency); - } - } - - // *** Display details dialog - - // Get the dialog - CDisplayDetailsDlg &displayDetails = dlg->DisplayDetailsDlg; - SetInt ("HDEntityTexture", displayDetails.TextureQualityInt==2); - SetInt ("DivideTextureSizeBy2", displayDetails.TextureQualityInt==0); - SetFloat ("LandscapeThreshold", QualityToLandscapeThreshold[displayDetails.LandscapeQualityInt]); - SetFloat ("Vision", QualityToZFar[displayDetails.LandscapeQualityInt]); - SetFloat ("LandscapeTileNear", QualityToLandscapeTileNear[displayDetails.LandscapeQualityInt]); - SetInt ("SkinNbMaxPoly", QualityToSkinNbMaxPoly[displayDetails.CharacterQualityInt]); - SetInt ("NbMaxSkeletonNotCLod", QualityToNbMaxSkeletonNotCLod[displayDetails.CharacterQualityInt]); - SetInt ("FxNbMaxPoly", QualityToFxNbMaxPoly[displayDetails.FXQualityInt]); - - // *** Display details dialog - - // Get the dialog - CDisplayAdvancedDlg &displayAdvanced = dlg->DisplayAdvancedDlg; - SetInt ("ForceDXTC", !displayAdvanced.DisableDXTC); - SetInt ("DisableVtxProgram", (int)displayAdvanced.DisableVertexProgram); - SetInt ("DisableVtxAGP", (int)displayAdvanced.DisableAGPVertices); - SetInt ("DisableTextureShdr", (int)displayAdvanced.DisableTextureShaders); - - // *** Sound dialog - - // Get the dialog - CSoundDlg &sound = dlg->SoundDlg; - SetInt ("SoundOn", (int)sound.SoundOn); - SetInt ("UseEax", sound.EAX ? true : false); - SetInt ("MaxTrack", sound.getAsNumSoundBuffer()); - SetStringDriverSound(sound.FMod ? "FMod" : "Auto"); - SetInt ("SoundForceSoftwareBuffer", sound.ForceSoundSoft? true : false); -} - -// *************************************************************************** - -uint getFullscreenMode (uint driver, const CVideoMode &mode) -{ - // Look for the valid mode ? - uint i; - for (i=0; iGeneralDlg; - general.UpdateData (); - - // *** General dialog - general.SaveConfig = GetInt ("SaveConfig"); - string lang = GetString ("LanguageCode"); - (lang == "de")?general.Language=2:(lang == "fr")?general.Language=1:general.Language=0; - - int sleep = GetInt ("ProcessPriority"); - if (sleep != -1) - { - general.Sleep = 0; - } - else - { - general.Sleep = -1; - } - general.UpdateData (FALSE); - - // *** Display dialog - - CDisplayDlg &display = dlg->DisplayDlg; - display.UpdateData (); - display.Windowed = !GetInt ("FullScreen"); - display.Width = GetInt ("Width"); - display.Height = GetInt ("Height"); - display.PositionX = GetInt ("PositionX"); - display.PositionY = GetInt ("PositionY"); - std::string driverMode = GetString("Driver3D"); - if (nlstricmp(driverMode, "Auto") == 0 || nlstricmp(driverMode, "0") == 0) display.DriverChoiceMode = CDisplayDlg::DrvChooseAuto; - else if (nlstricmp(driverMode, "OpenGL") == 0 || nlstricmp(driverMode, "1") == 0) display.DriverChoiceMode = CDisplayDlg::DrvChooseOpenGL; - else if (nlstricmp(driverMode, "Direct3D") == 0 || nlstricmp(driverMode, "2") == 0) display.DriverChoiceMode = CDisplayDlg::DrvChooseDirect3D; - else display.DriverChoiceMode = CDisplayDlg::DrvChooseAuto; - display.Mode = -1; - // The video mode - CVideoMode mode; - mode.Width = display.Width; - mode.Height = display.Height; - mode.ColorDepth = 32; - mode.Frequency = GetInt ("Frequency"); - - // Look for the valid mode ? - uint i; - CDisplayDlg::TDriver actualDriver = display.getActualDriver(); - for (i=0; iDisplayDetailsDlg; - int hdTextureInstalled = GetInt ("HDTextureInstalled"); - displayDetails.UpdateData (); - displayDetails.MaxTextureQuality= hdTextureInstalled?2:1; - // NB: if the player changes its client.cfg, mixing HDEntityTexture=1 and DivideTextureSizeBy2=1, it will - // result to a low quality! - if(GetInt ("DivideTextureSizeBy2")) - displayDetails.TextureQualityInt = 0; - else if(GetInt ("HDEntityTexture") && hdTextureInstalled) - displayDetails.TextureQualityInt = 2; - else - displayDetails.TextureQualityInt = 1; - displayDetails.LandscapeQualityInt = GetQuality (QualityToLandscapeThreshold, GetFloat ("LandscapeThreshold")); - displayDetails.FXQualityInt = GetQuality (QualityToFxNbMaxPoly, GetInt ("FxNbMaxPoly")); - // minimize quality according to NbMaxSkeletonNotCLod and SkinNbMaxPoly - displayDetails.CharacterQualityInt = GetQuality (QualityToSkinNbMaxPoly, GetInt ("SkinNbMaxPoly")); - displayDetails.CharacterQualityInt = min(displayDetails.CharacterQualityInt, GetQuality (QualityToNbMaxSkeletonNotCLod, GetInt ("NbMaxSkeletonNotCLod"))); - displayDetails.updateState (); - displayDetails.UpdateData (FALSE); - - // *** Display advanced dialog - - CDisplayAdvancedDlg &displayAdvanced = dlg->DisplayAdvancedDlg; - displayAdvanced.UpdateData (); - displayAdvanced.DisableDXTC = !GetInt ("ForceDXTC"); - displayAdvanced.DisableVertexProgram = GetInt ("DisableVtxProgram") ? TRUE : FALSE; - displayAdvanced.DisableAGPVertices = GetInt ("DisableVtxAGP") ? TRUE : FALSE; - displayAdvanced.DisableTextureShaders = GetInt ("DisableTextureShdr") ? TRUE : FALSE; - displayAdvanced.UpdateData (FALSE); - - // *** Sound dialog - - // Get the dialog - CSoundDlg &sound = dlg->SoundDlg; - sound.UpdateData (); - sound.SoundOn = GetInt ("SoundOn"); - sound.EAX = GetInt ("UseEax") ? TRUE : FALSE; - sound.FMod = GetStringDriverSound()=="FMod" ? TRUE : FALSE; - sound.ForceSoundSoft = GetInt ("SoundForceSoftwareBuffer") ? TRUE : FALSE; - sound.setAsNumSoundBuffer( GetInt ("MaxTrack") ); - sound.updateState (); - sound.UpdateData (FALSE); -} - -// *************************************************************************** - -bool LoadConfigFile () -{ - // Read the file - try - { - ConfigFile.load (CONFIG_FILE_NAME); - } - catch (Exception &e) - { - theApp.error ("Error reading the file "CONFIG_FILE_NAME" : "+string (e.what ())); - return false; - } - return true; -} - -// *************************************************************************** - -bool SaveConfigFile () -{ - // Read the file - try - { - ConfigFile.save (); - } - catch (Exception &e) - { - theApp.error (CI18N::get ("uiConfigErrorWritingTheFile")+" "CONFIG_FILE_NAME" : "+string (e.what ())); - return false; - } - return true; -} - -// *************************************************************************** - -void InvalidateConfig () -{ - theApp.Modified = true; - - // Get the window pointer - CClient_configDlg *dlg = (CClient_configDlg*)theApp.m_pMainWnd; - dlg->ApplyCtrl.EnableWindow (TRUE); - - // Set the title - setWindowText(*dlg, (WCHAR*)(CI18N::get ("uiConfigTitle") + " *").c_str()); -} - -// *************************************************************************** - -void ResetConfigFile () -{ - // Clear the config file - ConfigFile.clear (); - ConfigFile.reparse (/*CONFIG_DEFAULT_FILE_NAME*/); - CConfigFile::CVar var; - var.Type = CConfigFile::CVar::T_STRING; - var.setAsString (CONFIG_DEFAULT_FILE_NAME); - CConfigFile::CVar *newVar = ConfigFile.insertVar ("RootConfigFilename", var); -} - -// *************************************************************************** - -void MergeConfigFile (CConfigFile &configFile) -{ - // For each variable in the new config file - uint count = configFile.getNumVar (); - uint i; - for (i=0; iName, *src); - if ((src->Type == CConfigFile::CVar::T_INT) && (dest->Type == CConfigFile::CVar::T_INT) || - (src->Type == CConfigFile::CVar::T_REAL) && (dest->Type == CConfigFile::CVar::T_INT) || - (src->Type == CConfigFile::CVar::T_INT) && (dest->Type == CConfigFile::CVar::T_REAL) || - (src->Type == CConfigFile::CVar::T_REAL) && (dest->Type == CConfigFile::CVar::T_REAL) || - (src->Type == CConfigFile::CVar::T_STRING) && (dest->Type == CConfigFile::CVar::T_STRING)) - { - // Get the method for the merge - TMergeMethod merge = GetMergeMethod (src->Name.c_str ()); - if (src->Type == CConfigFile::CVar::T_INT) - { - if (dest->Root) - { - SetInt (src->Name.c_str (), src->asInt()); - } - else - { - if (merge == PreferInferior) - SetInt (src->Name.c_str (), min (src->asInt(), dest->asInt())); - else if (merge == PreferSuperior) - SetInt (src->Name.c_str (), max (src->asInt(), dest->asInt())); - else if (merge == PreferTrue) - SetInt (src->Name.c_str (), (int)((src->asInt()!=0)||(dest->asInt()!=0))); - else if (merge == PreferFalse) - SetInt (src->Name.c_str (), (int)((src->asInt()!=0)&&(dest->asInt()!=0))); - } - } - else if (src->Type == CConfigFile::CVar::T_REAL) - { - if (dest->Root) - { - SetFloat (src->Name.c_str (), src->asFloat()); - } - else - { - if (merge == PreferInferior) - SetFloat (src->Name.c_str (), min (src->asFloat(), dest->asFloat())); - else if (merge == PreferSuperior) - SetFloat (src->Name.c_str (), max (src->asFloat(), dest->asFloat())); - else if (merge == PreferTrue) - SetFloat (src->Name.c_str (), (float)((src->asFloat()!=0.f)||(dest->asFloat()!=0.f))); - else if (merge == PreferFalse) - SetFloat (src->Name.c_str (), (float)((src->asFloat()!=0.f)&&(dest->asFloat()!=0.f))); - } - } - else if (src->Type == CConfigFile::CVar::T_STRING) - { - if (dest->Root) - { - SetString (src->Name.c_str (), src->asString().c_str ()); - } - else - { - if (merge == PreferTrue) - SetBool (src->Name.c_str (), (src->asString()!="false")||(dest->asString()!="true")); - else if (merge == PreferFalse) - SetBool (src->Name.c_str (), (src->asString()!="false")&&(dest->asString()!="true")); - else - SetString (src->Name.c_str (), src->asString().c_str ()); - } - } - } - } -} - -// *************************************************************************** - -void ResetConfigFileToDefault () -{ - // For each variable not ROOT in the current config file - uint count = ConfigFile.getNumVar (); - uint i; - for (i=0; iName=="HDTextureInstalled") - continue; - - // Get the variable from default config file - CConfigFile::CVar *src = ConfigFileDefault.getVarPtr (dest->Name); - - // if default exist and cur not already default - if ( src && !dest->Root && - ((src->Type == CConfigFile::CVar::T_INT) && (dest->Type == CConfigFile::CVar::T_INT) || - (src->Type == CConfigFile::CVar::T_REAL) && (dest->Type == CConfigFile::CVar::T_INT) || - (src->Type == CConfigFile::CVar::T_INT) && (dest->Type == CConfigFile::CVar::T_REAL) || - (src->Type == CConfigFile::CVar::T_REAL) && (dest->Type == CConfigFile::CVar::T_REAL) || - (src->Type == CConfigFile::CVar::T_STRING) && (dest->Type == CConfigFile::CVar::T_STRING))) - { - if (src->Type == CConfigFile::CVar::T_INT) - { - SetInt (src->Name.c_str (), src->asInt()); - } - else if (src->Type == CConfigFile::CVar::T_REAL) - { - SetFloat (src->Name.c_str (), src->asFloat()); - } - else if (src->Type == CConfigFile::CVar::T_STRING) - { - SetString (src->Name.c_str (), src->asString().c_str()); - } - } - } -} - -// *************************************************************************** - -void backupWindowHandleRec (CWnd *cwnd) -{ - if (!cwnd) - cwnd = theApp.m_pMainWnd; - - CString text; - cwnd->GetWindowText (text); - string stlText = (const char*)text; - - // Add an entry for this window - if ((stlText.size()>2) && (stlText[0] == 'u') && (stlText[1] == 'i')) - HwndMap.insert (std::map::value_type (*cwnd, (const char*)text)); - /* else if (!stlText.empty() && GetInt ("TestConfig") ) - HwndMap.insert (std::map::value_type (*cwnd, (const char*)"toto")); */ - - // Go for the children - CWnd* child = cwnd->GetWindow(GW_CHILD); - while (child) - { - backupWindowHandleRec (child); - child = child->GetWindow(GW_HWNDNEXT); - } -} - -// *************************************************************************** - -void localizeWindowsRec (CWnd *cwnd, bool useMap) -{ - if (!cwnd) - cwnd = theApp.m_pMainWnd; - - if (useMap) - { - std::map::iterator ite = HwndMap.find (*cwnd); - if (ite != HwndMap.end()) - { - ucstring ucName = CI18N::get (ite->second); - setWindowText(ite->first, (WCHAR*)ucName.c_str()); - } - } - else - { - CString name; - cwnd->GetWindowText (name); - ucstring ucName = CI18N::get ((const char*)name); - setWindowText(*cwnd, (WCHAR*)ucName.c_str()); - } - - // Go for the children - CWnd* child = cwnd->GetWindow(GW_CHILD); - while (child) - { - localizeWindowsRec (child, useMap); - child = child->GetWindow(GW_HWNDNEXT); - } -} - - -// *************************************************************************** -std::string GetStringDriverSound() -{ - // Get the variable pointer - CConfigFile::CVar *variable = ConfigFile.getVarPtr ("DriverSound"); - - // Available ? - if (variable) - return variable->asString (); - // else force FMod - else - return "FMod"; -} - -// *************************************************************************** -sint GetIntForceLanguage() -{ - // Get the variable pointer - CConfigFile::CVar *variable = ConfigFile.getVarPtr ("ForceLanguage"); - - // Available ? - if (variable) - return variable->asInt (); - // else force "NO" - else - return 0; -} - -// *************************************************************************** -sint GetIntTestConfig() -{ - // Get the variable pointer - CConfigFile::CVar *variable = ConfigFile.getVarPtr ("TestConfig"); - - // Available ? - if (variable) - return variable->asInt (); - // else force NO - else - return 0; -} - -// *************************************************************************** -void SetStringDriverSound(const char *value) -{ - // Get the variable pointer - CConfigFile::CVar *variable = ConfigFile.getVarPtr ("DriverSound"); - - // Available ? - if (variable) - { - if (variable->Type == CConfigFile::CVar::T_STRING) - { - if (variable->asString () != value) - variable->setAsString (value); - } - else - { - theApp.error (ucstring("The variable DriverSound is not a string "CONFIG_FILE_NAME)); - } - } - else - { - // no op (FMod should be forced) - } -} - +// 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 "stdafx.h" +#include "cfg_file.h" +#include "client_config.h" +#include "client_configDlg.h" +#include "display_dlg.h" + +using namespace std; +using namespace NLMISC; + +CConfigFile ConfigFile; + +// Translation windows map +std::map HwndMap; + +// *************************************************************************** + +string GetString (const char *var) +{ + // Get the variable pointer + CConfigFile::CVar *variable = ConfigFile.getVarPtr (var); + + // Available ? + if (variable) + { + return variable->asString (); + } + else + { + theApp.error ("Can't find the variable "+(ucstring)var+" in "CONFIG_FILE_NAME); + return ""; + } +} + +// *************************************************************************** + +sint GetInt (const char *var) +{ + // Get the variable pointer + CConfigFile::CVar *variable = ConfigFile.getVarPtr (var); + + // Available ? + if (variable) + { + return variable->asInt (); + } + else + { + theApp.error ("Can't find the variable "+(ucstring)var+" in "CONFIG_FILE_NAME); + return -1; + } +} + +// *************************************************************************** + +float GetFloat (const char *var) +{ + // Get the variable pointer + CConfigFile::CVar *variable = ConfigFile.getVarPtr (var); + + // Available ? + if (variable) + { + return variable->asFloat (); + } + else + { + theApp.error ("Can't find the variable "+(ucstring)var+" in "CONFIG_FILE_NAME); + return -1; + } +} + +// *************************************************************************** + +bool GetBool (const char *var) +{ + // Get the variable pointer + CConfigFile::CVar *variable = ConfigFile.getVarPtr (var); + + // Available ? + if (variable) + { + string _bool = toLower (variable->asString ()); + if (_bool == "true") + return true; + if (_bool == "false") + return false; + theApp.error ("The variable "+(ucstring)var+" is not a boolean "CONFIG_FILE_NAME); + return false; + } + else + { + theApp.error ("Can't find the variable "+(ucstring)var+" in "CONFIG_FILE_NAME); + return false; + } +} + +// *************************************************************************** + +void SetString (const char *var, const char *value) +{ + // Get the variable pointer + CConfigFile::CVar *variable = ConfigFile.getVarPtr (var); + + // Available ? + if (variable) + { + if (variable->Type == CConfigFile::CVar::T_STRING) + { + if (variable->asString () != value) + variable->setAsString (value); + } + else + { + theApp.error ("The variable "+(ucstring)var+" is not a string "CONFIG_FILE_NAME); + } + } + else + { + theApp.error ("Can't find the variable "+(ucstring)var+" in "CONFIG_FILE_NAME); + } +} + +// *************************************************************************** + +void SetBool (const char *var, bool value) +{ + // Get the variable pointer + CConfigFile::CVar *variable = ConfigFile.getVarPtr (var); + + // Available ? + if (variable) + { + if (variable->Type == CConfigFile::CVar::T_STRING) + { + const char *valueToSet = value?"true":"false"; + if (variable->asString () != valueToSet) + variable->setAsString (valueToSet); + } + else + { + theApp.error ("The variable "+(ucstring)var+" is not a string "CONFIG_FILE_NAME); + } + } + else + { + theApp.error ("Can't find the variable "+(ucstring)var+" in "CONFIG_FILE_NAME); + } +} + +// *************************************************************************** + +void SetInt (const char *var, sint value) +{ + // Get the variable pointer + CConfigFile::CVar *variable = ConfigFile.getVarPtr (var); + + // Available ? + if (variable) + { + if (variable->Type == CConfigFile::CVar::T_INT) + { + if (variable->asInt () != value) + variable->setAsInt (value); + } + else + { + theApp.error ("The variable "+(ucstring)var+" is not an integer "CONFIG_FILE_NAME); + } + } + else + { + theApp.error ("Can't find the variable "+(ucstring)var+" in "CONFIG_FILE_NAME); + } +} + +// *************************************************************************** + +void SetFloat (const char *var, float value) +{ + // Get the variable pointer + CConfigFile::CVar *variable = ConfigFile.getVarPtr (var); + + // Available ? + if (variable) + { + if (variable->Type == CConfigFile::CVar::T_REAL) + { + if (fabs (variable->asFloat () - value) > 0.000001f) + variable->setAsFloat (value); + } + else + { + theApp.error ("The variable "+(ucstring)var+" is not a float "CONFIG_FILE_NAME); + } + } + else + { + theApp.error ("Can't find the variable "+(ucstring)var+" in "CONFIG_FILE_NAME); + } +} + +// *************************************************************************** + +void SetToConfigFile () +{ + // Get the window pointer + CClient_configDlg *dlg = (CClient_configDlg*)theApp.m_pMainWnd; + dlg->UpdateData (TRUE); + + // *** General dialog + + // Get the dialog + CGeneralDlg &general = dlg->GeneralDlg; + SetInt ("SaveConfig", (int)general.SaveConfig); + SetString ("LanguageCode", (general.Language==2)?"de":(general.Language==1)?"fr":"en"); + if (general.Sleep) + SetInt ("ProcessPriority", -1); + else + SetInt ("ProcessPriority", 0); + + // *** Display dialog + + // Get the dialog + CDisplayDlg &display = dlg->DisplayDlg; + SetInt ("PositionX", display.PositionX); + SetInt ("PositionY", display.PositionY); + SetInt ("FullScreen", !display.Windowed); + switch(display.DriverChoiceMode) + { + case CDisplayDlg::DrvChooseDirect3D: SetString("Driver3D", "Direct3D"); break; + case CDisplayDlg::DrvChooseOpenGL: SetString("Driver3D", "OpenGL"); break; + case CDisplayDlg::DrvChooseAuto: SetString("Driver3D", "Auto"); break; + } + if (display.Windowed) + { + SetInt ("Width", display.Width); + SetInt ("Height", display.Height); + SetInt ("Depth", 32); + } + else + { + // Mode valid ? + if (display.DriverChoiceMode != CDisplayDlg::DrvChooseUnknwown) + { + const CVideoMode &videoMode = VideoModes[display.getActualDriver()][display.Mode]; + SetInt ("Width", videoMode.Width); + SetInt ("Height", videoMode.Height); + SetInt ("Depth", 32); + SetInt ("Frequency", videoMode.Frequency); + } + } + + // *** Display details dialog + + // Get the dialog + CDisplayDetailsDlg &displayDetails = dlg->DisplayDetailsDlg; + SetInt ("HDEntityTexture", displayDetails.TextureQualityInt==2); + SetInt ("DivideTextureSizeBy2", displayDetails.TextureQualityInt==0); + SetFloat ("LandscapeThreshold", QualityToLandscapeThreshold[displayDetails.LandscapeQualityInt]); + SetFloat ("Vision", QualityToZFar[displayDetails.LandscapeQualityInt]); + SetFloat ("LandscapeTileNear", QualityToLandscapeTileNear[displayDetails.LandscapeQualityInt]); + SetInt ("SkinNbMaxPoly", QualityToSkinNbMaxPoly[displayDetails.CharacterQualityInt]); + SetInt ("NbMaxSkeletonNotCLod", QualityToNbMaxSkeletonNotCLod[displayDetails.CharacterQualityInt]); + SetInt ("FxNbMaxPoly", QualityToFxNbMaxPoly[displayDetails.FXQualityInt]); + + // *** Display details dialog + + // Get the dialog + CDisplayAdvancedDlg &displayAdvanced = dlg->DisplayAdvancedDlg; + SetInt ("ForceDXTC", !displayAdvanced.DisableDXTC); + SetInt ("DisableVtxProgram", (int)displayAdvanced.DisableVertexProgram); + SetInt ("DisableVtxAGP", (int)displayAdvanced.DisableAGPVertices); + SetInt ("DisableTextureShdr", (int)displayAdvanced.DisableTextureShaders); + + // *** Sound dialog + + // Get the dialog + CSoundDlg &sound = dlg->SoundDlg; + SetInt ("SoundOn", (int)sound.SoundOn); + SetInt ("UseEax", sound.EAX ? true : false); + SetInt ("MaxTrack", sound.getAsNumSoundBuffer()); + SetStringDriverSound(sound.FMod ? "FMod" : "Auto"); + SetInt ("SoundForceSoftwareBuffer", sound.ForceSoundSoft? true : false); +} + +// *************************************************************************** + +uint getFullscreenMode (uint driver, const CVideoMode &mode) +{ + // Look for the valid mode ? + uint i; + for (i=0; iGeneralDlg; + general.UpdateData (); + + // *** General dialog + general.SaveConfig = GetInt ("SaveConfig"); + string lang = GetString ("LanguageCode"); + (lang == "de")?general.Language=2:(lang == "fr")?general.Language=1:general.Language=0; + + int sleep = GetInt ("ProcessPriority"); + if (sleep != -1) + { + general.Sleep = 0; + } + else + { + general.Sleep = -1; + } + general.UpdateData (FALSE); + + // *** Display dialog + + CDisplayDlg &display = dlg->DisplayDlg; + display.UpdateData (); + display.Windowed = !GetInt ("FullScreen"); + display.Width = GetInt ("Width"); + display.Height = GetInt ("Height"); + display.PositionX = GetInt ("PositionX"); + display.PositionY = GetInt ("PositionY"); + std::string driverMode = GetString("Driver3D"); + if (nlstricmp(driverMode, "Auto") == 0 || nlstricmp(driverMode, "0") == 0) display.DriverChoiceMode = CDisplayDlg::DrvChooseAuto; + else if (nlstricmp(driverMode, "OpenGL") == 0 || nlstricmp(driverMode, "1") == 0) display.DriverChoiceMode = CDisplayDlg::DrvChooseOpenGL; + else if (nlstricmp(driverMode, "Direct3D") == 0 || nlstricmp(driverMode, "2") == 0) display.DriverChoiceMode = CDisplayDlg::DrvChooseDirect3D; + else display.DriverChoiceMode = CDisplayDlg::DrvChooseAuto; + display.Mode = -1; + // The video mode + CVideoMode mode; + mode.Width = display.Width; + mode.Height = display.Height; + mode.ColorDepth = 32; + mode.Frequency = GetInt ("Frequency"); + + // Look for the valid mode ? + uint i; + CDisplayDlg::TDriver actualDriver = display.getActualDriver(); + for (i=0; iDisplayDetailsDlg; + int hdTextureInstalled = GetInt ("HDTextureInstalled"); + displayDetails.UpdateData (); + displayDetails.MaxTextureQuality= hdTextureInstalled?2:1; + // NB: if the player changes its client.cfg, mixing HDEntityTexture=1 and DivideTextureSizeBy2=1, it will + // result to a low quality! + if(GetInt ("DivideTextureSizeBy2")) + displayDetails.TextureQualityInt = 0; + else if(GetInt ("HDEntityTexture") && hdTextureInstalled) + displayDetails.TextureQualityInt = 2; + else + displayDetails.TextureQualityInt = 1; + displayDetails.LandscapeQualityInt = GetQuality (QualityToLandscapeThreshold, GetFloat ("LandscapeThreshold")); + displayDetails.FXQualityInt = GetQuality (QualityToFxNbMaxPoly, GetInt ("FxNbMaxPoly")); + // minimize quality according to NbMaxSkeletonNotCLod and SkinNbMaxPoly + displayDetails.CharacterQualityInt = GetQuality (QualityToSkinNbMaxPoly, GetInt ("SkinNbMaxPoly")); + displayDetails.CharacterQualityInt = min(displayDetails.CharacterQualityInt, GetQuality (QualityToNbMaxSkeletonNotCLod, GetInt ("NbMaxSkeletonNotCLod"))); + displayDetails.updateState (); + displayDetails.UpdateData (FALSE); + + // *** Display advanced dialog + + CDisplayAdvancedDlg &displayAdvanced = dlg->DisplayAdvancedDlg; + displayAdvanced.UpdateData (); + displayAdvanced.DisableDXTC = !GetInt ("ForceDXTC"); + displayAdvanced.DisableVertexProgram = GetInt ("DisableVtxProgram") ? TRUE : FALSE; + displayAdvanced.DisableAGPVertices = GetInt ("DisableVtxAGP") ? TRUE : FALSE; + displayAdvanced.DisableTextureShaders = GetInt ("DisableTextureShdr") ? TRUE : FALSE; + displayAdvanced.UpdateData (FALSE); + + // *** Sound dialog + + // Get the dialog + CSoundDlg &sound = dlg->SoundDlg; + sound.UpdateData (); + sound.SoundOn = GetInt ("SoundOn"); + sound.EAX = GetInt ("UseEax") ? TRUE : FALSE; + sound.FMod = GetStringDriverSound()=="FMod" ? TRUE : FALSE; + sound.ForceSoundSoft = GetInt ("SoundForceSoftwareBuffer") ? TRUE : FALSE; + sound.setAsNumSoundBuffer( GetInt ("MaxTrack") ); + sound.updateState (); + sound.UpdateData (FALSE); +} + +// *************************************************************************** + +bool LoadConfigFile () +{ + // Read the file + try + { + ConfigFile.load (CONFIG_FILE_NAME); + } + catch (Exception &e) + { + theApp.error ("Error reading the file "CONFIG_FILE_NAME" : "+string (e.what ())); + return false; + } + return true; +} + +// *************************************************************************** + +bool SaveConfigFile () +{ + // Read the file + try + { + ConfigFile.save (); + } + catch (Exception &e) + { + theApp.error (CI18N::get ("uiConfigErrorWritingTheFile")+" "CONFIG_FILE_NAME" : "+string (e.what ())); + return false; + } + return true; +} + +// *************************************************************************** + +void InvalidateConfig () +{ + theApp.Modified = true; + + // Get the window pointer + CClient_configDlg *dlg = (CClient_configDlg*)theApp.m_pMainWnd; + dlg->ApplyCtrl.EnableWindow (TRUE); + + // Set the title + setWindowText(*dlg, (WCHAR*)(CI18N::get ("uiConfigTitle") + " *").c_str()); +} + +// *************************************************************************** + +void ResetConfigFile () +{ + // Clear the config file + ConfigFile.clear (); + ConfigFile.reparse (/*CONFIG_DEFAULT_FILE_NAME*/); + CConfigFile::CVar var; + var.Type = CConfigFile::CVar::T_STRING; + var.setAsString (CONFIG_DEFAULT_FILE_NAME); + CConfigFile::CVar *newVar = ConfigFile.insertVar ("RootConfigFilename", var); +} + +// *************************************************************************** + +void MergeConfigFile (CConfigFile &configFile) +{ + // For each variable in the new config file + uint count = configFile.getNumVar (); + uint i; + for (i=0; iName, *src); + if ((src->Type == CConfigFile::CVar::T_INT) && (dest->Type == CConfigFile::CVar::T_INT) || + (src->Type == CConfigFile::CVar::T_REAL) && (dest->Type == CConfigFile::CVar::T_INT) || + (src->Type == CConfigFile::CVar::T_INT) && (dest->Type == CConfigFile::CVar::T_REAL) || + (src->Type == CConfigFile::CVar::T_REAL) && (dest->Type == CConfigFile::CVar::T_REAL) || + (src->Type == CConfigFile::CVar::T_STRING) && (dest->Type == CConfigFile::CVar::T_STRING)) + { + // Get the method for the merge + TMergeMethod merge = GetMergeMethod (src->Name.c_str ()); + if (src->Type == CConfigFile::CVar::T_INT) + { + if (dest->Root) + { + SetInt (src->Name.c_str (), src->asInt()); + } + else + { + if (merge == PreferInferior) + SetInt (src->Name.c_str (), min (src->asInt(), dest->asInt())); + else if (merge == PreferSuperior) + SetInt (src->Name.c_str (), max (src->asInt(), dest->asInt())); + else if (merge == PreferTrue) + SetInt (src->Name.c_str (), (int)((src->asInt()!=0)||(dest->asInt()!=0))); + else if (merge == PreferFalse) + SetInt (src->Name.c_str (), (int)((src->asInt()!=0)&&(dest->asInt()!=0))); + } + } + else if (src->Type == CConfigFile::CVar::T_REAL) + { + if (dest->Root) + { + SetFloat (src->Name.c_str (), src->asFloat()); + } + else + { + if (merge == PreferInferior) + SetFloat (src->Name.c_str (), min (src->asFloat(), dest->asFloat())); + else if (merge == PreferSuperior) + SetFloat (src->Name.c_str (), max (src->asFloat(), dest->asFloat())); + else if (merge == PreferTrue) + SetFloat (src->Name.c_str (), (float)((src->asFloat()!=0.f)||(dest->asFloat()!=0.f))); + else if (merge == PreferFalse) + SetFloat (src->Name.c_str (), (float)((src->asFloat()!=0.f)&&(dest->asFloat()!=0.f))); + } + } + else if (src->Type == CConfigFile::CVar::T_STRING) + { + if (dest->Root) + { + SetString (src->Name.c_str (), src->asString().c_str ()); + } + else + { + if (merge == PreferTrue) + SetBool (src->Name.c_str (), (src->asString()!="false")||(dest->asString()!="true")); + else if (merge == PreferFalse) + SetBool (src->Name.c_str (), (src->asString()!="false")&&(dest->asString()!="true")); + else + SetString (src->Name.c_str (), src->asString().c_str ()); + } + } + } + } +} + +// *************************************************************************** + +void ResetConfigFileToDefault () +{ + // For each variable not ROOT in the current config file + uint count = ConfigFile.getNumVar (); + uint i; + for (i=0; iName=="HDTextureInstalled") + continue; + + // Get the variable from default config file + CConfigFile::CVar *src = ConfigFileDefault.getVarPtr (dest->Name); + + // if default exist and cur not already default + if ( src && !dest->Root && + ((src->Type == CConfigFile::CVar::T_INT) && (dest->Type == CConfigFile::CVar::T_INT) || + (src->Type == CConfigFile::CVar::T_REAL) && (dest->Type == CConfigFile::CVar::T_INT) || + (src->Type == CConfigFile::CVar::T_INT) && (dest->Type == CConfigFile::CVar::T_REAL) || + (src->Type == CConfigFile::CVar::T_REAL) && (dest->Type == CConfigFile::CVar::T_REAL) || + (src->Type == CConfigFile::CVar::T_STRING) && (dest->Type == CConfigFile::CVar::T_STRING))) + { + if (src->Type == CConfigFile::CVar::T_INT) + { + SetInt (src->Name.c_str (), src->asInt()); + } + else if (src->Type == CConfigFile::CVar::T_REAL) + { + SetFloat (src->Name.c_str (), src->asFloat()); + } + else if (src->Type == CConfigFile::CVar::T_STRING) + { + SetString (src->Name.c_str (), src->asString().c_str()); + } + } + } +} + +// *************************************************************************** + +void backupWindowHandleRec (CWnd *cwnd) +{ + if (!cwnd) + cwnd = theApp.m_pMainWnd; + + CString text; + cwnd->GetWindowText (text); + string stlText = (const char*)text; + + // Add an entry for this window + if ((stlText.size()>2) && (stlText[0] == 'u') && (stlText[1] == 'i')) + HwndMap.insert (std::map::value_type (*cwnd, (const char*)text)); + /* else if (!stlText.empty() && GetInt ("TestConfig") ) + HwndMap.insert (std::map::value_type (*cwnd, (const char*)"toto")); */ + + // Go for the children + CWnd* child = cwnd->GetWindow(GW_CHILD); + while (child) + { + backupWindowHandleRec (child); + child = child->GetWindow(GW_HWNDNEXT); + } +} + +// *************************************************************************** + +void localizeWindowsRec (CWnd *cwnd, bool useMap) +{ + if (!cwnd) + cwnd = theApp.m_pMainWnd; + + if (useMap) + { + std::map::iterator ite = HwndMap.find (*cwnd); + if (ite != HwndMap.end()) + { + ucstring ucName = CI18N::get (ite->second); + setWindowText(ite->first, (WCHAR*)ucName.c_str()); + } + } + else + { + CString name; + cwnd->GetWindowText (name); + ucstring ucName = CI18N::get ((const char*)name); + setWindowText(*cwnd, (WCHAR*)ucName.c_str()); + } + + // Go for the children + CWnd* child = cwnd->GetWindow(GW_CHILD); + while (child) + { + localizeWindowsRec (child, useMap); + child = child->GetWindow(GW_HWNDNEXT); + } +} + + +// *************************************************************************** +std::string GetStringDriverSound() +{ + // Get the variable pointer + CConfigFile::CVar *variable = ConfigFile.getVarPtr ("DriverSound"); + + // Available ? + if (variable) + return variable->asString (); + // else force FMod + else + return "FMod"; +} + +// *************************************************************************** +sint GetIntForceLanguage() +{ + // Get the variable pointer + CConfigFile::CVar *variable = ConfigFile.getVarPtr ("ForceLanguage"); + + // Available ? + if (variable) + return variable->asInt (); + // else force "NO" + else + return 0; +} + +// *************************************************************************** +sint GetIntTestConfig() +{ + // Get the variable pointer + CConfigFile::CVar *variable = ConfigFile.getVarPtr ("TestConfig"); + + // Available ? + if (variable) + return variable->asInt (); + // else force NO + else + return 0; +} + +// *************************************************************************** +void SetStringDriverSound(const char *value) +{ + // Get the variable pointer + CConfigFile::CVar *variable = ConfigFile.getVarPtr ("DriverSound"); + + // Available ? + if (variable) + { + if (variable->Type == CConfigFile::CVar::T_STRING) + { + if (variable->asString () != value) + variable->setAsString (value); + } + else + { + theApp.error (ucstring("The variable DriverSound is not a string "CONFIG_FILE_NAME)); + } + } + else + { + // no op (FMod should be forced) + } +} + diff --git a/code/ryzom/tools/client/client_config/cfg_file.h b/code/ryzom/tools/client/client_config/cfg_file.h index 1139094b4..30ce260ec 100644 --- a/code/ryzom/tools/client/client_config/cfg_file.h +++ b/code/ryzom/tools/client/client_config/cfg_file.h @@ -1,91 +1,91 @@ -// 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_CFG_FILE_H -#define NL_CFG_FILE_H - -// *************************************************************************** - -bool LoadConfigFile (); - -// *************************************************************************** - -bool SaveConfigFile (); - -// *************************************************************************** - -void GetFromConfigFile (); - -// *************************************************************************** - -void SetToConfigFile (); - -// *************************************************************************** - -void InvalidateConfig (); - -// *************************************************************************** - -void ResetConfigFile (); - -// *************************************************************************** - -void MergeConfigFile (NLMISC::CConfigFile &configFile); - -// *************************************************************************** - -void ResetConfigFileToDefault (); - -// *************************************************************************** - -std::string GetString (const char *var); - -// *************************************************************************** - -sint GetInt (const char *var); - -// *************************************************************************** - -bool GetBool (const char *var); - -// *************************************************************************** - -void backupWindowHandleRec (CWnd *cwnd = NULL); - -// *************************************************************************** - -void removeWindowHandleRec (CWnd *cwnd); - -// *************************************************************************** - -void localizeWindowsRec (CWnd *cwnd=NULL, bool useMap=true); - -// *************************************************************************** - -// Special Vars that must not pop up a window if not present in the CFG (because coder features) -std::string GetStringDriverSound(); -void SetStringDriverSound(const char *value); -sint GetIntForceLanguage(); -sint GetIntTestConfig(); - -// *************************************************************************** - - -#endif // NL_CFG_FILE_H - -/* End of database.h */ +// 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_CFG_FILE_H +#define NL_CFG_FILE_H + +// *************************************************************************** + +bool LoadConfigFile (); + +// *************************************************************************** + +bool SaveConfigFile (); + +// *************************************************************************** + +void GetFromConfigFile (); + +// *************************************************************************** + +void SetToConfigFile (); + +// *************************************************************************** + +void InvalidateConfig (); + +// *************************************************************************** + +void ResetConfigFile (); + +// *************************************************************************** + +void MergeConfigFile (NLMISC::CConfigFile &configFile); + +// *************************************************************************** + +void ResetConfigFileToDefault (); + +// *************************************************************************** + +std::string GetString (const char *var); + +// *************************************************************************** + +sint GetInt (const char *var); + +// *************************************************************************** + +bool GetBool (const char *var); + +// *************************************************************************** + +void backupWindowHandleRec (CWnd *cwnd = NULL); + +// *************************************************************************** + +void removeWindowHandleRec (CWnd *cwnd); + +// *************************************************************************** + +void localizeWindowsRec (CWnd *cwnd=NULL, bool useMap=true); + +// *************************************************************************** + +// Special Vars that must not pop up a window if not present in the CFG (because coder features) +std::string GetStringDriverSound(); +void SetStringDriverSound(const char *value); +sint GetIntForceLanguage(); +sint GetIntTestConfig(); + +// *************************************************************************** + + +#endif // NL_CFG_FILE_H + +/* End of database.h */ diff --git a/code/ryzom/tools/client/client_config/client_config.cpp b/code/ryzom/tools/client/client_config/client_config.cpp index 97a0f1ce1..da434171a 100644 --- a/code/ryzom/tools/client/client_config/client_config.cpp +++ b/code/ryzom/tools/client/client_config/client_config.cpp @@ -1,275 +1,275 @@ -// 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 . - -// client_config.cpp : Defines the class behaviors for the application. -// - -#include "stdafx.h" -#include "client_config.h" -#include "client_configDlg.h" -#include "cfg_file.h" - -#include - -using namespace NLMISC; -using namespace NL3D; - -// *************************************************************************** - -// CClientConfigApp - -BEGIN_MESSAGE_MAP(CClientConfigApp, CWinApp) - //{{AFX_MSG_MAP(CClientConfigApp) - // NOTE - the ClassWizard will add and remove mapping macros here. - // DO NOT EDIT what you see in these blocks of generated code! - //}}AFX_MSG - ON_COMMAND(ID_HELP, CWinApp::OnHelp) -END_MESSAGE_MAP() - -// *************************************************************************** - -// CClientConfigApp construction - -CClientConfigApp::CClientConfigApp() -{ - // Place all significant initialization in InitInstance - Localized = false; -} - -// *************************************************************************** - -// The one and only CClientConfigApp object - -CClientConfigApp theApp; - -// *************************************************************************** - -// CClientConfigApp initialization - -class CMyCommandLineInfo : public CCommandLineInfo -{ - virtual void ParseParam( LPCTSTR lpszParam, BOOL bFlag, BOOL bLast ) - { - /* Yoyo: Disable AutoConfig cause don't work on every config - if ((strnicmp (lpszParam, "auto_config", 3) == 0) && bFlag) - { - AutoConfig = true; - } - if ((strnicmp (lpszParam, "gpu", 3) == 0) && bFlag) - GLRenderer = lpszParam+3; - if ((strnicmp (lpszParam, "cpu", 3) == 0) && bFlag) - CPUFrequency = atoi (lpszParam+3); - if ((strnicmp (lpszParam, "ram", 3) == 0) && bFlag) - SystemMemory = 1024*1024*atoi (lpszParam+3); - if ((strnicmp (lpszParam, "vram", 4) == 0) && bFlag) - VideoMemory = 1024*1024*atoi (lpszParam+4); - if ((strnicmp (lpszParam, "hwsb", 4) == 0) && bFlag) - HardwareSoundBuffer = atoi (lpszParam+4); - if ((strcmp (lpszParam, "?") == 0) && bFlag) - MessageBoxW(NULL, - "\t/gpuGPUNAME\t\tSet GPU name to GPUNAME\n" - "\t/cpuCPUFREQUENCY\t\tSet CPU frequency to CPUFREQENCY\n" - "\t/ramAMOUNTRAM\t\tSet the amount of ram to AMOUNTRAM\n" - "\t/vramAMOUNTVRAM\t\tSet the amount of vram to AMOUNTVRAM\n" - "\t/hwsbHARDWARESOUNDBUFFER\t\tSet the number of hardware sound buffer\n" - "\t/auto_config\t\tAuto configuration mode\n" - "\t/?\t\tHelp\n" - "\nExemple : ryzom_configuration_r \"/gpu geforce4 ti 4600\" /cpu1500 /ram512 /vram64" - , CI18N::get ("uiConfigTitle"), MB_ICONEXCLAMATION|MB_OK); - */ - } -}; - -void pump () -{ - // Display the window - MSG msg; - while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } -} - -INT_PTR CALLBACK MyDialogProc( - HWND hwndDlg, // handle to dialog box - UINT uMsg, // message - WPARAM wParam, // first message parameter - LPARAM lParam // second message parameter -) -{ - return FALSE; -} - -BOOL CClientConfigApp::InitInstance() -{ - HANDLE mutex = CreateMutex (NULL, false, "RyzomConfig"); - if (mutex && GetLastError() == ERROR_ALREADY_EXISTS) - exit (0); - - // Get the bitmap size - HRSRC hrsrc = FindResource(m_hInstance, MAKEINTRESOURCE(IDB_SLASH_SCREEN), RT_BITMAP); - nlassert (hrsrc); - HGLOBAL hBitmap = LoadResource (m_hInstance, hrsrc); - nlassert (hBitmap); - BITMAP *bitmap = (BITMAP*)LockResource(hBitmap); - nlassert (bitmap); - int width = bitmap->bmWidth; - int height = bitmap->bmHeight; - - // Look the command line to see if we have a cookie and a addr - HWND SlashScreen = CreateDialog (m_hInstance, MAKEINTRESOURCE(IDD_SLASH_SCREEN), NULL, MyDialogProc); - RECT rect; - RECT rectDesktop; - GetWindowRect (SlashScreen, &rect); - GetWindowRect (GetDesktopWindow (), &rectDesktop); - SetWindowPos (SlashScreen, HWND_TOP, (rectDesktop.right-rectDesktop.left-width)/2, (rectDesktop.bottom-rectDesktop.top-height)/2, width, height, 0); - ShowWindow (SlashScreen, SW_SHOW); - - pump (); - - try - { - AfxEnableControlContainer(); - - // Create drivers - IDriver *glDriver = CDRU::createGlDriver(); - IDriver *d3dDriver = CDRU::createD3DDriver(); - - // Get some information about the system - RegisterVideoModes (0, glDriver); - RegisterVideoModes (1, d3dDriver); - GetSystemInformation (d3dDriver); - - // Load the config file - if (!LoadConfigFile ()) - return FALSE; - - // Add search pathes for *.uxt - // Local search path ? - if (::GetIntTestConfig()) - CPath::addSearchPath ("translation/work", true, false); - CPath::addSearchPath ("patch", true, false); - CPath::addSearchPath ("data", true, false); - - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. - -#ifdef _AFXDLL - Enable3dControls(); // Call this when using MFC in a shared DLL -#else - Enable3dControlsStatic(); // Call this when linking to MFC statically -#endif - - // Init the data - LoadConfigFileDefault (); - - // Init the database - CreateDataBase (); - - // Parse command line for standard shell commands, DDE, file open - CMyCommandLineInfo cmdInfo; - ParseCommandLine(cmdInfo); - - CClient_configDlg dlg; - m_pMainWnd = &dlg; - - DestroyWindow (SlashScreen); - - sint nResponse = (sint)dlg.DoModal(); - if (nResponse == IDOK) - { - // dismissed with OK - } - else if (nResponse == IDCANCEL) - { - // dismissed with Cancel - } - } - catch (Exception &e) - { - error ((ucstring)e.what()); - } - - // Since the dialog has been closed, return FALSE so that we exit the - // application, rather than start the application's message pump. - return FALSE; -} - - -// *************************************************************************** - -void CClientConfigApp::error (const ucstring &message) -{ - if (m_pMainWnd) - { - if (Localized) - { - MessageBoxW(*m_pMainWnd, (WCHAR*)message.c_str(), (WCHAR*)CI18N::get ("uiConfigTitle").c_str(), MB_OK|MB_ICONEXCLAMATION); - } - else - { - MessageBoxW(*m_pMainWnd, (WCHAR*)message.c_str(), (WCHAR*)ucstring("Ryzom Configuration").c_str(), MB_OK|MB_ICONEXCLAMATION); - } - } - else - MessageBoxW(NULL, (WCHAR*)message.c_str(), (WCHAR*)ucstring("Ryzom Configuration").c_str(), MB_OK|MB_ICONEXCLAMATION); -} - -// *************************************************************************** - -bool CClientConfigApp::yesNo (const ucstring &question) -{ - if (m_pMainWnd) - return MessageBoxW(*m_pMainWnd, (WCHAR*)question.c_str(), (WCHAR*)CI18N::get ("uiConfigTitle").c_str(), MB_YESNO|MB_ICONQUESTION) == IDYES; - else - return MessageBoxW(NULL, (WCHAR*)question.c_str(), (WCHAR*)CI18N::get ("uiConfigTitle").c_str(), MB_YESNO|MB_ICONQUESTION) == IDYES; -} - -// *************************************************************************** - -std::string GetNeLString (uint res) -{ - CString str; - str.LoadString (res); - return (const char*)str; -} - -// *************************************************************************** - -CString GetString (uint res) -{ - CString str; - str.LoadString (res); - return str; -} - -// *************************************************************************** -void setWindowText(HWND hwnd, LPCWSTR lpText) -{ - if (CSystemUtils::supportUnicode()) - { - SetWindowTextW(hwnd, lpText); - } - else - { - ucstring text((const ucchar *) lpText); - SetWindowTextA(hwnd, (LPCTSTR) text.toString().c_str()); - } -} - +// 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 . + +// client_config.cpp : Defines the class behaviors for the application. +// + +#include "stdafx.h" +#include "client_config.h" +#include "client_configDlg.h" +#include "cfg_file.h" + +#include + +using namespace NLMISC; +using namespace NL3D; + +// *************************************************************************** + +// CClientConfigApp + +BEGIN_MESSAGE_MAP(CClientConfigApp, CWinApp) + //{{AFX_MSG_MAP(CClientConfigApp) + // NOTE - the ClassWizard will add and remove mapping macros here. + // DO NOT EDIT what you see in these blocks of generated code! + //}}AFX_MSG + ON_COMMAND(ID_HELP, CWinApp::OnHelp) +END_MESSAGE_MAP() + +// *************************************************************************** + +// CClientConfigApp construction + +CClientConfigApp::CClientConfigApp() +{ + // Place all significant initialization in InitInstance + Localized = false; +} + +// *************************************************************************** + +// The one and only CClientConfigApp object + +CClientConfigApp theApp; + +// *************************************************************************** + +// CClientConfigApp initialization + +class CMyCommandLineInfo : public CCommandLineInfo +{ + virtual void ParseParam( LPCTSTR lpszParam, BOOL bFlag, BOOL bLast ) + { + /* Yoyo: Disable AutoConfig cause don't work on every config + if ((strnicmp (lpszParam, "auto_config", 3) == 0) && bFlag) + { + AutoConfig = true; + } + if ((strnicmp (lpszParam, "gpu", 3) == 0) && bFlag) + GLRenderer = lpszParam+3; + if ((strnicmp (lpszParam, "cpu", 3) == 0) && bFlag) + CPUFrequency = atoi (lpszParam+3); + if ((strnicmp (lpszParam, "ram", 3) == 0) && bFlag) + SystemMemory = 1024*1024*atoi (lpszParam+3); + if ((strnicmp (lpszParam, "vram", 4) == 0) && bFlag) + VideoMemory = 1024*1024*atoi (lpszParam+4); + if ((strnicmp (lpszParam, "hwsb", 4) == 0) && bFlag) + HardwareSoundBuffer = atoi (lpszParam+4); + if ((strcmp (lpszParam, "?") == 0) && bFlag) + MessageBoxW(NULL, + "\t/gpuGPUNAME\t\tSet GPU name to GPUNAME\n" + "\t/cpuCPUFREQUENCY\t\tSet CPU frequency to CPUFREQENCY\n" + "\t/ramAMOUNTRAM\t\tSet the amount of ram to AMOUNTRAM\n" + "\t/vramAMOUNTVRAM\t\tSet the amount of vram to AMOUNTVRAM\n" + "\t/hwsbHARDWARESOUNDBUFFER\t\tSet the number of hardware sound buffer\n" + "\t/auto_config\t\tAuto configuration mode\n" + "\t/?\t\tHelp\n" + "\nExemple : ryzom_configuration_r \"/gpu geforce4 ti 4600\" /cpu1500 /ram512 /vram64" + , CI18N::get ("uiConfigTitle"), MB_ICONEXCLAMATION|MB_OK); + */ + } +}; + +void pump () +{ + // Display the window + MSG msg; + while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } +} + +INT_PTR CALLBACK MyDialogProc( + HWND hwndDlg, // handle to dialog box + UINT uMsg, // message + WPARAM wParam, // first message parameter + LPARAM lParam // second message parameter +) +{ + return FALSE; +} + +BOOL CClientConfigApp::InitInstance() +{ + HANDLE mutex = CreateMutex (NULL, false, "RyzomConfig"); + if (mutex && GetLastError() == ERROR_ALREADY_EXISTS) + exit (0); + + // Get the bitmap size + HRSRC hrsrc = FindResource(m_hInstance, MAKEINTRESOURCE(IDB_SLASH_SCREEN), RT_BITMAP); + nlassert (hrsrc); + HGLOBAL hBitmap = LoadResource (m_hInstance, hrsrc); + nlassert (hBitmap); + BITMAP *bitmap = (BITMAP*)LockResource(hBitmap); + nlassert (bitmap); + int width = bitmap->bmWidth; + int height = bitmap->bmHeight; + + // Look the command line to see if we have a cookie and a addr + HWND SlashScreen = CreateDialog (m_hInstance, MAKEINTRESOURCE(IDD_SLASH_SCREEN), NULL, MyDialogProc); + RECT rect; + RECT rectDesktop; + GetWindowRect (SlashScreen, &rect); + GetWindowRect (GetDesktopWindow (), &rectDesktop); + SetWindowPos (SlashScreen, HWND_TOP, (rectDesktop.right-rectDesktop.left-width)/2, (rectDesktop.bottom-rectDesktop.top-height)/2, width, height, 0); + ShowWindow (SlashScreen, SW_SHOW); + + pump (); + + try + { + AfxEnableControlContainer(); + + // Create drivers + IDriver *glDriver = CDRU::createGlDriver(); + IDriver *d3dDriver = CDRU::createD3DDriver(); + + // Get some information about the system + RegisterVideoModes (0, glDriver); + RegisterVideoModes (1, d3dDriver); + GetSystemInformation (d3dDriver); + + // Load the config file + if (!LoadConfigFile ()) + return FALSE; + + // Add search pathes for *.uxt + // Local search path ? + if (::GetIntTestConfig()) + CPath::addSearchPath ("translation/work", true, false); + CPath::addSearchPath ("patch", true, false); + CPath::addSearchPath ("data", true, false); + + // Standard initialization + // If you are not using these features and wish to reduce the size + // of your final executable, you should remove from the following + // the specific initialization routines you do not need. + +#ifdef _AFXDLL + Enable3dControls(); // Call this when using MFC in a shared DLL +#else + Enable3dControlsStatic(); // Call this when linking to MFC statically +#endif + + // Init the data + LoadConfigFileDefault (); + + // Init the database + CreateDataBase (); + + // Parse command line for standard shell commands, DDE, file open + CMyCommandLineInfo cmdInfo; + ParseCommandLine(cmdInfo); + + CClient_configDlg dlg; + m_pMainWnd = &dlg; + + DestroyWindow (SlashScreen); + + sint nResponse = (sint)dlg.DoModal(); + if (nResponse == IDOK) + { + // dismissed with OK + } + else if (nResponse == IDCANCEL) + { + // dismissed with Cancel + } + } + catch (Exception &e) + { + error ((ucstring)e.what()); + } + + // Since the dialog has been closed, return FALSE so that we exit the + // application, rather than start the application's message pump. + return FALSE; +} + + +// *************************************************************************** + +void CClientConfigApp::error (const ucstring &message) +{ + if (m_pMainWnd) + { + if (Localized) + { + MessageBoxW(*m_pMainWnd, (WCHAR*)message.c_str(), (WCHAR*)CI18N::get ("uiConfigTitle").c_str(), MB_OK|MB_ICONEXCLAMATION); + } + else + { + MessageBoxW(*m_pMainWnd, (WCHAR*)message.c_str(), (WCHAR*)ucstring("Ryzom Configuration").c_str(), MB_OK|MB_ICONEXCLAMATION); + } + } + else + MessageBoxW(NULL, (WCHAR*)message.c_str(), (WCHAR*)ucstring("Ryzom Configuration").c_str(), MB_OK|MB_ICONEXCLAMATION); +} + +// *************************************************************************** + +bool CClientConfigApp::yesNo (const ucstring &question) +{ + if (m_pMainWnd) + return MessageBoxW(*m_pMainWnd, (WCHAR*)question.c_str(), (WCHAR*)CI18N::get ("uiConfigTitle").c_str(), MB_YESNO|MB_ICONQUESTION) == IDYES; + else + return MessageBoxW(NULL, (WCHAR*)question.c_str(), (WCHAR*)CI18N::get ("uiConfigTitle").c_str(), MB_YESNO|MB_ICONQUESTION) == IDYES; +} + +// *************************************************************************** + +std::string GetNeLString (uint res) +{ + CString str; + str.LoadString (res); + return (const char*)str; +} + +// *************************************************************************** + +CString GetString (uint res) +{ + CString str; + str.LoadString (res); + return str; +} + +// *************************************************************************** +void setWindowText(HWND hwnd, LPCWSTR lpText) +{ + if (CSystemUtils::supportUnicode()) + { + SetWindowTextW(hwnd, lpText); + } + else + { + ucstring text((const ucchar *) lpText); + SetWindowTextA(hwnd, (LPCTSTR) text.toString().c_str()); + } +} + diff --git a/code/ryzom/tools/client/client_config/client_config.h b/code/ryzom/tools/client/client_config/client_config.h index 139d888a4..cdbc015d1 100644 --- a/code/ryzom/tools/client/client_config/client_config.h +++ b/code/ryzom/tools/client/client_config/client_config.h @@ -1,83 +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 . - -// client_config.h : main header file for the CLIENT_CONFIG application -// - -#if !defined(AFX_CLIENT_CONFIG_H__5ABEECBC_CE23_47C4_BD2F_8EBD81F203F3__INCLUDED_) -#define AFX_CLIENT_CONFIG_H__5ABEECBC_CE23_47C4_BD2F_8EBD81F203F3__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -#define CONFIG_FILE_NAME "client.cfg" -#define CONFIG_DEFAULT_FILE_NAME "client_default.cfg" - -///////////////////////////////////////////////////////////////////////////// -// CClientConfigApp: -// See client_config.cpp for the implementation of this class -// - -class CClientConfigApp : public CWinApp -{ -public: - CClientConfigApp(); - - // Error message - void error (const ucstring &message); - bool yesNo (const ucstring &message); - - // Data modified ? - bool Modified; - bool Localized; - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CClientConfigApp) - public: - virtual BOOL InitInstance(); - //}}AFX_VIRTUAL - -// Implementation - - //{{AFX_MSG(CClientConfigApp) - // NOTE - the ClassWizard will add and remove member functions here. - // DO NOT EDIT what you see in these blocks of generated code ! - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -extern CClientConfigApp theApp; - -// Helper to set text in a window -// fallback to ascii set if the OS doesn't support unicode (windows 95/98/me) -void setWindowText(HWND hwnd, LPCWSTR lpText); - - - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_CLIENT_CONFIG_H__5ABEECBC_CE23_47C4_BD2F_8EBD81F203F3__INCLUDED_) +// 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 . + +// client_config.h : main header file for the CLIENT_CONFIG application +// + +#if !defined(AFX_CLIENT_CONFIG_H__5ABEECBC_CE23_47C4_BD2F_8EBD81F203F3__INCLUDED_) +#define AFX_CLIENT_CONFIG_H__5ABEECBC_CE23_47C4_BD2F_8EBD81F203F3__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#ifndef __AFXWIN_H__ + #error include 'stdafx.h' before including this file for PCH +#endif + +#include "resource.h" // main symbols + +#define CONFIG_FILE_NAME "client.cfg" +#define CONFIG_DEFAULT_FILE_NAME "client_default.cfg" + +///////////////////////////////////////////////////////////////////////////// +// CClientConfigApp: +// See client_config.cpp for the implementation of this class +// + +class CClientConfigApp : public CWinApp +{ +public: + CClientConfigApp(); + + // Error message + void error (const ucstring &message); + bool yesNo (const ucstring &message); + + // Data modified ? + bool Modified; + bool Localized; + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CClientConfigApp) + public: + virtual BOOL InitInstance(); + //}}AFX_VIRTUAL + +// Implementation + + //{{AFX_MSG(CClientConfigApp) + // NOTE - the ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +extern CClientConfigApp theApp; + +// Helper to set text in a window +// fallback to ascii set if the OS doesn't support unicode (windows 95/98/me) +void setWindowText(HWND hwnd, LPCWSTR lpText); + + + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_CLIENT_CONFIG_H__5ABEECBC_CE23_47C4_BD2F_8EBD81F203F3__INCLUDED_) diff --git a/code/ryzom/tools/client/client_config/client_configDlg.cpp b/code/ryzom/tools/client/client_config/client_configDlg.cpp index 9c2de231b..28ad963c5 100644 --- a/code/ryzom/tools/client/client_config/client_configDlg.cpp +++ b/code/ryzom/tools/client/client_config/client_configDlg.cpp @@ -1,628 +1,628 @@ -// 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 . - -// client_configDlg.cpp : implementation file -// - -#include "stdafx.h" -#include "client_config.h" -#include "client_configDlg.h" -#include "cfg_file.h" -#include "database.h" - -#include -#include - -#define ICON_ZONE_WIDTH 128 - -#define LEFT_WIDTH 256 -#define LEFT_HEIGHT 512 - -#define BAR_START_X (LEFT_WIDTH+ICON_ZONE_WIDTH) -#define BAR_WIDTH 448 -#define BAR_HEIGHT 72 -#define TREE_ZONE_WIDTH 150 -#define TREE_OFFSET_LEFT 10 -#define TREE_OFFSET_TOP 10 - -// Label -#define LARGE_LABEL_HEIGHT -22 -#define LARGE_LABEL_START_X (LEFT_WIDTH+TREE_ZONE_WIDTH) -#define LARGE_LABEL_START_Y (15) -#define LARGE_LABEL_END_X (LEFT_WIDTH+ICON_ZONE_WIDTH+BAR_WIDTH) -#define LARGE_LABEL_END_Y BAR_HEIGHT - -// Icon -#define ICON_WIDTH 64 -#define ICON_HEIGHT 64 -#define ICON_START_Y ((BAR_HEIGHT-ICON_HEIGHT)/2) -#define ICON_START_X (LEFT_WIDTH+ICON_START_Y) -#define ICON_START_Y ((BAR_HEIGHT-ICON_HEIGHT)/2) - -// *************************************************************************** -// CAboutDlg dialog used for App About -// *************************************************************************** - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - //{{AFX_MSG(CAboutDlg) - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -// *************************************************************************** - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT -} - -// *************************************************************************** - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAboutDlg) - //}}AFX_DATA_MAP -} - -// *************************************************************************** - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) - //{{AFX_MSG_MAP(CAboutDlg) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// *************************************************************************** -// CClient_configDlg dialog -// *************************************************************************** - -CClient_configDlg::CClient_configDlg(CWnd* pParent /*=NULL*/) - : CDialog(CClient_configDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CClient_configDlg) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT - // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 - m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); - - // Init dialog pointers - Dialogs[PageGeneral] = &GeneralDlg; - Dialogs[PageDisplay] = &DisplayDlg; - Dialogs[PageDisplayDetails] = &DisplayDetailsDlg; - Dialogs[PageDisplayAdvanced] = &DisplayAdvancedDlg; - Dialogs[PageDisplaySysInfo] = &SystemInformationDlg; - Dialogs[PageDisplayOpenGLInfo] = &DisplayInformationGLDlg; - Dialogs[PageDisplayOpenD3DInfo] = &DisplayInformationD3DDlg; - Dialogs[PageSound] = &SoundDlg; - _CurrentPage = 0; -} - -// *************************************************************************** - -void CClient_configDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CClient_configDlg) - DDX_Control(pDX, ID_APPLY, ApplyCtrl); - //}}AFX_DATA_MAP -} - -// *************************************************************************** - -BEGIN_MESSAGE_MAP(CClient_configDlg, CDialog) - //{{AFX_MSG_MAP(CClient_configDlg) - ON_WM_SYSCOMMAND() - ON_WM_PAINT() - ON_WM_QUERYDRAGICON() - ON_BN_CLICKED(ID_APPLY, OnApply) - ON_BN_CLICKED(ID_DEFAULT, OnDefault) - ON_BN_CLICKED(ID_LAUNCH, OnLaunch) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// *************************************************************************** -// CClient_configDlg message handlers -// *************************************************************************** - -BOOL CClient_configDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - // Add "About..." menu item to system menu. - - // IDM_ABOUTBOX must be in the system command range. - ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); - ASSERT(IDM_ABOUTBOX < 0xF000); - - CMenu* pSysMenu = GetSystemMenu(FALSE); - if (pSysMenu != NULL) - { - CString strAboutMenu = "uiConfigMenuAbout"; - if (!strAboutMenu.IsEmpty()) - { - pSysMenu->AppendMenu(MF_SEPARATOR); - pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); - } - } - - // Set the icon for this dialog. The framework does this automatically - // when the application's main window is not a dialog - SetIcon(m_hIcon, TRUE); // Set big icon - SetIcon(m_hIcon, FALSE); // Set small icon - - // Create bitmaps - uint i; - for (i=0; iCreate (Pages[i].ResId, this)); - nlverify (Dialogs[i]->SetWindowPos (NULL, LEFT_WIDTH+TREE_ZONE_WIDTH, BAR_HEIGHT+2, 0, 0, SWP_NOZORDER|SWP_NOSIZE)); - } - - // Build the tree - CPage *page = Root.Children[0]; - HTREEITEM parent = TVI_ROOT; - while (page) - { - // Add an item - parent = Tree.InsertItem ("", parent); - Tree.SetItemData (parent, page->PageId); - if (page->Bold) - Tree.SetItemState (parent, TVIS_BOLD, TVIS_BOLD); - - // Next - if (page->Children.size ()) - page = page->Children[0]; - else - { - // Got a parent ? - while (page->Parent) - { - // Brother ? - if (page->ChildId < page->Parent->Children.size ()-1) - { - page = page->Parent->Children[page->ChildId+1]; - parent = Tree.GetParentItem (parent); - break; - } - else - { - page = page->Parent; - parent = Tree.GetParentItem (parent); - Tree.Expand (parent, TVE_EXPAND); - } - } - if (!page->Parent) - break; - } - } - - ApplyCtrl.EnableWindow (FALSE); - - // Get from the config file - GetFromConfigFile (); - - theApp.Modified = false; - - // Build the localisation map - backupWindowHandleRec (); - - // Localize the windows - changeLanguage (::GetIntForceLanguage()?"en" : ::GetString ("LanguageCode").c_str()); - theApp.Localized = true; - - // Focus - Tree.SelectItem(Tree.GetChildItem (Tree.GetRootItem())); - Tree.SetFocus (); - - return TRUE; // return TRUE unless you set the focus to a control -} - -// *************************************************************************** - -void CClient_configDlg::changeLanguage (const char *language) -{ - // Init CI18N - NLMISC::CI18N::load(language); - - localizeWindowsRec (); - translateTree (); - - // Set the general page - setPage (_CurrentPage); - - DisplayDlg.updateState (); - DisplayDlg.UpdateData (FALSE); - DisplayDetailsDlg.updateState (); - SoundDlg.updateState (); - - // Set the title - setWindowText(*this, (WCHAR*)((NLMISC::CI18N::get ("uiConfigTitle") + (theApp.Modified?" *":"")).c_str())); - - // The menu - CMenu* pSysMenu = GetSystemMenu(FALSE); - if (pSysMenu) - { - if (NLMISC::CSystemUtils::supportUnicode()) - { - nlverify (::ModifyMenuW(*pSysMenu, IDM_ABOUTBOX, MF_BYCOMMAND|MF_STRING, IDM_ABOUTBOX, (WCHAR*)NLMISC::CI18N::get ("uiConfigMenuAbout").c_str())); - } - else - { - nlverify (::ModifyMenu(*pSysMenu, IDM_ABOUTBOX, MF_BYCOMMAND|MF_STRING, IDM_ABOUTBOX, (LPCTSTR)NLMISC::CI18N::get ("uiConfigMenuAbout").toString().c_str())); - } - } -} - -// *************************************************************************** - -void CClient_configDlg::translateTree () -{ - // Set the item text - HTREEITEM item = Tree.GetRootItem (); - while (item) - { - // Set the item text - uint page = (uint)Tree.GetItemData (item); - ucstring name = NLMISC::CI18N::get (Pages[page].Name); - if (NLMISC::CSystemUtils::supportUnicode()) - { - TVITEMEXW itemDesc; - memset (&itemDesc, 0, sizeof(TVITEMEXW)); - itemDesc.hItem = item; - itemDesc.mask = TVIF_TEXT; - itemDesc.pszText = (WCHAR*)name.c_str(); - nlverify (SendMessageW (Tree, TVM_SETITEMW, 0, (LPARAM)&itemDesc)); - } - else - { - TVITEMEXA itemDesc; - memset (&itemDesc, 0, sizeof(TVITEMEXA)); - itemDesc.hItem = item; - itemDesc.mask = TVIF_TEXT; - std::string tmpStr = name.toString(); - itemDesc.pszText = (LPSTR) tmpStr.c_str(); - nlverify (::SendMessageA(Tree, TVM_SETITEMA, 0 , (LPARAM)&itemDesc)); - } - // Next item - HTREEITEM old = item; - item = Tree.GetChildItem (item); - if (!item) - { - // No more child, try a brother - item = Tree.GetNextSiblingItem (old); - } - if (!item) - { - // No more brother, try an oncle - item = Tree.GetParentItem (old); - if (item) - item = Tree.GetNextSiblingItem (item); - } - } -} - -// *************************************************************************** - -void CClient_configDlg::OnSysCommand(UINT nID, LPARAM lParam) -{ - if ((nID & 0xFFF0) == IDM_ABOUTBOX) - { - CAboutDlg dlgAbout; - dlgAbout.DoModal(); - } - else - { - CDialog::OnSysCommand(nID, lParam); - } -} - -// *************************************************************************** - -// If you add a minimize button to your dialog, you will need the code below -// to draw the icon. For MFC applications using the document/view model, -// this is automatically done for you by the framework. - -void CClient_configDlg::OnPaint() -{ - if (IsIconic()) - { - CPaintDC dc(this); // device context for painting - - SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); - - // Center icon in client rectangle - int cxIcon = GetSystemMetrics(SM_CXICON); - int cyIcon = GetSystemMetrics(SM_CYICON); - CRect rect; - GetClientRect(&rect); - int x = (rect.Width() - cxIcon + 1) / 2; - int y = (rect.Height() - cyIcon + 1) / 2; - - // Draw the icon - dc.DrawIcon(x, y, m_hIcon); - } - else - { - // Draw rect - CPaintDC dc(this); // device context for painting - dc.FillSolidRect( LEFT_WIDTH, BAR_HEIGHT+2, TREE_ZONE_WIDTH, LEFT_HEIGHT-BAR_HEIGHT-2, GetSysColor (COLOR_WINDOW)); - - // Draw top bar - dc.FillSolidRect( LEFT_WIDTH, 0, ICON_ZONE_WIDTH, BAR_HEIGHT, RGB (255,255,255)); - CDC bitmapDC; - bitmapDC.CreateCompatibleDC (&dc); - bitmapDC.SelectObject (&Bitmaps[BitmapTopRight]); - nlverify (dc.BitBlt( LEFT_WIDTH + ICON_ZONE_WIDTH, 0, BAR_WIDTH, BAR_HEIGHT, &bitmapDC, 0, 0, SRCCOPY)); - - // Draw some text - dc.SetBkMode (TRANSPARENT); - dc.SelectObject (&BarFont); - CRect labelRect (LARGE_LABEL_START_X, LARGE_LABEL_START_Y, LARGE_LABEL_END_X, LARGE_LABEL_END_Y); - DrawTextW (&(*dc), (WCHAR*)TopLargeLabel.c_str (), (sint)TopLargeLabel.size (), &labelRect, DT_LEFT|DT_TOP); - - CDialog::OnPaint(); - } -} - -// *************************************************************************** - -HCURSOR CClient_configDlg::OnQueryDragIcon() -{ - return (HCURSOR) m_hIcon; -} - -// *************************************************************************** - -void CClient_configDlg::setPage (uint pageId) -{ - CPage &page = Pages[pageId]; - Icon.SetBitmap (Bitmaps[page.Icon]); - TopLargeLabel = NLMISC::CI18N::get (std::string(page.Name)); - - // Hide all the dialog - uint i; - for (i=0; iShowWindow (SW_HIDE); - - // Show the dialog - Dialogs[pageId]->ShowWindow (SW_SHOW); - - // Invalidate bar - InvalidateBar (); - _CurrentPage = pageId; -} - -// *************************************************************************** - -BOOL CClient_configDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) -{ - // TODO: Add your specialized code here and/or call the base class - int idCtrl = (int) wParam; - LPNMHDR pnmh = (LPNMHDR) lParam; - - switch (idCtrl) - { - case TreeId: - { - switch (pnmh->code) - { - case TVN_SELCHANGED: - { - // Get the selection - HTREEITEM item = Tree.GetSelectedItem (); - if (item) - { - // Get the page - uint pageId = (uint)Tree.GetItemData (item); - setPage (pageId); - } - } - break; - } - } - break; - } - - return CDialog::OnNotify(wParam, lParam, pResult); -} - -// *************************************************************************** - -void CClient_configDlg::InvalidateBar () -{ - CRect rect (BAR_START_X, 0, BAR_START_X+BAR_WIDTH, BAR_HEIGHT); - InvalidateRect (&rect); -} - -// *************************************************************************** - -BOOL CClient_configDlg::UpdateData ( BOOL bSaveAndValidate ) -{ - // For each pages - uint i; - for (i=0; iUpdateData (bSaveAndValidate); - } - - return CDialog::UpdateData ( bSaveAndValidate ); -} - -// *************************************************************************** - -void CClient_configDlg::OnApply() -{ - // Update config file - SetToConfigFile (); - - // Save the config file - SaveConfigFile (); - - // Doc is validated - theApp.Modified = false; - ApplyCtrl.EnableWindow (FALSE); - - // Set the title - setWindowText(*this, (WCHAR*)NLMISC::CI18N::get ("uiConfigTitle").c_str()); -} - -// *************************************************************************** - -void CClient_configDlg::OnCancel() -{ - // Modified ? - if (theApp.Modified) - { - // Quit without saving ? - if (theApp.yesNo (NLMISC::CI18N::get ("uiConfigQuitWithoutSaving"))) - { - CDialog::OnCancel(); - } - } - else - CDialog::OnCancel(); -} - -// *************************************************************************** - -void CClient_configDlg::OnOK() -{ - if (theApp.Modified) - { - // Update config file - SetToConfigFile (); - - // Save the config file - SaveConfigFile (); - - // Doc is validated - theApp.Modified = false; - } - - CDialog::OnOK(); -} - -// *************************************************************************** - -void CClient_configDlg::OnDefault() -{ - /* Yoyo: Don't use the preset dlg for now cause doesn't work everywhere - // Open the preset dialog - CPresetDlg preset; - if (preset.DoModal () == IDOK) - { - // Reset the CFG to default - ResetConfigFile(); - - // invalidate - InvalidateConfig (); - - // Update widgets - GetFromConfigFile (); - } - */ - // Quit without saving ? - if (theApp.yesNo (NLMISC::CI18N::get ("uiConfigRestaureDefault"))) - { - // Reset the CFG to default - ResetConfigFileToDefault(); - - // invalidate - InvalidateConfig (); - - // Update widgets - GetFromConfigFile (); - } -} - -// *************************************************************************** - -void CClient_configDlg::OnLaunch() -{ - if (theApp.Modified) - { - // Update config file - SetToConfigFile (); - - // Save the config file - SaveConfigFile (); - - // Doc is validated - theApp.Modified = false; - } - - // launch ryzom - NLMISC::launchProgram("client_ryzom_rd.exe",""); - - CDialog::OnOK(); -} - -// *************************************************************************** - -BOOL CAboutDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - localizeWindowsRec (this, false); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} +// 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 . + +// client_configDlg.cpp : implementation file +// + +#include "stdafx.h" +#include "client_config.h" +#include "client_configDlg.h" +#include "cfg_file.h" +#include "database.h" + +#include +#include + +#define ICON_ZONE_WIDTH 128 + +#define LEFT_WIDTH 256 +#define LEFT_HEIGHT 512 + +#define BAR_START_X (LEFT_WIDTH+ICON_ZONE_WIDTH) +#define BAR_WIDTH 448 +#define BAR_HEIGHT 72 +#define TREE_ZONE_WIDTH 150 +#define TREE_OFFSET_LEFT 10 +#define TREE_OFFSET_TOP 10 + +// Label +#define LARGE_LABEL_HEIGHT -22 +#define LARGE_LABEL_START_X (LEFT_WIDTH+TREE_ZONE_WIDTH) +#define LARGE_LABEL_START_Y (15) +#define LARGE_LABEL_END_X (LEFT_WIDTH+ICON_ZONE_WIDTH+BAR_WIDTH) +#define LARGE_LABEL_END_Y BAR_HEIGHT + +// Icon +#define ICON_WIDTH 64 +#define ICON_HEIGHT 64 +#define ICON_START_Y ((BAR_HEIGHT-ICON_HEIGHT)/2) +#define ICON_START_X (LEFT_WIDTH+ICON_START_Y) +#define ICON_START_Y ((BAR_HEIGHT-ICON_HEIGHT)/2) + +// *************************************************************************** +// CAboutDlg dialog used for App About +// *************************************************************************** + +class CAboutDlg : public CDialog +{ +public: + CAboutDlg(); + +// Dialog Data + //{{AFX_DATA(CAboutDlg) + enum { IDD = IDD_ABOUTBOX }; + //}}AFX_DATA + + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CAboutDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + //{{AFX_MSG(CAboutDlg) + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +// *************************************************************************** + +CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) +{ + //{{AFX_DATA_INIT(CAboutDlg) + //}}AFX_DATA_INIT +} + +// *************************************************************************** + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CAboutDlg) + //}}AFX_DATA_MAP +} + +// *************************************************************************** + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) + //{{AFX_MSG_MAP(CAboutDlg) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +// *************************************************************************** +// CClient_configDlg dialog +// *************************************************************************** + +CClient_configDlg::CClient_configDlg(CWnd* pParent /*=NULL*/) + : CDialog(CClient_configDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(CClient_configDlg) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 + m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); + + // Init dialog pointers + Dialogs[PageGeneral] = &GeneralDlg; + Dialogs[PageDisplay] = &DisplayDlg; + Dialogs[PageDisplayDetails] = &DisplayDetailsDlg; + Dialogs[PageDisplayAdvanced] = &DisplayAdvancedDlg; + Dialogs[PageDisplaySysInfo] = &SystemInformationDlg; + Dialogs[PageDisplayOpenGLInfo] = &DisplayInformationGLDlg; + Dialogs[PageDisplayOpenD3DInfo] = &DisplayInformationD3DDlg; + Dialogs[PageSound] = &SoundDlg; + _CurrentPage = 0; +} + +// *************************************************************************** + +void CClient_configDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CClient_configDlg) + DDX_Control(pDX, ID_APPLY, ApplyCtrl); + //}}AFX_DATA_MAP +} + +// *************************************************************************** + +BEGIN_MESSAGE_MAP(CClient_configDlg, CDialog) + //{{AFX_MSG_MAP(CClient_configDlg) + ON_WM_SYSCOMMAND() + ON_WM_PAINT() + ON_WM_QUERYDRAGICON() + ON_BN_CLICKED(ID_APPLY, OnApply) + ON_BN_CLICKED(ID_DEFAULT, OnDefault) + ON_BN_CLICKED(ID_LAUNCH, OnLaunch) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +// *************************************************************************** +// CClient_configDlg message handlers +// *************************************************************************** + +BOOL CClient_configDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // Add "About..." menu item to system menu. + + // IDM_ABOUTBOX must be in the system command range. + ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); + ASSERT(IDM_ABOUTBOX < 0xF000); + + CMenu* pSysMenu = GetSystemMenu(FALSE); + if (pSysMenu != NULL) + { + CString strAboutMenu = "uiConfigMenuAbout"; + if (!strAboutMenu.IsEmpty()) + { + pSysMenu->AppendMenu(MF_SEPARATOR); + pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); + } + } + + // Set the icon for this dialog. The framework does this automatically + // when the application's main window is not a dialog + SetIcon(m_hIcon, TRUE); // Set big icon + SetIcon(m_hIcon, FALSE); // Set small icon + + // Create bitmaps + uint i; + for (i=0; iCreate (Pages[i].ResId, this)); + nlverify (Dialogs[i]->SetWindowPos (NULL, LEFT_WIDTH+TREE_ZONE_WIDTH, BAR_HEIGHT+2, 0, 0, SWP_NOZORDER|SWP_NOSIZE)); + } + + // Build the tree + CPage *page = Root.Children[0]; + HTREEITEM parent = TVI_ROOT; + while (page) + { + // Add an item + parent = Tree.InsertItem ("", parent); + Tree.SetItemData (parent, page->PageId); + if (page->Bold) + Tree.SetItemState (parent, TVIS_BOLD, TVIS_BOLD); + + // Next + if (page->Children.size ()) + page = page->Children[0]; + else + { + // Got a parent ? + while (page->Parent) + { + // Brother ? + if (page->ChildId < page->Parent->Children.size ()-1) + { + page = page->Parent->Children[page->ChildId+1]; + parent = Tree.GetParentItem (parent); + break; + } + else + { + page = page->Parent; + parent = Tree.GetParentItem (parent); + Tree.Expand (parent, TVE_EXPAND); + } + } + if (!page->Parent) + break; + } + } + + ApplyCtrl.EnableWindow (FALSE); + + // Get from the config file + GetFromConfigFile (); + + theApp.Modified = false; + + // Build the localisation map + backupWindowHandleRec (); + + // Localize the windows + changeLanguage (::GetIntForceLanguage()?"en" : ::GetString ("LanguageCode").c_str()); + theApp.Localized = true; + + // Focus + Tree.SelectItem(Tree.GetChildItem (Tree.GetRootItem())); + Tree.SetFocus (); + + return TRUE; // return TRUE unless you set the focus to a control +} + +// *************************************************************************** + +void CClient_configDlg::changeLanguage (const char *language) +{ + // Init CI18N + NLMISC::CI18N::load(language); + + localizeWindowsRec (); + translateTree (); + + // Set the general page + setPage (_CurrentPage); + + DisplayDlg.updateState (); + DisplayDlg.UpdateData (FALSE); + DisplayDetailsDlg.updateState (); + SoundDlg.updateState (); + + // Set the title + setWindowText(*this, (WCHAR*)((NLMISC::CI18N::get ("uiConfigTitle") + (theApp.Modified?" *":"")).c_str())); + + // The menu + CMenu* pSysMenu = GetSystemMenu(FALSE); + if (pSysMenu) + { + if (NLMISC::CSystemUtils::supportUnicode()) + { + nlverify (::ModifyMenuW(*pSysMenu, IDM_ABOUTBOX, MF_BYCOMMAND|MF_STRING, IDM_ABOUTBOX, (WCHAR*)NLMISC::CI18N::get ("uiConfigMenuAbout").c_str())); + } + else + { + nlverify (::ModifyMenu(*pSysMenu, IDM_ABOUTBOX, MF_BYCOMMAND|MF_STRING, IDM_ABOUTBOX, (LPCTSTR)NLMISC::CI18N::get ("uiConfigMenuAbout").toString().c_str())); + } + } +} + +// *************************************************************************** + +void CClient_configDlg::translateTree () +{ + // Set the item text + HTREEITEM item = Tree.GetRootItem (); + while (item) + { + // Set the item text + uint page = (uint)Tree.GetItemData (item); + ucstring name = NLMISC::CI18N::get (Pages[page].Name); + if (NLMISC::CSystemUtils::supportUnicode()) + { + TVITEMEXW itemDesc; + memset (&itemDesc, 0, sizeof(TVITEMEXW)); + itemDesc.hItem = item; + itemDesc.mask = TVIF_TEXT; + itemDesc.pszText = (WCHAR*)name.c_str(); + nlverify (SendMessageW (Tree, TVM_SETITEMW, 0, (LPARAM)&itemDesc)); + } + else + { + TVITEMEXA itemDesc; + memset (&itemDesc, 0, sizeof(TVITEMEXA)); + itemDesc.hItem = item; + itemDesc.mask = TVIF_TEXT; + std::string tmpStr = name.toString(); + itemDesc.pszText = (LPSTR) tmpStr.c_str(); + nlverify (::SendMessageA(Tree, TVM_SETITEMA, 0 , (LPARAM)&itemDesc)); + } + // Next item + HTREEITEM old = item; + item = Tree.GetChildItem (item); + if (!item) + { + // No more child, try a brother + item = Tree.GetNextSiblingItem (old); + } + if (!item) + { + // No more brother, try an oncle + item = Tree.GetParentItem (old); + if (item) + item = Tree.GetNextSiblingItem (item); + } + } +} + +// *************************************************************************** + +void CClient_configDlg::OnSysCommand(UINT nID, LPARAM lParam) +{ + if ((nID & 0xFFF0) == IDM_ABOUTBOX) + { + CAboutDlg dlgAbout; + dlgAbout.DoModal(); + } + else + { + CDialog::OnSysCommand(nID, lParam); + } +} + +// *************************************************************************** + +// If you add a minimize button to your dialog, you will need the code below +// to draw the icon. For MFC applications using the document/view model, +// this is automatically done for you by the framework. + +void CClient_configDlg::OnPaint() +{ + if (IsIconic()) + { + CPaintDC dc(this); // device context for painting + + SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); + + // Center icon in client rectangle + int cxIcon = GetSystemMetrics(SM_CXICON); + int cyIcon = GetSystemMetrics(SM_CYICON); + CRect rect; + GetClientRect(&rect); + int x = (rect.Width() - cxIcon + 1) / 2; + int y = (rect.Height() - cyIcon + 1) / 2; + + // Draw the icon + dc.DrawIcon(x, y, m_hIcon); + } + else + { + // Draw rect + CPaintDC dc(this); // device context for painting + dc.FillSolidRect( LEFT_WIDTH, BAR_HEIGHT+2, TREE_ZONE_WIDTH, LEFT_HEIGHT-BAR_HEIGHT-2, GetSysColor (COLOR_WINDOW)); + + // Draw top bar + dc.FillSolidRect( LEFT_WIDTH, 0, ICON_ZONE_WIDTH, BAR_HEIGHT, RGB (255,255,255)); + CDC bitmapDC; + bitmapDC.CreateCompatibleDC (&dc); + bitmapDC.SelectObject (&Bitmaps[BitmapTopRight]); + nlverify (dc.BitBlt( LEFT_WIDTH + ICON_ZONE_WIDTH, 0, BAR_WIDTH, BAR_HEIGHT, &bitmapDC, 0, 0, SRCCOPY)); + + // Draw some text + dc.SetBkMode (TRANSPARENT); + dc.SelectObject (&BarFont); + CRect labelRect (LARGE_LABEL_START_X, LARGE_LABEL_START_Y, LARGE_LABEL_END_X, LARGE_LABEL_END_Y); + DrawTextW (&(*dc), (WCHAR*)TopLargeLabel.c_str (), (sint)TopLargeLabel.size (), &labelRect, DT_LEFT|DT_TOP); + + CDialog::OnPaint(); + } +} + +// *************************************************************************** + +HCURSOR CClient_configDlg::OnQueryDragIcon() +{ + return (HCURSOR) m_hIcon; +} + +// *************************************************************************** + +void CClient_configDlg::setPage (uint pageId) +{ + CPage &page = Pages[pageId]; + Icon.SetBitmap (Bitmaps[page.Icon]); + TopLargeLabel = NLMISC::CI18N::get (std::string(page.Name)); + + // Hide all the dialog + uint i; + for (i=0; iShowWindow (SW_HIDE); + + // Show the dialog + Dialogs[pageId]->ShowWindow (SW_SHOW); + + // Invalidate bar + InvalidateBar (); + _CurrentPage = pageId; +} + +// *************************************************************************** + +BOOL CClient_configDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) +{ + // TODO: Add your specialized code here and/or call the base class + int idCtrl = (int) wParam; + LPNMHDR pnmh = (LPNMHDR) lParam; + + switch (idCtrl) + { + case TreeId: + { + switch (pnmh->code) + { + case TVN_SELCHANGED: + { + // Get the selection + HTREEITEM item = Tree.GetSelectedItem (); + if (item) + { + // Get the page + uint pageId = (uint)Tree.GetItemData (item); + setPage (pageId); + } + } + break; + } + } + break; + } + + return CDialog::OnNotify(wParam, lParam, pResult); +} + +// *************************************************************************** + +void CClient_configDlg::InvalidateBar () +{ + CRect rect (BAR_START_X, 0, BAR_START_X+BAR_WIDTH, BAR_HEIGHT); + InvalidateRect (&rect); +} + +// *************************************************************************** + +BOOL CClient_configDlg::UpdateData ( BOOL bSaveAndValidate ) +{ + // For each pages + uint i; + for (i=0; iUpdateData (bSaveAndValidate); + } + + return CDialog::UpdateData ( bSaveAndValidate ); +} + +// *************************************************************************** + +void CClient_configDlg::OnApply() +{ + // Update config file + SetToConfigFile (); + + // Save the config file + SaveConfigFile (); + + // Doc is validated + theApp.Modified = false; + ApplyCtrl.EnableWindow (FALSE); + + // Set the title + setWindowText(*this, (WCHAR*)NLMISC::CI18N::get ("uiConfigTitle").c_str()); +} + +// *************************************************************************** + +void CClient_configDlg::OnCancel() +{ + // Modified ? + if (theApp.Modified) + { + // Quit without saving ? + if (theApp.yesNo (NLMISC::CI18N::get ("uiConfigQuitWithoutSaving"))) + { + CDialog::OnCancel(); + } + } + else + CDialog::OnCancel(); +} + +// *************************************************************************** + +void CClient_configDlg::OnOK() +{ + if (theApp.Modified) + { + // Update config file + SetToConfigFile (); + + // Save the config file + SaveConfigFile (); + + // Doc is validated + theApp.Modified = false; + } + + CDialog::OnOK(); +} + +// *************************************************************************** + +void CClient_configDlg::OnDefault() +{ + /* Yoyo: Don't use the preset dlg for now cause doesn't work everywhere + // Open the preset dialog + CPresetDlg preset; + if (preset.DoModal () == IDOK) + { + // Reset the CFG to default + ResetConfigFile(); + + // invalidate + InvalidateConfig (); + + // Update widgets + GetFromConfigFile (); + } + */ + // Quit without saving ? + if (theApp.yesNo (NLMISC::CI18N::get ("uiConfigRestaureDefault"))) + { + // Reset the CFG to default + ResetConfigFileToDefault(); + + // invalidate + InvalidateConfig (); + + // Update widgets + GetFromConfigFile (); + } +} + +// *************************************************************************** + +void CClient_configDlg::OnLaunch() +{ + if (theApp.Modified) + { + // Update config file + SetToConfigFile (); + + // Save the config file + SaveConfigFile (); + + // Doc is validated + theApp.Modified = false; + } + + // launch ryzom + NLMISC::launchProgram("client_ryzom_rd.exe",""); + + CDialog::OnOK(); +} + +// *************************************************************************** + +BOOL CAboutDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + localizeWindowsRec (this, false); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} diff --git a/code/ryzom/tools/client/client_config/client_configDlg.h b/code/ryzom/tools/client/client_config/client_configDlg.h index efd910c6e..88277f934 100644 --- a/code/ryzom/tools/client/client_config/client_configDlg.h +++ b/code/ryzom/tools/client/client_config/client_configDlg.h @@ -1,133 +1,133 @@ -// 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 . - -// client_configDlg.h : header file -// - -#if !defined(AFX_CLIENT_CONFIGDLG_H__B16BC0AD_3679_4AFF_BC6C_3AB03CBC2948__INCLUDED_) -#define AFX_CLIENT_CONFIGDLG_H__B16BC0AD_3679_4AFF_BC6C_3AB03CBC2948__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include "bar.h" -#include "database.h" -#include "general_dlg.h" -#include "display_dlg.h" -#include "display_details_dlg.h" -#include "display_advanced_dlg.h" -#include "system_information_dlg.h" -#include "display_information_gl_dlg.h" -#include "display_information_d3d_dlg.h" -#include "sound_dlg.h" - -// *************************************************************************** -// CClient_configDlg dialog -// *************************************************************************** - -enum -{ - TreeId = 255, -}; - -// *************************************************************************** - -class CClient_configDlg : public CDialog -{ -// Construction -public: - CClient_configDlg(CWnd* pParent = NULL); // standard constructor - - // Bitmaps - CBitmap Bitmaps[BitmapCount]; - - // Fonts - CFont BarFont; - - // Controls - CStatic Left; - CStatic Icon; - CBar Top; - CBar Bottom; - CTreeCtrl Tree; - - // Dialogs - CDialog *Dialogs[PageCount]; - CGeneralDlg GeneralDlg; - CDisplayDlg DisplayDlg; - CDisplayDetailsDlg DisplayDetailsDlg; - CDisplayAdvancedDlg DisplayAdvancedDlg; - CSoundDlg SoundDlg; - CSystemInformationDlg SystemInformationDlg; - CDisplayInformationGlDlg DisplayInformationGLDlg; - CDisplayInformationD3DDlg DisplayInformationD3DDlg; - - // Large label top bar string - ucstring TopLargeLabel; - - // Methods - void InvalidateBar (); - - // Overrided - virtual - BOOL UpdateData ( BOOL bSaveAndValidate ); - - void setPage (uint pageId); - void translateTree (); - void changeLanguage (const char *language); - -// Dialog Data - //{{AFX_DATA(CClient_configDlg) - enum { IDD = IDD_CLIENT_CONFIG_DIALOG }; - CButton ApplyCtrl; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CClient_configDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); - //}}AFX_VIRTUAL - -// Implementation -protected: - HICON m_hIcon; - uint _CurrentPage; - - // Hwnd to stringId map - std::map _HwndMap; - - // Generated message map functions - //{{AFX_MSG(CClient_configDlg) - virtual BOOL OnInitDialog(); - afx_msg void OnSysCommand(UINT nID, LPARAM lParam); - afx_msg void OnPaint(); - afx_msg HCURSOR OnQueryDragIcon(); - afx_msg void OnApply(); - afx_msg void OnDefault(); - afx_msg void OnLaunch(); - //}}AFX_MSG -public: - virtual void OnCancel(); - virtual void OnOK(); - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_CLIENT_CONFIGDLG_H__B16BC0AD_3679_4AFF_BC6C_3AB03CBC2948__INCLUDED_) +// 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 . + +// client_configDlg.h : header file +// + +#if !defined(AFX_CLIENT_CONFIGDLG_H__B16BC0AD_3679_4AFF_BC6C_3AB03CBC2948__INCLUDED_) +#define AFX_CLIENT_CONFIGDLG_H__B16BC0AD_3679_4AFF_BC6C_3AB03CBC2948__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "bar.h" +#include "database.h" +#include "general_dlg.h" +#include "display_dlg.h" +#include "display_details_dlg.h" +#include "display_advanced_dlg.h" +#include "system_information_dlg.h" +#include "display_information_gl_dlg.h" +#include "display_information_d3d_dlg.h" +#include "sound_dlg.h" + +// *************************************************************************** +// CClient_configDlg dialog +// *************************************************************************** + +enum +{ + TreeId = 255, +}; + +// *************************************************************************** + +class CClient_configDlg : public CDialog +{ +// Construction +public: + CClient_configDlg(CWnd* pParent = NULL); // standard constructor + + // Bitmaps + CBitmap Bitmaps[BitmapCount]; + + // Fonts + CFont BarFont; + + // Controls + CStatic Left; + CStatic Icon; + CBar Top; + CBar Bottom; + CTreeCtrl Tree; + + // Dialogs + CDialog *Dialogs[PageCount]; + CGeneralDlg GeneralDlg; + CDisplayDlg DisplayDlg; + CDisplayDetailsDlg DisplayDetailsDlg; + CDisplayAdvancedDlg DisplayAdvancedDlg; + CSoundDlg SoundDlg; + CSystemInformationDlg SystemInformationDlg; + CDisplayInformationGlDlg DisplayInformationGLDlg; + CDisplayInformationD3DDlg DisplayInformationD3DDlg; + + // Large label top bar string + ucstring TopLargeLabel; + + // Methods + void InvalidateBar (); + + // Overrided + virtual + BOOL UpdateData ( BOOL bSaveAndValidate ); + + void setPage (uint pageId); + void translateTree (); + void changeLanguage (const char *language); + +// Dialog Data + //{{AFX_DATA(CClient_configDlg) + enum { IDD = IDD_CLIENT_CONFIG_DIALOG }; + CButton ApplyCtrl; + //}}AFX_DATA + + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CClient_configDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); + //}}AFX_VIRTUAL + +// Implementation +protected: + HICON m_hIcon; + uint _CurrentPage; + + // Hwnd to stringId map + std::map _HwndMap; + + // Generated message map functions + //{{AFX_MSG(CClient_configDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnSysCommand(UINT nID, LPARAM lParam); + afx_msg void OnPaint(); + afx_msg HCURSOR OnQueryDragIcon(); + afx_msg void OnApply(); + afx_msg void OnDefault(); + afx_msg void OnLaunch(); + //}}AFX_MSG +public: + virtual void OnCancel(); + virtual void OnOK(); + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_CLIENT_CONFIGDLG_H__B16BC0AD_3679_4AFF_BC6C_3AB03CBC2948__INCLUDED_) diff --git a/code/ryzom/tools/client/client_config/database.cpp b/code/ryzom/tools/client/client_config/database.cpp index 493b61594..18ec56f63 100644 --- a/code/ryzom/tools/client/client_config/database.cpp +++ b/code/ryzom/tools/client/client_config/database.cpp @@ -1,220 +1,220 @@ -// 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 "stdafx.h" -#include "database.h" -#include "resource.h" -#include "client_config.h" - -using namespace NLMISC; -using namespace std; - -// *************************************************************************** -// Bitmaps -// *************************************************************************** - -const CBitmapId BitmapId[BitmapCount] = -{ - { IDB_DISPLAY }, - { IDB_DISPLAY_DETAILS }, - { IDB_DISPLAY_ADVANCED }, - { IDB_CARD }, - { IDB_GENERAL }, - { IDB_NETWORK }, - { IDB_SOUND }, - { IDB_UPDATE }, - { IDB_TOP_RIGHT }, - { IDB_WELCOME }, -}; - -// *************************************************************************** -// Pages -// *************************************************************************** - -CPage Root; - -// *************************************************************************** - -CPage Pages[PageCount]; - -// *************************************************************************** - -void CreateDataBase () -{ - Pages[PageGeneral].init (PageGeneral, "uiConfigGeneral", true, BitmapGeneral, IDD_GENERAL, &Root); - Pages[PageDisplay].init (PageDisplay, "uiConfigDisplay", true, BitmapDisplay, IDD_DISPLAY, &Root); - Pages[PageDisplayDetails].init (PageDisplayDetails, "uiConfigDisplayDetails", false, BitmapDisplayDetails, IDD_DISPLAY_DETAILS, &Pages[PageDisplay]); - Pages[PageDisplayAdvanced].init (PageDisplayAdvanced, "uiConfigDisplayAdvanced", false, BitmapDisplayAdvanced, IDD_DISPLAY_ADVANCED, &Pages[PageDisplay]); - Pages[PageSound].init (PageSound, "uiConfigSound", true, BitmapSound, IDD_SOUND, &Root); - Pages[PageDisplaySysInfo].init (PageDisplaySysInfo, "uiConfigDisplaySysInfo", true, BitmapGeneral, IDD_SYSTEM_INFO, &Root); - Pages[PageDisplayOpenGLInfo].init (PageDisplayOpenGLInfo, "uiConfigDisplayOpenGLInfo", false, BitmapCard, IDD_DISPLAY_INFO, &Pages[PageDisplaySysInfo]); - Pages[PageDisplayOpenD3DInfo].init (PageDisplayOpenD3DInfo, "uiConfigDisplayD3DInfo", false, BitmapCard, IDD_DISPLAY_D3D, &Pages[PageDisplaySysInfo]); -}; - -// *************************************************************************** - -CPage::CPage () -{ - Parent = NULL; - ChildId = 0xffffffff; -} - -// *************************************************************************** - -void CPage::init (uint id, const char *name, bool bold, uint icon, uint resid, CPage *parent) -{ - PageId = id; - Parent = parent; - Icon = icon; - ResId = resid; - ChildId = (uint)parent->Children.size (); - if (parent) - parent->Children.push_back (this); - Name = name; - Bold = bold; -} - -// *************************************************************************** - -void CPage::select () -{ - -} - -// *************************************************************************** -// Config File default -// *************************************************************************** - -NLMISC::CConfigFile ConfigFileDefault; - -void LoadConfigFileDefault () -{ - try - { - ConfigFileDefault.load (CONFIG_DEFAULT_FILE_NAME); - } - catch (Exception &e) - { - theApp.error (CI18N::get ("uiConfigErrorReadingTheFile")+" "CONFIG_FILE_NAME" : "+string (e.what ())); - } -} - -// *************************************************************************** -// Merge method -// *************************************************************************** - -struct CMergeDescriptor -{ - const char *Name; - TMergeMethod Method; -}; - -// *************************************************************************** - -static const CMergeDescriptor MergeDescriptor[] = -{ - { "DivideTextureSizeBy2", PreferSuperior }, - { "LandscapeThreshold", PreferInferior }, - { "MicroVeget", PreferFalse }, - { "HDEntityTexture", PreferFalse }, - { "Shadows", PreferFalse }, - { "DisableDXTC", PreferFalse }, - { "DisableVtxProgram", PreferTrue }, - { "DisableVtxAGP", PreferTrue }, - { "DisableTextureShdr", PreferTrue }, - { "SoundOn", PreferFalse }, - { "UseEax", PreferFalse }, - { "MaxTrack", PreferSuperior }, -}; - -// *************************************************************************** - -TMergeMethod GetMergeMethod (const char *varName) -{ - const uint count = sizeof (MergeDescriptor) / sizeof (CMergeDescriptor); - uint i; - for (i=0; i +// 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 "stdafx.h" +#include "database.h" +#include "resource.h" +#include "client_config.h" + +using namespace NLMISC; +using namespace std; + +// *************************************************************************** +// Bitmaps +// *************************************************************************** + +const CBitmapId BitmapId[BitmapCount] = +{ + { IDB_DISPLAY }, + { IDB_DISPLAY_DETAILS }, + { IDB_DISPLAY_ADVANCED }, + { IDB_CARD }, + { IDB_GENERAL }, + { IDB_NETWORK }, + { IDB_SOUND }, + { IDB_UPDATE }, + { IDB_TOP_RIGHT }, + { IDB_WELCOME }, +}; + +// *************************************************************************** +// Pages +// *************************************************************************** + +CPage Root; + +// *************************************************************************** + +CPage Pages[PageCount]; + +// *************************************************************************** + +void CreateDataBase () +{ + Pages[PageGeneral].init (PageGeneral, "uiConfigGeneral", true, BitmapGeneral, IDD_GENERAL, &Root); + Pages[PageDisplay].init (PageDisplay, "uiConfigDisplay", true, BitmapDisplay, IDD_DISPLAY, &Root); + Pages[PageDisplayDetails].init (PageDisplayDetails, "uiConfigDisplayDetails", false, BitmapDisplayDetails, IDD_DISPLAY_DETAILS, &Pages[PageDisplay]); + Pages[PageDisplayAdvanced].init (PageDisplayAdvanced, "uiConfigDisplayAdvanced", false, BitmapDisplayAdvanced, IDD_DISPLAY_ADVANCED, &Pages[PageDisplay]); + Pages[PageSound].init (PageSound, "uiConfigSound", true, BitmapSound, IDD_SOUND, &Root); + Pages[PageDisplaySysInfo].init (PageDisplaySysInfo, "uiConfigDisplaySysInfo", true, BitmapGeneral, IDD_SYSTEM_INFO, &Root); + Pages[PageDisplayOpenGLInfo].init (PageDisplayOpenGLInfo, "uiConfigDisplayOpenGLInfo", false, BitmapCard, IDD_DISPLAY_INFO, &Pages[PageDisplaySysInfo]); + Pages[PageDisplayOpenD3DInfo].init (PageDisplayOpenD3DInfo, "uiConfigDisplayD3DInfo", false, BitmapCard, IDD_DISPLAY_D3D, &Pages[PageDisplaySysInfo]); +}; + +// *************************************************************************** + +CPage::CPage () +{ + Parent = NULL; + ChildId = 0xffffffff; +} + +// *************************************************************************** + +void CPage::init (uint id, const char *name, bool bold, uint icon, uint resid, CPage *parent) +{ + PageId = id; + Parent = parent; + Icon = icon; + ResId = resid; + ChildId = (uint)parent->Children.size (); + if (parent) + parent->Children.push_back (this); + Name = name; + Bold = bold; +} + +// *************************************************************************** + +void CPage::select () +{ + +} + +// *************************************************************************** +// Config File default +// *************************************************************************** + +NLMISC::CConfigFile ConfigFileDefault; + +void LoadConfigFileDefault () +{ + try + { + ConfigFileDefault.load (CONFIG_DEFAULT_FILE_NAME); + } + catch (Exception &e) + { + theApp.error (CI18N::get ("uiConfigErrorReadingTheFile")+" "CONFIG_FILE_NAME" : "+string (e.what ())); + } +} + +// *************************************************************************** +// Merge method +// *************************************************************************** + +struct CMergeDescriptor +{ + const char *Name; + TMergeMethod Method; +}; + +// *************************************************************************** + +static const CMergeDescriptor MergeDescriptor[] = +{ + { "DivideTextureSizeBy2", PreferSuperior }, + { "LandscapeThreshold", PreferInferior }, + { "MicroVeget", PreferFalse }, + { "HDEntityTexture", PreferFalse }, + { "Shadows", PreferFalse }, + { "DisableDXTC", PreferFalse }, + { "DisableVtxProgram", PreferTrue }, + { "DisableVtxAGP", PreferTrue }, + { "DisableTextureShdr", PreferTrue }, + { "SoundOn", PreferFalse }, + { "UseEax", PreferFalse }, + { "MaxTrack", PreferSuperior }, +}; + +// *************************************************************************** + +TMergeMethod GetMergeMethod (const char *varName) +{ + const uint count = sizeof (MergeDescriptor) / sizeof (CMergeDescriptor); + uint i; + for (i=0; i -// 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_DATABASE_H -#define NL_DATABASE_H - -// *************************************************************************** -// Bitmaps -// *************************************************************************** - -enum -{ - BitmapDisplay = 0, - BitmapDisplayDetails, - BitmapDisplayAdvanced, - BitmapCard, - BitmapGeneral, - BitmapNetwork, - BitmapSound, - BitmapUpdate, - BitmapTopRight, - BitmapWelcome, - BitmapCount, -}; - -// *************************************************************************** - -struct CBitmapId -{ -public: - uint ResId; -}; - -// *************************************************************************** - -extern const CBitmapId BitmapId[BitmapCount]; - -// *************************************************************************** -// Pages -// *************************************************************************** - -enum -{ - PageGeneral=0, - PageDisplay, - PageDisplayDetails, - PageDisplayAdvanced, - PageSound, - PageDisplaySysInfo, - PageDisplayOpenGLInfo, - PageDisplayOpenD3DInfo, - PageCount -}; - -// *************************************************************************** - -/** - * Data page - * - * \author Cyril 'Hulud' Corvazier - * \author Nevrax France - * \date 2003 - */ -class CPage -{ -public: - - /// Constructor - CPage (); - void init (uint id, const char *name, bool bold, uint icon, uint resid, CPage *parent); - void select (); - - bool Bold; - uint ChildId; - uint ResId; - - uint PageId; - std::string Name; - uint Icon; - CPage *Parent; - std::vector Children; -}; - -// *************************************************************************** - -extern CPage Pages[PageCount]; - -// *************************************************************************** - -extern CPage Root; - -// *************************************************************************** - -void CreateDataBase (); - -// *************************************************************************** -// Config File default -// *************************************************************************** - -void LoadConfigFileDefault (); - -extern NLMISC::CConfigFile ConfigFileDefault; - -// *************************************************************************** -// Merge method -// *************************************************************************** - -enum TMergeMethod -{ - PreferInferior = 0, // Default - PreferSuperior, - PreferTrue, - PreferFalse, -}; - -TMergeMethod GetMergeMethod (const char *varName); - -// *************************************************************************** -// Quality -// *************************************************************************** - -#define QUALITY_STEP 4 -#define QUALITY_TEXTURE_STEP 3 - -extern const float QualityToLandscapeThreshold[QUALITY_STEP]; -extern const float QualityToZFar[QUALITY_STEP]; -extern const float QualityToLandscapeTileNear[QUALITY_STEP]; -extern const int QualityToSkinNbMaxPoly[QUALITY_STEP]; -extern const int QualityToNbMaxSkeletonNotCLod[QUALITY_STEP]; -extern const int QualityToFxNbMaxPoly[QUALITY_STEP]; - -// *************************************************************************** - -template -int GetQuality (const T *table, T value) -{ - if (table[0] < table[QUALITY_STEP-1]) - { - uint i=0; - while ((ivalue)) - i++; - return i; - } -} - -// *************************************************************************** - -#endif // NL_DATABASE_H - -/* End of database.h */ +// 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_DATABASE_H +#define NL_DATABASE_H + +// *************************************************************************** +// Bitmaps +// *************************************************************************** + +enum +{ + BitmapDisplay = 0, + BitmapDisplayDetails, + BitmapDisplayAdvanced, + BitmapCard, + BitmapGeneral, + BitmapNetwork, + BitmapSound, + BitmapUpdate, + BitmapTopRight, + BitmapWelcome, + BitmapCount, +}; + +// *************************************************************************** + +struct CBitmapId +{ +public: + uint ResId; +}; + +// *************************************************************************** + +extern const CBitmapId BitmapId[BitmapCount]; + +// *************************************************************************** +// Pages +// *************************************************************************** + +enum +{ + PageGeneral=0, + PageDisplay, + PageDisplayDetails, + PageDisplayAdvanced, + PageSound, + PageDisplaySysInfo, + PageDisplayOpenGLInfo, + PageDisplayOpenD3DInfo, + PageCount +}; + +// *************************************************************************** + +/** + * Data page + * + * \author Cyril 'Hulud' Corvazier + * \author Nevrax France + * \date 2003 + */ +class CPage +{ +public: + + /// Constructor + CPage (); + void init (uint id, const char *name, bool bold, uint icon, uint resid, CPage *parent); + void select (); + + bool Bold; + uint ChildId; + uint ResId; + + uint PageId; + std::string Name; + uint Icon; + CPage *Parent; + std::vector Children; +}; + +// *************************************************************************** + +extern CPage Pages[PageCount]; + +// *************************************************************************** + +extern CPage Root; + +// *************************************************************************** + +void CreateDataBase (); + +// *************************************************************************** +// Config File default +// *************************************************************************** + +void LoadConfigFileDefault (); + +extern NLMISC::CConfigFile ConfigFileDefault; + +// *************************************************************************** +// Merge method +// *************************************************************************** + +enum TMergeMethod +{ + PreferInferior = 0, // Default + PreferSuperior, + PreferTrue, + PreferFalse, +}; + +TMergeMethod GetMergeMethod (const char *varName); + +// *************************************************************************** +// Quality +// *************************************************************************** + +#define QUALITY_STEP 4 +#define QUALITY_TEXTURE_STEP 3 + +extern const float QualityToLandscapeThreshold[QUALITY_STEP]; +extern const float QualityToZFar[QUALITY_STEP]; +extern const float QualityToLandscapeTileNear[QUALITY_STEP]; +extern const int QualityToSkinNbMaxPoly[QUALITY_STEP]; +extern const int QualityToNbMaxSkeletonNotCLod[QUALITY_STEP]; +extern const int QualityToFxNbMaxPoly[QUALITY_STEP]; + +// *************************************************************************** + +template +int GetQuality (const T *table, T value) +{ + if (table[0] < table[QUALITY_STEP-1]) + { + uint i=0; + while ((ivalue)) + i++; + return i; + } +} + +// *************************************************************************** + +#endif // NL_DATABASE_H + +/* End of database.h */ diff --git a/code/ryzom/tools/client/client_config/display_advanced_dlg.cpp b/code/ryzom/tools/client/client_config/display_advanced_dlg.cpp index 1bb38cd40..718a338eb 100644 --- a/code/ryzom/tools/client/client_config/display_advanced_dlg.cpp +++ b/code/ryzom/tools/client/client_config/display_advanced_dlg.cpp @@ -1,95 +1,95 @@ -// 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 . - -// display_advanced_dlg.cpp : implementation file -// - -#include "stdafx.h" -#include "client_config.h" -#include "display_advanced_dlg.h" -#include "cfg_file.h" - -// *************************************************************************** -// CDisplayAdvancedDlg dialog -// *************************************************************************** - -CDisplayAdvancedDlg::CDisplayAdvancedDlg(CWnd* pParent /*=NULL*/) - : CBaseDialog(CDisplayAdvancedDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CDisplayAdvancedDlg) - DisableAGPVertices = FALSE; - DisableTextureShaders = FALSE; - DisableVertexProgram = FALSE; - DisableDXTC = FALSE; - //}}AFX_DATA_INIT -} - -// *************************************************************************** - -void CDisplayAdvancedDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CDisplayAdvancedDlg) - DDX_Check(pDX, IDC_DISABLE_AGP_VERTICES, DisableAGPVertices); - DDX_Check(pDX, IDC_DISABLE_TEXTURE_SHADERS, DisableTextureShaders); - DDX_Check(pDX, IDC_DISABLE_VERTEX_PROGRAM, DisableVertexProgram); - DDX_Check(pDX, IDC_FORCE_DXTC, DisableDXTC); - //}}AFX_DATA_MAP -} - -// *************************************************************************** - -BEGIN_MESSAGE_MAP(CDisplayAdvancedDlg, CDialog) - //{{AFX_MSG_MAP(CDisplayAdvancedDlg) - ON_BN_CLICKED(IDC_DISABLE_AGP_VERTICES, OnDisableAgpVertices) - ON_BN_CLICKED(IDC_DISABLE_TEXTURE_SHADERS, OnDisableTextureShaders) - ON_BN_CLICKED(IDC_DISABLE_VERTEX_PROGRAM, OnDisableVertexProgram) - ON_BN_CLICKED(IDC_FORCE_DXTC, OnForceDxtc) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// *************************************************************************** -// CDisplayAdvancedDlg message handlers -// *************************************************************************** - -void CDisplayAdvancedDlg::OnDisableAgpVertices() -{ - InvalidateConfig (); -} - -// *************************************************************************** - -void CDisplayAdvancedDlg::OnDisableTextureShaders() -{ - InvalidateConfig (); -} - -// *************************************************************************** - -void CDisplayAdvancedDlg::OnDisableVertexProgram() -{ - InvalidateConfig (); -} - -// *************************************************************************** - -void CDisplayAdvancedDlg::OnForceDxtc() -{ - InvalidateConfig (); -} - -// *************************************************************************** - +// 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 . + +// display_advanced_dlg.cpp : implementation file +// + +#include "stdafx.h" +#include "client_config.h" +#include "display_advanced_dlg.h" +#include "cfg_file.h" + +// *************************************************************************** +// CDisplayAdvancedDlg dialog +// *************************************************************************** + +CDisplayAdvancedDlg::CDisplayAdvancedDlg(CWnd* pParent /*=NULL*/) + : CBaseDialog(CDisplayAdvancedDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(CDisplayAdvancedDlg) + DisableAGPVertices = FALSE; + DisableTextureShaders = FALSE; + DisableVertexProgram = FALSE; + DisableDXTC = FALSE; + //}}AFX_DATA_INIT +} + +// *************************************************************************** + +void CDisplayAdvancedDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CDisplayAdvancedDlg) + DDX_Check(pDX, IDC_DISABLE_AGP_VERTICES, DisableAGPVertices); + DDX_Check(pDX, IDC_DISABLE_TEXTURE_SHADERS, DisableTextureShaders); + DDX_Check(pDX, IDC_DISABLE_VERTEX_PROGRAM, DisableVertexProgram); + DDX_Check(pDX, IDC_FORCE_DXTC, DisableDXTC); + //}}AFX_DATA_MAP +} + +// *************************************************************************** + +BEGIN_MESSAGE_MAP(CDisplayAdvancedDlg, CDialog) + //{{AFX_MSG_MAP(CDisplayAdvancedDlg) + ON_BN_CLICKED(IDC_DISABLE_AGP_VERTICES, OnDisableAgpVertices) + ON_BN_CLICKED(IDC_DISABLE_TEXTURE_SHADERS, OnDisableTextureShaders) + ON_BN_CLICKED(IDC_DISABLE_VERTEX_PROGRAM, OnDisableVertexProgram) + ON_BN_CLICKED(IDC_FORCE_DXTC, OnForceDxtc) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +// *************************************************************************** +// CDisplayAdvancedDlg message handlers +// *************************************************************************** + +void CDisplayAdvancedDlg::OnDisableAgpVertices() +{ + InvalidateConfig (); +} + +// *************************************************************************** + +void CDisplayAdvancedDlg::OnDisableTextureShaders() +{ + InvalidateConfig (); +} + +// *************************************************************************** + +void CDisplayAdvancedDlg::OnDisableVertexProgram() +{ + InvalidateConfig (); +} + +// *************************************************************************** + +void CDisplayAdvancedDlg::OnForceDxtc() +{ + InvalidateConfig (); +} + +// *************************************************************************** + diff --git a/code/ryzom/tools/client/client_config/display_advanced_dlg.h b/code/ryzom/tools/client/client_config/display_advanced_dlg.h index 9430b9f3a..ba998cbef 100644 --- a/code/ryzom/tools/client/client_config/display_advanced_dlg.h +++ b/code/ryzom/tools/client/client_config/display_advanced_dlg.h @@ -1,70 +1,70 @@ -// 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 . - -#if !defined(AFX_DISPLAY_ADVANCED_H__3B716022_3854_4A05_BC33_0A4738E2C37A__INCLUDED_) -#define AFX_DISPLAY_ADVANCED_H__3B716022_3854_4A05_BC33_0A4738E2C37A__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// display_advanced.h : header file -// -#include "base_dialog.h" - -// *************************************************************************** -// CDisplayAdvancedDlg dialog -// *************************************************************************** - -class CDisplayAdvancedDlg : public CBaseDialog -{ -// Construction -public: - CDisplayAdvancedDlg(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CDisplayAdvancedDlg) - enum { IDD = IDD_DISPLAY_ADVANCED }; - BOOL DisableAGPVertices; - BOOL DisableTextureShaders; - BOOL DisableVertexProgram; - BOOL DisableDXTC; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CDisplayAdvancedDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CDisplayAdvancedDlg) - afx_msg void OnDisableAgpVertices(); - afx_msg void OnDisableTextureShaders(); - afx_msg void OnDisableVertexProgram(); - afx_msg void OnForceDxtc(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_DISPLAY_ADVANCED_H__3B716022_3854_4A05_BC33_0A4738E2C37A__INCLUDED_) +// 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 . + +#if !defined(AFX_DISPLAY_ADVANCED_H__3B716022_3854_4A05_BC33_0A4738E2C37A__INCLUDED_) +#define AFX_DISPLAY_ADVANCED_H__3B716022_3854_4A05_BC33_0A4738E2C37A__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// display_advanced.h : header file +// +#include "base_dialog.h" + +// *************************************************************************** +// CDisplayAdvancedDlg dialog +// *************************************************************************** + +class CDisplayAdvancedDlg : public CBaseDialog +{ +// Construction +public: + CDisplayAdvancedDlg(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CDisplayAdvancedDlg) + enum { IDD = IDD_DISPLAY_ADVANCED }; + BOOL DisableAGPVertices; + BOOL DisableTextureShaders; + BOOL DisableVertexProgram; + BOOL DisableDXTC; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CDisplayAdvancedDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CDisplayAdvancedDlg) + afx_msg void OnDisableAgpVertices(); + afx_msg void OnDisableTextureShaders(); + afx_msg void OnDisableVertexProgram(); + afx_msg void OnForceDxtc(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_DISPLAY_ADVANCED_H__3B716022_3854_4A05_BC33_0A4738E2C37A__INCLUDED_) diff --git a/code/ryzom/tools/client/client_config/display_details_dlg.cpp b/code/ryzom/tools/client/client_config/display_details_dlg.cpp index e000ff3b3..c8e23309a 100644 --- a/code/ryzom/tools/client/client_config/display_details_dlg.cpp +++ b/code/ryzom/tools/client/client_config/display_details_dlg.cpp @@ -1,136 +1,136 @@ -// 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 . - -// display_details_dlg.cpp : implementation file -// - -#include "stdafx.h" -#include "base_dialog.h" -#include "client_config.h" -#include "database.h" -#include "cfg_file.h" -#include "display_details_dlg.h" - -// *************************************************************************** -// CDisplayDetailsDlg dialog -// *************************************************************************** - -CDisplayDetailsDlg::CDisplayDetailsDlg(CWnd* pParent /*=NULL*/) - : CBaseDialog(CDisplayDetailsDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CDisplayDetailsDlg) - CharacterQualityInt = 0; - FXQualityInt = 0; - LandscapeQualityInt = 0; - TextureQualityInt = 0; - //}}AFX_DATA_INIT - - MaxTextureQuality= 1; -} - -// *************************************************************************** - -void CDisplayDetailsDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CDisplayDetailsDlg) - DDX_Control(pDX, IDC_LANDSCAPE_QUALITY, LandscapeQuality); - DDX_Control(pDX, IDC_FX_QUALITY, FXQuality); - DDX_Control(pDX, IDC_CHARACTER_QUALITY, CharacterQuality); - DDX_Control(pDX, IDC_TEXTURE_QUALITY, TextureQuality); - DDX_Control(pDX, IDC_CHARACTER_QUALITY_VALUE, CharacterQualityValue); - DDX_Control(pDX, IDC_FX_QUALITY_VALUE, FXQualityValue); - DDX_Control(pDX, IDC_LANDSCAPE_QUALITY_VALUE, LandscapeQualityValue); - DDX_Control(pDX, IDC_TEXTURE_QUALITY_VALUE, TextureQualityValue); - DDX_Slider(pDX, IDC_CHARACTER_QUALITY, CharacterQualityInt); - DDX_Slider(pDX, IDC_FX_QUALITY, FXQualityInt); - DDX_Slider(pDX, IDC_LANDSCAPE_QUALITY, LandscapeQualityInt); - DDX_Slider(pDX, IDC_TEXTURE_QUALITY, TextureQualityInt); - //}}AFX_DATA_MAP -} - -// *************************************************************************** - -BEGIN_MESSAGE_MAP(CDisplayDetailsDlg, CDialog) - //{{AFX_MSG_MAP(CDisplayDetailsDlg) - ON_WM_HSCROLL() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// *************************************************************************** -// CDisplayDetailsDlg message handlers -// *************************************************************************** - -void InitQuality (CSliderCtrl &slider) -{ - slider.SetRange (0, QUALITY_STEP-1); -} - -// *************************************************************************** - -BOOL CDisplayDetailsDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - InitQuality (LandscapeQuality); - InitQuality (CharacterQuality); - InitQuality (FXQuality); - TextureQuality.SetRange(0, MaxTextureQuality); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -// *************************************************************************** - -void UpdateQuality (int quality, HWND hwnd) -{ - static const char *qualityString[QUALITY_STEP] = { "uiConfigPoor", "uiConfigMedium", "uiConfigNormal", "uiConfigSuper"}; - setWindowText(hwnd, (WCHAR*)NLMISC::CI18N::get (qualityString[quality]).c_str()); -} - -// *************************************************************************** - -void CDisplayDetailsDlg::updateState () -{ - UpdateQuality (LandscapeQualityInt, LandscapeQualityValue); - UpdateQuality (FXQualityInt, FXQualityValue); - UpdateQuality (CharacterQualityInt, CharacterQualityValue); - - // If control has bad range, reset - int rMin, rMax; - TextureQuality.GetRange(rMin, rMax); - if(rMin!=0 || rMax!=MaxTextureQuality) - TextureQuality.SetRange(0, MaxTextureQuality); - - // update texture quality text - static const char *textureString[QUALITY_TEXTURE_STEP] = { "uiConfigTexturePoor", "uiConfigTextureNormal", "uiConfigTextureSuper"}; - setWindowText(TextureQualityValue, (WCHAR*)NLMISC::CI18N::get (textureString[TextureQualityInt]).c_str()); -} - -// *************************************************************************** - -void CDisplayDetailsDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) -{ - // TODO: Add your message handler code here and/or call default - UpdateData (); - updateState (); - UpdateData (FALSE); - InvalidateConfig (); - - CDialog::OnHScroll(nSBCode, nPos, pScrollBar); -} - +// 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 . + +// display_details_dlg.cpp : implementation file +// + +#include "stdafx.h" +#include "base_dialog.h" +#include "client_config.h" +#include "database.h" +#include "cfg_file.h" +#include "display_details_dlg.h" + +// *************************************************************************** +// CDisplayDetailsDlg dialog +// *************************************************************************** + +CDisplayDetailsDlg::CDisplayDetailsDlg(CWnd* pParent /*=NULL*/) + : CBaseDialog(CDisplayDetailsDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(CDisplayDetailsDlg) + CharacterQualityInt = 0; + FXQualityInt = 0; + LandscapeQualityInt = 0; + TextureQualityInt = 0; + //}}AFX_DATA_INIT + + MaxTextureQuality= 1; +} + +// *************************************************************************** + +void CDisplayDetailsDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CDisplayDetailsDlg) + DDX_Control(pDX, IDC_LANDSCAPE_QUALITY, LandscapeQuality); + DDX_Control(pDX, IDC_FX_QUALITY, FXQuality); + DDX_Control(pDX, IDC_CHARACTER_QUALITY, CharacterQuality); + DDX_Control(pDX, IDC_TEXTURE_QUALITY, TextureQuality); + DDX_Control(pDX, IDC_CHARACTER_QUALITY_VALUE, CharacterQualityValue); + DDX_Control(pDX, IDC_FX_QUALITY_VALUE, FXQualityValue); + DDX_Control(pDX, IDC_LANDSCAPE_QUALITY_VALUE, LandscapeQualityValue); + DDX_Control(pDX, IDC_TEXTURE_QUALITY_VALUE, TextureQualityValue); + DDX_Slider(pDX, IDC_CHARACTER_QUALITY, CharacterQualityInt); + DDX_Slider(pDX, IDC_FX_QUALITY, FXQualityInt); + DDX_Slider(pDX, IDC_LANDSCAPE_QUALITY, LandscapeQualityInt); + DDX_Slider(pDX, IDC_TEXTURE_QUALITY, TextureQualityInt); + //}}AFX_DATA_MAP +} + +// *************************************************************************** + +BEGIN_MESSAGE_MAP(CDisplayDetailsDlg, CDialog) + //{{AFX_MSG_MAP(CDisplayDetailsDlg) + ON_WM_HSCROLL() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +// *************************************************************************** +// CDisplayDetailsDlg message handlers +// *************************************************************************** + +void InitQuality (CSliderCtrl &slider) +{ + slider.SetRange (0, QUALITY_STEP-1); +} + +// *************************************************************************** + +BOOL CDisplayDetailsDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + InitQuality (LandscapeQuality); + InitQuality (CharacterQuality); + InitQuality (FXQuality); + TextureQuality.SetRange(0, MaxTextureQuality); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +// *************************************************************************** + +void UpdateQuality (int quality, HWND hwnd) +{ + static const char *qualityString[QUALITY_STEP] = { "uiConfigPoor", "uiConfigMedium", "uiConfigNormal", "uiConfigSuper"}; + setWindowText(hwnd, (WCHAR*)NLMISC::CI18N::get (qualityString[quality]).c_str()); +} + +// *************************************************************************** + +void CDisplayDetailsDlg::updateState () +{ + UpdateQuality (LandscapeQualityInt, LandscapeQualityValue); + UpdateQuality (FXQualityInt, FXQualityValue); + UpdateQuality (CharacterQualityInt, CharacterQualityValue); + + // If control has bad range, reset + int rMin, rMax; + TextureQuality.GetRange(rMin, rMax); + if(rMin!=0 || rMax!=MaxTextureQuality) + TextureQuality.SetRange(0, MaxTextureQuality); + + // update texture quality text + static const char *textureString[QUALITY_TEXTURE_STEP] = { "uiConfigTexturePoor", "uiConfigTextureNormal", "uiConfigTextureSuper"}; + setWindowText(TextureQualityValue, (WCHAR*)NLMISC::CI18N::get (textureString[TextureQualityInt]).c_str()); +} + +// *************************************************************************** + +void CDisplayDetailsDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) +{ + // TODO: Add your message handler code here and/or call default + UpdateData (); + updateState (); + UpdateData (FALSE); + InvalidateConfig (); + + CDialog::OnHScroll(nSBCode, nPos, pScrollBar); +} + diff --git a/code/ryzom/tools/client/client_config/display_details_dlg.h b/code/ryzom/tools/client/client_config/display_details_dlg.h index f82cea5b5..831338a6f 100644 --- a/code/ryzom/tools/client/client_config/display_details_dlg.h +++ b/code/ryzom/tools/client/client_config/display_details_dlg.h @@ -1,79 +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 . - -#if !defined(AFX_DISPLAY_DETAILS_DLG_H__EA308599_3498_4ACD_B048_142FF92055E6__INCLUDED_) -#define AFX_DISPLAY_DETAILS_DLG_H__EA308599_3498_4ACD_B048_142FF92055E6__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// display_details_dlg.h : header file -// - -// *************************************************************************** -// CDisplayDetailsDlg dialog -// *************************************************************************** - -class CDisplayDetailsDlg : public CBaseDialog -{ -// Construction -public: - CDisplayDetailsDlg(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CDisplayDetailsDlg) - enum { IDD = IDD_DISPLAY_DETAILS }; - CSliderCtrl LandscapeQuality; - CSliderCtrl CharacterQuality; - CSliderCtrl FXQuality; - CSliderCtrl TextureQuality; - CStatic CharacterQualityValue; - CStatic FXQualityValue; - CStatic LandscapeQualityValue; - CStatic TextureQualityValue; - int CharacterQualityInt; - int FXQualityInt; - int LandscapeQualityInt; - int TextureQualityInt; - //}}AFX_DATA - - // 2, only for HD texture installed - int MaxTextureQuality; - - void updateState (); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CDisplayDetailsDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CDisplayDetailsDlg) - virtual BOOL OnInitDialog(); - afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_DISPLAY_DETAILS_DLG_H__EA308599_3498_4ACD_B048_142FF92055E6__INCLUDED_) +// 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 . + +#if !defined(AFX_DISPLAY_DETAILS_DLG_H__EA308599_3498_4ACD_B048_142FF92055E6__INCLUDED_) +#define AFX_DISPLAY_DETAILS_DLG_H__EA308599_3498_4ACD_B048_142FF92055E6__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// display_details_dlg.h : header file +// + +// *************************************************************************** +// CDisplayDetailsDlg dialog +// *************************************************************************** + +class CDisplayDetailsDlg : public CBaseDialog +{ +// Construction +public: + CDisplayDetailsDlg(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CDisplayDetailsDlg) + enum { IDD = IDD_DISPLAY_DETAILS }; + CSliderCtrl LandscapeQuality; + CSliderCtrl CharacterQuality; + CSliderCtrl FXQuality; + CSliderCtrl TextureQuality; + CStatic CharacterQualityValue; + CStatic FXQualityValue; + CStatic LandscapeQualityValue; + CStatic TextureQualityValue; + int CharacterQualityInt; + int FXQualityInt; + int LandscapeQualityInt; + int TextureQualityInt; + //}}AFX_DATA + + // 2, only for HD texture installed + int MaxTextureQuality; + + void updateState (); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CDisplayDetailsDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CDisplayDetailsDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_DISPLAY_DETAILS_DLG_H__EA308599_3498_4ACD_B048_142FF92055E6__INCLUDED_) diff --git a/code/ryzom/tools/client/client_config/display_dlg.cpp b/code/ryzom/tools/client/client_config/display_dlg.cpp index 3379d9d71..0c9c98a92 100644 --- a/code/ryzom/tools/client/client_config/display_dlg.cpp +++ b/code/ryzom/tools/client/client_config/display_dlg.cpp @@ -1,502 +1,502 @@ -// 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 . - -// *************************************************************************** -// display_dlg.cpp : implementation file -// *************************************************************************** - -#include "stdafx.h" -#include "client_config.h" -#include "display_dlg.h" -#include "cfg_file.h" - -using namespace std; -using namespace NLMISC; -using namespace NL3D; - -// *************************************************************************** - -std::vector GLExtensions; -std::string GLRenderer; -std::string GLVendor; -std::string GLVersion; -std::string D3DDescription; -std::string D3DDeviceName; -std::string D3DDriver; -std::string D3DDriverVersion; -std::string D3DVendor; - -uint VideoMemory; -uint HardwareSoundBuffer; -uint64 SystemMemory; -uint CPUFrequency; - -bool GetGLInformation () -{ - // *** INIT VARIABLES - - GLExtensions.clear (); - GLRenderer = ""; - GLVendor = ""; - GLVersion = ""; - - // *** INIT OPENGL - - // Register a window class - WNDCLASS wc; - memset(&wc,0,sizeof(wc)); - wc.style = CS_HREDRAW | CS_VREDRAW ;//| CS_DBLCLKS; - wc.lpfnWndProc = DefWindowProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = GetModuleHandle(NULL); - wc.hIcon = (HICON)NULL; - wc.hCursor = LoadCursor(NULL,IDC_ARROW); - wc.hbrBackground = WHITE_BRUSH; - wc.lpszClassName = "RyzomGetGlInformation"; - wc.lpszMenuName = NULL; - if ( !RegisterClass(&wc) ) - return false; - - // Create a window - ULONG WndFlags = WS_OVERLAPPEDWINDOW+WS_CLIPCHILDREN+WS_CLIPSIBLINGS; - RECT WndRect; - WndRect.left=0; - WndRect.top=0; - WndRect.right=100; - WndRect.bottom=100; - HWND hWnd = CreateWindow ( "RyzomGetGlInformation", - "", - WndFlags, - CW_USEDEFAULT,CW_USEDEFAULT, - WndRect.right,WndRect.bottom, - NULL, - NULL, - GetModuleHandle(NULL), - NULL); - if (!hWnd) - return false; - - HDC hDC = GetDC(hWnd); - - // Remove current gl context - wglMakeCurrent (hDC, NULL); - - // Select pixel format - int depth = GetDeviceCaps (hDC, BITSPIXEL); - PIXELFORMATDESCRIPTOR pfd; - memset(&pfd,0,sizeof(pfd)); - pfd.nSize = sizeof(pfd); - pfd.nVersion = 1; - pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; - pfd.iPixelType = PFD_TYPE_RGBA; - pfd.cColorBits = (char)depth; - if(depth<=16) - pfd.cDepthBits = 16; - else - { - pfd.cDepthBits = 24; - pfd.cAlphaBits = 8; - } - pfd.iLayerType = PFD_MAIN_PLANE; - int pf=ChoosePixelFormat(hDC, &pfd); - if (!pf) - return false; - if ( !SetPixelFormat(hDC, pf, &pfd) ) - return false; - - // Create final context - HGLRC hRC = wglCreateContext (hDC); - wglMakeCurrent(hDC, hRC); - - // *** GET INFORMATION - - GLVendor = (const char *) glGetString (GL_VENDOR); - GLRenderer = (const char *) glGetString (GL_RENDERER); - GLVersion = (const char *) glGetString (GL_VERSION); - - // Get extension string - string glext = (char*)glGetString(GL_EXTENSIONS); - const char *token = strtok ( (char*)glext.c_str (), " "); - while( token != NULL ) - { - GLExtensions.push_back (token); - token = strtok( NULL, " "); - } - - // Get proc adress - typedef const char* (APIENTRY * PFNWGFGETEXTENSIONSSTRINGARB) (HDC); - PFNWGFGETEXTENSIONSSTRINGARB wglGetExtensionsStringARB; - if ((wglGetExtensionsStringARB=(PFNWGFGETEXTENSIONSSTRINGARB)wglGetProcAddress("wglGetExtensionsStringARB"))) - { - // Get extension string - glext = wglGetExtensionsStringARB (hDC); - token = strtok ( (char*)glext.c_str (), " "); - while( token != NULL ) - { - GLExtensions.push_back (token); - token = strtok( NULL, " "); - } - } - - // *** RELEASE OPENGL - - if (hRC) - wglDeleteContext(hRC); - if (hWnd&&hDC) - { - ReleaseDC (hWnd,hDC); - DestroyWindow (hWnd); - } - - // Done - return true; -} - -// *************************************************************************** - -bool GetD3DInformation (NL3D::IDriver *d3dDriver) -{ - IDriver::CAdapter desc; - if (d3dDriver->getAdapter (0xffffffff, desc)) - { - D3DDescription = desc.Description; - D3DDeviceName = desc.DeviceName; - D3DDriver = desc.Driver; - D3DDriverVersion = toString ((uint16)(desc.DriverVersion>>48))+"."+ - toString ((uint16)(desc.DriverVersion>>32))+"."+ - toString ((uint16)(desc.DriverVersion>>16))+"."+ - toString ((uint16)(desc.DriverVersion&0xffff)); - D3DVendor = desc.Vendor; - return true; - } - return false; -} - -// *************************************************************************** - -bool GetVideoMemory () -{ - VideoMemory = 0; - bool ret = false; - - // Initialise Direct Draw - IDirectDraw *dd; - HRESULT result = DirectDrawCreate(NULL, &dd, NULL); - if (result == DD_OK) - { - DDCAPS caps; - memset (&caps, 0, sizeof(DDCAPS)); - caps.dwSize = sizeof(DDCAPS); - dd->GetCaps (&caps, NULL); - VideoMemory = caps.dwVidMemTotal; - ret = true; - dd->Release (); - } - - // Can't get it - return ret; -} - -// *************************************************************************** - -bool GetHardwareSoundBuffer () -{ - bool ret = false; - HardwareSoundBuffer = 0; - - // The DirectSound object -#if (DIRECTSOUND_VERSION >= 0x0800) - LPDIRECTSOUND8 _DirectSound; -#else - LPDIRECTSOUND _DirectSound; -#endif - -#if (DIRECTSOUND_VERSION >= 0x0800) - if (DirectSoundCreate8(NULL, &_DirectSound, NULL) == DS_OK) -#else - if (DirectSoundCreate(NULL, &_DirectSound, NULL) == DS_OK) -#endif - { - DSCAPS caps; - memset (&caps, 0, sizeof (DSCAPS)); - caps.dwSize = sizeof (DSCAPS); - - HRESULT result = _DirectSound->GetCaps (&caps); - if (result == DS_OK) - { - HardwareSoundBuffer = caps.dwFreeHw3DStaticBuffers; - ret = true; - } - _DirectSound->Release (); - } - return ret; -} - -// *************************************************************************** - -bool GetSystemInformation (IDriver *d3dDriver) -{ - bool result = GetGLInformation (); - result |= GetD3DInformation (d3dDriver); - result |= GetVideoMemory (); - result |= GetHardwareSoundBuffer (); - SystemMemory = CSystemInfo::totalPhysicalMemory (); - CPUFrequency = (uint)(CSystemInfo::getProcessorFrequency () / (uint64)1000000); - return result; -} -// *************************************************************************** - -std::vector VideoModes[2]; - -// *************************************************************************** - -void RegisterVideoModes (uint driverId, IDriver *driver) -{ - vector modes; - driver->getModes (modes); - - uint i; - VideoModes[driverId].clear(); - for (i=0; i= 800) && (modes[i].Width >= 600)) - { - // Add this mode - CVideoMode mode; - mode.Width = modes[i].Width; - mode.Height = modes[i].Height; - mode.ColorDepth = modes[i].Depth; - mode.Frequency = modes[i].Frequency; - VideoModes[driverId].push_back (mode); - } - } -} - -// *************************************************************************** -// CDisplayDlg dialog -// *************************************************************************** - -CDisplayDlg::CDisplayDlg(CWnd* pParent /*=NULL*/) - : CBaseDialog(CDisplayDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CDisplayDlg) - DriverChoiceMode = DrvChooseUnknwown; - Windowed = -1; - Width = 0; - Height = 0; - Mode = -1; - PositionX = 0; - PositionY = 0; - //}}AFX_DATA_INIT -} - -// *************************************************************************** - -void CDisplayDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CDisplayDlg) - DDX_Control(pDX, IDC_DISPLAY_FS_TEXT0, TextFS0); - DDX_Control(pDX, IDC_DISPLAY_WND_TEXT0, TextWnd0); - DDX_Control(pDX, IDC_DISPLAY_WND_TEXT1, TextWnd1); - DDX_Control(pDX, IDC_DISPLAY_WND_TEXT2, TextWnd2); - DDX_Control(pDX, IDC_DISPLAY_WND_TEXT3, TextWnd3); - DDX_Control(pDX, IDC_POSITION_Y, PositionYCtrl); - DDX_Control(pDX, IDC_POSITION_X, PositionXCtrl); - DDX_Control(pDX, IDC_HEIGHT, HeightCtrl); - DDX_Control(pDX, IDC_WIDTH, WidthCtrl); - DDX_Control(pDX, IDC_MODE, ModeCtrl); - DDX_Radio(pDX, IDC_DRV3D_AUTO, DriverChoiceMode); - DDX_Radio(pDX, IDC_FULLSCREEN, Windowed); - DDX_Text(pDX, IDC_WIDTH, Width); - DDX_Text(pDX, IDC_HEIGHT, Height); - DDX_CBIndex(pDX, IDC_MODE, Mode); - DDX_Text(pDX, IDC_POSITION_X, PositionX); - DDX_Text(pDX, IDC_POSITION_Y, PositionY); - //}}AFX_DATA_MAP -} - -// *************************************************************************** - -BEGIN_MESSAGE_MAP(CDisplayDlg, CDialog) - //{{AFX_MSG_MAP(CDisplayDlg) - ON_BN_CLICKED(IDC_FULLSCREEN, OnFullscreen) - ON_BN_CLICKED(IDC_WINDOW, OnWindow) - ON_BN_CLICKED(IDC_DIRECT3D, OnDirect3d) - ON_BN_CLICKED(IDC_DRV3D_AUTO, OnDrv3DAuto) - ON_EN_CHANGE(IDC_HEIGHT, OnChangeHeight) - ON_BN_CLICKED(IDC_OPENGL, OnOpengl) - ON_EN_CHANGE(IDC_POSITION_X, OnChangePositionX) - ON_EN_CHANGE(IDC_WIDTH, OnChangeWidth) - ON_EN_CHANGE(IDC_POSITION_Y, OnChangePositionY) - ON_CBN_SELCHANGE(IDC_MODE, OnSelchangeMode) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// *************************************************************************** -// CDisplayDlg message handlers -// *************************************************************************** - -void CDisplayDlg::OnFullscreen() -{ - UpdateData (TRUE); - updateState (); - UpdateData (FALSE); - InvalidateConfig (); -} - -// *************************************************************************** - -void CDisplayDlg::OnWindow() -{ - UpdateData (TRUE); - updateState (); - UpdateData (FALSE); - InvalidateConfig (); -} - -// *************************************************************************** - -void CDisplayDlg::updateState () -{ - ModeCtrl.EnableWindow (Windowed == 0); - TextFS0.EnableWindow (Windowed == 0); - WidthCtrl.EnableWindow (Windowed == 1); - HeightCtrl.EnableWindow (Windowed == 1); - PositionXCtrl.EnableWindow (Windowed == 1); - PositionYCtrl.EnableWindow (Windowed == 1); - TextWnd0.EnableWindow (Windowed == 1); - TextWnd1.EnableWindow (Windowed == 1); - TextWnd2.EnableWindow (Windowed == 1); - TextWnd3.EnableWindow (Windowed == 1); - - // Fill the combobox values - ModeCtrl.ResetContent (); - uint i; - if (DriverChoiceMode != DrvChooseUnknwown) - { - TDriver actualDriver = getActualDriver(); - for (i=0; i +// 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 . + +// *************************************************************************** +// display_dlg.cpp : implementation file +// *************************************************************************** + +#include "stdafx.h" +#include "client_config.h" +#include "display_dlg.h" +#include "cfg_file.h" + +using namespace std; +using namespace NLMISC; +using namespace NL3D; + +// *************************************************************************** + +std::vector GLExtensions; +std::string GLRenderer; +std::string GLVendor; +std::string GLVersion; +std::string D3DDescription; +std::string D3DDeviceName; +std::string D3DDriver; +std::string D3DDriverVersion; +std::string D3DVendor; + +uint VideoMemory; +uint HardwareSoundBuffer; +uint64 SystemMemory; +uint CPUFrequency; + +bool GetGLInformation () +{ + // *** INIT VARIABLES + + GLExtensions.clear (); + GLRenderer = ""; + GLVendor = ""; + GLVersion = ""; + + // *** INIT OPENGL + + // Register a window class + WNDCLASS wc; + memset(&wc,0,sizeof(wc)); + wc.style = CS_HREDRAW | CS_VREDRAW ;//| CS_DBLCLKS; + wc.lpfnWndProc = DefWindowProc; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = GetModuleHandle(NULL); + wc.hIcon = (HICON)NULL; + wc.hCursor = LoadCursor(NULL,IDC_ARROW); + wc.hbrBackground = WHITE_BRUSH; + wc.lpszClassName = "RyzomGetGlInformation"; + wc.lpszMenuName = NULL; + if ( !RegisterClass(&wc) ) + return false; + + // Create a window + ULONG WndFlags = WS_OVERLAPPEDWINDOW+WS_CLIPCHILDREN+WS_CLIPSIBLINGS; + RECT WndRect; + WndRect.left=0; + WndRect.top=0; + WndRect.right=100; + WndRect.bottom=100; + HWND hWnd = CreateWindow ( "RyzomGetGlInformation", + "", + WndFlags, + CW_USEDEFAULT,CW_USEDEFAULT, + WndRect.right,WndRect.bottom, + NULL, + NULL, + GetModuleHandle(NULL), + NULL); + if (!hWnd) + return false; + + HDC hDC = GetDC(hWnd); + + // Remove current gl context + wglMakeCurrent (hDC, NULL); + + // Select pixel format + int depth = GetDeviceCaps (hDC, BITSPIXEL); + PIXELFORMATDESCRIPTOR pfd; + memset(&pfd,0,sizeof(pfd)); + pfd.nSize = sizeof(pfd); + pfd.nVersion = 1; + pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; + pfd.iPixelType = PFD_TYPE_RGBA; + pfd.cColorBits = (char)depth; + if(depth<=16) + pfd.cDepthBits = 16; + else + { + pfd.cDepthBits = 24; + pfd.cAlphaBits = 8; + } + pfd.iLayerType = PFD_MAIN_PLANE; + int pf=ChoosePixelFormat(hDC, &pfd); + if (!pf) + return false; + if ( !SetPixelFormat(hDC, pf, &pfd) ) + return false; + + // Create final context + HGLRC hRC = wglCreateContext (hDC); + wglMakeCurrent(hDC, hRC); + + // *** GET INFORMATION + + GLVendor = (const char *) glGetString (GL_VENDOR); + GLRenderer = (const char *) glGetString (GL_RENDERER); + GLVersion = (const char *) glGetString (GL_VERSION); + + // Get extension string + string glext = (char*)glGetString(GL_EXTENSIONS); + const char *token = strtok ( (char*)glext.c_str (), " "); + while( token != NULL ) + { + GLExtensions.push_back (token); + token = strtok( NULL, " "); + } + + // Get proc adress + typedef const char* (APIENTRY * PFNWGFGETEXTENSIONSSTRINGARB) (HDC); + PFNWGFGETEXTENSIONSSTRINGARB wglGetExtensionsStringARB; + if ((wglGetExtensionsStringARB=(PFNWGFGETEXTENSIONSSTRINGARB)wglGetProcAddress("wglGetExtensionsStringARB"))) + { + // Get extension string + glext = wglGetExtensionsStringARB (hDC); + token = strtok ( (char*)glext.c_str (), " "); + while( token != NULL ) + { + GLExtensions.push_back (token); + token = strtok( NULL, " "); + } + } + + // *** RELEASE OPENGL + + if (hRC) + wglDeleteContext(hRC); + if (hWnd&&hDC) + { + ReleaseDC (hWnd,hDC); + DestroyWindow (hWnd); + } + + // Done + return true; +} + +// *************************************************************************** + +bool GetD3DInformation (NL3D::IDriver *d3dDriver) +{ + IDriver::CAdapter desc; + if (d3dDriver->getAdapter (0xffffffff, desc)) + { + D3DDescription = desc.Description; + D3DDeviceName = desc.DeviceName; + D3DDriver = desc.Driver; + D3DDriverVersion = toString ((uint16)(desc.DriverVersion>>48))+"."+ + toString ((uint16)(desc.DriverVersion>>32))+"."+ + toString ((uint16)(desc.DriverVersion>>16))+"."+ + toString ((uint16)(desc.DriverVersion&0xffff)); + D3DVendor = desc.Vendor; + return true; + } + return false; +} + +// *************************************************************************** + +bool GetVideoMemory () +{ + VideoMemory = 0; + bool ret = false; + + // Initialise Direct Draw + IDirectDraw *dd; + HRESULT result = DirectDrawCreate(NULL, &dd, NULL); + if (result == DD_OK) + { + DDCAPS caps; + memset (&caps, 0, sizeof(DDCAPS)); + caps.dwSize = sizeof(DDCAPS); + dd->GetCaps (&caps, NULL); + VideoMemory = caps.dwVidMemTotal; + ret = true; + dd->Release (); + } + + // Can't get it + return ret; +} + +// *************************************************************************** + +bool GetHardwareSoundBuffer () +{ + bool ret = false; + HardwareSoundBuffer = 0; + + // The DirectSound object +#if (DIRECTSOUND_VERSION >= 0x0800) + LPDIRECTSOUND8 _DirectSound; +#else + LPDIRECTSOUND _DirectSound; +#endif + +#if (DIRECTSOUND_VERSION >= 0x0800) + if (DirectSoundCreate8(NULL, &_DirectSound, NULL) == DS_OK) +#else + if (DirectSoundCreate(NULL, &_DirectSound, NULL) == DS_OK) +#endif + { + DSCAPS caps; + memset (&caps, 0, sizeof (DSCAPS)); + caps.dwSize = sizeof (DSCAPS); + + HRESULT result = _DirectSound->GetCaps (&caps); + if (result == DS_OK) + { + HardwareSoundBuffer = caps.dwFreeHw3DStaticBuffers; + ret = true; + } + _DirectSound->Release (); + } + return ret; +} + +// *************************************************************************** + +bool GetSystemInformation (IDriver *d3dDriver) +{ + bool result = GetGLInformation (); + result |= GetD3DInformation (d3dDriver); + result |= GetVideoMemory (); + result |= GetHardwareSoundBuffer (); + SystemMemory = CSystemInfo::totalPhysicalMemory (); + CPUFrequency = (uint)(CSystemInfo::getProcessorFrequency () / (uint64)1000000); + return result; +} +// *************************************************************************** + +std::vector VideoModes[2]; + +// *************************************************************************** + +void RegisterVideoModes (uint driverId, IDriver *driver) +{ + vector modes; + driver->getModes (modes); + + uint i; + VideoModes[driverId].clear(); + for (i=0; i= 800) && (modes[i].Width >= 600)) + { + // Add this mode + CVideoMode mode; + mode.Width = modes[i].Width; + mode.Height = modes[i].Height; + mode.ColorDepth = modes[i].Depth; + mode.Frequency = modes[i].Frequency; + VideoModes[driverId].push_back (mode); + } + } +} + +// *************************************************************************** +// CDisplayDlg dialog +// *************************************************************************** + +CDisplayDlg::CDisplayDlg(CWnd* pParent /*=NULL*/) + : CBaseDialog(CDisplayDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(CDisplayDlg) + DriverChoiceMode = DrvChooseUnknwown; + Windowed = -1; + Width = 0; + Height = 0; + Mode = -1; + PositionX = 0; + PositionY = 0; + //}}AFX_DATA_INIT +} + +// *************************************************************************** + +void CDisplayDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CDisplayDlg) + DDX_Control(pDX, IDC_DISPLAY_FS_TEXT0, TextFS0); + DDX_Control(pDX, IDC_DISPLAY_WND_TEXT0, TextWnd0); + DDX_Control(pDX, IDC_DISPLAY_WND_TEXT1, TextWnd1); + DDX_Control(pDX, IDC_DISPLAY_WND_TEXT2, TextWnd2); + DDX_Control(pDX, IDC_DISPLAY_WND_TEXT3, TextWnd3); + DDX_Control(pDX, IDC_POSITION_Y, PositionYCtrl); + DDX_Control(pDX, IDC_POSITION_X, PositionXCtrl); + DDX_Control(pDX, IDC_HEIGHT, HeightCtrl); + DDX_Control(pDX, IDC_WIDTH, WidthCtrl); + DDX_Control(pDX, IDC_MODE, ModeCtrl); + DDX_Radio(pDX, IDC_DRV3D_AUTO, DriverChoiceMode); + DDX_Radio(pDX, IDC_FULLSCREEN, Windowed); + DDX_Text(pDX, IDC_WIDTH, Width); + DDX_Text(pDX, IDC_HEIGHT, Height); + DDX_CBIndex(pDX, IDC_MODE, Mode); + DDX_Text(pDX, IDC_POSITION_X, PositionX); + DDX_Text(pDX, IDC_POSITION_Y, PositionY); + //}}AFX_DATA_MAP +} + +// *************************************************************************** + +BEGIN_MESSAGE_MAP(CDisplayDlg, CDialog) + //{{AFX_MSG_MAP(CDisplayDlg) + ON_BN_CLICKED(IDC_FULLSCREEN, OnFullscreen) + ON_BN_CLICKED(IDC_WINDOW, OnWindow) + ON_BN_CLICKED(IDC_DIRECT3D, OnDirect3d) + ON_BN_CLICKED(IDC_DRV3D_AUTO, OnDrv3DAuto) + ON_EN_CHANGE(IDC_HEIGHT, OnChangeHeight) + ON_BN_CLICKED(IDC_OPENGL, OnOpengl) + ON_EN_CHANGE(IDC_POSITION_X, OnChangePositionX) + ON_EN_CHANGE(IDC_WIDTH, OnChangeWidth) + ON_EN_CHANGE(IDC_POSITION_Y, OnChangePositionY) + ON_CBN_SELCHANGE(IDC_MODE, OnSelchangeMode) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +// *************************************************************************** +// CDisplayDlg message handlers +// *************************************************************************** + +void CDisplayDlg::OnFullscreen() +{ + UpdateData (TRUE); + updateState (); + UpdateData (FALSE); + InvalidateConfig (); +} + +// *************************************************************************** + +void CDisplayDlg::OnWindow() +{ + UpdateData (TRUE); + updateState (); + UpdateData (FALSE); + InvalidateConfig (); +} + +// *************************************************************************** + +void CDisplayDlg::updateState () +{ + ModeCtrl.EnableWindow (Windowed == 0); + TextFS0.EnableWindow (Windowed == 0); + WidthCtrl.EnableWindow (Windowed == 1); + HeightCtrl.EnableWindow (Windowed == 1); + PositionXCtrl.EnableWindow (Windowed == 1); + PositionYCtrl.EnableWindow (Windowed == 1); + TextWnd0.EnableWindow (Windowed == 1); + TextWnd1.EnableWindow (Windowed == 1); + TextWnd2.EnableWindow (Windowed == 1); + TextWnd3.EnableWindow (Windowed == 1); + + // Fill the combobox values + ModeCtrl.ResetContent (); + uint i; + if (DriverChoiceMode != DrvChooseUnknwown) + { + TDriver actualDriver = getActualDriver(); + for (i=0; i -// 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 . - -#if !defined(AFX_DISPLAY_DLG_H__1287701D_07D1_48F0_8F13_3FCE937DA3A2__INCLUDED_) -#define AFX_DISPLAY_DLG_H__1287701D_07D1_48F0_8F13_3FCE937DA3A2__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// display_dlg.h : header file -// - -#include "base_dialog.h" -#include "resource.h" - -// *************************************************************************** -// CDisplayDlg dialog -// *************************************************************************** - -class CDisplayDlg : public CBaseDialog -{ -// Construction -public: - CDisplayDlg(CWnd* pParent = NULL); // standard constructor - enum TDriverChoiceMode { DrvChooseAuto = 0, DrvChooseOpenGL, DrvChooseDirect3D, DrvChooseUnknwown = -1 }; - enum TDriver { OpenGL = 0, Direct3D }; -// Dialog Data - //{{AFX_DATA(CDisplayDlg) - enum { IDD = IDD_DISPLAY }; - CStatic TextFS0; - CStatic TextWnd0; - CStatic TextWnd1; - CStatic TextWnd2; - CStatic TextWnd3; - CEdit PositionYCtrl; - CEdit PositionXCtrl; - CEdit HeightCtrl; - CEdit WidthCtrl; - CComboBox ModeCtrl; - int DriverChoiceMode; // one of the TDriverChoiceMode values - int Windowed; - UINT Width; - UINT Height; - int Mode; - int PositionX; - int PositionY; - //}}AFX_DATA - - // Update data - void updateState (); - - /** Get the selected driver (if Driver is in mode Auto, choose the best driver depending on the hardware) - * \return 0 for D3D & 1 for OpenGL - */ - TDriver getActualDriver() const; - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CDisplayDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CDisplayDlg) - afx_msg void OnFullscreen(); - afx_msg void OnWindow(); - virtual BOOL OnInitDialog(); - afx_msg void OnDirect3d(); - afx_msg void OnDrv3DAuto(); - afx_msg void OnChangeHeight(); - afx_msg void OnOpengl(); - afx_msg void OnChangePositionX(); - afx_msg void OnChangeWidth(); - afx_msg void OnChangePositionY(); - afx_msg void OnColorDepth32(); - afx_msg void OnSelchangeMode(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -// *************************************************************************** - -class CVideoMode -{ -public: - uint Width; - uint Height; - uint ColorDepth; // 32 only - uint Frequency; - - // Operator - bool operator== (const CVideoMode &other) const - { - return (Width == other.Width) && (Height == other.Height) && (ColorDepth == other.ColorDepth) && (Frequency == other.Frequency); - } - bool operator< (const CVideoMode &other) const - { - if (Width < other.Width) return true; - else if (Width > other.Width) return false; - else if (Height < other.Height) return true; - else if (Height > other.Height) return false; - else if (ColorDepth < other.ColorDepth) return true; - else if (ColorDepth > other.ColorDepth) return false; - else if (Frequency < other.Frequency) return true; - else return false; - } -}; - -// *************************************************************************** - -enum -{ - ModeOpenGL = 0, - ModeDirectX -}; - -// *************************************************************************** - -extern std::vector VideoModes[2]; -extern std::vector GLExtensions; -extern std::string GLRenderer; -extern std::string GLVendor; -extern std::string GLVersion; -extern std::string D3DDescription; -extern std::string D3DDeviceName; -extern std::string D3DDriver; -extern std::string D3DDriverVersion; -extern std::string D3DVendor; -extern uint VideoMemory; -extern uint HardwareSoundBuffer; -extern uint64 SystemMemory; -extern uint CPUFrequency; - -// *************************************************************************** - -// Register video modes -void RegisterVideoModes (uint mode, NL3D::IDriver *driver); - -// Get opengl information -bool GetSystemInformation (NL3D::IDriver *d3dDriver); - -// *************************************************************************** - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_DISPLAY_DLG_H__1287701D_07D1_48F0_8F13_3FCE937DA3A2__INCLUDED_) - - +// 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 . + +#if !defined(AFX_DISPLAY_DLG_H__1287701D_07D1_48F0_8F13_3FCE937DA3A2__INCLUDED_) +#define AFX_DISPLAY_DLG_H__1287701D_07D1_48F0_8F13_3FCE937DA3A2__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// display_dlg.h : header file +// + +#include "base_dialog.h" +#include "resource.h" + +// *************************************************************************** +// CDisplayDlg dialog +// *************************************************************************** + +class CDisplayDlg : public CBaseDialog +{ +// Construction +public: + CDisplayDlg(CWnd* pParent = NULL); // standard constructor + enum TDriverChoiceMode { DrvChooseAuto = 0, DrvChooseOpenGL, DrvChooseDirect3D, DrvChooseUnknwown = -1 }; + enum TDriver { OpenGL = 0, Direct3D }; +// Dialog Data + //{{AFX_DATA(CDisplayDlg) + enum { IDD = IDD_DISPLAY }; + CStatic TextFS0; + CStatic TextWnd0; + CStatic TextWnd1; + CStatic TextWnd2; + CStatic TextWnd3; + CEdit PositionYCtrl; + CEdit PositionXCtrl; + CEdit HeightCtrl; + CEdit WidthCtrl; + CComboBox ModeCtrl; + int DriverChoiceMode; // one of the TDriverChoiceMode values + int Windowed; + UINT Width; + UINT Height; + int Mode; + int PositionX; + int PositionY; + //}}AFX_DATA + + // Update data + void updateState (); + + /** Get the selected driver (if Driver is in mode Auto, choose the best driver depending on the hardware) + * \return 0 for D3D & 1 for OpenGL + */ + TDriver getActualDriver() const; + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CDisplayDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CDisplayDlg) + afx_msg void OnFullscreen(); + afx_msg void OnWindow(); + virtual BOOL OnInitDialog(); + afx_msg void OnDirect3d(); + afx_msg void OnDrv3DAuto(); + afx_msg void OnChangeHeight(); + afx_msg void OnOpengl(); + afx_msg void OnChangePositionX(); + afx_msg void OnChangeWidth(); + afx_msg void OnChangePositionY(); + afx_msg void OnColorDepth32(); + afx_msg void OnSelchangeMode(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +// *************************************************************************** + +class CVideoMode +{ +public: + uint Width; + uint Height; + uint ColorDepth; // 32 only + uint Frequency; + + // Operator + bool operator== (const CVideoMode &other) const + { + return (Width == other.Width) && (Height == other.Height) && (ColorDepth == other.ColorDepth) && (Frequency == other.Frequency); + } + bool operator< (const CVideoMode &other) const + { + if (Width < other.Width) return true; + else if (Width > other.Width) return false; + else if (Height < other.Height) return true; + else if (Height > other.Height) return false; + else if (ColorDepth < other.ColorDepth) return true; + else if (ColorDepth > other.ColorDepth) return false; + else if (Frequency < other.Frequency) return true; + else return false; + } +}; + +// *************************************************************************** + +enum +{ + ModeOpenGL = 0, + ModeDirectX +}; + +// *************************************************************************** + +extern std::vector VideoModes[2]; +extern std::vector GLExtensions; +extern std::string GLRenderer; +extern std::string GLVendor; +extern std::string GLVersion; +extern std::string D3DDescription; +extern std::string D3DDeviceName; +extern std::string D3DDriver; +extern std::string D3DDriverVersion; +extern std::string D3DVendor; +extern uint VideoMemory; +extern uint HardwareSoundBuffer; +extern uint64 SystemMemory; +extern uint CPUFrequency; + +// *************************************************************************** + +// Register video modes +void RegisterVideoModes (uint mode, NL3D::IDriver *driver); + +// Get opengl information +bool GetSystemInformation (NL3D::IDriver *d3dDriver); + +// *************************************************************************** + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_DISPLAY_DLG_H__1287701D_07D1_48F0_8F13_3FCE937DA3A2__INCLUDED_) + + diff --git a/code/ryzom/tools/client/client_config/display_information_d3d_dlg.cpp b/code/ryzom/tools/client/client_config/display_information_d3d_dlg.cpp index 77dc9a13b..acbbff87e 100644 --- a/code/ryzom/tools/client/client_config/display_information_d3d_dlg.cpp +++ b/code/ryzom/tools/client/client_config/display_information_d3d_dlg.cpp @@ -1,73 +1,73 @@ -// 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 . - -// display_information_d3d_dlg.cpp : implementation file -// - -#include "stdafx.h" -#include "client_config.h" -#include "display_information_d3d_dlg.h" -#include "display_dlg.h" - -// *************************************************************************** -// CDisplayInformationD3DDlg dialog -// *************************************************************************** - -CDisplayInformationD3DDlg::CDisplayInformationD3DDlg(CWnd* pParent /*=NULL*/) - : CBaseDialog(CDisplayInformationD3DDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CDisplayInformationD3DDlg) - //}}AFX_DATA_INIT -} - -// *************************************************************************** - -void CDisplayInformationD3DDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CDisplayInformationD3DDlg) - DDX_Control(pDX, IDC_D3D_DRIVER_VERSION, DriverVersion); - DDX_Control(pDX, IDC_D3D_DRIVER, Driver); - DDX_Control(pDX, IDC_D3D_DESCRIPTION, Description); - //}}AFX_DATA_MAP -} - -// *************************************************************************** - -BEGIN_MESSAGE_MAP(CDisplayInformationD3DDlg, CDialog) - //{{AFX_MSG_MAP(CDisplayInformationD3DDlg) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// *************************************************************************** -// CDisplayInformationD3DDlg message handlers -// *************************************************************************** - -BOOL CDisplayInformationD3DDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - Description.SetWindowText (D3DDescription.c_str ()); - Driver.SetWindowText (D3DDriver.c_str ()); - DriverVersion.SetWindowText (D3DDriverVersion.c_str ()); - - UpdateData (TRUE); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -// *************************************************************************** +// 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 . + +// display_information_d3d_dlg.cpp : implementation file +// + +#include "stdafx.h" +#include "client_config.h" +#include "display_information_d3d_dlg.h" +#include "display_dlg.h" + +// *************************************************************************** +// CDisplayInformationD3DDlg dialog +// *************************************************************************** + +CDisplayInformationD3DDlg::CDisplayInformationD3DDlg(CWnd* pParent /*=NULL*/) + : CBaseDialog(CDisplayInformationD3DDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(CDisplayInformationD3DDlg) + //}}AFX_DATA_INIT +} + +// *************************************************************************** + +void CDisplayInformationD3DDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CDisplayInformationD3DDlg) + DDX_Control(pDX, IDC_D3D_DRIVER_VERSION, DriverVersion); + DDX_Control(pDX, IDC_D3D_DRIVER, Driver); + DDX_Control(pDX, IDC_D3D_DESCRIPTION, Description); + //}}AFX_DATA_MAP +} + +// *************************************************************************** + +BEGIN_MESSAGE_MAP(CDisplayInformationD3DDlg, CDialog) + //{{AFX_MSG_MAP(CDisplayInformationD3DDlg) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +// *************************************************************************** +// CDisplayInformationD3DDlg message handlers +// *************************************************************************** + +BOOL CDisplayInformationD3DDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + Description.SetWindowText (D3DDescription.c_str ()); + Driver.SetWindowText (D3DDriver.c_str ()); + DriverVersion.SetWindowText (D3DDriverVersion.c_str ()); + + UpdateData (TRUE); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +// *************************************************************************** diff --git a/code/ryzom/tools/client/client_config/display_information_d3d_dlg.h b/code/ryzom/tools/client/client_config/display_information_d3d_dlg.h index e24ae8dfc..63ccf0eba 100644 --- a/code/ryzom/tools/client/client_config/display_information_d3d_dlg.h +++ b/code/ryzom/tools/client/client_config/display_information_d3d_dlg.h @@ -1,66 +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 . - -#if !defined(AFX_DISPLAY_INFORMATION_D3D_DLG_H__90FE554C_8224_4A68_94CE_65D71FED52F8__INCLUDED_) -#define AFX_DISPLAY_INFORMATION_D3D_DLG_H__90FE554C_8224_4A68_94CE_65D71FED52F8__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// display_information_d3d_dlg.h : header file -// - -#include "base_dialog.h" - -///////////////////////////////////////////////////////////////////////////// -// CDisplayInformationD3DDlg dialog - -class CDisplayInformationD3DDlg : public CBaseDialog -{ -// Construction -public: - CDisplayInformationD3DDlg(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CDisplayInformationD3DDlg) - enum { IDD = IDD_DISPLAY_D3D }; - CStatic DriverVersion; - CStatic Driver; - CStatic Description; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CDisplayInformationD3DDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CDisplayInformationD3DDlg) - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_DISPLAY_INFORMATION_D3D_DLG_H__90FE554C_8224_4A68_94CE_65D71FED52F8__INCLUDED_) +// 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 . + +#if !defined(AFX_DISPLAY_INFORMATION_D3D_DLG_H__90FE554C_8224_4A68_94CE_65D71FED52F8__INCLUDED_) +#define AFX_DISPLAY_INFORMATION_D3D_DLG_H__90FE554C_8224_4A68_94CE_65D71FED52F8__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// display_information_d3d_dlg.h : header file +// + +#include "base_dialog.h" + +///////////////////////////////////////////////////////////////////////////// +// CDisplayInformationD3DDlg dialog + +class CDisplayInformationD3DDlg : public CBaseDialog +{ +// Construction +public: + CDisplayInformationD3DDlg(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CDisplayInformationD3DDlg) + enum { IDD = IDD_DISPLAY_D3D }; + CStatic DriverVersion; + CStatic Driver; + CStatic Description; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CDisplayInformationD3DDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CDisplayInformationD3DDlg) + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_DISPLAY_INFORMATION_D3D_DLG_H__90FE554C_8224_4A68_94CE_65D71FED52F8__INCLUDED_) diff --git a/code/ryzom/tools/client/client_config/display_information_gl_dlg.cpp b/code/ryzom/tools/client/client_config/display_information_gl_dlg.cpp index 7a696760d..e21712861 100644 --- a/code/ryzom/tools/client/client_config/display_information_gl_dlg.cpp +++ b/code/ryzom/tools/client/client_config/display_information_gl_dlg.cpp @@ -1,77 +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 . - -// display_information_gl_dlg.cpp : implementation file -// - -#include "stdafx.h" -#include "client_config.h" -#include "display_information_gl_dlg.h" -#include "display_dlg.h" - -// *************************************************************************** -// CDisplayInformationGlDlg dialog -// *************************************************************************** - -CDisplayInformationGlDlg::CDisplayInformationGlDlg(CWnd* pParent /*=NULL*/) - : CBaseDialog(CDisplayInformationGlDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CDisplayInformationGlDlg) - //}}AFX_DATA_INIT -} - -// *************************************************************************** - -void CDisplayInformationGlDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CDisplayInformationGlDlg) - DDX_Control(pDX, IDC_GL_VERSION, VersionCtrl); - DDX_Control(pDX, IDC_GL_VENDOR, VendorCtrl); - DDX_Control(pDX, IDC_GL_RENDERER, RendererCtrl); - DDX_Control(pDX, IDC_EXTENSION, Extensions); - //}}AFX_DATA_MAP -} - -// *************************************************************************** - -BEGIN_MESSAGE_MAP(CDisplayInformationGlDlg, CDialog) - //{{AFX_MSG_MAP(CDisplayInformationGlDlg) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// *************************************************************************** -// CDisplayInformationGlDlg message handlers -// *************************************************************************** - -BOOL CDisplayInformationGlDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - RendererCtrl.SetWindowText (GLRenderer.c_str ()); - VendorCtrl.SetWindowText (GLVendor.c_str ()); - VersionCtrl.SetWindowText (GLVersion.c_str ()); - uint i; - for (i=0; i +// 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 . + +// display_information_gl_dlg.cpp : implementation file +// + +#include "stdafx.h" +#include "client_config.h" +#include "display_information_gl_dlg.h" +#include "display_dlg.h" + +// *************************************************************************** +// CDisplayInformationGlDlg dialog +// *************************************************************************** + +CDisplayInformationGlDlg::CDisplayInformationGlDlg(CWnd* pParent /*=NULL*/) + : CBaseDialog(CDisplayInformationGlDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(CDisplayInformationGlDlg) + //}}AFX_DATA_INIT +} + +// *************************************************************************** + +void CDisplayInformationGlDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CDisplayInformationGlDlg) + DDX_Control(pDX, IDC_GL_VERSION, VersionCtrl); + DDX_Control(pDX, IDC_GL_VENDOR, VendorCtrl); + DDX_Control(pDX, IDC_GL_RENDERER, RendererCtrl); + DDX_Control(pDX, IDC_EXTENSION, Extensions); + //}}AFX_DATA_MAP +} + +// *************************************************************************** + +BEGIN_MESSAGE_MAP(CDisplayInformationGlDlg, CDialog) + //{{AFX_MSG_MAP(CDisplayInformationGlDlg) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +// *************************************************************************** +// CDisplayInformationGlDlg message handlers +// *************************************************************************** + +BOOL CDisplayInformationGlDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + RendererCtrl.SetWindowText (GLRenderer.c_str ()); + VendorCtrl.SetWindowText (GLVendor.c_str ()); + VersionCtrl.SetWindowText (GLVersion.c_str ()); + uint i; + for (i=0; i -// 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 . - -#if !defined(AFX_DISPLAY_INFORMATION_GL_DLG_H__296CBB2A_5856_4C1D_94AD_8509265543E2__INCLUDED_) -#define AFX_DISPLAY_INFORMATION_GL_DLG_H__296CBB2A_5856_4C1D_94AD_8509265543E2__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// display_information_gl_dlg.h : header file -// -#include "base_dialog.h" - -// *************************************************************************** -// CDisplayInformationGlDlg dialog -// *************************************************************************** - -class CDisplayInformationGlDlg : public CBaseDialog -{ -// Construction -public: - CDisplayInformationGlDlg(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CDisplayInformationGlDlg) - enum { IDD = IDD_DISPLAY_INFO }; - CStatic VersionCtrl; - CStatic VendorCtrl; - CStatic RendererCtrl; - CListBox Extensions; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CDisplayInformationGlDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CDisplayInformationGlDlg) - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_DISPLAY_INFORMATION_GL_DLG_H__296CBB2A_5856_4C1D_94AD_8509265543E2__INCLUDED_) +// 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 . + +#if !defined(AFX_DISPLAY_INFORMATION_GL_DLG_H__296CBB2A_5856_4C1D_94AD_8509265543E2__INCLUDED_) +#define AFX_DISPLAY_INFORMATION_GL_DLG_H__296CBB2A_5856_4C1D_94AD_8509265543E2__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// display_information_gl_dlg.h : header file +// +#include "base_dialog.h" + +// *************************************************************************** +// CDisplayInformationGlDlg dialog +// *************************************************************************** + +class CDisplayInformationGlDlg : public CBaseDialog +{ +// Construction +public: + CDisplayInformationGlDlg(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CDisplayInformationGlDlg) + enum { IDD = IDD_DISPLAY_INFO }; + CStatic VersionCtrl; + CStatic VendorCtrl; + CStatic RendererCtrl; + CListBox Extensions; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CDisplayInformationGlDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CDisplayInformationGlDlg) + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_DISPLAY_INFORMATION_GL_DLG_H__296CBB2A_5856_4C1D_94AD_8509265543E2__INCLUDED_) diff --git a/code/ryzom/tools/client/client_config/general_dlg.cpp b/code/ryzom/tools/client/client_config/general_dlg.cpp index a27093c68..6043bd3e1 100644 --- a/code/ryzom/tools/client/client_config/general_dlg.cpp +++ b/code/ryzom/tools/client/client_config/general_dlg.cpp @@ -1,111 +1,111 @@ -// 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 . - -// general_dlg.cpp : implementation file -// - -#include "stdafx.h" -#include "client_config.h" -#include "general_dlg.h" -#include "cfg_file.h" -#include "client_configdlg.h" - -// *************************************************************************** -// CGeneralDlg dialog -// *************************************************************************** - -CGeneralDlg::CGeneralDlg(CWnd* pParent /*=NULL*/) - : CBaseDialog(CGeneralDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CGeneralDlg) - Sleep = FALSE; - SaveConfig = FALSE; - Language = -1; - //}}AFX_DATA_INIT -} - -// *************************************************************************** - -void CGeneralDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CGeneralDlg) - DDX_Check(pDX, IDC_SLEEP, Sleep); - DDX_Check(pDX, IDC_SAVE_CONFIG, SaveConfig); - DDX_CBIndex(pDX, IDC_LANGUAGE, Language); - //}}AFX_DATA_MAP -} - -// *************************************************************************** - -BEGIN_MESSAGE_MAP(CGeneralDlg, CDialog) - //{{AFX_MSG_MAP(CGeneralDlg) - ON_BN_CLICKED(IDC_SLEEP, OnSleep) - ON_BN_CLICKED(IDC_SAVE_CONFIG, OnSaveConfig) - ON_CBN_SELENDOK(IDC_LANGUAGE, OnSelendokLanguage) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// *************************************************************************** -// CGeneralDlg message handlers -// *************************************************************************** - -void CGeneralDlg::OnSleep() -{ - UpdateData (TRUE); - updateState (); - UpdateData (FALSE); - InvalidateConfig (); -} - -// *************************************************************************** - -void CGeneralDlg::updateState () -{ -} - -// *************************************************************************** - -void CGeneralDlg::OnSaveConfig() -{ - InvalidateConfig (); -} - -// *************************************************************************** - -BOOL CGeneralDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - updateState (); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -// *************************************************************************** - -void CGeneralDlg::OnSelendokLanguage() -{ - InvalidateConfig (); - - // Localize the windows - CClient_configDlg *dlg = (CClient_configDlg*)theApp.m_pMainWnd; - dlg->UpdateData (TRUE); - dlg->changeLanguage (::GetIntForceLanguage()?"en" : (dlg->GeneralDlg.Language==2)?"de":(dlg->GeneralDlg.Language==1)?"fr":"en"); -} - -// *************************************************************************** +// 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 . + +// general_dlg.cpp : implementation file +// + +#include "stdafx.h" +#include "client_config.h" +#include "general_dlg.h" +#include "cfg_file.h" +#include "client_configdlg.h" + +// *************************************************************************** +// CGeneralDlg dialog +// *************************************************************************** + +CGeneralDlg::CGeneralDlg(CWnd* pParent /*=NULL*/) + : CBaseDialog(CGeneralDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(CGeneralDlg) + Sleep = FALSE; + SaveConfig = FALSE; + Language = -1; + //}}AFX_DATA_INIT +} + +// *************************************************************************** + +void CGeneralDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CGeneralDlg) + DDX_Check(pDX, IDC_SLEEP, Sleep); + DDX_Check(pDX, IDC_SAVE_CONFIG, SaveConfig); + DDX_CBIndex(pDX, IDC_LANGUAGE, Language); + //}}AFX_DATA_MAP +} + +// *************************************************************************** + +BEGIN_MESSAGE_MAP(CGeneralDlg, CDialog) + //{{AFX_MSG_MAP(CGeneralDlg) + ON_BN_CLICKED(IDC_SLEEP, OnSleep) + ON_BN_CLICKED(IDC_SAVE_CONFIG, OnSaveConfig) + ON_CBN_SELENDOK(IDC_LANGUAGE, OnSelendokLanguage) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +// *************************************************************************** +// CGeneralDlg message handlers +// *************************************************************************** + +void CGeneralDlg::OnSleep() +{ + UpdateData (TRUE); + updateState (); + UpdateData (FALSE); + InvalidateConfig (); +} + +// *************************************************************************** + +void CGeneralDlg::updateState () +{ +} + +// *************************************************************************** + +void CGeneralDlg::OnSaveConfig() +{ + InvalidateConfig (); +} + +// *************************************************************************** + +BOOL CGeneralDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + updateState (); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +// *************************************************************************** + +void CGeneralDlg::OnSelendokLanguage() +{ + InvalidateConfig (); + + // Localize the windows + CClient_configDlg *dlg = (CClient_configDlg*)theApp.m_pMainWnd; + dlg->UpdateData (TRUE); + dlg->changeLanguage (::GetIntForceLanguage()?"en" : (dlg->GeneralDlg.Language==2)?"de":(dlg->GeneralDlg.Language==1)?"fr":"en"); +} + +// *************************************************************************** diff --git a/code/ryzom/tools/client/client_config/general_dlg.h b/code/ryzom/tools/client/client_config/general_dlg.h index fe2f50ebc..22da2ca40 100644 --- a/code/ryzom/tools/client/client_config/general_dlg.h +++ b/code/ryzom/tools/client/client_config/general_dlg.h @@ -1,72 +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 . - -#if !defined(AFX_GENERAL_DLG_H__E680149A_E05A_4599_853E_43BFAE338273__INCLUDED_) -#define AFX_GENERAL_DLG_H__E680149A_E05A_4599_853E_43BFAE338273__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// general_dlg.h : header file -// - -#include "base_dialog.h" - -///////////////////////////////////////////////////////////////////////////// -// CGeneralDlg dialog - -class CGeneralDlg : public CBaseDialog -{ -// Construction -public: - CGeneralDlg(CWnd* pParent = NULL); // standard constructor - - // Update data - void updateState (); - -// Dialog Data - //{{AFX_DATA(CGeneralDlg) - enum { IDD = IDD_GENERAL }; - BOOL Sleep; - BOOL SaveConfig; - int Language; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CGeneralDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CGeneralDlg) - afx_msg void OnSleep(); - afx_msg void OnSaveConfig(); - virtual BOOL OnInitDialog(); - afx_msg void OnSelendokLanguage(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_GENERAL_DLG_H__E680149A_E05A_4599_853E_43BFAE338273__INCLUDED_) +// 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 . + +#if !defined(AFX_GENERAL_DLG_H__E680149A_E05A_4599_853E_43BFAE338273__INCLUDED_) +#define AFX_GENERAL_DLG_H__E680149A_E05A_4599_853E_43BFAE338273__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// general_dlg.h : header file +// + +#include "base_dialog.h" + +///////////////////////////////////////////////////////////////////////////// +// CGeneralDlg dialog + +class CGeneralDlg : public CBaseDialog +{ +// Construction +public: + CGeneralDlg(CWnd* pParent = NULL); // standard constructor + + // Update data + void updateState (); + +// Dialog Data + //{{AFX_DATA(CGeneralDlg) + enum { IDD = IDD_GENERAL }; + BOOL Sleep; + BOOL SaveConfig; + int Language; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CGeneralDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CGeneralDlg) + afx_msg void OnSleep(); + afx_msg void OnSaveConfig(); + virtual BOOL OnInitDialog(); + afx_msg void OnSelendokLanguage(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_GENERAL_DLG_H__E680149A_E05A_4599_853E_43BFAE338273__INCLUDED_) diff --git a/code/ryzom/tools/client/client_config/preset_dlg.cpp b/code/ryzom/tools/client/client_config/preset_dlg.cpp index 3e069ae8d..528420a67 100644 --- a/code/ryzom/tools/client/client_config/preset_dlg.cpp +++ b/code/ryzom/tools/client/client_config/preset_dlg.cpp @@ -1,174 +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 . - -// preset_dlg.cpp : implementation file -// - -todo hulud remove - -#include "stdafx.h" -#include "client_config.h" -#include "preset_dlg.h" -#include "database.h" -#include "display_dlg.h" -#include "cfg_file.h" - -#undef max - -using namespace NLMISC; - -///////////////////////////////////////////////////////////////////////////// -// CPresetDlg dialog - - -CPresetDlg::CPresetDlg(CWnd* pParent /*=NULL*/) - : CDialog(CPresetDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CPresetDlg) - CPUFrequency = _T(""); - SystemMemory = _T(""); - VideoCard = -1; - VideoMemory = _T(""); - HardwareSoundBuffer = _T(""); - //}}AFX_DATA_INIT -} - - -void CPresetDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CPresetDlg) - DDX_Control(pDX, IDOK, OkCtrl); - DDX_Control(pDX, IDCANCEL, CancelCtrl); - DDX_Control(pDX, IDC_VIDEO_CARD, VideoCardCtrl); - DDX_Text(pDX, IDC_CPU_FREQUENCY, CPUFrequency); - DDX_Text(pDX, IDC_SYSTEM_MEMORY, SystemMemory); - DDX_CBIndex(pDX, IDC_VIDEO_CARD, VideoCard); - DDX_Text(pDX, IDC_VIDEO_MEMORY, VideoMemory); - DDX_Text(pDX, IDC_HARDWARE_SOUND_BUFFER, HardwareSoundBuffer); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CPresetDlg, CDialog) - //{{AFX_MSG_MAP(CPresetDlg) - ON_BN_CLICKED(IDC_RESET, OnReset) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CPresetDlg message handlers - -void CPresetDlg::OnReset() -{ - // TODO: Add your control notification handler code here - -} - -BOOL CPresetDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - // Set the video card list - uint i; - for (i=0; iType) - { - var->setAsInt (::HardwareSoundBuffer); - MergeConfigFile (ConfigFilePreset[SoundBuffer]); - } - - CDialog::OnOK(); - } -} - -void CPresetDlg::OnCancel() -{ - CDialog::OnCancel(); -} +// 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 . + +// preset_dlg.cpp : implementation file +// + +todo hulud remove + +#include "stdafx.h" +#include "client_config.h" +#include "preset_dlg.h" +#include "database.h" +#include "display_dlg.h" +#include "cfg_file.h" + +#undef max + +using namespace NLMISC; + +///////////////////////////////////////////////////////////////////////////// +// CPresetDlg dialog + + +CPresetDlg::CPresetDlg(CWnd* pParent /*=NULL*/) + : CDialog(CPresetDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(CPresetDlg) + CPUFrequency = _T(""); + SystemMemory = _T(""); + VideoCard = -1; + VideoMemory = _T(""); + HardwareSoundBuffer = _T(""); + //}}AFX_DATA_INIT +} + + +void CPresetDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CPresetDlg) + DDX_Control(pDX, IDOK, OkCtrl); + DDX_Control(pDX, IDCANCEL, CancelCtrl); + DDX_Control(pDX, IDC_VIDEO_CARD, VideoCardCtrl); + DDX_Text(pDX, IDC_CPU_FREQUENCY, CPUFrequency); + DDX_Text(pDX, IDC_SYSTEM_MEMORY, SystemMemory); + DDX_CBIndex(pDX, IDC_VIDEO_CARD, VideoCard); + DDX_Text(pDX, IDC_VIDEO_MEMORY, VideoMemory); + DDX_Text(pDX, IDC_HARDWARE_SOUND_BUFFER, HardwareSoundBuffer); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CPresetDlg, CDialog) + //{{AFX_MSG_MAP(CPresetDlg) + ON_BN_CLICKED(IDC_RESET, OnReset) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CPresetDlg message handlers + +void CPresetDlg::OnReset() +{ + // TODO: Add your control notification handler code here + +} + +BOOL CPresetDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // Set the video card list + uint i; + for (i=0; iType) + { + var->setAsInt (::HardwareSoundBuffer); + MergeConfigFile (ConfigFilePreset[SoundBuffer]); + } + + CDialog::OnOK(); + } +} + +void CPresetDlg::OnCancel() +{ + CDialog::OnCancel(); +} diff --git a/code/ryzom/tools/client/client_config/preset_dlg.h b/code/ryzom/tools/client/client_config/preset_dlg.h index 9db9c6dbe..0e53cb922 100644 --- a/code/ryzom/tools/client/client_config/preset_dlg.h +++ b/code/ryzom/tools/client/client_config/preset_dlg.h @@ -1,76 +1,76 @@ -// 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 . - -#if !defined(AFX_PRESET_DLG_H__E8E0170F_3445_4F38_9F73_EE1685B89CAC__INCLUDED_) -#define AFX_PRESET_DLG_H__E8E0170F_3445_4F38_9F73_EE1685B89CAC__INCLUDED_ - -todo hulud remove - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// preset_dlg.h : header file -// - -#include "base_dialog.h" - -///////////////////////////////////////////////////////////////////////////// -// CPresetDlg dialog - -class CPresetDlg : public CDialog -{ -// Construction -public: - CPresetDlg(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CPresetDlg) - enum { IDD = IDD_PRESET }; - CButton OkCtrl; - CButton CancelCtrl; - CComboBox VideoCardCtrl; - CString CPUFrequency; - CString SystemMemory; - int VideoCard; - CString VideoMemory; - CString HardwareSoundBuffer; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CPresetDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CPresetDlg) - afx_msg void OnReset(); - virtual BOOL OnInitDialog(); - virtual void OnOK(); - virtual void OnCancel(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_PRESET_DLG_H__E8E0170F_3445_4F38_9F73_EE1685B89CAC__INCLUDED_) +// 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 . + +#if !defined(AFX_PRESET_DLG_H__E8E0170F_3445_4F38_9F73_EE1685B89CAC__INCLUDED_) +#define AFX_PRESET_DLG_H__E8E0170F_3445_4F38_9F73_EE1685B89CAC__INCLUDED_ + +todo hulud remove + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// preset_dlg.h : header file +// + +#include "base_dialog.h" + +///////////////////////////////////////////////////////////////////////////// +// CPresetDlg dialog + +class CPresetDlg : public CDialog +{ +// Construction +public: + CPresetDlg(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CPresetDlg) + enum { IDD = IDD_PRESET }; + CButton OkCtrl; + CButton CancelCtrl; + CComboBox VideoCardCtrl; + CString CPUFrequency; + CString SystemMemory; + int VideoCard; + CString VideoMemory; + CString HardwareSoundBuffer; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CPresetDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CPresetDlg) + afx_msg void OnReset(); + virtual BOOL OnInitDialog(); + virtual void OnOK(); + virtual void OnCancel(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_PRESET_DLG_H__E8E0170F_3445_4F38_9F73_EE1685B89CAC__INCLUDED_) diff --git a/code/ryzom/tools/client/client_config/resource.h b/code/ryzom/tools/client/client_config/resource.h index c234c6144..5e23b5a4d 100644 --- a/code/ryzom/tools/client/client_config/resource.h +++ b/code/ryzom/tools/client/client_config/resource.h @@ -1,188 +1,188 @@ -// 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 . - -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by client_config.rc -// -#define IDCANCEL2 4 -#define ID_APPLY 4 -#define ID_DEFAULT 5 -#define ID_LAUNCH 6 -#define IDM_ABOUTBOX 0x0010 -#define IDD_ABOUTBOX 100 -#define IDS_ABOUTBOX 101 -#define IDD_CLIENT_CONFIG_DIALOG 102 -#define IDS_GENERAL 102 -#define IDD_LAYOUT 103 -#define IDS_DISPLAY 103 -#define IDS_DETAILS 104 -#define IDS_DISPLAY_DETAILS 104 -#define IDS_ADVANCED 105 -#define IDS_DISPLAY_ADVANCED 105 -#define IDS_SOUND 106 -#define IDS_NETWORK 107 -#define IDS_PATCHES 108 -#define IDS_DRIVER 109 -#define IDS_WELCOME 110 -#define IDS_TITLE 111 -#define IDS_BITS 112 -#define IDS_HZ 113 -#define IDS_PRESET 114 -#define IDS_Q_QUIT_WITHOUT_SAVING 115 -#define IDS_UNKNOWN 116 -#define IDD_SLASH_SCREEN 116 -#define IDS_DISPLAY_OPENGL_INFO 117 -#define IDS_MO 118 -#define IDS_MHZ 119 -#define IDS_UNKOWN_VIDEO_CARD 120 -#define IDS_GENERIC_NO_TNL 121 -#define IDS_GENERIC_TNL 122 -#define IDS_GEFORCE 123 -#define IDS_GEFORCE2 124 -#define IDS_GEFORCE3 125 -#define IDS_GEFORCE4TI 126 -#define IDS_GEFORCE4MX 127 -#define IDR_MAINFRAME 128 -#define IDS_RADEON_SDR 128 -#define IDB_LEFT_0 129 -#define IDS_RADEON_DDR 129 -#define IDS_RADEON_7200 130 -#define IDS_RADEON_7500 131 -#define IDB_TOP_RIGHT 132 -#define IDS_RADEON_8500 132 -#define IDB_DISPLAY 133 -#define IDS_RADEON_9000 133 -#define IDB_CARD 134 -#define IDS_RADEON_9500 134 -#define IDB_DISPLAY_CONFIG 135 -#define IDB_DISPLAY_ADVANCED 135 -#define IDS_RADEON_9700 135 -#define IDB_DISPLAY_PROPERTIES 136 -#define IDB_DISPLAY_DETAILS 136 -#define IDS_CHOOSE_A_CARD 136 -#define IDB_GENERAL 137 -#define IDS_POOR 137 -#define IDB_NETWORK 138 -#define IDS_MEDIUM 138 -#define IDB_SOUND 139 -#define IDS_NORMAL 139 -#define IDB_UPDATE 140 -#define IDS_SUPER 140 -#define IDS_GEFORCEFX 141 -#define IDB_WELCOME 142 -#define IDS_BUFFERS 142 -#define IDD_GENERAL 143 -#define IDS_TEXTURE_LOW 143 -#define IDD_DISPLAY 144 -#define IDS_TEXTURE_NORMAL 144 -#define IDD_SOUND 145 -#define IDS_TEXTURE_HIGH 145 -#define IDD_DISPLAY_DETAILS 146 -#define IDS_TRACKS 146 -#define IDD_DISPLAY_ADVANCED 147 -#define IDD_DISPLAY_INFO 148 -#define IDD_PRESET 149 -#define IDD_DISPLAY_D3D 150 -#define IDS_DISPLAY_D3D_INFO 151 -#define IDS_Q_RESTAURE_DEFAULT 152 -#define IDD_SYSTEM_INFO 153 -#define IDB_SLASH_SCREEN 155 -#define IDC_TREE1 1000 -#define IDC_BAR 1001 -#define IDC_STATIC_UP 1004 -#define IDC_STATIC_DOWN 1005 -#define IDC_FULLSCREEN 1009 -#define IDC_RADIO2 1010 -#define IDC_WINDOW 1010 -#define IDC_MODE 1011 -#define IDC_WIDTH 1015 -#define IDC_COLOR_DEPTH_16 1016 -#define IDC_HEIGHT 1017 -#define IDC_SAVE_CONFIG 1017 -#define IDC_POSITION_X 1018 -#define IDC_SLEEP_TIME 1018 -#define IDC_COLOR_DEPTH_32 1019 -#define IDC_SLEEP 1019 -#define IDC_POSITION_Y 1020 -#define IDC_SOUND_ON 1020 -#define IDC_EAX 1021 -#define IDC_LD_TEXTURE 1021 -#define IDC_HD_TEXTURE 1022 -#define IDC_FMOD 1022 -#define IDC_FORCESOUNDSOFT 1023 -#define IDC_FORCE_DXTC 1024 -#define IDC_DISABLE_VERTEX_PROGRAM 1025 -#define IDC_DIVIDE_TEXTURE_SIZE 1025 -#define IDC_DISABLE_AGP_VERTICES 1026 -#define IDC_GL_VENDOR 1027 -#define IDC_DISABLE_TEXTURE_SHADERS 1028 -#define IDC_GL_RENDERER 1028 -#define IDC_GL_VERSION 1029 -#define IDC_EXTENSION 1030 -#define IDC_D3D_DRIVER 1030 -#define IDC_D3D_DRIVER_VERSION 1031 -#define IDC_VIDEO_CARD 1033 -#define IDC_BUTTON1 1035 -#define IDC_RESET 1035 -#define IDC_SYSTEM_MEMORY 1036 -#define IDC_CPU_FREQUENCY 1037 -#define IDC_VIDEO_MEMORY 1038 -#define IDC_LANDSCAPE_QUALITY 1039 -#define IDC_HARDWARE_SOUND_BUFFER 1039 -#define IDC_LANDSCAPE_QUALITY_VALUE 1041 -#define IDC_NUMBER_HIGH_CHARACTER 1042 -#define IDC_CHARACTER_QUALITY 1043 -#define IDC_CHARACTER_QUALITY_VALUE 1044 -#define IDC_SOUND_BUFFERS 1044 -#define IDC_FX_QUALITY 1045 -#define IDC_FX_QUALITY_VALUE 1046 -#define IDC_SOUND_QUALITY 1046 -#define IDC_TEXTURE_QUALITY_VALUE 1047 -#define IDC_SOUND_QUALITY_VALUE 1047 -#define IDC_TEXTURE_QUALITY 1048 -#define IDC_SOUND_TEXT_EAX 1048 -#define IDC_SOUND_TEXT_SB 1049 -#define IDC_DISPLAY_WND_TEXT0 1050 -#define IDC_SOUND_TEXT_FMOD 1050 -#define IDC_DISPLAY_WND_TEXT1 1051 -#define IDC_SOUND_TEXT_FORCESOFT 1051 -#define IDC_DISPLAY_WND_TEXT2 1052 -#define IDC_DISPLAY_WND_TEXT3 1053 -#define IDC_DISPLAY_FS_TEXT0 1054 -#define IDC_D3D_VENDOR 1055 -#define IDC_D3D_DEVICE_NAME 1056 -#define IDC_D3D_DESCRIPTION 1057 -#define IDC_LANGUAGE 1058 -#define IDC_SYS_INFO_PHY_MEM 1059 -#define IDC_SYS_INFO_OS 1060 -#define IDC_SYS_INFO_CPU 1061 -#define IDC_SYS_INFO_VIDEO 1062 -#define IDC_SYS_INFO_VIDEO_DRIVER 1063 -#define IDC_DRV3D_AUTO 1100 -#define IDC_DIRECT3D 1101 -#define IDC_OPENGL 1102 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 156 -#define _APS_NEXT_COMMAND_VALUE 32771 -#define _APS_NEXT_CONTROL_VALUE 1063 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif +// 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 . + +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by client_config.rc +// +#define IDCANCEL2 4 +#define ID_APPLY 4 +#define ID_DEFAULT 5 +#define ID_LAUNCH 6 +#define IDM_ABOUTBOX 0x0010 +#define IDD_ABOUTBOX 100 +#define IDS_ABOUTBOX 101 +#define IDD_CLIENT_CONFIG_DIALOG 102 +#define IDS_GENERAL 102 +#define IDD_LAYOUT 103 +#define IDS_DISPLAY 103 +#define IDS_DETAILS 104 +#define IDS_DISPLAY_DETAILS 104 +#define IDS_ADVANCED 105 +#define IDS_DISPLAY_ADVANCED 105 +#define IDS_SOUND 106 +#define IDS_NETWORK 107 +#define IDS_PATCHES 108 +#define IDS_DRIVER 109 +#define IDS_WELCOME 110 +#define IDS_TITLE 111 +#define IDS_BITS 112 +#define IDS_HZ 113 +#define IDS_PRESET 114 +#define IDS_Q_QUIT_WITHOUT_SAVING 115 +#define IDS_UNKNOWN 116 +#define IDD_SLASH_SCREEN 116 +#define IDS_DISPLAY_OPENGL_INFO 117 +#define IDS_MO 118 +#define IDS_MHZ 119 +#define IDS_UNKOWN_VIDEO_CARD 120 +#define IDS_GENERIC_NO_TNL 121 +#define IDS_GENERIC_TNL 122 +#define IDS_GEFORCE 123 +#define IDS_GEFORCE2 124 +#define IDS_GEFORCE3 125 +#define IDS_GEFORCE4TI 126 +#define IDS_GEFORCE4MX 127 +#define IDR_MAINFRAME 128 +#define IDS_RADEON_SDR 128 +#define IDB_LEFT_0 129 +#define IDS_RADEON_DDR 129 +#define IDS_RADEON_7200 130 +#define IDS_RADEON_7500 131 +#define IDB_TOP_RIGHT 132 +#define IDS_RADEON_8500 132 +#define IDB_DISPLAY 133 +#define IDS_RADEON_9000 133 +#define IDB_CARD 134 +#define IDS_RADEON_9500 134 +#define IDB_DISPLAY_CONFIG 135 +#define IDB_DISPLAY_ADVANCED 135 +#define IDS_RADEON_9700 135 +#define IDB_DISPLAY_PROPERTIES 136 +#define IDB_DISPLAY_DETAILS 136 +#define IDS_CHOOSE_A_CARD 136 +#define IDB_GENERAL 137 +#define IDS_POOR 137 +#define IDB_NETWORK 138 +#define IDS_MEDIUM 138 +#define IDB_SOUND 139 +#define IDS_NORMAL 139 +#define IDB_UPDATE 140 +#define IDS_SUPER 140 +#define IDS_GEFORCEFX 141 +#define IDB_WELCOME 142 +#define IDS_BUFFERS 142 +#define IDD_GENERAL 143 +#define IDS_TEXTURE_LOW 143 +#define IDD_DISPLAY 144 +#define IDS_TEXTURE_NORMAL 144 +#define IDD_SOUND 145 +#define IDS_TEXTURE_HIGH 145 +#define IDD_DISPLAY_DETAILS 146 +#define IDS_TRACKS 146 +#define IDD_DISPLAY_ADVANCED 147 +#define IDD_DISPLAY_INFO 148 +#define IDD_PRESET 149 +#define IDD_DISPLAY_D3D 150 +#define IDS_DISPLAY_D3D_INFO 151 +#define IDS_Q_RESTAURE_DEFAULT 152 +#define IDD_SYSTEM_INFO 153 +#define IDB_SLASH_SCREEN 155 +#define IDC_TREE1 1000 +#define IDC_BAR 1001 +#define IDC_STATIC_UP 1004 +#define IDC_STATIC_DOWN 1005 +#define IDC_FULLSCREEN 1009 +#define IDC_RADIO2 1010 +#define IDC_WINDOW 1010 +#define IDC_MODE 1011 +#define IDC_WIDTH 1015 +#define IDC_COLOR_DEPTH_16 1016 +#define IDC_HEIGHT 1017 +#define IDC_SAVE_CONFIG 1017 +#define IDC_POSITION_X 1018 +#define IDC_SLEEP_TIME 1018 +#define IDC_COLOR_DEPTH_32 1019 +#define IDC_SLEEP 1019 +#define IDC_POSITION_Y 1020 +#define IDC_SOUND_ON 1020 +#define IDC_EAX 1021 +#define IDC_LD_TEXTURE 1021 +#define IDC_HD_TEXTURE 1022 +#define IDC_FMOD 1022 +#define IDC_FORCESOUNDSOFT 1023 +#define IDC_FORCE_DXTC 1024 +#define IDC_DISABLE_VERTEX_PROGRAM 1025 +#define IDC_DIVIDE_TEXTURE_SIZE 1025 +#define IDC_DISABLE_AGP_VERTICES 1026 +#define IDC_GL_VENDOR 1027 +#define IDC_DISABLE_TEXTURE_SHADERS 1028 +#define IDC_GL_RENDERER 1028 +#define IDC_GL_VERSION 1029 +#define IDC_EXTENSION 1030 +#define IDC_D3D_DRIVER 1030 +#define IDC_D3D_DRIVER_VERSION 1031 +#define IDC_VIDEO_CARD 1033 +#define IDC_BUTTON1 1035 +#define IDC_RESET 1035 +#define IDC_SYSTEM_MEMORY 1036 +#define IDC_CPU_FREQUENCY 1037 +#define IDC_VIDEO_MEMORY 1038 +#define IDC_LANDSCAPE_QUALITY 1039 +#define IDC_HARDWARE_SOUND_BUFFER 1039 +#define IDC_LANDSCAPE_QUALITY_VALUE 1041 +#define IDC_NUMBER_HIGH_CHARACTER 1042 +#define IDC_CHARACTER_QUALITY 1043 +#define IDC_CHARACTER_QUALITY_VALUE 1044 +#define IDC_SOUND_BUFFERS 1044 +#define IDC_FX_QUALITY 1045 +#define IDC_FX_QUALITY_VALUE 1046 +#define IDC_SOUND_QUALITY 1046 +#define IDC_TEXTURE_QUALITY_VALUE 1047 +#define IDC_SOUND_QUALITY_VALUE 1047 +#define IDC_TEXTURE_QUALITY 1048 +#define IDC_SOUND_TEXT_EAX 1048 +#define IDC_SOUND_TEXT_SB 1049 +#define IDC_DISPLAY_WND_TEXT0 1050 +#define IDC_SOUND_TEXT_FMOD 1050 +#define IDC_DISPLAY_WND_TEXT1 1051 +#define IDC_SOUND_TEXT_FORCESOFT 1051 +#define IDC_DISPLAY_WND_TEXT2 1052 +#define IDC_DISPLAY_WND_TEXT3 1053 +#define IDC_DISPLAY_FS_TEXT0 1054 +#define IDC_D3D_VENDOR 1055 +#define IDC_D3D_DEVICE_NAME 1056 +#define IDC_D3D_DESCRIPTION 1057 +#define IDC_LANGUAGE 1058 +#define IDC_SYS_INFO_PHY_MEM 1059 +#define IDC_SYS_INFO_OS 1060 +#define IDC_SYS_INFO_CPU 1061 +#define IDC_SYS_INFO_VIDEO 1062 +#define IDC_SYS_INFO_VIDEO_DRIVER 1063 +#define IDC_DRV3D_AUTO 1100 +#define IDC_DIRECT3D 1101 +#define IDC_OPENGL 1102 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 156 +#define _APS_NEXT_COMMAND_VALUE 32771 +#define _APS_NEXT_CONTROL_VALUE 1063 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/code/ryzom/tools/client/client_config/sound_dlg.cpp b/code/ryzom/tools/client/client_config/sound_dlg.cpp index 703965b8f..6d8550398 100644 --- a/code/ryzom/tools/client/client_config/sound_dlg.cpp +++ b/code/ryzom/tools/client/client_config/sound_dlg.cpp @@ -1,174 +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 . - -// sound_dlg.cpp : implementation file -// - -#include "stdafx.h" -#include "base_dialog.h" -#include "client_config.h" -#include "sound_dlg.h" -#include "cfg_file.h" - -// *************************************************************************** -#define SOUND_BUFFER_STEP 8 -#define SOUND_BUFFER_NUM_STEP (32/SOUND_BUFFER_STEP) - -// *************************************************************************** -// CSoundDlg dialog -// *************************************************************************** - -CSoundDlg::CSoundDlg(CWnd* pParent /*=NULL*/) - : CBaseDialog(CSoundDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CSoundDlg) - SoundOn = FALSE; - EAX = FALSE; - FMod = FALSE; - ForceSoundSoft = FALSE; - SoundQualityInt = 1; - //}}AFX_DATA_INIT -} - -// *************************************************************************** - -void CSoundDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CSoundDlg) - DDX_Control(pDX, IDC_SOUND_TEXT_SB, TextSB); - DDX_Control(pDX, IDC_SOUND_TEXT_EAX, TextEAX); - DDX_Control(pDX, IDC_SOUND_TEXT_FMOD, TextFMod); - DDX_Control(pDX, IDC_SOUND_TEXT_FORCESOFT, TextForceSoundSoft); - DDX_Control(pDX, IDC_EAX, EAXCtrl); - DDX_Control(pDX, IDC_FMOD, FModCtrl); - DDX_Control(pDX, IDC_FORCESOUNDSOFT, ForceSoundSoftCtrl); - DDX_Check(pDX, IDC_SOUND_ON, SoundOn); - DDX_Check(pDX, IDC_EAX, EAX); - DDX_Check(pDX, IDC_FMOD, FMod); - DDX_Check(pDX, IDC_FORCESOUNDSOFT, ForceSoundSoft); - DDX_Control(pDX, IDC_SOUND_QUALITY, SoundQuality); - DDX_Control(pDX, IDC_SOUND_QUALITY_VALUE, SoundQualityValue); - DDX_Slider(pDX, IDC_SOUND_QUALITY, SoundQualityInt); - //}}AFX_DATA_MAP -} - -// *************************************************************************** - -BEGIN_MESSAGE_MAP(CSoundDlg, CDialog) - //{{AFX_MSG_MAP(CSoundDlg) - ON_WM_HSCROLL() - ON_BN_CLICKED(IDC_SOUND_ON, OnSoundOn) - ON_BN_CLICKED(IDC_EAX, OnEax) - ON_BN_CLICKED(IDC_FMOD, OnFMod) - ON_BN_CLICKED(IDC_FORCESOUNDSOFT, OnForceSoundSoft) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// *************************************************************************** -// CSoundDlg message handlers -// *************************************************************************** - -void CSoundDlg::OnSoundOn() -{ - UpdateData (TRUE); - updateState (); - UpdateData (FALSE); - InvalidateConfig (); -} - -// *************************************************************************** - -void CSoundDlg::updateState () -{ - FModCtrl.EnableWindow (SoundOn); - ForceSoundSoftCtrl.EnableWindow (SoundOn); - EAXCtrl.EnableWindow (SoundOn); - SoundQuality.EnableWindow (SoundOn); - TextSB.EnableWindow (SoundOn); - TextEAX.EnableWindow (SoundOn); - TextFMod.EnableWindow (SoundOn); - TextForceSoundSoft.EnableWindow (SoundOn); - SoundQualityValue.EnableWindow (SoundOn); - - // Yoyo: temporary avoid FMod ctrl, since always FMod.... - TextFMod.ShowWindow(SW_HIDE); - FModCtrl.ShowWindow(SW_HIDE); - - ucstring str = NLMISC::toString (getAsNumSoundBuffer()) + " " + NLMISC::CI18N::get ("uiConfigTracks"); - setWindowText(SoundQualityValue, (WCHAR*)str.c_str()); -} - -// *************************************************************************** - -BOOL CSoundDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - SoundQuality.SetRange(1, SOUND_BUFFER_NUM_STEP); - - updateState (); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -// *************************************************************************** - -void CSoundDlg::OnEax() -{ - InvalidateConfig (); -} - -// *************************************************************************** - -void CSoundDlg::OnFMod() -{ - InvalidateConfig (); -} - -// *************************************************************************** - -void CSoundDlg::OnForceSoundSoft() -{ - InvalidateConfig (); -} - -// *************************************************************************** -void CSoundDlg::setAsNumSoundBuffer(uint sb) -{ - SoundQualityInt= sb/SOUND_BUFFER_STEP; - NLMISC::clamp(SoundQualityInt, 1, SOUND_BUFFER_NUM_STEP); -} - -// *************************************************************************** -uint CSoundDlg::getAsNumSoundBuffer() const -{ - return SoundQualityInt * SOUND_BUFFER_STEP; -} - -// *************************************************************************** - -void CSoundDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) -{ - UpdateData (); - updateState (); - UpdateData (FALSE); - InvalidateConfig (); - - CDialog::OnHScroll(nSBCode, nPos, pScrollBar); -} - +// 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 . + +// sound_dlg.cpp : implementation file +// + +#include "stdafx.h" +#include "base_dialog.h" +#include "client_config.h" +#include "sound_dlg.h" +#include "cfg_file.h" + +// *************************************************************************** +#define SOUND_BUFFER_STEP 8 +#define SOUND_BUFFER_NUM_STEP (32/SOUND_BUFFER_STEP) + +// *************************************************************************** +// CSoundDlg dialog +// *************************************************************************** + +CSoundDlg::CSoundDlg(CWnd* pParent /*=NULL*/) + : CBaseDialog(CSoundDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(CSoundDlg) + SoundOn = FALSE; + EAX = FALSE; + FMod = FALSE; + ForceSoundSoft = FALSE; + SoundQualityInt = 1; + //}}AFX_DATA_INIT +} + +// *************************************************************************** + +void CSoundDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CSoundDlg) + DDX_Control(pDX, IDC_SOUND_TEXT_SB, TextSB); + DDX_Control(pDX, IDC_SOUND_TEXT_EAX, TextEAX); + DDX_Control(pDX, IDC_SOUND_TEXT_FMOD, TextFMod); + DDX_Control(pDX, IDC_SOUND_TEXT_FORCESOFT, TextForceSoundSoft); + DDX_Control(pDX, IDC_EAX, EAXCtrl); + DDX_Control(pDX, IDC_FMOD, FModCtrl); + DDX_Control(pDX, IDC_FORCESOUNDSOFT, ForceSoundSoftCtrl); + DDX_Check(pDX, IDC_SOUND_ON, SoundOn); + DDX_Check(pDX, IDC_EAX, EAX); + DDX_Check(pDX, IDC_FMOD, FMod); + DDX_Check(pDX, IDC_FORCESOUNDSOFT, ForceSoundSoft); + DDX_Control(pDX, IDC_SOUND_QUALITY, SoundQuality); + DDX_Control(pDX, IDC_SOUND_QUALITY_VALUE, SoundQualityValue); + DDX_Slider(pDX, IDC_SOUND_QUALITY, SoundQualityInt); + //}}AFX_DATA_MAP +} + +// *************************************************************************** + +BEGIN_MESSAGE_MAP(CSoundDlg, CDialog) + //{{AFX_MSG_MAP(CSoundDlg) + ON_WM_HSCROLL() + ON_BN_CLICKED(IDC_SOUND_ON, OnSoundOn) + ON_BN_CLICKED(IDC_EAX, OnEax) + ON_BN_CLICKED(IDC_FMOD, OnFMod) + ON_BN_CLICKED(IDC_FORCESOUNDSOFT, OnForceSoundSoft) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +// *************************************************************************** +// CSoundDlg message handlers +// *************************************************************************** + +void CSoundDlg::OnSoundOn() +{ + UpdateData (TRUE); + updateState (); + UpdateData (FALSE); + InvalidateConfig (); +} + +// *************************************************************************** + +void CSoundDlg::updateState () +{ + FModCtrl.EnableWindow (SoundOn); + ForceSoundSoftCtrl.EnableWindow (SoundOn); + EAXCtrl.EnableWindow (SoundOn); + SoundQuality.EnableWindow (SoundOn); + TextSB.EnableWindow (SoundOn); + TextEAX.EnableWindow (SoundOn); + TextFMod.EnableWindow (SoundOn); + TextForceSoundSoft.EnableWindow (SoundOn); + SoundQualityValue.EnableWindow (SoundOn); + + // Yoyo: temporary avoid FMod ctrl, since always FMod.... + TextFMod.ShowWindow(SW_HIDE); + FModCtrl.ShowWindow(SW_HIDE); + + ucstring str = NLMISC::toString (getAsNumSoundBuffer()) + " " + NLMISC::CI18N::get ("uiConfigTracks"); + setWindowText(SoundQualityValue, (WCHAR*)str.c_str()); +} + +// *************************************************************************** + +BOOL CSoundDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + SoundQuality.SetRange(1, SOUND_BUFFER_NUM_STEP); + + updateState (); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +// *************************************************************************** + +void CSoundDlg::OnEax() +{ + InvalidateConfig (); +} + +// *************************************************************************** + +void CSoundDlg::OnFMod() +{ + InvalidateConfig (); +} + +// *************************************************************************** + +void CSoundDlg::OnForceSoundSoft() +{ + InvalidateConfig (); +} + +// *************************************************************************** +void CSoundDlg::setAsNumSoundBuffer(uint sb) +{ + SoundQualityInt= sb/SOUND_BUFFER_STEP; + NLMISC::clamp(SoundQualityInt, 1, SOUND_BUFFER_NUM_STEP); +} + +// *************************************************************************** +uint CSoundDlg::getAsNumSoundBuffer() const +{ + return SoundQualityInt * SOUND_BUFFER_STEP; +} + +// *************************************************************************** + +void CSoundDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) +{ + UpdateData (); + updateState (); + UpdateData (FALSE); + InvalidateConfig (); + + CDialog::OnHScroll(nSBCode, nPos, pScrollBar); +} + diff --git a/code/ryzom/tools/client/client_config/sound_dlg.h b/code/ryzom/tools/client/client_config/sound_dlg.h index 4d8b0d993..8bc70875d 100644 --- a/code/ryzom/tools/client/client_config/sound_dlg.h +++ b/code/ryzom/tools/client/client_config/sound_dlg.h @@ -1,85 +1,85 @@ -// 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 . - -#if !defined(AFX_SOUND_DLG_H__2BBC25D5_CD0E_4705_8D66_3912F5B14D88__INCLUDED_) -#define AFX_SOUND_DLG_H__2BBC25D5_CD0E_4705_8D66_3912F5B14D88__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// sound_dlg.h : header file -// - -// *************************************************************************** -// CSoundDlg dialog -// *************************************************************************** - -class CSoundDlg : public CBaseDialog -{ -// Construction -public: - CSoundDlg(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CSoundDlg) - enum { IDD = IDD_SOUND }; - CStatic TextSB; - CStatic TextEAX; - CStatic TextFMod; - CStatic TextForceSoundSoft; - CButton EAXCtrl; - CButton FModCtrl; - CButton ForceSoundSoftCtrl; - BOOL SoundOn; - BOOL EAX; - BOOL FMod; - BOOL ForceSoundSoft; - CSliderCtrl SoundQuality; - CStatic SoundQualityValue; - int SoundQualityInt; - //}}AFX_DATA - - void updateState (); - - void setAsNumSoundBuffer(uint sb); - uint getAsNumSoundBuffer() const; - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CSoundDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CSoundDlg) - afx_msg void OnSoundOn(); - virtual BOOL OnInitDialog(); - afx_msg void OnEax(); - afx_msg void OnFMod(); - afx_msg void OnForceSoundSoft(); - afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_SOUND_DLG_H__2BBC25D5_CD0E_4705_8D66_3912F5B14D88__INCLUDED_) +// 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 . + +#if !defined(AFX_SOUND_DLG_H__2BBC25D5_CD0E_4705_8D66_3912F5B14D88__INCLUDED_) +#define AFX_SOUND_DLG_H__2BBC25D5_CD0E_4705_8D66_3912F5B14D88__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// sound_dlg.h : header file +// + +// *************************************************************************** +// CSoundDlg dialog +// *************************************************************************** + +class CSoundDlg : public CBaseDialog +{ +// Construction +public: + CSoundDlg(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CSoundDlg) + enum { IDD = IDD_SOUND }; + CStatic TextSB; + CStatic TextEAX; + CStatic TextFMod; + CStatic TextForceSoundSoft; + CButton EAXCtrl; + CButton FModCtrl; + CButton ForceSoundSoftCtrl; + BOOL SoundOn; + BOOL EAX; + BOOL FMod; + BOOL ForceSoundSoft; + CSliderCtrl SoundQuality; + CStatic SoundQualityValue; + int SoundQualityInt; + //}}AFX_DATA + + void updateState (); + + void setAsNumSoundBuffer(uint sb); + uint getAsNumSoundBuffer() const; + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CSoundDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CSoundDlg) + afx_msg void OnSoundOn(); + virtual BOOL OnInitDialog(); + afx_msg void OnEax(); + afx_msg void OnFMod(); + afx_msg void OnForceSoundSoft(); + afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_SOUND_DLG_H__2BBC25D5_CD0E_4705_8D66_3912F5B14D88__INCLUDED_) diff --git a/code/ryzom/tools/client/client_config/system_information_dlg.cpp b/code/ryzom/tools/client/client_config/system_information_dlg.cpp index 0b9556d2a..d1a3071be 100644 --- a/code/ryzom/tools/client/client_config/system_information_dlg.cpp +++ b/code/ryzom/tools/client/client_config/system_information_dlg.cpp @@ -1,83 +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 . - -// system_information_dlg.cpp : implementation file -// - -#include "stdafx.h" -#include "client_config.h" -#include "system_information_dlg.h" - -using namespace std; -using namespace NLMISC; - -// *************************************************************************** -// CSystemInformationDlg dialog -// *************************************************************************** - -CSystemInformationDlg::CSystemInformationDlg(CWnd* pParent /*=NULL*/) - : CBaseDialog(CSystemInformationDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CSystemInformationDlg) - //}}AFX_DATA_INIT -} - -// *************************************************************************** - -void CSystemInformationDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CSystemInformationDlg) - DDX_Control(pDX, IDC_SYS_INFO_VIDEO, VideoCtrl); - DDX_Control(pDX, IDC_SYS_INFO_PHY_MEM, PhysicalMemoryCtrl); - DDX_Control(pDX, IDC_SYS_INFO_VIDEO_DRIVER, VideoDriverCtrl); - DDX_Control(pDX, IDC_SYS_INFO_OS, OSCtrl); - DDX_Control(pDX, IDC_SYS_INFO_CPU, CPUCtrl); - //}}AFX_DATA_MAP -} - -// *************************************************************************** - -BEGIN_MESSAGE_MAP(CSystemInformationDlg, CDialog) - //{{AFX_MSG_MAP(CSystemInformationDlg) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// *************************************************************************** -// CSystemInformationDlg message handlers -// *************************************************************************** - -BOOL CSystemInformationDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - string deviceName; - uint64 driverVersion; - if (CSystemInfo::getVideoInfo (deviceName, driverVersion)) - { - VideoCtrl.SetWindowText (deviceName.c_str ()); - uint32 version = (uint32)(driverVersion&0xffff); - VideoDriverCtrl.SetWindowText (toString ("%d.%d.%d.%d", version/1000%10, version/100%10, version/10%10, version%10).c_str ()); - } - PhysicalMemoryCtrl.SetWindowText (bytesToHumanReadable(CSystemInfo::totalPhysicalMemory()).c_str ()); - OSCtrl.SetWindowText (CSystemInfo::getOS().c_str ()); - CPUCtrl.SetWindowText (CSystemInfo::getProc().c_str ()); - - UpdateData (TRUE); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} +// 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 . + +// system_information_dlg.cpp : implementation file +// + +#include "stdafx.h" +#include "client_config.h" +#include "system_information_dlg.h" + +using namespace std; +using namespace NLMISC; + +// *************************************************************************** +// CSystemInformationDlg dialog +// *************************************************************************** + +CSystemInformationDlg::CSystemInformationDlg(CWnd* pParent /*=NULL*/) + : CBaseDialog(CSystemInformationDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(CSystemInformationDlg) + //}}AFX_DATA_INIT +} + +// *************************************************************************** + +void CSystemInformationDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CSystemInformationDlg) + DDX_Control(pDX, IDC_SYS_INFO_VIDEO, VideoCtrl); + DDX_Control(pDX, IDC_SYS_INFO_PHY_MEM, PhysicalMemoryCtrl); + DDX_Control(pDX, IDC_SYS_INFO_VIDEO_DRIVER, VideoDriverCtrl); + DDX_Control(pDX, IDC_SYS_INFO_OS, OSCtrl); + DDX_Control(pDX, IDC_SYS_INFO_CPU, CPUCtrl); + //}}AFX_DATA_MAP +} + +// *************************************************************************** + +BEGIN_MESSAGE_MAP(CSystemInformationDlg, CDialog) + //{{AFX_MSG_MAP(CSystemInformationDlg) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +// *************************************************************************** +// CSystemInformationDlg message handlers +// *************************************************************************** + +BOOL CSystemInformationDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + string deviceName; + uint64 driverVersion; + if (CSystemInfo::getVideoInfo (deviceName, driverVersion)) + { + VideoCtrl.SetWindowText (deviceName.c_str ()); + uint32 version = (uint32)(driverVersion&0xffff); + VideoDriverCtrl.SetWindowText (toString ("%d.%d.%d.%d", version/1000%10, version/100%10, version/10%10, version%10).c_str ()); + } + PhysicalMemoryCtrl.SetWindowText (bytesToHumanReadable(CSystemInfo::totalPhysicalMemory()).c_str ()); + OSCtrl.SetWindowText (CSystemInfo::getOS().c_str ()); + CPUCtrl.SetWindowText (CSystemInfo::getProc().c_str ()); + + UpdateData (TRUE); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} diff --git a/code/ryzom/tools/client/client_config/system_information_dlg.h b/code/ryzom/tools/client/client_config/system_information_dlg.h index c1b35713c..24a07f38a 100644 --- a/code/ryzom/tools/client/client_config/system_information_dlg.h +++ b/code/ryzom/tools/client/client_config/system_information_dlg.h @@ -1,68 +1,68 @@ -// 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 . - -#if !defined(AFX_SYSTEM_INFORMATION_DLG_H__1640EAF7_D7B9_4A7D_9F07_B4F5D943D22D__INCLUDED_) -#define AFX_SYSTEM_INFORMATION_DLG_H__1640EAF7_D7B9_4A7D_9F07_B4F5D943D22D__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// system_information_dlg.h : header file -// - -#include "base_dialog.h" - -///////////////////////////////////////////////////////////////////////////// -// CSystemInformationDlg dialog - -class CSystemInformationDlg : public CBaseDialog -{ -// Construction -public: - CSystemInformationDlg(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CSystemInformationDlg) - enum { IDD = IDD_SYSTEM_INFO }; - CStatic VideoCtrl; - CStatic PhysicalMemoryCtrl; - CStatic VideoDriverCtrl; - CStatic OSCtrl; - CStatic CPUCtrl; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CSystemInformationDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CSystemInformationDlg) - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_SYSTEM_INFORMATION_DLG_H__1640EAF7_D7B9_4A7D_9F07_B4F5D943D22D__INCLUDED_) +// 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 . + +#if !defined(AFX_SYSTEM_INFORMATION_DLG_H__1640EAF7_D7B9_4A7D_9F07_B4F5D943D22D__INCLUDED_) +#define AFX_SYSTEM_INFORMATION_DLG_H__1640EAF7_D7B9_4A7D_9F07_B4F5D943D22D__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// system_information_dlg.h : header file +// + +#include "base_dialog.h" + +///////////////////////////////////////////////////////////////////////////// +// CSystemInformationDlg dialog + +class CSystemInformationDlg : public CBaseDialog +{ +// Construction +public: + CSystemInformationDlg(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CSystemInformationDlg) + enum { IDD = IDD_SYSTEM_INFO }; + CStatic VideoCtrl; + CStatic PhysicalMemoryCtrl; + CStatic VideoDriverCtrl; + CStatic OSCtrl; + CStatic CPUCtrl; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CSystemInformationDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CSystemInformationDlg) + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_SYSTEM_INFORMATION_DLG_H__1640EAF7_D7B9_4A7D_9F07_B4F5D943D22D__INCLUDED_) diff --git a/code/ryzom/tools/client/client_data_check/ReadMe.txt b/code/ryzom/tools/client/client_data_check/ReadMe.txt index 9774a5f6f..617a88ad1 100644 --- a/code/ryzom/tools/client/client_data_check/ReadMe.txt +++ b/code/ryzom/tools/client/client_data_check/ReadMe.txt @@ -1,88 +1,88 @@ -======================================================================== - MICROSOFT FOUNDATION CLASS LIBRARY : client_data_check -======================================================================== - - -AppWizard has created this client_data_check application for you. This application -not only demonstrates the basics of using the Microsoft Foundation classes -but is also a starting point for writing your application. - -This file contains a summary of what you will find in each of the files that -make up your client_data_check application. - -client_data_check.dsp - This file (the project file) contains information at the project level and - is used to build a single project or subproject. Other users can share the - project (.dsp) file, but they should export the makefiles locally. - -client_data_check.h - This is the main header file for the application. It includes other - project specific headers (including Resource.h) and declares the - CClient_data_checkApp application class. - -client_data_check.cpp - This is the main application source file that contains the application - class CClient_data_checkApp. - -client_data_check.rc - This is a listing of all of the Microsoft Windows resources that the - program uses. It includes the icons, bitmaps, and cursors that are stored - in the RES subdirectory. This file can be directly edited in Microsoft - Visual C++. - -client_data_check.clw - This file contains information used by ClassWizard to edit existing - classes or add new classes. ClassWizard also uses this file to store - information needed to create and edit message maps and dialog data - maps and to create prototype member functions. - -res\client_data_check.ico - This is an icon file, which is used as the application's icon. This - icon is included by the main resource file client_data_check.rc. - -res\client_data_check.rc2 - This file contains resources that are not edited by Microsoft - Visual C++. You should place all resources not editable by - the resource editor in this file. - - - - -///////////////////////////////////////////////////////////////////////////// - -AppWizard creates one dialog class: - -client_data_checkDlg.h, client_data_checkDlg.cpp - the dialog - These files contain your CClient_data_checkDlg class. This class defines - the behavior of your application's main dialog. The dialog's - template is in client_data_check.rc, which can be edited in Microsoft - Visual C++. - - -///////////////////////////////////////////////////////////////////////////// -Other standard files: - -StdAfx.h, StdAfx.cpp - These files are used to build a precompiled header (PCH) file - named client_data_check.pch and a precompiled types file named StdAfx.obj. - -Resource.h - This is the standard header file, which defines new resource IDs. - Microsoft Visual C++ reads and updates this file. - -///////////////////////////////////////////////////////////////////////////// -Other notes: - -AppWizard uses "TODO:" to indicate parts of the source code you -should add to or customize. - -If your application uses MFC in a shared DLL, and your application is -in a language other than the operating system's current language, you -will need to copy the corresponding localized resources MFC42XXX.DLL -from the Microsoft Visual C++ CD-ROM onto the system or system32 directory, -and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation. -For example, MFC42DEU.DLL contains resources translated to German.) If you -don't do this, some of the UI elements of your application will remain in the -language of the operating system. - -///////////////////////////////////////////////////////////////////////////// +======================================================================== + MICROSOFT FOUNDATION CLASS LIBRARY : client_data_check +======================================================================== + + +AppWizard has created this client_data_check application for you. This application +not only demonstrates the basics of using the Microsoft Foundation classes +but is also a starting point for writing your application. + +This file contains a summary of what you will find in each of the files that +make up your client_data_check application. + +client_data_check.dsp + This file (the project file) contains information at the project level and + is used to build a single project or subproject. Other users can share the + project (.dsp) file, but they should export the makefiles locally. + +client_data_check.h + This is the main header file for the application. It includes other + project specific headers (including Resource.h) and declares the + CClient_data_checkApp application class. + +client_data_check.cpp + This is the main application source file that contains the application + class CClient_data_checkApp. + +client_data_check.rc + This is a listing of all of the Microsoft Windows resources that the + program uses. It includes the icons, bitmaps, and cursors that are stored + in the RES subdirectory. This file can be directly edited in Microsoft + Visual C++. + +client_data_check.clw + This file contains information used by ClassWizard to edit existing + classes or add new classes. ClassWizard also uses this file to store + information needed to create and edit message maps and dialog data + maps and to create prototype member functions. + +res\client_data_check.ico + This is an icon file, which is used as the application's icon. This + icon is included by the main resource file client_data_check.rc. + +res\client_data_check.rc2 + This file contains resources that are not edited by Microsoft + Visual C++. You should place all resources not editable by + the resource editor in this file. + + + + +///////////////////////////////////////////////////////////////////////////// + +AppWizard creates one dialog class: + +client_data_checkDlg.h, client_data_checkDlg.cpp - the dialog + These files contain your CClient_data_checkDlg class. This class defines + the behavior of your application's main dialog. The dialog's + template is in client_data_check.rc, which can be edited in Microsoft + Visual C++. + + +///////////////////////////////////////////////////////////////////////////// +Other standard files: + +StdAfx.h, StdAfx.cpp + These files are used to build a precompiled header (PCH) file + named client_data_check.pch and a precompiled types file named StdAfx.obj. + +Resource.h + This is the standard header file, which defines new resource IDs. + Microsoft Visual C++ reads and updates this file. + +///////////////////////////////////////////////////////////////////////////// +Other notes: + +AppWizard uses "TODO:" to indicate parts of the source code you +should add to or customize. + +If your application uses MFC in a shared DLL, and your application is +in a language other than the operating system's current language, you +will need to copy the corresponding localized resources MFC42XXX.DLL +from the Microsoft Visual C++ CD-ROM onto the system or system32 directory, +and rename it to be MFCLOC.DLL. ("XXX" stands for the language abbreviation. +For example, MFC42DEU.DLL contains resources translated to German.) If you +don't do this, some of the UI elements of your application will remain in the +language of the operating system. + +///////////////////////////////////////////////////////////////////////////// diff --git a/code/ryzom/tools/client/client_data_check/StdAfx.cpp b/code/ryzom/tools/client/client_data_check/StdAfx.cpp index 3d755dc73..e69297f51 100644 --- a/code/ryzom/tools/client/client_data_check/StdAfx.cpp +++ b/code/ryzom/tools/client/client_data_check/StdAfx.cpp @@ -1,24 +1,24 @@ -// 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 . - -// stdafx.cpp : source file that includes just the standard includes -// client_data_check.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - - +// 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 . + +// stdafx.cpp : source file that includes just the standard includes +// client_data_check.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + + diff --git a/code/ryzom/tools/client/client_data_check/StdAfx.h b/code/ryzom/tools/client/client_data_check/StdAfx.h index 9f9328f1d..495612df0 100644 --- a/code/ryzom/tools/client/client_data_check/StdAfx.h +++ b/code/ryzom/tools/client/client_data_check/StdAfx.h @@ -1,43 +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 . - -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#if !defined(AFX_STDAFX_H__BF272F6C_B60A_4444_BC7C_C5B28ACF3B42__INCLUDED_) -#define AFX_STDAFX_H__BF272F6C_B60A_4444_BC7C_C5B28ACF3B42__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers - -#include // MFC core and standard components -#include // MFC extensions -#include // MFC Automation classes -#include // MFC support for Internet Explorer 4 Common Controls -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__BF272F6C_B60A_4444_BC7C_C5B28ACF3B42__INCLUDED_) +// 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 . + +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__BF272F6C_B60A_4444_BC7C_C5B28ACF3B42__INCLUDED_) +#define AFX_STDAFX_H__BF272F6C_B60A_4444_BC7C_C5B28ACF3B42__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers + +#include // MFC core and standard components +#include // MFC extensions +#include // MFC Automation classes +#include // MFC support for Internet Explorer 4 Common Controls +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC support for Windows Common Controls +#endif // _AFX_NO_AFXCMN_SUPPORT + + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__BF272F6C_B60A_4444_BC7C_C5B28ACF3B42__INCLUDED_) diff --git a/code/ryzom/tools/client/client_data_check/client_data_check.cpp b/code/ryzom/tools/client/client_data_check/client_data_check.cpp index 0a42ac368..f7ab9e10b 100644 --- a/code/ryzom/tools/client/client_data_check/client_data_check.cpp +++ b/code/ryzom/tools/client/client_data_check/client_data_check.cpp @@ -1,435 +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 . - -// client_data_check.cpp : Defines the class behaviors for the application. -// - -#include "nel/misc/time_nl.h" -#include "nel/misc/ucstring.h" -#include "nel/misc/algo.h" -#include "data_scan.h" -#include "nel/misc/debug.h" -#include "nel/misc/big_file.h" -#include "nel/misc/file.h" -#include "3d/shape.h" -#include "3d/mesh_mrm.h" -#include "3d/mesh_mrm_skinned.h" -#include "3d/register_3d.h" - -#include "stdafx.h" -#include "client_data_check.h" -#include "client_data_checkDlg.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -#pragma optimize("",off) - -///////////////////////////////////////////////////////////////////////////// -// CClient_data_checkApp - -BEGIN_MESSAGE_MAP(CClient_data_checkApp, CWinApp) - //{{AFX_MSG_MAP(CClient_data_checkApp) - // NOTE - the ClassWizard will add and remove mapping macros here. - // DO NOT EDIT what you see in these blocks of generated code! - //}}AFX_MSG - ON_COMMAND(ID_HELP, CWinApp::OnHelp) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CClient_data_checkApp construction - -CClient_data_checkApp::CClient_data_checkApp() -{ - _CheckDlg= NULL; - _StateProcess= Init; - _BnpIndex= 0; - _FileIndex= 0; -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only CClient_data_checkApp object - -CClient_data_checkApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// CClient_data_checkApp initialization - -BOOL CClient_data_checkApp::InitInstance() -{ - AfxEnableControlContainer(); - - // Standard initialization - // If you are not using these features and wish to reduce the size - // of your final executable, you should remove from the following - // the specific initialization routines you do not need. - -#ifdef _AFXDLL - Enable3dControls(); // Call this when using MFC in a shared DLL -#else - Enable3dControlsStatic(); // Call this when linking to MFC statically -#endif - - // init path - NLMISC::CPath::addSearchPath("data"); - NLMISC::CPath::addSearchPath("unpack"); - NL3D::registerSerial3d(); - - // init debug - NLMISC::createDebug(); - NLMISC::CFileDisplayer *DataCheckLogDisplayer= new NLMISC::CFileDisplayer("data_check.log", true, "DATA_CHECK.LOG"); - NLMISC::DebugLog->addDisplayer (DataCheckLogDisplayer); - NLMISC::InfoLog->addDisplayer (DataCheckLogDisplayer); - NLMISC::WarningLog->addDisplayer (DataCheckLogDisplayer); - NLMISC::ErrorLog->addDisplayer (DataCheckLogDisplayer); - NLMISC::AssertLog->addDisplayer (DataCheckLogDisplayer); - - - // init dlg - _CheckDlg= new CClient_data_checkDlg(this); - _CheckDlg->Create(CClient_data_checkDlg::IDD); - m_pMainWnd = _CheckDlg; - - /*int nResponse = dlg.DoModal(); - if (nResponse == IDOK) - { - // TODO: Place code here to handle when the dialog is - // dismissed with OK - } - else if (nResponse == IDCANCEL) - { - // TODO: Place code here to handle when the dialog is - // dismissed with Cancel - }*/ - - return TRUE; -} - -// *************************************************************************** -void CClient_data_checkApp::setLog() -{ - if(_CheckDlg) - { - _CheckDlg->ListBox.ResetContent(); - std::string tam= _LastDataScanLog.toString(); - std::vector listStr; - NLMISC::splitString(tam, "\n", listStr); - for(uint i=0;iListBox.AddString(listStr[i].c_str()); - _CheckDlg->UpdateData(FALSE); - } -} - -// *************************************************************************** -void CClient_data_checkApp::addLog(const std::string &logAdd) -{ - _LastDataScanLog+= std::string("\n") + logAdd; - setLog(); -} - -// *************************************************************************** -void CClient_data_checkApp::setStatus(const std::string &status) -{ - if(_CheckDlg) - { - _CheckDlg->TextStatus= status.c_str(); - _CheckDlg->UpdateData(FALSE); - } -} - - -// *************************************************************************** -void CClient_data_checkApp::checkMeshMrm(const std::string &fileName, NL3D::CMeshMRM *meshMrm) -{ - uint numLod= meshMrm->getNbLod(); - uint numVerts= meshMrm->getMeshGeom().getVertexBuffer().getNumVertices(); - if(numLod==0) - { - addLog(std::string("Warning: The File: ") + fileName + "has 0 Lods"); - } - else - { - const NL3D::CMeshMRMGeom& meshGeom= meshMrm->getMeshGeom(); - // Scan all Geomoprhs - for(uint i=0;i &geoms= meshGeom.getGeomorphs(i); - for(uint j=0;j=numVerts || geoms[j].End>=numVerts) - { - addLog(NLMISC::toString("ERROR: The Mrm File: %s has a bad Geomorph. Lod: %d. Vert: %d. Start/End: %d/%d. Max:%d", - fileName.c_str(), i, j, geoms[j].Start, geoms[j].End, numVerts)); - } - } - } - } -} - -// *************************************************************************** -void CClient_data_checkApp::checkMeshMrmSkinned(const std::string &fileName, NL3D::CMeshMRMSkinned *meshMrm) -{ - uint numLod= meshMrm->getNbLod(); - NL3D::CVertexBuffer vb; - meshMrm->getMeshGeom().getVertexBuffer(vb); - uint numVerts= vb.getNumVertices(); - if(numLod==0) - { - addLog(std::string("Warning: The File: ") + fileName + "has 0 Lods"); - } - else - { - const NL3D::CMeshMRMSkinnedGeom& meshGeom= meshMrm->getMeshGeom(); - // Scan all Geomoprhs - for(uint i=0;i &geoms= meshGeom.getGeomorphs(i); - for(uint j=0;j=numVerts || geoms[j].End>=numVerts) - { - addLog(NLMISC::toString("ERROR: The MrmSkinned File: %s has a bad Geomorph. Lod: %d. Vert: %d. Start/End: %d/%d. Max:%d", - fileName.c_str(), i, j, geoms[j].Start, geoms[j].End, numVerts)); - } - } - } - } -} - -// *************************************************************************** -bool CClient_data_checkApp::processBnpMRM() -{ - // init bnp list? - if(_BnpList.empty()) - { - NLMISC::CPath::getPathContent("./data/", false, false, true, _BnpList); - if(_BnpList.empty()) - { - std::string tam= "Don't find any BNP files for MRM Check"; - _LastDataScanLog+= tam; - nlinfo(tam.c_str()); - } - else - { - // add path into BNP - NLMISC::CPath::addSearchPath("data", true, false); - } - _BnpIndex= 0; - _FileIndex= 0; - } - - // if some BNP to look through - if(_BnpIndex<_BnpList.size()) - { - std::string bnpName= NLMISC::CFile::getFilename(_BnpList[_BnpIndex]); - - // get the list of file in this bnp - if(_CurrentBnpFileList.empty()) - { - // List all files From the bnp - if(NLMISC::CFile::getExtension(bnpName)=="bnp" || NLMISC::CFile::getExtension(bnpName)==".bnp") - NLMISC::CBigFile::getInstance().list(bnpName, _CurrentBnpFileList); - _FileIndex= 0; - } - - // if some file to look throuh - if(_FileIndex<_CurrentBnpFileList.size()) - { - std::string fileName= NLMISC::CFile::getFilename(_CurrentBnpFileList[_FileIndex]); - std::string status= NLMISC::toString("Checking File: BNP(%d/%d) - File(%d/%d)", - _BnpIndex, _BnpList.size(), _FileIndex, _CurrentBnpFileList.size()); - if(NLMISC::CFile::getExtension(fileName)=="shape" || NLMISC::CFile::getExtension(fileName)==".shape") - { - // log - setStatus(status + "\nChecking Mesh File: " + fileName); - - // try to load as mrm - std::string pathName= NLMISC::CPath::lookup(fileName); - NLMISC::CIFile file; - if(!pathName.empty() && file.open(pathName)) - { - NL3D::CShapeStream ss; - ss.serial(file); - NL3D::CMeshMRM *meshMrm= dynamic_cast(ss.getShapePointer()); - NL3D::CMeshMRMSkinned *meshMrmSkinned= dynamic_cast(ss.getShapePointer()); - if(meshMrm) - checkMeshMrm(fileName, meshMrm); - if(meshMrmSkinned) - checkMeshMrmSkinned(fileName, meshMrmSkinned); - } - } - else - { - // log - setStatus(status); - } - // next file in this bnp - _FileIndex++; - } - else - { - // else next one - _BnpIndex++; - _CurrentBnpFileList.clear(); - } - - - return false; - } - // else ended - else - return true; -} - - -// *************************************************************************** -BOOL CClient_data_checkApp::OnIdle(LONG lCount) -{ - // Init - if(_StateProcess==Init) - { - CPatchManager::getInstance()->init(); - CPatchManager::getInstance()->startScanDataThread(); - _StateProcess=CheckSum; - } - - // CheckSum pass? - if(_StateProcess==CheckSum || _StateProcess==CancelCheckSum) - { - CPatchManager *pPM= CPatchManager::getInstance(); - - // update messages - if(_StateProcess==CheckSum) - { - // get state - ucstring state; - std::vector stateLog; - if(pPM->getThreadState(state, stateLog)) - { - setStatus(state.toString()); - } - - // get Log - ucstring dsLog; - if(pPM->getDataScanLog(dsLog)) - { - _LastDataScanLog= dsLog; - setLog(); - } - } - - // if ended - bool res; - if(pPM->isScanDataThreadEnded(res)) - { - // the log may have changed - ucstring dsLog; - if(pPM->getDataScanLog(dsLog)) - { - _LastDataScanLog= dsLog; - setLog(); - } - - // Next - _StateProcess= MRMCheck; - } - } - - // MRM Pass? - if(_StateProcess==MRMCheck ) - { - if(processBnpMRM()) - _StateProcess= NearEnd; - } - - // Quit - if(_StateProcess==NearEnd ) - { - // Report result - if(_LastDataScanLog.empty()) - { - setStatus("Data Scan reported no corrupted Files.\nPress 'Close'"); - nlinfo("Data Scan reported no corrupted Files."); - } - else - { - setStatus("Data Scan reported some corrupted Files.\nPlease send us the file 'data_check.log'.\nPress 'Close'"); - nlinfo(""); - nlinfo(""); - nlinfo("*******************************************"); - nlinfo("*******************************************"); - nlinfo("Data Scan reported some corrupted Files."); - nlinfo("*******************************************"); - nlinfo("*******************************************"); - nlinfo(""); - nlinfo(""); - - // Log - std::string tam= _LastDataScanLog.toString(); - std::vector listStr; - NLMISC::splitString(tam, "\n", listStr); - for(uint i=0;iCancelButton.SetWindowText("Close"); - } - - // End - _StateProcess= End; - } - - return TRUE; - //return CWinApp::OnIdle(lCount); -} - -// *************************************************************************** -void CClient_data_checkApp::cancel() -{ - if(_StateProcess==CheckSum) - { - _StateProcess= CancelCheckSum; - CPatchManager::getInstance()->askForStopScanDataThread(); - - if(_CheckDlg) - { - _CheckDlg->TextStatus= "Canceling Data Scan. Please wait..."; - _CheckDlg->UpdateData(FALSE); - } - } - - if(_StateProcess==MRMCheck) - { - _StateProcess= NearEnd; - } - - if(_StateProcess==End) - { - _CheckDlg->DestroyWindow(); - delete _CheckDlg; - _CheckDlg= NULL; - - // quit - exit(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 . + +// client_data_check.cpp : Defines the class behaviors for the application. +// + +#include "nel/misc/time_nl.h" +#include "nel/misc/ucstring.h" +#include "nel/misc/algo.h" +#include "data_scan.h" +#include "nel/misc/debug.h" +#include "nel/misc/big_file.h" +#include "nel/misc/file.h" +#include "3d/shape.h" +#include "3d/mesh_mrm.h" +#include "3d/mesh_mrm_skinned.h" +#include "3d/register_3d.h" + +#include "stdafx.h" +#include "client_data_check.h" +#include "client_data_checkDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +#pragma optimize("",off) + +///////////////////////////////////////////////////////////////////////////// +// CClient_data_checkApp + +BEGIN_MESSAGE_MAP(CClient_data_checkApp, CWinApp) + //{{AFX_MSG_MAP(CClient_data_checkApp) + // NOTE - the ClassWizard will add and remove mapping macros here. + // DO NOT EDIT what you see in these blocks of generated code! + //}}AFX_MSG + ON_COMMAND(ID_HELP, CWinApp::OnHelp) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CClient_data_checkApp construction + +CClient_data_checkApp::CClient_data_checkApp() +{ + _CheckDlg= NULL; + _StateProcess= Init; + _BnpIndex= 0; + _FileIndex= 0; +} + +///////////////////////////////////////////////////////////////////////////// +// The one and only CClient_data_checkApp object + +CClient_data_checkApp theApp; + +///////////////////////////////////////////////////////////////////////////// +// CClient_data_checkApp initialization + +BOOL CClient_data_checkApp::InitInstance() +{ + AfxEnableControlContainer(); + + // Standard initialization + // If you are not using these features and wish to reduce the size + // of your final executable, you should remove from the following + // the specific initialization routines you do not need. + +#ifdef _AFXDLL + Enable3dControls(); // Call this when using MFC in a shared DLL +#else + Enable3dControlsStatic(); // Call this when linking to MFC statically +#endif + + // init path + NLMISC::CPath::addSearchPath("data"); + NLMISC::CPath::addSearchPath("unpack"); + NL3D::registerSerial3d(); + + // init debug + NLMISC::createDebug(); + NLMISC::CFileDisplayer *DataCheckLogDisplayer= new NLMISC::CFileDisplayer("data_check.log", true, "DATA_CHECK.LOG"); + NLMISC::DebugLog->addDisplayer (DataCheckLogDisplayer); + NLMISC::InfoLog->addDisplayer (DataCheckLogDisplayer); + NLMISC::WarningLog->addDisplayer (DataCheckLogDisplayer); + NLMISC::ErrorLog->addDisplayer (DataCheckLogDisplayer); + NLMISC::AssertLog->addDisplayer (DataCheckLogDisplayer); + + + // init dlg + _CheckDlg= new CClient_data_checkDlg(this); + _CheckDlg->Create(CClient_data_checkDlg::IDD); + m_pMainWnd = _CheckDlg; + + /*int nResponse = dlg.DoModal(); + if (nResponse == IDOK) + { + // TODO: Place code here to handle when the dialog is + // dismissed with OK + } + else if (nResponse == IDCANCEL) + { + // TODO: Place code here to handle when the dialog is + // dismissed with Cancel + }*/ + + return TRUE; +} + +// *************************************************************************** +void CClient_data_checkApp::setLog() +{ + if(_CheckDlg) + { + _CheckDlg->ListBox.ResetContent(); + std::string tam= _LastDataScanLog.toString(); + std::vector listStr; + NLMISC::splitString(tam, "\n", listStr); + for(uint i=0;iListBox.AddString(listStr[i].c_str()); + _CheckDlg->UpdateData(FALSE); + } +} + +// *************************************************************************** +void CClient_data_checkApp::addLog(const std::string &logAdd) +{ + _LastDataScanLog+= std::string("\n") + logAdd; + setLog(); +} + +// *************************************************************************** +void CClient_data_checkApp::setStatus(const std::string &status) +{ + if(_CheckDlg) + { + _CheckDlg->TextStatus= status.c_str(); + _CheckDlg->UpdateData(FALSE); + } +} + + +// *************************************************************************** +void CClient_data_checkApp::checkMeshMrm(const std::string &fileName, NL3D::CMeshMRM *meshMrm) +{ + uint numLod= meshMrm->getNbLod(); + uint numVerts= meshMrm->getMeshGeom().getVertexBuffer().getNumVertices(); + if(numLod==0) + { + addLog(std::string("Warning: The File: ") + fileName + "has 0 Lods"); + } + else + { + const NL3D::CMeshMRMGeom& meshGeom= meshMrm->getMeshGeom(); + // Scan all Geomoprhs + for(uint i=0;i &geoms= meshGeom.getGeomorphs(i); + for(uint j=0;j=numVerts || geoms[j].End>=numVerts) + { + addLog(NLMISC::toString("ERROR: The Mrm File: %s has a bad Geomorph. Lod: %d. Vert: %d. Start/End: %d/%d. Max:%d", + fileName.c_str(), i, j, geoms[j].Start, geoms[j].End, numVerts)); + } + } + } + } +} + +// *************************************************************************** +void CClient_data_checkApp::checkMeshMrmSkinned(const std::string &fileName, NL3D::CMeshMRMSkinned *meshMrm) +{ + uint numLod= meshMrm->getNbLod(); + NL3D::CVertexBuffer vb; + meshMrm->getMeshGeom().getVertexBuffer(vb); + uint numVerts= vb.getNumVertices(); + if(numLod==0) + { + addLog(std::string("Warning: The File: ") + fileName + "has 0 Lods"); + } + else + { + const NL3D::CMeshMRMSkinnedGeom& meshGeom= meshMrm->getMeshGeom(); + // Scan all Geomoprhs + for(uint i=0;i &geoms= meshGeom.getGeomorphs(i); + for(uint j=0;j=numVerts || geoms[j].End>=numVerts) + { + addLog(NLMISC::toString("ERROR: The MrmSkinned File: %s has a bad Geomorph. Lod: %d. Vert: %d. Start/End: %d/%d. Max:%d", + fileName.c_str(), i, j, geoms[j].Start, geoms[j].End, numVerts)); + } + } + } + } +} + +// *************************************************************************** +bool CClient_data_checkApp::processBnpMRM() +{ + // init bnp list? + if(_BnpList.empty()) + { + NLMISC::CPath::getPathContent("./data/", false, false, true, _BnpList); + if(_BnpList.empty()) + { + std::string tam= "Don't find any BNP files for MRM Check"; + _LastDataScanLog+= tam; + nlinfo(tam.c_str()); + } + else + { + // add path into BNP + NLMISC::CPath::addSearchPath("data", true, false); + } + _BnpIndex= 0; + _FileIndex= 0; + } + + // if some BNP to look through + if(_BnpIndex<_BnpList.size()) + { + std::string bnpName= NLMISC::CFile::getFilename(_BnpList[_BnpIndex]); + + // get the list of file in this bnp + if(_CurrentBnpFileList.empty()) + { + // List all files From the bnp + if(NLMISC::CFile::getExtension(bnpName)=="bnp" || NLMISC::CFile::getExtension(bnpName)==".bnp") + NLMISC::CBigFile::getInstance().list(bnpName, _CurrentBnpFileList); + _FileIndex= 0; + } + + // if some file to look throuh + if(_FileIndex<_CurrentBnpFileList.size()) + { + std::string fileName= NLMISC::CFile::getFilename(_CurrentBnpFileList[_FileIndex]); + std::string status= NLMISC::toString("Checking File: BNP(%d/%d) - File(%d/%d)", + _BnpIndex, _BnpList.size(), _FileIndex, _CurrentBnpFileList.size()); + if(NLMISC::CFile::getExtension(fileName)=="shape" || NLMISC::CFile::getExtension(fileName)==".shape") + { + // log + setStatus(status + "\nChecking Mesh File: " + fileName); + + // try to load as mrm + std::string pathName= NLMISC::CPath::lookup(fileName); + NLMISC::CIFile file; + if(!pathName.empty() && file.open(pathName)) + { + NL3D::CShapeStream ss; + ss.serial(file); + NL3D::CMeshMRM *meshMrm= dynamic_cast(ss.getShapePointer()); + NL3D::CMeshMRMSkinned *meshMrmSkinned= dynamic_cast(ss.getShapePointer()); + if(meshMrm) + checkMeshMrm(fileName, meshMrm); + if(meshMrmSkinned) + checkMeshMrmSkinned(fileName, meshMrmSkinned); + } + } + else + { + // log + setStatus(status); + } + // next file in this bnp + _FileIndex++; + } + else + { + // else next one + _BnpIndex++; + _CurrentBnpFileList.clear(); + } + + + return false; + } + // else ended + else + return true; +} + + +// *************************************************************************** +BOOL CClient_data_checkApp::OnIdle(LONG lCount) +{ + // Init + if(_StateProcess==Init) + { + CPatchManager::getInstance()->init(); + CPatchManager::getInstance()->startScanDataThread(); + _StateProcess=CheckSum; + } + + // CheckSum pass? + if(_StateProcess==CheckSum || _StateProcess==CancelCheckSum) + { + CPatchManager *pPM= CPatchManager::getInstance(); + + // update messages + if(_StateProcess==CheckSum) + { + // get state + ucstring state; + std::vector stateLog; + if(pPM->getThreadState(state, stateLog)) + { + setStatus(state.toString()); + } + + // get Log + ucstring dsLog; + if(pPM->getDataScanLog(dsLog)) + { + _LastDataScanLog= dsLog; + setLog(); + } + } + + // if ended + bool res; + if(pPM->isScanDataThreadEnded(res)) + { + // the log may have changed + ucstring dsLog; + if(pPM->getDataScanLog(dsLog)) + { + _LastDataScanLog= dsLog; + setLog(); + } + + // Next + _StateProcess= MRMCheck; + } + } + + // MRM Pass? + if(_StateProcess==MRMCheck ) + { + if(processBnpMRM()) + _StateProcess= NearEnd; + } + + // Quit + if(_StateProcess==NearEnd ) + { + // Report result + if(_LastDataScanLog.empty()) + { + setStatus("Data Scan reported no corrupted Files.\nPress 'Close'"); + nlinfo("Data Scan reported no corrupted Files."); + } + else + { + setStatus("Data Scan reported some corrupted Files.\nPlease send us the file 'data_check.log'.\nPress 'Close'"); + nlinfo(""); + nlinfo(""); + nlinfo("*******************************************"); + nlinfo("*******************************************"); + nlinfo("Data Scan reported some corrupted Files."); + nlinfo("*******************************************"); + nlinfo("*******************************************"); + nlinfo(""); + nlinfo(""); + + // Log + std::string tam= _LastDataScanLog.toString(); + std::vector listStr; + NLMISC::splitString(tam, "\n", listStr); + for(uint i=0;iCancelButton.SetWindowText("Close"); + } + + // End + _StateProcess= End; + } + + return TRUE; + //return CWinApp::OnIdle(lCount); +} + +// *************************************************************************** +void CClient_data_checkApp::cancel() +{ + if(_StateProcess==CheckSum) + { + _StateProcess= CancelCheckSum; + CPatchManager::getInstance()->askForStopScanDataThread(); + + if(_CheckDlg) + { + _CheckDlg->TextStatus= "Canceling Data Scan. Please wait..."; + _CheckDlg->UpdateData(FALSE); + } + } + + if(_StateProcess==MRMCheck) + { + _StateProcess= NearEnd; + } + + if(_StateProcess==End) + { + _CheckDlg->DestroyWindow(); + delete _CheckDlg; + _CheckDlg= NULL; + + // quit + exit(0); + } +} + diff --git a/code/ryzom/tools/client/client_data_check/client_data_check.h b/code/ryzom/tools/client/client_data_check/client_data_check.h index 676d29361..115c9f236 100644 --- a/code/ryzom/tools/client/client_data_check/client_data_check.h +++ b/code/ryzom/tools/client/client_data_check/client_data_check.h @@ -1,107 +1,107 @@ -// 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 . - -// client_data_check.h : main header file for the CLIENT_DATA_CHECK application -// - -#if !defined(AFX_CLIENT_DATA_CHECK_H__3B7BC465_4902_4E07_B8B2_A5240E493164__INCLUDED_) -#define AFX_CLIENT_DATA_CHECK_H__3B7BC465_4902_4E07_B8B2_A5240E493164__INCLUDED_ - -#include "nel/misc/types_nl.h" -#include "nel/misc/ucstring.h" -namespace NL3D -{ - class CMeshMRM; - class CMeshMRMSkinned; -} - -// main symbols - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// CClient_data_checkApp: -// See client_data_check.cpp for the implementation of this class -// - -class CClient_data_checkApp : public CWinApp -{ -public: - CClient_data_checkApp(); - - void cancel(); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CClient_data_checkApp) - public: - virtual BOOL InitInstance(); - virtual BOOL OnIdle(LONG lCount); - //}}AFX_VIRTUAL - -// Implementation - - //{{AFX_MSG(CClient_data_checkApp) - // NOTE - the ClassWizard will add and remove member functions here. - // DO NOT EDIT what you see in these blocks of generated code ! - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - -private: - class CClient_data_checkDlg *_CheckDlg; - enum TState - { - Init= 0, - CheckSum, - CancelCheckSum, - MRMCheck, - NearEnd, - End, - }; - TState _StateProcess; - ucstring _LastDataScanLog; - - // MRM Check - std::vector _BnpList; - std::vector _CurrentBnpFileList; - uint32 _BnpIndex; - uint32 _FileIndex; - - void setLog(); - void addLog(const std::string &logAdd); - void setStatus(const std::string &status); - - bool processBnpMRM(); - - void checkMeshMrm(const std::string &fileName, NL3D::CMeshMRM *meshMrm); - void checkMeshMrmSkinned(const std::string &fileName, NL3D::CMeshMRMSkinned *meshMrmSkinned); -}; - - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_CLIENT_DATA_CHECK_H__3B7BC465_4902_4E07_B8B2_A5240E493164__INCLUDED_) +// 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 . + +// client_data_check.h : main header file for the CLIENT_DATA_CHECK application +// + +#if !defined(AFX_CLIENT_DATA_CHECK_H__3B7BC465_4902_4E07_B8B2_A5240E493164__INCLUDED_) +#define AFX_CLIENT_DATA_CHECK_H__3B7BC465_4902_4E07_B8B2_A5240E493164__INCLUDED_ + +#include "nel/misc/types_nl.h" +#include "nel/misc/ucstring.h" +namespace NL3D +{ + class CMeshMRM; + class CMeshMRMSkinned; +} + +// main symbols + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#ifndef __AFXWIN_H__ + #error include 'stdafx.h' before including this file for PCH +#endif + +#include "resource.h" // main symbols + +///////////////////////////////////////////////////////////////////////////// +// CClient_data_checkApp: +// See client_data_check.cpp for the implementation of this class +// + +class CClient_data_checkApp : public CWinApp +{ +public: + CClient_data_checkApp(); + + void cancel(); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CClient_data_checkApp) + public: + virtual BOOL InitInstance(); + virtual BOOL OnIdle(LONG lCount); + //}}AFX_VIRTUAL + +// Implementation + + //{{AFX_MSG(CClient_data_checkApp) + // NOTE - the ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + +private: + class CClient_data_checkDlg *_CheckDlg; + enum TState + { + Init= 0, + CheckSum, + CancelCheckSum, + MRMCheck, + NearEnd, + End, + }; + TState _StateProcess; + ucstring _LastDataScanLog; + + // MRM Check + std::vector _BnpList; + std::vector _CurrentBnpFileList; + uint32 _BnpIndex; + uint32 _FileIndex; + + void setLog(); + void addLog(const std::string &logAdd); + void setStatus(const std::string &status); + + bool processBnpMRM(); + + void checkMeshMrm(const std::string &fileName, NL3D::CMeshMRM *meshMrm); + void checkMeshMrmSkinned(const std::string &fileName, NL3D::CMeshMRMSkinned *meshMrmSkinned); +}; + + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_CLIENT_DATA_CHECK_H__3B7BC465_4902_4E07_B8B2_A5240E493164__INCLUDED_) diff --git a/code/ryzom/tools/client/client_data_check/client_data_checkDlg.cpp b/code/ryzom/tools/client/client_data_check/client_data_checkDlg.cpp index e385ab7be..e05be2d3d 100644 --- a/code/ryzom/tools/client/client_data_check/client_data_checkDlg.cpp +++ b/code/ryzom/tools/client/client_data_check/client_data_checkDlg.cpp @@ -1,118 +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 . - -// client_data_checkDlg.cpp : implementation file -// - -#include "stdafx.h" -#include "client_data_check.h" -#include "client_data_checkDlg.h" -#include "client_data_checkDlg.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CClient_data_checkDlg dialog - -CClient_data_checkDlg::CClient_data_checkDlg(class CClient_data_checkApp *appParent, CWnd* pParent /*=NULL*/) - : _AppParent(appParent), CDialog(CClient_data_checkDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CClient_data_checkDlg) - TextStatus = _T(""); - //}}AFX_DATA_INIT - // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 - m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); -} - -void CClient_data_checkDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CClient_data_checkDlg) - DDX_Control(pDX, IDC_BUTTON_CANCEL, CancelButton); - DDX_Control(pDX, IDC_LIST_LOG, ListBox); - DDX_Text(pDX, IDC_STATIC_STATUS, TextStatus); - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CClient_data_checkDlg, CDialog) - //{{AFX_MSG_MAP(CClient_data_checkDlg) - ON_WM_PAINT() - ON_WM_QUERYDRAGICON() - ON_BN_CLICKED(IDC_BUTTON_CANCEL, OnButtonCancel) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CClient_data_checkDlg message handlers - -BOOL CClient_data_checkDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - // Set the icon for this dialog. The framework does this automatically - // when the application's main window is not a dialog - SetIcon(m_hIcon, TRUE); // Set big icon - SetIcon(m_hIcon, FALSE); // Set small icon - - - return TRUE; // return TRUE unless you set the focus to a control -} - -// If you add a minimize button to your dialog, you will need the code below -// to draw the icon. For MFC applications using the document/view model, -// this is automatically done for you by the framework. - -void CClient_data_checkDlg::OnPaint() -{ - if (IsIconic()) - { - CPaintDC dc(this); // device context for painting - - SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); - - // Center icon in client rectangle - int cxIcon = GetSystemMetrics(SM_CXICON); - int cyIcon = GetSystemMetrics(SM_CYICON); - CRect rect; - GetClientRect(&rect); - int x = (rect.Width() - cxIcon + 1) / 2; - int y = (rect.Height() - cyIcon + 1) / 2; - - // Draw the icon - dc.DrawIcon(x, y, m_hIcon); - } - else - { - CDialog::OnPaint(); - } -} - -// The system calls this to obtain the cursor to display while the user drags -// the minimized window. -HCURSOR CClient_data_checkDlg::OnQueryDragIcon() -{ - return (HCURSOR) m_hIcon; -} - -void CClient_data_checkDlg::OnButtonCancel() -{ - if(_AppParent) - _AppParent->cancel(); -} +// 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 . + +// client_data_checkDlg.cpp : implementation file +// + +#include "stdafx.h" +#include "client_data_check.h" +#include "client_data_checkDlg.h" +#include "client_data_checkDlg.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CClient_data_checkDlg dialog + +CClient_data_checkDlg::CClient_data_checkDlg(class CClient_data_checkApp *appParent, CWnd* pParent /*=NULL*/) + : _AppParent(appParent), CDialog(CClient_data_checkDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(CClient_data_checkDlg) + TextStatus = _T(""); + //}}AFX_DATA_INIT + // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 + m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); +} + +void CClient_data_checkDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CClient_data_checkDlg) + DDX_Control(pDX, IDC_BUTTON_CANCEL, CancelButton); + DDX_Control(pDX, IDC_LIST_LOG, ListBox); + DDX_Text(pDX, IDC_STATIC_STATUS, TextStatus); + //}}AFX_DATA_MAP +} + +BEGIN_MESSAGE_MAP(CClient_data_checkDlg, CDialog) + //{{AFX_MSG_MAP(CClient_data_checkDlg) + ON_WM_PAINT() + ON_WM_QUERYDRAGICON() + ON_BN_CLICKED(IDC_BUTTON_CANCEL, OnButtonCancel) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CClient_data_checkDlg message handlers + +BOOL CClient_data_checkDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // Set the icon for this dialog. The framework does this automatically + // when the application's main window is not a dialog + SetIcon(m_hIcon, TRUE); // Set big icon + SetIcon(m_hIcon, FALSE); // Set small icon + + + return TRUE; // return TRUE unless you set the focus to a control +} + +// If you add a minimize button to your dialog, you will need the code below +// to draw the icon. For MFC applications using the document/view model, +// this is automatically done for you by the framework. + +void CClient_data_checkDlg::OnPaint() +{ + if (IsIconic()) + { + CPaintDC dc(this); // device context for painting + + SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); + + // Center icon in client rectangle + int cxIcon = GetSystemMetrics(SM_CXICON); + int cyIcon = GetSystemMetrics(SM_CYICON); + CRect rect; + GetClientRect(&rect); + int x = (rect.Width() - cxIcon + 1) / 2; + int y = (rect.Height() - cyIcon + 1) / 2; + + // Draw the icon + dc.DrawIcon(x, y, m_hIcon); + } + else + { + CDialog::OnPaint(); + } +} + +// The system calls this to obtain the cursor to display while the user drags +// the minimized window. +HCURSOR CClient_data_checkDlg::OnQueryDragIcon() +{ + return (HCURSOR) m_hIcon; +} + +void CClient_data_checkDlg::OnButtonCancel() +{ + if(_AppParent) + _AppParent->cancel(); +} diff --git a/code/ryzom/tools/client/client_data_check/client_data_checkDlg.h b/code/ryzom/tools/client/client_data_check/client_data_checkDlg.h index 0bd74dcfe..78ef57130 100644 --- a/code/ryzom/tools/client/client_data_check/client_data_checkDlg.h +++ b/code/ryzom/tools/client/client_data_check/client_data_checkDlg.h @@ -1,69 +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 . - -// client_data_checkDlg.h : header file -// - -#if !defined(AFX_CLIENT_DATA_CHECKDLG_H__7790303F_B248_4E03_A038_DBF0A911836C__INCLUDED_) -#define AFX_CLIENT_DATA_CHECKDLG_H__7790303F_B248_4E03_A038_DBF0A911836C__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -///////////////////////////////////////////////////////////////////////////// -// CClient_data_checkDlg dialog - -class CClient_data_checkDlg : public CDialog -{ -// Construction -public: - CClient_data_checkDlg(class CClient_data_checkApp *appParent, CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CClient_data_checkDlg) - enum { IDD = IDD_CLIENT_DATA_CHECK_DIALOG }; - CButton CancelButton; - CListBox ListBox; - CString TextStatus; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CClient_data_checkDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - HICON m_hIcon; - - // Generated message map functions - //{{AFX_MSG(CClient_data_checkDlg) - virtual BOOL OnInitDialog(); - afx_msg void OnPaint(); - afx_msg HCURSOR OnQueryDragIcon(); - afx_msg void OnButtonCancel(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - - class CClient_data_checkApp *_AppParent; -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_CLIENT_DATA_CHECKDLG_H__7790303F_B248_4E03_A038_DBF0A911836C__INCLUDED_) +// 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 . + +// client_data_checkDlg.h : header file +// + +#if !defined(AFX_CLIENT_DATA_CHECKDLG_H__7790303F_B248_4E03_A038_DBF0A911836C__INCLUDED_) +#define AFX_CLIENT_DATA_CHECKDLG_H__7790303F_B248_4E03_A038_DBF0A911836C__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +///////////////////////////////////////////////////////////////////////////// +// CClient_data_checkDlg dialog + +class CClient_data_checkDlg : public CDialog +{ +// Construction +public: + CClient_data_checkDlg(class CClient_data_checkApp *appParent, CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CClient_data_checkDlg) + enum { IDD = IDD_CLIENT_DATA_CHECK_DIALOG }; + CButton CancelButton; + CListBox ListBox; + CString TextStatus; + //}}AFX_DATA + + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CClient_data_checkDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + HICON m_hIcon; + + // Generated message map functions + //{{AFX_MSG(CClient_data_checkDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnPaint(); + afx_msg HCURSOR OnQueryDragIcon(); + afx_msg void OnButtonCancel(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + + class CClient_data_checkApp *_AppParent; +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_CLIENT_DATA_CHECKDLG_H__7790303F_B248_4E03_A038_DBF0A911836C__INCLUDED_) diff --git a/code/ryzom/tools/client/client_data_check/data_scan.cpp b/code/ryzom/tools/client/client_data_check/data_scan.cpp index 5240112a8..7031aaa92 100644 --- a/code/ryzom/tools/client/client_data_check/data_scan.cpp +++ b/code/ryzom/tools/client/client_data_check/data_scan.cpp @@ -1,537 +1,537 @@ -// 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 . - -// -// Includes -// - -#include "nel/misc/debug.h" -#include "nel/misc/path.h" -#include "nel/misc/thread.h" -#include "nel/misc/sha1.h" -#include "nel/misc/big_file.h" -#include "nel/misc/i18n.h" - -#include "data_scan.h" - - -// -// Namespaces -// - -using namespace std; -using namespace NLMISC; - - -// *************************************************************************** -static ucstring dummyI18N(const std::string &s) -{ - return s; -} - - -// **************************************************************************** -// **************************************************************************** -// **************************************************************************** -// CPatchManager -// **************************************************************************** -// **************************************************************************** -// **************************************************************************** - -struct EPatchDownloadException : public Exception -{ - EPatchDownloadException() : Exception( "Download Error" ) {} - EPatchDownloadException( const std::string& str ) : Exception( str ) {} - virtual ~EPatchDownloadException() throw() {} -}; - -CPatchManager *CPatchManager::_Instance = NULL; - -// **************************************************************************** -CPatchManager::CPatchManager() : State("t_state"), DataScanState("t_data_scan_state") -{ - DescFilename = "ryzom_xxxxx.idx"; - - ClientPatchPath = "./unpack/"; - ClientDataPath = "./data/"; - - - VerboseLog = true; - - ScanDataThread = NULL; - thread = NULL; - - ValidDescFile = false; -} - -// **************************************************************************** -void CPatchManager::init() -{ - // retrieve the current client version, according to .idx - readClientVersionAndDescFile(); -} - -// *************************************************************************** -void CPatchManager::readClientVersionAndDescFile() -{ - try - { - ValidDescFile = false; - vector vFiles; - CPath::getPathContent(ClientPatchPath, false, false, true, vFiles); - uint32 nVersion = 0xFFFFFFFF; - for (uint32 i = 0; i < vFiles.size(); ++i) - { - string sName = CFile::getFilename(vFiles[i]); - string sExt = CFile::getExtension(sName); - string sBase = sName.substr(0, sName.rfind('_')); - if ((sExt == "idx") && (sBase == "ryzom")) - { - string val = sName.substr(sName.rfind('_')+1, 5); - uint32 nNewVersion = atoi(val.c_str()); - if ((nNewVersion > nVersion) || (nVersion == 0xFFFFFFFF)) - nVersion = nNewVersion; - } - } - if (nVersion != 0xFFFFFFFF) - readDescFile(nVersion); - else - DescFilename = "unknown"; - ValidDescFile = true; - } - catch(Exception &) - { - // Not important that there is no desc file - } -} - -// **************************************************************************** -// Called in main thread -bool CPatchManager::getThreadState (ucstring &stateOut, vector &stateLogOut) -{ - if (ScanDataThread==NULL) - return false; - - // clear output - stateOut.clear(); - stateLogOut.clear(); - - // Get access to the state - bool changed= false; - { - CSynchronized::CAccessor as(&State); - CState &rState= as.value(); - if (rState.StateChanged) - { - // and retrieve info - changed= true; - stateOut = rState.State; - stateLogOut = rState.StateLog; - // clear state - rState.StateLog.clear(); - rState.StateChanged= false; - } - } - - // verbose log - if (isVerboseLog() && !stateLogOut.empty()) - for (uint32 i = 0; i < stateLogOut.size(); ++i) - nlinfo("%s", stateLogOut[i].toString().c_str()); - - return changed; -} - -// **************************************************************************** -int CPatchManager::getTotalFilesToGet() -{ - if (ScanDataThread != NULL) - return ScanDataThread->TotalFileToScan; - - return 1; -} - -// **************************************************************************** -int CPatchManager::getCurrentFilesToGet() -{ - if (ScanDataThread != NULL) - return ScanDataThread->CurrentFileScanned; - - return 1; -} - -// **************************************************************************** -// Take care this function is called by the thread -void CPatchManager::setState (bool bOutputToLog, const ucstring &ucsNewState) -{ - { - CSynchronized::CAccessor as(&State); - CState &rState= as.value(); - rState.State= ucsNewState; - if(bOutputToLog) - rState.StateLog.push_back(ucsNewState); - rState.StateChanged= true; - } -} - -// **************************************************************************** -string CPatchManager::getClientVersion() -{ - if (!ValidDescFile) - return ""; - - return toString("%05d", DescFile.getFiles().getVersionNumber()); -} - -// **************************************************************************** -void CPatchManager::readDescFile(sint32 nVersion) -{ - DescFilename = toString("ryzom_%05d.idx", nVersion); - string srcName = ClientPatchPath + DescFilename; - DescFile.clear(); - if (!DescFile.load(srcName)) - throw Exception ("Can't open file '%s'", srcName.c_str ()); -} - -// **************************************************************************** -// Get all the patches that need to be applied to a file from the description of this file given by the server -void CPatchManager::getPatchFromDesc(SFileToPatch &ftpOut, const CBNPFile &fIn, bool forceCheckSumTest) -{ - uint32 j; - const CBNPFile rFile = fIn; - const string &rFilename = rFile.getFileName(); - // Does the BNP exists ? - string sFilePath = CPath::lookup(rFilename); - if (sFilePath.empty()) - { - if (NLMISC::CFile::fileExists(ClientPatchPath + rFilename)) - sFilePath = ClientPatchPath + rFilename; - } - - // if file not found anywhere - if (sFilePath.empty()) - { - ftpOut.FileName = rFilename; - ftpOut.LocalFileToDelete = false; - ftpOut.LocalFileExists = false; - // It happens some time (maybe a bug) that the versionCount is 0... => - // it happens if the BNP file is empty (8 bytes) - ftpOut.FinalFileSize = EmptyBnpFileSize; - // BNP does not exists : get all the patches version - for (j = 0; j < rFile.versionCount(); ++j) - { - ftpOut.Patches.push_back(rFile.getVersion(j).getVersionNumber()); - ftpOut.PatcheSizes.push_back(rFile.getVersion(j).getPatchSize()); - ftpOut.LastFileDate = rFile.getVersion(j).getTimeStamp(); - ftpOut.FinalFileSize = rFile.getVersion(j).getFileSize(); - } - } - else - { - // The local BNP file exists : find its version - uint32 nLocalSize = CFile::getFileSize(sFilePath); - uint32 nLocalTime = CFile::getFileModificationDate(sFilePath); - // From the couple time, size look the version of the file - uint32 nVersionFound = 0xFFFFFFFF; - // If forceChecksum is wanted (slow), then don't do the test with filesize/date - if(!forceCheckSumTest) - { - for (j = 0; j < rFile.versionCount(); ++j) - { - const CBNPFileVersion &rVersion = rFile.getVersion(j); - uint32 nServerSize = rVersion.getFileSize(); - uint32 nServerTime = rVersion.getTimeStamp(); - // Does the time and size match a version ? - if ((nServerSize == nLocalSize) && (abs((sint32)(nServerTime - nLocalTime)) <= 2) ) - { - nVersionFound = rVersion.getVersionNumber(); - // break; // ace -> get the last good version (if more than one version of the same file exists) - } - } - } - - // If the version cannot be found with size and time try with sha1 - if (nVersionFound == 0xFFFFFFFF) - { - ucstring sTranslate = dummyI18N("Checking Integrity :") + " " + rFilename; - setState(true, sTranslate); - CHashKey hkLocalSHA1 = getSHA1(sFilePath); - for (j = 0; j < rFile.versionCount(); ++j) - { - const CBNPFileVersion &rVersion = rFile.getVersion(j); - CHashKey hkServerSHA1 = rVersion.getHashKey(); - // Does the sha1 match a version ? - if (hkServerSHA1 == hkLocalSHA1) - { - nVersionFound = rVersion.getVersionNumber(); - // break; // ace -> same as above - } - } - } - - // No version available found - if (nVersionFound == 0xFFFFFFFF) - { - ucstring sTranslate = dummyI18N("No Version Found"); - setState(true, sTranslate); - // Get all patches from beginning (first patch is reference file) - ftpOut.FileName = rFilename; - ftpOut.LocalFileToDelete = true; - ftpOut.LocalFileExists = true; - // It happens some time (maybe a bug) that the versionCount is 0... => - // it happens if the BNP file is empty (8 bytes) - ftpOut.FinalFileSize = EmptyBnpFileSize; - // Get all the patches version - for (j = 0; j < rFile.versionCount(); ++j) - { - ftpOut.Patches.push_back(rFile.getVersion(j).getVersionNumber()); - ftpOut.PatcheSizes.push_back(rFile.getVersion(j).getPatchSize()); - ftpOut.LastFileDate = rFile.getVersion(j).getTimeStamp(); - ftpOut.FinalFileSize = rFile.getVersion(j).getFileSize(); - } - } - else // A version of the file has been found - { - ucstring sTranslate = dummyI18N("Version Found :") + " " + toString(nVersionFound); - setState(true, sTranslate); - // Get All patches from this version ! - ftpOut.FileName = rFilename; - ftpOut.LocalFileToDelete = false; - ftpOut.LocalFileExists = true; - // Go to the version - for (j = 0; j < rFile.versionCount(); ++j) - if (rFile.getVersion(j).getVersionNumber() == nVersionFound) - break; - - nlassert(j != rFile.versionCount()); // Not normal if we cant find the version we found previously - - // Point on the next version - j++; - // If there are newer versions - if (j != rFile.versionCount()) - { - // Add all version until the last one - for (; j < rFile.versionCount(); ++j) - { - ftpOut.Patches.push_back(rFile.getVersion(j).getVersionNumber()); - ftpOut.PatcheSizes.push_back(rFile.getVersion(j).getPatchSize()); - ftpOut.LastFileDate = rFile.getVersion(j).getTimeStamp(); - } - } - // Else this file is up to date ! - - // For info, get its final file size - ftpOut.FinalFileSize= rFile.getVersion(rFile.versionCount()-1).getFileSize(); - } - } // end of else local BNP file exists -} - - -// *************************************************************************** -void CPatchManager::startScanDataThread() -{ - if (ScanDataThread != NULL) - { - nlwarning ("scan data thread is already running"); - return; - } - if (thread != NULL) - { - nlwarning ("a thread is already running"); - return; - } - - // Reset result - clearDataScanLog(); - - // Read now the client version and Desc File. - readClientVersionAndDescFile(); - - // start thread - ScanDataThread = new CScanDataThread(); - nlassert (ScanDataThread != NULL); - - thread = IThread::create (ScanDataThread); - nlassert (thread != NULL); - thread->start (); -} - -// **************************************************************************** -bool CPatchManager::isScanDataThreadEnded(bool &ok) -{ - if (ScanDataThread == NULL) - { - ok = false; - return true; - } - - bool end = ScanDataThread->Ended; - if (end) - { - ok = ScanDataThread->CheckOk; - stopScanDataThread(); - } - - return end; -} - -// **************************************************************************** -void CPatchManager::stopScanDataThread() -{ - if(ScanDataThread && thread) - { - thread->wait(); - delete thread; - thread = NULL; - delete ScanDataThread; - ScanDataThread = NULL; - } -} - -// *************************************************************************** -void CPatchManager::askForStopScanDataThread() -{ - if(!ScanDataThread) - return; - - ScanDataThread->AskForCancel= true; -} - -// *************************************************************************** -bool CPatchManager::getDataScanLog(ucstring &text) -{ - text.clear(); - bool changed= false; - { - TSyncDataScanState::CAccessor ac(&DataScanState); - CDataScanState &val= ac.value(); - changed= val.Changed; - // if changed, build the log - if(changed) - { - for(uint i=0;igetClientVersion(); - ucstring sTranslate = dummyI18N("Client Version") + " (" + sClientVersion + ") "; - pPM->setState(true, sTranslate); - - // For all bnp in the description file get all patches to apply - // depending on the version of the client bnp files - const CBNPFileSet &rDescFiles = pPM->DescFile.getFiles(); - TotalFileToScan = rDescFiles.fileCount(); - for (i = 0; i < rDescFiles.fileCount(); ++i) - { - sTranslate = dummyI18N("Checking File") + " " + rDescFiles.getFile(i).getFileName(); - pPM->setState(true, sTranslate); - - // get list of file to apply to this patch, performing a full checksum test (slow...) - CPatchManager::SFileToPatch ftp; - pPM->getPatchFromDesc(ftp, rDescFiles.getFile(i), true); - // if the file has been found but don't correspond to any local version (SHA1) - if (ftp.LocalFileExists && ftp.LocalFileToDelete) - { - pPM->addDataScanLogCorruptedFile(ftp); - CPatchManager::getCorruptedFileInfo(ftp, sTranslate); - pPM->setState(true, sTranslate); - } - CurrentFileScanned = i; - - // if the user ask to cancel the thread, stop now - if(AskForCancel) - break; - } - - sTranslate = dummyI18N("Checking file ended with no error"); - pPM->setState(true, sTranslate); - CheckOk = true; - Ended = true; - } - catch (Exception &e) - { - ucstring sTranslate = dummyI18N("Checking file ended with errors :") + " " + e.what(); - pPM->setState(true, sTranslate); - CheckOk = false; - Ended = true; - } -} - +// 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 . + +// +// Includes +// + +#include "nel/misc/debug.h" +#include "nel/misc/path.h" +#include "nel/misc/thread.h" +#include "nel/misc/sha1.h" +#include "nel/misc/big_file.h" +#include "nel/misc/i18n.h" + +#include "data_scan.h" + + +// +// Namespaces +// + +using namespace std; +using namespace NLMISC; + + +// *************************************************************************** +static ucstring dummyI18N(const std::string &s) +{ + return s; +} + + +// **************************************************************************** +// **************************************************************************** +// **************************************************************************** +// CPatchManager +// **************************************************************************** +// **************************************************************************** +// **************************************************************************** + +struct EPatchDownloadException : public Exception +{ + EPatchDownloadException() : Exception( "Download Error" ) {} + EPatchDownloadException( const std::string& str ) : Exception( str ) {} + virtual ~EPatchDownloadException() throw() {} +}; + +CPatchManager *CPatchManager::_Instance = NULL; + +// **************************************************************************** +CPatchManager::CPatchManager() : State("t_state"), DataScanState("t_data_scan_state") +{ + DescFilename = "ryzom_xxxxx.idx"; + + ClientPatchPath = "./unpack/"; + ClientDataPath = "./data/"; + + + VerboseLog = true; + + ScanDataThread = NULL; + thread = NULL; + + ValidDescFile = false; +} + +// **************************************************************************** +void CPatchManager::init() +{ + // retrieve the current client version, according to .idx + readClientVersionAndDescFile(); +} + +// *************************************************************************** +void CPatchManager::readClientVersionAndDescFile() +{ + try + { + ValidDescFile = false; + vector vFiles; + CPath::getPathContent(ClientPatchPath, false, false, true, vFiles); + uint32 nVersion = 0xFFFFFFFF; + for (uint32 i = 0; i < vFiles.size(); ++i) + { + string sName = CFile::getFilename(vFiles[i]); + string sExt = CFile::getExtension(sName); + string sBase = sName.substr(0, sName.rfind('_')); + if ((sExt == "idx") && (sBase == "ryzom")) + { + string val = sName.substr(sName.rfind('_')+1, 5); + uint32 nNewVersion = atoi(val.c_str()); + if ((nNewVersion > nVersion) || (nVersion == 0xFFFFFFFF)) + nVersion = nNewVersion; + } + } + if (nVersion != 0xFFFFFFFF) + readDescFile(nVersion); + else + DescFilename = "unknown"; + ValidDescFile = true; + } + catch(Exception &) + { + // Not important that there is no desc file + } +} + +// **************************************************************************** +// Called in main thread +bool CPatchManager::getThreadState (ucstring &stateOut, vector &stateLogOut) +{ + if (ScanDataThread==NULL) + return false; + + // clear output + stateOut.clear(); + stateLogOut.clear(); + + // Get access to the state + bool changed= false; + { + CSynchronized::CAccessor as(&State); + CState &rState= as.value(); + if (rState.StateChanged) + { + // and retrieve info + changed= true; + stateOut = rState.State; + stateLogOut = rState.StateLog; + // clear state + rState.StateLog.clear(); + rState.StateChanged= false; + } + } + + // verbose log + if (isVerboseLog() && !stateLogOut.empty()) + for (uint32 i = 0; i < stateLogOut.size(); ++i) + nlinfo("%s", stateLogOut[i].toString().c_str()); + + return changed; +} + +// **************************************************************************** +int CPatchManager::getTotalFilesToGet() +{ + if (ScanDataThread != NULL) + return ScanDataThread->TotalFileToScan; + + return 1; +} + +// **************************************************************************** +int CPatchManager::getCurrentFilesToGet() +{ + if (ScanDataThread != NULL) + return ScanDataThread->CurrentFileScanned; + + return 1; +} + +// **************************************************************************** +// Take care this function is called by the thread +void CPatchManager::setState (bool bOutputToLog, const ucstring &ucsNewState) +{ + { + CSynchronized::CAccessor as(&State); + CState &rState= as.value(); + rState.State= ucsNewState; + if(bOutputToLog) + rState.StateLog.push_back(ucsNewState); + rState.StateChanged= true; + } +} + +// **************************************************************************** +string CPatchManager::getClientVersion() +{ + if (!ValidDescFile) + return ""; + + return toString("%05d", DescFile.getFiles().getVersionNumber()); +} + +// **************************************************************************** +void CPatchManager::readDescFile(sint32 nVersion) +{ + DescFilename = toString("ryzom_%05d.idx", nVersion); + string srcName = ClientPatchPath + DescFilename; + DescFile.clear(); + if (!DescFile.load(srcName)) + throw Exception ("Can't open file '%s'", srcName.c_str ()); +} + +// **************************************************************************** +// Get all the patches that need to be applied to a file from the description of this file given by the server +void CPatchManager::getPatchFromDesc(SFileToPatch &ftpOut, const CBNPFile &fIn, bool forceCheckSumTest) +{ + uint32 j; + const CBNPFile rFile = fIn; + const string &rFilename = rFile.getFileName(); + // Does the BNP exists ? + string sFilePath = CPath::lookup(rFilename); + if (sFilePath.empty()) + { + if (NLMISC::CFile::fileExists(ClientPatchPath + rFilename)) + sFilePath = ClientPatchPath + rFilename; + } + + // if file not found anywhere + if (sFilePath.empty()) + { + ftpOut.FileName = rFilename; + ftpOut.LocalFileToDelete = false; + ftpOut.LocalFileExists = false; + // It happens some time (maybe a bug) that the versionCount is 0... => + // it happens if the BNP file is empty (8 bytes) + ftpOut.FinalFileSize = EmptyBnpFileSize; + // BNP does not exists : get all the patches version + for (j = 0; j < rFile.versionCount(); ++j) + { + ftpOut.Patches.push_back(rFile.getVersion(j).getVersionNumber()); + ftpOut.PatcheSizes.push_back(rFile.getVersion(j).getPatchSize()); + ftpOut.LastFileDate = rFile.getVersion(j).getTimeStamp(); + ftpOut.FinalFileSize = rFile.getVersion(j).getFileSize(); + } + } + else + { + // The local BNP file exists : find its version + uint32 nLocalSize = CFile::getFileSize(sFilePath); + uint32 nLocalTime = CFile::getFileModificationDate(sFilePath); + // From the couple time, size look the version of the file + uint32 nVersionFound = 0xFFFFFFFF; + // If forceChecksum is wanted (slow), then don't do the test with filesize/date + if(!forceCheckSumTest) + { + for (j = 0; j < rFile.versionCount(); ++j) + { + const CBNPFileVersion &rVersion = rFile.getVersion(j); + uint32 nServerSize = rVersion.getFileSize(); + uint32 nServerTime = rVersion.getTimeStamp(); + // Does the time and size match a version ? + if ((nServerSize == nLocalSize) && (abs((sint32)(nServerTime - nLocalTime)) <= 2) ) + { + nVersionFound = rVersion.getVersionNumber(); + // break; // ace -> get the last good version (if more than one version of the same file exists) + } + } + } + + // If the version cannot be found with size and time try with sha1 + if (nVersionFound == 0xFFFFFFFF) + { + ucstring sTranslate = dummyI18N("Checking Integrity :") + " " + rFilename; + setState(true, sTranslate); + CHashKey hkLocalSHA1 = getSHA1(sFilePath); + for (j = 0; j < rFile.versionCount(); ++j) + { + const CBNPFileVersion &rVersion = rFile.getVersion(j); + CHashKey hkServerSHA1 = rVersion.getHashKey(); + // Does the sha1 match a version ? + if (hkServerSHA1 == hkLocalSHA1) + { + nVersionFound = rVersion.getVersionNumber(); + // break; // ace -> same as above + } + } + } + + // No version available found + if (nVersionFound == 0xFFFFFFFF) + { + ucstring sTranslate = dummyI18N("No Version Found"); + setState(true, sTranslate); + // Get all patches from beginning (first patch is reference file) + ftpOut.FileName = rFilename; + ftpOut.LocalFileToDelete = true; + ftpOut.LocalFileExists = true; + // It happens some time (maybe a bug) that the versionCount is 0... => + // it happens if the BNP file is empty (8 bytes) + ftpOut.FinalFileSize = EmptyBnpFileSize; + // Get all the patches version + for (j = 0; j < rFile.versionCount(); ++j) + { + ftpOut.Patches.push_back(rFile.getVersion(j).getVersionNumber()); + ftpOut.PatcheSizes.push_back(rFile.getVersion(j).getPatchSize()); + ftpOut.LastFileDate = rFile.getVersion(j).getTimeStamp(); + ftpOut.FinalFileSize = rFile.getVersion(j).getFileSize(); + } + } + else // A version of the file has been found + { + ucstring sTranslate = dummyI18N("Version Found :") + " " + toString(nVersionFound); + setState(true, sTranslate); + // Get All patches from this version ! + ftpOut.FileName = rFilename; + ftpOut.LocalFileToDelete = false; + ftpOut.LocalFileExists = true; + // Go to the version + for (j = 0; j < rFile.versionCount(); ++j) + if (rFile.getVersion(j).getVersionNumber() == nVersionFound) + break; + + nlassert(j != rFile.versionCount()); // Not normal if we cant find the version we found previously + + // Point on the next version + j++; + // If there are newer versions + if (j != rFile.versionCount()) + { + // Add all version until the last one + for (; j < rFile.versionCount(); ++j) + { + ftpOut.Patches.push_back(rFile.getVersion(j).getVersionNumber()); + ftpOut.PatcheSizes.push_back(rFile.getVersion(j).getPatchSize()); + ftpOut.LastFileDate = rFile.getVersion(j).getTimeStamp(); + } + } + // Else this file is up to date ! + + // For info, get its final file size + ftpOut.FinalFileSize= rFile.getVersion(rFile.versionCount()-1).getFileSize(); + } + } // end of else local BNP file exists +} + + +// *************************************************************************** +void CPatchManager::startScanDataThread() +{ + if (ScanDataThread != NULL) + { + nlwarning ("scan data thread is already running"); + return; + } + if (thread != NULL) + { + nlwarning ("a thread is already running"); + return; + } + + // Reset result + clearDataScanLog(); + + // Read now the client version and Desc File. + readClientVersionAndDescFile(); + + // start thread + ScanDataThread = new CScanDataThread(); + nlassert (ScanDataThread != NULL); + + thread = IThread::create (ScanDataThread); + nlassert (thread != NULL); + thread->start (); +} + +// **************************************************************************** +bool CPatchManager::isScanDataThreadEnded(bool &ok) +{ + if (ScanDataThread == NULL) + { + ok = false; + return true; + } + + bool end = ScanDataThread->Ended; + if (end) + { + ok = ScanDataThread->CheckOk; + stopScanDataThread(); + } + + return end; +} + +// **************************************************************************** +void CPatchManager::stopScanDataThread() +{ + if(ScanDataThread && thread) + { + thread->wait(); + delete thread; + thread = NULL; + delete ScanDataThread; + ScanDataThread = NULL; + } +} + +// *************************************************************************** +void CPatchManager::askForStopScanDataThread() +{ + if(!ScanDataThread) + return; + + ScanDataThread->AskForCancel= true; +} + +// *************************************************************************** +bool CPatchManager::getDataScanLog(ucstring &text) +{ + text.clear(); + bool changed= false; + { + TSyncDataScanState::CAccessor ac(&DataScanState); + CDataScanState &val= ac.value(); + changed= val.Changed; + // if changed, build the log + if(changed) + { + for(uint i=0;igetClientVersion(); + ucstring sTranslate = dummyI18N("Client Version") + " (" + sClientVersion + ") "; + pPM->setState(true, sTranslate); + + // For all bnp in the description file get all patches to apply + // depending on the version of the client bnp files + const CBNPFileSet &rDescFiles = pPM->DescFile.getFiles(); + TotalFileToScan = rDescFiles.fileCount(); + for (i = 0; i < rDescFiles.fileCount(); ++i) + { + sTranslate = dummyI18N("Checking File") + " " + rDescFiles.getFile(i).getFileName(); + pPM->setState(true, sTranslate); + + // get list of file to apply to this patch, performing a full checksum test (slow...) + CPatchManager::SFileToPatch ftp; + pPM->getPatchFromDesc(ftp, rDescFiles.getFile(i), true); + // if the file has been found but don't correspond to any local version (SHA1) + if (ftp.LocalFileExists && ftp.LocalFileToDelete) + { + pPM->addDataScanLogCorruptedFile(ftp); + CPatchManager::getCorruptedFileInfo(ftp, sTranslate); + pPM->setState(true, sTranslate); + } + CurrentFileScanned = i; + + // if the user ask to cancel the thread, stop now + if(AskForCancel) + break; + } + + sTranslate = dummyI18N("Checking file ended with no error"); + pPM->setState(true, sTranslate); + CheckOk = true; + Ended = true; + } + catch (Exception &e) + { + ucstring sTranslate = dummyI18N("Checking file ended with errors :") + " " + e.what(); + pPM->setState(true, sTranslate); + CheckOk = false; + Ended = true; + } +} + diff --git a/code/ryzom/tools/client/client_data_check/data_scan.h b/code/ryzom/tools/client/client_data_check/data_scan.h index 1b63cecb2..be1c5ee59 100644 --- a/code/ryzom/tools/client/client_data_check/data_scan.h +++ b/code/ryzom/tools/client/client_data_check/data_scan.h @@ -1,217 +1,217 @@ -// 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_PATCH_H -#define CL_PATCH_H - -#include - -#include "nel/misc/types_nl.h" -#include "nel/misc/config_file.h" -#include "nel/misc/thread.h" -#include "../game_share/bnp_patch.h" -#include - -class CScanDataThread; - -/** - * class managing the patch system - * \author Matthieu 'TrapII' Besson - * \author Vianney 'Ace' Lecroart - * \author Nevrax France - * \date July 2004 - */ -class CPatchManager -{ - -public: - - struct SFileToPatch - { - std::string FileName; - std::vector Patches; - std::vector PatcheSizes; - uint32 LastFileDate; // Used during patching to set the date of the file to the Date of the last patch - bool LocalFileToDelete; // Used during patching to know if we have to delete local file prior to apply patches - bool LocalFileExists; - bool Incremental; // Used during patching to know if we have to xdelta against a ref file - std::string ExtractPath; // Used during patching to extract a bnp file to a specific directory - uint32 FinalFileSize; // just for info, the final size after patch - }; - -public: - - /// Singleton method : Get the unique patch manager instance - static CPatchManager* getInstance() - { - if (_Instance == NULL) - _Instance = new CPatchManager(); - return _Instance; - } - - // init - void init(); - - /// Get the version with the Description file (must be done after init) - std::string getClientVersion (); - - bool isVerboseLog() { return VerboseLog; } - - void setVerboseLog(bool b) { VerboseLog = b; } - - // Get the string information about what the threads are doing - // Return true if the state has changed - bool getThreadState (ucstring &state, std::vector &stateLog); - - // TODO : Revoir ca pour la seconde partie ... - // On a peut etre pas les informations de taille des patches ... voir avec daniel - // pour l'instant c'est un fake qui retourne 1 ! - - int getTotalFilesToGet(); - int getCurrentFilesToGet(); - - // ---------------------------------------------- - // ScanData Part : optional task wich verify all data - // ---------------------------------------------- - - // start the full check of BNP - void startScanDataThread(); - - // if the scan data thread has ended - bool isScanDataThreadEnded(bool &ok); - - // ask to stop the Scan Data thread. NB: for security, the thread will continue to the current scanned file, - // then stop. Hence, you must still wait isScanDataThreadEnded() return true - void askForStopScanDataThread(); - - // get the current info Log for data Scan (true if some change from last get, else text is not filled) - bool getDataScanLog(ucstring &text); - -private: - - // Methods used by patch & check threads - // ------------------------------------- - - friend class CScanDataThread; - - // Set the thread state (called by threads to let us know what they are doing) - void setState (bool bOutputToLog, const ucstring &ucsState); - - /// Read the description file (throw exception if it doesn't exists) - void readDescFile(sint32 nVersion); - - /// Read the description of the highest client version file found - void readClientVersionAndDescFile(); - - /// get all the patchs toapply from the desc and current files present - void getPatchFromDesc(SFileToPatch &ftpOut, const CBNPFile &fIn, bool forceCheckSumTest); - - // stop the threads (called when knowing the thread ended) - void stopScanDataThread(); - - // add a file to the scan data log - void addDataScanLogCorruptedFile(const SFileToPatch &ftp); - void clearDataScanLog(); - static void getCorruptedFileInfo(const SFileToPatch &ftp, ucstring &sTranslate); - -private: - - /// Constructor - CPatchManager(); - - /// The singleton's instance - static CPatchManager* _Instance; - - /// Description file - std::string DescFilename; - bool ValidDescFile; - CProductDescriptionForClient DescFile; - std::vector FilesToPatch; - - // Threads - CScanDataThread *ScanDataThread; - NLMISC::IThread *thread; - - // State - struct CState - { - ucstring State; - std::vector StateLog; - bool StateChanged; - CState() - { - StateChanged= false; - } - }; - NLMISC::CSynchronized State; - - // Where the client get all delta and desc file - std::string ClientPatchPath; - std::string ClientDataPath; - - /// Output usefull information for debugging in the log file - bool VerboseLog; - - // For Data Scan, list of files with checksum error => should delete them - struct CDataScanState - { - std::vector FilesWithScanDataError; - bool Changed; - CDataScanState() - { - Changed= false; - } - }; - typedef NLMISC::CSynchronized TSyncDataScanState; - TSyncDataScanState DataScanState; - // The file size of a an empty BNP - enum {EmptyBnpFileSize= 8}; -}; - -/** - * This thread perform a checksum check on all existing files registered in the local .idx - * \author Lionel Berenguier - * \author Nevrax France - * \date July 2004 - */ -class CScanDataThread : public NLMISC::IRunnable -{ - -public: - - CScanDataThread(); - -public: - - // Written by MainThread, read by thread - bool AskForCancel; // true if the main thread ask to cancel the task - - // Written by thread, read by Main Thread - bool Ended; // true if the thread have ended - bool CheckOk; // true if the check is good - int TotalFileToScan; - int CurrentFileScanned; - -private: - - void run(); - -}; - - -#endif // CL_PATCH_H - -/* End of login_patch.h */ +// 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_PATCH_H +#define CL_PATCH_H + +#include + +#include "nel/misc/types_nl.h" +#include "nel/misc/config_file.h" +#include "nel/misc/thread.h" +#include "../game_share/bnp_patch.h" +#include + +class CScanDataThread; + +/** + * class managing the patch system + * \author Matthieu 'TrapII' Besson + * \author Vianney 'Ace' Lecroart + * \author Nevrax France + * \date July 2004 + */ +class CPatchManager +{ + +public: + + struct SFileToPatch + { + std::string FileName; + std::vector Patches; + std::vector PatcheSizes; + uint32 LastFileDate; // Used during patching to set the date of the file to the Date of the last patch + bool LocalFileToDelete; // Used during patching to know if we have to delete local file prior to apply patches + bool LocalFileExists; + bool Incremental; // Used during patching to know if we have to xdelta against a ref file + std::string ExtractPath; // Used during patching to extract a bnp file to a specific directory + uint32 FinalFileSize; // just for info, the final size after patch + }; + +public: + + /// Singleton method : Get the unique patch manager instance + static CPatchManager* getInstance() + { + if (_Instance == NULL) + _Instance = new CPatchManager(); + return _Instance; + } + + // init + void init(); + + /// Get the version with the Description file (must be done after init) + std::string getClientVersion (); + + bool isVerboseLog() { return VerboseLog; } + + void setVerboseLog(bool b) { VerboseLog = b; } + + // Get the string information about what the threads are doing + // Return true if the state has changed + bool getThreadState (ucstring &state, std::vector &stateLog); + + // TODO : Revoir ca pour la seconde partie ... + // On a peut etre pas les informations de taille des patches ... voir avec daniel + // pour l'instant c'est un fake qui retourne 1 ! + + int getTotalFilesToGet(); + int getCurrentFilesToGet(); + + // ---------------------------------------------- + // ScanData Part : optional task wich verify all data + // ---------------------------------------------- + + // start the full check of BNP + void startScanDataThread(); + + // if the scan data thread has ended + bool isScanDataThreadEnded(bool &ok); + + // ask to stop the Scan Data thread. NB: for security, the thread will continue to the current scanned file, + // then stop. Hence, you must still wait isScanDataThreadEnded() return true + void askForStopScanDataThread(); + + // get the current info Log for data Scan (true if some change from last get, else text is not filled) + bool getDataScanLog(ucstring &text); + +private: + + // Methods used by patch & check threads + // ------------------------------------- + + friend class CScanDataThread; + + // Set the thread state (called by threads to let us know what they are doing) + void setState (bool bOutputToLog, const ucstring &ucsState); + + /// Read the description file (throw exception if it doesn't exists) + void readDescFile(sint32 nVersion); + + /// Read the description of the highest client version file found + void readClientVersionAndDescFile(); + + /// get all the patchs toapply from the desc and current files present + void getPatchFromDesc(SFileToPatch &ftpOut, const CBNPFile &fIn, bool forceCheckSumTest); + + // stop the threads (called when knowing the thread ended) + void stopScanDataThread(); + + // add a file to the scan data log + void addDataScanLogCorruptedFile(const SFileToPatch &ftp); + void clearDataScanLog(); + static void getCorruptedFileInfo(const SFileToPatch &ftp, ucstring &sTranslate); + +private: + + /// Constructor + CPatchManager(); + + /// The singleton's instance + static CPatchManager* _Instance; + + /// Description file + std::string DescFilename; + bool ValidDescFile; + CProductDescriptionForClient DescFile; + std::vector FilesToPatch; + + // Threads + CScanDataThread *ScanDataThread; + NLMISC::IThread *thread; + + // State + struct CState + { + ucstring State; + std::vector StateLog; + bool StateChanged; + CState() + { + StateChanged= false; + } + }; + NLMISC::CSynchronized State; + + // Where the client get all delta and desc file + std::string ClientPatchPath; + std::string ClientDataPath; + + /// Output usefull information for debugging in the log file + bool VerboseLog; + + // For Data Scan, list of files with checksum error => should delete them + struct CDataScanState + { + std::vector FilesWithScanDataError; + bool Changed; + CDataScanState() + { + Changed= false; + } + }; + typedef NLMISC::CSynchronized TSyncDataScanState; + TSyncDataScanState DataScanState; + // The file size of a an empty BNP + enum {EmptyBnpFileSize= 8}; +}; + +/** + * This thread perform a checksum check on all existing files registered in the local .idx + * \author Lionel Berenguier + * \author Nevrax France + * \date July 2004 + */ +class CScanDataThread : public NLMISC::IRunnable +{ + +public: + + CScanDataThread(); + +public: + + // Written by MainThread, read by thread + bool AskForCancel; // true if the main thread ask to cancel the task + + // Written by thread, read by Main Thread + bool Ended; // true if the thread have ended + bool CheckOk; // true if the check is good + int TotalFileToScan; + int CurrentFileScanned; + +private: + + void run(); + +}; + + +#endif // CL_PATCH_H + +/* End of login_patch.h */ diff --git a/code/ryzom/tools/client/client_data_check/resource.h b/code/ryzom/tools/client/client_data_check/resource.h index 7ed09015b..acd0a6a0e 100644 --- a/code/ryzom/tools/client/client_data_check/resource.h +++ b/code/ryzom/tools/client/client_data_check/resource.h @@ -1,36 +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 . - -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by client_data_check.rc -// -#define IDD_CLIENT_DATA_CHECK_DIALOG 102 -#define IDR_MAINFRAME 128 -#define IDC_STATIC_STATUS 1000 -#define IDC_LIST_LOG 1002 -#define IDC_BUTTON_CANCEL 1003 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 129 -#define _APS_NEXT_COMMAND_VALUE 32771 -#define _APS_NEXT_CONTROL_VALUE 1004 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif +// 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 . + +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by client_data_check.rc +// +#define IDD_CLIENT_DATA_CHECK_DIALOG 102 +#define IDR_MAINFRAME 128 +#define IDC_STATIC_STATUS 1000 +#define IDC_LIST_LOG 1002 +#define IDC_BUTTON_CANCEL 1003 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 129 +#define _APS_NEXT_COMMAND_VALUE 32771 +#define _APS_NEXT_CONTROL_VALUE 1004 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/code/ryzom/tools/client/client_patcher/main.cpp b/code/ryzom/tools/client/client_patcher/main.cpp index 052bd40d2..146da383c 100644 --- a/code/ryzom/tools/client/client_patcher/main.cpp +++ b/code/ryzom/tools/client/client_patcher/main.cpp @@ -1,417 +1,417 @@ -#include "stdpch.h" -#include "login_patch.h" -#include "client_cfg.h" -#include - -#ifdef NL_OS_WINDOWS -#include -#endif - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -using namespace NLMISC; -using namespace std; - -// stuff which is defined as extern in other .cpp files -void quitCrashReport() -{ -} - -/// domain server version for patch -string R2ServerVersion; -/// name of the version (used to alias many version under the same name), -/// the value is used to get the release not if not empty -string VersionName; - -string LoginLogin, LoginPassword; -uint32 LoginShardId = 0xFFFFFFFF; - -// stuff which is defined in other .cpp files -extern void tmpFlagRemovedPatchCategories(NLMISC::CConfigFile &cf); - -bool useUtf8 = false; -bool useEsc = false; - -#ifdef NL_OS_WINDOWS -HANDLE hStdout = NULL; -sint attributes = 0; -#endif - -std::string convert(const ucstring &str) -{ - if (useUtf8) - return str.toUtf8(); - - return str.toString(); -} - -void printError(const std::string &str) -{ - // display error in red if possible - if (useEsc) - { - printf("\033[1;31mError: %s\033[0m\n", str.c_str()); - } - else - { -#ifdef NL_OS_WINDOWS - if (hStdout != INVALID_HANDLE_VALUE && hStdout) - SetConsoleTextAttribute(hStdout, FOREGROUND_RED|FOREGROUND_INTENSITY); -#endif - - printf("Error: %s\n", str.c_str()); - -#ifdef NL_OS_WINDOWS - if (hStdout != INVALID_HANDLE_VALUE && hStdout) - SetConsoleTextAttribute(hStdout, attributes); -#endif - } -} - -void printCheck(const std::string &str) -{ - // display check - printf("%s\n", str.c_str()); -} - -void printDownload(const std::string &str) -{ - static char spaces[80]; - - uint maxLength = 80; - - // if "COLUMNS" environnement variable is defined, use it - if (getenv("COLUMNS")) - { - NLMISC::fromString(std::string(getenv("COLUMNS")), maxLength); - } - - // only use 79 columns to not wrap - --maxLength; - - // temporary modified string - std::string nstr = str; - - uint length = 0; - - if (useUtf8) - { - ucstring ucstr; - ucstr.fromUtf8(nstr); - length = (uint)ucstr.length(); - if (length > maxLength) - { - ucstr = ucstr.luabind_substr(length - maxLength + 3); - nstr = std::string("...") + ucstr.toUtf8(); - length = maxLength; - } - } - else - { - length = (uint)nstr.length(); - if (length > maxLength) - { - nstr = std::string("...") + nstr.substr(length - maxLength + 3); - length = maxLength; - } - } - - // add padding with spaces - memset(spaces, ' ', maxLength); - spaces[maxLength - length] = '\0'; - - // display download in purple - if (useEsc) - { - printf("\033[1;35m%s%s\033[0m\r", nstr.c_str(), spaces); - } - else - { -#ifdef NL_OS_WINDOWS - if (hStdout != INVALID_HANDLE_VALUE && hStdout) - SetConsoleTextAttribute(hStdout, FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_INTENSITY); -#endif - - printf("%s%s\r", nstr.c_str(), spaces); - -#ifdef NL_OS_WINDOWS - if (hStdout != INVALID_HANDLE_VALUE && hStdout) - SetConsoleTextAttribute(hStdout, attributes); -#endif - } - - fflush(stdout); -} - -int main(int argc, char *argv[]) -{ - // init the Nel context - CApplicationContext appContext; - - // create logs in temporary directory - createDebug(CPath::getTemporaryDirectory().c_str(), true, true); - - // disable log display on stdout - INelContext::getInstance().getDebugLog()->removeDisplayer("DEFAULT_SD"); - INelContext::getInstance().getInfoLog()->removeDisplayer("DEFAULT_SD"); - INelContext::getInstance().getWarningLog()->removeDisplayer("DEFAULT_SD"); - - std::string config = "client.cfg"; - - // if client.cfg is not in current directory, use client.cfg from user directory - if (!CFile::isExists(config)) - config = CPath::getApplicationDirectory("Ryzom") + config; - - // if client.cfg is not in current directory, use client_default.cfg - if (!CFile::isExists(config)) - config = "client_default.cfg"; - -#ifdef RYZOM_ETC_PREFIX - // if client_default.cfg is not in current directory, use application default directory - if (!CFile::isExists(config)) - config = CPath::standardizePath(RYZOM_ETC_PREFIX) + config; -#endif - - if (!CFile::isExists(config)) - { - printError(config + " not found, aborting patch."); - return 1; - } - - // check if console supports utf-8 - std::string lang = toLower(std::string(setlocale(LC_CTYPE, ""))); - useUtf8 = (lang.find("utf8") != string::npos || lang.find("utf-8") != string::npos); - lang = lang.substr(0, 2); - - // check if console supports colors - std::string term = toLower(std::string(getenv("TERM") ? getenv("TERM"):"")); - useEsc = (term.find("xterm") != string::npos || term.find("linux") != string::npos); - -#ifdef NL_OS_WINDOWS - // setup Windows console - hStdout = GetStdHandle(STD_OUTPUT_HANDLE); - - if (hStdout != INVALID_HANDLE_VALUE) - { - CONSOLE_SCREEN_BUFFER_INFO consoleScreenBufferInfo; - - if (GetConsoleScreenBufferInfo(hStdout, &consoleScreenBufferInfo)) - attributes = consoleScreenBufferInfo.wAttributes; - } -#endif - - // load client.cfg or client_default.cfg - ClientCfg.init(config); - - // check if PatchServer is defined - if (ClientCfg.PatchServer.empty()) - { - printError("PatchServer not defined in " + config); - return 1; - } - - // set default paths - std::string dataPath = "./data/"; - std::string rootPath = "./"; - - // use custom data path if specified - if (!ClientCfg.DataPath.empty()) - { - dataPath = CPath::standardizePath(ClientCfg.DataPath.front()); - string::size_type pos = dataPath.rfind('/', dataPath.length()-2); - if (pos != string::npos) - rootPath = dataPath.substr(0, pos+1); - } - - std::string unpackPath = CPath::standardizePath(rootPath + "unpack"); - - // check if user can write in data directory - if (!CFile::isExists(unpackPath)) - { - if (!CFile::createDirectoryTree(unpackPath)) - { - printError("You don't have permission to create " + unpackPath); - return 1; - } - } - else - { - if (!CFile::createEmptyFile(unpackPath + "empty")) - { - printError("You don't have write permission in " + unpackPath); - return 1; - } - - CFile::deleteFile(unpackPath + "empty"); - } - - // only use PreDataPath for looking paths - if (!ClientCfg.PreDataPath.empty()) - { - for(uint i = 0; i < ClientCfg.PreDataPath.size(); ++i) - { - CPath::addSearchPath(ClientCfg.PreDataPath[i], true, false); - } - } - - // add more search paths if translation is not found - if (!CPath::exists(lang + ".uxt")) - { - CPath::addSearchPath("patcher", true, false); -#ifdef RYZOM_SHARE_PREFIX - CPath::addSearchPath(RYZOM_SHARE_PREFIX"/patcher", true, false); -#endif - } - - // load translation - CI18N::load(lang); - - printf("Checking %s files to patch...\n", convert(CI18N::get("TheSagaOfRyzom")).c_str()); - -#ifdef NL_OS_UNIX - // don't use cfg, exe and dll from Windows version - CConfigFile::CVar var; - var.Type = CConfigFile::CVar::T_STRING; - std::vector cats; - cats.push_back("main_exedll"); - cats.push_back("main_cfg"); - var.setAsString(cats); - ClientCfg.ConfigFile.insertVar("RemovePatchCategories", var); - - // add categories to remove - tmpFlagRemovedPatchCategories(ClientCfg.ConfigFile); -#endif - - // initialize patch manager and set the ryzom full path, before it's used - CPatchManager *pPM = CPatchManager::getInstance(); - - // set the correct root path - pPM->setClientRootPath(rootPath); - - // use PatchServer URL - vector patchURLs; - pPM->init(patchURLs, ClientCfg.PatchServer, ClientCfg.PatchVersion); - pPM->startCheckThread(true /* include background patchs */); - - ucstring state; - vector log; - bool res = false; - bool finished = false; - - while (!finished) - { - nlSleep(100); - - finished = pPM->isCheckThreadEnded(res); - - if (pPM->getThreadState(state, log)) - { - for(uint i = 0; i < log.size(); ++i) - { - printCheck(convert(log[i])); - } - } - } - - if (!res && !pPM->getLastErrorMessage().empty()) - { - printError(convert(CI18N::get("uiErrChecking") + " " + pPM->getLastErrorMessage())); - return 1; - } - - CPatchManager::SPatchInfo InfoOnPatch; - - // Check is good now ask the player if he wants to apply the patch - pPM->getInfoToDisp(InfoOnPatch); - - // Get the list of optional categories to patch - vector vCategories; - - for(uint i = 0; i < InfoOnPatch.OptCat.size(); i++) - { - // Ok for the moment all optional categories must be patched even if the player - // does not want it. Because we can't detect that a continent have to be patched ingame. - vCategories.push_back(InfoOnPatch.OptCat[i].Name); - } - - // start patch thread - pPM->startPatchThread(vCategories, true); - - res = false; - finished = false; - - while (!finished) - { - nlSleep(100); - - finished = pPM->isPatchThreadEnded(res); - - if (pPM->getThreadState(state, log)) - { - printDownload(convert(state)); - - for(uint i = 0; i < log.size(); ++i) - { - printCheck(convert(log[i])); - } - } - } - - if (!res && !pPM->getLastErrorMessage().empty()) - { - printError(convert(CI18N::get("uiErrPatchApply") + " " + pPM->getLastErrorMessage())); - return 1; - } - - if (CPatchManager::getInstance()->mustLaunchBatFile()) - { - std::string error; - - try - { - // move downloaded files to final location - pPM->createBatchFile(pPM->getDescFile(), false, false); - CFile::createEmptyFile("show_eula"); - - if (!pPM->getLastErrorMessage().empty()) - { - error = convert(pPM->getLastErrorMessage()); - } - } - catch(const EDiskFullError &) - { - error = convert(CI18N::get("uiPatchDiskFull"));; - } - catch(const EWriteError &) - { - error = convert(CI18N::get("uiPatchWriteError"));; - } - catch(const Exception &e) - { - error = convert(CI18N::get("uiCheckEndWithErr") + " " + e.what()); - } - catch(...) - { - error = "unknown exception"; - } - - if (!error.empty()) - { - printError(convert(CI18N::get("uiErrPatchApply")) + " " + error); - return 1; - } - } - -/* - // Start Scanning - pPM->startScanDataThread(); - - // request to stop the thread - pPM->askForStopScanDataThread(); -*/ - - return 0; -} - +#include "stdpch.h" +#include "login_patch.h" +#include "client_cfg.h" +#include + +#ifdef NL_OS_WINDOWS +#include +#endif + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +using namespace NLMISC; +using namespace std; + +// stuff which is defined as extern in other .cpp files +void quitCrashReport() +{ +} + +/// domain server version for patch +string R2ServerVersion; +/// name of the version (used to alias many version under the same name), +/// the value is used to get the release not if not empty +string VersionName; + +string LoginLogin, LoginPassword; +uint32 LoginShardId = 0xFFFFFFFF; + +// stuff which is defined in other .cpp files +extern void tmpFlagRemovedPatchCategories(NLMISC::CConfigFile &cf); + +bool useUtf8 = false; +bool useEsc = false; + +#ifdef NL_OS_WINDOWS +HANDLE hStdout = NULL; +sint attributes = 0; +#endif + +std::string convert(const ucstring &str) +{ + if (useUtf8) + return str.toUtf8(); + + return str.toString(); +} + +void printError(const std::string &str) +{ + // display error in red if possible + if (useEsc) + { + printf("\033[1;31mError: %s\033[0m\n", str.c_str()); + } + else + { +#ifdef NL_OS_WINDOWS + if (hStdout != INVALID_HANDLE_VALUE && hStdout) + SetConsoleTextAttribute(hStdout, FOREGROUND_RED|FOREGROUND_INTENSITY); +#endif + + printf("Error: %s\n", str.c_str()); + +#ifdef NL_OS_WINDOWS + if (hStdout != INVALID_HANDLE_VALUE && hStdout) + SetConsoleTextAttribute(hStdout, attributes); +#endif + } +} + +void printCheck(const std::string &str) +{ + // display check + printf("%s\n", str.c_str()); +} + +void printDownload(const std::string &str) +{ + static char spaces[80]; + + uint maxLength = 80; + + // if "COLUMNS" environnement variable is defined, use it + if (getenv("COLUMNS")) + { + NLMISC::fromString(std::string(getenv("COLUMNS")), maxLength); + } + + // only use 79 columns to not wrap + --maxLength; + + // temporary modified string + std::string nstr = str; + + uint length = 0; + + if (useUtf8) + { + ucstring ucstr; + ucstr.fromUtf8(nstr); + length = (uint)ucstr.length(); + if (length > maxLength) + { + ucstr = ucstr.luabind_substr(length - maxLength + 3); + nstr = std::string("...") + ucstr.toUtf8(); + length = maxLength; + } + } + else + { + length = (uint)nstr.length(); + if (length > maxLength) + { + nstr = std::string("...") + nstr.substr(length - maxLength + 3); + length = maxLength; + } + } + + // add padding with spaces + memset(spaces, ' ', maxLength); + spaces[maxLength - length] = '\0'; + + // display download in purple + if (useEsc) + { + printf("\033[1;35m%s%s\033[0m\r", nstr.c_str(), spaces); + } + else + { +#ifdef NL_OS_WINDOWS + if (hStdout != INVALID_HANDLE_VALUE && hStdout) + SetConsoleTextAttribute(hStdout, FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_INTENSITY); +#endif + + printf("%s%s\r", nstr.c_str(), spaces); + +#ifdef NL_OS_WINDOWS + if (hStdout != INVALID_HANDLE_VALUE && hStdout) + SetConsoleTextAttribute(hStdout, attributes); +#endif + } + + fflush(stdout); +} + +int main(int argc, char *argv[]) +{ + // init the Nel context + CApplicationContext appContext; + + // create logs in temporary directory + createDebug(CPath::getTemporaryDirectory().c_str(), true, true); + + // disable log display on stdout + INelContext::getInstance().getDebugLog()->removeDisplayer("DEFAULT_SD"); + INelContext::getInstance().getInfoLog()->removeDisplayer("DEFAULT_SD"); + INelContext::getInstance().getWarningLog()->removeDisplayer("DEFAULT_SD"); + + std::string config = "client.cfg"; + + // if client.cfg is not in current directory, use client.cfg from user directory + if (!CFile::isExists(config)) + config = CPath::getApplicationDirectory("Ryzom") + config; + + // if client.cfg is not in current directory, use client_default.cfg + if (!CFile::isExists(config)) + config = "client_default.cfg"; + +#ifdef RYZOM_ETC_PREFIX + // if client_default.cfg is not in current directory, use application default directory + if (!CFile::isExists(config)) + config = CPath::standardizePath(RYZOM_ETC_PREFIX) + config; +#endif + + if (!CFile::isExists(config)) + { + printError(config + " not found, aborting patch."); + return 1; + } + + // check if console supports utf-8 + std::string lang = toLower(std::string(setlocale(LC_CTYPE, ""))); + useUtf8 = (lang.find("utf8") != string::npos || lang.find("utf-8") != string::npos); + lang = lang.substr(0, 2); + + // check if console supports colors + std::string term = toLower(std::string(getenv("TERM") ? getenv("TERM"):"")); + useEsc = (term.find("xterm") != string::npos || term.find("linux") != string::npos); + +#ifdef NL_OS_WINDOWS + // setup Windows console + hStdout = GetStdHandle(STD_OUTPUT_HANDLE); + + if (hStdout != INVALID_HANDLE_VALUE) + { + CONSOLE_SCREEN_BUFFER_INFO consoleScreenBufferInfo; + + if (GetConsoleScreenBufferInfo(hStdout, &consoleScreenBufferInfo)) + attributes = consoleScreenBufferInfo.wAttributes; + } +#endif + + // load client.cfg or client_default.cfg + ClientCfg.init(config); + + // check if PatchServer is defined + if (ClientCfg.PatchServer.empty()) + { + printError("PatchServer not defined in " + config); + return 1; + } + + // set default paths + std::string dataPath = "./data/"; + std::string rootPath = "./"; + + // use custom data path if specified + if (!ClientCfg.DataPath.empty()) + { + dataPath = CPath::standardizePath(ClientCfg.DataPath.front()); + string::size_type pos = dataPath.rfind('/', dataPath.length()-2); + if (pos != string::npos) + rootPath = dataPath.substr(0, pos+1); + } + + std::string unpackPath = CPath::standardizePath(rootPath + "unpack"); + + // check if user can write in data directory + if (!CFile::isExists(unpackPath)) + { + if (!CFile::createDirectoryTree(unpackPath)) + { + printError("You don't have permission to create " + unpackPath); + return 1; + } + } + else + { + if (!CFile::createEmptyFile(unpackPath + "empty")) + { + printError("You don't have write permission in " + unpackPath); + return 1; + } + + CFile::deleteFile(unpackPath + "empty"); + } + + // only use PreDataPath for looking paths + if (!ClientCfg.PreDataPath.empty()) + { + for(uint i = 0; i < ClientCfg.PreDataPath.size(); ++i) + { + CPath::addSearchPath(ClientCfg.PreDataPath[i], true, false); + } + } + + // add more search paths if translation is not found + if (!CPath::exists(lang + ".uxt")) + { + CPath::addSearchPath("patcher", true, false); +#ifdef RYZOM_SHARE_PREFIX + CPath::addSearchPath(RYZOM_SHARE_PREFIX"/patcher", true, false); +#endif + } + + // load translation + CI18N::load(lang); + + printf("Checking %s files to patch...\n", convert(CI18N::get("TheSagaOfRyzom")).c_str()); + +#ifdef NL_OS_UNIX + // don't use cfg, exe and dll from Windows version + CConfigFile::CVar var; + var.Type = CConfigFile::CVar::T_STRING; + std::vector cats; + cats.push_back("main_exedll"); + cats.push_back("main_cfg"); + var.setAsString(cats); + ClientCfg.ConfigFile.insertVar("RemovePatchCategories", var); + + // add categories to remove + tmpFlagRemovedPatchCategories(ClientCfg.ConfigFile); +#endif + + // initialize patch manager and set the ryzom full path, before it's used + CPatchManager *pPM = CPatchManager::getInstance(); + + // set the correct root path + pPM->setClientRootPath(rootPath); + + // use PatchServer URL + vector patchURLs; + pPM->init(patchURLs, ClientCfg.PatchServer, ClientCfg.PatchVersion); + pPM->startCheckThread(true /* include background patchs */); + + ucstring state; + vector log; + bool res = false; + bool finished = false; + + while (!finished) + { + nlSleep(100); + + finished = pPM->isCheckThreadEnded(res); + + if (pPM->getThreadState(state, log)) + { + for(uint i = 0; i < log.size(); ++i) + { + printCheck(convert(log[i])); + } + } + } + + if (!res && !pPM->getLastErrorMessage().empty()) + { + printError(convert(CI18N::get("uiErrChecking") + " " + pPM->getLastErrorMessage())); + return 1; + } + + CPatchManager::SPatchInfo InfoOnPatch; + + // Check is good now ask the player if he wants to apply the patch + pPM->getInfoToDisp(InfoOnPatch); + + // Get the list of optional categories to patch + vector vCategories; + + for(uint i = 0; i < InfoOnPatch.OptCat.size(); i++) + { + // Ok for the moment all optional categories must be patched even if the player + // does not want it. Because we can't detect that a continent have to be patched ingame. + vCategories.push_back(InfoOnPatch.OptCat[i].Name); + } + + // start patch thread + pPM->startPatchThread(vCategories, true); + + res = false; + finished = false; + + while (!finished) + { + nlSleep(100); + + finished = pPM->isPatchThreadEnded(res); + + if (pPM->getThreadState(state, log)) + { + printDownload(convert(state)); + + for(uint i = 0; i < log.size(); ++i) + { + printCheck(convert(log[i])); + } + } + } + + if (!res && !pPM->getLastErrorMessage().empty()) + { + printError(convert(CI18N::get("uiErrPatchApply") + " " + pPM->getLastErrorMessage())); + return 1; + } + + if (CPatchManager::getInstance()->mustLaunchBatFile()) + { + std::string error; + + try + { + // move downloaded files to final location + pPM->createBatchFile(pPM->getDescFile(), false, false); + CFile::createEmptyFile("show_eula"); + + if (!pPM->getLastErrorMessage().empty()) + { + error = convert(pPM->getLastErrorMessage()); + } + } + catch(const EDiskFullError &) + { + error = convert(CI18N::get("uiPatchDiskFull"));; + } + catch(const EWriteError &) + { + error = convert(CI18N::get("uiPatchWriteError"));; + } + catch(const Exception &e) + { + error = convert(CI18N::get("uiCheckEndWithErr") + " " + e.what()); + } + catch(...) + { + error = "unknown exception"; + } + + if (!error.empty()) + { + printError(convert(CI18N::get("uiErrPatchApply")) + " " + error); + return 1; + } + } + +/* + // Start Scanning + pPM->startScanDataThread(); + + // request to stop the thread + pPM->askForStopScanDataThread(); +*/ + + return 0; +} + diff --git a/code/ryzom/tools/connection_stats/StdAfx.cpp b/code/ryzom/tools/connection_stats/StdAfx.cpp index a25721276..7155b4447 100644 --- a/code/ryzom/tools/connection_stats/StdAfx.cpp +++ b/code/ryzom/tools/connection_stats/StdAfx.cpp @@ -1,24 +1,24 @@ -// 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 . - -// stdafx.cpp : source file that includes just the standard includes -// connection_stats.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file +// 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 . + +// stdafx.cpp : source file that includes just the standard includes +// connection_stats.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/code/ryzom/tools/connection_stats/StdAfx.h b/code/ryzom/tools/connection_stats/StdAfx.h index fe8b96d48..01e23d195 100644 --- a/code/ryzom/tools/connection_stats/StdAfx.h +++ b/code/ryzom/tools/connection_stats/StdAfx.h @@ -1,40 +1,40 @@ -// 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 . - -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#if !defined(AFX_STDAFX_H__24B1BEF5_A66E_4D62_B3E7_E623CB4BC77D__INCLUDED_) -#define AFX_STDAFX_H__24B1BEF5_A66E_4D62_B3E7_E623CB4BC77D__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - - -// Insert your headers here -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - -#include - -// TODO: reference additional headers your program requires here - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__24B1BEF5_A66E_4D62_B3E7_E623CB4BC77D__INCLUDED_) +// 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 . + +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__24B1BEF5_A66E_4D62_B3E7_E623CB4BC77D__INCLUDED_) +#define AFX_STDAFX_H__24B1BEF5_A66E_4D62_B3E7_E623CB4BC77D__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + + +// Insert your headers here +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +#include + +// TODO: reference additional headers your program requires here + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__24B1BEF5_A66E_4D62_B3E7_E623CB4BC77D__INCLUDED_) diff --git a/code/ryzom/tools/connection_stats/connection_stats.cpp b/code/ryzom/tools/connection_stats/connection_stats.cpp index b01733e3d..b502b4bef 100644 --- a/code/ryzom/tools/connection_stats/connection_stats.cpp +++ b/code/ryzom/tools/connection_stats/connection_stats.cpp @@ -1,1013 +1,1013 @@ -// 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 . - -// connection_stats.cpp : Defines the entry point for the DLL application. -// - -#include "stdafx.h" - -#define LOG_ANALYSER_PLUGIN_EXPORTS -#include "connection_stats.h" - -#include - - -BOOL APIENTRY DllMain( HANDLE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved - ) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} - - -#include -using namespace NLMISC; - - -#include -#include -using namespace std; - - -time_t LogBeginTime = 0, LogEndTime = 0; -bool ContinuationOfStatInPreviousFile = true; - - -// -string timeToStr( const time_t& ts ) -{ - //return string(ctime( &ts )).substr( 0, 24 ); - return IDisplayer::dateToHumanString( ts ); -} - - -// -string toHourStr( uint totalSec ) -{ - uint hour = totalSec / 3600; - uint remMin = totalSec % 3600; - string res = toString( "%uh%02u'%02u\"", hour, remMin / 60, remMin % 60 ); - return res; -} - - -/* - * - */ -struct TSession -{ - uint ClientId; - time_t BeginTime; - time_t EndTime; - time_t Duration; - bool Closed; -}; - - -/* - * - */ -struct TPlayerStat -{ - uint UserId; - string Name; - vector Sessions; - uint Average; - uint Sum; - uint Min; - uint Max; - - /// - TPlayerStat() : UserId(0), Name("?"), Average(0), Sum(0), Min(0), Max(0) {} - - /// - bool beginSession( const time_t& ts, uint clientId, uint userId, const string& name ) - { - if ( Sessions.empty() || (Name == "?") ) - { - init( userId, name ); - } - - if ( Sessions.empty() || (Sessions.back().EndTime != 0) ) - { - // Open a new session - TSession s; - s.ClientId = clientId; - s.BeginTime = ts; - s.EndTime = 0; - s.Closed = false; - Sessions.push_back( s ); - return true; - } - else - { - // Occurs if two clients have the same userId - nlwarning( "Opening a session for user %u (%s) at %s while previous session at %s not closed", UserId, Name.c_str(), timeToStr( ts ).c_str(), timeToStr( Sessions.back().BeginTime ).c_str() ); - //Sessions.back().ClientId = clientId; // cumulate times - //return false; - - // Close the previous session - bool userMissing; - endSession( ts, Sessions.back().ClientId, userId, name, &userMissing, false ); - - // Open a new session - TSession s; - s.ClientId = clientId; - s.BeginTime = ts; - s.EndTime = 0; - s.Closed = false; - Sessions.push_back( s ); - return false; - - } - } - - /** - * Return true if the disconnection is valid, false if ignored. If true, set userMissing if connection of user not found in the log - * but was done before writing into this stat file. - */ - bool endSession( const time_t& ts, uint clientId, uint userId, const string& name, bool *userMissing, bool closed=true ) - { - if ( Sessions.empty() || (Name == "?") ) - { - init( userId, name ); - } - - if ( Sessions.empty() ) - { - // User was already connected at beginning of log - if ( ContinuationOfStatInPreviousFile ) - { - nldebug( "User %u (%s): disconnection at %s: connection before beginning of stat detected", userId, name.c_str(), timeToStr( ts ).c_str() ); - TSession s; - s.ClientId = clientId; - s.BeginTime = 0; - s.EndTime = ts; - s.Closed = closed; - Sessions.push_back( s ); - *userMissing = true; - return true; - } - else - { - nldebug( "User %u (%s): ignoring disconnection at %s (could not be connected before stat)", userId, name.c_str(), timeToStr( ts ).c_str() ); - return false; - } - } - else - { - // Close the current session - if ( clientId == Sessions.back().ClientId ) - { - if ( Sessions.back().EndTime == 0 ) - { - Sessions.back().EndTime = ts; - Sessions.back().Closed = closed; - *userMissing = false; - return true; - } - else - { - nlwarning( "Detected two successive disconnections of user %u (%s) without reconnection (second ignored) at %s", userId, name.c_str(), timeToStr( ts ).c_str() ); - return false; - } - } - else - { - // Occurs if two clients have the same userId - nlwarning( "Closing a session for user %u (%s) with invalid client (ignored)", userId, name.c_str() ); - return false; - } - } - } - - /// - sint calcSessionTime( uint numSession, const time_t& testEndTime ) - { - if ( numSession < Sessions.size() ) - { - if ( Sessions[numSession].BeginTime == 0 ) - { - Sessions[numSession].BeginTime = LogBeginTime; - nlinfo( "User %u %s already connected at beginning of log (session end at %s)", UserId, Name.c_str(), timeToStr( Sessions[numSession].EndTime ).c_str() ); - } - if ( Sessions[numSession].EndTime == 0 ) - { - Sessions[numSession].EndTime = LogEndTime; - nlinfo( "User %u %s still connected at end of log (session begin at %s)", UserId, Name.c_str(), timeToStr( Sessions[numSession].BeginTime ).c_str() ); - } - - Sessions[numSession].Duration = (int)difftime( Sessions[numSession].EndTime, Sessions[numSession].BeginTime ); - return Sessions[numSession].Duration; - } - else - return 0; - } - -private: - - /// - void init( uint userId, const string& name ) - { - UserId = userId; - Name = name; - } - -}; - - -/* - * - */ -struct TInstantNbPlayers -{ - uint Nb; - time_t Timestamp; - uint UserId; - string Event; -}; - - -/* - * - */ -typedef std::map< uint, TPlayerStat > TPlayerMap; -typedef std::deque< TInstantNbPlayers > TNbPlayersSeries; -TPlayerMap PlayerMap; -TNbPlayersSeries NbPlayersSeries; -uint NbPlayers; -string MainStats; -float TotalTimeInDays; - - -/// -void resetAll() -{ - LogBeginTime = 0; - LogEndTime = 0; - PlayerMap.clear(); - NbPlayersSeries.clear(); - NbPlayers = 0; - MainStats = ""; -} - - -/// -void addConnectionEvent( const time_t& ts, uint userId ) -{ - ++NbPlayers; - TInstantNbPlayers inp; - inp.UserId = userId; - inp.Event = "+"; - if ( ts != 0 ) - { - inp.Nb = NbPlayers; - inp.Timestamp = ts; - NbPlayersSeries.push_back( inp ); - } - else - { - nldebug( "Inserting connection of user %u at beginning", userId ); - // Insert at front and increment every other number - for ( TNbPlayersSeries::iterator iv=NbPlayersSeries.begin(); iv!=NbPlayersSeries.end(); ++iv ) - ++(*iv).Nb; - inp.Nb = 1; - inp.Timestamp = LogBeginTime; - NbPlayersSeries.push_front( inp ); - } -} - - -/// -void addDisconnectionEvent( const time_t& ts, uint userId ) -{ - --NbPlayers; - TInstantNbPlayers inp; - inp.Nb = NbPlayers; - inp.Timestamp = ts; - inp.UserId = userId; - inp.Event = "-"; - NbPlayersSeries.push_back( inp ); -} - - -/// -void addConnection( const time_t& ts, uint clientId, uint userId, const string& name ) -{ - if ( PlayerMap[userId].beginSession( ts, clientId, userId, name ) ) - { - addConnectionEvent( ts, userId ); - } -} - - -/// -void addDisconnection( const time_t& ts, uint clientId, uint userId ) -{ - bool userMissing; - if ( PlayerMap[userId].endSession( ts, clientId, userId, "?", &userMissing ) ) - { - if ( userMissing ) - { - // Add connection at beginning if the server was started at a date anterior to the beginning of this stat file - // (otherwise, just discard the disconnection, it could be a stat file corruption transformed - // into server reset) - addConnectionEvent( 0, userId ); - } - - addDisconnectionEvent( ts, userId ); - } -} - - -/// -void resetConnections( const time_t& shutdownTs, const time_t& restartTs ) -{ - ContinuationOfStatInPreviousFile = false; - - TPlayerMap::iterator ipm; - for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) - { - if ( ! (*ipm).second.Sessions.empty() ) - { - if ( (*ipm).second.Sessions.back().EndTime == 0 ) - { - addDisconnection( shutdownTs, (*ipm).second.Sessions.back().ClientId, (*ipm).second.UserId ); - nlwarning( "Resetting connection of user %u because of server shutdown at %s (restart at %s)", (*ipm).second.UserId, timeToStr( shutdownTs ).c_str(), timeToStr( restartTs ).c_str() ); - } - } - } -} - - -/// -void fillUserNamesInEvents() -{ - TNbPlayersSeries::iterator iv; - for ( iv=NbPlayersSeries.begin(); iv!=NbPlayersSeries.end(); ++iv ) - { - (*iv).Event += PlayerMap[(*iv).UserId].Name; - } -} - - -/// -void extractTime( const string& line, time_t& ts ) -{ - struct tm t; - t.tm_isdst = -1; // auto-detect Daylight Saving Time - t.tm_wday = 0; - t.tm_yday = 0; - sscanf( line.c_str(), "%d/%d/%d %d:%d:%d", &t.tm_year, &t.tm_mon, &t.tm_mday, &t.tm_hour, &t.tm_min, &t.tm_sec ); - t.tm_year -= 1900; - t.tm_mon -= 1; // 0..11 - - ts = mktime( &t ); - if ( ts == (time_t)-1 ) - { - /*CString s; - s.Format( "%d/%d/%d %d:%d:%d (%d)", t.tm_year, t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec, ts ); - AfxMessageBox( s );* - exit(-1);*/ - ts = 0; - } -} - - -/// -void calcStats( string& res ) -{ - TPlayerMap::iterator ipm; - for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) - { - uint sum = 0, themax = 0, themin = ~0; - for ( uint i = 0; i!=(*ipm).second.Sessions.size(); ++i ) - { - sum += (*ipm).second.Sessions[i].Duration; - if ( (uint)(*ipm).second.Sessions[i].Duration < themin ) - themin = (*ipm).second.Sessions[i].Duration; - if ( (uint)(*ipm).second.Sessions[i].Duration > themax ) - themax = (*ipm).second.Sessions[i].Duration; - } - (*ipm).second.Sum = sum; - (*ipm).second.Average = sum / (*ipm).second.Sessions.size(); - (*ipm).second.Min = themin; - (*ipm).second.Max = themax; - } -} - - -// Return date for filename such as 2003-06-24 -string extractDateFilename( time_t date ) -{ - string dateStr = timeToStr( date ); - string::size_type pos; - for ( pos=0; pos!=dateStr.size(); ++pos ) - { - if ( dateStr[pos] == '/' ) - dateStr[pos] = '-'; - if ( dateStr[pos] == ' ' ) - { - dateStr = dateStr.substr( 0, pos ); - break; - } - } - return dateStr; - - /*// Revert date - string::size_type slashPos = dateStr.rfind( '/' ); - if ( slashPos == string::npos ) - return ""; - string year = dateStr.substr( slashPos+1, slashPos+5 ); - slashPos = dateStr.rfind( '/', slashPos-1 ); - if ( slashPos == string::npos ) - return ""; - string month = dateStr.substr( slashPos+1, slashPos+3 ); - string day = dateStr.substr( 0, 2 ); - return year + "-" + month + "-" + day;*/ -} - - -enum TMainStatEnum { MSNb, MSAverage, MSSum, MSMin, MSMax }; - - -/// Return stats in float 'days' -void getValuesStatsAndClearValues( vector& values, string& res, bool isTimeInMinute, TMainStatEnum msEnum ) -{ - float sum = 0.0f, themax = 0.0f, themin = 60.0f*24.0f*365.25f*100.0f; // 1 century should be enough - vector::const_iterator iv; - for ( iv=values.begin(); iv!=values.end(); ++iv ) - { - sum += (*iv); - if ( (*iv) < themin ) - themin = (*iv); - if ( (*iv) > themax ) - themax = (*iv); - } - if ( isTimeInMinute ) - { - res += toString( "\t%g", sum / (float)values.size() / (24.0f*60.0f) ) + - toString( "\t%g", sum / (24.0f*60.0f) ) + - toString( "\t%g", themin / (24.0f*60.0f) ) + - toString( "\t%g", themax / (24.0f*60.0f) ); - switch( msEnum ) - { - case MSAverage: - break; - case MSSum: - MainStats += toString( "\t%g", sum / (float)values.size() / (24.0f*60.0f) / TotalTimeInDays ) + - toString( "\t%g", sum / (24.0f*60.0f) / TotalTimeInDays ) + - toString( "\t%g", themax / (24.0f*60.0f) / TotalTimeInDays ); - break; - case MSMax: - break; - default: - break; - } - - } - else - { - res += "\t" + toString( "%g", sum / (float)values.size() ) + - "\t" + toString( "%g", sum ) + - "\t" + toString( "%g", themin ) + - "\t" + toString( "%g", themax ); - } - values.clear(); -} - - -/// Return stats in float 'days' -void getValuesStatsAndClearValues( vector& values, vector< vector >& table, bool isTimeInMinute, TMainStatEnum msEnum ) -{ - float sum = 0.0f, themax = 0.0f, themin = 60.0f*24.0f*365.25f*100.0f; // 1 century should be enough - vector::const_iterator iv; - for ( iv=values.begin(); iv!=values.end(); ++iv ) - { - sum += (*iv); - if ( (*iv) < themin ) - themin = (*iv); - if ( (*iv) > themax ) - themax = (*iv); - } - if ( isTimeInMinute ) - { - table.back().push_back( toString( "%g", sum / (float)values.size() / (24.0f*60.0f) ) ); - table.back().push_back( toString( "%g", sum / (24.0f*60.0f) ) ); - table.back().push_back( toString( "%g", themin / (24.0f*60.0f) ) ); - table.back().push_back( toString( "%g", themax / (24.0f*60.0f) ) ); - switch( msEnum ) - { - case MSAverage: - break; - case MSSum: - MainStats += toString( "\t%g", sum / (float)values.size() / (24.0f*60.0f) / TotalTimeInDays ) + - toString( "\t%g", sum / (24.0f*60.0f) / TotalTimeInDays ) + - toString( "\t%g", themax / (24.0f*60.0f) / TotalTimeInDays ); - break; - case MSMax: - break; - default: - break; - } - - } - else - { - table.back().push_back( toString( "%g", sum / (float)values.size() ) ); - table.back().push_back( toString( "%g", sum ) ); - table.back().push_back( toString( "%g", themin ) ); - table.back().push_back( toString( "%g", themax ) ); - } - values.clear(); -} - - -/// (Note: main stats only for minutes) -uint getSessionDurations( string& res, time_t endTime, bool convertToMinutes, bool inColumnsWithDetail ) -{ - uint sessionNum = 0; - if ( inColumnsWithDetail ) - { - string s1, s2; - TPlayerMap::iterator ipm; - for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) - { - s1 += toString( "%u", (*ipm).second.UserId ) + "\t"; - s2 += (*ipm).second.Name + "\t"; - } - res += s1 + "\r\n" + s2 + "\r\n"; - sint timeSum; - do - { - timeSum = 0; - for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) - { - sint duration = (*ipm).second.calcSessionTime( sessionNum, endTime ); - if ( duration != 0 ) - { - res += (convertToMinutes ? toString( "%.2f", (float)duration/60.0f ) : toString( "%d", duration )) + "\t"; - } - else - { - res += string(convertToMinutes ? "0" : "") + "\t"; - } - timeSum += duration; - } - res += "\r\n"; - - ++sessionNum; - } - while ( timeSum != 0 ); - res += "\r\n"; - - calcStats( res ); - - if ( ! convertToMinutes) - { - // Stats - for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) - { - res += toString( "%u\t", (*ipm).second.Sessions.size() ); - } - res += "\r\n"; - for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) - { - res += toString( "%u\t", (*ipm).second.Average ); - } - res += "\r\n"; - for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) - { - res += toString( "%u\t", (*ipm).second.Sum ); - } - res += "\r\n"; - for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) - { - res += toString( "%u\t", (*ipm).second.Min ); - } - res += "\r\n"; - for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) - { - res += toString( "%u\t", (*ipm).second.Max ); - } - res += "\r\n"; - } - else - { - // Stats - vector values; - for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) - { - values.push_back( (float)((*ipm).second.Sessions.size()) ); - res += toString( "%u\t", (*ipm).second.Sessions.size() ); - } - getValuesStatsAndClearValues( values, res, false, MSNb ); - res += "\r\n"; - for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) - { - values.push_back( (float)((*ipm).second.Average)/60.0f ); - res += toString( "%.2f\t", values.back() ); - } - getValuesStatsAndClearValues( values, res, true, MSAverage ); - res += "\r\n"; - for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) - { - values.push_back( (float)((*ipm).second.Sum)/60.0f ); - res += toString( "%.2f\t", values.back() ); - } - getValuesStatsAndClearValues( values, res, true, MSSum ); - res += "\r\n"; - for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) - { - values.push_back( (float)((*ipm).second.Min)/60.0f ); - res += toString( "%.2f\t", values.back() ); - } - getValuesStatsAndClearValues( values, res, true, MSMin ); - res += "\r\n"; - for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) - { - values.push_back( (float)((*ipm).second.Max)/60.0f ); - res += toString( "%.2f\t", values.back() ); - } - getValuesStatsAndClearValues( values, res, true, MSMax ); - res += "\r\n"; - } - } - else - { - vector< vector > table; - - string s1, s2; - table.push_back(); - table.push_back(); - TPlayerMap::iterator ipm; - for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) - { - table[0].push_back( toString( "%u", (*ipm).second.UserId ) ); //+ "\t"; - table[1].push_back( (*ipm).second.Name ); //+ "\t"; - } - //res += s1 + "\r\n" + s2 + "\r\n"; - sint timeSum; - do - { - timeSum = 0; - for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) - { - sint duration = (*ipm).second.calcSessionTime( sessionNum, endTime ); - timeSum += duration; - } - ++sessionNum; - } - while ( timeSum != 0 ); - table.push_back(); - //res += "\r\n"; - - calcStats( res ); - - if ( ! convertToMinutes) - { - // Stats - table.push_back(); - for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) - { - table.back().push_back( toString( "%u", (*ipm).second.Sessions.size() ) ); - } - //res += "\r\n"; - table.push_back(); - for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) - { - table.back().push_back( toString( "%u", (*ipm).second.Average ) ); - } - //res += "\r\n"; - table.push_back(); - for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) - { - table.back().push_back( toString( "%u", (*ipm).second.Sum ) ); - } - //res += "\r\n"; - table.push_back(); - for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) - { - table.back().push_back( toString( "%u", (*ipm).second.Min ) ); - } - //res += "\r\n"; - table.push_back(); - for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) - { - table.back().push_back( toString( "%u", (*ipm).second.Max ) ); - } - //res += "\r\n"; - } - else - { - // Stats - vector values; - table.push_back(); - for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) - { - values.push_back( (float)((*ipm).second.Sessions.size()) ); - table.back().push_back( toString( "%u", (*ipm).second.Sessions.size() ) ); - } - getValuesStatsAndClearValues( values, table, false, MSNb ); - //res += "\r\n"; - table.push_back(); - for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) - { - values.push_back( (float)((*ipm).second.Average)/60.0f ); - table.back().push_back( toString( "%.2f", values.back() ) ); - } - getValuesStatsAndClearValues( values, table, true, MSAverage ); - //res += "\r\n"; - table.push_back(); - for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) - { - values.push_back( (float)((*ipm).second.Sum)/60.0f ); - table.back().push_back( toString( "%.2f", values.back() ) ); - } - getValuesStatsAndClearValues( values, table, true, MSSum ); - //res += "\r\n"; - table.push_back(); - for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) - { - values.push_back( (float)((*ipm).second.Min)/60.0f ); - table.back().push_back( toString( "%.2f", values.back() ) ); - } - getValuesStatsAndClearValues( values, table, true, MSMin ); - //res += "\r\n"; - table.push_back(); - for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) - { - values.push_back( (float)((*ipm).second.Max)/60.0f ); - table.back().push_back( toString( "%.2f", values.back() ) ); - } - getValuesStatsAndClearValues( values, table, true, MSMax ); - //res += "\r\n"; - } - - // Print in column - /*for ( uint j=0; j!=table.size(); ++j ) - { - for ( uint i=0; i!=table[j].size(); ++i ) - { - res += table[j][i] + "\t"; - } - res += "\r\n"; - }*/ - - // Print in row - uint maxI = 0; - for ( uint j=0; j!=table.size(); ++j ) - { - if ( table[j].size() > maxI ) - maxI = table[j].size(); - } - for ( uint i=0; i!=maxI; ++i ) - { - for ( uint j=0; j!=table.size(); ++j ) - { - if ( i < table[j].size() ) - res += table[j][i] + "\t"; - else - res += "\t"; - } - res += "\r\n"; - } - } - - res += "\r\n"; - - return sessionNum; -} - - -/* - * - */ -LOG_ANALYSER_PLUGIN_API std::string getInfoString() -{ - return "Input log: connection.stat or frontend_service.log.\n\nProduces tab-separated connection stats for Excel."; -} - - -/* - * - */ -LOG_ANALYSER_PLUGIN_API bool doAnalyse( const std::vector& vec, std::string& res, std::string& log ) -{ - NLMISC::createDebug(); - CMemDisplayer memdisp; - NLMISC::DebugLog->addDisplayer( &memdisp, true ); - NLMISC::InfoLog->addDisplayer( &memdisp, true ); - NLMISC::WarningLog->addDisplayer( &memdisp, true ); - NLMISC::ErrorLog->addDisplayer( &memdisp, true ); - NLMISC::AssertLog->addDisplayer( &memdisp, true ); - - resetAll(); - - // Begin and end time - if ( ! vec.empty() ) - { - sint l = 0; - sint quicklines = min( vec.size(), 100 ); - while ( (l < quicklines) && ((string(vec[l]).size()<5) || (vec[l][4] != '/')) ) - ++l; - if ( l < quicklines ) - extractTime( string(vec[l]), LogBeginTime ); - - l = ((sint)vec.size())-1; - quicklines = max( ((sint)vec.size())-100, 0 ); - while ( (l >= quicklines) && ((string(vec[l]).size()<5) || (vec[l][4] != '/')) ) - --l; - if ( l >= quicklines ) - extractTime( string(vec[l]), LogEndTime ); - } - res += "Log begin time\t\t" + timeToStr( LogBeginTime ) + "\r\n"; - res += "Log end time\t\t" + timeToStr( LogEndTime ) + "\r\n"; - MainStats += timeToStr( LogEndTime ); - TotalTimeInDays = ((float)(LogEndTime-LogBeginTime)) / 3600.0f / 24.0f; - - // Scan sessions - uint nbPossibleCorruptions = 0; - uint i; - for ( i=0; i!=vec.size(); ++i ) - { - string line = string(vec[i]); - time_t ts; - uint clientId; - uint userId; - string::size_type p; - - // Auto-detect file corruption (version for connections.stat) - if ( !line.empty() ) - { - bool corrupted = false; - - // Search for beginning not being a date or 'Log Starting" - if ( (line.size() < 20) || (line[10]!=' ') || (line[13]!=':') - || (line[16]!=':') || (line[19]!=' ') || (line.substr( 20 ).find( " : ") == string::npos ) ) - { - if ( line.find( "Log Starting [" ) != 0 ) - corrupted = true; - } - else - { - // Search for year not at beginning. Ex: "2003/" (it does not work when the year changes in the log!) - p = line.substr( 1 ).find( timeToStr( LogBeginTime ).substr( 0, 5 ) ); - if ( p != string::npos ) - { - ++p; // because searched from pos 1 - - // Search for date/time - if ( (line.size()>p+20) && (line[p+10]==' ') && (line[p+13]==':') - && (line[p+16]==':') && (line[p+19]==' ') ) - { - // Search for the two next blank characters. The second is followed by ": ". - // (Date Time ThreadId Machine/Service : User-defined log line) - uint nbBlank = 0; - string::size_type sp; - for ( sp=p+20; sp!=line.size(); ++sp ) - { - if ( line[sp]==' ') - ++nbBlank; - if ( nbBlank==2 ) - break; - } - if ( (nbBlank==2) && (line[sp+1]==':') && (line[sp+2]==' ') ) - { - corrupted = true; - } - } - } - } - if ( corrupted ) - { - ++nbPossibleCorruptions; - nlwarning( "Found possible file corruption at line %u: %s", i, line.c_str() ); - } - } - - // Detect connections/disconnections - p = line.find( "Adding client" ); - if ( p != string::npos ) - { - extractTime( line, ts ); - char name [200]; - sscanf( line.substr( p ).c_str(), "Adding client %u (uid %u name %s", &clientId, &userId, &name ); - string sname = name; - addConnection( ts, clientId, userId, sname /*sname.substr( 0, sname.size()-1 )*/ ); // now name format is "name priv ''". - continue; - } - p = line.find( "Sent CL_DISCONNECT for client" ); - if ( p != string::npos ) - { - extractTime( line, ts ); - sscanf( line.substr( p ).c_str(), "Sent CL_DISCONNECT for client %u (uid %u)", &clientId, &userId ); - addDisconnection( ts, clientId, userId ); - continue; - } - p = line.find( "Log Starting [" ); - if ( p != string::npos ) - { - uint hs = string("Log Starting [").size(); - line = line.substr( hs, line.size() - hs - 1 ); // remove ] to get the timestamp - time_t restartTs; - extractTime( line, restartTs ); - // Go back to find the last time of log - sint quicklines = max( ((sint)i)-10, 0 ); - sint l = ((sint)i)-1; - while ( (l >= quicklines) && ((string(vec[l]).size()<5) || (vec[l][4] != '/')) ) - l--; - if ( l >= quicklines ) - extractTime( vec[l], ts ); - else - ts = restartTs; - resetConnections( ts, restartTs ); - } - } - fillUserNamesInEvents(); - - // Session durations - string sd; - uint maxNbSession = getSessionDurations( sd, LogEndTime, true, false ); - res += "Number of accounts\t" + toString( "%u", PlayerMap.size() ) + "\r\n"; - res += "Max number of session\t" + toString( "%u", maxNbSession ) + "\r\n"; - res += "\r\nTime of sessions\r\n"; - res += sd; - res += "Connection events\r\n"; - MainStats += toString( "\t%u", PlayerMap.size() ); - - // Timetable - time_t prevTimestamp = 0; - sint durationSum = 0; - int prevPlayerNb = -1; - uint maxPlayerNb = 0; - for ( i=0; i!=NbPlayersSeries.size(); ++i ) - { - sint duration = (prevTimestamp!=0) ? (int)difftime( NbPlayersSeries[i].Timestamp, prevTimestamp ) : 0; - prevTimestamp = NbPlayersSeries[i].Timestamp; - durationSum += duration; - if ( prevPlayerNb != -1 ) - res += "\t" + toString( "%d", durationSum ) + "\t" + timeToStr( NbPlayersSeries[i].Timestamp ) + "\t" + toString( "%u", prevPlayerNb ) + "\t" + "\r\n"; - res += toString( "%d", duration ) + "\t" + toString( "%d", durationSum ) + "\t" + timeToStr( NbPlayersSeries[i].Timestamp ) + "\t" + toString( "%u", NbPlayersSeries[i].Nb ) + "\t" + NbPlayersSeries[i].Event + "\r\n"; - prevPlayerNb = NbPlayersSeries[i].Nb; - if ( NbPlayersSeries[i].Nb > maxPlayerNb ) - maxPlayerNb = NbPlayersSeries[i].Nb; - } - MainStats += toString( "\t%u", maxPlayerNb ) + toString( "\t\t(%g days)", TotalTimeInDays ); - if ( nbPossibleCorruptions == 0 ) - MainStats += toString( "\t\tStat file OK" ); - else - MainStats += toString( "\t\tFound %u possible stat file corruptions (edit the stat file to replace them with server reset if time too long, see log.log)", nbPossibleCorruptions ); - - // Stats per user - res += "\r\n\nStats per user (hrs)\r\n\nName\tUserId\tSessions\tCumulated\tAverage\tMin\tMax"; - for ( TPlayerMap::const_iterator ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) - { - res += "\r\n\n"; - const TPlayerStat& playerStat = (*ipm).second; - res += toString( "%s\tUser %u\t%u\t%s\t%s\t%s\t%s", - playerStat.Name.c_str(), playerStat.UserId, playerStat.Sessions.size(), - toHourStr(playerStat.Sum).c_str(), toHourStr(playerStat.Average).c_str(), toHourStr(playerStat.Min).c_str(), toHourStr(playerStat.Max).c_str() ); - for ( uint i=0; i!=playerStat.Sessions.size(); ++i ) - { - res += "\r\n"; - const TSession& sess = playerStat.Sessions[i]; - string status = sess.Closed ? "OK" : "Not closed"; - res += timeToStr( sess.BeginTime ) + "\t" + timeToStr( sess.EndTime ) + "\t" + status + "\t" + toHourStr( sess.Duration ); - } - } - - string dateStr = " " + extractDateFilename( LogEndTime ); - res = dateStr + "\r\nDate\tAvg per player\tTotal time\tMax per player\tNb Players\tSimult. Pl.\r\n" + MainStats + "\r\n" + res; - - memdisp.write( log ); - return true; -} - - - -/*CString s; -s.Format( "Found C=%u U=%u N=%s in %s", clientId, userId, name, line.substr( p ).c_str() ); +// 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 . + +// connection_stats.cpp : Defines the entry point for the DLL application. +// + +#include "stdafx.h" + +#define LOG_ANALYSER_PLUGIN_EXPORTS +#include "connection_stats.h" + +#include + + +BOOL APIENTRY DllMain( HANDLE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved + ) +{ + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + break; + } + return TRUE; +} + + +#include +using namespace NLMISC; + + +#include +#include +using namespace std; + + +time_t LogBeginTime = 0, LogEndTime = 0; +bool ContinuationOfStatInPreviousFile = true; + + +// +string timeToStr( const time_t& ts ) +{ + //return string(ctime( &ts )).substr( 0, 24 ); + return IDisplayer::dateToHumanString( ts ); +} + + +// +string toHourStr( uint totalSec ) +{ + uint hour = totalSec / 3600; + uint remMin = totalSec % 3600; + string res = toString( "%uh%02u'%02u\"", hour, remMin / 60, remMin % 60 ); + return res; +} + + +/* + * + */ +struct TSession +{ + uint ClientId; + time_t BeginTime; + time_t EndTime; + time_t Duration; + bool Closed; +}; + + +/* + * + */ +struct TPlayerStat +{ + uint UserId; + string Name; + vector Sessions; + uint Average; + uint Sum; + uint Min; + uint Max; + + /// + TPlayerStat() : UserId(0), Name("?"), Average(0), Sum(0), Min(0), Max(0) {} + + /// + bool beginSession( const time_t& ts, uint clientId, uint userId, const string& name ) + { + if ( Sessions.empty() || (Name == "?") ) + { + init( userId, name ); + } + + if ( Sessions.empty() || (Sessions.back().EndTime != 0) ) + { + // Open a new session + TSession s; + s.ClientId = clientId; + s.BeginTime = ts; + s.EndTime = 0; + s.Closed = false; + Sessions.push_back( s ); + return true; + } + else + { + // Occurs if two clients have the same userId + nlwarning( "Opening a session for user %u (%s) at %s while previous session at %s not closed", UserId, Name.c_str(), timeToStr( ts ).c_str(), timeToStr( Sessions.back().BeginTime ).c_str() ); + //Sessions.back().ClientId = clientId; // cumulate times + //return false; + + // Close the previous session + bool userMissing; + endSession( ts, Sessions.back().ClientId, userId, name, &userMissing, false ); + + // Open a new session + TSession s; + s.ClientId = clientId; + s.BeginTime = ts; + s.EndTime = 0; + s.Closed = false; + Sessions.push_back( s ); + return false; + + } + } + + /** + * Return true if the disconnection is valid, false if ignored. If true, set userMissing if connection of user not found in the log + * but was done before writing into this stat file. + */ + bool endSession( const time_t& ts, uint clientId, uint userId, const string& name, bool *userMissing, bool closed=true ) + { + if ( Sessions.empty() || (Name == "?") ) + { + init( userId, name ); + } + + if ( Sessions.empty() ) + { + // User was already connected at beginning of log + if ( ContinuationOfStatInPreviousFile ) + { + nldebug( "User %u (%s): disconnection at %s: connection before beginning of stat detected", userId, name.c_str(), timeToStr( ts ).c_str() ); + TSession s; + s.ClientId = clientId; + s.BeginTime = 0; + s.EndTime = ts; + s.Closed = closed; + Sessions.push_back( s ); + *userMissing = true; + return true; + } + else + { + nldebug( "User %u (%s): ignoring disconnection at %s (could not be connected before stat)", userId, name.c_str(), timeToStr( ts ).c_str() ); + return false; + } + } + else + { + // Close the current session + if ( clientId == Sessions.back().ClientId ) + { + if ( Sessions.back().EndTime == 0 ) + { + Sessions.back().EndTime = ts; + Sessions.back().Closed = closed; + *userMissing = false; + return true; + } + else + { + nlwarning( "Detected two successive disconnections of user %u (%s) without reconnection (second ignored) at %s", userId, name.c_str(), timeToStr( ts ).c_str() ); + return false; + } + } + else + { + // Occurs if two clients have the same userId + nlwarning( "Closing a session for user %u (%s) with invalid client (ignored)", userId, name.c_str() ); + return false; + } + } + } + + /// + sint calcSessionTime( uint numSession, const time_t& testEndTime ) + { + if ( numSession < Sessions.size() ) + { + if ( Sessions[numSession].BeginTime == 0 ) + { + Sessions[numSession].BeginTime = LogBeginTime; + nlinfo( "User %u %s already connected at beginning of log (session end at %s)", UserId, Name.c_str(), timeToStr( Sessions[numSession].EndTime ).c_str() ); + } + if ( Sessions[numSession].EndTime == 0 ) + { + Sessions[numSession].EndTime = LogEndTime; + nlinfo( "User %u %s still connected at end of log (session begin at %s)", UserId, Name.c_str(), timeToStr( Sessions[numSession].BeginTime ).c_str() ); + } + + Sessions[numSession].Duration = (int)difftime( Sessions[numSession].EndTime, Sessions[numSession].BeginTime ); + return Sessions[numSession].Duration; + } + else + return 0; + } + +private: + + /// + void init( uint userId, const string& name ) + { + UserId = userId; + Name = name; + } + +}; + + +/* + * + */ +struct TInstantNbPlayers +{ + uint Nb; + time_t Timestamp; + uint UserId; + string Event; +}; + + +/* + * + */ +typedef std::map< uint, TPlayerStat > TPlayerMap; +typedef std::deque< TInstantNbPlayers > TNbPlayersSeries; +TPlayerMap PlayerMap; +TNbPlayersSeries NbPlayersSeries; +uint NbPlayers; +string MainStats; +float TotalTimeInDays; + + +/// +void resetAll() +{ + LogBeginTime = 0; + LogEndTime = 0; + PlayerMap.clear(); + NbPlayersSeries.clear(); + NbPlayers = 0; + MainStats = ""; +} + + +/// +void addConnectionEvent( const time_t& ts, uint userId ) +{ + ++NbPlayers; + TInstantNbPlayers inp; + inp.UserId = userId; + inp.Event = "+"; + if ( ts != 0 ) + { + inp.Nb = NbPlayers; + inp.Timestamp = ts; + NbPlayersSeries.push_back( inp ); + } + else + { + nldebug( "Inserting connection of user %u at beginning", userId ); + // Insert at front and increment every other number + for ( TNbPlayersSeries::iterator iv=NbPlayersSeries.begin(); iv!=NbPlayersSeries.end(); ++iv ) + ++(*iv).Nb; + inp.Nb = 1; + inp.Timestamp = LogBeginTime; + NbPlayersSeries.push_front( inp ); + } +} + + +/// +void addDisconnectionEvent( const time_t& ts, uint userId ) +{ + --NbPlayers; + TInstantNbPlayers inp; + inp.Nb = NbPlayers; + inp.Timestamp = ts; + inp.UserId = userId; + inp.Event = "-"; + NbPlayersSeries.push_back( inp ); +} + + +/// +void addConnection( const time_t& ts, uint clientId, uint userId, const string& name ) +{ + if ( PlayerMap[userId].beginSession( ts, clientId, userId, name ) ) + { + addConnectionEvent( ts, userId ); + } +} + + +/// +void addDisconnection( const time_t& ts, uint clientId, uint userId ) +{ + bool userMissing; + if ( PlayerMap[userId].endSession( ts, clientId, userId, "?", &userMissing ) ) + { + if ( userMissing ) + { + // Add connection at beginning if the server was started at a date anterior to the beginning of this stat file + // (otherwise, just discard the disconnection, it could be a stat file corruption transformed + // into server reset) + addConnectionEvent( 0, userId ); + } + + addDisconnectionEvent( ts, userId ); + } +} + + +/// +void resetConnections( const time_t& shutdownTs, const time_t& restartTs ) +{ + ContinuationOfStatInPreviousFile = false; + + TPlayerMap::iterator ipm; + for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) + { + if ( ! (*ipm).second.Sessions.empty() ) + { + if ( (*ipm).second.Sessions.back().EndTime == 0 ) + { + addDisconnection( shutdownTs, (*ipm).second.Sessions.back().ClientId, (*ipm).second.UserId ); + nlwarning( "Resetting connection of user %u because of server shutdown at %s (restart at %s)", (*ipm).second.UserId, timeToStr( shutdownTs ).c_str(), timeToStr( restartTs ).c_str() ); + } + } + } +} + + +/// +void fillUserNamesInEvents() +{ + TNbPlayersSeries::iterator iv; + for ( iv=NbPlayersSeries.begin(); iv!=NbPlayersSeries.end(); ++iv ) + { + (*iv).Event += PlayerMap[(*iv).UserId].Name; + } +} + + +/// +void extractTime( const string& line, time_t& ts ) +{ + struct tm t; + t.tm_isdst = -1; // auto-detect Daylight Saving Time + t.tm_wday = 0; + t.tm_yday = 0; + sscanf( line.c_str(), "%d/%d/%d %d:%d:%d", &t.tm_year, &t.tm_mon, &t.tm_mday, &t.tm_hour, &t.tm_min, &t.tm_sec ); + t.tm_year -= 1900; + t.tm_mon -= 1; // 0..11 + + ts = mktime( &t ); + if ( ts == (time_t)-1 ) + { + /*CString s; + s.Format( "%d/%d/%d %d:%d:%d (%d)", t.tm_year, t.tm_mon, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec, ts ); + AfxMessageBox( s );* + exit(-1);*/ + ts = 0; + } +} + + +/// +void calcStats( string& res ) +{ + TPlayerMap::iterator ipm; + for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) + { + uint sum = 0, themax = 0, themin = ~0; + for ( uint i = 0; i!=(*ipm).second.Sessions.size(); ++i ) + { + sum += (*ipm).second.Sessions[i].Duration; + if ( (uint)(*ipm).second.Sessions[i].Duration < themin ) + themin = (*ipm).second.Sessions[i].Duration; + if ( (uint)(*ipm).second.Sessions[i].Duration > themax ) + themax = (*ipm).second.Sessions[i].Duration; + } + (*ipm).second.Sum = sum; + (*ipm).second.Average = sum / (*ipm).second.Sessions.size(); + (*ipm).second.Min = themin; + (*ipm).second.Max = themax; + } +} + + +// Return date for filename such as 2003-06-24 +string extractDateFilename( time_t date ) +{ + string dateStr = timeToStr( date ); + string::size_type pos; + for ( pos=0; pos!=dateStr.size(); ++pos ) + { + if ( dateStr[pos] == '/' ) + dateStr[pos] = '-'; + if ( dateStr[pos] == ' ' ) + { + dateStr = dateStr.substr( 0, pos ); + break; + } + } + return dateStr; + + /*// Revert date + string::size_type slashPos = dateStr.rfind( '/' ); + if ( slashPos == string::npos ) + return ""; + string year = dateStr.substr( slashPos+1, slashPos+5 ); + slashPos = dateStr.rfind( '/', slashPos-1 ); + if ( slashPos == string::npos ) + return ""; + string month = dateStr.substr( slashPos+1, slashPos+3 ); + string day = dateStr.substr( 0, 2 ); + return year + "-" + month + "-" + day;*/ +} + + +enum TMainStatEnum { MSNb, MSAverage, MSSum, MSMin, MSMax }; + + +/// Return stats in float 'days' +void getValuesStatsAndClearValues( vector& values, string& res, bool isTimeInMinute, TMainStatEnum msEnum ) +{ + float sum = 0.0f, themax = 0.0f, themin = 60.0f*24.0f*365.25f*100.0f; // 1 century should be enough + vector::const_iterator iv; + for ( iv=values.begin(); iv!=values.end(); ++iv ) + { + sum += (*iv); + if ( (*iv) < themin ) + themin = (*iv); + if ( (*iv) > themax ) + themax = (*iv); + } + if ( isTimeInMinute ) + { + res += toString( "\t%g", sum / (float)values.size() / (24.0f*60.0f) ) + + toString( "\t%g", sum / (24.0f*60.0f) ) + + toString( "\t%g", themin / (24.0f*60.0f) ) + + toString( "\t%g", themax / (24.0f*60.0f) ); + switch( msEnum ) + { + case MSAverage: + break; + case MSSum: + MainStats += toString( "\t%g", sum / (float)values.size() / (24.0f*60.0f) / TotalTimeInDays ) + + toString( "\t%g", sum / (24.0f*60.0f) / TotalTimeInDays ) + + toString( "\t%g", themax / (24.0f*60.0f) / TotalTimeInDays ); + break; + case MSMax: + break; + default: + break; + } + + } + else + { + res += "\t" + toString( "%g", sum / (float)values.size() ) + + "\t" + toString( "%g", sum ) + + "\t" + toString( "%g", themin ) + + "\t" + toString( "%g", themax ); + } + values.clear(); +} + + +/// Return stats in float 'days' +void getValuesStatsAndClearValues( vector& values, vector< vector >& table, bool isTimeInMinute, TMainStatEnum msEnum ) +{ + float sum = 0.0f, themax = 0.0f, themin = 60.0f*24.0f*365.25f*100.0f; // 1 century should be enough + vector::const_iterator iv; + for ( iv=values.begin(); iv!=values.end(); ++iv ) + { + sum += (*iv); + if ( (*iv) < themin ) + themin = (*iv); + if ( (*iv) > themax ) + themax = (*iv); + } + if ( isTimeInMinute ) + { + table.back().push_back( toString( "%g", sum / (float)values.size() / (24.0f*60.0f) ) ); + table.back().push_back( toString( "%g", sum / (24.0f*60.0f) ) ); + table.back().push_back( toString( "%g", themin / (24.0f*60.0f) ) ); + table.back().push_back( toString( "%g", themax / (24.0f*60.0f) ) ); + switch( msEnum ) + { + case MSAverage: + break; + case MSSum: + MainStats += toString( "\t%g", sum / (float)values.size() / (24.0f*60.0f) / TotalTimeInDays ) + + toString( "\t%g", sum / (24.0f*60.0f) / TotalTimeInDays ) + + toString( "\t%g", themax / (24.0f*60.0f) / TotalTimeInDays ); + break; + case MSMax: + break; + default: + break; + } + + } + else + { + table.back().push_back( toString( "%g", sum / (float)values.size() ) ); + table.back().push_back( toString( "%g", sum ) ); + table.back().push_back( toString( "%g", themin ) ); + table.back().push_back( toString( "%g", themax ) ); + } + values.clear(); +} + + +/// (Note: main stats only for minutes) +uint getSessionDurations( string& res, time_t endTime, bool convertToMinutes, bool inColumnsWithDetail ) +{ + uint sessionNum = 0; + if ( inColumnsWithDetail ) + { + string s1, s2; + TPlayerMap::iterator ipm; + for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) + { + s1 += toString( "%u", (*ipm).second.UserId ) + "\t"; + s2 += (*ipm).second.Name + "\t"; + } + res += s1 + "\r\n" + s2 + "\r\n"; + sint timeSum; + do + { + timeSum = 0; + for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) + { + sint duration = (*ipm).second.calcSessionTime( sessionNum, endTime ); + if ( duration != 0 ) + { + res += (convertToMinutes ? toString( "%.2f", (float)duration/60.0f ) : toString( "%d", duration )) + "\t"; + } + else + { + res += string(convertToMinutes ? "0" : "") + "\t"; + } + timeSum += duration; + } + res += "\r\n"; + + ++sessionNum; + } + while ( timeSum != 0 ); + res += "\r\n"; + + calcStats( res ); + + if ( ! convertToMinutes) + { + // Stats + for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) + { + res += toString( "%u\t", (*ipm).second.Sessions.size() ); + } + res += "\r\n"; + for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) + { + res += toString( "%u\t", (*ipm).second.Average ); + } + res += "\r\n"; + for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) + { + res += toString( "%u\t", (*ipm).second.Sum ); + } + res += "\r\n"; + for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) + { + res += toString( "%u\t", (*ipm).second.Min ); + } + res += "\r\n"; + for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) + { + res += toString( "%u\t", (*ipm).second.Max ); + } + res += "\r\n"; + } + else + { + // Stats + vector values; + for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) + { + values.push_back( (float)((*ipm).second.Sessions.size()) ); + res += toString( "%u\t", (*ipm).second.Sessions.size() ); + } + getValuesStatsAndClearValues( values, res, false, MSNb ); + res += "\r\n"; + for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) + { + values.push_back( (float)((*ipm).second.Average)/60.0f ); + res += toString( "%.2f\t", values.back() ); + } + getValuesStatsAndClearValues( values, res, true, MSAverage ); + res += "\r\n"; + for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) + { + values.push_back( (float)((*ipm).second.Sum)/60.0f ); + res += toString( "%.2f\t", values.back() ); + } + getValuesStatsAndClearValues( values, res, true, MSSum ); + res += "\r\n"; + for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) + { + values.push_back( (float)((*ipm).second.Min)/60.0f ); + res += toString( "%.2f\t", values.back() ); + } + getValuesStatsAndClearValues( values, res, true, MSMin ); + res += "\r\n"; + for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) + { + values.push_back( (float)((*ipm).second.Max)/60.0f ); + res += toString( "%.2f\t", values.back() ); + } + getValuesStatsAndClearValues( values, res, true, MSMax ); + res += "\r\n"; + } + } + else + { + vector< vector > table; + + string s1, s2; + table.push_back(); + table.push_back(); + TPlayerMap::iterator ipm; + for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) + { + table[0].push_back( toString( "%u", (*ipm).second.UserId ) ); //+ "\t"; + table[1].push_back( (*ipm).second.Name ); //+ "\t"; + } + //res += s1 + "\r\n" + s2 + "\r\n"; + sint timeSum; + do + { + timeSum = 0; + for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) + { + sint duration = (*ipm).second.calcSessionTime( sessionNum, endTime ); + timeSum += duration; + } + ++sessionNum; + } + while ( timeSum != 0 ); + table.push_back(); + //res += "\r\n"; + + calcStats( res ); + + if ( ! convertToMinutes) + { + // Stats + table.push_back(); + for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) + { + table.back().push_back( toString( "%u", (*ipm).second.Sessions.size() ) ); + } + //res += "\r\n"; + table.push_back(); + for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) + { + table.back().push_back( toString( "%u", (*ipm).second.Average ) ); + } + //res += "\r\n"; + table.push_back(); + for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) + { + table.back().push_back( toString( "%u", (*ipm).second.Sum ) ); + } + //res += "\r\n"; + table.push_back(); + for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) + { + table.back().push_back( toString( "%u", (*ipm).second.Min ) ); + } + //res += "\r\n"; + table.push_back(); + for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) + { + table.back().push_back( toString( "%u", (*ipm).second.Max ) ); + } + //res += "\r\n"; + } + else + { + // Stats + vector values; + table.push_back(); + for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) + { + values.push_back( (float)((*ipm).second.Sessions.size()) ); + table.back().push_back( toString( "%u", (*ipm).second.Sessions.size() ) ); + } + getValuesStatsAndClearValues( values, table, false, MSNb ); + //res += "\r\n"; + table.push_back(); + for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) + { + values.push_back( (float)((*ipm).second.Average)/60.0f ); + table.back().push_back( toString( "%.2f", values.back() ) ); + } + getValuesStatsAndClearValues( values, table, true, MSAverage ); + //res += "\r\n"; + table.push_back(); + for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) + { + values.push_back( (float)((*ipm).second.Sum)/60.0f ); + table.back().push_back( toString( "%.2f", values.back() ) ); + } + getValuesStatsAndClearValues( values, table, true, MSSum ); + //res += "\r\n"; + table.push_back(); + for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) + { + values.push_back( (float)((*ipm).second.Min)/60.0f ); + table.back().push_back( toString( "%.2f", values.back() ) ); + } + getValuesStatsAndClearValues( values, table, true, MSMin ); + //res += "\r\n"; + table.push_back(); + for ( ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) + { + values.push_back( (float)((*ipm).second.Max)/60.0f ); + table.back().push_back( toString( "%.2f", values.back() ) ); + } + getValuesStatsAndClearValues( values, table, true, MSMax ); + //res += "\r\n"; + } + + // Print in column + /*for ( uint j=0; j!=table.size(); ++j ) + { + for ( uint i=0; i!=table[j].size(); ++i ) + { + res += table[j][i] + "\t"; + } + res += "\r\n"; + }*/ + + // Print in row + uint maxI = 0; + for ( uint j=0; j!=table.size(); ++j ) + { + if ( table[j].size() > maxI ) + maxI = table[j].size(); + } + for ( uint i=0; i!=maxI; ++i ) + { + for ( uint j=0; j!=table.size(); ++j ) + { + if ( i < table[j].size() ) + res += table[j][i] + "\t"; + else + res += "\t"; + } + res += "\r\n"; + } + } + + res += "\r\n"; + + return sessionNum; +} + + +/* + * + */ +LOG_ANALYSER_PLUGIN_API std::string getInfoString() +{ + return "Input log: connection.stat or frontend_service.log.\n\nProduces tab-separated connection stats for Excel."; +} + + +/* + * + */ +LOG_ANALYSER_PLUGIN_API bool doAnalyse( const std::vector& vec, std::string& res, std::string& log ) +{ + NLMISC::createDebug(); + CMemDisplayer memdisp; + NLMISC::DebugLog->addDisplayer( &memdisp, true ); + NLMISC::InfoLog->addDisplayer( &memdisp, true ); + NLMISC::WarningLog->addDisplayer( &memdisp, true ); + NLMISC::ErrorLog->addDisplayer( &memdisp, true ); + NLMISC::AssertLog->addDisplayer( &memdisp, true ); + + resetAll(); + + // Begin and end time + if ( ! vec.empty() ) + { + sint l = 0; + sint quicklines = min( vec.size(), 100 ); + while ( (l < quicklines) && ((string(vec[l]).size()<5) || (vec[l][4] != '/')) ) + ++l; + if ( l < quicklines ) + extractTime( string(vec[l]), LogBeginTime ); + + l = ((sint)vec.size())-1; + quicklines = max( ((sint)vec.size())-100, 0 ); + while ( (l >= quicklines) && ((string(vec[l]).size()<5) || (vec[l][4] != '/')) ) + --l; + if ( l >= quicklines ) + extractTime( string(vec[l]), LogEndTime ); + } + res += "Log begin time\t\t" + timeToStr( LogBeginTime ) + "\r\n"; + res += "Log end time\t\t" + timeToStr( LogEndTime ) + "\r\n"; + MainStats += timeToStr( LogEndTime ); + TotalTimeInDays = ((float)(LogEndTime-LogBeginTime)) / 3600.0f / 24.0f; + + // Scan sessions + uint nbPossibleCorruptions = 0; + uint i; + for ( i=0; i!=vec.size(); ++i ) + { + string line = string(vec[i]); + time_t ts; + uint clientId; + uint userId; + string::size_type p; + + // Auto-detect file corruption (version for connections.stat) + if ( !line.empty() ) + { + bool corrupted = false; + + // Search for beginning not being a date or 'Log Starting" + if ( (line.size() < 20) || (line[10]!=' ') || (line[13]!=':') + || (line[16]!=':') || (line[19]!=' ') || (line.substr( 20 ).find( " : ") == string::npos ) ) + { + if ( line.find( "Log Starting [" ) != 0 ) + corrupted = true; + } + else + { + // Search for year not at beginning. Ex: "2003/" (it does not work when the year changes in the log!) + p = line.substr( 1 ).find( timeToStr( LogBeginTime ).substr( 0, 5 ) ); + if ( p != string::npos ) + { + ++p; // because searched from pos 1 + + // Search for date/time + if ( (line.size()>p+20) && (line[p+10]==' ') && (line[p+13]==':') + && (line[p+16]==':') && (line[p+19]==' ') ) + { + // Search for the two next blank characters. The second is followed by ": ". + // (Date Time ThreadId Machine/Service : User-defined log line) + uint nbBlank = 0; + string::size_type sp; + for ( sp=p+20; sp!=line.size(); ++sp ) + { + if ( line[sp]==' ') + ++nbBlank; + if ( nbBlank==2 ) + break; + } + if ( (nbBlank==2) && (line[sp+1]==':') && (line[sp+2]==' ') ) + { + corrupted = true; + } + } + } + } + if ( corrupted ) + { + ++nbPossibleCorruptions; + nlwarning( "Found possible file corruption at line %u: %s", i, line.c_str() ); + } + } + + // Detect connections/disconnections + p = line.find( "Adding client" ); + if ( p != string::npos ) + { + extractTime( line, ts ); + char name [200]; + sscanf( line.substr( p ).c_str(), "Adding client %u (uid %u name %s", &clientId, &userId, &name ); + string sname = name; + addConnection( ts, clientId, userId, sname /*sname.substr( 0, sname.size()-1 )*/ ); // now name format is "name priv ''". + continue; + } + p = line.find( "Sent CL_DISCONNECT for client" ); + if ( p != string::npos ) + { + extractTime( line, ts ); + sscanf( line.substr( p ).c_str(), "Sent CL_DISCONNECT for client %u (uid %u)", &clientId, &userId ); + addDisconnection( ts, clientId, userId ); + continue; + } + p = line.find( "Log Starting [" ); + if ( p != string::npos ) + { + uint hs = string("Log Starting [").size(); + line = line.substr( hs, line.size() - hs - 1 ); // remove ] to get the timestamp + time_t restartTs; + extractTime( line, restartTs ); + // Go back to find the last time of log + sint quicklines = max( ((sint)i)-10, 0 ); + sint l = ((sint)i)-1; + while ( (l >= quicklines) && ((string(vec[l]).size()<5) || (vec[l][4] != '/')) ) + l--; + if ( l >= quicklines ) + extractTime( vec[l], ts ); + else + ts = restartTs; + resetConnections( ts, restartTs ); + } + } + fillUserNamesInEvents(); + + // Session durations + string sd; + uint maxNbSession = getSessionDurations( sd, LogEndTime, true, false ); + res += "Number of accounts\t" + toString( "%u", PlayerMap.size() ) + "\r\n"; + res += "Max number of session\t" + toString( "%u", maxNbSession ) + "\r\n"; + res += "\r\nTime of sessions\r\n"; + res += sd; + res += "Connection events\r\n"; + MainStats += toString( "\t%u", PlayerMap.size() ); + + // Timetable + time_t prevTimestamp = 0; + sint durationSum = 0; + int prevPlayerNb = -1; + uint maxPlayerNb = 0; + for ( i=0; i!=NbPlayersSeries.size(); ++i ) + { + sint duration = (prevTimestamp!=0) ? (int)difftime( NbPlayersSeries[i].Timestamp, prevTimestamp ) : 0; + prevTimestamp = NbPlayersSeries[i].Timestamp; + durationSum += duration; + if ( prevPlayerNb != -1 ) + res += "\t" + toString( "%d", durationSum ) + "\t" + timeToStr( NbPlayersSeries[i].Timestamp ) + "\t" + toString( "%u", prevPlayerNb ) + "\t" + "\r\n"; + res += toString( "%d", duration ) + "\t" + toString( "%d", durationSum ) + "\t" + timeToStr( NbPlayersSeries[i].Timestamp ) + "\t" + toString( "%u", NbPlayersSeries[i].Nb ) + "\t" + NbPlayersSeries[i].Event + "\r\n"; + prevPlayerNb = NbPlayersSeries[i].Nb; + if ( NbPlayersSeries[i].Nb > maxPlayerNb ) + maxPlayerNb = NbPlayersSeries[i].Nb; + } + MainStats += toString( "\t%u", maxPlayerNb ) + toString( "\t\t(%g days)", TotalTimeInDays ); + if ( nbPossibleCorruptions == 0 ) + MainStats += toString( "\t\tStat file OK" ); + else + MainStats += toString( "\t\tFound %u possible stat file corruptions (edit the stat file to replace them with server reset if time too long, see log.log)", nbPossibleCorruptions ); + + // Stats per user + res += "\r\n\nStats per user (hrs)\r\n\nName\tUserId\tSessions\tCumulated\tAverage\tMin\tMax"; + for ( TPlayerMap::const_iterator ipm=PlayerMap.begin(); ipm!=PlayerMap.end(); ++ipm ) + { + res += "\r\n\n"; + const TPlayerStat& playerStat = (*ipm).second; + res += toString( "%s\tUser %u\t%u\t%s\t%s\t%s\t%s", + playerStat.Name.c_str(), playerStat.UserId, playerStat.Sessions.size(), + toHourStr(playerStat.Sum).c_str(), toHourStr(playerStat.Average).c_str(), toHourStr(playerStat.Min).c_str(), toHourStr(playerStat.Max).c_str() ); + for ( uint i=0; i!=playerStat.Sessions.size(); ++i ) + { + res += "\r\n"; + const TSession& sess = playerStat.Sessions[i]; + string status = sess.Closed ? "OK" : "Not closed"; + res += timeToStr( sess.BeginTime ) + "\t" + timeToStr( sess.EndTime ) + "\t" + status + "\t" + toHourStr( sess.Duration ); + } + } + + string dateStr = " " + extractDateFilename( LogEndTime ); + res = dateStr + "\r\nDate\tAvg per player\tTotal time\tMax per player\tNb Players\tSimult. Pl.\r\n" + MainStats + "\r\n" + res; + + memdisp.write( log ); + return true; +} + + + +/*CString s; +s.Format( "Found C=%u U=%u N=%s in %s", clientId, userId, name, line.substr( p ).c_str() ); AfxMessageBox( s );*/ \ No newline at end of file diff --git a/code/ryzom/tools/connection_stats/connection_stats.h b/code/ryzom/tools/connection_stats/connection_stats.h index d745a0cfb..fd5feae9c 100644 --- a/code/ryzom/tools/connection_stats/connection_stats.h +++ b/code/ryzom/tools/connection_stats/connection_stats.h @@ -1,42 +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 CONNECTION_STATS_H -#define CONNECTION_STATS_H - -#include -#include -#include - - -// The following ifdef block is the standard way of creating macros which make exporting -// from a DLL simpler. All files within this DLL are compiled with the CONNECTION_STATS_EXPORTS -// symbol defined on the command line. this symbol should not be defined on any project -// that uses this DLL. This way any other project whose source files include this file see -// CONNECTION_STATS_API functions as being imported from a DLL, wheras this DLL sees symbols -// defined with this macro as being exported. -#ifdef LOG_ANALYSER_PLUGIN_EXPORTS -#define LOG_ANALYSER_PLUGIN_API __declspec(dllexport) -#else -#define LOG_ANALYSER_PLUGIN_API __declspec(dllimport) -#endif - - -LOG_ANALYSER_PLUGIN_API std::string getInfoString(); -LOG_ANALYSER_PLUGIN_API bool doAnalyse( const std::vector& vec, std::string& res, std::string& log ); - +// 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 CONNECTION_STATS_H +#define CONNECTION_STATS_H + +#include +#include +#include + + +// The following ifdef block is the standard way of creating macros which make exporting +// from a DLL simpler. All files within this DLL are compiled with the CONNECTION_STATS_EXPORTS +// symbol defined on the command line. this symbol should not be defined on any project +// that uses this DLL. This way any other project whose source files include this file see +// CONNECTION_STATS_API functions as being imported from a DLL, wheras this DLL sees symbols +// defined with this macro as being exported. +#ifdef LOG_ANALYSER_PLUGIN_EXPORTS +#define LOG_ANALYSER_PLUGIN_API __declspec(dllexport) +#else +#define LOG_ANALYSER_PLUGIN_API __declspec(dllimport) +#endif + + +LOG_ANALYSER_PLUGIN_API std::string getInfoString(); +LOG_ANALYSER_PLUGIN_API bool doAnalyse( const std::vector& vec, std::string& res, std::string& log ); + #endif \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/alias_synchronizer/alias_synchronizer.cpp b/code/ryzom/tools/leveldesign/alias_synchronizer/alias_synchronizer.cpp index 7653c964c..c080fd038 100644 --- a/code/ryzom/tools/leveldesign/alias_synchronizer/alias_synchronizer.cpp +++ b/code/ryzom/tools/leveldesign/alias_synchronizer/alias_synchronizer.cpp @@ -1,409 +1,409 @@ -// 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/types_nl.h" -#include "nel/misc/config_file.h" -#include "nel/misc/path.h" -#include "nel/ligo/primitive.h" -#include "nel/ligo/ligo_config.h" -#include "nel/ligo/primitive_utils.h" -#include "nel/misc/algo.h" - -using namespace std; -using namespace NLMISC; -using namespace NLLIGO; - -CLigoConfig LigoConfig; - -vector Filters; - - -// always true predicate -struct TAllPrimitivePredicate : public std::unary_function -{ - bool operator () (IPrimitive *prim) - { - - return true; - } - -}; - -bool isFiltered(const std::string &path) -{ - for (uint i=0; i setBuilder; - - setBuilder.buildSet(srcDoc.RootNode, pred, primAlias); - - // look at each matched node - for (uint i=0; i(primAlias[i]); - if (srcPa == NULL) - continue; - - // build a ascii path to the prim - string primPath = buildPrimPath(srcPa); - - // look in the dst doc for a node with this path - TPrimitiveSet dstAlias; - selectPrimByPath(dstDoc.RootNode, primPath, dstAlias); - - if (dstAlias.size() == 1) - { - // yeah ! we found a match - CPrimAlias *pa = dynamic_cast(dstAlias.front()); - if (pa != NULL && pa->getAlias() != srcPa->getAlias()) - { -// nldebug("%s : forcing alias %u", primPath.c_str(), srcPa->getAlias()); - dstDoc.forceAlias(pa, srcPa->getAlias()); - modified = true; - } - } - else if (dstAlias.size() == 0) - { - // try to go up one level and add a prim alias node - while (!primPath.empty() && primPath[primPath.size()-1] != '.') - primPath.resize(primPath.size()-1); - - if (primPath.empty()) - continue; - - // remove the '.' - primPath.resize(primPath.size()-1); - if (primPath.empty()) - continue; - - // ok, retry the primitive select now - selectPrimByPath(dstDoc.RootNode, primPath, dstAlias); - - if (dstAlias.size() == 1) - { - IPrimitive *parent = dstAlias.front(); - - CPrimAlias *pa = static_cast (CClassRegistry::create ("CPrimAlias")); - CPropertyString *pname = new CPropertyString ("alias"); - pa->addPropertyByName("name", pname); - CPropertyString *pclass = new CPropertyString ("alias"); - pa->addPropertyByName("class", pclass); - -// nldebug("%s : creating new CPrimAlias for %u", primPath.c_str(), srcPa->getAlias()); - // insert the prim alias at first pos - CPrimitiveContext::instance().CurrentPrimitive = &dstDoc; - parent->insertChild(pa, 0); - dstDoc.forceAlias(pa, srcPa->getAlias()); - - modified = true; - } - else - { - // multiple node match ! - // try to affect the alias if src an dst have the same number of match - TPrimitiveSet srcAlias; - selectPrimByPath(srcDoc.RootNode, primPath, srcAlias); - - if (dstAlias.size() == srcAlias.size()) - { - // ok, we can match - for (uint i=0; i(getPrimitiveChild(srcAlias[i], pred)); - - CPrimAlias *pa = static_cast (CClassRegistry::create ("CPrimAlias")); - CPropertyString *pname = new CPropertyString ("alias"); - pa->addPropertyByName("name", pname); - CPropertyString *pclass = new CPropertyString ("alias"); - pa->addPropertyByName("class", pclass); - -// nldebug("%s : creating new CPrimAlias for %u", primPath.c_str(), srcPa->getAlias()); - // insert the prim alias at first pos - CPrimitiveContext::instance().CurrentPrimitive = &dstDoc; - parent->insertChild(pa, 0); - dstDoc.forceAlias(pa, srcPa->getAlias()); - - modified = true; - - } - } - else if (!dstAlias.empty()) - { - nlwarning("In '%s', the path '%s' match to a different multiple node set, no alias restored !", - CFile::getFilename(srcPath).c_str(), - primPath.c_str()); - } - - } - } - else - { - // multiple dst node mapping - // try to affect the alias if src an dst have the same number of match - TPrimitiveSet srcAlias; - selectPrimByPath(srcDoc.RootNode, primPath, srcAlias); - - if (dstAlias.size() == srcAlias.size()) - { - // ok, we can match - for (uint i=0; i(dstAlias[i]); - CPrimAlias *srcPa = dynamic_cast(srcAlias[i]); - if (pa != NULL && pa->getAlias() != srcPa->getAlias()) - { -// nldebug("%s : forcing alias %u", primPath.c_str(), srcPa->getAlias()); - dstDoc.forceAlias(pa, srcPa->getAlias()); - modified = true; - } - - } - } - else if (!dstAlias.empty()) - { - nlwarning("In '%s', the path '%s' match to a different multiple node set, no alias restored !", - CFile::getFilename(srcPath).c_str(), - primPath.c_str()); - - } - - } - } - - // second loop : for each dst node, look if it need a missing CPrimAlias node and generated it if needed - { - TAllPrimitivePredicate pred; - CPrimitiveEnumerator pe(dstDoc.RootNode, pred); - IPrimitive *prim; - - while ((prim = pe.getNextMatch()) != NULL) - { - const CPrimitiveClass *pc = LigoConfig.getPrimitiveClass(*prim); - if (pc) - { - // check all the static childrens - for (uint i=0; iStaticChildren.size(); ++i) - { - const CPrimitiveClass::CChild &cc = pc->StaticChildren[i]; - - if (cc.ClassName == "alias" && cc.Name == "alias") - { - bool found = false; - // ok, this node need an alias, check if it is present - for (uint i=0; igetNumChildren(); ++i) - { - IPrimitive *child; - if (prim->getChild(child, i)) - { - string className; - if (child->getPropertyByName("class", className) && className == "alias") - { - found = true; - break; - } - } - } - - if (!found) - { - // ok, we need to add the alias class - CPrimAlias *pa = static_cast (CClassRegistry::create ("CPrimAlias")); - CPropertyString *pname = new CPropertyString ("alias"); - pa->addPropertyByName("name", pname); - CPropertyString *pclass = new CPropertyString ("alias"); - pa->addPropertyByName("class", pclass); - - // nldebug("%s : creating new CPrimAlias for %u", primPath.c_str(), srcPa->getAlias()); - // insert the prim alias at first pos - CPrimitiveContext::instance().CurrentPrimitive = &dstDoc; - prim->insertChild(pa, 0); - - modified = true; - } - } - } - } - } - } - - if (modified) - { - saveXmlPrimitiveFile(dstDoc, dstPath); - } -} - - -struct TSetFileName -{ - void operator () (std::string &str) - { - str = CFile::getFilename(str); - } -}; - -struct TSetLastFolder -{ - void operator () (std::string &str) - { - vector folders; - str = CPath::standardizePath(str, false); -#ifdef NL_OS_WINDOWS - explode(str, std::string("/"), folders, true); -#else // NL_OS_WINDOW - NLMISC::splitString(str, "/", folders); -#endif // NL_OS_WINDOWS - if (!folders.empty()) - str = folders.back(); - else - str = ""; - } -}; - -void syncFolder(const string &srcPath, const string &dstPath) -{ - string tmp(srcPath); - TSetLastFolder slf; - slf.operator()(tmp); - nlinfo("Synchronizing folder '%s'", tmp.c_str()); - - // check all the file in the current folder - vector srcFiles; - CPath::getPathContent(srcPath, false, false, true, srcFiles); - for_each(srcFiles.begin(), srcFiles.end(), TSetFileName()); - sort(srcFiles.begin(), srcFiles.end()); - - vector dstFiles; - CPath::getPathContent(dstPath, false, false, true, dstFiles); - for_each(dstFiles.begin(), dstFiles.end(), TSetFileName()); - sort(dstFiles.begin(), dstFiles.end()); - - uint si=0; uint di=0; - for (; si < srcFiles.size() && di < dstFiles.size(); ++si, ++di) - { - if (srcFiles[si] < dstFiles[di]) - --di; - else if (srcFiles[si] > dstFiles[di]) - --si; - else if (srcFiles[si].find(".primitive") != string::npos) - { - // two file identical, synch the alias inside - syncFile(srcPath+"/"+srcFiles[si], dstPath+"/"+dstFiles[di]); - } - } - - // check all the folders in the current folder - vector srcFolders; - CPath::getPathContent(srcPath, false, true, false, srcFolders); - for_each(srcFolders.begin(), srcFolders.end(), TSetLastFolder()); - sort(srcFolders.begin(), srcFolders.end()); - - vector dstFolders; - CPath::getPathContent(dstPath, false, true, false, dstFolders); - for_each(dstFolders.begin(), dstFolders.end(), TSetLastFolder()); - sort(dstFolders.begin(), dstFolders.end()); - - si=0; di=0; - for (; si < srcFolders.size() && di < dstFolders.size(); ++si, ++di) - { - if (srcFolders[si] < dstFolders[di]) - --di; - else if (srcFolders[si] > dstFolders[di]) - --si; - else - { - // two folder identical, synch the files inside - syncFolder(srcPath+"/"+srcFolders[si], dstPath+"/"+dstFolders[di]); - } - } -} - - -int main() -{ - new NLMISC::CApplicationContext; - - CConfigFile cf; - - // register ligo primitives - Register(); - - cf.load("alias_synchronizer.cfg"); - - CConfigFile::CVar &paths = cf.getVar("Paths"); - CConfigFile::CVar &srcPath = cf.getVar("SrcPath"); - CConfigFile::CVar &dstPath = cf.getVar("DstPath"); - CConfigFile::CVar &filters = cf.getVar("Filters"); - - // store the filters - for (uint i=0; i +// 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/types_nl.h" +#include "nel/misc/config_file.h" +#include "nel/misc/path.h" +#include "nel/ligo/primitive.h" +#include "nel/ligo/ligo_config.h" +#include "nel/ligo/primitive_utils.h" +#include "nel/misc/algo.h" + +using namespace std; +using namespace NLMISC; +using namespace NLLIGO; + +CLigoConfig LigoConfig; + +vector Filters; + + +// always true predicate +struct TAllPrimitivePredicate : public std::unary_function +{ + bool operator () (IPrimitive *prim) + { + + return true; + } + +}; + +bool isFiltered(const std::string &path) +{ + for (uint i=0; i setBuilder; + + setBuilder.buildSet(srcDoc.RootNode, pred, primAlias); + + // look at each matched node + for (uint i=0; i(primAlias[i]); + if (srcPa == NULL) + continue; + + // build a ascii path to the prim + string primPath = buildPrimPath(srcPa); + + // look in the dst doc for a node with this path + TPrimitiveSet dstAlias; + selectPrimByPath(dstDoc.RootNode, primPath, dstAlias); + + if (dstAlias.size() == 1) + { + // yeah ! we found a match + CPrimAlias *pa = dynamic_cast(dstAlias.front()); + if (pa != NULL && pa->getAlias() != srcPa->getAlias()) + { +// nldebug("%s : forcing alias %u", primPath.c_str(), srcPa->getAlias()); + dstDoc.forceAlias(pa, srcPa->getAlias()); + modified = true; + } + } + else if (dstAlias.size() == 0) + { + // try to go up one level and add a prim alias node + while (!primPath.empty() && primPath[primPath.size()-1] != '.') + primPath.resize(primPath.size()-1); + + if (primPath.empty()) + continue; + + // remove the '.' + primPath.resize(primPath.size()-1); + if (primPath.empty()) + continue; + + // ok, retry the primitive select now + selectPrimByPath(dstDoc.RootNode, primPath, dstAlias); + + if (dstAlias.size() == 1) + { + IPrimitive *parent = dstAlias.front(); + + CPrimAlias *pa = static_cast (CClassRegistry::create ("CPrimAlias")); + CPropertyString *pname = new CPropertyString ("alias"); + pa->addPropertyByName("name", pname); + CPropertyString *pclass = new CPropertyString ("alias"); + pa->addPropertyByName("class", pclass); + +// nldebug("%s : creating new CPrimAlias for %u", primPath.c_str(), srcPa->getAlias()); + // insert the prim alias at first pos + CPrimitiveContext::instance().CurrentPrimitive = &dstDoc; + parent->insertChild(pa, 0); + dstDoc.forceAlias(pa, srcPa->getAlias()); + + modified = true; + } + else + { + // multiple node match ! + // try to affect the alias if src an dst have the same number of match + TPrimitiveSet srcAlias; + selectPrimByPath(srcDoc.RootNode, primPath, srcAlias); + + if (dstAlias.size() == srcAlias.size()) + { + // ok, we can match + for (uint i=0; i(getPrimitiveChild(srcAlias[i], pred)); + + CPrimAlias *pa = static_cast (CClassRegistry::create ("CPrimAlias")); + CPropertyString *pname = new CPropertyString ("alias"); + pa->addPropertyByName("name", pname); + CPropertyString *pclass = new CPropertyString ("alias"); + pa->addPropertyByName("class", pclass); + +// nldebug("%s : creating new CPrimAlias for %u", primPath.c_str(), srcPa->getAlias()); + // insert the prim alias at first pos + CPrimitiveContext::instance().CurrentPrimitive = &dstDoc; + parent->insertChild(pa, 0); + dstDoc.forceAlias(pa, srcPa->getAlias()); + + modified = true; + + } + } + else if (!dstAlias.empty()) + { + nlwarning("In '%s', the path '%s' match to a different multiple node set, no alias restored !", + CFile::getFilename(srcPath).c_str(), + primPath.c_str()); + } + + } + } + else + { + // multiple dst node mapping + // try to affect the alias if src an dst have the same number of match + TPrimitiveSet srcAlias; + selectPrimByPath(srcDoc.RootNode, primPath, srcAlias); + + if (dstAlias.size() == srcAlias.size()) + { + // ok, we can match + for (uint i=0; i(dstAlias[i]); + CPrimAlias *srcPa = dynamic_cast(srcAlias[i]); + if (pa != NULL && pa->getAlias() != srcPa->getAlias()) + { +// nldebug("%s : forcing alias %u", primPath.c_str(), srcPa->getAlias()); + dstDoc.forceAlias(pa, srcPa->getAlias()); + modified = true; + } + + } + } + else if (!dstAlias.empty()) + { + nlwarning("In '%s', the path '%s' match to a different multiple node set, no alias restored !", + CFile::getFilename(srcPath).c_str(), + primPath.c_str()); + + } + + } + } + + // second loop : for each dst node, look if it need a missing CPrimAlias node and generated it if needed + { + TAllPrimitivePredicate pred; + CPrimitiveEnumerator pe(dstDoc.RootNode, pred); + IPrimitive *prim; + + while ((prim = pe.getNextMatch()) != NULL) + { + const CPrimitiveClass *pc = LigoConfig.getPrimitiveClass(*prim); + if (pc) + { + // check all the static childrens + for (uint i=0; iStaticChildren.size(); ++i) + { + const CPrimitiveClass::CChild &cc = pc->StaticChildren[i]; + + if (cc.ClassName == "alias" && cc.Name == "alias") + { + bool found = false; + // ok, this node need an alias, check if it is present + for (uint i=0; igetNumChildren(); ++i) + { + IPrimitive *child; + if (prim->getChild(child, i)) + { + string className; + if (child->getPropertyByName("class", className) && className == "alias") + { + found = true; + break; + } + } + } + + if (!found) + { + // ok, we need to add the alias class + CPrimAlias *pa = static_cast (CClassRegistry::create ("CPrimAlias")); + CPropertyString *pname = new CPropertyString ("alias"); + pa->addPropertyByName("name", pname); + CPropertyString *pclass = new CPropertyString ("alias"); + pa->addPropertyByName("class", pclass); + + // nldebug("%s : creating new CPrimAlias for %u", primPath.c_str(), srcPa->getAlias()); + // insert the prim alias at first pos + CPrimitiveContext::instance().CurrentPrimitive = &dstDoc; + prim->insertChild(pa, 0); + + modified = true; + } + } + } + } + } + } + + if (modified) + { + saveXmlPrimitiveFile(dstDoc, dstPath); + } +} + + +struct TSetFileName +{ + void operator () (std::string &str) + { + str = CFile::getFilename(str); + } +}; + +struct TSetLastFolder +{ + void operator () (std::string &str) + { + vector folders; + str = CPath::standardizePath(str, false); +#ifdef NL_OS_WINDOWS + explode(str, std::string("/"), folders, true); +#else // NL_OS_WINDOW + NLMISC::splitString(str, "/", folders); +#endif // NL_OS_WINDOWS + if (!folders.empty()) + str = folders.back(); + else + str = ""; + } +}; + +void syncFolder(const string &srcPath, const string &dstPath) +{ + string tmp(srcPath); + TSetLastFolder slf; + slf.operator()(tmp); + nlinfo("Synchronizing folder '%s'", tmp.c_str()); + + // check all the file in the current folder + vector srcFiles; + CPath::getPathContent(srcPath, false, false, true, srcFiles); + for_each(srcFiles.begin(), srcFiles.end(), TSetFileName()); + sort(srcFiles.begin(), srcFiles.end()); + + vector dstFiles; + CPath::getPathContent(dstPath, false, false, true, dstFiles); + for_each(dstFiles.begin(), dstFiles.end(), TSetFileName()); + sort(dstFiles.begin(), dstFiles.end()); + + uint si=0; uint di=0; + for (; si < srcFiles.size() && di < dstFiles.size(); ++si, ++di) + { + if (srcFiles[si] < dstFiles[di]) + --di; + else if (srcFiles[si] > dstFiles[di]) + --si; + else if (srcFiles[si].find(".primitive") != string::npos) + { + // two file identical, synch the alias inside + syncFile(srcPath+"/"+srcFiles[si], dstPath+"/"+dstFiles[di]); + } + } + + // check all the folders in the current folder + vector srcFolders; + CPath::getPathContent(srcPath, false, true, false, srcFolders); + for_each(srcFolders.begin(), srcFolders.end(), TSetLastFolder()); + sort(srcFolders.begin(), srcFolders.end()); + + vector dstFolders; + CPath::getPathContent(dstPath, false, true, false, dstFolders); + for_each(dstFolders.begin(), dstFolders.end(), TSetLastFolder()); + sort(dstFolders.begin(), dstFolders.end()); + + si=0; di=0; + for (; si < srcFolders.size() && di < dstFolders.size(); ++si, ++di) + { + if (srcFolders[si] < dstFolders[di]) + --di; + else if (srcFolders[si] > dstFolders[di]) + --si; + else + { + // two folder identical, synch the files inside + syncFolder(srcPath+"/"+srcFolders[si], dstPath+"/"+dstFolders[di]); + } + } +} + + +int main() +{ + new NLMISC::CApplicationContext; + + CConfigFile cf; + + // register ligo primitives + Register(); + + cf.load("alias_synchronizer.cfg"); + + CConfigFile::CVar &paths = cf.getVar("Paths"); + CConfigFile::CVar &srcPath = cf.getVar("SrcPath"); + CConfigFile::CVar &dstPath = cf.getVar("DstPath"); + CConfigFile::CVar &filters = cf.getVar("Filters"); + + // store the filters + for (uint i=0; i -// 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 . - -// forBoris.cpp : Defines the entry point for the console application. -// - -#include - -#include "nel/misc/sstring.h" -#include "nel/misc/file.h" -#include "sadge_lib/include/text_input.h" -#include "sadge_lib/include/text_output.h" - -using namespace NLMISC; -using namespace std; - -CTextOutput info(CTextOutput::ECHO_STDOUT); -CTextOutput warn(CTextOutput::ECHO_STDERR); -CTextOutput out(CTextOutput::RECORD+CTextOutput::ECHO_STDOUT); - - -void splitStringCSV(const CSString& in,const CSString& separator,vector& result) -{ - bool lastEmpty = false; - CSString s=in.strip(); - if (s.right((uint)separator.size()) == separator) - { - // there is en empty column at end of line, remember this - lastEmpty = true; - } - - while (!s.empty()) - { - // deal with empty columns first - while (s.left((uint)separator.size())==separator) - { - s=s.leftCrop((uint)separator.size()); - result.push_back(""); - } - if (!s.empty()) - { - string::size_type pos = s.find(separator.c_str(), 0); - CSString col = s.left((uint)pos); - s=s.leftCrop((uint)pos); - if (!col.empty() && col[0] == '\"') - { - result.push_back(s.firstWordOrWords(true)); - } - else - result.push_back(col); - // we have a non-empty column... -/* result.push_back(s.firstWordOrWords(true)); - while (s.left(separator.size())!=separator && !s.empty()) - result.back()+=s.firstWordOrWords(true); -*/ - s=s.leftCrop((uint)separator.size()); - } - } - if (lastEmpty) - result.push_back(""); -} - - -class CCruncher -{ -private: - map paras; // the map of paragraph names to paragraph bodies - map headers; // the map of column names to paragraph header bodies - map footers; // the map of column names to paragraph footer bodies - map headerIsOpen; // map of open headers... - vector tblColumnNames; // the names of the table columns in a table - vector lastTblCols; // the last set of table columns - CSString tblSep; // the table column separator - CSString outputName; // the name of the output file that we're building - CSString paraName; // the name of the para, header or footer that we're building - CSString fileHeader; // text to insert at start of output file - CSString fileFooter; // text to insert at end of output file - CSString fileBody; // the body text of the file - bool firstTblLine; // boolean used to identify the first line of a table... - bool readColumnName; // boolean used to identify need to read column name in first table line - CSString tabTablePara; // name of the paragraph for tabbed table import - enum { DEFAULT, PARA, HEADER, FOOTER, FILE_HEADER, FILE_FOOTER, TBL, TABTBL, TEXT } mode; - -public: - CCruncher(): firstTblLine(true), readColumnName(false), mode(DEFAULT) - { - } - - void crunch(CTextInput& infile) - { - //--------------------------------------------------------------------------------------------- - // process input file contents - - while (!infile.eof()) - { - CSString line=infile.getLine(); - - if (line.strip().left(1)=="#") - { - //------------------------------------------------------------------------------------- - // deal with keywords - - dealWithKeyword(line,infile); - } - else - { - //------------------------------------------------------------------------------------- - // deal with non-keyword lines - - switch (mode) - { - case TBL: - case TABTBL: - addTableLine(line); - break; - - case PARA: - // append text to the current para - paras[paraName]+=line+"\n"; - break; - - case HEADER: - // append text to the current para - headers[paraName]+=line+"\n"; - headerIsOpen[paraName]=false; - break; - - case FILE_HEADER: - // append text to the current para - fileHeader+=line+"\n"; - break; - - case FILE_FOOTER: - // append text to the current para - fileFooter+=line+"\n"; - break; - - case FOOTER: - // append text to the current para - footers[paraName]+=line+"\n"; - break; - case TEXT: - // append the text directly to the output - fileBody += line+"\n"; - break; - default: - if (!line.strip().empty()) - warn<<"ignoring line: "< cols; - splitStringCSV(line,tblSep,cols); - - if (!tabTablePara.empty()) - { - // prepend the paragraph name to the columns names - cols.insert(cols.begin(), tabTablePara); - } - - // if not an empty line... - if (!cols.empty()) - { - if (!firstTblLine && !readColumnName) - { - // deal with footer paragraphs - uint32 firstChange; - for (firstChange=0;firstChange=cols.size()) - break; - if (cols[firstChange]!=lastTblCols[firstChange]) - break; - } - } - } - - for (uint32 i=(uint32)tblColumnNames.size();(i--)>firstChange;) - { - CSString s=footers[tblColumnNames[i]]; - for (uint32 j=1;j=cols.size() - || i>=lastTblCols.size() - || cols[i]!=lastTblCols[i] - || (cols[i]!="" && !headerIsOpen[tblColumnNames[i]])) - { - CSString s=headers[tblColumnNames[i]]; - for (uint32 j=1;j\n"; - return 1; - } - - CTextInput infile(argv[1]); - - if (infile.eof()) - { - warn<<"File not found or empty: "< +// 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 . + +// forBoris.cpp : Defines the entry point for the console application. +// + +#include + +#include "nel/misc/sstring.h" +#include "nel/misc/file.h" +#include "sadge_lib/include/text_input.h" +#include "sadge_lib/include/text_output.h" + +using namespace NLMISC; +using namespace std; + +CTextOutput info(CTextOutput::ECHO_STDOUT); +CTextOutput warn(CTextOutput::ECHO_STDERR); +CTextOutput out(CTextOutput::RECORD+CTextOutput::ECHO_STDOUT); + + +void splitStringCSV(const CSString& in,const CSString& separator,vector& result) +{ + bool lastEmpty = false; + CSString s=in.strip(); + if (s.right((uint)separator.size()) == separator) + { + // there is en empty column at end of line, remember this + lastEmpty = true; + } + + while (!s.empty()) + { + // deal with empty columns first + while (s.left((uint)separator.size())==separator) + { + s=s.leftCrop((uint)separator.size()); + result.push_back(""); + } + if (!s.empty()) + { + string::size_type pos = s.find(separator.c_str(), 0); + CSString col = s.left((uint)pos); + s=s.leftCrop((uint)pos); + if (!col.empty() && col[0] == '\"') + { + result.push_back(s.firstWordOrWords(true)); + } + else + result.push_back(col); + // we have a non-empty column... +/* result.push_back(s.firstWordOrWords(true)); + while (s.left(separator.size())!=separator && !s.empty()) + result.back()+=s.firstWordOrWords(true); +*/ + s=s.leftCrop((uint)separator.size()); + } + } + if (lastEmpty) + result.push_back(""); +} + + +class CCruncher +{ +private: + map paras; // the map of paragraph names to paragraph bodies + map headers; // the map of column names to paragraph header bodies + map footers; // the map of column names to paragraph footer bodies + map headerIsOpen; // map of open headers... + vector tblColumnNames; // the names of the table columns in a table + vector lastTblCols; // the last set of table columns + CSString tblSep; // the table column separator + CSString outputName; // the name of the output file that we're building + CSString paraName; // the name of the para, header or footer that we're building + CSString fileHeader; // text to insert at start of output file + CSString fileFooter; // text to insert at end of output file + CSString fileBody; // the body text of the file + bool firstTblLine; // boolean used to identify the first line of a table... + bool readColumnName; // boolean used to identify need to read column name in first table line + CSString tabTablePara; // name of the paragraph for tabbed table import + enum { DEFAULT, PARA, HEADER, FOOTER, FILE_HEADER, FILE_FOOTER, TBL, TABTBL, TEXT } mode; + +public: + CCruncher(): firstTblLine(true), readColumnName(false), mode(DEFAULT) + { + } + + void crunch(CTextInput& infile) + { + //--------------------------------------------------------------------------------------------- + // process input file contents + + while (!infile.eof()) + { + CSString line=infile.getLine(); + + if (line.strip().left(1)=="#") + { + //------------------------------------------------------------------------------------- + // deal with keywords + + dealWithKeyword(line,infile); + } + else + { + //------------------------------------------------------------------------------------- + // deal with non-keyword lines + + switch (mode) + { + case TBL: + case TABTBL: + addTableLine(line); + break; + + case PARA: + // append text to the current para + paras[paraName]+=line+"\n"; + break; + + case HEADER: + // append text to the current para + headers[paraName]+=line+"\n"; + headerIsOpen[paraName]=false; + break; + + case FILE_HEADER: + // append text to the current para + fileHeader+=line+"\n"; + break; + + case FILE_FOOTER: + // append text to the current para + fileFooter+=line+"\n"; + break; + + case FOOTER: + // append text to the current para + footers[paraName]+=line+"\n"; + break; + case TEXT: + // append the text directly to the output + fileBody += line+"\n"; + break; + default: + if (!line.strip().empty()) + warn<<"ignoring line: "< cols; + splitStringCSV(line,tblSep,cols); + + if (!tabTablePara.empty()) + { + // prepend the paragraph name to the columns names + cols.insert(cols.begin(), tabTablePara); + } + + // if not an empty line... + if (!cols.empty()) + { + if (!firstTblLine && !readColumnName) + { + // deal with footer paragraphs + uint32 firstChange; + for (firstChange=0;firstChange=cols.size()) + break; + if (cols[firstChange]!=lastTblCols[firstChange]) + break; + } + } + } + + for (uint32 i=(uint32)tblColumnNames.size();(i--)>firstChange;) + { + CSString s=footers[tblColumnNames[i]]; + for (uint32 j=1;j=cols.size() + || i>=lastTblCols.size() + || cols[i]!=lastTblCols[i] + || (cols[i]!="" && !headerIsOpen[tblColumnNames[i]])) + { + CSString s=headers[tblColumnNames[i]]; + for (uint32 j=1;j\n"; + return 1; + } + + CTextInput infile(argv[1]); + + if (infile.eof()) + { + warn<<"File not found or empty: "< -// 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 . - -//------------------------------------------------------------------------------------------------- -// project: sadge lib -// file: text_input.h -// version: $Id: text_input.h,v 1.2 2004/06/15 17:33:37 boucher Exp $ -// -//------------------------------------------------------------------------------------------------- - -#ifndef SADGE_TEXT_INPUT_H -#define SADGE_TEXT_INPUT_H - -//------------------------------------------------------------------------------------------------- - -#include "nel/misc/types_nl.h" -#include "nel/misc/sstring.h" -#include "nel/misc/path.h" - -#include "sadge_lib/include/text_output.h" - -#include - -//---------------------------------------------------------------------- -// CTextInput - an object that encapsulates output -//---------------------------------------------------------------------- - -class CTextInput -{ -public: - CTextInput(CTextOutput *warnings=NULL) - { - // initialise the pointer properties - _Warnings=warnings; - _SubFile=NULL; - _Buffer=NULL; - - // call the 'reset' method to initalise other properties - clear(); - } - - CTextInput(const char *fileName,CTextOutput *warnings=NULL) - { - // use default ctor to perform common initialisation code - *this=CTextInput(); - - // initialise the warning channel pointer (if supplied) - _Warnings=warnings; - - // read the input file - readFile(fileName); - } - - ~CTextInput() - { - clear(); - } - - void clear() - { - // free the input buffer - if (_Buffer!=NULL) - free(_Buffer); - _Buffer=NULL; - - // clear any child input manager objects - if (_SubFile!=NULL) - delete _SubFile; - _SubFile=NULL; - - // clear the 'used file names' list - _FileNames.clear(); - - // reset - _FileLength=0; - _CurPos=0; - _LineNumber=1; - } - - void readFile(const char *fileName) - { - // make sure we've never read this file before - unsigned i; - for (i=0;i<_FileNames.size();++i) - if (fileName==_FileNames[i]) - { - *_Warnings<<"Ignoring 'read' of file: "<readFile(fileName); - else - { - _SubFile=new CTextInput(fileName); - _FileNames.push_back(fileName); - } - return; - } - - // make a note of the file anme for later - _FileNames.push_back(fileName); - - // open the file - FILE* inf=fopen(fileName,"rb"); - if (inf==NULL) - { - printf("File not found: %s\n",fileName); - goto ERROR_LABEL; - } - - // allocate a big buffer for input - _FileLength= (inf!=NULL)? NLMISC::CFile::getFileSize(inf): 0; - _Buffer=(char *)malloc(_FileLength+1); - if (_Buffer==NULL) - { - printf("Failed to allocate %d bytes of RAM required to read file: %s\n",_FileLength+1,fileName); - goto ERROR_LABEL; - } - - // read the input - if (fread(_Buffer,1,_FileLength,inf)!=_FileLength) - { - printf("Failed to allocate %d bytes of RAM required to read file: %s\n",_FileLength+1,fileName); - goto ERROR_LABEL; - } - - // housekeeping - _Buffer[_FileLength]=0; - fclose(inf); - return; - - ERROR_LABEL: - // in case of error we have a few things to clean up properly... - clear(); - if (inf!=NULL) - fclose(inf); - } - - bool eof() - { - return _CurPos>=_FileLength; - } - - NLMISC::CSString getLine() - { - // if there's an open sub file then recurse into it - if (_SubFile!=NULL) - { - // check that we're not at the end of the sub file - if (!_SubFile->eof()) - return _SubFile->getLine(); - - // we're at the end of the sub file so close it down and return to business as usual - delete _SubFile; - _FileNames.pop_back(); - _SubFile=NULL; - } - - NLMISC::CSString result; - - // skip leading empty lines - while (_Buffer[_CurPos]=='\n' || _Buffer[_CurPos]=='\r') - { - if (_Buffer[_CurPos]=='\n') - ++_LineNumber; - ++_CurPos; - } - - // copy out the text to the next '\n' or '\r' - while (!eof() && _Buffer[_CurPos]!='\n' && _Buffer[_CurPos]!='\r') - { - result+= _Buffer[_CurPos]; - ++_CurPos; - } - - return result; - } - - NLMISC::CSString getLineName() - { - NLMISC::CSString result; - if (_SubFile!=NULL) - result=_SubFile->getLineName()+'<'; - result+=NLMISC::toString("%s:%d:",_FileNames.back().c_str(),_LineNumber); - return result; - } - -private: - unsigned _FileLength; - unsigned _CurPos; - unsigned _LineNumber; - char *_Buffer; - - std::vector _FileNames; - CTextInput *_SubFile; - - CTextOutput *_Warnings; -}; - -#endif +// 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 . + +//------------------------------------------------------------------------------------------------- +// project: sadge lib +// file: text_input.h +// version: $Id: text_input.h,v 1.2 2004/06/15 17:33:37 boucher Exp $ +// +//------------------------------------------------------------------------------------------------- + +#ifndef SADGE_TEXT_INPUT_H +#define SADGE_TEXT_INPUT_H + +//------------------------------------------------------------------------------------------------- + +#include "nel/misc/types_nl.h" +#include "nel/misc/sstring.h" +#include "nel/misc/path.h" + +#include "sadge_lib/include/text_output.h" + +#include + +//---------------------------------------------------------------------- +// CTextInput - an object that encapsulates output +//---------------------------------------------------------------------- + +class CTextInput +{ +public: + CTextInput(CTextOutput *warnings=NULL) + { + // initialise the pointer properties + _Warnings=warnings; + _SubFile=NULL; + _Buffer=NULL; + + // call the 'reset' method to initalise other properties + clear(); + } + + CTextInput(const char *fileName,CTextOutput *warnings=NULL) + { + // use default ctor to perform common initialisation code + *this=CTextInput(); + + // initialise the warning channel pointer (if supplied) + _Warnings=warnings; + + // read the input file + readFile(fileName); + } + + ~CTextInput() + { + clear(); + } + + void clear() + { + // free the input buffer + if (_Buffer!=NULL) + free(_Buffer); + _Buffer=NULL; + + // clear any child input manager objects + if (_SubFile!=NULL) + delete _SubFile; + _SubFile=NULL; + + // clear the 'used file names' list + _FileNames.clear(); + + // reset + _FileLength=0; + _CurPos=0; + _LineNumber=1; + } + + void readFile(const char *fileName) + { + // make sure we've never read this file before + unsigned i; + for (i=0;i<_FileNames.size();++i) + if (fileName==_FileNames[i]) + { + *_Warnings<<"Ignoring 'read' of file: "<readFile(fileName); + else + { + _SubFile=new CTextInput(fileName); + _FileNames.push_back(fileName); + } + return; + } + + // make a note of the file anme for later + _FileNames.push_back(fileName); + + // open the file + FILE* inf=fopen(fileName,"rb"); + if (inf==NULL) + { + printf("File not found: %s\n",fileName); + goto ERROR_LABEL; + } + + // allocate a big buffer for input + _FileLength= (inf!=NULL)? NLMISC::CFile::getFileSize(inf): 0; + _Buffer=(char *)malloc(_FileLength+1); + if (_Buffer==NULL) + { + printf("Failed to allocate %d bytes of RAM required to read file: %s\n",_FileLength+1,fileName); + goto ERROR_LABEL; + } + + // read the input + if (fread(_Buffer,1,_FileLength,inf)!=_FileLength) + { + printf("Failed to allocate %d bytes of RAM required to read file: %s\n",_FileLength+1,fileName); + goto ERROR_LABEL; + } + + // housekeeping + _Buffer[_FileLength]=0; + fclose(inf); + return; + + ERROR_LABEL: + // in case of error we have a few things to clean up properly... + clear(); + if (inf!=NULL) + fclose(inf); + } + + bool eof() + { + return _CurPos>=_FileLength; + } + + NLMISC::CSString getLine() + { + // if there's an open sub file then recurse into it + if (_SubFile!=NULL) + { + // check that we're not at the end of the sub file + if (!_SubFile->eof()) + return _SubFile->getLine(); + + // we're at the end of the sub file so close it down and return to business as usual + delete _SubFile; + _FileNames.pop_back(); + _SubFile=NULL; + } + + NLMISC::CSString result; + + // skip leading empty lines + while (_Buffer[_CurPos]=='\n' || _Buffer[_CurPos]=='\r') + { + if (_Buffer[_CurPos]=='\n') + ++_LineNumber; + ++_CurPos; + } + + // copy out the text to the next '\n' or '\r' + while (!eof() && _Buffer[_CurPos]!='\n' && _Buffer[_CurPos]!='\r') + { + result+= _Buffer[_CurPos]; + ++_CurPos; + } + + return result; + } + + NLMISC::CSString getLineName() + { + NLMISC::CSString result; + if (_SubFile!=NULL) + result=_SubFile->getLineName()+'<'; + result+=NLMISC::toString("%s:%d:",_FileNames.back().c_str(),_LineNumber); + return result; + } + +private: + unsigned _FileLength; + unsigned _CurPos; + unsigned _LineNumber; + char *_Buffer; + + std::vector _FileNames; + CTextInput *_SubFile; + + CTextOutput *_Warnings; +}; + +#endif diff --git a/code/ryzom/tools/leveldesign/csv_transform/sadge_lib/include/text_output.h b/code/ryzom/tools/leveldesign/csv_transform/sadge_lib/include/text_output.h index c77db2956..2eec9a4a0 100644 --- a/code/ryzom/tools/leveldesign/csv_transform/sadge_lib/include/text_output.h +++ b/code/ryzom/tools/leveldesign/csv_transform/sadge_lib/include/text_output.h @@ -1,410 +1,410 @@ -// 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 . - -//------------------------------------------------------------------------------------------------- -// project: sadge lib -// file: text_output.h -// version: $Id: text_output.h,v 1.1 2004/02/10 17:54:46 boucher Exp $ -// -// This file contains a string class derived from the STL string -// The string compare functions od the class are case insensitive -// -// The coding style is not CPU efficent - the routines are not designed for performance -//------------------------------------------------------------------------------------------------- - -#ifndef SADGE_TEXT_OUTPUT_H -#define SADGE_TEXT_OUTPUT_H - -//------------------------------------------------------------------------------------------------- - -#include "nel/misc/types_nl.h" -#include "nel/misc/log.h" -#include "nel/misc/sstring.h" - -#include - -//---------------------------------------------------------------------- -// CTextOutput - an object that encapsulates output -//---------------------------------------------------------------------- - -class CTextOutput -{ -public: - static CTextOutput Nul; // an empty tet output object - static CTextOutput StdErr; // an object that spews out to the stderr stream - static CTextOutput StdOut; // an object that spews out to the stdout stream - static CTextOutput NelInfo; // an object that spews out to nlinfo - static CTextOutput NelDebug; // an object that spews out to nldebug - static CTextOutput NelWarning; // an object that spews out to nlwarning - static CTextOutput NelError; // an object that spews out to nlerror - static CTextOutput NelAssert; // an object that spews out to nlassert - -public: - enum { NUL=0, ECHO_STDOUT=1, ECHO_STDERR=2, RECORD=4 }; - enum TSpecialCodes { HEX }; - - CTextOutput(uint flags=ECHO_STDOUT, NLMISC::CLog* log=NULL) - { - _initData(); - _Echo= (flags&ECHO_STDOUT)!=0; - _EchoStdErr= (flags&ECHO_STDERR)!=0; - _Record= (flags&RECORD)!=0; - _MiscLog= log; - } - - CTextOutput(CTextOutput& indirect) - { - _initData(); - _Indirect=&indirect; - } - - ~CTextOutput() - { -// _push('\n'); - } - - bool empty() - { - if (this==NULL) - return true; - if (_Indirect!=NULL) - return _Indirect->empty(); - - return _RecordBuff.empty(); - } - - void clear(CTextOutput *warnChannel=NULL,bool warnNotEmpty=false) - { - if (this==NULL) - return; - if (_Indirect!=NULL) - { - _Indirect->clear(warnChannel,warnNotEmpty); - return; - } - - if (warnNotEmpty && warnChannel != NULL && !(_RecordBuff.empty())) - *warnChannel<<"WARNING: CTextOutput::clear(): some content in channel was lost...\n"; - - _RecordBuff.clear(); - } - - void write(FILE *outf,bool resetAfterWrite=true) - { - if (this==NULL) - return; - if (_Indirect!=NULL) - { - _Indirect->write(outf,resetAfterWrite); - return; - } - - // write the buffer and close the file - fwrite(_RecordBuff.data(), 1, _RecordBuff.size(), outf); - - // clear the buffer - if (resetAfterWrite) - _RecordBuff.clear(); - } - - void write(const NLMISC::CSString& fileName,bool resetAfterWrite=true) - { - if (this==NULL) - return; - if (_Indirect!=NULL) - { - _Indirect->write(fileName,resetAfterWrite); - return; - } - - // open the output file - FILE *outf=fopen(fileName.c_str(),"wt"); - if (outf==NULL) - { - fprintf(stderr,"Failed to open file for output: %s\n",fileName.c_str()); - return; - } - - // write the buffer and close the file - write(outf,resetAfterWrite); - fclose(outf); - } - - void display(bool resetAfterDisplay=false) - { - if (this==NULL) - return; - if (_Indirect!=NULL) - { - _Indirect->display(resetAfterDisplay); - return; - } - - // write the buffer to the console - write(stdout,resetAfterDisplay); - } - - void setEchoStdOut(bool echo) - { - if (this==NULL) - return; - if (_Indirect!=NULL) - { - _Indirect->setEchoStdOut(echo); - return; - } - - _Echo=echo; - } - - void setEchoStdErr(bool echo) - { - if (this==NULL) - return; - if (_Indirect!=NULL) - { - _Indirect->setEchoStdErr(echo); - return; - } - - _EchoStdErr=echo; - } - - void setRecord(bool record,bool clearBuffer=false) - { - if (this==NULL) - return; - if (_Indirect!=NULL) - { - _Indirect->setRecord(record,clearBuffer); - return; - } - - _Record=record; - - if (clearBuffer) - _RecordBuff.clear(); - } - - void setMiscLog(NLMISC::CLog* log) - { - if (this==NULL) - return; - if (_Indirect!=NULL) - { - _Indirect->setMiscLog(log); - return; - } - - _MiscLog=log; - } - - template CTextOutput &operator<<(const C& code) - { - if (this==NULL) - return *this; - - if (_Indirect!=NULL) - { - return *_Indirect<>32),"%08X"); - _pushHex(unsigned(u),"%08X"); - return; - } - - uint32 tera= uint32(u/1000000/1000000); u-= tera*1000000*1000000; - uint32 mega= uint32(u/1000000); u-= mega*1000000; - uint32 units= uint32(u); u-= units; - - if (tera!=0) - { - _pushUnsigned(tera,""); - _pushUnsigned(mega,"",6); - _pushUnsigned(units,"",6); - } - else if (mega!=0) - { - _pushUnsigned(mega,""); - _pushUnsigned(units,"",6); - } - else - { - _pushUnsigned(units,""); - } - } - - void _push(sint64 i) - { - if (_ModeHex || i>=0) - { - _push((uint64) i); - } - else - { - _push('-'); - _push((uint64) -i); - } - } - - void _pushSString(const std::string &s) - { - _pushValue("%s",s.c_str()); - } - - void _pushString(const char *s) - { - _pushValue("%s",s); - } - - void _pushChar(char c) - { - if (_ModeHex) - { - _pushHex((int)c,"%02X"); - } - else - { - _pushValue("%c",c); - } - } - - void _pushUnsigned(unsigned u,const char* hexFmt,int padding=0) - { - _pushInt((int)u,'d',hexFmt,padding); - } - - void _pushSigned(int i,const char* hexFmt,int padding=0) - { - _pushInt(i,'d',hexFmt,padding); - } - - void _pushHex(int i,const char* hexFmt) - { - _pushValue(hexFmt,i); - _ModeHex=false; - } - - void _pushInt(int i,char fmtChar,const char* hexFmt,int padding=0) - { - if (_ModeHex) - { - _pushHex(i,hexFmt); - return; - } - - if (padding==0) - { - char fmt[]="% "; - fmt[1]=fmtChar; - _pushValue(fmt,i); - } - else - { - NLMISC::CSString fmt="%0"+NLMISC::CSString(padding)+fmtChar; - _pushValue(fmt.c_str(),i); - } - } - - void _pushFloat(double d) - { - _pushValue("%f",d); - } - - template void _pushValue(const char* fmt,const C& val) - { - if (_Echo) printf(fmt,val); - if (_EchoStdErr) fprintf(stderr,fmt,val); - if (_Record) _RecordBuff+=NLMISC::toString(fmt,val); - if (_MiscLog!=NULL) - { - _MiscLogString+=NLMISC::toString(fmt,val); - while (_MiscLogString.contains("\n")) - { - _MiscLog->displayNL("%s",_MiscLogString.splitTo('\n').c_str()); - _MiscLogString=_MiscLogString.splitFrom('\n'); - } - } - } - - void _initData() - { - _Echo=false; - _EchoStdErr=false; - _Record=false; - - _MiscLog=NULL; - _Indirect=NULL; - - _ModeHex=false; - } - - -private: - bool _EchoStdErr; - bool _Echo; - bool _Record; - - NLMISC::CLog* _MiscLog; - NLMISC::CSString _MiscLogString; - CTextOutput* _Indirect; - - bool _ModeHex; - - NLMISC::CSString _RecordBuff; -}; - - -#endif +// 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 . + +//------------------------------------------------------------------------------------------------- +// project: sadge lib +// file: text_output.h +// version: $Id: text_output.h,v 1.1 2004/02/10 17:54:46 boucher Exp $ +// +// This file contains a string class derived from the STL string +// The string compare functions od the class are case insensitive +// +// The coding style is not CPU efficent - the routines are not designed for performance +//------------------------------------------------------------------------------------------------- + +#ifndef SADGE_TEXT_OUTPUT_H +#define SADGE_TEXT_OUTPUT_H + +//------------------------------------------------------------------------------------------------- + +#include "nel/misc/types_nl.h" +#include "nel/misc/log.h" +#include "nel/misc/sstring.h" + +#include + +//---------------------------------------------------------------------- +// CTextOutput - an object that encapsulates output +//---------------------------------------------------------------------- + +class CTextOutput +{ +public: + static CTextOutput Nul; // an empty tet output object + static CTextOutput StdErr; // an object that spews out to the stderr stream + static CTextOutput StdOut; // an object that spews out to the stdout stream + static CTextOutput NelInfo; // an object that spews out to nlinfo + static CTextOutput NelDebug; // an object that spews out to nldebug + static CTextOutput NelWarning; // an object that spews out to nlwarning + static CTextOutput NelError; // an object that spews out to nlerror + static CTextOutput NelAssert; // an object that spews out to nlassert + +public: + enum { NUL=0, ECHO_STDOUT=1, ECHO_STDERR=2, RECORD=4 }; + enum TSpecialCodes { HEX }; + + CTextOutput(uint flags=ECHO_STDOUT, NLMISC::CLog* log=NULL) + { + _initData(); + _Echo= (flags&ECHO_STDOUT)!=0; + _EchoStdErr= (flags&ECHO_STDERR)!=0; + _Record= (flags&RECORD)!=0; + _MiscLog= log; + } + + CTextOutput(CTextOutput& indirect) + { + _initData(); + _Indirect=&indirect; + } + + ~CTextOutput() + { +// _push('\n'); + } + + bool empty() + { + if (this==NULL) + return true; + if (_Indirect!=NULL) + return _Indirect->empty(); + + return _RecordBuff.empty(); + } + + void clear(CTextOutput *warnChannel=NULL,bool warnNotEmpty=false) + { + if (this==NULL) + return; + if (_Indirect!=NULL) + { + _Indirect->clear(warnChannel,warnNotEmpty); + return; + } + + if (warnNotEmpty && warnChannel != NULL && !(_RecordBuff.empty())) + *warnChannel<<"WARNING: CTextOutput::clear(): some content in channel was lost...\n"; + + _RecordBuff.clear(); + } + + void write(FILE *outf,bool resetAfterWrite=true) + { + if (this==NULL) + return; + if (_Indirect!=NULL) + { + _Indirect->write(outf,resetAfterWrite); + return; + } + + // write the buffer and close the file + fwrite(_RecordBuff.data(), 1, _RecordBuff.size(), outf); + + // clear the buffer + if (resetAfterWrite) + _RecordBuff.clear(); + } + + void write(const NLMISC::CSString& fileName,bool resetAfterWrite=true) + { + if (this==NULL) + return; + if (_Indirect!=NULL) + { + _Indirect->write(fileName,resetAfterWrite); + return; + } + + // open the output file + FILE *outf=fopen(fileName.c_str(),"wt"); + if (outf==NULL) + { + fprintf(stderr,"Failed to open file for output: %s\n",fileName.c_str()); + return; + } + + // write the buffer and close the file + write(outf,resetAfterWrite); + fclose(outf); + } + + void display(bool resetAfterDisplay=false) + { + if (this==NULL) + return; + if (_Indirect!=NULL) + { + _Indirect->display(resetAfterDisplay); + return; + } + + // write the buffer to the console + write(stdout,resetAfterDisplay); + } + + void setEchoStdOut(bool echo) + { + if (this==NULL) + return; + if (_Indirect!=NULL) + { + _Indirect->setEchoStdOut(echo); + return; + } + + _Echo=echo; + } + + void setEchoStdErr(bool echo) + { + if (this==NULL) + return; + if (_Indirect!=NULL) + { + _Indirect->setEchoStdErr(echo); + return; + } + + _EchoStdErr=echo; + } + + void setRecord(bool record,bool clearBuffer=false) + { + if (this==NULL) + return; + if (_Indirect!=NULL) + { + _Indirect->setRecord(record,clearBuffer); + return; + } + + _Record=record; + + if (clearBuffer) + _RecordBuff.clear(); + } + + void setMiscLog(NLMISC::CLog* log) + { + if (this==NULL) + return; + if (_Indirect!=NULL) + { + _Indirect->setMiscLog(log); + return; + } + + _MiscLog=log; + } + + template CTextOutput &operator<<(const C& code) + { + if (this==NULL) + return *this; + + if (_Indirect!=NULL) + { + return *_Indirect<>32),"%08X"); + _pushHex(unsigned(u),"%08X"); + return; + } + + uint32 tera= uint32(u/1000000/1000000); u-= tera*1000000*1000000; + uint32 mega= uint32(u/1000000); u-= mega*1000000; + uint32 units= uint32(u); u-= units; + + if (tera!=0) + { + _pushUnsigned(tera,""); + _pushUnsigned(mega,"",6); + _pushUnsigned(units,"",6); + } + else if (mega!=0) + { + _pushUnsigned(mega,""); + _pushUnsigned(units,"",6); + } + else + { + _pushUnsigned(units,""); + } + } + + void _push(sint64 i) + { + if (_ModeHex || i>=0) + { + _push((uint64) i); + } + else + { + _push('-'); + _push((uint64) -i); + } + } + + void _pushSString(const std::string &s) + { + _pushValue("%s",s.c_str()); + } + + void _pushString(const char *s) + { + _pushValue("%s",s); + } + + void _pushChar(char c) + { + if (_ModeHex) + { + _pushHex((int)c,"%02X"); + } + else + { + _pushValue("%c",c); + } + } + + void _pushUnsigned(unsigned u,const char* hexFmt,int padding=0) + { + _pushInt((int)u,'d',hexFmt,padding); + } + + void _pushSigned(int i,const char* hexFmt,int padding=0) + { + _pushInt(i,'d',hexFmt,padding); + } + + void _pushHex(int i,const char* hexFmt) + { + _pushValue(hexFmt,i); + _ModeHex=false; + } + + void _pushInt(int i,char fmtChar,const char* hexFmt,int padding=0) + { + if (_ModeHex) + { + _pushHex(i,hexFmt); + return; + } + + if (padding==0) + { + char fmt[]="% "; + fmt[1]=fmtChar; + _pushValue(fmt,i); + } + else + { + NLMISC::CSString fmt="%0"+NLMISC::CSString(padding)+fmtChar; + _pushValue(fmt.c_str(),i); + } + } + + void _pushFloat(double d) + { + _pushValue("%f",d); + } + + template void _pushValue(const char* fmt,const C& val) + { + if (_Echo) printf(fmt,val); + if (_EchoStdErr) fprintf(stderr,fmt,val); + if (_Record) _RecordBuff+=NLMISC::toString(fmt,val); + if (_MiscLog!=NULL) + { + _MiscLogString+=NLMISC::toString(fmt,val); + while (_MiscLogString.contains("\n")) + { + _MiscLog->displayNL("%s",_MiscLogString.splitTo('\n').c_str()); + _MiscLogString=_MiscLogString.splitFrom('\n'); + } + } + } + + void _initData() + { + _Echo=false; + _EchoStdErr=false; + _Record=false; + + _MiscLog=NULL; + _Indirect=NULL; + + _ModeHex=false; + } + + +private: + bool _EchoStdErr; + bool _Echo; + bool _Record; + + NLMISC::CLog* _MiscLog; + NLMISC::CSString _MiscLogString; + CTextOutput* _Indirect; + + bool _ModeHex; + + NLMISC::CSString _RecordBuff; +}; + + +#endif diff --git a/code/ryzom/tools/leveldesign/export/export.cpp b/code/ryzom/tools/leveldesign/export/export.cpp index f02a659c1..0380aad4d 100644 --- a/code/ryzom/tools/leveldesign/export/export.cpp +++ b/code/ryzom/tools/leveldesign/export/export.cpp @@ -1,2212 +1,2212 @@ -// 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 "export.h" -#include "formFlora.h" -#include "formPlant.h" -#ifdef NL_OS_WINDOWS -#define NOMINMAX -#include -#endif // NL_OS_WINDOWS - -#include "nel/ligo/zone_region.h" -#include "nel/ligo/primitive.h" - -#include "nel/georges/u_form_loader.h" -#include "nel/georges/u_form.h" -#include "nel/georges/u_form_elm.h" - -#include "nel/3d/zone.h" -#include "nel/3d/landscape.h" -#include "nel/3d/scene_group.h" -#include "nel/3d/visual_collision_manager.h" -#include "nel/3d/visual_collision_entity.h" - -#include "nel/misc/o_xml.h" -#include "nel/misc/i_xml.h" -#include "nel/misc/path.h" -#include "nel/misc/file.h" - -#include "tools.h" -#include "../master/ContinentCfg.h" - -using namespace std; -using namespace NLMISC; -using namespace NL3D; -using namespace NLLIGO; -using namespace NLGEORGES; - -#define MAX_SYS_DIR 6 -const char *gExportSysDir[MAX_SYS_DIR] = -{ - ".", - "..", - "ZoneBitmaps", - "ZoneLigos", - "dfn", - "tmp" -}; - - -// --------------------------------------------------------------------------- -// --------------------------------------------------------------------------- -// --------------------------------------------------------------------------- -// --------------------------------------------------------------------------- - -// ----------------------------------------------------------------------------------------------- -// Segment line intersection P1P2 and P3P4 -bool CExport::segmentIntersection(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) -{ - double denominator = (y4-y3)*(x2-x1) - (x4-x3)*(y2-y1); - if( denominator == 0.0 ) - return false; // The segment are colinear - double k = ((x4-x3)*(y1-y3) - (y4-y3)*(x1-x3) ) / denominator; - if( (k<=0.0) || (k>=1.0) ) return false; - k = ( (x2-x1)*(y1-y3) - (y2-y1)*(x1-x3) ) / denominator; - if( (k<=0.0) || (k>=1.0) ) return false; - return true; -} - -// --------------------------------------------------------------------------- -void CExport::delIGZone (sint32 x, sint32 y) -{ - string sZoneName = CExport::getZoneNameFromXY (x, y); - sZoneName += ".ig"; - if (CFile::deleteFile(sZoneName)) - { - CTools::chdir (_ExeDir); - string sTmp = string(" zone ") + sZoneName + " deleted"; - if (_ExportCB != NULL) - _ExportCB->dispInfo(sTmp); - } -} - -// --------------------------------------------------------------------------- -void CExport::delAllIGZoneUnderPoint (float fCellSize, CPrimPoint *pPoint, const string &sIGOutputDir) -{ - if (pPoint == NULL) return; - sint32 nX, nY; - CTools::chdir (sIGOutputDir); - nX = (sint32) floor (pPoint->Point.x / fCellSize); - nY = (sint32) floor (pPoint->Point.y / fCellSize); - delIGZone (nX, nY); - CTools::chdir (sIGOutputDir); -} - -// --------------------------------------------------------------------------- -void CExport::delAllIGZoneUnderPath (float fCellSize, CPrimPath *pPath, const string &sIGOutputDir) -{ - if (pPath == NULL) return; - if (pPath->VPoints.size() == 0) return; - uint32 i, j; - CVector vMin, vMax; - - CTools::chdir (sIGOutputDir); - vMin = vMax = pPath->VPoints[0]; - for (i = 0; i < pPath->VPoints.size(); ++i) - { - if (vMin.x > pPath->VPoints[i].x) vMin.x = pPath->VPoints[i].x; - if (vMin.y > pPath->VPoints[i].y) vMin.y = pPath->VPoints[i].y; - if (vMin.z > pPath->VPoints[i].z) vMin.z = pPath->VPoints[i].z; - if (vMax.x < pPath->VPoints[i].x) vMax.x = pPath->VPoints[i].x; - if (vMax.y < pPath->VPoints[i].y) vMax.y = pPath->VPoints[i].y; - if (vMax.z < pPath->VPoints[i].z) vMax.z = pPath->VPoints[i].z; - } - - sint32 x, y; - sint32 nMinX, nMinY, nMaxX, nMaxY; - nMinX = (sint32) floor (vMin.x / fCellSize); - nMinY = (sint32) floor (vMin.y / fCellSize); - nMaxX = (sint32) floor (vMax.x / fCellSize); - nMaxY = (sint32) floor (vMax.y / fCellSize); - - for (x = nMinX; x <= nMaxX; ++x) - for (y = nMinY; y <= nMaxY; ++y) - { - // Does the zone (x,y) is under the patah ? - - CVector vSquare[4]; - vSquare[0].x = x * fCellSize; - vSquare[0].y = y * fCellSize; - vSquare[0].z = 0.0f; - - vSquare[1].x = (x+1) * fCellSize; - vSquare[1].y = y * fCellSize; - vSquare[1].z = 0.0f; - - vSquare[2].x = (x+1) * fCellSize; - vSquare[2].y = (y+1) * fCellSize; - vSquare[2].z = 0.0f; - - vSquare[3].x = x * fCellSize; - vSquare[3].y = (y+1) * fCellSize; - vSquare[3].z = 0.0f; - - // Is a vertex of the path inside the zone ? - for (i = 0; i < pPath->VPoints.size(); ++i) - { - if ((pPath->VPoints[i].x >= (x*fCellSize)) && - (pPath->VPoints[i].x <= ((x+1)*fCellSize)) && - (pPath->VPoints[i].y <= (y*fCellSize)) && - (pPath->VPoints[i].y <= ((y+1)*fCellSize))) - { - delIGZone (x, y); - CTools::chdir (sIGOutputDir); - } - } - - // Is an segment of the path cut an edge of the patat ? - for (i = 0; i < pPath->VPoints.size()-1; ++i) - for (j = 0; j < 4; ++j) - { - double x1 = vSquare[j].x; - double y1 = vSquare[j].y; - double x2 = vSquare[(j+1)%4].x; - double y2 = vSquare[(j+1)%4].y; - - double x3 = pPath->VPoints[i].x; - double y3 = pPath->VPoints[i].y; - double x4 = pPath->VPoints[i+1].x; - double y4 = pPath->VPoints[i+1].y; - - if (segmentIntersection(x1, y1, x2, y2, x3, y3, x4, y4)) - { - delIGZone (x, y); - CTools::chdir (sIGOutputDir); - } - } - } -} - -// --------------------------------------------------------------------------- -void CExport::delAllIGZoneUnderPatat (float fCellSize, CPrimZone *pPatat, const string &sIGOutputDir) -{ - if (pPatat == NULL) return; - if (pPatat->VPoints.size() == 0) return; - uint32 i, j; - CVector vMin, vMax; - - CTools::chdir (sIGOutputDir); - vMin = vMax = pPatat->VPoints[0]; - for (i = 0; i < pPatat->VPoints.size(); ++i) - { - if (vMin.x > pPatat->VPoints[i].x) vMin.x = pPatat->VPoints[i].x; - if (vMin.y > pPatat->VPoints[i].y) vMin.y = pPatat->VPoints[i].y; - if (vMin.z > pPatat->VPoints[i].z) vMin.z = pPatat->VPoints[i].z; - if (vMax.x < pPatat->VPoints[i].x) vMax.x = pPatat->VPoints[i].x; - if (vMax.y < pPatat->VPoints[i].y) vMax.y = pPatat->VPoints[i].y; - if (vMax.z < pPatat->VPoints[i].z) vMax.z = pPatat->VPoints[i].z; - } - - sint32 x, y; - sint32 nMinX, nMinY, nMaxX, nMaxY; - nMinX = (sint32) floor (vMin.x / fCellSize); - nMinY = (sint32) floor (vMin.y / fCellSize); - nMaxX = (sint32) floor (vMax.x / fCellSize); - nMaxY = (sint32) floor (vMax.y / fCellSize); - - for (x = nMinX; x <= nMaxX; ++x) - for (y = nMinY; y <= nMaxY; ++y) - { - // Does the zone (x,y) is under the patat ? - - // Is a vertex of the zone in the patat ? - CVector vSquare[4]; - vSquare[0].x = x * fCellSize; - vSquare[0].y = y * fCellSize; - vSquare[0].z = 0.0f; - - vSquare[1].x = (x+1) * fCellSize; - vSquare[1].y = y * fCellSize; - vSquare[1].z = 0.0f; - - vSquare[2].x = (x+1) * fCellSize; - vSquare[2].y = (y+1) * fCellSize; - vSquare[2].z = 0.0f; - - vSquare[3].x = x * fCellSize; - vSquare[3].y = (y+1) * fCellSize; - vSquare[3].z = 0.0f; - - for (i = 0; i < 4; ++i) - { - if (pPatat->contains(vSquare[i])) - { - delIGZone (x, y); - CTools::chdir (sIGOutputDir); - } - } - - // Is a vertex of the patat inside the zone ? - for (i = 0; i < pPatat->VPoints.size(); ++i) - { - if ((pPatat->VPoints[i].x >= (x*fCellSize)) && - (pPatat->VPoints[i].x <= ((x+1)*fCellSize)) && - (pPatat->VPoints[i].y <= (y*fCellSize)) && - (pPatat->VPoints[i].y <= ((y+1)*fCellSize))) - { - delIGZone (x, y); - CTools::chdir (sIGOutputDir); - } - } - - // Is an edge of the zone cut an edge of the patat ? - for (i = 0; i < pPatat->VPoints.size(); ++i) - for (j = 0; j < 4; ++j) - { - double x1 = vSquare[j].x; - double y1 = vSquare[j].y; - double x2 = vSquare[(j+1)%4].x; - double y2 = vSquare[(j+1)%4].y; - - double x3 = pPatat->VPoints[i].x; - double y3 = pPatat->VPoints[i].y; - double x4 = pPatat->VPoints[(i+1)%pPatat->VPoints.size()].x; - double y4 = pPatat->VPoints[(i+1)%pPatat->VPoints.size()].y; - - if (segmentIntersection(x1, y1, x2, y2, x3, y3, x4, y4)) - { - delIGZone (x, y); - CTools::chdir (sIGOutputDir); - } - } - } -} - -// --------------------------------------------------------------------------- -// A patat needs an update if there is at least one zone under itself that is not present -bool CExport::isPatatNeedUpdate (float fCellSize, CPrimZone *pPatat, const string &sIGOutputDir) -{ - uint32 i, j; - CVector vMin, vMax; - - CTools::chdir (sIGOutputDir); - if (pPatat->VPoints.size() == 0) - return false; - vMin = vMax = pPatat->VPoints[0]; - for (i = 0; i < pPatat->VPoints.size(); ++i) - { - if (vMin.x > pPatat->VPoints[i].x) vMin.x = pPatat->VPoints[i].x; - if (vMin.y > pPatat->VPoints[i].y) vMin.y = pPatat->VPoints[i].y; - if (vMin.z > pPatat->VPoints[i].z) vMin.z = pPatat->VPoints[i].z; - if (vMax.x < pPatat->VPoints[i].x) vMax.x = pPatat->VPoints[i].x; - if (vMax.y < pPatat->VPoints[i].y) vMax.y = pPatat->VPoints[i].y; - if (vMax.z < pPatat->VPoints[i].z) vMax.z = pPatat->VPoints[i].z; - } - - sint32 x, y; - sint32 nMinX, nMinY, nMaxX, nMaxY; - nMinX = (sint32) floor (vMin.x / fCellSize); - nMinY = (sint32) floor (vMin.y / fCellSize); - nMaxX = (sint32) floor (vMax.x / fCellSize); - nMaxY = (sint32) floor (vMax.y / fCellSize); - - for (x = nMinX; x <= nMaxX; ++x) - for (y = nMinY; y <= nMaxY; ++y) - { - // Does the zone (x,y) is under the patat ? - bool bZoneUnderPatat = false; - // Is a vertex of the zone in the patat ? - CVector vSquare[4]; - vSquare[0].x = x * fCellSize; - vSquare[0].y = y * fCellSize; - vSquare[0].z = 0.0f; - - vSquare[1].x = (x+1) * fCellSize; - vSquare[1].y = y * fCellSize; - vSquare[1].z = 0.0f; - - vSquare[2].x = (x+1) * fCellSize; - vSquare[2].y = (y+1) * fCellSize; - vSquare[2].z = 0.0f; - - vSquare[3].x = x * fCellSize; - vSquare[3].y = (y+1) * fCellSize; - vSquare[3].z = 0.0f; - - for (i = 0; i < 4; ++i) - { - if (pPatat->contains(vSquare[i])) - { - string sTmp = CExport::getZoneNameFromXY(x,y) + ".ig"; - if (!CTools::fileExist(sTmp)) // If the file does not exist - return true; // need update - } - } - - // Is a vertex of the patat inside the zone ? - for (i = 0; i < pPatat->VPoints.size(); ++i) - { - if ((pPatat->VPoints[i].x >= (x*fCellSize)) && - (pPatat->VPoints[i].x <= ((x+1)*fCellSize)) && - (pPatat->VPoints[i].y >= (y*fCellSize)) && - (pPatat->VPoints[i].y <= ((y+1)*fCellSize))) - { - string sTmp = CExport::getZoneNameFromXY(x,y) + ".ig"; - if (!CTools::fileExist(sTmp)) // If the file does not exist - return true; // need update - } - } - - // Is an edge of the zone cut an edge of the patat ? - for (i = 0; i < pPatat->VPoints.size(); ++i) - for (j = 0; j < 4; ++j) - { - double x1 = vSquare[j].x; - double y1 = vSquare[j].y; - double x2 = vSquare[(j+1)%4].x; - double y2 = vSquare[(j+1)%4].y; - - double x3 = pPatat->VPoints[i].x; - double y3 = pPatat->VPoints[i].y; - double x4 = pPatat->VPoints[(i+1)%pPatat->VPoints.size()].x; - double y4 = pPatat->VPoints[(i+1)%pPatat->VPoints.size()].y; - - if (segmentIntersection(x1, y1, x2, y2, x3, y3, x4, y4)) - { - string sTmp = CExport::getZoneNameFromXY (x, y) + ".ig"; - if (!CTools::fileExist(sTmp)) // If the file does not exist - return true; // need update - } - } - } - return false; -} - -// --------------------------------------------------------------------------- -// A path needs an update if there is at least one zone under itself that is not present -bool CExport::isPathNeedUpdate (float fCellSize, CPrimPath *pPath, const string &sIGOutputDir) -{ - uint32 i, j; - CVector vMin, vMax; - - CTools::chdir (sIGOutputDir); - if (pPath->VPoints.size() == 0) - return false; - vMin = vMax = pPath->VPoints[0]; - for (i = 0; i < pPath->VPoints.size(); ++i) - { - if (vMin.x > pPath->VPoints[i].x) vMin.x = pPath->VPoints[i].x; - if (vMin.y > pPath->VPoints[i].y) vMin.y = pPath->VPoints[i].y; - if (vMin.z > pPath->VPoints[i].z) vMin.z = pPath->VPoints[i].z; - if (vMax.x < pPath->VPoints[i].x) vMax.x = pPath->VPoints[i].x; - if (vMax.y < pPath->VPoints[i].y) vMax.y = pPath->VPoints[i].y; - if (vMax.z < pPath->VPoints[i].z) vMax.z = pPath->VPoints[i].z; - } - - sint32 x, y; - sint32 nMinX, nMinY, nMaxX, nMaxY; - nMinX = (sint32) floor (vMin.x / fCellSize); - nMinY = (sint32) floor (vMin.y / fCellSize); - nMaxX = (sint32) floor (vMax.x / fCellSize); - nMaxY = (sint32) floor (vMax.y / fCellSize); - - for (x = nMinX; x <= nMaxX; ++x) - for (y = nMinY; y <= nMaxY; ++y) - { - // Does the zone (x,y) is under the patat ? - bool bZoneUnderPatat = false; - // Is a vertex of the zone in the patat ? - CVector vSquare[4]; - vSquare[0].x = x * fCellSize; - vSquare[0].y = y * fCellSize; - vSquare[0].z = 0.0f; - - vSquare[1].x = (x+1) * fCellSize; - vSquare[1].y = y * fCellSize; - vSquare[1].z = 0.0f; - - vSquare[2].x = (x+1) * fCellSize; - vSquare[2].y = (y+1) * fCellSize; - vSquare[2].z = 0.0f; - - vSquare[3].x = x * fCellSize; - vSquare[3].y = (y+1) * fCellSize; - vSquare[3].z = 0.0f; - - // Is a vertex of the path inside the zone ? - for (i = 0; i < pPath->VPoints.size(); ++i) - { - if ((pPath->VPoints[i].x >= (x*fCellSize)) && - (pPath->VPoints[i].x <= ((x+1)*fCellSize)) && - (pPath->VPoints[i].y >= (y*fCellSize)) && - (pPath->VPoints[i].y <= ((y+1)*fCellSize))) - { - string sTmp = CExport::getZoneNameFromXY(x,y) + ".ig"; - if (!CTools::fileExist(sTmp)) // If the file does not exist - return true; // need update - } - } - - // Is an edge of the zone cut an edge of the patat ? - for (i = 0; i < (pPath->VPoints.size()-1); ++i) - for (j = 0; j < 4; ++j) - { - double x1 = vSquare[j].x; - double y1 = vSquare[j].y; - double x2 = vSquare[(j+1)%4].x; - double y2 = vSquare[(j+1)%4].y; - - double x3 = pPath->VPoints[i].x; - double y3 = pPath->VPoints[i].y; - double x4 = pPath->VPoints[i+1].x; - double y4 = pPath->VPoints[i+1].y; - - if (segmentIntersection(x1, y1, x2, y2, x3, y3, x4, y4)) - { - string sTmp = CExport::getZoneNameFromXY (x, y) + ".ig"; - if (!CTools::fileExist(sTmp)) // If the file does not exist - return true; // need update - } - } - } - return false; -} - -// --------------------------------------------------------------------------- -// A path needs an update if there is at least one zone under itself that is not present -bool CExport::isPointNeedUpdate (float fCellSize, CPrimPoint *pPoint, const string &sIGOutputDir) -{ - CTools::chdir (sIGOutputDir); - - sint32 x, y; - x = (sint32) floor (pPoint->Point.x / fCellSize); - y = (sint32) floor (pPoint->Point.y / fCellSize); - - // Does the zone (x,y) is under the patat ? - bool bZoneUnderPatat = false; - // Is a vertex of the zone in the patat ? - CVector vSquare[4]; - vSquare[0].x = x * fCellSize; - vSquare[0].y = y * fCellSize; - vSquare[0].z = 0.0f; - - vSquare[1].x = (x+1) * fCellSize; - vSquare[1].y = y * fCellSize; - vSquare[1].z = 0.0f; - - vSquare[2].x = (x+1) * fCellSize; - vSquare[2].y = (y+1) * fCellSize; - vSquare[2].z = 0.0f; - - vSquare[3].x = x * fCellSize; - vSquare[3].y = (y+1) * fCellSize; - vSquare[3].z = 0.0f; - - // Is the vertex inside the zone ? - if ((pPoint->Point.x >= (x*fCellSize)) && - (pPoint->Point.x <= ((x+1)*fCellSize)) && - (pPoint->Point.y >= (y*fCellSize)) && - (pPoint->Point.y <= ((y+1)*fCellSize))) - { - string sTmp = CExport::getZoneNameFromXY(x,y) + ".ig"; - if (!CTools::fileExist(sTmp)) // If the file does not exist - return true; // need update - } - - return false; -} - -// --------------------------------------------------------------------------- -// SExportOptions -// --------------------------------------------------------------------------- - -// --------------------------------------------------------------------------- -SExportOptions::SExportOptions () -{ - CellSize = 160.0f; -} - -// --------------------------------------------------------------------------- -bool SExportOptions::loadcf (CConfigFile &cf) -{ - // Out - CConfigFile::CVar &cvOutIGDir = cf.getVar("EXP_OutIGDir"); - OutIGDir = cvOutIGDir.asString(); - - // In - CConfigFile::CVar &cvInLandscapeDir = cf.getVar("EXP_ZoneWDir"); - InLandscapeDir = cvInLandscapeDir.asString(); - - CConfigFile::CVar &cvLandBankFile = cf.getVar("EXP_SmallBank"); - LandBankFile = cvLandBankFile.asString(); - CConfigFile::CVar &cvLandFarBankFile = cf.getVar("EXP_FarBank"); - LandFarBankFile = cvLandFarBankFile.asString(); - CConfigFile::CVar &cvLandTileNoiseDir = cf.getVar("EXP_DisplaceDir"); - LandTileNoiseDir = cvLandTileNoiseDir.asString(); - - CConfigFile::CVar &cvCellSize = cf.getVar("EXP_CellSize"); - CellSize = cvCellSize.asFloat(); - - CConfigFile::CVar &cvPrimFloraDir = cf.getVar("EXP_PrimFloraDir"); - PrimFloraDir = cvPrimFloraDir.asString(); - - return true; -} - -// --------------------------------------------------------------------------- -bool SExportOptions::save (FILE *f) -{ - fprintf (f,"\n// Export Options\n"); - fprintf (f, "EXP_OutIGDir = \"%s\";\n", OutIGDir); - fprintf (f, "EXP_ZoneWDir = \"%s\";\n", InLandscapeDir); - fprintf (f, "EXP_SmallBank = \"%s\";\n", LandBankFile); - fprintf (f, "EXP_FarBank = \"%s\";\n", LandFarBankFile); - fprintf (f, "EXP_DisplaceDir = \"%s\";\n", LandTileNoiseDir); - fprintf (f, "EXP_CellSize = %f;\n", CellSize); - fprintf (f, "EXP_PrimFloraDir = \"%s\";\n", PrimFloraDir); - return true; -} - -// --------------------------------------------------------------------------- -// SExportPrimitive -// --------------------------------------------------------------------------- - -// --------------------------------------------------------------------------- -bool SExportPrimitive::operator == (const SExportPrimitive &rRightArg) -{ - if (strcmp(this->FullPrimName.c_str(), rRightArg.FullPrimName.c_str()) == 0) - if (strcmp(this->PrimitiveName.c_str(), rRightArg.PrimitiveName.c_str()) == 0) - return true; - return false; -} - -// --------------------------------------------------------------------------- -// CExport -// --------------------------------------------------------------------------- - -// --------------------------------------------------------------------------- -CExport::CExport() -{ - _Landscape = NULL; - _VCM = NULL; - _VCE = NULL; - _ExportCB = NULL; - _Options = NULL; -} - -// --------------------------------------------------------------------------- -CExport::~CExport() -{ - if (_Landscape != NULL) - delete _Landscape; - if (_VCM != NULL) - { - _VCM->deleteEntity (_VCE); - delete _VCM; - } -} - - - -// --------------------------------------------------------------------------- -bool CExport::newExport (SExportOptions &opt, IExportCB *expCB) -{ - _ExeDir = CTools::pwd(); - _Options = &opt; - _ExportCB = expCB; - - string sTmp; - uint32 i, j, k, m; - - - - // First of all read the CFG - string sContinentDir = _Options->PrimFloraDir; - - sContinentDir = CTools::normalizePath (sContinentDir); - CTools::chdir (sContinentDir.c_str()); // Relative to absolute path - sContinentDir = CTools::pwd () + "\\"; - CTools::chdir (_ExeDir); - - // Read continent.cfg - SContinentCfg ContinentCFG; - { - string sTmp = sContinentDir + "continent.cfg"; - if (!ContinentCFG.load(sTmp.c_str())) - throw Exception("Cannot load continent.cfg"); - } - - // Ok set parameters from options first and with CFG if no options set - - if (_Options->OutIGDir == "") - _OutIGDir = CTools::normalizePath (ContinentCFG.OutIGDir); - else - _OutIGDir = CTools::normalizePath (_Options->OutIGDir); - - if (_Options->LandFile == "") - _LandFile = ContinentCFG.LandFile; - else - _LandFile = _Options->LandFile; - - if (_Options->DfnDir == "") - _DfnDir = ContinentCFG.DfnDir; - else - _DfnDir = _Options->DfnDir; - - if (_Options->GameElemDir == "") - _GameElemDir = ContinentCFG.GameElemDir; - else - _GameElemDir = _Options->GameElemDir; - - if (_Options->InLandscapeDir == "") - _InLandscapeDir = ContinentCFG.LandZoneWDir; // Directory where to get .zonew files - else - _InLandscapeDir = _Options->InLandscapeDir; - - if (_Options->LandFarBankFile == "") - _LandBankFile = ContinentCFG.LandBankFile; // The .smallbank file associated with the landscape - else - _LandBankFile = _Options->LandBankFile; - - if (_Options->LandFarBankFile == "") - _LandFarBankFile = ContinentCFG.LandFarBankFile; // The .farbank file - else - _LandFarBankFile = _Options->LandFarBankFile; - - if (_Options->LandTileNoiseDir == "") - _LandTileNoiseDir = ContinentCFG.LandTileNoiseDir; // Directory where to get displacement map - else - _LandTileNoiseDir = _Options->LandTileNoiseDir; - - - // Now create output directory - CTools::mkdir (_OutIGDir); - - CTools::chdir (_OutIGDir.c_str()); - _OutIGDir = CTools::pwd () + "\\"; - CTools::chdir (_ExeDir); - - - CPath::addSearchPath (_DfnDir, true, true); - CPath::addSearchPath (_GameElemDir, true, true); - CPath::addSearchPath (_LandTileNoiseDir, true, true); - - - // Get all regions - vector vRegions; - WIN32_FIND_DATA findData; - HANDLE hFind; - - CTools::chdir (sContinentDir); - hFind = FindFirstFile ("*.*", &findData); - while (hFind != INVALID_HANDLE_VALUE) - { - if (GetFileAttributes(findData.cFileName)&FILE_ATTRIBUTE_DIRECTORY) - { - // Look if the name is a system directory - bool bFound = false; - for (i = 0; i < MAX_SYS_DIR; ++i) - if (stricmp (findData.cFileName, gExportSysDir[i]) == 0) - { - bFound = true; - break; - } - if (!bFound) // No, ok lets recurse it - { - vRegions.push_back (findData.cFileName); - } - } - if (FindNextFile (hFind, &findData) == 0) - break; - } - FindClose (hFind); - - - // Process all regions - uint32 nRegion; - for (nRegion = 0; nRegion < vRegions.size(); ++nRegion) - { - CTools::chdir (sContinentDir + vRegions[nRegion]); - - // Process if a flora has been modified - vector vFloraToUpdate; - uint32 nFloraFile; - - // Fill the structure for update - { - // Get all new flora of the region - vector vFloraFiles; - CTools::dirSub ("*.flora", vFloraFiles, true); - for (nFloraFile = 0; nFloraFile < vFloraFiles.size(); ++nFloraFile) - { - // Compare the date with the old file stored in the IG output directory - CTools::chdir (sContinentDir + vRegions[nRegion]); - string sBaseName = vFloraFiles[nFloraFile].substr(sContinentDir.size()); - sBaseName = sBaseName.substr(0,sBaseName.rfind('\\')); - for (i = 0; i < sBaseName.size(); ++i) - if (sBaseName[i] == '\\') - sBaseName[i] = '-'; - sBaseName += '-'; - string sOldFloraName = _OutIGDir + sBaseName + vFloraFiles[nFloraFile].substr(vFloraFiles[nFloraFile].rfind('\\')+1); - - if (CTools::fileExist(sOldFloraName)) - { - if (CTools::fileDateCmp(vFloraFiles[nFloraFile], sOldFloraName) > 0) - { - // Delete zones from the 2 files - SFloraToUpdate ftuTmp; - // Delete zones from the newest file - ftuTmp.FloraFile = vFloraFiles[nFloraFile]; - CTools::chdir (vFloraFiles[nFloraFile].substr(0,vFloraFiles[nFloraFile].rfind('\\'))); - CTools::dir ("*.prim", ftuTmp.PrimFile, true); - vFloraToUpdate.push_back (ftuTmp); - // Delete zones from the oldest file - CTools::chdir (_OutIGDir); - ftuTmp.FloraFile = sOldFloraName; - CTools::dir (sBaseName + "*.prim", ftuTmp.PrimFile, true); - vFloraToUpdate.push_back (ftuTmp); - CTools::chdir (_ExeDir); - sTmp = vFloraFiles[nFloraFile] + " has been modified."; - if (_ExportCB != NULL) _ExportCB->dispInfo (sTmp); - } - else - { - CTools::chdir (_ExeDir); - sTmp = vFloraFiles[nFloraFile] + string(" up to date."); - if (_ExportCB != NULL) _ExportCB->dispInfo (sTmp); - } - } - else - { - // Delete zone from newest file - SFloraToUpdate ftuTmp; - ftuTmp.FloraFile = vFloraFiles[nFloraFile]; - CTools::chdir (vFloraFiles[nFloraFile].substr(0,vFloraFiles[nFloraFile].rfind('\\'))); - CTools::dir ("*.prim", ftuTmp.PrimFile, true); - vFloraToUpdate.push_back (ftuTmp); - CTools::chdir (_ExeDir); - sTmp = vFloraFiles[nFloraFile] + " not generated."; - if (_ExportCB != NULL) _ExportCB->dispInfo (sTmp); - } - } - - // Get all old flora of the current region - CTools::chdir (_OutIGDir); - CTools::dir (vRegions[nRegion] + "-*.flora", vFloraFiles, true); - for (nFloraFile = 0; nFloraFile < vFloraFiles.size(); ++nFloraFile) - { - CTools::chdir (_OutIGDir); - // if the old flora file still exist but the new one not -> delete zone for the oldest file - string sNewFloraName = vFloraFiles[nFloraFile].substr(vFloraFiles[nFloraFile].rfind('\\')+1); - string sBaseName = sNewFloraName.substr (0, vFloraFiles[nFloraFile].rfind('-')); - for (i = 0; i < sNewFloraName.size(); ++i) - if (sNewFloraName[i] == '-') - sNewFloraName[i] = '\\'; - - sNewFloraName = sContinentDir + sNewFloraName; - if (!CTools::fileExist(sNewFloraName)) - { - SFloraToUpdate ftuTmp; - // Delete zones from the oldest file - ftuTmp.FloraFile = vFloraFiles[nFloraFile]; - CTools::dir (sBaseName + "*.prim", ftuTmp.PrimFile, true); - vFloraToUpdate.push_back (ftuTmp); - CTools::chdir (_ExeDir); - sTmp = vFloraFiles[nFloraFile] + " not needed anymore."; - if (_ExportCB != NULL) _ExportCB->dispInfo (sTmp); - } - } - } - // End of fill the structure for update - - // Interpret the FloraToUpdate - for (nFloraFile = 0; nFloraFile < vFloraToUpdate.size(); ++nFloraFile) - { - // Get all patats referenced by the flora and suppress zones under - - // Load the .flora file - SFormFlora FormFlora; - { - // Get a loader - UFormLoader *loader = UFormLoader::createLoader (); - - // Load the form - CSmartPtr form = loader->loadForm (vFloraToUpdate[nFloraFile].FloraFile.c_str ()); - if (form) - FormFlora.build (form->getRootNode ()); - - // Release the loader - UFormLoader::releaseLoader (loader); - } - - // Load all the .prim files that can be referenced by the flora - vector vPrimRegions; - { - vector &rPrimFiles = vFloraToUpdate[nFloraFile].PrimFile; - for (i = 0; i < rPrimFiles.size(); ++i) - { - CPrimRegion tmpPrimRegion; - CIFile fileIn; - fileIn.open (rPrimFiles[i]); - CIXml input; - input.init (fileIn); - tmpPrimRegion.serial (input); - vPrimRegions.push_back (tmpPrimRegion); - } - } - - // Delete zones under the old prims referenced by the old zone - - for (i = 0; i < FormFlora.IncludePatats.size(); ++i) - { - // Get the patat - CPrimZone *pPatat = NULL; - CPrimPoint *pPoint = NULL; - CPrimPath *pPath = NULL; - for (j = 0; j < vPrimRegions.size(); ++j) - { - for (k = 0; k < vPrimRegions[j].VZones.size(); ++k) - if (vPrimRegions[j].VZones[k].getName() == FormFlora.IncludePatats[i]) - pPatat = &vPrimRegions[j].VZones[k]; - for (k = 0; k < vPrimRegions[j].VPoints.size(); ++k) - if (vPrimRegions[j].VPoints[k].getName() == FormFlora.IncludePatats[i]) - pPoint = &vPrimRegions[j].VPoints[k]; - for (k = 0; k < vPrimRegions[j].VPaths.size(); ++k) - if (vPrimRegions[j].VPaths[k].getName() == FormFlora.IncludePatats[i]) - pPath = &vPrimRegions[j].VPaths[k]; - } - - if ((pPatat == NULL) && (pPoint == NULL) && (pPath == NULL)) - { - CTools::chdir (_ExeDir); - sTmp = "WARNING : Cannot find " + FormFlora.IncludePatats[i]; - if (_ExportCB != NULL) _ExportCB->dispInfo (sTmp); - continue; - } - - if ((pPatat != NULL) && (pPatat->VPoints.size() <= 2)) - { - CTools::chdir (_ExeDir); - sTmp = "Patat " + pPatat->getName() + " has less than 3 points"; - if (_ExportCB != NULL) _ExportCB->dispInfo (sTmp); - continue; - } - - if ((pPath != NULL) && (pPath->VPoints.size() < 2)) - { - CTools::chdir (_ExeDir); - sTmp = "Patat " + pPatat->getName() + " has less than 2 points"; - if (_ExportCB != NULL) _ExportCB->dispInfo (sTmp); - continue; - } - - if (pPatat != NULL) - delAllIGZoneUnderPatat (160.0f, pPatat, _OutIGDir); - if (pPoint != NULL) - delAllIGZoneUnderPoint (160.0f, pPoint, _OutIGDir); - if (pPath != NULL) - delAllIGZoneUnderPath (160.0f, pPath, _OutIGDir); - } - } - // End of Process if a flora has been modified - - // Process if a prim has been modified - // Fill the structure for update - CTools::chdir (sContinentDir + vRegions[nRegion]); - vector vPrimToUpdate; - { - uint32 nPrimFile; - vector vPrimFiles; - // Get all new prim of the region - CTools::dirSub ("*.prim", vPrimFiles, true); - for (nPrimFile = 0; nPrimFile < vPrimFiles.size(); ++nPrimFile) - { - CTools::chdir (sContinentDir + vRegions[nRegion]); - // Compare the date with the old file stored in the IG output directory - string sBaseName = vPrimFiles[nPrimFile].substr(sContinentDir.size()); - sBaseName = sBaseName.substr(0,sBaseName.rfind('\\')); - for (i = 0; i < sBaseName.size(); ++i) - if (sBaseName[i] == '\\') - sBaseName[i] = '-'; - sBaseName += '-'; - string sOldPrimName = _OutIGDir + sBaseName + vPrimFiles[nPrimFile].substr(vPrimFiles[nPrimFile].rfind('\\')+1); - - if (CTools::fileExist(sOldPrimName)) - { - if (CTools::fileDateCmp(vPrimFiles[nPrimFile], sOldPrimName) > 0) - { - // Delete zones from the 2 files - SPrimToUpdate ptuTmp; - // Delete zones from the newest file - ptuTmp.PrimFile = vPrimFiles[nPrimFile]; - CTools::chdir (vPrimFiles[nPrimFile].substr(0,vPrimFiles[nPrimFile].rfind('\\'))); - CTools::dir ("*.flora", ptuTmp.FloraFile, true); - vPrimToUpdate.push_back (ptuTmp); - // Delete zones from the oldest file - CTools::chdir (_OutIGDir); - ptuTmp.PrimFile = sOldPrimName; - CTools::dir (sBaseName + "*.flora", ptuTmp.FloraFile, true); - vPrimToUpdate.push_back (ptuTmp); - CTools::chdir (_ExeDir); - sTmp = vPrimFiles[nPrimFile] + " has been modified."; - if (_ExportCB != NULL) _ExportCB->dispInfo (sTmp); - } - else - { - CTools::chdir (_ExeDir); - sTmp = vPrimFiles[nPrimFile] + " up to date."; - if (_ExportCB != NULL) _ExportCB->dispInfo (sTmp); - } - } - else - { - // Delete zone from newest file - SPrimToUpdate ptuTmp; - ptuTmp.PrimFile = vPrimFiles[nPrimFile]; - CTools::chdir (vPrimFiles[nPrimFile].substr(0,vPrimFiles[nPrimFile].rfind('\\'))); - CTools::dir ("*.flora", ptuTmp.FloraFile, true); - vPrimToUpdate.push_back (ptuTmp); - CTools::chdir (_ExeDir); - sTmp = vPrimFiles[nPrimFile] + " not generated."; - if (_ExportCB != NULL) _ExportCB->dispInfo (sTmp); - } - } - - // Get all old prim of the current region - CTools::chdir (_OutIGDir); - CTools::dir (vRegions[nRegion] + "-*.prim", vPrimFiles, false); - for (nPrimFile = 0; nPrimFile < vPrimFiles.size(); ++nPrimFile) - { - CTools::chdir (_OutIGDir); - // if the old prim file still exist but the new one not -> delete zone for the oldest file - string sNewPrimName = vPrimFiles[nPrimFile].substr(vPrimFiles[nPrimFile].rfind('\\')+1); - string sBaseName = sNewPrimName.substr (0, vPrimFiles[nPrimFile].rfind('-')); - for (i = 0; i < sNewPrimName.size(); ++i) - if (sNewPrimName[i] == '-') - sNewPrimName[i] = '\\'; - - sNewPrimName = sContinentDir + sNewPrimName; - if (!CTools::fileExist(sNewPrimName)) - { - // Delete zones from the oldest file - CPrimRegion PrimRegion; - { - CIFile fileIn; - fileIn.open (vPrimFiles[nPrimFile]); - CIXml input; - input.init (fileIn); - PrimRegion.serial (input); - } - - for (j = 0; j < PrimRegion.VZones.size(); ++j) - delAllIGZoneUnderPatat (_Options->CellSize, &PrimRegion.VZones[j], _OutIGDir); - for (j = 0; j < PrimRegion.VPaths.size(); ++j) - delAllIGZoneUnderPath (_Options->CellSize, &PrimRegion.VPaths[j], _OutIGDir); - for (j = 0; j < PrimRegion.VPoints.size(); ++j) - delAllIGZoneUnderPoint (_Options->CellSize, &PrimRegion.VPoints[j], _OutIGDir); - - CTools::chdir (_ExeDir); - sTmp = vPrimFiles[nPrimFile] + " not needed anymore."; - if (_ExportCB != NULL) _ExportCB->dispInfo (sTmp); - } - } - } - // End of fill the structure for update - - // Interpretation of structure for update - for (i = 0; i < vPrimToUpdate.size(); ++i) - { - // Load all the .flora file - vector vFormFloras; - for (j = 0; j < vPrimToUpdate[i].FloraFile.size(); ++j) - { - // Create the loader - UFormLoader *loader = UFormLoader::createLoader (); - - // Load the form - CSmartPtr form = loader->loadForm (vPrimToUpdate[i].FloraFile[j].c_str ()); - if (form) - { - SFormFlora FormFloraTmp; - FormFloraTmp.build (form->getRootNode ()); - vFormFloras.push_back (FormFloraTmp); - } - - // Release the loader - UFormLoader::releaseLoader (loader); - } - - // Load all the .prim files that can be referenced by the flora - CPrimRegion PrimRegion; - { - CIFile fileIn; - fileIn.open (vPrimToUpdate[i].PrimFile); - CIXml input; - input.init (fileIn); - PrimRegion.serial (input); - } - - // Delete zones under the prims that has been referenced by a flora - - for (j = 0; j < PrimRegion.VZones.size(); ++j) - { - // Get the patat - CPrimZone *pPatat = NULL; - - // Check if the current patat is referenced by a flora - for (k = 0; k < vFormFloras.size(); ++k) - for (m = 0; m < vFormFloras[k].IncludePatats.size(); ++m) - if (PrimRegion.VZones[j].getName() == vFormFloras[k].IncludePatats[m]) - pPatat = &PrimRegion.VZones[j]; - - if ((pPatat == NULL) || (pPatat->VPoints.size() <= 2)) - { - continue; - } - delAllIGZoneUnderPatat (_Options->CellSize, pPatat, _OutIGDir); - } - for (j = 0; j < PrimRegion.VPoints.size(); ++j) - { - // Get the point - CPrimPoint *pPoint = NULL; - - // Check if the current point is referenced by a flora - for (k = 0; k < vFormFloras.size(); ++k) - for (m = 0; m < vFormFloras[k].IncludePatats.size(); ++m) - if (PrimRegion.VPoints[j].getName() == vFormFloras[k].IncludePatats[m]) - pPoint = &PrimRegion.VPoints[j]; - delAllIGZoneUnderPoint (_Options->CellSize, pPoint, _OutIGDir); - } - for (j = 0; j < PrimRegion.VPaths.size(); ++j) - { - // Get the path - CPrimPath *pPath = NULL; - - // Check if the current path is referenced by a flora - for (k = 0; k < vFormFloras.size(); ++k) - for (m = 0; m < vFormFloras[k].IncludePatats.size(); ++m) - if (PrimRegion.VPaths[j].getName() == vFormFloras[k].IncludePatats[m]) - pPath = &PrimRegion.VPaths[j]; - delAllIGZoneUnderPath (_Options->CellSize, pPath, _OutIGDir); - } - } - // End of Process if a prim has been modified - - } - // End of process all regions - - // Check all patat to export (a patat that has no zone under itself (deleted or not present)) - vector vExportPrimitives; - vector vAllPrimFiles; // All prim files of a continent - CTools::chdir (sContinentDir); - CTools::dirSub ("*.prim", vAllPrimFiles, true); - for (i = 0; i < vAllPrimFiles.size(); ++i) - { - vAllPrimFiles[i] = strlwr(vAllPrimFiles[i]); - // Load the primfile - CPrimRegion PrimRegion; - { - CIFile fileIn; - fileIn.open (vAllPrimFiles[i]); - CIXml input; - input.init (fileIn); - PrimRegion.serial (input); - } - - for (j = 0; j < PrimRegion.VZones.size(); ++j) - { - // Check all zones to know if this patat must be updated - if (isPatatNeedUpdate(_Options->CellSize, &PrimRegion.VZones[j], _OutIGDir)) - { - SExportPrimitive epTmp; - epTmp.FullPrimName = vAllPrimFiles[i]; - epTmp.PrimitiveName = PrimRegion.VZones[j].getName(); - vExportPrimitives.push_back (epTmp); - } - } - - for (j = 0; j < PrimRegion.VPaths.size(); ++j) - { - // Check all pathes to know if some must be updated (if no zone under) - if (isPathNeedUpdate(_Options->CellSize, &PrimRegion.VPaths[j], _OutIGDir)) - { - SExportPrimitive epTmp; - epTmp.FullPrimName = vAllPrimFiles[i]; - epTmp.PrimitiveName = PrimRegion.VPaths[j].getName(); - vExportPrimitives.push_back (epTmp); - } - } - - for (j = 0; j < PrimRegion.VPoints.size(); ++j) - { - // Check all points to know if some must be updated (if no zone under) - if (isPointNeedUpdate(_Options->CellSize, &PrimRegion.VPoints[j], _OutIGDir)) - { - SExportPrimitive epTmp; - epTmp.FullPrimName = vAllPrimFiles[i]; - epTmp.PrimitiveName = PrimRegion.VPoints[j].getName(); - vExportPrimitives.push_back (epTmp); - } - } - } - - // Export - - CTools::chdir (_ExeDir); - _Options->PrimFloraDir = sContinentDir; - sTmp = "Exporting"; - if (_ExportCB != NULL) _ExportCB->dispInfo (sTmp); - doExport (*_Options, _ExportCB, &vExportPrimitives); - - // Copy new files for incremental purpose - CTools::chdir (_ExeDir); - sTmp = "Incrementing"; - if (_ExportCB != NULL) _ExportCB->dispInfo (sTmp); - for (nRegion = 0; nRegion < vRegions.size(); ++nRegion) - { - CTools::chdir (sContinentDir + vRegions[nRegion]); - vector vFiles; - CTools::dirSub ("*.prim", vFiles, true); - for (i = 0; i < vFiles.size(); ++i) - { - string sDst = vFiles[i].substr (sContinentDir.size()); - for (j = 0; j < sDst.size(); ++j) - if (sDst[j] == '\\') - sDst[j] = '-'; - sDst = _OutIGDir + sDst; - CTools::copy (sDst, vFiles[i]); - } - CTools::chdir (sContinentDir + vRegions[nRegion]); - CTools::dirSub ("*.flora", vFiles, true); - for (i = 0; i < vFiles.size(); ++i) - { - string sDst = vFiles[i].substr (sContinentDir.size()); - for (j = 0; j < sDst.size(); ++j) - if (sDst[j] == '\\') - sDst[j] = '-'; - sDst = _OutIGDir + sDst; - CTools::copy (sDst, vFiles[i]); - } - - // ------------------------------------------------------------------- - // If the new file do not exists anymore but the old file exists -> delete old file - CTools::chdir (_OutIGDir); - CTools::dir (vRegions[nRegion] + "-*.prim", vFiles, false); - for (i = 0; i < vFiles.size(); ++i) - { - // Get the name of the recent file - string sNewName = vFiles[i]; - for (j = 0; j < sNewName.size(); ++j) - if (sNewName[j] == '-') - sNewName[j] = '\\'; - - sNewName = sContinentDir + sNewName; - if (!CTools::fileExist(sNewName)) - { - // Delete the oldest file - CFile::deleteFile(vFiles[i]); - } - } - - // If the new file do not exists anymore but the old file exists -> delete old file - CTools::dir (vRegions[nRegion] + "-*.flora", vFiles, false); - for (i = 0; i < vFiles.size(); ++i) - { - // Get the name of the recent file - string sNewName = vFiles[i]; - for (j = 0; j < sNewName.size(); ++j) - if (sNewName[j] == '-') - sNewName[j] = '\\'; - - sNewName = sContinentDir + sNewName; - if (!CTools::fileExist(sNewName)) - { - // Delete the oldest file - CFile::deleteFile(vFiles[i]); - } - } - } - - CTools::chdir (_ExeDir); - return true; -} - -// --------------------------------------------------------------------------- -bool CExport::doExport (SExportOptions &opt, IExportCB *expCB, vector *selection) -{ - char sTmp[MAX_PATH]; - GetCurrentDirectory (MAX_PATH, sTmp); - - _Options = &opt; - _ExportCB = expCB; - - // Does we have something to export - if ((selection != NULL) && (selection->size() == 0)) - { - if (_ExportCB) - _ExportCB->dispInfo ("Nothing to export"); - return true; - } - - // If we want to generate flora then we have to load the landscape - uint32 i; - - if (_ExportCB) - _ExportCB->dispPass ("Load Landscape"); - if (_Landscape == NULL) - { - _Landscape = new CLandscape; - _Landscape->init (); - _VCM = new CVisualCollisionManager; - _VCE = _VCM->createEntity (); - _VCM->setLandscape (_Landscape); - _VCE->setSnapToRenderedTesselation (false); - try - { - CIFile bankFile (_LandBankFile); - _Landscape->TileBank.serial (bankFile); - CIFile farbankFile (_LandFarBankFile); - _Landscape->TileFarBank.serial (farbankFile); - _Landscape->TileBank.makeAllPathRelative (); - _Landscape->TileBank.setAbsPath (""); - _Landscape->TileBank.makeAllExtensionDDS (); - _Landscape->initTileBanks (); - - loadLandscape (_LandFile); - } - catch (const Exception &/*e*/) - { - if (_ExportCB) - _ExportCB->dispError ("Cannot load banks files"); - } - } - - _FloraInsts.clear (); - if (_ExportCB) - _ExportCB->dispPass ("Generate Flora"); - vector allFloraFiles; - SetCurrentDirectory (_Options->PrimFloraDir.c_str()); - getAllFiles (".Flora", allFloraFiles); - SetCurrentDirectory (sTmp); - for (i = 0; i < allFloraFiles.size(); ++i) - { - generateIGFromFlora (allFloraFiles[i], selection); - } - - writeFloraIG (_LandFile, (selection != NULL)); // If selection != NULL then test for writing - - SetCurrentDirectory (sTmp); - if (_ExportCB) - _ExportCB->dispPass ("Finished"); - - return true; -} - -// --------------------------------------------------------------------------- -void CExport::getAllFiles (const string &ext, vector &files) -{ - char sCurDir[MAX_PATH]; - GetCurrentDirectory (MAX_PATH, sCurDir); - - WIN32_FIND_DATA findData; - HANDLE hFind = FindFirstFile ("*.*", &findData); - while (hFind != INVALID_HANDLE_VALUE) - { - if (!((strcmp (findData.cFileName, ".") == 0) || (strcmp (findData.cFileName, "..") == 0))) - { - if (findData.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) - { - string sNewDir = sCurDir; - sNewDir += string("\\") + findData.cFileName; - SetCurrentDirectory (sNewDir.c_str()); - getAllFiles (ext, files); - SetCurrentDirectory (sCurDir); - } - else - { - if (strlen(findData.cFileName) > strlen(ext.c_str())) - if (stricmp(&findData.cFileName[strlen(findData.cFileName)-strlen(ext.c_str())], ext.c_str()) == 0) - { - string fullName = sCurDir; - fullName += string("\\") + findData.cFileName; - fullName = strlwr (fullName); - files.push_back (fullName); - } - } - } - - if (FindNextFile (hFind, &findData) == 0) - break; - } - FindClose (hFind); - - SetCurrentDirectory (sCurDir); -} - -// --------------------------------------------------------------------------- -bool CExport::searchFile (const std::string &plantName, std::string &dir) -{ - char sCurDir[MAX_PATH]; - bool bFound = false; - GetCurrentDirectory (MAX_PATH, sCurDir); - - WIN32_FIND_DATA findData; - HANDLE hFind = FindFirstFile ("*.*", &findData); - while (hFind != INVALID_HANDLE_VALUE) - { - string filename = findData.cFileName; - filename = strlwr(filename); - if (!((filename == ".") || (filename == ".."))) - { - if (findData.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) - { - string sNewDir = sCurDir; - sNewDir += string("\\") + filename; - SetCurrentDirectory (sNewDir.c_str()); - if (searchFile (plantName, dir)) - { - bFound = true; - break; - } - SetCurrentDirectory (sCurDir); - } - else - { - if (strlwr(plantName) == filename) - { - dir = sCurDir; - bFound = true; - break; - } - } - } - - if (FindNextFile (hFind, &findData) == 0) - break; - } - FindClose (hFind); - SetCurrentDirectory (sCurDir); - return bFound; -} - -// --------------------------------------------------------------------------- -bool CExport::generateIGFromFlora (const std::string &SrcFile, std::vector *selection) -{ - uint32 i, j, k, l, m; - - if (_ExportCB) - _ExportCB->dispPass ("Generating From " + SrcFile); - - // Load all .prim - vector allPrimRegion; - vector allPrimFiles; - { - char sCurDir[MAX_PATH]; - GetCurrentDirectory (MAX_PATH, sCurDir); - SetCurrentDirectory (_Options->PrimFloraDir.c_str()); - getAllFiles (".prim", allPrimFiles); - SetCurrentDirectory (sCurDir); - for (i = 0; i < allPrimFiles.size(); ++i) - { - try - { - CPrimRegion tmpPrimRegion; - CIFile fileIn; - fileIn.open (allPrimFiles[i]); - CIXml input; - input.init (fileIn); - tmpPrimRegion.serial (input); - allPrimRegion.push_back (tmpPrimRegion); - } - catch (const Exception &/*e*/) - { - if (_ExportCB != NULL) - _ExportCB->dispWarning (string("Cant load ") + allPrimFiles[i]); - CPrimRegion tmpPrimRegion; - allPrimRegion.push_back (tmpPrimRegion); - } - } - } - - // Load the .Flora file (georges file) and load all associated .plant - SFormFlora formFlora; - map Plants; - { - // Create a loader - UFormLoader *loader = UFormLoader::createLoader (); -// CPath::addSearchPath (_Options->DfnDir, true, true); -// CPath::addSearchPath (_Options->GameElemDir, true, true); -// CPath::addSearchPath (_Options->LandTileNoiseDir, true, true); - - // Load the form - CSmartPtr form = loader->loadForm (SrcFile.c_str ()); - if (form == NULL) - { - if (_ExportCB != NULL) - _ExportCB->dispError (string("Cant load ") + SrcFile ); - } - else - { - // Read .Flora - formFlora.build (form->getRootNode ()); - - // Load the .plant associated - for (i = 0; i < formFlora.PlantInstances.size(); ++i) - { - const string &plantName = formFlora.PlantInstances[i].Name; - map::iterator it = Plants.find (plantName); - if (it != Plants.end()) // Already here ?! - continue; // Zap it - - char sCurDir[MAX_PATH]; - GetCurrentDirectory (MAX_PATH, sCurDir); - - try - { - SetCurrentDirectory (_GameElemDir.c_str()); - string dir; - - if (searchFile (plantName, dir)) - { - string tmpName = dir + string("\\") + plantName; - - CSmartPtr form2 = loader->loadForm (tmpName.c_str()); - if (form2) - { - SFormPlant plantTmp; - plantTmp.build (form2->getRootNode ()); - Plants.insert (map::value_type(plantName, plantTmp)); - } - else - { - if (_ExportCB != NULL) - _ExportCB->dispWarning (string("Cant load ") + plantName); - } - } - else - { - if (_ExportCB != NULL) - _ExportCB->dispWarning (string("Cant load ") + plantName); - } - SetCurrentDirectory (sCurDir); - } - catch (const Exception &e) - { - SetCurrentDirectory (sCurDir); - if (_ExportCB != NULL) - _ExportCB->dispWarning (string("Cant load ") + plantName + "(" + e.what() + ")" ); - } - } - } - } - - // Sort PlantInstances by biggest radius first - if (formFlora.PlantInstances.size() > 1) - for (i = 0; i < (formFlora.PlantInstances.size()-1); ++i) - for (j = i+1; j < formFlora.PlantInstances.size(); ++j) - { - SPlantInstance &rPlantI = formFlora.PlantInstances[i]; - SPlantInstance &rPlantJ = formFlora.PlantInstances[j]; - map::iterator it = Plants.find (rPlantI.Name); - if (it == Plants.end()) - continue; - SFormPlant &rFormPlantI = it->second; - - it = Plants.find (rPlantJ.Name); - if (it == Plants.end()) - continue; - SFormPlant &rFormPlantJ = it->second; - if (rFormPlantI.BoundingRadius < rFormPlantJ.BoundingRadius) - { - SPlantInstance pi = formFlora.PlantInstances[i]; - formFlora.PlantInstances[i] = formFlora.PlantInstances[j]; - formFlora.PlantInstances[j] = pi; - } - } - - // Generating - float jitter = formFlora.JitterPos; - clamp (jitter, 0.0f, 1.0f); - srand (formFlora.RandomSeed); - for (i = 0; i < formFlora.IncludePatats.size(); ++i) - { - uint32 nCurPlant = 0; - CVector vMin, vMax; - - if (_ExportCB) - _ExportCB->dispPass ("IncludePatats("+toString(i+1)+"/"+toString(formFlora.IncludePatats.size())+")"); - - // Get the patat - CPrimZone *pPatat = NULL; - CPrimPoint *pPoint = NULL; - CPrimPath *pPath = NULL; - - // Look if this is a patat - for (j = 0; j < allPrimRegion.size(); ++j) - { - for (k = 0; k < allPrimRegion[j].VZones.size(); ++k) - { - if (allPrimRegion[j].VZones[k].getName() == formFlora.IncludePatats[i]) - { - if (selection != NULL) - { - SExportPrimitive epTmp; - epTmp.FullPrimName = allPrimFiles[j]; - epTmp.PrimitiveName = allPrimRegion[j].VZones[k].getName(); - for (m = 0; m < selection->size(); ++m) - if (selection->operator[](m) == epTmp) - { - pPatat = &allPrimRegion[j].VZones[k]; - break; - } - } - else - { - pPatat = &allPrimRegion[j].VZones[k]; - } - } - } - } - - //Look if this is a point - for (j = 0; j < allPrimRegion.size(); ++j) - { - for (k = 0; k < allPrimRegion[j].VPoints.size(); ++k) - { - if (allPrimRegion[j].VPoints[k].getName() == formFlora.IncludePatats[i]) - { - if (selection != NULL) - { - SExportPrimitive epTmp; - epTmp.FullPrimName = allPrimFiles[j]; - epTmp.PrimitiveName = allPrimRegion[j].VPoints[k].getName(); - for (m = 0; m < selection->size(); ++m) - if (selection->operator[](m) == epTmp) - { - pPoint = &allPrimRegion[j].VPoints[k]; - break; - } - } - else - { - pPoint = &allPrimRegion[j].VPoints[k]; - } - } - } - } - - //Look if this is a path - for (j = 0; j < allPrimRegion.size(); ++j) - { - for (k = 0; k < allPrimRegion[j].VPaths.size(); ++k) - { - if (allPrimRegion[j].VPaths[k].getName() == formFlora.IncludePatats[i]) - { - if (selection != NULL) - { - SExportPrimitive epTmp; - epTmp.FullPrimName = allPrimFiles[j]; - epTmp.PrimitiveName = allPrimRegion[j].VPaths[k].getName(); - for (m = 0; m < selection->size(); ++m) - if (selection->operator[](m) == epTmp) - { - pPath = &allPrimRegion[j].VPaths[k]; - break; - } - } - else - { - pPath = &allPrimRegion[j].VPaths[k]; - } - } - } - } - - - if ((pPatat == NULL) && (pPoint == NULL) && (pPath == NULL)) - { - if (selection == NULL) - if (_ExportCB) - _ExportCB->dispWarning ("Cannot find " + formFlora.IncludePatats[i]); - continue; - } - - if ((pPatat != NULL) && (pPatat->VPoints.size() <= 2)) - { - if (_ExportCB) - _ExportCB->dispWarning ("Patat " + pPatat->getName() + " has less than 3 points"); - continue; - } - - if ((pPath != NULL) && (pPath->VPoints.size() <= 1)) - { - if (_ExportCB) - _ExportCB->dispWarning ("Path " + pPath->getName() + " has less than 2 points"); - continue; - } - - // Generate for a patat - if (pPatat != NULL) - { - vMin = vMax = pPatat->VPoints[0]; - for (j = 0; j < pPatat->VPoints.size(); ++j) - { - if (vMin.x > pPatat->VPoints[j].x) vMin.x = pPatat->VPoints[j].x; - if (vMin.y > pPatat->VPoints[j].y) vMin.y = pPatat->VPoints[j].y; - if (vMin.z > pPatat->VPoints[j].z) vMin.z = pPatat->VPoints[j].z; - if (vMax.x < pPatat->VPoints[j].x) vMax.x = pPatat->VPoints[j].x; - if (vMax.y < pPatat->VPoints[j].y) vMax.y = pPatat->VPoints[j].y; - if (vMax.z < pPatat->VPoints[j].z) vMax.z = pPatat->VPoints[j].z; - } - - for (j = 0; j < formFlora.PlantInstances.size(); ++j) - { - SPlantInstance &rPlant = formFlora.PlantInstances[j]; - map::iterator it = Plants.find (rPlant.Name); - if (it == Plants.end()) - { - if (_ExportCB) - _ExportCB->dispWarning ("Cannot find " + rPlant.Name); - continue; - } - SFormPlant &rFormPlant = it->second; - - float squareLength = (float)sqrt (Pi*rFormPlant.BoundingRadius*rFormPlant.BoundingRadius / rPlant.Density); - uint32 nNbPlantX = 1+(int)floor ((vMax.x-vMin.x) / squareLength); - uint32 nNbPlantY = 1+(int)floor ((vMax.y-vMin.y) / squareLength); - for (l = 0; l < nNbPlantY; ++l) - for (k = 0; k < nNbPlantX; ++k) - { - if (_ExportCB) - _ExportCB->dispPassProgress (((float)(k+l*nNbPlantX))/((float)(nNbPlantX*nNbPlantY))); - - bool bExists = false; - CVector pos; - float scaleTmp; - for (m = 0; m < 32; ++m) - { - pos.x = vMin.x + squareLength * k + (frand(2.0f)-1.0f) * jitter * 0.5f * squareLength; - pos.y = vMin.y + squareLength * l + (frand(2.0f)-1.0f) * jitter * 0.5f * squareLength; - pos.z = 0.0f; - scaleTmp = (formFlora.ScaleMax-formFlora.ScaleMin)*frand(1.0)+formFlora.ScaleMin; - if (pPatat->contains(pos)) - { - if (isWellPlaced(pos, rPlant, rFormPlant, scaleTmp)) - { - // Testt finally with the exclude patats ... - bExists = true; - for (uint32 expat = 0; expat < formFlora.ExcludePatats.size(); ++expat) - { - CPrimZone *pExPatat = NULL; - for (uint32 epj = 0; epj < allPrimRegion.size(); ++epj) - for (uint32 epk = 0; epk < allPrimRegion[epj].VZones.size(); ++epk) - if (allPrimRegion[epj].VZones[epk].getName() == formFlora.ExcludePatats[expat]) - { - pExPatat = &allPrimRegion[epj].VZones[epk]; - break; - } - if (pExPatat != NULL) - { - if (pExPatat->contains(pos)) - { - bExists = false; - break; - } - } - } - if (bExists) - break; - } - } - } - - if (!bExists) - continue; - - SFloraInst vi; - vi.ShapeName = rFormPlant.Shape; - vi.PlantName = rPlant.Name; - vi.Scale = scaleTmp; - vi.Radius = rFormPlant.BoundingRadius * vi.Scale; - vi.Rot = (float)Pi * frand (1.0); - - if (formFlora.PutOnWater) - { - if (pos.z < formFlora.WaterHeight) - pos.z = formFlora.WaterHeight; - } - vi.Pos = pos; - _FloraInsts.push_back (vi); - } // End of for all position of a plant x,y check if we cant put it - } // End of for all plant instances - } // End of Generate for a patat - - // Generate for a point - if (pPoint != NULL) - { - // Choose a plant - float total = 0.0f; - for (j = 0; j < formFlora.PlantInstances.size(); ++j) - { - total += formFlora.PlantInstances[j].Density; - } - float posf = total * frand(1.0); - total = 0.0f; - for (j = 0; j < formFlora.PlantInstances.size(); ++j) - { - total += formFlora.PlantInstances[j].Density; - if (posf < total) break; - } - if (j == formFlora.PlantInstances.size()) - j = (uint32)formFlora.PlantInstances.size()-1; - - SPlantInstance &rPlant = formFlora.PlantInstances[j]; - map::iterator it = Plants.find (rPlant.Name); - if (it == Plants.end()) - { - if (_ExportCB) - _ExportCB->dispWarning ("Cannot find " + rPlant.Name); - continue; - } - SFormPlant &rFormPlant = it->second; - - SFloraInst vi; - vi.ShapeName = rFormPlant.Shape; - vi.PlantName = rPlant.Name; - vi.Scale = (formFlora.ScaleMax-formFlora.ScaleMin)*frand(1.0)+formFlora.ScaleMin; - vi.Radius = rFormPlant.BoundingRadius * vi.Scale; - vi.Rot = (float)Pi * frand (1.0); - - CVector pos; - pos.x = pPoint->Point.x; - pos.y = pPoint->Point.y; - pos.z = getZFromXY (pos.x, pos.y); - if (formFlora.PutOnWater) - { - if (pos.z < formFlora.WaterHeight) - pos.z = formFlora.WaterHeight; - } - vi.Pos = pos; - if (pos.z > -90000.0f) - _FloraInsts.push_back (vi); - - } // End of Generate for a point - - // Generate for a path - if (pPath != NULL) - { - float rLength = 0.0f; // Total length of the broken line - for (j = 0; j < pPath->VPoints.size()-1; ++j) - { - rLength += (pPath->VPoints[j]-pPath->VPoints[j+1]).norm(); - } - - for (j = 0; j < formFlora.PlantInstances.size(); ++j) - { - SPlantInstance &rPlant = formFlora.PlantInstances[j]; - map::iterator it = Plants.find (rPlant.Name); - if (it == Plants.end()) - { - if (_ExportCB) - _ExportCB->dispWarning ("Cannot find " + rPlant.Name); - continue; - } - SFormPlant &rFormPlant = it->second; - - float squareLength = (float)(2*rFormPlant.BoundingRadius / rPlant.Density); - uint32 nNbPlant = 1+(int)floor (rLength / squareLength); - - for (k = 0; k < nNbPlant; ++k) - { - if (_ExportCB) - _ExportCB->dispPassProgress (((float)(k))/((float)(nNbPlant))); - - bool bExists = false; - CVector pos; - float scaleTmp; - for (m = 0; m < 32; ++m) - { - // Calculate the curviline abscisse - float curvAbs = squareLength * k + (frand(2.0f)-1.0f) * jitter * 0.5f * squareLength; - float TempLength = 0.0f; - // Convert to a real point along the curve (broken line) - for (l = 0; l < pPath->VPoints.size()-1; ++l) - { - float newSize = (pPath->VPoints[l]-pPath->VPoints[l+1]).norm(); - if (curvAbs < (TempLength+newSize)) - { - curvAbs -= TempLength; - break; - } - TempLength += newSize; - } - if (l == (pPath->VPoints.size()-1)) - { - l = (uint32)pPath->VPoints.size()-2; - curvAbs = (pPath->VPoints[l]-pPath->VPoints[l+1]).norm(); - } - // Calculate the coord - curvAbs = curvAbs / (pPath->VPoints[l]-pPath->VPoints[l+1]).norm(); - pos = pPath->VPoints[l] + (pPath->VPoints[l+1]-pPath->VPoints[l])*curvAbs; - pos.z = 0.0f; - scaleTmp = (formFlora.ScaleMax-formFlora.ScaleMin)*frand(1.0)+formFlora.ScaleMin; - if (isWellPlaced(pos, rPlant, rFormPlant, scaleTmp)) - { - // Test finally with the exclude patats ... - bExists = true; - for (uint32 expat = 0; expat < formFlora.ExcludePatats.size(); ++expat) - { - CPrimZone *pExPatat = NULL; - for (uint32 epj = 0; epj < allPrimRegion.size(); ++epj) - for (uint32 epk = 0; epk < allPrimRegion[epj].VZones.size(); ++epk) - if (allPrimRegion[epj].VZones[epk].getName() == formFlora.ExcludePatats[expat]) - { - pExPatat = &allPrimRegion[epj].VZones[epk]; - break; - } - if (pExPatat != NULL) - { - if (pExPatat->contains(pos)) - { - bExists = false; - break; - } - } - } - if (bExists) - break; - } - } - - if (!bExists) - continue; - - SFloraInst vi; - vi.ShapeName = rFormPlant.Shape; - vi.PlantName = rPlant.Name; - vi.Scale = scaleTmp; - vi.Radius = rFormPlant.BoundingRadius * vi.Scale; - vi.Rot = (float)Pi * frand (1.0); - - if (formFlora.PutOnWater) - { - if (pos.z < formFlora.WaterHeight) - pos.z = formFlora.WaterHeight; - } - vi.Pos = pos; - _FloraInsts.push_back (vi); - } // End of for all position of a plant x,y check if we cant put it - } // End of for all plant instances - - } // End of Generate for a path - - } // End of for all IncludePatats - return true; -} - -// --------------------------------------------------------------------------- -float CExport::getZFromXY (float x, float y) -{ - CVector pos = CVector(x, y, 0); - CVector normal; - float z, zmin, zmax; - - // Approximate the z with patch bounding boxes - sint32 zoneX = (sint32)floor (x/_Options->CellSize); - sint32 zoneY = (sint32)floor (-y/_Options->CellSize); - sint32 zoneId = zoneY * 256 + zoneX; - CZone *pZone = _Landscape->getZone (zoneId); - if (pZone == NULL) - return -100000.0f; - - CAABBoxExt bb = pZone->getZoneBB(); - zmin = bb.getMin().z; - zmax = bb.getMax().z; - pos.z = zmin; - z = zmin; - while (z < zmax) - { - if (_VCE->snapToGround(pos, normal)) - break; - z += CVisualCollisionEntity::BBoxRadiusZ / 2.0f; // Super sampling due to max frequency on radiosity - pos.z = z; - } - - if (z >= zmax) - return -100000.0f; - - return pos.z; -} - -// --------------------------------------------------------------------------- -bool CExport::isWellPlaced (CVector &pos, SPlantInstance &rPI, SFormPlant &rFP, float scale) -{ - uint32 i; - - // Look if this Flora intersect with one of the current ones - for (i = 0; i < _FloraInsts.size(); ++i) - { - CVector temp = _FloraInsts[i].Pos - pos; - temp.z = 0.0f; - if (temp.norm() < (_FloraInsts[i].Radius + scale*rFP.BoundingRadius)) - return false; - } - - // Get the real Z - pos.z = getZFromXY (pos.x, pos.y); - if (pos.z < -90000.0f) - return false; - - // Get some Z around to see if we can put the Flora on the ground - uint32 nNbSamples = 8; // Const to be put somewhere - vector base; - base.resize (nNbSamples); - for (i = 0; i < nNbSamples; ++i) - { - base[i] = pos; - base[i].x += scale * rFP.CollisionRadius * cosf((2.0f*(float)Pi*i)/(float)nNbSamples); - base[i].y += scale * rFP.CollisionRadius * sinf((2.0f*(float)Pi*i)/(float)nNbSamples); - base[i].z = getZFromXY (base[i].x, base[i].y); - - if (fabs(base[i].z-pos.z) > 0.8f) - return false; - } - - return true; -} - -// --------------------------------------------------------------------------- -void CExport::writeFloraIG (const string &LandFile, bool bTestForWriting) -{ - sint32 i, j, k; - - if (_FloraInsts.size() == 0) - return; - - CZoneRegion zoneRegion; - CIFile inFile; - if (inFile.open (LandFile)) - { - CIXml xml(true); - xml.init (inFile); - zoneRegion.serial (xml); - - inFile.close(); - } - else - { - nlwarning ("Can't open the file %s", LandFile.c_str()); - } - - // Load all zone - - for (j = zoneRegion.getMinY(); j <= zoneRegion.getMaxY(); ++j) - for (i = zoneRegion.getMinX(); i <= zoneRegion.getMaxX(); ++i) - { - if ((zoneRegion.getName(i,j) == STRING_OUT_OF_BOUND) || - (zoneRegion.getName(i,j) == STRING_UNUSED)) - continue; - - vector vegZone; - // Take all Flora instances in the zone (i,j) - for (k = 0; k < (sint32)_FloraInsts.size(); ++k) - { - if (((i*_Options->CellSize) < _FloraInsts[k].Pos.x) && (_FloraInsts[k].Pos.x < ((i+1)*_Options->CellSize)) && - ((j*_Options->CellSize) < _FloraInsts[k].Pos.y) && (_FloraInsts[k].Pos.y < ((j+1)*_Options->CellSize))) - { - vegZone.push_back (k); - } - } - - - // Make the .IG - string ZoneName = ""; - ZoneName += NLMISC::toString(-j) + "_"; - ZoneName += 'a' + (i/26); - ZoneName += 'a' + (i%26); - - CVector vGlobalPos = CVector (0.0f, 0.0f, 0.0f); - CInstanceGroup::TInstanceArray Instances; - vector Portals; - vector Clusters; - Instances.resize (vegZone.size()); - - for (k = 0; k < (sint32)vegZone.size(); ++k) - { -//vGlobalPos += _FloraInsts[vegZone[k]].Pos; - Instances[k].Pos = _FloraInsts[vegZone[k]].Pos; - Instances[k].Rot = CQuat(CVector::K, _FloraInsts[vegZone[k]].Rot); - Instances[k].Scale = CVector(_FloraInsts[vegZone[k]].Scale, _FloraInsts[vegZone[k]].Scale, _FloraInsts[vegZone[k]].Scale); - Instances[k].nParent = -1; - Instances[k].Name = _FloraInsts[vegZone[k]].ShapeName; - Instances[k].InstanceName = _FloraInsts[vegZone[k]].PlantName; - /*Instances[k].InstanceName = "Flora_"; // see if it works - Instances[k].InstanceName += ZoneName + "_"; - Instances[k].InstanceName += '0' + ((k/1000)%10); - Instances[k].InstanceName += '0' + ((k/100) %10); - Instances[k].InstanceName += '0' + ((k/10) %10); - Instances[k].InstanceName += '0' + ( k %10);*/ - } - -// \todo trap -> look why it dont seems to work with a global positionning -//vGlobalPos /= (float)vegZone.size(); -//for (k = 0; k < (sint32)vegZone.size(); ++k) -// Instances[k].Pos -= vGlobalPos; - - CInstanceGroup IG; - IG.build (vGlobalPos, Instances, Portals, Clusters); - - ZoneName = _OutIGDir + "\\" + ZoneName; - ZoneName += ".ig"; - - CIFile inFile; // If file already exists and we have selection... - if (bTestForWriting) - if (inFile.open(ZoneName)) - { - inFile.close(); - continue; - } - - try - { - COFile outFile (ZoneName); - IG.serial (outFile); - if (_ExportCB != NULL) - _ExportCB->dispInfo (ZoneName + " generated"); - } - catch (const Exception &e) - { - if (_ExportCB != NULL) - _ExportCB->dispWarning ("Cant write " + ZoneName + " (" + e.what() + ")"); - } - } -} - -// --------------------------------------------------------------------------- -void CExport::loadLandscape (const string &LandFile) -{ - CZoneRegion zoneRegion; - - CIFile inFile; - try - { - if (inFile.open (LandFile)) - { - CIXml xml(true); - xml.init (inFile); - zoneRegion.serial (xml); - - inFile.close(); - } - else - { - if (_ExportCB != NULL) - _ExportCB->dispWarning (string("Can't open file ") + LandFile); - } - } - catch (const Exception &e) - { - if (_ExportCB != NULL) - _ExportCB->dispWarning (string("Cant load ") + LandFile + " : " + e.what()); - } - // Load all zone - - sint32 nTotalFile = (1 + zoneRegion.getMaxY() - zoneRegion.getMinY()) * (1 + zoneRegion.getMaxX() - zoneRegion.getMinX()); - sint32 nCurrentFile = 0; - for (sint32 j = zoneRegion.getMinY(); j <= zoneRegion.getMaxY(); ++j) - for (sint32 i = zoneRegion.getMinX(); i <= zoneRegion.getMaxX(); ++i) - { - ++nCurrentFile; - if (_ExportCB != NULL) - _ExportCB->dispPassProgress(((float)nCurrentFile)/((float)nTotalFile)); - - if ((zoneRegion.getName(i,j) == STRING_OUT_OF_BOUND) || - (zoneRegion.getName(i,j) == STRING_UNUSED)) - continue; - - // Generate zone name - - string ZoneName = getZoneNameFromXY (i, j); - - ZoneName = _InLandscapeDir + string("\\") + ZoneName; - - //if (_ExportCB != NULL) - // _ExportCB->dispInfo (string("Loading ") + ZoneName); - - try - { - CZone zone; - if (!inFile.open (ZoneName + string(".zonew"))) - inFile.open (ZoneName + string(".zonel")); - zone.serial (inFile); - inFile.close (); - _Landscape->addZone (zone); - } - catch(const Exception &/*e*/) - { - if (_ExportCB != NULL) - _ExportCB->dispWarning (string("Cant load ") + ZoneName + string(".zone(l,w)")); - } - if ((_ExportCB != NULL) && (_ExportCB->isCanceled())) - return; - } - -} - -// Public Helpers -// ************** - -// --------------------------------------------------------------------------- -string CExport::getZoneNameFromXY (sint32 x, sint32 y) -{ - string tmp; - - if ((y>0) || (y<-255) || (x<0) || (x>255)) - return "NOT VALID"; - tmp = toString(-y) + "_"; - tmp += ('A' + (x/26)); - tmp += ('A' + (x%26)); - return tmp; -} - -// --------------------------------------------------------------------------- -sint32 CExport::getXFromZoneName (const string &ZoneName) -{ - string xStr, yStr; - uint32 i = 0; - while (ZoneName[i] != '_') - { - yStr += ZoneName[i]; ++i; - if (i == ZoneName.size()) - return -1; - } - ++i; - while (i < ZoneName.size()) - { - xStr += ZoneName[i]; ++i; - } - return ((xStr[0] - 'A')*26 + (xStr[1] - 'A')); -} - -// --------------------------------------------------------------------------- -sint32 CExport::getYFromZoneName (const string &ZoneName) -{ - string xStr, yStr; - uint32 i = 0; - while (ZoneName[i] != '_') - { - yStr += ZoneName[i]; ++i; - if (i == ZoneName.size()) - return 1; - } - ++i; - while (i < ZoneName.size()) - { - xStr += ZoneName[i]; ++i; - } - return -atoi(yStr.c_str()); -} +// 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 "export.h" +#include "formFlora.h" +#include "formPlant.h" +#ifdef NL_OS_WINDOWS +#define NOMINMAX +#include +#endif // NL_OS_WINDOWS + +#include "nel/ligo/zone_region.h" +#include "nel/ligo/primitive.h" + +#include "nel/georges/u_form_loader.h" +#include "nel/georges/u_form.h" +#include "nel/georges/u_form_elm.h" + +#include "nel/3d/zone.h" +#include "nel/3d/landscape.h" +#include "nel/3d/scene_group.h" +#include "nel/3d/visual_collision_manager.h" +#include "nel/3d/visual_collision_entity.h" + +#include "nel/misc/o_xml.h" +#include "nel/misc/i_xml.h" +#include "nel/misc/path.h" +#include "nel/misc/file.h" + +#include "tools.h" +#include "../master/ContinentCfg.h" + +using namespace std; +using namespace NLMISC; +using namespace NL3D; +using namespace NLLIGO; +using namespace NLGEORGES; + +#define MAX_SYS_DIR 6 +const char *gExportSysDir[MAX_SYS_DIR] = +{ + ".", + "..", + "ZoneBitmaps", + "ZoneLigos", + "dfn", + "tmp" +}; + + +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- +// --------------------------------------------------------------------------- + +// ----------------------------------------------------------------------------------------------- +// Segment line intersection P1P2 and P3P4 +bool CExport::segmentIntersection(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4) +{ + double denominator = (y4-y3)*(x2-x1) - (x4-x3)*(y2-y1); + if( denominator == 0.0 ) + return false; // The segment are colinear + double k = ((x4-x3)*(y1-y3) - (y4-y3)*(x1-x3) ) / denominator; + if( (k<=0.0) || (k>=1.0) ) return false; + k = ( (x2-x1)*(y1-y3) - (y2-y1)*(x1-x3) ) / denominator; + if( (k<=0.0) || (k>=1.0) ) return false; + return true; +} + +// --------------------------------------------------------------------------- +void CExport::delIGZone (sint32 x, sint32 y) +{ + string sZoneName = CExport::getZoneNameFromXY (x, y); + sZoneName += ".ig"; + if (CFile::deleteFile(sZoneName)) + { + CTools::chdir (_ExeDir); + string sTmp = string(" zone ") + sZoneName + " deleted"; + if (_ExportCB != NULL) + _ExportCB->dispInfo(sTmp); + } +} + +// --------------------------------------------------------------------------- +void CExport::delAllIGZoneUnderPoint (float fCellSize, CPrimPoint *pPoint, const string &sIGOutputDir) +{ + if (pPoint == NULL) return; + sint32 nX, nY; + CTools::chdir (sIGOutputDir); + nX = (sint32) floor (pPoint->Point.x / fCellSize); + nY = (sint32) floor (pPoint->Point.y / fCellSize); + delIGZone (nX, nY); + CTools::chdir (sIGOutputDir); +} + +// --------------------------------------------------------------------------- +void CExport::delAllIGZoneUnderPath (float fCellSize, CPrimPath *pPath, const string &sIGOutputDir) +{ + if (pPath == NULL) return; + if (pPath->VPoints.size() == 0) return; + uint32 i, j; + CVector vMin, vMax; + + CTools::chdir (sIGOutputDir); + vMin = vMax = pPath->VPoints[0]; + for (i = 0; i < pPath->VPoints.size(); ++i) + { + if (vMin.x > pPath->VPoints[i].x) vMin.x = pPath->VPoints[i].x; + if (vMin.y > pPath->VPoints[i].y) vMin.y = pPath->VPoints[i].y; + if (vMin.z > pPath->VPoints[i].z) vMin.z = pPath->VPoints[i].z; + if (vMax.x < pPath->VPoints[i].x) vMax.x = pPath->VPoints[i].x; + if (vMax.y < pPath->VPoints[i].y) vMax.y = pPath->VPoints[i].y; + if (vMax.z < pPath->VPoints[i].z) vMax.z = pPath->VPoints[i].z; + } + + sint32 x, y; + sint32 nMinX, nMinY, nMaxX, nMaxY; + nMinX = (sint32) floor (vMin.x / fCellSize); + nMinY = (sint32) floor (vMin.y / fCellSize); + nMaxX = (sint32) floor (vMax.x / fCellSize); + nMaxY = (sint32) floor (vMax.y / fCellSize); + + for (x = nMinX; x <= nMaxX; ++x) + for (y = nMinY; y <= nMaxY; ++y) + { + // Does the zone (x,y) is under the patah ? + + CVector vSquare[4]; + vSquare[0].x = x * fCellSize; + vSquare[0].y = y * fCellSize; + vSquare[0].z = 0.0f; + + vSquare[1].x = (x+1) * fCellSize; + vSquare[1].y = y * fCellSize; + vSquare[1].z = 0.0f; + + vSquare[2].x = (x+1) * fCellSize; + vSquare[2].y = (y+1) * fCellSize; + vSquare[2].z = 0.0f; + + vSquare[3].x = x * fCellSize; + vSquare[3].y = (y+1) * fCellSize; + vSquare[3].z = 0.0f; + + // Is a vertex of the path inside the zone ? + for (i = 0; i < pPath->VPoints.size(); ++i) + { + if ((pPath->VPoints[i].x >= (x*fCellSize)) && + (pPath->VPoints[i].x <= ((x+1)*fCellSize)) && + (pPath->VPoints[i].y <= (y*fCellSize)) && + (pPath->VPoints[i].y <= ((y+1)*fCellSize))) + { + delIGZone (x, y); + CTools::chdir (sIGOutputDir); + } + } + + // Is an segment of the path cut an edge of the patat ? + for (i = 0; i < pPath->VPoints.size()-1; ++i) + for (j = 0; j < 4; ++j) + { + double x1 = vSquare[j].x; + double y1 = vSquare[j].y; + double x2 = vSquare[(j+1)%4].x; + double y2 = vSquare[(j+1)%4].y; + + double x3 = pPath->VPoints[i].x; + double y3 = pPath->VPoints[i].y; + double x4 = pPath->VPoints[i+1].x; + double y4 = pPath->VPoints[i+1].y; + + if (segmentIntersection(x1, y1, x2, y2, x3, y3, x4, y4)) + { + delIGZone (x, y); + CTools::chdir (sIGOutputDir); + } + } + } +} + +// --------------------------------------------------------------------------- +void CExport::delAllIGZoneUnderPatat (float fCellSize, CPrimZone *pPatat, const string &sIGOutputDir) +{ + if (pPatat == NULL) return; + if (pPatat->VPoints.size() == 0) return; + uint32 i, j; + CVector vMin, vMax; + + CTools::chdir (sIGOutputDir); + vMin = vMax = pPatat->VPoints[0]; + for (i = 0; i < pPatat->VPoints.size(); ++i) + { + if (vMin.x > pPatat->VPoints[i].x) vMin.x = pPatat->VPoints[i].x; + if (vMin.y > pPatat->VPoints[i].y) vMin.y = pPatat->VPoints[i].y; + if (vMin.z > pPatat->VPoints[i].z) vMin.z = pPatat->VPoints[i].z; + if (vMax.x < pPatat->VPoints[i].x) vMax.x = pPatat->VPoints[i].x; + if (vMax.y < pPatat->VPoints[i].y) vMax.y = pPatat->VPoints[i].y; + if (vMax.z < pPatat->VPoints[i].z) vMax.z = pPatat->VPoints[i].z; + } + + sint32 x, y; + sint32 nMinX, nMinY, nMaxX, nMaxY; + nMinX = (sint32) floor (vMin.x / fCellSize); + nMinY = (sint32) floor (vMin.y / fCellSize); + nMaxX = (sint32) floor (vMax.x / fCellSize); + nMaxY = (sint32) floor (vMax.y / fCellSize); + + for (x = nMinX; x <= nMaxX; ++x) + for (y = nMinY; y <= nMaxY; ++y) + { + // Does the zone (x,y) is under the patat ? + + // Is a vertex of the zone in the patat ? + CVector vSquare[4]; + vSquare[0].x = x * fCellSize; + vSquare[0].y = y * fCellSize; + vSquare[0].z = 0.0f; + + vSquare[1].x = (x+1) * fCellSize; + vSquare[1].y = y * fCellSize; + vSquare[1].z = 0.0f; + + vSquare[2].x = (x+1) * fCellSize; + vSquare[2].y = (y+1) * fCellSize; + vSquare[2].z = 0.0f; + + vSquare[3].x = x * fCellSize; + vSquare[3].y = (y+1) * fCellSize; + vSquare[3].z = 0.0f; + + for (i = 0; i < 4; ++i) + { + if (pPatat->contains(vSquare[i])) + { + delIGZone (x, y); + CTools::chdir (sIGOutputDir); + } + } + + // Is a vertex of the patat inside the zone ? + for (i = 0; i < pPatat->VPoints.size(); ++i) + { + if ((pPatat->VPoints[i].x >= (x*fCellSize)) && + (pPatat->VPoints[i].x <= ((x+1)*fCellSize)) && + (pPatat->VPoints[i].y <= (y*fCellSize)) && + (pPatat->VPoints[i].y <= ((y+1)*fCellSize))) + { + delIGZone (x, y); + CTools::chdir (sIGOutputDir); + } + } + + // Is an edge of the zone cut an edge of the patat ? + for (i = 0; i < pPatat->VPoints.size(); ++i) + for (j = 0; j < 4; ++j) + { + double x1 = vSquare[j].x; + double y1 = vSquare[j].y; + double x2 = vSquare[(j+1)%4].x; + double y2 = vSquare[(j+1)%4].y; + + double x3 = pPatat->VPoints[i].x; + double y3 = pPatat->VPoints[i].y; + double x4 = pPatat->VPoints[(i+1)%pPatat->VPoints.size()].x; + double y4 = pPatat->VPoints[(i+1)%pPatat->VPoints.size()].y; + + if (segmentIntersection(x1, y1, x2, y2, x3, y3, x4, y4)) + { + delIGZone (x, y); + CTools::chdir (sIGOutputDir); + } + } + } +} + +// --------------------------------------------------------------------------- +// A patat needs an update if there is at least one zone under itself that is not present +bool CExport::isPatatNeedUpdate (float fCellSize, CPrimZone *pPatat, const string &sIGOutputDir) +{ + uint32 i, j; + CVector vMin, vMax; + + CTools::chdir (sIGOutputDir); + if (pPatat->VPoints.size() == 0) + return false; + vMin = vMax = pPatat->VPoints[0]; + for (i = 0; i < pPatat->VPoints.size(); ++i) + { + if (vMin.x > pPatat->VPoints[i].x) vMin.x = pPatat->VPoints[i].x; + if (vMin.y > pPatat->VPoints[i].y) vMin.y = pPatat->VPoints[i].y; + if (vMin.z > pPatat->VPoints[i].z) vMin.z = pPatat->VPoints[i].z; + if (vMax.x < pPatat->VPoints[i].x) vMax.x = pPatat->VPoints[i].x; + if (vMax.y < pPatat->VPoints[i].y) vMax.y = pPatat->VPoints[i].y; + if (vMax.z < pPatat->VPoints[i].z) vMax.z = pPatat->VPoints[i].z; + } + + sint32 x, y; + sint32 nMinX, nMinY, nMaxX, nMaxY; + nMinX = (sint32) floor (vMin.x / fCellSize); + nMinY = (sint32) floor (vMin.y / fCellSize); + nMaxX = (sint32) floor (vMax.x / fCellSize); + nMaxY = (sint32) floor (vMax.y / fCellSize); + + for (x = nMinX; x <= nMaxX; ++x) + for (y = nMinY; y <= nMaxY; ++y) + { + // Does the zone (x,y) is under the patat ? + bool bZoneUnderPatat = false; + // Is a vertex of the zone in the patat ? + CVector vSquare[4]; + vSquare[0].x = x * fCellSize; + vSquare[0].y = y * fCellSize; + vSquare[0].z = 0.0f; + + vSquare[1].x = (x+1) * fCellSize; + vSquare[1].y = y * fCellSize; + vSquare[1].z = 0.0f; + + vSquare[2].x = (x+1) * fCellSize; + vSquare[2].y = (y+1) * fCellSize; + vSquare[2].z = 0.0f; + + vSquare[3].x = x * fCellSize; + vSquare[3].y = (y+1) * fCellSize; + vSquare[3].z = 0.0f; + + for (i = 0; i < 4; ++i) + { + if (pPatat->contains(vSquare[i])) + { + string sTmp = CExport::getZoneNameFromXY(x,y) + ".ig"; + if (!CTools::fileExist(sTmp)) // If the file does not exist + return true; // need update + } + } + + // Is a vertex of the patat inside the zone ? + for (i = 0; i < pPatat->VPoints.size(); ++i) + { + if ((pPatat->VPoints[i].x >= (x*fCellSize)) && + (pPatat->VPoints[i].x <= ((x+1)*fCellSize)) && + (pPatat->VPoints[i].y >= (y*fCellSize)) && + (pPatat->VPoints[i].y <= ((y+1)*fCellSize))) + { + string sTmp = CExport::getZoneNameFromXY(x,y) + ".ig"; + if (!CTools::fileExist(sTmp)) // If the file does not exist + return true; // need update + } + } + + // Is an edge of the zone cut an edge of the patat ? + for (i = 0; i < pPatat->VPoints.size(); ++i) + for (j = 0; j < 4; ++j) + { + double x1 = vSquare[j].x; + double y1 = vSquare[j].y; + double x2 = vSquare[(j+1)%4].x; + double y2 = vSquare[(j+1)%4].y; + + double x3 = pPatat->VPoints[i].x; + double y3 = pPatat->VPoints[i].y; + double x4 = pPatat->VPoints[(i+1)%pPatat->VPoints.size()].x; + double y4 = pPatat->VPoints[(i+1)%pPatat->VPoints.size()].y; + + if (segmentIntersection(x1, y1, x2, y2, x3, y3, x4, y4)) + { + string sTmp = CExport::getZoneNameFromXY (x, y) + ".ig"; + if (!CTools::fileExist(sTmp)) // If the file does not exist + return true; // need update + } + } + } + return false; +} + +// --------------------------------------------------------------------------- +// A path needs an update if there is at least one zone under itself that is not present +bool CExport::isPathNeedUpdate (float fCellSize, CPrimPath *pPath, const string &sIGOutputDir) +{ + uint32 i, j; + CVector vMin, vMax; + + CTools::chdir (sIGOutputDir); + if (pPath->VPoints.size() == 0) + return false; + vMin = vMax = pPath->VPoints[0]; + for (i = 0; i < pPath->VPoints.size(); ++i) + { + if (vMin.x > pPath->VPoints[i].x) vMin.x = pPath->VPoints[i].x; + if (vMin.y > pPath->VPoints[i].y) vMin.y = pPath->VPoints[i].y; + if (vMin.z > pPath->VPoints[i].z) vMin.z = pPath->VPoints[i].z; + if (vMax.x < pPath->VPoints[i].x) vMax.x = pPath->VPoints[i].x; + if (vMax.y < pPath->VPoints[i].y) vMax.y = pPath->VPoints[i].y; + if (vMax.z < pPath->VPoints[i].z) vMax.z = pPath->VPoints[i].z; + } + + sint32 x, y; + sint32 nMinX, nMinY, nMaxX, nMaxY; + nMinX = (sint32) floor (vMin.x / fCellSize); + nMinY = (sint32) floor (vMin.y / fCellSize); + nMaxX = (sint32) floor (vMax.x / fCellSize); + nMaxY = (sint32) floor (vMax.y / fCellSize); + + for (x = nMinX; x <= nMaxX; ++x) + for (y = nMinY; y <= nMaxY; ++y) + { + // Does the zone (x,y) is under the patat ? + bool bZoneUnderPatat = false; + // Is a vertex of the zone in the patat ? + CVector vSquare[4]; + vSquare[0].x = x * fCellSize; + vSquare[0].y = y * fCellSize; + vSquare[0].z = 0.0f; + + vSquare[1].x = (x+1) * fCellSize; + vSquare[1].y = y * fCellSize; + vSquare[1].z = 0.0f; + + vSquare[2].x = (x+1) * fCellSize; + vSquare[2].y = (y+1) * fCellSize; + vSquare[2].z = 0.0f; + + vSquare[3].x = x * fCellSize; + vSquare[3].y = (y+1) * fCellSize; + vSquare[3].z = 0.0f; + + // Is a vertex of the path inside the zone ? + for (i = 0; i < pPath->VPoints.size(); ++i) + { + if ((pPath->VPoints[i].x >= (x*fCellSize)) && + (pPath->VPoints[i].x <= ((x+1)*fCellSize)) && + (pPath->VPoints[i].y >= (y*fCellSize)) && + (pPath->VPoints[i].y <= ((y+1)*fCellSize))) + { + string sTmp = CExport::getZoneNameFromXY(x,y) + ".ig"; + if (!CTools::fileExist(sTmp)) // If the file does not exist + return true; // need update + } + } + + // Is an edge of the zone cut an edge of the patat ? + for (i = 0; i < (pPath->VPoints.size()-1); ++i) + for (j = 0; j < 4; ++j) + { + double x1 = vSquare[j].x; + double y1 = vSquare[j].y; + double x2 = vSquare[(j+1)%4].x; + double y2 = vSquare[(j+1)%4].y; + + double x3 = pPath->VPoints[i].x; + double y3 = pPath->VPoints[i].y; + double x4 = pPath->VPoints[i+1].x; + double y4 = pPath->VPoints[i+1].y; + + if (segmentIntersection(x1, y1, x2, y2, x3, y3, x4, y4)) + { + string sTmp = CExport::getZoneNameFromXY (x, y) + ".ig"; + if (!CTools::fileExist(sTmp)) // If the file does not exist + return true; // need update + } + } + } + return false; +} + +// --------------------------------------------------------------------------- +// A path needs an update if there is at least one zone under itself that is not present +bool CExport::isPointNeedUpdate (float fCellSize, CPrimPoint *pPoint, const string &sIGOutputDir) +{ + CTools::chdir (sIGOutputDir); + + sint32 x, y; + x = (sint32) floor (pPoint->Point.x / fCellSize); + y = (sint32) floor (pPoint->Point.y / fCellSize); + + // Does the zone (x,y) is under the patat ? + bool bZoneUnderPatat = false; + // Is a vertex of the zone in the patat ? + CVector vSquare[4]; + vSquare[0].x = x * fCellSize; + vSquare[0].y = y * fCellSize; + vSquare[0].z = 0.0f; + + vSquare[1].x = (x+1) * fCellSize; + vSquare[1].y = y * fCellSize; + vSquare[1].z = 0.0f; + + vSquare[2].x = (x+1) * fCellSize; + vSquare[2].y = (y+1) * fCellSize; + vSquare[2].z = 0.0f; + + vSquare[3].x = x * fCellSize; + vSquare[3].y = (y+1) * fCellSize; + vSquare[3].z = 0.0f; + + // Is the vertex inside the zone ? + if ((pPoint->Point.x >= (x*fCellSize)) && + (pPoint->Point.x <= ((x+1)*fCellSize)) && + (pPoint->Point.y >= (y*fCellSize)) && + (pPoint->Point.y <= ((y+1)*fCellSize))) + { + string sTmp = CExport::getZoneNameFromXY(x,y) + ".ig"; + if (!CTools::fileExist(sTmp)) // If the file does not exist + return true; // need update + } + + return false; +} + +// --------------------------------------------------------------------------- +// SExportOptions +// --------------------------------------------------------------------------- + +// --------------------------------------------------------------------------- +SExportOptions::SExportOptions () +{ + CellSize = 160.0f; +} + +// --------------------------------------------------------------------------- +bool SExportOptions::loadcf (CConfigFile &cf) +{ + // Out + CConfigFile::CVar &cvOutIGDir = cf.getVar("EXP_OutIGDir"); + OutIGDir = cvOutIGDir.asString(); + + // In + CConfigFile::CVar &cvInLandscapeDir = cf.getVar("EXP_ZoneWDir"); + InLandscapeDir = cvInLandscapeDir.asString(); + + CConfigFile::CVar &cvLandBankFile = cf.getVar("EXP_SmallBank"); + LandBankFile = cvLandBankFile.asString(); + CConfigFile::CVar &cvLandFarBankFile = cf.getVar("EXP_FarBank"); + LandFarBankFile = cvLandFarBankFile.asString(); + CConfigFile::CVar &cvLandTileNoiseDir = cf.getVar("EXP_DisplaceDir"); + LandTileNoiseDir = cvLandTileNoiseDir.asString(); + + CConfigFile::CVar &cvCellSize = cf.getVar("EXP_CellSize"); + CellSize = cvCellSize.asFloat(); + + CConfigFile::CVar &cvPrimFloraDir = cf.getVar("EXP_PrimFloraDir"); + PrimFloraDir = cvPrimFloraDir.asString(); + + return true; +} + +// --------------------------------------------------------------------------- +bool SExportOptions::save (FILE *f) +{ + fprintf (f,"\n// Export Options\n"); + fprintf (f, "EXP_OutIGDir = \"%s\";\n", OutIGDir); + fprintf (f, "EXP_ZoneWDir = \"%s\";\n", InLandscapeDir); + fprintf (f, "EXP_SmallBank = \"%s\";\n", LandBankFile); + fprintf (f, "EXP_FarBank = \"%s\";\n", LandFarBankFile); + fprintf (f, "EXP_DisplaceDir = \"%s\";\n", LandTileNoiseDir); + fprintf (f, "EXP_CellSize = %f;\n", CellSize); + fprintf (f, "EXP_PrimFloraDir = \"%s\";\n", PrimFloraDir); + return true; +} + +// --------------------------------------------------------------------------- +// SExportPrimitive +// --------------------------------------------------------------------------- + +// --------------------------------------------------------------------------- +bool SExportPrimitive::operator == (const SExportPrimitive &rRightArg) +{ + if (strcmp(this->FullPrimName.c_str(), rRightArg.FullPrimName.c_str()) == 0) + if (strcmp(this->PrimitiveName.c_str(), rRightArg.PrimitiveName.c_str()) == 0) + return true; + return false; +} + +// --------------------------------------------------------------------------- +// CExport +// --------------------------------------------------------------------------- + +// --------------------------------------------------------------------------- +CExport::CExport() +{ + _Landscape = NULL; + _VCM = NULL; + _VCE = NULL; + _ExportCB = NULL; + _Options = NULL; +} + +// --------------------------------------------------------------------------- +CExport::~CExport() +{ + if (_Landscape != NULL) + delete _Landscape; + if (_VCM != NULL) + { + _VCM->deleteEntity (_VCE); + delete _VCM; + } +} + + + +// --------------------------------------------------------------------------- +bool CExport::newExport (SExportOptions &opt, IExportCB *expCB) +{ + _ExeDir = CTools::pwd(); + _Options = &opt; + _ExportCB = expCB; + + string sTmp; + uint32 i, j, k, m; + + + + // First of all read the CFG + string sContinentDir = _Options->PrimFloraDir; + + sContinentDir = CTools::normalizePath (sContinentDir); + CTools::chdir (sContinentDir.c_str()); // Relative to absolute path + sContinentDir = CTools::pwd () + "\\"; + CTools::chdir (_ExeDir); + + // Read continent.cfg + SContinentCfg ContinentCFG; + { + string sTmp = sContinentDir + "continent.cfg"; + if (!ContinentCFG.load(sTmp.c_str())) + throw Exception("Cannot load continent.cfg"); + } + + // Ok set parameters from options first and with CFG if no options set + + if (_Options->OutIGDir == "") + _OutIGDir = CTools::normalizePath (ContinentCFG.OutIGDir); + else + _OutIGDir = CTools::normalizePath (_Options->OutIGDir); + + if (_Options->LandFile == "") + _LandFile = ContinentCFG.LandFile; + else + _LandFile = _Options->LandFile; + + if (_Options->DfnDir == "") + _DfnDir = ContinentCFG.DfnDir; + else + _DfnDir = _Options->DfnDir; + + if (_Options->GameElemDir == "") + _GameElemDir = ContinentCFG.GameElemDir; + else + _GameElemDir = _Options->GameElemDir; + + if (_Options->InLandscapeDir == "") + _InLandscapeDir = ContinentCFG.LandZoneWDir; // Directory where to get .zonew files + else + _InLandscapeDir = _Options->InLandscapeDir; + + if (_Options->LandFarBankFile == "") + _LandBankFile = ContinentCFG.LandBankFile; // The .smallbank file associated with the landscape + else + _LandBankFile = _Options->LandBankFile; + + if (_Options->LandFarBankFile == "") + _LandFarBankFile = ContinentCFG.LandFarBankFile; // The .farbank file + else + _LandFarBankFile = _Options->LandFarBankFile; + + if (_Options->LandTileNoiseDir == "") + _LandTileNoiseDir = ContinentCFG.LandTileNoiseDir; // Directory where to get displacement map + else + _LandTileNoiseDir = _Options->LandTileNoiseDir; + + + // Now create output directory + CTools::mkdir (_OutIGDir); + + CTools::chdir (_OutIGDir.c_str()); + _OutIGDir = CTools::pwd () + "\\"; + CTools::chdir (_ExeDir); + + + CPath::addSearchPath (_DfnDir, true, true); + CPath::addSearchPath (_GameElemDir, true, true); + CPath::addSearchPath (_LandTileNoiseDir, true, true); + + + // Get all regions + vector vRegions; + WIN32_FIND_DATA findData; + HANDLE hFind; + + CTools::chdir (sContinentDir); + hFind = FindFirstFile ("*.*", &findData); + while (hFind != INVALID_HANDLE_VALUE) + { + if (GetFileAttributes(findData.cFileName)&FILE_ATTRIBUTE_DIRECTORY) + { + // Look if the name is a system directory + bool bFound = false; + for (i = 0; i < MAX_SYS_DIR; ++i) + if (stricmp (findData.cFileName, gExportSysDir[i]) == 0) + { + bFound = true; + break; + } + if (!bFound) // No, ok lets recurse it + { + vRegions.push_back (findData.cFileName); + } + } + if (FindNextFile (hFind, &findData) == 0) + break; + } + FindClose (hFind); + + + // Process all regions + uint32 nRegion; + for (nRegion = 0; nRegion < vRegions.size(); ++nRegion) + { + CTools::chdir (sContinentDir + vRegions[nRegion]); + + // Process if a flora has been modified + vector vFloraToUpdate; + uint32 nFloraFile; + + // Fill the structure for update + { + // Get all new flora of the region + vector vFloraFiles; + CTools::dirSub ("*.flora", vFloraFiles, true); + for (nFloraFile = 0; nFloraFile < vFloraFiles.size(); ++nFloraFile) + { + // Compare the date with the old file stored in the IG output directory + CTools::chdir (sContinentDir + vRegions[nRegion]); + string sBaseName = vFloraFiles[nFloraFile].substr(sContinentDir.size()); + sBaseName = sBaseName.substr(0,sBaseName.rfind('\\')); + for (i = 0; i < sBaseName.size(); ++i) + if (sBaseName[i] == '\\') + sBaseName[i] = '-'; + sBaseName += '-'; + string sOldFloraName = _OutIGDir + sBaseName + vFloraFiles[nFloraFile].substr(vFloraFiles[nFloraFile].rfind('\\')+1); + + if (CTools::fileExist(sOldFloraName)) + { + if (CTools::fileDateCmp(vFloraFiles[nFloraFile], sOldFloraName) > 0) + { + // Delete zones from the 2 files + SFloraToUpdate ftuTmp; + // Delete zones from the newest file + ftuTmp.FloraFile = vFloraFiles[nFloraFile]; + CTools::chdir (vFloraFiles[nFloraFile].substr(0,vFloraFiles[nFloraFile].rfind('\\'))); + CTools::dir ("*.prim", ftuTmp.PrimFile, true); + vFloraToUpdate.push_back (ftuTmp); + // Delete zones from the oldest file + CTools::chdir (_OutIGDir); + ftuTmp.FloraFile = sOldFloraName; + CTools::dir (sBaseName + "*.prim", ftuTmp.PrimFile, true); + vFloraToUpdate.push_back (ftuTmp); + CTools::chdir (_ExeDir); + sTmp = vFloraFiles[nFloraFile] + " has been modified."; + if (_ExportCB != NULL) _ExportCB->dispInfo (sTmp); + } + else + { + CTools::chdir (_ExeDir); + sTmp = vFloraFiles[nFloraFile] + string(" up to date."); + if (_ExportCB != NULL) _ExportCB->dispInfo (sTmp); + } + } + else + { + // Delete zone from newest file + SFloraToUpdate ftuTmp; + ftuTmp.FloraFile = vFloraFiles[nFloraFile]; + CTools::chdir (vFloraFiles[nFloraFile].substr(0,vFloraFiles[nFloraFile].rfind('\\'))); + CTools::dir ("*.prim", ftuTmp.PrimFile, true); + vFloraToUpdate.push_back (ftuTmp); + CTools::chdir (_ExeDir); + sTmp = vFloraFiles[nFloraFile] + " not generated."; + if (_ExportCB != NULL) _ExportCB->dispInfo (sTmp); + } + } + + // Get all old flora of the current region + CTools::chdir (_OutIGDir); + CTools::dir (vRegions[nRegion] + "-*.flora", vFloraFiles, true); + for (nFloraFile = 0; nFloraFile < vFloraFiles.size(); ++nFloraFile) + { + CTools::chdir (_OutIGDir); + // if the old flora file still exist but the new one not -> delete zone for the oldest file + string sNewFloraName = vFloraFiles[nFloraFile].substr(vFloraFiles[nFloraFile].rfind('\\')+1); + string sBaseName = sNewFloraName.substr (0, vFloraFiles[nFloraFile].rfind('-')); + for (i = 0; i < sNewFloraName.size(); ++i) + if (sNewFloraName[i] == '-') + sNewFloraName[i] = '\\'; + + sNewFloraName = sContinentDir + sNewFloraName; + if (!CTools::fileExist(sNewFloraName)) + { + SFloraToUpdate ftuTmp; + // Delete zones from the oldest file + ftuTmp.FloraFile = vFloraFiles[nFloraFile]; + CTools::dir (sBaseName + "*.prim", ftuTmp.PrimFile, true); + vFloraToUpdate.push_back (ftuTmp); + CTools::chdir (_ExeDir); + sTmp = vFloraFiles[nFloraFile] + " not needed anymore."; + if (_ExportCB != NULL) _ExportCB->dispInfo (sTmp); + } + } + } + // End of fill the structure for update + + // Interpret the FloraToUpdate + for (nFloraFile = 0; nFloraFile < vFloraToUpdate.size(); ++nFloraFile) + { + // Get all patats referenced by the flora and suppress zones under + + // Load the .flora file + SFormFlora FormFlora; + { + // Get a loader + UFormLoader *loader = UFormLoader::createLoader (); + + // Load the form + CSmartPtr form = loader->loadForm (vFloraToUpdate[nFloraFile].FloraFile.c_str ()); + if (form) + FormFlora.build (form->getRootNode ()); + + // Release the loader + UFormLoader::releaseLoader (loader); + } + + // Load all the .prim files that can be referenced by the flora + vector vPrimRegions; + { + vector &rPrimFiles = vFloraToUpdate[nFloraFile].PrimFile; + for (i = 0; i < rPrimFiles.size(); ++i) + { + CPrimRegion tmpPrimRegion; + CIFile fileIn; + fileIn.open (rPrimFiles[i]); + CIXml input; + input.init (fileIn); + tmpPrimRegion.serial (input); + vPrimRegions.push_back (tmpPrimRegion); + } + } + + // Delete zones under the old prims referenced by the old zone + + for (i = 0; i < FormFlora.IncludePatats.size(); ++i) + { + // Get the patat + CPrimZone *pPatat = NULL; + CPrimPoint *pPoint = NULL; + CPrimPath *pPath = NULL; + for (j = 0; j < vPrimRegions.size(); ++j) + { + for (k = 0; k < vPrimRegions[j].VZones.size(); ++k) + if (vPrimRegions[j].VZones[k].getName() == FormFlora.IncludePatats[i]) + pPatat = &vPrimRegions[j].VZones[k]; + for (k = 0; k < vPrimRegions[j].VPoints.size(); ++k) + if (vPrimRegions[j].VPoints[k].getName() == FormFlora.IncludePatats[i]) + pPoint = &vPrimRegions[j].VPoints[k]; + for (k = 0; k < vPrimRegions[j].VPaths.size(); ++k) + if (vPrimRegions[j].VPaths[k].getName() == FormFlora.IncludePatats[i]) + pPath = &vPrimRegions[j].VPaths[k]; + } + + if ((pPatat == NULL) && (pPoint == NULL) && (pPath == NULL)) + { + CTools::chdir (_ExeDir); + sTmp = "WARNING : Cannot find " + FormFlora.IncludePatats[i]; + if (_ExportCB != NULL) _ExportCB->dispInfo (sTmp); + continue; + } + + if ((pPatat != NULL) && (pPatat->VPoints.size() <= 2)) + { + CTools::chdir (_ExeDir); + sTmp = "Patat " + pPatat->getName() + " has less than 3 points"; + if (_ExportCB != NULL) _ExportCB->dispInfo (sTmp); + continue; + } + + if ((pPath != NULL) && (pPath->VPoints.size() < 2)) + { + CTools::chdir (_ExeDir); + sTmp = "Patat " + pPatat->getName() + " has less than 2 points"; + if (_ExportCB != NULL) _ExportCB->dispInfo (sTmp); + continue; + } + + if (pPatat != NULL) + delAllIGZoneUnderPatat (160.0f, pPatat, _OutIGDir); + if (pPoint != NULL) + delAllIGZoneUnderPoint (160.0f, pPoint, _OutIGDir); + if (pPath != NULL) + delAllIGZoneUnderPath (160.0f, pPath, _OutIGDir); + } + } + // End of Process if a flora has been modified + + // Process if a prim has been modified + // Fill the structure for update + CTools::chdir (sContinentDir + vRegions[nRegion]); + vector vPrimToUpdate; + { + uint32 nPrimFile; + vector vPrimFiles; + // Get all new prim of the region + CTools::dirSub ("*.prim", vPrimFiles, true); + for (nPrimFile = 0; nPrimFile < vPrimFiles.size(); ++nPrimFile) + { + CTools::chdir (sContinentDir + vRegions[nRegion]); + // Compare the date with the old file stored in the IG output directory + string sBaseName = vPrimFiles[nPrimFile].substr(sContinentDir.size()); + sBaseName = sBaseName.substr(0,sBaseName.rfind('\\')); + for (i = 0; i < sBaseName.size(); ++i) + if (sBaseName[i] == '\\') + sBaseName[i] = '-'; + sBaseName += '-'; + string sOldPrimName = _OutIGDir + sBaseName + vPrimFiles[nPrimFile].substr(vPrimFiles[nPrimFile].rfind('\\')+1); + + if (CTools::fileExist(sOldPrimName)) + { + if (CTools::fileDateCmp(vPrimFiles[nPrimFile], sOldPrimName) > 0) + { + // Delete zones from the 2 files + SPrimToUpdate ptuTmp; + // Delete zones from the newest file + ptuTmp.PrimFile = vPrimFiles[nPrimFile]; + CTools::chdir (vPrimFiles[nPrimFile].substr(0,vPrimFiles[nPrimFile].rfind('\\'))); + CTools::dir ("*.flora", ptuTmp.FloraFile, true); + vPrimToUpdate.push_back (ptuTmp); + // Delete zones from the oldest file + CTools::chdir (_OutIGDir); + ptuTmp.PrimFile = sOldPrimName; + CTools::dir (sBaseName + "*.flora", ptuTmp.FloraFile, true); + vPrimToUpdate.push_back (ptuTmp); + CTools::chdir (_ExeDir); + sTmp = vPrimFiles[nPrimFile] + " has been modified."; + if (_ExportCB != NULL) _ExportCB->dispInfo (sTmp); + } + else + { + CTools::chdir (_ExeDir); + sTmp = vPrimFiles[nPrimFile] + " up to date."; + if (_ExportCB != NULL) _ExportCB->dispInfo (sTmp); + } + } + else + { + // Delete zone from newest file + SPrimToUpdate ptuTmp; + ptuTmp.PrimFile = vPrimFiles[nPrimFile]; + CTools::chdir (vPrimFiles[nPrimFile].substr(0,vPrimFiles[nPrimFile].rfind('\\'))); + CTools::dir ("*.flora", ptuTmp.FloraFile, true); + vPrimToUpdate.push_back (ptuTmp); + CTools::chdir (_ExeDir); + sTmp = vPrimFiles[nPrimFile] + " not generated."; + if (_ExportCB != NULL) _ExportCB->dispInfo (sTmp); + } + } + + // Get all old prim of the current region + CTools::chdir (_OutIGDir); + CTools::dir (vRegions[nRegion] + "-*.prim", vPrimFiles, false); + for (nPrimFile = 0; nPrimFile < vPrimFiles.size(); ++nPrimFile) + { + CTools::chdir (_OutIGDir); + // if the old prim file still exist but the new one not -> delete zone for the oldest file + string sNewPrimName = vPrimFiles[nPrimFile].substr(vPrimFiles[nPrimFile].rfind('\\')+1); + string sBaseName = sNewPrimName.substr (0, vPrimFiles[nPrimFile].rfind('-')); + for (i = 0; i < sNewPrimName.size(); ++i) + if (sNewPrimName[i] == '-') + sNewPrimName[i] = '\\'; + + sNewPrimName = sContinentDir + sNewPrimName; + if (!CTools::fileExist(sNewPrimName)) + { + // Delete zones from the oldest file + CPrimRegion PrimRegion; + { + CIFile fileIn; + fileIn.open (vPrimFiles[nPrimFile]); + CIXml input; + input.init (fileIn); + PrimRegion.serial (input); + } + + for (j = 0; j < PrimRegion.VZones.size(); ++j) + delAllIGZoneUnderPatat (_Options->CellSize, &PrimRegion.VZones[j], _OutIGDir); + for (j = 0; j < PrimRegion.VPaths.size(); ++j) + delAllIGZoneUnderPath (_Options->CellSize, &PrimRegion.VPaths[j], _OutIGDir); + for (j = 0; j < PrimRegion.VPoints.size(); ++j) + delAllIGZoneUnderPoint (_Options->CellSize, &PrimRegion.VPoints[j], _OutIGDir); + + CTools::chdir (_ExeDir); + sTmp = vPrimFiles[nPrimFile] + " not needed anymore."; + if (_ExportCB != NULL) _ExportCB->dispInfo (sTmp); + } + } + } + // End of fill the structure for update + + // Interpretation of structure for update + for (i = 0; i < vPrimToUpdate.size(); ++i) + { + // Load all the .flora file + vector vFormFloras; + for (j = 0; j < vPrimToUpdate[i].FloraFile.size(); ++j) + { + // Create the loader + UFormLoader *loader = UFormLoader::createLoader (); + + // Load the form + CSmartPtr form = loader->loadForm (vPrimToUpdate[i].FloraFile[j].c_str ()); + if (form) + { + SFormFlora FormFloraTmp; + FormFloraTmp.build (form->getRootNode ()); + vFormFloras.push_back (FormFloraTmp); + } + + // Release the loader + UFormLoader::releaseLoader (loader); + } + + // Load all the .prim files that can be referenced by the flora + CPrimRegion PrimRegion; + { + CIFile fileIn; + fileIn.open (vPrimToUpdate[i].PrimFile); + CIXml input; + input.init (fileIn); + PrimRegion.serial (input); + } + + // Delete zones under the prims that has been referenced by a flora + + for (j = 0; j < PrimRegion.VZones.size(); ++j) + { + // Get the patat + CPrimZone *pPatat = NULL; + + // Check if the current patat is referenced by a flora + for (k = 0; k < vFormFloras.size(); ++k) + for (m = 0; m < vFormFloras[k].IncludePatats.size(); ++m) + if (PrimRegion.VZones[j].getName() == vFormFloras[k].IncludePatats[m]) + pPatat = &PrimRegion.VZones[j]; + + if ((pPatat == NULL) || (pPatat->VPoints.size() <= 2)) + { + continue; + } + delAllIGZoneUnderPatat (_Options->CellSize, pPatat, _OutIGDir); + } + for (j = 0; j < PrimRegion.VPoints.size(); ++j) + { + // Get the point + CPrimPoint *pPoint = NULL; + + // Check if the current point is referenced by a flora + for (k = 0; k < vFormFloras.size(); ++k) + for (m = 0; m < vFormFloras[k].IncludePatats.size(); ++m) + if (PrimRegion.VPoints[j].getName() == vFormFloras[k].IncludePatats[m]) + pPoint = &PrimRegion.VPoints[j]; + delAllIGZoneUnderPoint (_Options->CellSize, pPoint, _OutIGDir); + } + for (j = 0; j < PrimRegion.VPaths.size(); ++j) + { + // Get the path + CPrimPath *pPath = NULL; + + // Check if the current path is referenced by a flora + for (k = 0; k < vFormFloras.size(); ++k) + for (m = 0; m < vFormFloras[k].IncludePatats.size(); ++m) + if (PrimRegion.VPaths[j].getName() == vFormFloras[k].IncludePatats[m]) + pPath = &PrimRegion.VPaths[j]; + delAllIGZoneUnderPath (_Options->CellSize, pPath, _OutIGDir); + } + } + // End of Process if a prim has been modified + + } + // End of process all regions + + // Check all patat to export (a patat that has no zone under itself (deleted or not present)) + vector vExportPrimitives; + vector vAllPrimFiles; // All prim files of a continent + CTools::chdir (sContinentDir); + CTools::dirSub ("*.prim", vAllPrimFiles, true); + for (i = 0; i < vAllPrimFiles.size(); ++i) + { + vAllPrimFiles[i] = strlwr(vAllPrimFiles[i]); + // Load the primfile + CPrimRegion PrimRegion; + { + CIFile fileIn; + fileIn.open (vAllPrimFiles[i]); + CIXml input; + input.init (fileIn); + PrimRegion.serial (input); + } + + for (j = 0; j < PrimRegion.VZones.size(); ++j) + { + // Check all zones to know if this patat must be updated + if (isPatatNeedUpdate(_Options->CellSize, &PrimRegion.VZones[j], _OutIGDir)) + { + SExportPrimitive epTmp; + epTmp.FullPrimName = vAllPrimFiles[i]; + epTmp.PrimitiveName = PrimRegion.VZones[j].getName(); + vExportPrimitives.push_back (epTmp); + } + } + + for (j = 0; j < PrimRegion.VPaths.size(); ++j) + { + // Check all pathes to know if some must be updated (if no zone under) + if (isPathNeedUpdate(_Options->CellSize, &PrimRegion.VPaths[j], _OutIGDir)) + { + SExportPrimitive epTmp; + epTmp.FullPrimName = vAllPrimFiles[i]; + epTmp.PrimitiveName = PrimRegion.VPaths[j].getName(); + vExportPrimitives.push_back (epTmp); + } + } + + for (j = 0; j < PrimRegion.VPoints.size(); ++j) + { + // Check all points to know if some must be updated (if no zone under) + if (isPointNeedUpdate(_Options->CellSize, &PrimRegion.VPoints[j], _OutIGDir)) + { + SExportPrimitive epTmp; + epTmp.FullPrimName = vAllPrimFiles[i]; + epTmp.PrimitiveName = PrimRegion.VPoints[j].getName(); + vExportPrimitives.push_back (epTmp); + } + } + } + + // Export + + CTools::chdir (_ExeDir); + _Options->PrimFloraDir = sContinentDir; + sTmp = "Exporting"; + if (_ExportCB != NULL) _ExportCB->dispInfo (sTmp); + doExport (*_Options, _ExportCB, &vExportPrimitives); + + // Copy new files for incremental purpose + CTools::chdir (_ExeDir); + sTmp = "Incrementing"; + if (_ExportCB != NULL) _ExportCB->dispInfo (sTmp); + for (nRegion = 0; nRegion < vRegions.size(); ++nRegion) + { + CTools::chdir (sContinentDir + vRegions[nRegion]); + vector vFiles; + CTools::dirSub ("*.prim", vFiles, true); + for (i = 0; i < vFiles.size(); ++i) + { + string sDst = vFiles[i].substr (sContinentDir.size()); + for (j = 0; j < sDst.size(); ++j) + if (sDst[j] == '\\') + sDst[j] = '-'; + sDst = _OutIGDir + sDst; + CTools::copy (sDst, vFiles[i]); + } + CTools::chdir (sContinentDir + vRegions[nRegion]); + CTools::dirSub ("*.flora", vFiles, true); + for (i = 0; i < vFiles.size(); ++i) + { + string sDst = vFiles[i].substr (sContinentDir.size()); + for (j = 0; j < sDst.size(); ++j) + if (sDst[j] == '\\') + sDst[j] = '-'; + sDst = _OutIGDir + sDst; + CTools::copy (sDst, vFiles[i]); + } + + // ------------------------------------------------------------------- + // If the new file do not exists anymore but the old file exists -> delete old file + CTools::chdir (_OutIGDir); + CTools::dir (vRegions[nRegion] + "-*.prim", vFiles, false); + for (i = 0; i < vFiles.size(); ++i) + { + // Get the name of the recent file + string sNewName = vFiles[i]; + for (j = 0; j < sNewName.size(); ++j) + if (sNewName[j] == '-') + sNewName[j] = '\\'; + + sNewName = sContinentDir + sNewName; + if (!CTools::fileExist(sNewName)) + { + // Delete the oldest file + CFile::deleteFile(vFiles[i]); + } + } + + // If the new file do not exists anymore but the old file exists -> delete old file + CTools::dir (vRegions[nRegion] + "-*.flora", vFiles, false); + for (i = 0; i < vFiles.size(); ++i) + { + // Get the name of the recent file + string sNewName = vFiles[i]; + for (j = 0; j < sNewName.size(); ++j) + if (sNewName[j] == '-') + sNewName[j] = '\\'; + + sNewName = sContinentDir + sNewName; + if (!CTools::fileExist(sNewName)) + { + // Delete the oldest file + CFile::deleteFile(vFiles[i]); + } + } + } + + CTools::chdir (_ExeDir); + return true; +} + +// --------------------------------------------------------------------------- +bool CExport::doExport (SExportOptions &opt, IExportCB *expCB, vector *selection) +{ + char sTmp[MAX_PATH]; + GetCurrentDirectory (MAX_PATH, sTmp); + + _Options = &opt; + _ExportCB = expCB; + + // Does we have something to export + if ((selection != NULL) && (selection->size() == 0)) + { + if (_ExportCB) + _ExportCB->dispInfo ("Nothing to export"); + return true; + } + + // If we want to generate flora then we have to load the landscape + uint32 i; + + if (_ExportCB) + _ExportCB->dispPass ("Load Landscape"); + if (_Landscape == NULL) + { + _Landscape = new CLandscape; + _Landscape->init (); + _VCM = new CVisualCollisionManager; + _VCE = _VCM->createEntity (); + _VCM->setLandscape (_Landscape); + _VCE->setSnapToRenderedTesselation (false); + try + { + CIFile bankFile (_LandBankFile); + _Landscape->TileBank.serial (bankFile); + CIFile farbankFile (_LandFarBankFile); + _Landscape->TileFarBank.serial (farbankFile); + _Landscape->TileBank.makeAllPathRelative (); + _Landscape->TileBank.setAbsPath (""); + _Landscape->TileBank.makeAllExtensionDDS (); + _Landscape->initTileBanks (); + + loadLandscape (_LandFile); + } + catch (const Exception &/*e*/) + { + if (_ExportCB) + _ExportCB->dispError ("Cannot load banks files"); + } + } + + _FloraInsts.clear (); + if (_ExportCB) + _ExportCB->dispPass ("Generate Flora"); + vector allFloraFiles; + SetCurrentDirectory (_Options->PrimFloraDir.c_str()); + getAllFiles (".Flora", allFloraFiles); + SetCurrentDirectory (sTmp); + for (i = 0; i < allFloraFiles.size(); ++i) + { + generateIGFromFlora (allFloraFiles[i], selection); + } + + writeFloraIG (_LandFile, (selection != NULL)); // If selection != NULL then test for writing + + SetCurrentDirectory (sTmp); + if (_ExportCB) + _ExportCB->dispPass ("Finished"); + + return true; +} + +// --------------------------------------------------------------------------- +void CExport::getAllFiles (const string &ext, vector &files) +{ + char sCurDir[MAX_PATH]; + GetCurrentDirectory (MAX_PATH, sCurDir); + + WIN32_FIND_DATA findData; + HANDLE hFind = FindFirstFile ("*.*", &findData); + while (hFind != INVALID_HANDLE_VALUE) + { + if (!((strcmp (findData.cFileName, ".") == 0) || (strcmp (findData.cFileName, "..") == 0))) + { + if (findData.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) + { + string sNewDir = sCurDir; + sNewDir += string("\\") + findData.cFileName; + SetCurrentDirectory (sNewDir.c_str()); + getAllFiles (ext, files); + SetCurrentDirectory (sCurDir); + } + else + { + if (strlen(findData.cFileName) > strlen(ext.c_str())) + if (stricmp(&findData.cFileName[strlen(findData.cFileName)-strlen(ext.c_str())], ext.c_str()) == 0) + { + string fullName = sCurDir; + fullName += string("\\") + findData.cFileName; + fullName = strlwr (fullName); + files.push_back (fullName); + } + } + } + + if (FindNextFile (hFind, &findData) == 0) + break; + } + FindClose (hFind); + + SetCurrentDirectory (sCurDir); +} + +// --------------------------------------------------------------------------- +bool CExport::searchFile (const std::string &plantName, std::string &dir) +{ + char sCurDir[MAX_PATH]; + bool bFound = false; + GetCurrentDirectory (MAX_PATH, sCurDir); + + WIN32_FIND_DATA findData; + HANDLE hFind = FindFirstFile ("*.*", &findData); + while (hFind != INVALID_HANDLE_VALUE) + { + string filename = findData.cFileName; + filename = strlwr(filename); + if (!((filename == ".") || (filename == ".."))) + { + if (findData.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) + { + string sNewDir = sCurDir; + sNewDir += string("\\") + filename; + SetCurrentDirectory (sNewDir.c_str()); + if (searchFile (plantName, dir)) + { + bFound = true; + break; + } + SetCurrentDirectory (sCurDir); + } + else + { + if (strlwr(plantName) == filename) + { + dir = sCurDir; + bFound = true; + break; + } + } + } + + if (FindNextFile (hFind, &findData) == 0) + break; + } + FindClose (hFind); + SetCurrentDirectory (sCurDir); + return bFound; +} + +// --------------------------------------------------------------------------- +bool CExport::generateIGFromFlora (const std::string &SrcFile, std::vector *selection) +{ + uint32 i, j, k, l, m; + + if (_ExportCB) + _ExportCB->dispPass ("Generating From " + SrcFile); + + // Load all .prim + vector allPrimRegion; + vector allPrimFiles; + { + char sCurDir[MAX_PATH]; + GetCurrentDirectory (MAX_PATH, sCurDir); + SetCurrentDirectory (_Options->PrimFloraDir.c_str()); + getAllFiles (".prim", allPrimFiles); + SetCurrentDirectory (sCurDir); + for (i = 0; i < allPrimFiles.size(); ++i) + { + try + { + CPrimRegion tmpPrimRegion; + CIFile fileIn; + fileIn.open (allPrimFiles[i]); + CIXml input; + input.init (fileIn); + tmpPrimRegion.serial (input); + allPrimRegion.push_back (tmpPrimRegion); + } + catch (const Exception &/*e*/) + { + if (_ExportCB != NULL) + _ExportCB->dispWarning (string("Cant load ") + allPrimFiles[i]); + CPrimRegion tmpPrimRegion; + allPrimRegion.push_back (tmpPrimRegion); + } + } + } + + // Load the .Flora file (georges file) and load all associated .plant + SFormFlora formFlora; + map Plants; + { + // Create a loader + UFormLoader *loader = UFormLoader::createLoader (); +// CPath::addSearchPath (_Options->DfnDir, true, true); +// CPath::addSearchPath (_Options->GameElemDir, true, true); +// CPath::addSearchPath (_Options->LandTileNoiseDir, true, true); + + // Load the form + CSmartPtr form = loader->loadForm (SrcFile.c_str ()); + if (form == NULL) + { + if (_ExportCB != NULL) + _ExportCB->dispError (string("Cant load ") + SrcFile ); + } + else + { + // Read .Flora + formFlora.build (form->getRootNode ()); + + // Load the .plant associated + for (i = 0; i < formFlora.PlantInstances.size(); ++i) + { + const string &plantName = formFlora.PlantInstances[i].Name; + map::iterator it = Plants.find (plantName); + if (it != Plants.end()) // Already here ?! + continue; // Zap it + + char sCurDir[MAX_PATH]; + GetCurrentDirectory (MAX_PATH, sCurDir); + + try + { + SetCurrentDirectory (_GameElemDir.c_str()); + string dir; + + if (searchFile (plantName, dir)) + { + string tmpName = dir + string("\\") + plantName; + + CSmartPtr form2 = loader->loadForm (tmpName.c_str()); + if (form2) + { + SFormPlant plantTmp; + plantTmp.build (form2->getRootNode ()); + Plants.insert (map::value_type(plantName, plantTmp)); + } + else + { + if (_ExportCB != NULL) + _ExportCB->dispWarning (string("Cant load ") + plantName); + } + } + else + { + if (_ExportCB != NULL) + _ExportCB->dispWarning (string("Cant load ") + plantName); + } + SetCurrentDirectory (sCurDir); + } + catch (const Exception &e) + { + SetCurrentDirectory (sCurDir); + if (_ExportCB != NULL) + _ExportCB->dispWarning (string("Cant load ") + plantName + "(" + e.what() + ")" ); + } + } + } + } + + // Sort PlantInstances by biggest radius first + if (formFlora.PlantInstances.size() > 1) + for (i = 0; i < (formFlora.PlantInstances.size()-1); ++i) + for (j = i+1; j < formFlora.PlantInstances.size(); ++j) + { + SPlantInstance &rPlantI = formFlora.PlantInstances[i]; + SPlantInstance &rPlantJ = formFlora.PlantInstances[j]; + map::iterator it = Plants.find (rPlantI.Name); + if (it == Plants.end()) + continue; + SFormPlant &rFormPlantI = it->second; + + it = Plants.find (rPlantJ.Name); + if (it == Plants.end()) + continue; + SFormPlant &rFormPlantJ = it->second; + if (rFormPlantI.BoundingRadius < rFormPlantJ.BoundingRadius) + { + SPlantInstance pi = formFlora.PlantInstances[i]; + formFlora.PlantInstances[i] = formFlora.PlantInstances[j]; + formFlora.PlantInstances[j] = pi; + } + } + + // Generating + float jitter = formFlora.JitterPos; + clamp (jitter, 0.0f, 1.0f); + srand (formFlora.RandomSeed); + for (i = 0; i < formFlora.IncludePatats.size(); ++i) + { + uint32 nCurPlant = 0; + CVector vMin, vMax; + + if (_ExportCB) + _ExportCB->dispPass ("IncludePatats("+toString(i+1)+"/"+toString(formFlora.IncludePatats.size())+")"); + + // Get the patat + CPrimZone *pPatat = NULL; + CPrimPoint *pPoint = NULL; + CPrimPath *pPath = NULL; + + // Look if this is a patat + for (j = 0; j < allPrimRegion.size(); ++j) + { + for (k = 0; k < allPrimRegion[j].VZones.size(); ++k) + { + if (allPrimRegion[j].VZones[k].getName() == formFlora.IncludePatats[i]) + { + if (selection != NULL) + { + SExportPrimitive epTmp; + epTmp.FullPrimName = allPrimFiles[j]; + epTmp.PrimitiveName = allPrimRegion[j].VZones[k].getName(); + for (m = 0; m < selection->size(); ++m) + if (selection->operator[](m) == epTmp) + { + pPatat = &allPrimRegion[j].VZones[k]; + break; + } + } + else + { + pPatat = &allPrimRegion[j].VZones[k]; + } + } + } + } + + //Look if this is a point + for (j = 0; j < allPrimRegion.size(); ++j) + { + for (k = 0; k < allPrimRegion[j].VPoints.size(); ++k) + { + if (allPrimRegion[j].VPoints[k].getName() == formFlora.IncludePatats[i]) + { + if (selection != NULL) + { + SExportPrimitive epTmp; + epTmp.FullPrimName = allPrimFiles[j]; + epTmp.PrimitiveName = allPrimRegion[j].VPoints[k].getName(); + for (m = 0; m < selection->size(); ++m) + if (selection->operator[](m) == epTmp) + { + pPoint = &allPrimRegion[j].VPoints[k]; + break; + } + } + else + { + pPoint = &allPrimRegion[j].VPoints[k]; + } + } + } + } + + //Look if this is a path + for (j = 0; j < allPrimRegion.size(); ++j) + { + for (k = 0; k < allPrimRegion[j].VPaths.size(); ++k) + { + if (allPrimRegion[j].VPaths[k].getName() == formFlora.IncludePatats[i]) + { + if (selection != NULL) + { + SExportPrimitive epTmp; + epTmp.FullPrimName = allPrimFiles[j]; + epTmp.PrimitiveName = allPrimRegion[j].VPaths[k].getName(); + for (m = 0; m < selection->size(); ++m) + if (selection->operator[](m) == epTmp) + { + pPath = &allPrimRegion[j].VPaths[k]; + break; + } + } + else + { + pPath = &allPrimRegion[j].VPaths[k]; + } + } + } + } + + + if ((pPatat == NULL) && (pPoint == NULL) && (pPath == NULL)) + { + if (selection == NULL) + if (_ExportCB) + _ExportCB->dispWarning ("Cannot find " + formFlora.IncludePatats[i]); + continue; + } + + if ((pPatat != NULL) && (pPatat->VPoints.size() <= 2)) + { + if (_ExportCB) + _ExportCB->dispWarning ("Patat " + pPatat->getName() + " has less than 3 points"); + continue; + } + + if ((pPath != NULL) && (pPath->VPoints.size() <= 1)) + { + if (_ExportCB) + _ExportCB->dispWarning ("Path " + pPath->getName() + " has less than 2 points"); + continue; + } + + // Generate for a patat + if (pPatat != NULL) + { + vMin = vMax = pPatat->VPoints[0]; + for (j = 0; j < pPatat->VPoints.size(); ++j) + { + if (vMin.x > pPatat->VPoints[j].x) vMin.x = pPatat->VPoints[j].x; + if (vMin.y > pPatat->VPoints[j].y) vMin.y = pPatat->VPoints[j].y; + if (vMin.z > pPatat->VPoints[j].z) vMin.z = pPatat->VPoints[j].z; + if (vMax.x < pPatat->VPoints[j].x) vMax.x = pPatat->VPoints[j].x; + if (vMax.y < pPatat->VPoints[j].y) vMax.y = pPatat->VPoints[j].y; + if (vMax.z < pPatat->VPoints[j].z) vMax.z = pPatat->VPoints[j].z; + } + + for (j = 0; j < formFlora.PlantInstances.size(); ++j) + { + SPlantInstance &rPlant = formFlora.PlantInstances[j]; + map::iterator it = Plants.find (rPlant.Name); + if (it == Plants.end()) + { + if (_ExportCB) + _ExportCB->dispWarning ("Cannot find " + rPlant.Name); + continue; + } + SFormPlant &rFormPlant = it->second; + + float squareLength = (float)sqrt (Pi*rFormPlant.BoundingRadius*rFormPlant.BoundingRadius / rPlant.Density); + uint32 nNbPlantX = 1+(int)floor ((vMax.x-vMin.x) / squareLength); + uint32 nNbPlantY = 1+(int)floor ((vMax.y-vMin.y) / squareLength); + for (l = 0; l < nNbPlantY; ++l) + for (k = 0; k < nNbPlantX; ++k) + { + if (_ExportCB) + _ExportCB->dispPassProgress (((float)(k+l*nNbPlantX))/((float)(nNbPlantX*nNbPlantY))); + + bool bExists = false; + CVector pos; + float scaleTmp; + for (m = 0; m < 32; ++m) + { + pos.x = vMin.x + squareLength * k + (frand(2.0f)-1.0f) * jitter * 0.5f * squareLength; + pos.y = vMin.y + squareLength * l + (frand(2.0f)-1.0f) * jitter * 0.5f * squareLength; + pos.z = 0.0f; + scaleTmp = (formFlora.ScaleMax-formFlora.ScaleMin)*frand(1.0)+formFlora.ScaleMin; + if (pPatat->contains(pos)) + { + if (isWellPlaced(pos, rPlant, rFormPlant, scaleTmp)) + { + // Testt finally with the exclude patats ... + bExists = true; + for (uint32 expat = 0; expat < formFlora.ExcludePatats.size(); ++expat) + { + CPrimZone *pExPatat = NULL; + for (uint32 epj = 0; epj < allPrimRegion.size(); ++epj) + for (uint32 epk = 0; epk < allPrimRegion[epj].VZones.size(); ++epk) + if (allPrimRegion[epj].VZones[epk].getName() == formFlora.ExcludePatats[expat]) + { + pExPatat = &allPrimRegion[epj].VZones[epk]; + break; + } + if (pExPatat != NULL) + { + if (pExPatat->contains(pos)) + { + bExists = false; + break; + } + } + } + if (bExists) + break; + } + } + } + + if (!bExists) + continue; + + SFloraInst vi; + vi.ShapeName = rFormPlant.Shape; + vi.PlantName = rPlant.Name; + vi.Scale = scaleTmp; + vi.Radius = rFormPlant.BoundingRadius * vi.Scale; + vi.Rot = (float)Pi * frand (1.0); + + if (formFlora.PutOnWater) + { + if (pos.z < formFlora.WaterHeight) + pos.z = formFlora.WaterHeight; + } + vi.Pos = pos; + _FloraInsts.push_back (vi); + } // End of for all position of a plant x,y check if we cant put it + } // End of for all plant instances + } // End of Generate for a patat + + // Generate for a point + if (pPoint != NULL) + { + // Choose a plant + float total = 0.0f; + for (j = 0; j < formFlora.PlantInstances.size(); ++j) + { + total += formFlora.PlantInstances[j].Density; + } + float posf = total * frand(1.0); + total = 0.0f; + for (j = 0; j < formFlora.PlantInstances.size(); ++j) + { + total += formFlora.PlantInstances[j].Density; + if (posf < total) break; + } + if (j == formFlora.PlantInstances.size()) + j = (uint32)formFlora.PlantInstances.size()-1; + + SPlantInstance &rPlant = formFlora.PlantInstances[j]; + map::iterator it = Plants.find (rPlant.Name); + if (it == Plants.end()) + { + if (_ExportCB) + _ExportCB->dispWarning ("Cannot find " + rPlant.Name); + continue; + } + SFormPlant &rFormPlant = it->second; + + SFloraInst vi; + vi.ShapeName = rFormPlant.Shape; + vi.PlantName = rPlant.Name; + vi.Scale = (formFlora.ScaleMax-formFlora.ScaleMin)*frand(1.0)+formFlora.ScaleMin; + vi.Radius = rFormPlant.BoundingRadius * vi.Scale; + vi.Rot = (float)Pi * frand (1.0); + + CVector pos; + pos.x = pPoint->Point.x; + pos.y = pPoint->Point.y; + pos.z = getZFromXY (pos.x, pos.y); + if (formFlora.PutOnWater) + { + if (pos.z < formFlora.WaterHeight) + pos.z = formFlora.WaterHeight; + } + vi.Pos = pos; + if (pos.z > -90000.0f) + _FloraInsts.push_back (vi); + + } // End of Generate for a point + + // Generate for a path + if (pPath != NULL) + { + float rLength = 0.0f; // Total length of the broken line + for (j = 0; j < pPath->VPoints.size()-1; ++j) + { + rLength += (pPath->VPoints[j]-pPath->VPoints[j+1]).norm(); + } + + for (j = 0; j < formFlora.PlantInstances.size(); ++j) + { + SPlantInstance &rPlant = formFlora.PlantInstances[j]; + map::iterator it = Plants.find (rPlant.Name); + if (it == Plants.end()) + { + if (_ExportCB) + _ExportCB->dispWarning ("Cannot find " + rPlant.Name); + continue; + } + SFormPlant &rFormPlant = it->second; + + float squareLength = (float)(2*rFormPlant.BoundingRadius / rPlant.Density); + uint32 nNbPlant = 1+(int)floor (rLength / squareLength); + + for (k = 0; k < nNbPlant; ++k) + { + if (_ExportCB) + _ExportCB->dispPassProgress (((float)(k))/((float)(nNbPlant))); + + bool bExists = false; + CVector pos; + float scaleTmp; + for (m = 0; m < 32; ++m) + { + // Calculate the curviline abscisse + float curvAbs = squareLength * k + (frand(2.0f)-1.0f) * jitter * 0.5f * squareLength; + float TempLength = 0.0f; + // Convert to a real point along the curve (broken line) + for (l = 0; l < pPath->VPoints.size()-1; ++l) + { + float newSize = (pPath->VPoints[l]-pPath->VPoints[l+1]).norm(); + if (curvAbs < (TempLength+newSize)) + { + curvAbs -= TempLength; + break; + } + TempLength += newSize; + } + if (l == (pPath->VPoints.size()-1)) + { + l = (uint32)pPath->VPoints.size()-2; + curvAbs = (pPath->VPoints[l]-pPath->VPoints[l+1]).norm(); + } + // Calculate the coord + curvAbs = curvAbs / (pPath->VPoints[l]-pPath->VPoints[l+1]).norm(); + pos = pPath->VPoints[l] + (pPath->VPoints[l+1]-pPath->VPoints[l])*curvAbs; + pos.z = 0.0f; + scaleTmp = (formFlora.ScaleMax-formFlora.ScaleMin)*frand(1.0)+formFlora.ScaleMin; + if (isWellPlaced(pos, rPlant, rFormPlant, scaleTmp)) + { + // Test finally with the exclude patats ... + bExists = true; + for (uint32 expat = 0; expat < formFlora.ExcludePatats.size(); ++expat) + { + CPrimZone *pExPatat = NULL; + for (uint32 epj = 0; epj < allPrimRegion.size(); ++epj) + for (uint32 epk = 0; epk < allPrimRegion[epj].VZones.size(); ++epk) + if (allPrimRegion[epj].VZones[epk].getName() == formFlora.ExcludePatats[expat]) + { + pExPatat = &allPrimRegion[epj].VZones[epk]; + break; + } + if (pExPatat != NULL) + { + if (pExPatat->contains(pos)) + { + bExists = false; + break; + } + } + } + if (bExists) + break; + } + } + + if (!bExists) + continue; + + SFloraInst vi; + vi.ShapeName = rFormPlant.Shape; + vi.PlantName = rPlant.Name; + vi.Scale = scaleTmp; + vi.Radius = rFormPlant.BoundingRadius * vi.Scale; + vi.Rot = (float)Pi * frand (1.0); + + if (formFlora.PutOnWater) + { + if (pos.z < formFlora.WaterHeight) + pos.z = formFlora.WaterHeight; + } + vi.Pos = pos; + _FloraInsts.push_back (vi); + } // End of for all position of a plant x,y check if we cant put it + } // End of for all plant instances + + } // End of Generate for a path + + } // End of for all IncludePatats + return true; +} + +// --------------------------------------------------------------------------- +float CExport::getZFromXY (float x, float y) +{ + CVector pos = CVector(x, y, 0); + CVector normal; + float z, zmin, zmax; + + // Approximate the z with patch bounding boxes + sint32 zoneX = (sint32)floor (x/_Options->CellSize); + sint32 zoneY = (sint32)floor (-y/_Options->CellSize); + sint32 zoneId = zoneY * 256 + zoneX; + CZone *pZone = _Landscape->getZone (zoneId); + if (pZone == NULL) + return -100000.0f; + + CAABBoxExt bb = pZone->getZoneBB(); + zmin = bb.getMin().z; + zmax = bb.getMax().z; + pos.z = zmin; + z = zmin; + while (z < zmax) + { + if (_VCE->snapToGround(pos, normal)) + break; + z += CVisualCollisionEntity::BBoxRadiusZ / 2.0f; // Super sampling due to max frequency on radiosity + pos.z = z; + } + + if (z >= zmax) + return -100000.0f; + + return pos.z; +} + +// --------------------------------------------------------------------------- +bool CExport::isWellPlaced (CVector &pos, SPlantInstance &rPI, SFormPlant &rFP, float scale) +{ + uint32 i; + + // Look if this Flora intersect with one of the current ones + for (i = 0; i < _FloraInsts.size(); ++i) + { + CVector temp = _FloraInsts[i].Pos - pos; + temp.z = 0.0f; + if (temp.norm() < (_FloraInsts[i].Radius + scale*rFP.BoundingRadius)) + return false; + } + + // Get the real Z + pos.z = getZFromXY (pos.x, pos.y); + if (pos.z < -90000.0f) + return false; + + // Get some Z around to see if we can put the Flora on the ground + uint32 nNbSamples = 8; // Const to be put somewhere + vector base; + base.resize (nNbSamples); + for (i = 0; i < nNbSamples; ++i) + { + base[i] = pos; + base[i].x += scale * rFP.CollisionRadius * cosf((2.0f*(float)Pi*i)/(float)nNbSamples); + base[i].y += scale * rFP.CollisionRadius * sinf((2.0f*(float)Pi*i)/(float)nNbSamples); + base[i].z = getZFromXY (base[i].x, base[i].y); + + if (fabs(base[i].z-pos.z) > 0.8f) + return false; + } + + return true; +} + +// --------------------------------------------------------------------------- +void CExport::writeFloraIG (const string &LandFile, bool bTestForWriting) +{ + sint32 i, j, k; + + if (_FloraInsts.size() == 0) + return; + + CZoneRegion zoneRegion; + CIFile inFile; + if (inFile.open (LandFile)) + { + CIXml xml(true); + xml.init (inFile); + zoneRegion.serial (xml); + + inFile.close(); + } + else + { + nlwarning ("Can't open the file %s", LandFile.c_str()); + } + + // Load all zone + + for (j = zoneRegion.getMinY(); j <= zoneRegion.getMaxY(); ++j) + for (i = zoneRegion.getMinX(); i <= zoneRegion.getMaxX(); ++i) + { + if ((zoneRegion.getName(i,j) == STRING_OUT_OF_BOUND) || + (zoneRegion.getName(i,j) == STRING_UNUSED)) + continue; + + vector vegZone; + // Take all Flora instances in the zone (i,j) + for (k = 0; k < (sint32)_FloraInsts.size(); ++k) + { + if (((i*_Options->CellSize) < _FloraInsts[k].Pos.x) && (_FloraInsts[k].Pos.x < ((i+1)*_Options->CellSize)) && + ((j*_Options->CellSize) < _FloraInsts[k].Pos.y) && (_FloraInsts[k].Pos.y < ((j+1)*_Options->CellSize))) + { + vegZone.push_back (k); + } + } + + + // Make the .IG + string ZoneName = ""; + ZoneName += NLMISC::toString(-j) + "_"; + ZoneName += 'a' + (i/26); + ZoneName += 'a' + (i%26); + + CVector vGlobalPos = CVector (0.0f, 0.0f, 0.0f); + CInstanceGroup::TInstanceArray Instances; + vector Portals; + vector Clusters; + Instances.resize (vegZone.size()); + + for (k = 0; k < (sint32)vegZone.size(); ++k) + { +//vGlobalPos += _FloraInsts[vegZone[k]].Pos; + Instances[k].Pos = _FloraInsts[vegZone[k]].Pos; + Instances[k].Rot = CQuat(CVector::K, _FloraInsts[vegZone[k]].Rot); + Instances[k].Scale = CVector(_FloraInsts[vegZone[k]].Scale, _FloraInsts[vegZone[k]].Scale, _FloraInsts[vegZone[k]].Scale); + Instances[k].nParent = -1; + Instances[k].Name = _FloraInsts[vegZone[k]].ShapeName; + Instances[k].InstanceName = _FloraInsts[vegZone[k]].PlantName; + /*Instances[k].InstanceName = "Flora_"; // see if it works + Instances[k].InstanceName += ZoneName + "_"; + Instances[k].InstanceName += '0' + ((k/1000)%10); + Instances[k].InstanceName += '0' + ((k/100) %10); + Instances[k].InstanceName += '0' + ((k/10) %10); + Instances[k].InstanceName += '0' + ( k %10);*/ + } + +// \todo trap -> look why it dont seems to work with a global positionning +//vGlobalPos /= (float)vegZone.size(); +//for (k = 0; k < (sint32)vegZone.size(); ++k) +// Instances[k].Pos -= vGlobalPos; + + CInstanceGroup IG; + IG.build (vGlobalPos, Instances, Portals, Clusters); + + ZoneName = _OutIGDir + "\\" + ZoneName; + ZoneName += ".ig"; + + CIFile inFile; // If file already exists and we have selection... + if (bTestForWriting) + if (inFile.open(ZoneName)) + { + inFile.close(); + continue; + } + + try + { + COFile outFile (ZoneName); + IG.serial (outFile); + if (_ExportCB != NULL) + _ExportCB->dispInfo (ZoneName + " generated"); + } + catch (const Exception &e) + { + if (_ExportCB != NULL) + _ExportCB->dispWarning ("Cant write " + ZoneName + " (" + e.what() + ")"); + } + } +} + +// --------------------------------------------------------------------------- +void CExport::loadLandscape (const string &LandFile) +{ + CZoneRegion zoneRegion; + + CIFile inFile; + try + { + if (inFile.open (LandFile)) + { + CIXml xml(true); + xml.init (inFile); + zoneRegion.serial (xml); + + inFile.close(); + } + else + { + if (_ExportCB != NULL) + _ExportCB->dispWarning (string("Can't open file ") + LandFile); + } + } + catch (const Exception &e) + { + if (_ExportCB != NULL) + _ExportCB->dispWarning (string("Cant load ") + LandFile + " : " + e.what()); + } + // Load all zone + + sint32 nTotalFile = (1 + zoneRegion.getMaxY() - zoneRegion.getMinY()) * (1 + zoneRegion.getMaxX() - zoneRegion.getMinX()); + sint32 nCurrentFile = 0; + for (sint32 j = zoneRegion.getMinY(); j <= zoneRegion.getMaxY(); ++j) + for (sint32 i = zoneRegion.getMinX(); i <= zoneRegion.getMaxX(); ++i) + { + ++nCurrentFile; + if (_ExportCB != NULL) + _ExportCB->dispPassProgress(((float)nCurrentFile)/((float)nTotalFile)); + + if ((zoneRegion.getName(i,j) == STRING_OUT_OF_BOUND) || + (zoneRegion.getName(i,j) == STRING_UNUSED)) + continue; + + // Generate zone name + + string ZoneName = getZoneNameFromXY (i, j); + + ZoneName = _InLandscapeDir + string("\\") + ZoneName; + + //if (_ExportCB != NULL) + // _ExportCB->dispInfo (string("Loading ") + ZoneName); + + try + { + CZone zone; + if (!inFile.open (ZoneName + string(".zonew"))) + inFile.open (ZoneName + string(".zonel")); + zone.serial (inFile); + inFile.close (); + _Landscape->addZone (zone); + } + catch(const Exception &/*e*/) + { + if (_ExportCB != NULL) + _ExportCB->dispWarning (string("Cant load ") + ZoneName + string(".zone(l,w)")); + } + if ((_ExportCB != NULL) && (_ExportCB->isCanceled())) + return; + } + +} + +// Public Helpers +// ************** + +// --------------------------------------------------------------------------- +string CExport::getZoneNameFromXY (sint32 x, sint32 y) +{ + string tmp; + + if ((y>0) || (y<-255) || (x<0) || (x>255)) + return "NOT VALID"; + tmp = toString(-y) + "_"; + tmp += ('A' + (x/26)); + tmp += ('A' + (x%26)); + return tmp; +} + +// --------------------------------------------------------------------------- +sint32 CExport::getXFromZoneName (const string &ZoneName) +{ + string xStr, yStr; + uint32 i = 0; + while (ZoneName[i] != '_') + { + yStr += ZoneName[i]; ++i; + if (i == ZoneName.size()) + return -1; + } + ++i; + while (i < ZoneName.size()) + { + xStr += ZoneName[i]; ++i; + } + return ((xStr[0] - 'A')*26 + (xStr[1] - 'A')); +} + +// --------------------------------------------------------------------------- +sint32 CExport::getYFromZoneName (const string &ZoneName) +{ + string xStr, yStr; + uint32 i = 0; + while (ZoneName[i] != '_') + { + yStr += ZoneName[i]; ++i; + if (i == ZoneName.size()) + return 1; + } + ++i; + while (i < ZoneName.size()) + { + xStr += ZoneName[i]; ++i; + } + return -atoi(yStr.c_str()); +} diff --git a/code/ryzom/tools/leveldesign/export/export.h b/code/ryzom/tools/leveldesign/export/export.h index 05687edab..2b55b0eb0 100644 --- a/code/ryzom/tools/leveldesign/export/export.h +++ b/code/ryzom/tools/leveldesign/export/export.h @@ -1,214 +1,214 @@ -// 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 LD_EXPORT_H -#define LD_EXPORT_H - -// --------------------------------------------------------------------------- - -#include "nel/misc/config_file.h" -#include "nel/misc/vector.h" -#include -#include - -// --------------------------------------------------------------------------- - -namespace NLLIGO -{ - class CPrimZone; - class CPrimPoint; - class CPrimPath; -} - -namespace NL3D -{ - class CLandscape; - class CVisualCollisionManager; - class CVisualCollisionEntity; -} - -struct SPlantInstance; -struct SFormPlant; - -// --------------------------------------------------------------------------- - -// --------------------------------------------------------------------------- -// Export options -// --------------------------------------------------------------------------- -struct SExportOptions -{ - std::string InLandscapeDir; // Directory where to get .zonew files - std::string OutIGDir; // Directory where to put IG - std::string LandBankFile; // The .smallbank file associated with the landscape - std::string LandFarBankFile; // The .farbank file - float CellSize; // Typically 160.0 - std::string LandTileNoiseDir; // Directory where to get displacement map - - std::string PrimFloraDir; // Directory to parse for .flora and .prim associated - // This is here we get continent.cfg file - - // Not read for the moment - std::string LandFile; // The .land file to get the mask and date of zones - std::string DfnDir; // Directory to get georges dfn - std::string GameElemDir; // Directory to get georges file (pipoti.plant) - - // ======================================================================= - - SExportOptions (); - bool loadcf (NLMISC::CConfigFile &cf); - bool save (FILE *f); -}; - -// --------------------------------------------------------------------------- -// Export callback -// --------------------------------------------------------------------------- -class IExportCB -{ -public: - virtual bool isCanceled () = 0; // Tell the exporter if it must end as quick as possible - // Display callbacks - virtual void dispPass (const std::string &Text) = 0; // Pass (generate land, flora, etc...) - virtual void dispPassProgress (float percentage) = 0; // [ 0.0 , 1.0 ] - virtual void dispInfo (const std::string &Text) = 0; // Verbose - virtual void dispWarning (const std::string &Text) = 0; // Error but not critical - virtual void dispError (const std::string &Text) = 0; // Should block (misfunction) -}; - -// --------------------------------------------------------------------------- -// Export Patat -// --------------------------------------------------------------------------- -struct SExportPrimitive -{ - std::string FullPrimName; - std::string PrimitiveName; - - bool operator == (const SExportPrimitive &rRightArg); -}; - -// --------------------------------------------------------------------------- -// Flora export -// --------------------------------------------------------------------------- -struct SFloraInst -{ - NLMISC::CVector Pos; - float Rot; - float Scale; - - float Radius; - std::string ShapeName; // the .shape stored in the name field of the instance (that represents the shape name) - std::string PlantName; // the .plant associated which is stored in the instance name -}; - -// --------------------------------------------------------------------------- -// Export class -// --------------------------------------------------------------------------- -class CExport -{ - -public: - - CExport (); - ~CExport (); - - // EXPORT one region : - // Parse the SourceDir find the .land and .prim - // newExport is the incremental export - bool newExport (SExportOptions &options, IExportCB *expCB = NULL); - bool doExport (SExportOptions &options, IExportCB *expCB = NULL, std::vector *selection = NULL); - - // HELPERS - // Get All files with the extension ext in the current directory and subdirectory - static void getAllFiles (const std::string &ext, std::vector &files); - // Search a file through all subdirectories of the current one (and in the current too) - static bool searchFile (const std::string &plantName, std::string &dir); - -private: - - SExportOptions *_Options; - IExportCB *_ExportCB; - - // Temp data to generate ig - NL3D::CLandscape *_Landscape; - NL3D::CVisualCollisionManager *_VCM; - NL3D::CVisualCollisionEntity *_VCE; - - std::vector _FloraInsts; - - std::string _ExeDir; - std::string _LandFile; - std::string _GameElemDir; - std::string _DfnDir; - - std::string _InLandscapeDir; // Directory where to get .zonew files - std::string _OutIGDir; // Directory where to put IG - std::string _LandBankFile; // The .smallbank file associated with the landscape - std::string _LandFarBankFile; // The .farbank file - std::string _LandTileNoiseDir; // Directory where to get displacement map - -private: - - struct SFloraToUpdate - { - std::string FloraFile; - std::vector PrimFile; - }; - - struct SPrimToUpdate - { - std::string PrimFile; - std::vector FloraFile; - }; - - // All the functions to generate the igs from flora - // ************************************************ - - // Entry point - bool generateIGFromFlora (const std::string &SrcFile, std::vector *selection = NULL); - - // Get the altitude from the position in 2D - float getZFromXY (float x, float y); - - // Does the plant is well placed - bool isWellPlaced (NLMISC::CVector &pos, SPlantInstance &rPI, SFormPlant &rFP, float scale); - - // Write zone by zone the instance group of the flora generated in the specific land - void writeFloraIG (const std::string &LandFile, bool bTestForWriting = false); - - // Helpers - // ******* - - // Load all zones of a .land - void loadLandscape (const std::string &name); - - bool segmentIntersection(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4); - void delIGZone (sint32 x, sint32 y); - void delAllIGZoneUnderPatat (float fCellSize, NLLIGO::CPrimZone *pPatat, const std::string &sIGOutputDir); - void delAllIGZoneUnderPoint (float fCellSize, NLLIGO::CPrimPoint *pPoint, const std::string &sIGOutputDir); - void delAllIGZoneUnderPath (float fCellSize, NLLIGO::CPrimPath *pPath, const std::string &sIGOutputDir); - bool isPatatNeedUpdate (float fCellSize, NLLIGO::CPrimZone *pPatat, const std::string &sIGOutputDir); - bool isPathNeedUpdate (float fCellSize, NLLIGO::CPrimPath *pPath, const std::string &sIGOutputDir); - bool isPointNeedUpdate (float fCellSize, NLLIGO::CPrimPoint *pPoint, const std::string &sIGOutputDir); - - -public: - - static std::string getZoneNameFromXY (sint32 x, sint32 y); - static sint32 getXFromZoneName (const std::string &ZoneName); - static sint32 getYFromZoneName (const std::string &ZoneName); - -}; - -#endif // LD_EXPORT_H +// 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 LD_EXPORT_H +#define LD_EXPORT_H + +// --------------------------------------------------------------------------- + +#include "nel/misc/config_file.h" +#include "nel/misc/vector.h" +#include +#include + +// --------------------------------------------------------------------------- + +namespace NLLIGO +{ + class CPrimZone; + class CPrimPoint; + class CPrimPath; +} + +namespace NL3D +{ + class CLandscape; + class CVisualCollisionManager; + class CVisualCollisionEntity; +} + +struct SPlantInstance; +struct SFormPlant; + +// --------------------------------------------------------------------------- + +// --------------------------------------------------------------------------- +// Export options +// --------------------------------------------------------------------------- +struct SExportOptions +{ + std::string InLandscapeDir; // Directory where to get .zonew files + std::string OutIGDir; // Directory where to put IG + std::string LandBankFile; // The .smallbank file associated with the landscape + std::string LandFarBankFile; // The .farbank file + float CellSize; // Typically 160.0 + std::string LandTileNoiseDir; // Directory where to get displacement map + + std::string PrimFloraDir; // Directory to parse for .flora and .prim associated + // This is here we get continent.cfg file + + // Not read for the moment + std::string LandFile; // The .land file to get the mask and date of zones + std::string DfnDir; // Directory to get georges dfn + std::string GameElemDir; // Directory to get georges file (pipoti.plant) + + // ======================================================================= + + SExportOptions (); + bool loadcf (NLMISC::CConfigFile &cf); + bool save (FILE *f); +}; + +// --------------------------------------------------------------------------- +// Export callback +// --------------------------------------------------------------------------- +class IExportCB +{ +public: + virtual bool isCanceled () = 0; // Tell the exporter if it must end as quick as possible + // Display callbacks + virtual void dispPass (const std::string &Text) = 0; // Pass (generate land, flora, etc...) + virtual void dispPassProgress (float percentage) = 0; // [ 0.0 , 1.0 ] + virtual void dispInfo (const std::string &Text) = 0; // Verbose + virtual void dispWarning (const std::string &Text) = 0; // Error but not critical + virtual void dispError (const std::string &Text) = 0; // Should block (misfunction) +}; + +// --------------------------------------------------------------------------- +// Export Patat +// --------------------------------------------------------------------------- +struct SExportPrimitive +{ + std::string FullPrimName; + std::string PrimitiveName; + + bool operator == (const SExportPrimitive &rRightArg); +}; + +// --------------------------------------------------------------------------- +// Flora export +// --------------------------------------------------------------------------- +struct SFloraInst +{ + NLMISC::CVector Pos; + float Rot; + float Scale; + + float Radius; + std::string ShapeName; // the .shape stored in the name field of the instance (that represents the shape name) + std::string PlantName; // the .plant associated which is stored in the instance name +}; + +// --------------------------------------------------------------------------- +// Export class +// --------------------------------------------------------------------------- +class CExport +{ + +public: + + CExport (); + ~CExport (); + + // EXPORT one region : + // Parse the SourceDir find the .land and .prim + // newExport is the incremental export + bool newExport (SExportOptions &options, IExportCB *expCB = NULL); + bool doExport (SExportOptions &options, IExportCB *expCB = NULL, std::vector *selection = NULL); + + // HELPERS + // Get All files with the extension ext in the current directory and subdirectory + static void getAllFiles (const std::string &ext, std::vector &files); + // Search a file through all subdirectories of the current one (and in the current too) + static bool searchFile (const std::string &plantName, std::string &dir); + +private: + + SExportOptions *_Options; + IExportCB *_ExportCB; + + // Temp data to generate ig + NL3D::CLandscape *_Landscape; + NL3D::CVisualCollisionManager *_VCM; + NL3D::CVisualCollisionEntity *_VCE; + + std::vector _FloraInsts; + + std::string _ExeDir; + std::string _LandFile; + std::string _GameElemDir; + std::string _DfnDir; + + std::string _InLandscapeDir; // Directory where to get .zonew files + std::string _OutIGDir; // Directory where to put IG + std::string _LandBankFile; // The .smallbank file associated with the landscape + std::string _LandFarBankFile; // The .farbank file + std::string _LandTileNoiseDir; // Directory where to get displacement map + +private: + + struct SFloraToUpdate + { + std::string FloraFile; + std::vector PrimFile; + }; + + struct SPrimToUpdate + { + std::string PrimFile; + std::vector FloraFile; + }; + + // All the functions to generate the igs from flora + // ************************************************ + + // Entry point + bool generateIGFromFlora (const std::string &SrcFile, std::vector *selection = NULL); + + // Get the altitude from the position in 2D + float getZFromXY (float x, float y); + + // Does the plant is well placed + bool isWellPlaced (NLMISC::CVector &pos, SPlantInstance &rPI, SFormPlant &rFP, float scale); + + // Write zone by zone the instance group of the flora generated in the specific land + void writeFloraIG (const std::string &LandFile, bool bTestForWriting = false); + + // Helpers + // ******* + + // Load all zones of a .land + void loadLandscape (const std::string &name); + + bool segmentIntersection(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4); + void delIGZone (sint32 x, sint32 y); + void delAllIGZoneUnderPatat (float fCellSize, NLLIGO::CPrimZone *pPatat, const std::string &sIGOutputDir); + void delAllIGZoneUnderPoint (float fCellSize, NLLIGO::CPrimPoint *pPoint, const std::string &sIGOutputDir); + void delAllIGZoneUnderPath (float fCellSize, NLLIGO::CPrimPath *pPath, const std::string &sIGOutputDir); + bool isPatatNeedUpdate (float fCellSize, NLLIGO::CPrimZone *pPatat, const std::string &sIGOutputDir); + bool isPathNeedUpdate (float fCellSize, NLLIGO::CPrimPath *pPath, const std::string &sIGOutputDir); + bool isPointNeedUpdate (float fCellSize, NLLIGO::CPrimPoint *pPoint, const std::string &sIGOutputDir); + + +public: + + static std::string getZoneNameFromXY (sint32 x, sint32 y); + static sint32 getXFromZoneName (const std::string &ZoneName); + static sint32 getYFromZoneName (const std::string &ZoneName); + +}; + +#endif // LD_EXPORT_H diff --git a/code/ryzom/tools/leveldesign/export/formFlora.cpp b/code/ryzom/tools/leveldesign/export/formFlora.cpp index 8614cce03..4ed1ddd4b 100644 --- a/code/ryzom/tools/leveldesign/export/formFlora.cpp +++ b/code/ryzom/tools/leveldesign/export/formFlora.cpp @@ -1,93 +1,93 @@ -// 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 "formFlora.h" - -#include "nel/misc/common.h" -#include "nel/misc/debug.h" - -#include "nel/georges/u_form_elm.h" - -using namespace std; -using namespace NLMISC; -using namespace NLGEORGES; - -// --------------------------------------------------------------------------- -void SFormFlora::build (UFormElm &item) -{ - IncludePatats.clear (); - ExcludePatats.clear (); - PlantInstances.clear (); - - // Read the Include_patats field - UFormElm *pElt; - if (item.getNodeByName (&pElt, "Include_patats") && pElt) - { - uint size; - nlverify (pElt->getArraySize (size)); - for (uint i=0; igetArrayValue (value, i); - IncludePatats.push_back (value); - } - } - - // Read the Include_patats field - if (item.getNodeByName (&pElt, "Exclude_patats") && pElt) - { - uint size; - nlverify (pElt->getArraySize (size)); - for (uint i=0; igetArrayValue (value, i); - ExcludePatats.push_back (value); - } - } - - // Read the Plants field - if (item.getNodeByName (&pElt, "Plants") && pElt) - { - uint size; - nlverify (pElt->getArraySize (size)); - for (uint i=0; igetArrayNode (&pArrayElt, i) && pArrayElt) - { - SPlantInstance piTmp; - pArrayElt->getValueByName (piTmp.Name, "File name"); - pArrayElt->getValueByName (piTmp.Density, "Density"); - pArrayElt->getValueByName (piTmp.Falloff, "Falloff"); - PlantInstances.push_back (piTmp); - } - } - } - - item.getValueByName (JitterPos, "Jitter_Pos"); - - item.getValueByName (ScaleMin, "Scale_Min"); - - item.getValueByName (ScaleMax, "Scale_Max"); - - item.getValueByName (PutOnWater, "Put_On_Water"); - - item.getValueByName (WaterHeight, "Water_Height"); - - item.getValueByName (RandomSeed, "Random_Seed"); -} +// 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 "formFlora.h" + +#include "nel/misc/common.h" +#include "nel/misc/debug.h" + +#include "nel/georges/u_form_elm.h" + +using namespace std; +using namespace NLMISC; +using namespace NLGEORGES; + +// --------------------------------------------------------------------------- +void SFormFlora::build (UFormElm &item) +{ + IncludePatats.clear (); + ExcludePatats.clear (); + PlantInstances.clear (); + + // Read the Include_patats field + UFormElm *pElt; + if (item.getNodeByName (&pElt, "Include_patats") && pElt) + { + uint size; + nlverify (pElt->getArraySize (size)); + for (uint i=0; igetArrayValue (value, i); + IncludePatats.push_back (value); + } + } + + // Read the Include_patats field + if (item.getNodeByName (&pElt, "Exclude_patats") && pElt) + { + uint size; + nlverify (pElt->getArraySize (size)); + for (uint i=0; igetArrayValue (value, i); + ExcludePatats.push_back (value); + } + } + + // Read the Plants field + if (item.getNodeByName (&pElt, "Plants") && pElt) + { + uint size; + nlverify (pElt->getArraySize (size)); + for (uint i=0; igetArrayNode (&pArrayElt, i) && pArrayElt) + { + SPlantInstance piTmp; + pArrayElt->getValueByName (piTmp.Name, "File name"); + pArrayElt->getValueByName (piTmp.Density, "Density"); + pArrayElt->getValueByName (piTmp.Falloff, "Falloff"); + PlantInstances.push_back (piTmp); + } + } + } + + item.getValueByName (JitterPos, "Jitter_Pos"); + + item.getValueByName (ScaleMin, "Scale_Min"); + + item.getValueByName (ScaleMax, "Scale_Max"); + + item.getValueByName (PutOnWater, "Put_On_Water"); + + item.getValueByName (WaterHeight, "Water_Height"); + + item.getValueByName (RandomSeed, "Random_Seed"); +} diff --git a/code/ryzom/tools/leveldesign/export/formFlora.h b/code/ryzom/tools/leveldesign/export/formFlora.h index 809f0570e..2cdf01f00 100644 --- a/code/ryzom/tools/leveldesign/export/formFlora.h +++ b/code/ryzom/tools/leveldesign/export/formFlora.h @@ -1,56 +1,56 @@ -// 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 LD_FORMFLORA_H -#define LD_FORMFLORA_H - -// --------------------------------------------------------------------------- - -#include "nel/misc/types_nl.h" - -#include -#include - -namespace NLGEORGES -{ - class UFormElm; -} - -// --------------------------------------------------------------------------- -struct SPlantInstance -{ - std::string Name; - float Density; - float Falloff; -}; - -// --------------------------------------------------------------------------- -struct SFormFlora -{ - std::vector IncludePatats; - std::vector ExcludePatats; - std::vector PlantInstances; - float JitterPos; - float ScaleMin; - float ScaleMax; - bool PutOnWater; - float WaterHeight; - uint32 RandomSeed; - - void build (NLGEORGES::UFormElm &item); -}; - +// 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 LD_FORMFLORA_H +#define LD_FORMFLORA_H + +// --------------------------------------------------------------------------- + +#include "nel/misc/types_nl.h" + +#include +#include + +namespace NLGEORGES +{ + class UFormElm; +} + +// --------------------------------------------------------------------------- +struct SPlantInstance +{ + std::string Name; + float Density; + float Falloff; +}; + +// --------------------------------------------------------------------------- +struct SFormFlora +{ + std::vector IncludePatats; + std::vector ExcludePatats; + std::vector PlantInstances; + float JitterPos; + float ScaleMin; + float ScaleMax; + bool PutOnWater; + float WaterHeight; + uint32 RandomSeed; + + void build (NLGEORGES::UFormElm &item); +}; + #endif // LD_FORMFLORA_H \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/export/formPlant.cpp b/code/ryzom/tools/leveldesign/export/formPlant.cpp index 3fd56bb29..48bfa8a6a 100644 --- a/code/ryzom/tools/leveldesign/export/formPlant.cpp +++ b/code/ryzom/tools/leveldesign/export/formPlant.cpp @@ -1,41 +1,41 @@ -// 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 "formPlant.h" - -#include "nel/misc/common.h" - -#include "nel/georges/u_form_elm.h" - -using namespace std; -using namespace NLMISC; -using namespace NLGEORGES; - -// --------------------------------------------------------------------------- -void SFormPlant::build (UFormElm &item) -{ - item.getValueByName (Name, "Plant Name"); - - item.getValueByName (Shape, "3D.Shape"); - - item.getValueByName (Shadow, "3D.Shadow Shape"); - - if (!item.getValueByName (CollisionRadius, "3D.Collision Radius")) - CollisionRadius = 0.0f; - - if (!item.getValueByName (BoundingRadius, "3D.Bounding Radius")) - BoundingRadius = 0.0f; -} +// 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 "formPlant.h" + +#include "nel/misc/common.h" + +#include "nel/georges/u_form_elm.h" + +using namespace std; +using namespace NLMISC; +using namespace NLGEORGES; + +// --------------------------------------------------------------------------- +void SFormPlant::build (UFormElm &item) +{ + item.getValueByName (Name, "Plant Name"); + + item.getValueByName (Shape, "3D.Shape"); + + item.getValueByName (Shadow, "3D.Shadow Shape"); + + if (!item.getValueByName (CollisionRadius, "3D.Collision Radius")) + CollisionRadius = 0.0f; + + if (!item.getValueByName (BoundingRadius, "3D.Bounding Radius")) + BoundingRadius = 0.0f; +} diff --git a/code/ryzom/tools/leveldesign/export/formPlant.h b/code/ryzom/tools/leveldesign/export/formPlant.h index c0aea3166..a9ead73c2 100644 --- a/code/ryzom/tools/leveldesign/export/formPlant.h +++ b/code/ryzom/tools/leveldesign/export/formPlant.h @@ -1,41 +1,41 @@ -// 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 LD_FORMPLANT_H -#define LD_FORMPLANT_H - -// --------------------------------------------------------------------------- - -#include - -namespace NLGEORGES -{ - class UFormElm; -} - -// --------------------------------------------------------------------------- -struct SFormPlant -{ - std::string Name; - std::string Shape; - std::string Shadow; - float CollisionRadius; - float BoundingRadius; - - void build (NLGEORGES::UFormElm &item); -}; - +// 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 LD_FORMPLANT_H +#define LD_FORMPLANT_H + +// --------------------------------------------------------------------------- + +#include + +namespace NLGEORGES +{ + class UFormElm; +} + +// --------------------------------------------------------------------------- +struct SFormPlant +{ + std::string Name; + std::string Shape; + std::string Shadow; + float CollisionRadius; + float BoundingRadius; + + void build (NLGEORGES::UFormElm &item); +}; + #endif \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/export/tools.cpp b/code/ryzom/tools/leveldesign/export/tools.cpp index 0d93a95ff..742359840 100644 --- a/code/ryzom/tools/leveldesign/export/tools.cpp +++ b/code/ryzom/tools/leveldesign/export/tools.cpp @@ -1,249 +1,249 @@ -// 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 "tools.h" -#include - -#include "nel/misc/common.h" - -// --------------------------------------------------------------------------- - -using namespace std; -using namespace NLMISC; - -// --------------------------------------------------------------------------- -void CTools::mkdir (const string &dirName) -{ - if (dirName == "") - return; - // Does the directory exist ? - string newDir = pwd(); - if (SetCurrentDirectory (dirName.c_str())) - { - SetCurrentDirectory (newDir.c_str()); - return; - } - SetCurrentDirectory (newDir.c_str()); - // Create upper levels - newDir = ""; - string::size_type pos = dirName.rfind('\\'); - if (pos != string::npos) - { - for (uint i = 0; i < pos; ++i) - newDir += dirName[i]; - mkdir (newDir); - } - // Create Directory - if (!CreateDirectory(dirName.c_str(),NULL)) - throw Exception(string("Cannot create directory ")+dirName); -} - -// --------------------------------------------------------------------------- -void CTools::chdir (const std::string &newDir) -{ - if (!SetCurrentDirectory (newDir.c_str())) - throwError ((newDir+" : ").c_str ()); -} - -// --------------------------------------------------------------------------- -std::string CTools::pwd () -{ - char sTmp[512]; - if (GetCurrentDirectory (512, sTmp) == 0) - { - throwError ("Get current directory : "); - } - string sTmp2 = sTmp; - return sTmp2; -} - -// --------------------------------------------------------------------------- -std::string CTools::normalizePath (const std::string &path) -{ - // Convert slash to anti-slash - string retPath = path; - for (uint32 i = 0; i < retPath.size(); ++i) - if (retPath[i] == '/') - retPath[i] = '\\'; - return retPath; -} - -// --------------------------------------------------------------------------- -bool CTools::fileExist (const std::string &sFileName) -{ - HANDLE hFile = CreateFile (sFileName.c_str(), GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (hFile == INVALID_HANDLE_VALUE) - return false; - CloseHandle (hFile); - return true; -} - -// --------------------------------------------------------------------------- -int CTools::fileDateCmp (const std::string &file1, const std::string &file2) -{ - HANDLE hFile1 = CreateFile (file1.c_str(), GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - HANDLE hFile2 = CreateFile (file2.c_str(), GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if ((hFile1 == INVALID_HANDLE_VALUE) && (hFile2 == INVALID_HANDLE_VALUE)) - return 0; - if (hFile1 == INVALID_HANDLE_VALUE) - { - CloseHandle(hFile2); - return -1; - } - if (hFile2 == INVALID_HANDLE_VALUE) - { - CloseHandle(hFile1); - return 1; - } - - FILETIME CreationTime1, LastAccessTime1, LastWrite1; - GetFileTime (hFile1, &CreationTime1, &LastAccessTime1, &LastWrite1); - FILETIME CreationTime2, LastAccessTime2, LastWrite2; - GetFileTime (hFile2, &CreationTime2, &LastAccessTime2, &LastWrite2); - - LONG nRet = CompareFileTime (&LastWrite1, &LastWrite2); - - CloseHandle(hFile1); - CloseHandle(hFile2); - - return nRet; -} - -// --------------------------------------------------------------------------- -int CTools::fileDateCmp (const std::string &file1, uint32 nDateLow, uint32 nDateHigh) -{ - HANDLE hFile1 = CreateFile (file1.c_str(), GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (hFile1 == INVALID_HANDLE_VALUE) - { - return -1; - } - FILETIME CreationTime1, LastAccessTime1, LastWrite1; - GetFileTime (hFile1, &CreationTime1, &LastAccessTime1, &LastWrite1); - FILETIME Date; - Date.dwLowDateTime = nDateLow; - Date.dwHighDateTime = nDateHigh; - LONG nRet = CompareFileTime (&LastWrite1, &Date); - - CloseHandle(hFile1); - return nRet; -} - -// --------------------------------------------------------------------------- -void CTools::dir (const std::string &sFilter, std::vector &sAllFiles, bool bFullPath) -{ - WIN32_FIND_DATA findData; - HANDLE hFind; - char sCurDir[MAX_PATH]; - sAllFiles.clear (); - GetCurrentDirectory (MAX_PATH, sCurDir); - hFind = FindFirstFile (sFilter.c_str(), &findData); - while (hFind != INVALID_HANDLE_VALUE) - { - if (!(GetFileAttributes(findData.cFileName)&FILE_ATTRIBUTE_DIRECTORY)) - { - if (bFullPath) - sAllFiles.push_back(string(sCurDir) + "\\" + findData.cFileName); - else - sAllFiles.push_back(findData.cFileName); - } - if (FindNextFile (hFind, &findData) == 0) - break; - } - FindClose (hFind); -} - -// --------------------------------------------------------------------------- -void CTools::dirSub (const std::string &sFilter, std::vector &sAllFiles, bool bFullPath) -{ - sAllFiles.clear(); - string sTmp; - for (uint32 i = 0; i < sFilter.size(); ++i) - if (sFilter[i] != '*') - sTmp += sFilter[i]; - dirSubRecurse (sTmp, sAllFiles, bFullPath); -} - -// --------------------------------------------------------------------------- -void CTools::copy (const std::string &DstFile, const std::string &SrcFile) -{ - if (!CopyFile (SrcFile.c_str(), DstFile.c_str(), false)) - { - throw Exception(string("Cannot copy ")+SrcFile+" to "+DstFile); - } -} - -// ******* -// PRIVATE -// ******* - -// --------------------------------------------------------------------------- -void CTools::throwError (const char *message) -{ - LPVOID lpMsgBuf; - FormatMessage ( FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &lpMsgBuf, - 0, - NULL ); - string sTmp = (char*)lpMsgBuf; - sTmp = message + sTmp; - LocalFree (lpMsgBuf); - throw Exception (sTmp); -} - -// --------------------------------------------------------------------------- -void CTools::dirSubRecurse (const std::string &sFilter, std::vector &sAllFiles, bool bFullPath) -{ - WIN32_FIND_DATA findData; - HANDLE hFind; - char sCurDir[MAX_PATH]; - - GetCurrentDirectory (MAX_PATH, sCurDir); - hFind = FindFirstFile ("*.*", &findData); - while (hFind != INVALID_HANDLE_VALUE) - { - if (!(GetFileAttributes(findData.cFileName)&FILE_ATTRIBUTE_DIRECTORY)) - { - string sTmp = findData.cFileName; - if (sTmp.size() > sFilter.size()) - if (strcmp(sTmp.c_str()+sTmp.size()-sFilter.size(), sFilter.c_str()) == 0) - { - if (bFullPath) - sAllFiles.push_back(string(sCurDir) + "\\" + findData.cFileName); - else - sAllFiles.push_back(findData.cFileName); - } - } - else if ((strcmp(findData.cFileName, ".") != 0) && (strcmp(findData.cFileName, "..") != 0)) - { - SetCurrentDirectory (findData.cFileName); - dirSubRecurse (sFilter, sAllFiles, bFullPath); - SetCurrentDirectory (sCurDir); - } - if (FindNextFile (hFind, &findData) == 0) - break; - } - FindClose (hFind); -} - +// 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 "tools.h" +#include + +#include "nel/misc/common.h" + +// --------------------------------------------------------------------------- + +using namespace std; +using namespace NLMISC; + +// --------------------------------------------------------------------------- +void CTools::mkdir (const string &dirName) +{ + if (dirName == "") + return; + // Does the directory exist ? + string newDir = pwd(); + if (SetCurrentDirectory (dirName.c_str())) + { + SetCurrentDirectory (newDir.c_str()); + return; + } + SetCurrentDirectory (newDir.c_str()); + // Create upper levels + newDir = ""; + string::size_type pos = dirName.rfind('\\'); + if (pos != string::npos) + { + for (uint i = 0; i < pos; ++i) + newDir += dirName[i]; + mkdir (newDir); + } + // Create Directory + if (!CreateDirectory(dirName.c_str(),NULL)) + throw Exception(string("Cannot create directory ")+dirName); +} + +// --------------------------------------------------------------------------- +void CTools::chdir (const std::string &newDir) +{ + if (!SetCurrentDirectory (newDir.c_str())) + throwError ((newDir+" : ").c_str ()); +} + +// --------------------------------------------------------------------------- +std::string CTools::pwd () +{ + char sTmp[512]; + if (GetCurrentDirectory (512, sTmp) == 0) + { + throwError ("Get current directory : "); + } + string sTmp2 = sTmp; + return sTmp2; +} + +// --------------------------------------------------------------------------- +std::string CTools::normalizePath (const std::string &path) +{ + // Convert slash to anti-slash + string retPath = path; + for (uint32 i = 0; i < retPath.size(); ++i) + if (retPath[i] == '/') + retPath[i] = '\\'; + return retPath; +} + +// --------------------------------------------------------------------------- +bool CTools::fileExist (const std::string &sFileName) +{ + HANDLE hFile = CreateFile (sFileName.c_str(), GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (hFile == INVALID_HANDLE_VALUE) + return false; + CloseHandle (hFile); + return true; +} + +// --------------------------------------------------------------------------- +int CTools::fileDateCmp (const std::string &file1, const std::string &file2) +{ + HANDLE hFile1 = CreateFile (file1.c_str(), GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + HANDLE hFile2 = CreateFile (file2.c_str(), GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if ((hFile1 == INVALID_HANDLE_VALUE) && (hFile2 == INVALID_HANDLE_VALUE)) + return 0; + if (hFile1 == INVALID_HANDLE_VALUE) + { + CloseHandle(hFile2); + return -1; + } + if (hFile2 == INVALID_HANDLE_VALUE) + { + CloseHandle(hFile1); + return 1; + } + + FILETIME CreationTime1, LastAccessTime1, LastWrite1; + GetFileTime (hFile1, &CreationTime1, &LastAccessTime1, &LastWrite1); + FILETIME CreationTime2, LastAccessTime2, LastWrite2; + GetFileTime (hFile2, &CreationTime2, &LastAccessTime2, &LastWrite2); + + LONG nRet = CompareFileTime (&LastWrite1, &LastWrite2); + + CloseHandle(hFile1); + CloseHandle(hFile2); + + return nRet; +} + +// --------------------------------------------------------------------------- +int CTools::fileDateCmp (const std::string &file1, uint32 nDateLow, uint32 nDateHigh) +{ + HANDLE hFile1 = CreateFile (file1.c_str(), GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (hFile1 == INVALID_HANDLE_VALUE) + { + return -1; + } + FILETIME CreationTime1, LastAccessTime1, LastWrite1; + GetFileTime (hFile1, &CreationTime1, &LastAccessTime1, &LastWrite1); + FILETIME Date; + Date.dwLowDateTime = nDateLow; + Date.dwHighDateTime = nDateHigh; + LONG nRet = CompareFileTime (&LastWrite1, &Date); + + CloseHandle(hFile1); + return nRet; +} + +// --------------------------------------------------------------------------- +void CTools::dir (const std::string &sFilter, std::vector &sAllFiles, bool bFullPath) +{ + WIN32_FIND_DATA findData; + HANDLE hFind; + char sCurDir[MAX_PATH]; + sAllFiles.clear (); + GetCurrentDirectory (MAX_PATH, sCurDir); + hFind = FindFirstFile (sFilter.c_str(), &findData); + while (hFind != INVALID_HANDLE_VALUE) + { + if (!(GetFileAttributes(findData.cFileName)&FILE_ATTRIBUTE_DIRECTORY)) + { + if (bFullPath) + sAllFiles.push_back(string(sCurDir) + "\\" + findData.cFileName); + else + sAllFiles.push_back(findData.cFileName); + } + if (FindNextFile (hFind, &findData) == 0) + break; + } + FindClose (hFind); +} + +// --------------------------------------------------------------------------- +void CTools::dirSub (const std::string &sFilter, std::vector &sAllFiles, bool bFullPath) +{ + sAllFiles.clear(); + string sTmp; + for (uint32 i = 0; i < sFilter.size(); ++i) + if (sFilter[i] != '*') + sTmp += sFilter[i]; + dirSubRecurse (sTmp, sAllFiles, bFullPath); +} + +// --------------------------------------------------------------------------- +void CTools::copy (const std::string &DstFile, const std::string &SrcFile) +{ + if (!CopyFile (SrcFile.c_str(), DstFile.c_str(), false)) + { + throw Exception(string("Cannot copy ")+SrcFile+" to "+DstFile); + } +} + +// ******* +// PRIVATE +// ******* + +// --------------------------------------------------------------------------- +void CTools::throwError (const char *message) +{ + LPVOID lpMsgBuf; + FormatMessage ( FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPTSTR) &lpMsgBuf, + 0, + NULL ); + string sTmp = (char*)lpMsgBuf; + sTmp = message + sTmp; + LocalFree (lpMsgBuf); + throw Exception (sTmp); +} + +// --------------------------------------------------------------------------- +void CTools::dirSubRecurse (const std::string &sFilter, std::vector &sAllFiles, bool bFullPath) +{ + WIN32_FIND_DATA findData; + HANDLE hFind; + char sCurDir[MAX_PATH]; + + GetCurrentDirectory (MAX_PATH, sCurDir); + hFind = FindFirstFile ("*.*", &findData); + while (hFind != INVALID_HANDLE_VALUE) + { + if (!(GetFileAttributes(findData.cFileName)&FILE_ATTRIBUTE_DIRECTORY)) + { + string sTmp = findData.cFileName; + if (sTmp.size() > sFilter.size()) + if (strcmp(sTmp.c_str()+sTmp.size()-sFilter.size(), sFilter.c_str()) == 0) + { + if (bFullPath) + sAllFiles.push_back(string(sCurDir) + "\\" + findData.cFileName); + else + sAllFiles.push_back(findData.cFileName); + } + } + else if ((strcmp(findData.cFileName, ".") != 0) && (strcmp(findData.cFileName, "..") != 0)) + { + SetCurrentDirectory (findData.cFileName); + dirSubRecurse (sFilter, sAllFiles, bFullPath); + SetCurrentDirectory (sCurDir); + } + if (FindNextFile (hFind, &findData) == 0) + break; + } + FindClose (hFind); +} + diff --git a/code/ryzom/tools/leveldesign/export/tools.h b/code/ryzom/tools/leveldesign/export/tools.h index b45851856..69c5c1012 100644 --- a/code/ryzom/tools/leveldesign/export/tools.h +++ b/code/ryzom/tools/leveldesign/export/tools.h @@ -1,77 +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 __TOOLS_H__ -#define __TOOLS_H__ - -#include "nel/misc/types_nl.h" -#include -#include - -class CTools -{ - -public: - - // Make directory even if not the whole path is not created - // Example : c:\temp is created and we call mkdir("c:\temp\aze\qsd") - // The function create c:\temp\aze and then c:\temp\aze\qsd - static void mkdir (const std::string &FullDirName); - - // Change the directory. We can give directory relative to the current one - static void chdir (const std::string &dirName); - - // Get the current directory - static std::string pwd (); - - // Convert a relative and not formated path to an absolute one - static std::string normalizePath (const std::string &path); - - // Return true if file exists - static bool fileExist (const std::string &sFileName); - - // Return -1 if file1.date < file2.date (file1 is older than file2) - // Return 0 if file1.date = file2.date (file1 and file2 has the same date) - // Return 1 if file1.date > file2.date (file1 is newer than file2) - static int fileDateCmp (const std::string &file1, const std::string &file2); - - // Return -1 if file1.date < (nDateLow+(nDateHigh<<32)) (file1 is older than nDate) - // Return 0 if file1.date = (nDateLow+(nDateHigh<<32)) (file1 and nDate has the same date) - // Return 1 if file1.date > (nDateLow+(nDateHigh<<32)) (file1 is newer than nDate) - static int fileDateCmp (const std::string &file1, uint32 nDateLow, uint32 nDateHigh); - - // Return in sAllFiles all the files listed in the current directory - // bFullPath indicates if the returned names are fully qualified - static void dir (const std::string &sFilter, std::vector &sAllFiles, bool bFullPath); - - // Return in sAllFiles all the files listed in the current directory and subdirectories - // bFullPath indicates if the returned names are fully qualified - static void dirSub (const std::string &sFilter, std::vector &sAllFiles, bool bFullPath); - - // Copy a file - static void copy (const std::string &DstFile, const std::string &SrcFile); - -private: - - // Throw the last error - static void throwError (const char *message); - - // Used by dirSub - static void dirSubRecurse (const std::string &sFilter, std::vector &sAllFiles, bool bFullPath); - -}; - +// 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 __TOOLS_H__ +#define __TOOLS_H__ + +#include "nel/misc/types_nl.h" +#include +#include + +class CTools +{ + +public: + + // Make directory even if not the whole path is not created + // Example : c:\temp is created and we call mkdir("c:\temp\aze\qsd") + // The function create c:\temp\aze and then c:\temp\aze\qsd + static void mkdir (const std::string &FullDirName); + + // Change the directory. We can give directory relative to the current one + static void chdir (const std::string &dirName); + + // Get the current directory + static std::string pwd (); + + // Convert a relative and not formated path to an absolute one + static std::string normalizePath (const std::string &path); + + // Return true if file exists + static bool fileExist (const std::string &sFileName); + + // Return -1 if file1.date < file2.date (file1 is older than file2) + // Return 0 if file1.date = file2.date (file1 and file2 has the same date) + // Return 1 if file1.date > file2.date (file1 is newer than file2) + static int fileDateCmp (const std::string &file1, const std::string &file2); + + // Return -1 if file1.date < (nDateLow+(nDateHigh<<32)) (file1 is older than nDate) + // Return 0 if file1.date = (nDateLow+(nDateHigh<<32)) (file1 and nDate has the same date) + // Return 1 if file1.date > (nDateLow+(nDateHigh<<32)) (file1 is newer than nDate) + static int fileDateCmp (const std::string &file1, uint32 nDateLow, uint32 nDateHigh); + + // Return in sAllFiles all the files listed in the current directory + // bFullPath indicates if the returned names are fully qualified + static void dir (const std::string &sFilter, std::vector &sAllFiles, bool bFullPath); + + // Return in sAllFiles all the files listed in the current directory and subdirectories + // bFullPath indicates if the returned names are fully qualified + static void dirSub (const std::string &sFilter, std::vector &sAllFiles, bool bFullPath); + + // Copy a file + static void copy (const std::string &DstFile, const std::string &SrcFile); + +private: + + // Throw the last error + static void throwError (const char *message); + + // Used by dirSub + static void dirSubRecurse (const std::string &sFilter, std::vector &sAllFiles, bool bFullPath); + +}; + #endif // __TOOLS_H__ \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_convert/common.h b/code/ryzom/tools/leveldesign/georges_convert/common.h index 74cc2d04e..9965279e8 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/common.h +++ b/code/ryzom/tools/leveldesign/georges_convert/common.h @@ -1,36 +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 NLGEORGES_COMMON_H -#define NLGEORGES_COMMON_H - -namespace NLOLDGEORGES -{ - -#define ITEM_HAVEPARENT 1 -#define ITEM_HAVECURRENT 2 -#define ITEM_ISATOM 4 -#define ITEM_ISSTRUCT 8 -#define ITEM_ISLIST 16 -#define ITEM_ISENUM 32 -#define ITEM_ISLISTCHILD 64 - -#define RESERVEDKEYWORD_PARENTS "Parents" -#define RESERVEDKEYWORD_COMMENTS "Comments" - -} - -#endif // NLGEORGES_COMMON_H +// 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 NLGEORGES_COMMON_H +#define NLGEORGES_COMMON_H + +namespace NLOLDGEORGES +{ + +#define ITEM_HAVEPARENT 1 +#define ITEM_HAVECURRENT 2 +#define ITEM_ISATOM 4 +#define ITEM_ISSTRUCT 8 +#define ITEM_ISLIST 16 +#define ITEM_ISENUM 32 +#define ITEM_ISLISTCHILD 64 + +#define RESERVEDKEYWORD_PARENTS "Parents" +#define RESERVEDKEYWORD_COMMENTS "Comments" + +} + +#endif // NLGEORGES_COMMON_H diff --git a/code/ryzom/tools/leveldesign/georges_convert/form.cpp b/code/ryzom/tools/leveldesign/georges_convert/form.cpp index f1567f650..fa07b1fd7 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/form.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/form.cpp @@ -1,150 +1,150 @@ -// 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 "stdgeorgesconvert.h" - -#include "form.h" -#include "form_body_elt.h" - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CForm::CForm() -{ - body.SetName( "BODY" ); - bmodified = false; -} - -CForm::CForm( const CForm& _f ) -{ - bmodified = _f.bmodified; - head = _f.head; - body = _f.body; -} - -CForm::~CForm() -{ -} - -void CForm::serial( NLMISC::IStream& s ) -{ - s.serial( head ); - s.serial( body ); -} - -CStringEx CForm::GetDate() const -{ - return( head.GetDate() ); -} - -CStringEx CForm::GetVersion() const -{ - return( head.GetVersion() ); -} - -CStringEx CForm::GetUser() const -{ - return( head.GetUser() ); -} - -CStringEx CForm::GetComment() const -{ - return( body.GetComment() ); -} - -void CForm::SetDate( const CStringEx _sxdate ) -{ - head.SetDate( _sxdate ); -} - -void CForm::SetVersion( const CStringEx _sxversion ) -{ - head.SetVersion( _sxversion ); -} - -void CForm::SetUser( const CStringEx _sxuser ) -{ - head.SetUser( _sxuser ); -} - -void CForm::SetComment( const CStringEx _sxcomment ) -{ - body.SetComment( _sxcomment ); -} - -CStringEx CForm::GetParent( unsigned int _index ) const -{ - return( body.GetParent( _index ) ); -} - -CStringEx CForm::GetActivity( unsigned int _index ) const -{ - return( body.GetActivity( _index ) ); -} - -CFormBodyElt* CForm::GetElt( const CStringEx _sxname ) const -{ - return( body.GetElt( _sxname ) ); -} - -CFormBodyEltStruct* CForm::GetBody() const -{ - return( (CFormBodyEltStruct*)(&body) ); -} - -bool CForm::GetModified() const -{ - return( bmodified ); -} - -void CForm::SetModified( const bool _b ) -{ - bmodified = _b; -} - -CForm& CForm::operator =( const CForm& _f ) -{ - head = _f.head; - body = _f.body; - bmodified = true; - return( *this ); -} - -CForm& CForm::operator +=( const CForm& _f ) -{ - head = _f.head; - body += _f.body; - bmodified = true; - return( *this ); -} - -CForm& CForm::operator -=( const CForm& _f ) -{ - body -= _f.body; - bmodified = true; - return( *this ); -} - -bool CForm::operator ==( const CForm& _f ) const -{ - return( (body == _f.body) ); -} - +// 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 "stdgeorgesconvert.h" + +#include "form.h" +#include "form_body_elt.h" + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CForm::CForm() +{ + body.SetName( "BODY" ); + bmodified = false; +} + +CForm::CForm( const CForm& _f ) +{ + bmodified = _f.bmodified; + head = _f.head; + body = _f.body; +} + +CForm::~CForm() +{ +} + +void CForm::serial( NLMISC::IStream& s ) +{ + s.serial( head ); + s.serial( body ); +} + +CStringEx CForm::GetDate() const +{ + return( head.GetDate() ); +} + +CStringEx CForm::GetVersion() const +{ + return( head.GetVersion() ); +} + +CStringEx CForm::GetUser() const +{ + return( head.GetUser() ); +} + +CStringEx CForm::GetComment() const +{ + return( body.GetComment() ); +} + +void CForm::SetDate( const CStringEx _sxdate ) +{ + head.SetDate( _sxdate ); +} + +void CForm::SetVersion( const CStringEx _sxversion ) +{ + head.SetVersion( _sxversion ); +} + +void CForm::SetUser( const CStringEx _sxuser ) +{ + head.SetUser( _sxuser ); +} + +void CForm::SetComment( const CStringEx _sxcomment ) +{ + body.SetComment( _sxcomment ); +} + +CStringEx CForm::GetParent( unsigned int _index ) const +{ + return( body.GetParent( _index ) ); +} + +CStringEx CForm::GetActivity( unsigned int _index ) const +{ + return( body.GetActivity( _index ) ); +} + +CFormBodyElt* CForm::GetElt( const CStringEx _sxname ) const +{ + return( body.GetElt( _sxname ) ); +} + +CFormBodyEltStruct* CForm::GetBody() const +{ + return( (CFormBodyEltStruct*)(&body) ); +} + +bool CForm::GetModified() const +{ + return( bmodified ); +} + +void CForm::SetModified( const bool _b ) +{ + bmodified = _b; +} + +CForm& CForm::operator =( const CForm& _f ) +{ + head = _f.head; + body = _f.body; + bmodified = true; + return( *this ); +} + +CForm& CForm::operator +=( const CForm& _f ) +{ + head = _f.head; + body += _f.body; + bmodified = true; + return( *this ); +} + +CForm& CForm::operator -=( const CForm& _f ) +{ + body -= _f.body; + bmodified = true; + return( *this ); +} + +bool CForm::operator ==( const CForm& _f ) const +{ + return( (body == _f.body) ); +} + } \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_convert/form.h b/code/ryzom/tools/leveldesign/georges_convert/form.h index bc97021ec..6a9718c8e 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/form.h +++ b/code/ryzom/tools/leveldesign/georges_convert/form.h @@ -1,71 +1,71 @@ -// 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 NLGEORGES_FORM_H -#define NLGEORGES_FORM_H - -#include "nel/misc/stream.h" -#include "form_head.h" -#include "form_body_elt_struct.h" - -namespace NLOLDGEORGES -{ - -class CFormBodyElt; - -// La classe CForm représente une fiche. -// Elle comprend Head et Body. -// Elle comporte des opérateurs qui permettent de l'additionner ou de la soustraire dans le cadre des historiques. -class CForm -{ -public: - CFormHead head; - CFormBodyEltStruct body; - bool bmodified; - - CForm(); - CForm( const CForm& _f ); - virtual ~CForm(); - - void serial( NLMISC::IStream& s ); - - CStringEx GetDate() const; - CStringEx GetVersion() const; - CStringEx GetUser() const; - CStringEx GetComment() const; - void SetDate( const CStringEx _sxdate ); - void SetVersion( const CStringEx _sxversion ); - void SetUser( const CStringEx _sxuser ); - void SetComment( const CStringEx _sxcomment ); - - - CStringEx GetParent( unsigned int _index ) const; - CStringEx GetActivity( unsigned int _index ) const; - CFormBodyElt* GetElt( const CStringEx _sxname ) const; - CFormBodyEltStruct* GetBody() const; - bool GetModified() const; - void SetModified( const bool _b ); - - CForm& operator =( const CForm& _f ); - CForm& operator +=( const CForm& _f ); - CForm& operator -=( const CForm& _f ); - bool operator ==( const CForm& _f ) const; -}; - -} // NLGEORGES - -#endif // NLGEORGES_FORM_H - +// 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 NLGEORGES_FORM_H +#define NLGEORGES_FORM_H + +#include "nel/misc/stream.h" +#include "form_head.h" +#include "form_body_elt_struct.h" + +namespace NLOLDGEORGES +{ + +class CFormBodyElt; + +// La classe CForm représente une fiche. +// Elle comprend Head et Body. +// Elle comporte des opérateurs qui permettent de l'additionner ou de la soustraire dans le cadre des historiques. +class CForm +{ +public: + CFormHead head; + CFormBodyEltStruct body; + bool bmodified; + + CForm(); + CForm( const CForm& _f ); + virtual ~CForm(); + + void serial( NLMISC::IStream& s ); + + CStringEx GetDate() const; + CStringEx GetVersion() const; + CStringEx GetUser() const; + CStringEx GetComment() const; + void SetDate( const CStringEx _sxdate ); + void SetVersion( const CStringEx _sxversion ); + void SetUser( const CStringEx _sxuser ); + void SetComment( const CStringEx _sxcomment ); + + + CStringEx GetParent( unsigned int _index ) const; + CStringEx GetActivity( unsigned int _index ) const; + CFormBodyElt* GetElt( const CStringEx _sxname ) const; + CFormBodyEltStruct* GetBody() const; + bool GetModified() const; + void SetModified( const bool _b ); + + CForm& operator =( const CForm& _f ); + CForm& operator +=( const CForm& _f ); + CForm& operator -=( const CForm& _f ); + bool operator ==( const CForm& _f ) const; +}; + +} // NLGEORGES + +#endif // NLGEORGES_FORM_H + diff --git a/code/ryzom/tools/leveldesign/georges_convert/form_body_elt.cpp b/code/ryzom/tools/leveldesign/georges_convert/form_body_elt.cpp index 88b82e1bb..f8c4c1c95 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/form_body_elt.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/form_body_elt.cpp @@ -1,99 +1,99 @@ -// 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 "stdgeorgesconvert.h" -#include "form_body_elt.h" - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CFormBodyElt::CFormBodyElt() -{ -} - -CFormBodyElt::CFormBodyElt( const CFormBodyElt& _fbe ) -{ -} - -CFormBodyElt::~CFormBodyElt() -{ -} - -void CFormBodyElt::serial( NLMISC::IStream& s) -{ -} - -CFormBodyElt& CFormBodyElt::operator =( const CFormBodyElt& _fbe ) -{ - return( *this ); -} - -CFormBodyElt& CFormBodyElt::operator +=( const CFormBodyElt& _fbe ) -{ - return( *this ); -} - -CFormBodyElt& CFormBodyElt::operator -=( const CFormBodyElt& _fbe ) -{ - return( *this ); -} - -bool CFormBodyElt::operator ==( const CFormBodyElt& _fbe ) const -{ - return( false ); -} - -CFormBodyElt* CFormBodyElt::Clone() const -{ - return( new CFormBodyElt( *this ) ); -} - -CStringEx CFormBodyElt::GetName() const -{ - return( sxname ); -} - -void CFormBodyElt::SetName( const CStringEx _sxname ) -{ - sxname = _sxname; -} - -bool CFormBodyElt::Empty() const -{ - return( false ); -} - -CStringEx CFormBodyElt::GetValue() const -{ - CStringEx object; - return( object ); -} - -CFormBodyElt* CFormBodyElt::GetElt( const unsigned int _index ) const -{ - return( 0 ); -} - -CFormBodyElt* CFormBodyElt::GetElt( const CStringEx _sxname ) const -{ - return( 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 "stdgeorgesconvert.h" +#include "form_body_elt.h" + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CFormBodyElt::CFormBodyElt() +{ +} + +CFormBodyElt::CFormBodyElt( const CFormBodyElt& _fbe ) +{ +} + +CFormBodyElt::~CFormBodyElt() +{ +} + +void CFormBodyElt::serial( NLMISC::IStream& s) +{ +} + +CFormBodyElt& CFormBodyElt::operator =( const CFormBodyElt& _fbe ) +{ + return( *this ); +} + +CFormBodyElt& CFormBodyElt::operator +=( const CFormBodyElt& _fbe ) +{ + return( *this ); +} + +CFormBodyElt& CFormBodyElt::operator -=( const CFormBodyElt& _fbe ) +{ + return( *this ); +} + +bool CFormBodyElt::operator ==( const CFormBodyElt& _fbe ) const +{ + return( false ); +} + +CFormBodyElt* CFormBodyElt::Clone() const +{ + return( new CFormBodyElt( *this ) ); +} + +CStringEx CFormBodyElt::GetName() const +{ + return( sxname ); +} + +void CFormBodyElt::SetName( const CStringEx _sxname ) +{ + sxname = _sxname; +} + +bool CFormBodyElt::Empty() const +{ + return( false ); +} + +CStringEx CFormBodyElt::GetValue() const +{ + CStringEx object; + return( object ); +} + +CFormBodyElt* CFormBodyElt::GetElt( const unsigned int _index ) const +{ + return( 0 ); +} + +CFormBodyElt* CFormBodyElt::GetElt( const CStringEx _sxname ) const +{ + return( 0 ); +} + +} diff --git a/code/ryzom/tools/leveldesign/georges_convert/form_body_elt.h b/code/ryzom/tools/leveldesign/georges_convert/form_body_elt.h index c9505daaa..63ce1d7a9 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/form_body_elt.h +++ b/code/ryzom/tools/leveldesign/georges_convert/form_body_elt.h @@ -1,57 +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 NLGEORGES_FORM_BODY_ELT_H -#define NLGEORGES_FORM_BODY_ELT_H - -#include "nel/misc/stream.h" -#include "string_ex.h" - -namespace NLOLDGEORGES -{ - -// La classe CFormBodyElt est la classe de base pour le polymorphisme des CFormBodyEltAtom, CFormBodyEltList, CFormBodyEltStruct -// Elle comprend le nom de la branche ou de la feuille. -class CFormBodyElt : public NLMISC::IStreamable -{ -public: - CStringEx sxname; - - NLMISC_DECLARE_CLASS( CFormBodyElt ); - CFormBodyElt(); - CFormBodyElt( const CFormBodyElt& _fbe ); - virtual ~CFormBodyElt(); - virtual void serial( NLMISC::IStream& s ); - - virtual CFormBodyElt& operator =( const CFormBodyElt& _fbe ); - virtual CFormBodyElt& operator +=( const CFormBodyElt& _fbe ); - virtual CFormBodyElt& operator -=( const CFormBodyElt& _fbe ); - virtual bool operator ==( const CFormBodyElt& _fbe ) const; - - virtual CFormBodyElt* Clone() const; - virtual bool Empty() const; - - CStringEx GetName() const; - virtual CStringEx GetValue() const; - virtual CFormBodyElt* GetElt( const unsigned int _index ) const; - virtual CFormBodyElt* GetElt( const CStringEx _sxname ) const; - - void SetName( const CStringEx _sxname ); -}; - -} // NLGEORGES - -#endif // NLGEORGES_FORM_BODY_ELT_H +// 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 NLGEORGES_FORM_BODY_ELT_H +#define NLGEORGES_FORM_BODY_ELT_H + +#include "nel/misc/stream.h" +#include "string_ex.h" + +namespace NLOLDGEORGES +{ + +// La classe CFormBodyElt est la classe de base pour le polymorphisme des CFormBodyEltAtom, CFormBodyEltList, CFormBodyEltStruct +// Elle comprend le nom de la branche ou de la feuille. +class CFormBodyElt : public NLMISC::IStreamable +{ +public: + CStringEx sxname; + + NLMISC_DECLARE_CLASS( CFormBodyElt ); + CFormBodyElt(); + CFormBodyElt( const CFormBodyElt& _fbe ); + virtual ~CFormBodyElt(); + virtual void serial( NLMISC::IStream& s ); + + virtual CFormBodyElt& operator =( const CFormBodyElt& _fbe ); + virtual CFormBodyElt& operator +=( const CFormBodyElt& _fbe ); + virtual CFormBodyElt& operator -=( const CFormBodyElt& _fbe ); + virtual bool operator ==( const CFormBodyElt& _fbe ) const; + + virtual CFormBodyElt* Clone() const; + virtual bool Empty() const; + + CStringEx GetName() const; + virtual CStringEx GetValue() const; + virtual CFormBodyElt* GetElt( const unsigned int _index ) const; + virtual CFormBodyElt* GetElt( const CStringEx _sxname ) const; + + void SetName( const CStringEx _sxname ); +}; + +} // NLGEORGES + +#endif // NLGEORGES_FORM_BODY_ELT_H diff --git a/code/ryzom/tools/leveldesign/georges_convert/form_body_elt_atom.cpp b/code/ryzom/tools/leveldesign/georges_convert/form_body_elt_atom.cpp index 5a5df2b12..a2ef24414 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/form_body_elt_atom.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/form_body_elt_atom.cpp @@ -1,106 +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 . - -#include "stdgeorgesconvert.h" -#include "form_body_elt_atom.h" - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CFormBodyEltAtom::CFormBodyEltAtom() -{ -} - -CFormBodyEltAtom::CFormBodyEltAtom( const CFormBodyEltAtom& _fbea ) : CFormBodyElt( _fbea ) -{ - sxname = _fbea.sxname; - sxvalue = _fbea.sxvalue; -} - -CFormBodyEltAtom::~CFormBodyEltAtom() -{ -} - -void CFormBodyEltAtom::serial( NLMISC::IStream& s) -{ - - s.xmlPushBegin( "Atom" ); - s.xmlSetAttrib( "Name" ); - s.serial( sxname ); - s.xmlSetAttrib( "Value" ); - s.serial( sxvalue ); - s.xmlPushEnd(); - s.xmlPop(); -} - -CFormBodyElt& CFormBodyEltAtom::operator =( const CFormBodyElt& _fbe ) -{ - const CFormBodyEltAtom* pfbea = dynamic_cast< const CFormBodyEltAtom* >( &_fbe ); - nlassert( pfbea ); - sxname = pfbea->sxname; - sxvalue = pfbea->sxvalue; - return( *this ); -} - -CFormBodyElt& CFormBodyEltAtom::operator +=( const CFormBodyElt& _fbe ) -{ - const CFormBodyEltAtom* pfbea = dynamic_cast< const CFormBodyEltAtom* >( &_fbe ); - nlassert( pfbea ); - sxvalue = pfbea->sxvalue; - return( *this ); -} - -CFormBodyElt& CFormBodyEltAtom::operator -=( const CFormBodyElt& _fbe ) -{ - const CFormBodyEltAtom* pfbea = dynamic_cast< const CFormBodyEltAtom* >( &_fbe ); - nlassert( pfbea ); - if( sxvalue == pfbea->sxvalue ) - sxvalue.erase(); - return( *this ); -} - -bool CFormBodyEltAtom::operator ==( const CFormBodyElt& _fbe ) const -{ - const CFormBodyEltAtom* pfbea = dynamic_cast< const CFormBodyEltAtom* >( &_fbe ); - nlassert( pfbea ); - return( sxvalue == pfbea->sxvalue ); -} - -CFormBodyElt* CFormBodyEltAtom::Clone() const -{ - return( new CFormBodyEltAtom( *this ) ); -} - -bool CFormBodyEltAtom::Empty() const -{ - return( sxvalue.empty() ); -} - -CStringEx CFormBodyEltAtom::GetValue() const -{ - return( sxvalue ); -} - -void CFormBodyEltAtom::SetValue( const CStringEx _sxvalue ) -{ - sxvalue = _sxvalue; -} - +// 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 "stdgeorgesconvert.h" +#include "form_body_elt_atom.h" + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CFormBodyEltAtom::CFormBodyEltAtom() +{ +} + +CFormBodyEltAtom::CFormBodyEltAtom( const CFormBodyEltAtom& _fbea ) : CFormBodyElt( _fbea ) +{ + sxname = _fbea.sxname; + sxvalue = _fbea.sxvalue; +} + +CFormBodyEltAtom::~CFormBodyEltAtom() +{ +} + +void CFormBodyEltAtom::serial( NLMISC::IStream& s) +{ + + s.xmlPushBegin( "Atom" ); + s.xmlSetAttrib( "Name" ); + s.serial( sxname ); + s.xmlSetAttrib( "Value" ); + s.serial( sxvalue ); + s.xmlPushEnd(); + s.xmlPop(); +} + +CFormBodyElt& CFormBodyEltAtom::operator =( const CFormBodyElt& _fbe ) +{ + const CFormBodyEltAtom* pfbea = dynamic_cast< const CFormBodyEltAtom* >( &_fbe ); + nlassert( pfbea ); + sxname = pfbea->sxname; + sxvalue = pfbea->sxvalue; + return( *this ); +} + +CFormBodyElt& CFormBodyEltAtom::operator +=( const CFormBodyElt& _fbe ) +{ + const CFormBodyEltAtom* pfbea = dynamic_cast< const CFormBodyEltAtom* >( &_fbe ); + nlassert( pfbea ); + sxvalue = pfbea->sxvalue; + return( *this ); +} + +CFormBodyElt& CFormBodyEltAtom::operator -=( const CFormBodyElt& _fbe ) +{ + const CFormBodyEltAtom* pfbea = dynamic_cast< const CFormBodyEltAtom* >( &_fbe ); + nlassert( pfbea ); + if( sxvalue == pfbea->sxvalue ) + sxvalue.erase(); + return( *this ); +} + +bool CFormBodyEltAtom::operator ==( const CFormBodyElt& _fbe ) const +{ + const CFormBodyEltAtom* pfbea = dynamic_cast< const CFormBodyEltAtom* >( &_fbe ); + nlassert( pfbea ); + return( sxvalue == pfbea->sxvalue ); +} + +CFormBodyElt* CFormBodyEltAtom::Clone() const +{ + return( new CFormBodyEltAtom( *this ) ); +} + +bool CFormBodyEltAtom::Empty() const +{ + return( sxvalue.empty() ); +} + +CStringEx CFormBodyEltAtom::GetValue() const +{ + return( sxvalue ); +} + +void CFormBodyEltAtom::SetValue( const CStringEx _sxvalue ) +{ + sxvalue = _sxvalue; +} + } \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_convert/form_body_elt_atom.h b/code/ryzom/tools/leveldesign/georges_convert/form_body_elt_atom.h index e2bf5ecf3..65c24273a 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/form_body_elt_atom.h +++ b/code/ryzom/tools/leveldesign/georges_convert/form_body_elt_atom.h @@ -1,55 +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 NLGEORGES_FORM_BODY_ELT_ATOM_H -#define NLGEORGES_FORM_BODY_ELT_ATOM_H - -#include "nel/misc/stream.h" -#include "string_ex.h" -#include "form_body_elt.h" - -namespace NLOLDGEORGES -{ - - -// La classe CFormBodyEltAtom représente l'élément terminal de l'arbre. -// Il est composé de deux string: sxname et sxvalue -class CFormBodyEltAtom : public CFormBodyElt -{ -public: - CStringEx sxvalue; - - NLMISC_DECLARE_CLASS( CFormBodyEltAtom ); - CFormBodyEltAtom(); - CFormBodyEltAtom( const CFormBodyEltAtom& _fbea ); - virtual ~CFormBodyEltAtom(); - virtual void serial( NLMISC::IStream& s ); - - virtual CFormBodyElt& operator =( const CFormBodyElt& _fbe ); - virtual CFormBodyElt& operator +=( const CFormBodyElt& _fbe ); - virtual CFormBodyElt& operator -=( const CFormBodyElt& _fbe ); - virtual bool operator ==( const CFormBodyElt& _fbe ) const; - - virtual CFormBodyElt* Clone() const; - virtual bool Empty() const; - virtual CStringEx GetValue() const; - - void SetValue( const CStringEx _sxvalue ); -}; - -} // NLGEORGES - -#endif // NLGEORGES_FORM_BODY_ELT_ATOM_H +// 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 NLGEORGES_FORM_BODY_ELT_ATOM_H +#define NLGEORGES_FORM_BODY_ELT_ATOM_H + +#include "nel/misc/stream.h" +#include "string_ex.h" +#include "form_body_elt.h" + +namespace NLOLDGEORGES +{ + + +// La classe CFormBodyEltAtom représente l'élément terminal de l'arbre. +// Il est composé de deux string: sxname et sxvalue +class CFormBodyEltAtom : public CFormBodyElt +{ +public: + CStringEx sxvalue; + + NLMISC_DECLARE_CLASS( CFormBodyEltAtom ); + CFormBodyEltAtom(); + CFormBodyEltAtom( const CFormBodyEltAtom& _fbea ); + virtual ~CFormBodyEltAtom(); + virtual void serial( NLMISC::IStream& s ); + + virtual CFormBodyElt& operator =( const CFormBodyElt& _fbe ); + virtual CFormBodyElt& operator +=( const CFormBodyElt& _fbe ); + virtual CFormBodyElt& operator -=( const CFormBodyElt& _fbe ); + virtual bool operator ==( const CFormBodyElt& _fbe ) const; + + virtual CFormBodyElt* Clone() const; + virtual bool Empty() const; + virtual CStringEx GetValue() const; + + void SetValue( const CStringEx _sxvalue ); +}; + +} // NLGEORGES + +#endif // NLGEORGES_FORM_BODY_ELT_ATOM_H diff --git a/code/ryzom/tools/leveldesign/georges_convert/form_body_elt_list.cpp b/code/ryzom/tools/leveldesign/georges_convert/form_body_elt_list.cpp index ca6e06276..c3a959284 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/form_body_elt_list.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/form_body_elt_list.cpp @@ -1,153 +1,153 @@ -// 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 "stdgeorgesconvert.h" -#include "form_body_elt_list.h" - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CFormBodyEltList::CFormBodyEltList() -{ -} - -CFormBodyEltList::CFormBodyEltList( const CFormBodyEltList& _fbel ) -{ - sxname = _fbel.sxname; - for( std::vector< CFormBodyElt* >::const_iterator it = _fbel.vpbodyelt.begin(); it != _fbel.vpbodyelt.end(); ++it ) - vpbodyelt.push_back( (*it)->Clone() ); -} - -CFormBodyEltList::~CFormBodyEltList() -{ - Clear(); -} - -void CFormBodyEltList::Clear() -{ - for( std::vector< CFormBodyElt* >::iterator it = vpbodyelt.begin(); it != vpbodyelt.end(); ++it ) - if( *it ) - delete *it; - vpbodyelt.clear(); -} - -void CFormBodyEltList::serial( NLMISC::IStream& s) -{ - - s.xmlPushBegin( "List" ); - s.xmlSetAttrib( "Name" ); - s.serial( sxname ); - s.xmlPushEnd(); - s.serialContPolyPtr( vpbodyelt ); - s.xmlPop(); -} - -std::vector< CFormBodyElt* >::iterator CFormBodyEltList::Find( const CStringEx _sxname ) -{ - std::vector< CFormBodyElt* >::iterator it; - for( it = vpbodyelt.begin(); it != vpbodyelt.end(); ++it ) - if( (*it)->GetName() == _sxname ) - return it; - return it; -} - -std::vector< CFormBodyElt* >::const_iterator CFormBodyEltList::Find( const CStringEx _sxname ) const -{ - std::vector< CFormBodyElt* >::const_iterator it; - for( it = vpbodyelt.begin(); it != vpbodyelt.end(); ++it ) - if( (*it)->GetName() == _sxname ) - return it; - return it; -} - -CFormBodyElt& CFormBodyEltList::operator =( const CFormBodyElt& _fbe ) -{ - const CFormBodyEltList* pfbel = dynamic_cast< const CFormBodyEltList* >( &_fbe ); - nlassert( pfbel ); - sxname = pfbel->sxname; - return( *this ); -} - -CFormBodyElt& CFormBodyEltList::operator +=( const CFormBodyElt& _fbe ) -{ - const CFormBodyEltList* pfbel = dynamic_cast< const CFormBodyEltList* >( &_fbe ); - nlassert( pfbel ); - Clear(); - for( std::vector< CFormBodyElt* >::const_iterator it = pfbel->vpbodyelt.begin(); it != pfbel->vpbodyelt.end(); ++it ) - vpbodyelt.push_back( (*it)->Clone() ); - return( *this ); -} - -CFormBodyElt& CFormBodyEltList::operator -=( const CFormBodyElt& _fbe ) -{ - const CFormBodyEltList* pfbel = dynamic_cast< const CFormBodyEltList* >( &_fbe ); - nlassert( pfbel ); - if( *this == *pfbel ) - Clear(); - return( *this ); -} - -bool CFormBodyEltList::operator ==( const CFormBodyElt& _fbe ) const -{ - const CFormBodyEltList* pfbel = dynamic_cast< const CFormBodyEltList* >( &_fbe ); - nlassert( pfbel ); - if( vpbodyelt.size() != pfbel->vpbodyelt.size() ) - return( false ); - std::vector< CFormBodyElt* >::const_iterator it = pfbel->vpbodyelt.begin(); - std::vector< CFormBodyElt* >::const_iterator iu = vpbodyelt.begin(); - while( iu != vpbodyelt.end() ) - if( !(**iu++ == **it++) ) - return false; - return( true ); -} - -CFormBodyElt* CFormBodyEltList::Clone() const -{ - return( new CFormBodyEltList( *this ) ); -} - -bool CFormBodyEltList::Empty() const -{ - return( vpbodyelt.empty() ); -} - -CFormBodyElt* CFormBodyEltList::GetElt( const unsigned int _index ) const -{ - if( _index >= vpbodyelt.size() ) - return( 0 ); - return( vpbodyelt[_index] ); -} - -CFormBodyElt* CFormBodyEltList::GetElt( const CStringEx _sxname ) const -{ - std::vector< CFormBodyElt* >::const_iterator it = Find( _sxname ); - if( it == vpbodyelt.end() ) - return( 0 ); - return( *it ); -} - -void CFormBodyEltList::AddElt( CFormBodyElt* const pfbe ) -{ - if( !pfbe ) - return; - vpbodyelt.push_back( pfbe ); -} - -} +// 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 "stdgeorgesconvert.h" +#include "form_body_elt_list.h" + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CFormBodyEltList::CFormBodyEltList() +{ +} + +CFormBodyEltList::CFormBodyEltList( const CFormBodyEltList& _fbel ) +{ + sxname = _fbel.sxname; + for( std::vector< CFormBodyElt* >::const_iterator it = _fbel.vpbodyelt.begin(); it != _fbel.vpbodyelt.end(); ++it ) + vpbodyelt.push_back( (*it)->Clone() ); +} + +CFormBodyEltList::~CFormBodyEltList() +{ + Clear(); +} + +void CFormBodyEltList::Clear() +{ + for( std::vector< CFormBodyElt* >::iterator it = vpbodyelt.begin(); it != vpbodyelt.end(); ++it ) + if( *it ) + delete *it; + vpbodyelt.clear(); +} + +void CFormBodyEltList::serial( NLMISC::IStream& s) +{ + + s.xmlPushBegin( "List" ); + s.xmlSetAttrib( "Name" ); + s.serial( sxname ); + s.xmlPushEnd(); + s.serialContPolyPtr( vpbodyelt ); + s.xmlPop(); +} + +std::vector< CFormBodyElt* >::iterator CFormBodyEltList::Find( const CStringEx _sxname ) +{ + std::vector< CFormBodyElt* >::iterator it; + for( it = vpbodyelt.begin(); it != vpbodyelt.end(); ++it ) + if( (*it)->GetName() == _sxname ) + return it; + return it; +} + +std::vector< CFormBodyElt* >::const_iterator CFormBodyEltList::Find( const CStringEx _sxname ) const +{ + std::vector< CFormBodyElt* >::const_iterator it; + for( it = vpbodyelt.begin(); it != vpbodyelt.end(); ++it ) + if( (*it)->GetName() == _sxname ) + return it; + return it; +} + +CFormBodyElt& CFormBodyEltList::operator =( const CFormBodyElt& _fbe ) +{ + const CFormBodyEltList* pfbel = dynamic_cast< const CFormBodyEltList* >( &_fbe ); + nlassert( pfbel ); + sxname = pfbel->sxname; + return( *this ); +} + +CFormBodyElt& CFormBodyEltList::operator +=( const CFormBodyElt& _fbe ) +{ + const CFormBodyEltList* pfbel = dynamic_cast< const CFormBodyEltList* >( &_fbe ); + nlassert( pfbel ); + Clear(); + for( std::vector< CFormBodyElt* >::const_iterator it = pfbel->vpbodyelt.begin(); it != pfbel->vpbodyelt.end(); ++it ) + vpbodyelt.push_back( (*it)->Clone() ); + return( *this ); +} + +CFormBodyElt& CFormBodyEltList::operator -=( const CFormBodyElt& _fbe ) +{ + const CFormBodyEltList* pfbel = dynamic_cast< const CFormBodyEltList* >( &_fbe ); + nlassert( pfbel ); + if( *this == *pfbel ) + Clear(); + return( *this ); +} + +bool CFormBodyEltList::operator ==( const CFormBodyElt& _fbe ) const +{ + const CFormBodyEltList* pfbel = dynamic_cast< const CFormBodyEltList* >( &_fbe ); + nlassert( pfbel ); + if( vpbodyelt.size() != pfbel->vpbodyelt.size() ) + return( false ); + std::vector< CFormBodyElt* >::const_iterator it = pfbel->vpbodyelt.begin(); + std::vector< CFormBodyElt* >::const_iterator iu = vpbodyelt.begin(); + while( iu != vpbodyelt.end() ) + if( !(**iu++ == **it++) ) + return false; + return( true ); +} + +CFormBodyElt* CFormBodyEltList::Clone() const +{ + return( new CFormBodyEltList( *this ) ); +} + +bool CFormBodyEltList::Empty() const +{ + return( vpbodyelt.empty() ); +} + +CFormBodyElt* CFormBodyEltList::GetElt( const unsigned int _index ) const +{ + if( _index >= vpbodyelt.size() ) + return( 0 ); + return( vpbodyelt[_index] ); +} + +CFormBodyElt* CFormBodyEltList::GetElt( const CStringEx _sxname ) const +{ + std::vector< CFormBodyElt* >::const_iterator it = Find( _sxname ); + if( it == vpbodyelt.end() ) + return( 0 ); + return( *it ); +} + +void CFormBodyEltList::AddElt( CFormBodyElt* const pfbe ) +{ + if( !pfbe ) + return; + vpbodyelt.push_back( pfbe ); +} + +} diff --git a/code/ryzom/tools/leveldesign/georges_convert/form_body_elt_list.h b/code/ryzom/tools/leveldesign/georges_convert/form_body_elt_list.h index b5de064d6..cc96ecab4 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/form_body_elt_list.h +++ b/code/ryzom/tools/leveldesign/georges_convert/form_body_elt_list.h @@ -1,60 +1,60 @@ -// 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 NLGEORGES_FORM_BODY_ELT_LIST_H -#define NLGEORGES_FORM_BODY_ELT_LIST_H - - -#include "nel/misc/stream.h" -#include "form_body_elt.h" - -namespace NLOLDGEORGES -{ - - -// La classe CFormBodyEltList permet d'obtenir un ensemble de CFormBodyElt sous forme de liste. -// Dans l'opérateur +=, l'ensemble des anciens éléments sont éliminés. Les nouveaux les remplacent. -class CFormBodyEltList : public CFormBodyElt -{ -public: - std::vector< CFormBodyElt* > vpbodyelt; - std::vector< CFormBodyElt* >::iterator Find( const CStringEx _sxname ); - std::vector< CFormBodyElt* >::const_iterator Find( const CStringEx _sxname ) const; - - NLMISC_DECLARE_CLASS( CFormBodyEltList ); - CFormBodyEltList(); - CFormBodyEltList( const CFormBodyEltList& _fbel ); - virtual ~CFormBodyEltList(); - virtual void serial( NLMISC::IStream& s ); - - virtual CFormBodyElt& operator =( const CFormBodyElt& _fbe ); - virtual CFormBodyElt& operator +=( const CFormBodyElt& _fbe ); - virtual CFormBodyElt& operator -=( const CFormBodyElt& _fbe ); - virtual bool operator ==( const CFormBodyElt& _fbe ) const; - - virtual CFormBodyElt* Clone() const; - virtual bool Empty() const; - virtual CFormBodyElt* GetElt( const unsigned int _index ) const; - virtual CFormBodyElt* GetElt( const CStringEx _sxname ) const; - - void AddElt( CFormBodyElt* const pfbe ); - void Clear(); -}; - -} // NLGEORGES - -#endif // NLGEORGES_FORM_BODY_ELT_LIST_H - +// 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 NLGEORGES_FORM_BODY_ELT_LIST_H +#define NLGEORGES_FORM_BODY_ELT_LIST_H + + +#include "nel/misc/stream.h" +#include "form_body_elt.h" + +namespace NLOLDGEORGES +{ + + +// La classe CFormBodyEltList permet d'obtenir un ensemble de CFormBodyElt sous forme de liste. +// Dans l'opérateur +=, l'ensemble des anciens éléments sont éliminés. Les nouveaux les remplacent. +class CFormBodyEltList : public CFormBodyElt +{ +public: + std::vector< CFormBodyElt* > vpbodyelt; + std::vector< CFormBodyElt* >::iterator Find( const CStringEx _sxname ); + std::vector< CFormBodyElt* >::const_iterator Find( const CStringEx _sxname ) const; + + NLMISC_DECLARE_CLASS( CFormBodyEltList ); + CFormBodyEltList(); + CFormBodyEltList( const CFormBodyEltList& _fbel ); + virtual ~CFormBodyEltList(); + virtual void serial( NLMISC::IStream& s ); + + virtual CFormBodyElt& operator =( const CFormBodyElt& _fbe ); + virtual CFormBodyElt& operator +=( const CFormBodyElt& _fbe ); + virtual CFormBodyElt& operator -=( const CFormBodyElt& _fbe ); + virtual bool operator ==( const CFormBodyElt& _fbe ) const; + + virtual CFormBodyElt* Clone() const; + virtual bool Empty() const; + virtual CFormBodyElt* GetElt( const unsigned int _index ) const; + virtual CFormBodyElt* GetElt( const CStringEx _sxname ) const; + + void AddElt( CFormBodyElt* const pfbe ); + void Clear(); +}; + +} // NLGEORGES + +#endif // NLGEORGES_FORM_BODY_ELT_LIST_H + diff --git a/code/ryzom/tools/leveldesign/georges_convert/form_body_elt_struct.cpp b/code/ryzom/tools/leveldesign/georges_convert/form_body_elt_struct.cpp index 98032bf9b..3dd9c76bd 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/form_body_elt_struct.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/form_body_elt_struct.cpp @@ -1,285 +1,285 @@ -// 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 "stdgeorgesconvert.h" -#include "form_body_elt_struct.h" -#include "form_body_elt_list.h" -#include "form_body_elt_atom.h" - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CFormBodyEltStruct::CFormBodyEltStruct() -{ -} - -CFormBodyEltStruct::CFormBodyEltStruct( const CFormBodyEltStruct& _fbes ) -{ - sxname = _fbes.sxname; - for( std::vector< CFormBodyElt* >::const_iterator it = _fbes.vpbodyelt.begin(); it != _fbes.vpbodyelt.end(); ++it ) - vpbodyelt.push_back( (*it)->Clone() ); -} - -CFormBodyEltStruct::~CFormBodyEltStruct() -{ - Clear(); -} - -void CFormBodyEltStruct::Clear() -{ - for( std::vector< CFormBodyElt* >::iterator it = vpbodyelt.begin(); it != vpbodyelt.end(); ++it ) - if( *it ) - delete *it; - vpbodyelt.clear(); -} - -void CFormBodyEltStruct::serial( NLMISC::IStream& s) -{ - s.xmlPushBegin( "Body" ); - s.xmlSetAttrib( "Name" ); - s.serial( sxname ); - s.xmlPushEnd(); - s.serialContPolyPtr( vpbodyelt ); - s.xmlPop(); -} - -std::vector< CFormBodyElt* >::iterator CFormBodyEltStruct::Find( const CStringEx _sxname ) -{ - std::vector< CFormBodyElt* >::iterator it; - for( it = vpbodyelt.begin(); it != vpbodyelt.end(); ++it ) - if( (*it)->GetName() == _sxname ) - return it; - return it; -} - -std::vector< CFormBodyElt* >::const_iterator CFormBodyEltStruct::Find( const CStringEx _sxname ) const -{ - std::vector< CFormBodyElt* >::const_iterator it; - for( it = vpbodyelt.begin(); it != vpbodyelt.end(); ++it ) - if( (*it)->GetName() == _sxname ) - return it; - return it; -} - -CFormBodyElt& CFormBodyEltStruct::operator =( const CFormBodyElt& _fbe ) -{ - const CFormBodyEltStruct* pfbes = dynamic_cast< const CFormBodyEltStruct* >( &_fbe ); - nlassert( pfbes ); - Clear(); - sxname = pfbes->sxname; - for( std::vector< CFormBodyElt* >::const_iterator it = pfbes->vpbodyelt.begin(); it != pfbes->vpbodyelt.end(); ++it ) - vpbodyelt.push_back( (*it)->Clone() ); - return( *this ); -} - -CFormBodyElt& CFormBodyEltStruct::operator =( const CFormBodyEltStruct& _fbes ) -{ - Clear(); - sxname = _fbes.sxname; - for( std::vector< CFormBodyElt* >::const_iterator it = _fbes.vpbodyelt.begin(); it != _fbes.vpbodyelt.end(); ++it ) - vpbodyelt.push_back( (*it)->Clone() ); - return( *this ); -} - -CFormBodyElt& CFormBodyEltStruct::operator +=( const CFormBodyElt& _fbe ) -{ - const CFormBodyEltStruct* pfbes = dynamic_cast< const CFormBodyEltStruct* >( &_fbe ); - nlassert( pfbes ); - for( std::vector< CFormBodyElt* >::const_iterator it = pfbes->vpbodyelt.begin(); it != pfbes->vpbodyelt.end(); ++it ) - { - std::vector< CFormBodyElt* >::iterator iu = Find( (*it)->GetName() ); - if( iu == vpbodyelt.end() ) - { - vpbodyelt.push_back( (*it)->Clone() ); - iu = vpbodyelt.end(); - --iu; - } - **iu += **it; - } - return( *this ); -} - -CFormBodyElt& CFormBodyEltStruct::operator -=( const CFormBodyElt& _fbe ) -{ - const CFormBodyEltStruct* pfbes = dynamic_cast< const CFormBodyEltStruct* >( &_fbe ); - nlassert( pfbes ); - for( std::vector< CFormBodyElt* >::const_iterator it = pfbes->vpbodyelt.begin(); it != pfbes->vpbodyelt.end(); ++it ) - { - std::vector< CFormBodyElt* >::iterator iu = Find( (*it)->GetName() ); - if( iu == vpbodyelt.end() ) - continue; - **iu -= **it; - if( (*iu)->Empty() ) - { - delete( *iu ); - vpbodyelt.erase( iu ); - } - } - return( *this ); -} - -bool CFormBodyEltStruct::operator ==( const CFormBodyElt& _fbe ) const -{ - const CFormBodyEltStruct* pfbes = dynamic_cast< const CFormBodyEltStruct* >( &_fbe ); - nlassert( pfbes ); - if( vpbodyelt.size() != pfbes->vpbodyelt.size() ) - return( false ); - for( std::vector< CFormBodyElt* >::const_iterator it = pfbes->vpbodyelt.begin(); it != pfbes->vpbodyelt.end(); ++it ) - { - std::vector< CFormBodyElt* >::const_iterator iu = Find( (*it)->GetName() ); - if( ( iu == vpbodyelt.end() )||( !(**iu == **it) ) ) - return false; - } - return( true ); -} - -CFormBodyElt* CFormBodyEltStruct::Clone() const -{ - return( new CFormBodyEltStruct( *this ) ); -} - -bool CFormBodyEltStruct::Empty() const -{ - return( vpbodyelt.empty() ); -} - -uint32 CFormBodyEltStruct::GetNbElt () const -{ - return (uint32)vpbodyelt.size(); -} - -CFormBodyElt* CFormBodyEltStruct::GetElt( const unsigned int _index ) const -{ - if( _index >= vpbodyelt.size() ) - return( 0 ); - return( vpbodyelt[_index] ); -} - -CFormBodyElt* CFormBodyEltStruct::GetElt( const CStringEx _sxname ) const -{ - std::vector< CFormBodyElt* >::const_iterator it = Find( _sxname ); - if( it == vpbodyelt.end() ) - return( 0 ); - return( *it ); -} - -CStringEx CFormBodyEltStruct::GetComment() const -{ - std::vector< CFormBodyElt* >::const_iterator it = Find( SXCOMMENT ); - if( it == vpbodyelt.end() ) - { - CStringEx object; - return( object ); - } - const CFormBodyEltAtom* pfbea = dynamic_cast< CFormBodyEltAtom* >( *it ); - nlassert( pfbea ); - return pfbea->GetValue(); -} - -void CFormBodyEltStruct::SetComment( const CStringEx _sxcomment ) -{ - // todo -} - -CStringEx CFormBodyEltStruct::GetParent( unsigned int _index ) const -{ - std::vector< CFormBodyElt* >::const_iterator it = Find( SXPARENTS ); - if( it == vpbodyelt.end() ) - { - CStringEx object; - return( object ); - } - const CFormBodyEltList* pfbel = dynamic_cast< CFormBodyEltList* >( *it ); - if( !pfbel ) - { - CStringEx object; - return( object ); - } - const CFormBodyEltStruct* pfbes = dynamic_cast< CFormBodyEltStruct* >( pfbel->GetElt( _index ) ); - if( !pfbes ) - { - CStringEx object; - return( object ); - } -/* - - const CFormBodyEltAtom* pfbea = dynamic_cast< CFormBodyEltAtom* >( pfbes->GetElt( "Activity" ) ); - if( !pfbea ) - return( CStringEx() ); - CStringEx sxactivity = pfbea->GetValue(); - if( sxactivity != "true" ) - return( CStringEx(" ") ); -*/ - const CFormBodyEltAtom* pfbea = dynamic_cast< CFormBodyEltAtom* >( pfbes->GetElt( "Filename" ) ); -// pfbea = dynamic_cast< CFormBodyEltAtom* >( pfbes->GetElt( "Filename" ) ); - if( !pfbea ) - { - CStringEx object; - return( object ); - } - return pfbea->GetValue(); - -} - -CStringEx CFormBodyEltStruct::GetActivity( unsigned int _index ) const -{ - std::vector< CFormBodyElt* >::const_iterator it = Find( SXPARENTS ); - if( it == vpbodyelt.end() ) - { - CStringEx object; - return( object ); - } - const CFormBodyEltList* pfbel = dynamic_cast< CFormBodyEltList* >( *it ); - if( !pfbel ) - { - CStringEx object; - return( object ); - } - const CFormBodyEltStruct* pfbes = dynamic_cast< CFormBodyEltStruct* >( pfbel->GetElt( _index ) ); - if( !pfbes ) - { - CStringEx object; - return( object ); - } - const CFormBodyEltAtom* pfbea = dynamic_cast< CFormBodyEltAtom* >( pfbes->GetElt( "Activity" ) ); - if( !pfbea ) - { - CStringEx object; - return( object ); - } -/* - CStringEx sxactivity = pfbea->GetValue(); - if( sxactivity != "true" ) - return( CStringEx(" ") ); - pfbea = dynamic_cast< CFormBodyEltAtom* >( pfbes->GetElt( "Filename" ) ); - if( !pfbea ) - return( CStringEx() ); -*/ - return pfbea->GetValue(); -} - -void CFormBodyEltStruct::AddElt( CFormBodyElt* const pfbe ) -{ - if( !pfbe ) - return; - vpbodyelt.push_back( pfbe ); -} - -} +// 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 "stdgeorgesconvert.h" +#include "form_body_elt_struct.h" +#include "form_body_elt_list.h" +#include "form_body_elt_atom.h" + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CFormBodyEltStruct::CFormBodyEltStruct() +{ +} + +CFormBodyEltStruct::CFormBodyEltStruct( const CFormBodyEltStruct& _fbes ) +{ + sxname = _fbes.sxname; + for( std::vector< CFormBodyElt* >::const_iterator it = _fbes.vpbodyelt.begin(); it != _fbes.vpbodyelt.end(); ++it ) + vpbodyelt.push_back( (*it)->Clone() ); +} + +CFormBodyEltStruct::~CFormBodyEltStruct() +{ + Clear(); +} + +void CFormBodyEltStruct::Clear() +{ + for( std::vector< CFormBodyElt* >::iterator it = vpbodyelt.begin(); it != vpbodyelt.end(); ++it ) + if( *it ) + delete *it; + vpbodyelt.clear(); +} + +void CFormBodyEltStruct::serial( NLMISC::IStream& s) +{ + s.xmlPushBegin( "Body" ); + s.xmlSetAttrib( "Name" ); + s.serial( sxname ); + s.xmlPushEnd(); + s.serialContPolyPtr( vpbodyelt ); + s.xmlPop(); +} + +std::vector< CFormBodyElt* >::iterator CFormBodyEltStruct::Find( const CStringEx _sxname ) +{ + std::vector< CFormBodyElt* >::iterator it; + for( it = vpbodyelt.begin(); it != vpbodyelt.end(); ++it ) + if( (*it)->GetName() == _sxname ) + return it; + return it; +} + +std::vector< CFormBodyElt* >::const_iterator CFormBodyEltStruct::Find( const CStringEx _sxname ) const +{ + std::vector< CFormBodyElt* >::const_iterator it; + for( it = vpbodyelt.begin(); it != vpbodyelt.end(); ++it ) + if( (*it)->GetName() == _sxname ) + return it; + return it; +} + +CFormBodyElt& CFormBodyEltStruct::operator =( const CFormBodyElt& _fbe ) +{ + const CFormBodyEltStruct* pfbes = dynamic_cast< const CFormBodyEltStruct* >( &_fbe ); + nlassert( pfbes ); + Clear(); + sxname = pfbes->sxname; + for( std::vector< CFormBodyElt* >::const_iterator it = pfbes->vpbodyelt.begin(); it != pfbes->vpbodyelt.end(); ++it ) + vpbodyelt.push_back( (*it)->Clone() ); + return( *this ); +} + +CFormBodyElt& CFormBodyEltStruct::operator =( const CFormBodyEltStruct& _fbes ) +{ + Clear(); + sxname = _fbes.sxname; + for( std::vector< CFormBodyElt* >::const_iterator it = _fbes.vpbodyelt.begin(); it != _fbes.vpbodyelt.end(); ++it ) + vpbodyelt.push_back( (*it)->Clone() ); + return( *this ); +} + +CFormBodyElt& CFormBodyEltStruct::operator +=( const CFormBodyElt& _fbe ) +{ + const CFormBodyEltStruct* pfbes = dynamic_cast< const CFormBodyEltStruct* >( &_fbe ); + nlassert( pfbes ); + for( std::vector< CFormBodyElt* >::const_iterator it = pfbes->vpbodyelt.begin(); it != pfbes->vpbodyelt.end(); ++it ) + { + std::vector< CFormBodyElt* >::iterator iu = Find( (*it)->GetName() ); + if( iu == vpbodyelt.end() ) + { + vpbodyelt.push_back( (*it)->Clone() ); + iu = vpbodyelt.end(); + --iu; + } + **iu += **it; + } + return( *this ); +} + +CFormBodyElt& CFormBodyEltStruct::operator -=( const CFormBodyElt& _fbe ) +{ + const CFormBodyEltStruct* pfbes = dynamic_cast< const CFormBodyEltStruct* >( &_fbe ); + nlassert( pfbes ); + for( std::vector< CFormBodyElt* >::const_iterator it = pfbes->vpbodyelt.begin(); it != pfbes->vpbodyelt.end(); ++it ) + { + std::vector< CFormBodyElt* >::iterator iu = Find( (*it)->GetName() ); + if( iu == vpbodyelt.end() ) + continue; + **iu -= **it; + if( (*iu)->Empty() ) + { + delete( *iu ); + vpbodyelt.erase( iu ); + } + } + return( *this ); +} + +bool CFormBodyEltStruct::operator ==( const CFormBodyElt& _fbe ) const +{ + const CFormBodyEltStruct* pfbes = dynamic_cast< const CFormBodyEltStruct* >( &_fbe ); + nlassert( pfbes ); + if( vpbodyelt.size() != pfbes->vpbodyelt.size() ) + return( false ); + for( std::vector< CFormBodyElt* >::const_iterator it = pfbes->vpbodyelt.begin(); it != pfbes->vpbodyelt.end(); ++it ) + { + std::vector< CFormBodyElt* >::const_iterator iu = Find( (*it)->GetName() ); + if( ( iu == vpbodyelt.end() )||( !(**iu == **it) ) ) + return false; + } + return( true ); +} + +CFormBodyElt* CFormBodyEltStruct::Clone() const +{ + return( new CFormBodyEltStruct( *this ) ); +} + +bool CFormBodyEltStruct::Empty() const +{ + return( vpbodyelt.empty() ); +} + +uint32 CFormBodyEltStruct::GetNbElt () const +{ + return (uint32)vpbodyelt.size(); +} + +CFormBodyElt* CFormBodyEltStruct::GetElt( const unsigned int _index ) const +{ + if( _index >= vpbodyelt.size() ) + return( 0 ); + return( vpbodyelt[_index] ); +} + +CFormBodyElt* CFormBodyEltStruct::GetElt( const CStringEx _sxname ) const +{ + std::vector< CFormBodyElt* >::const_iterator it = Find( _sxname ); + if( it == vpbodyelt.end() ) + return( 0 ); + return( *it ); +} + +CStringEx CFormBodyEltStruct::GetComment() const +{ + std::vector< CFormBodyElt* >::const_iterator it = Find( SXCOMMENT ); + if( it == vpbodyelt.end() ) + { + CStringEx object; + return( object ); + } + const CFormBodyEltAtom* pfbea = dynamic_cast< CFormBodyEltAtom* >( *it ); + nlassert( pfbea ); + return pfbea->GetValue(); +} + +void CFormBodyEltStruct::SetComment( const CStringEx _sxcomment ) +{ + // todo +} + +CStringEx CFormBodyEltStruct::GetParent( unsigned int _index ) const +{ + std::vector< CFormBodyElt* >::const_iterator it = Find( SXPARENTS ); + if( it == vpbodyelt.end() ) + { + CStringEx object; + return( object ); + } + const CFormBodyEltList* pfbel = dynamic_cast< CFormBodyEltList* >( *it ); + if( !pfbel ) + { + CStringEx object; + return( object ); + } + const CFormBodyEltStruct* pfbes = dynamic_cast< CFormBodyEltStruct* >( pfbel->GetElt( _index ) ); + if( !pfbes ) + { + CStringEx object; + return( object ); + } +/* + + const CFormBodyEltAtom* pfbea = dynamic_cast< CFormBodyEltAtom* >( pfbes->GetElt( "Activity" ) ); + if( !pfbea ) + return( CStringEx() ); + CStringEx sxactivity = pfbea->GetValue(); + if( sxactivity != "true" ) + return( CStringEx(" ") ); +*/ + const CFormBodyEltAtom* pfbea = dynamic_cast< CFormBodyEltAtom* >( pfbes->GetElt( "Filename" ) ); +// pfbea = dynamic_cast< CFormBodyEltAtom* >( pfbes->GetElt( "Filename" ) ); + if( !pfbea ) + { + CStringEx object; + return( object ); + } + return pfbea->GetValue(); + +} + +CStringEx CFormBodyEltStruct::GetActivity( unsigned int _index ) const +{ + std::vector< CFormBodyElt* >::const_iterator it = Find( SXPARENTS ); + if( it == vpbodyelt.end() ) + { + CStringEx object; + return( object ); + } + const CFormBodyEltList* pfbel = dynamic_cast< CFormBodyEltList* >( *it ); + if( !pfbel ) + { + CStringEx object; + return( object ); + } + const CFormBodyEltStruct* pfbes = dynamic_cast< CFormBodyEltStruct* >( pfbel->GetElt( _index ) ); + if( !pfbes ) + { + CStringEx object; + return( object ); + } + const CFormBodyEltAtom* pfbea = dynamic_cast< CFormBodyEltAtom* >( pfbes->GetElt( "Activity" ) ); + if( !pfbea ) + { + CStringEx object; + return( object ); + } +/* + CStringEx sxactivity = pfbea->GetValue(); + if( sxactivity != "true" ) + return( CStringEx(" ") ); + pfbea = dynamic_cast< CFormBodyEltAtom* >( pfbes->GetElt( "Filename" ) ); + if( !pfbea ) + return( CStringEx() ); +*/ + return pfbea->GetValue(); +} + +void CFormBodyEltStruct::AddElt( CFormBodyElt* const pfbe ) +{ + if( !pfbe ) + return; + vpbodyelt.push_back( pfbe ); +} + +} diff --git a/code/ryzom/tools/leveldesign/georges_convert/form_body_elt_struct.h b/code/ryzom/tools/leveldesign/georges_convert/form_body_elt_struct.h index 10c059bef..d661a36a0 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/form_body_elt_struct.h +++ b/code/ryzom/tools/leveldesign/georges_convert/form_body_elt_struct.h @@ -1,67 +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 NLGEORGES_FORM_BODY_ELT_STRUCT_H -#define NLGEORGES_FORM_BODY_ELT_STRUCT_H - -#include "nel/misc/stream.h" -#include "form_body_elt.h" - -namespace NLOLDGEORGES -{ - -#define SXCOMMENT "Comment" -#define SXPARENTS "Parents" - -// La classe CFormBodyEltStruct permet d'obtenir un ensemble de CFormBodyElt. -// Dans l'opérateur +=, les nouveaux élément remplacent les anciens, les anciens non-écrasés restent -class CFormBodyEltStruct : public CFormBodyElt -{ -public: - std::vector< CFormBodyElt* > vpbodyelt; - std::vector< CFormBodyElt* >::iterator Find( const CStringEx _sxname ); - std::vector< CFormBodyElt* >::const_iterator Find( const CStringEx _sxname ) const; - void Clear(); - - NLMISC_DECLARE_CLASS( CFormBodyEltStruct ); - CFormBodyEltStruct(); - CFormBodyEltStruct( const CFormBodyEltStruct& _fbes ); - virtual ~CFormBodyEltStruct(); - virtual void serial( NLMISC::IStream& s ); - - CFormBodyElt& operator =( const CFormBodyEltStruct& _fbes ); - virtual CFormBodyElt& operator =( const CFormBodyElt& _fbe ); - virtual CFormBodyElt& operator +=( const CFormBodyElt& _fbe ); - virtual CFormBodyElt& operator -=( const CFormBodyElt& _fbe ); - virtual bool operator ==( const CFormBodyElt& _fbe ) const; - - virtual CFormBodyElt* Clone() const; - virtual bool Empty() const; - CStringEx GetComment() const; - void SetComment( const CStringEx _sxcomment ); - CStringEx GetParent( unsigned int _index ) const; - CStringEx GetActivity( unsigned int _index ) const; - - uint32 GetNbElt () const; - virtual CFormBodyElt* GetElt( const unsigned int _index ) const; - virtual CFormBodyElt* GetElt( const CStringEx _sxname ) const; - - void AddElt( CFormBodyElt* const pfbe ); -}; - -} // NLGEORGES - -#endif // NLGEORGES_FORM_BODY_ELT_STRUCT_H +// 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 NLGEORGES_FORM_BODY_ELT_STRUCT_H +#define NLGEORGES_FORM_BODY_ELT_STRUCT_H + +#include "nel/misc/stream.h" +#include "form_body_elt.h" + +namespace NLOLDGEORGES +{ + +#define SXCOMMENT "Comment" +#define SXPARENTS "Parents" + +// La classe CFormBodyEltStruct permet d'obtenir un ensemble de CFormBodyElt. +// Dans l'opérateur +=, les nouveaux élément remplacent les anciens, les anciens non-écrasés restent +class CFormBodyEltStruct : public CFormBodyElt +{ +public: + std::vector< CFormBodyElt* > vpbodyelt; + std::vector< CFormBodyElt* >::iterator Find( const CStringEx _sxname ); + std::vector< CFormBodyElt* >::const_iterator Find( const CStringEx _sxname ) const; + void Clear(); + + NLMISC_DECLARE_CLASS( CFormBodyEltStruct ); + CFormBodyEltStruct(); + CFormBodyEltStruct( const CFormBodyEltStruct& _fbes ); + virtual ~CFormBodyEltStruct(); + virtual void serial( NLMISC::IStream& s ); + + CFormBodyElt& operator =( const CFormBodyEltStruct& _fbes ); + virtual CFormBodyElt& operator =( const CFormBodyElt& _fbe ); + virtual CFormBodyElt& operator +=( const CFormBodyElt& _fbe ); + virtual CFormBodyElt& operator -=( const CFormBodyElt& _fbe ); + virtual bool operator ==( const CFormBodyElt& _fbe ) const; + + virtual CFormBodyElt* Clone() const; + virtual bool Empty() const; + CStringEx GetComment() const; + void SetComment( const CStringEx _sxcomment ); + CStringEx GetParent( unsigned int _index ) const; + CStringEx GetActivity( unsigned int _index ) const; + + uint32 GetNbElt () const; + virtual CFormBodyElt* GetElt( const unsigned int _index ) const; + virtual CFormBodyElt* GetElt( const CStringEx _sxname ) const; + + void AddElt( CFormBodyElt* const pfbe ); +}; + +} // NLGEORGES + +#endif // NLGEORGES_FORM_BODY_ELT_STRUCT_H diff --git a/code/ryzom/tools/leveldesign/georges_convert/form_file.cpp b/code/ryzom/tools/leveldesign/georges_convert/form_file.cpp index 30f258726..293209176 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/form_file.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/form_file.cpp @@ -1,99 +1,99 @@ -// 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 "stdgeorgesconvert.h" -#include "nel/misc/file.h" -#include "nel/misc/i_xml.h" -#include "nel/misc/o_xml.h" -#include "form_file.h" - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CFormFile::CFormFile() -{ -} - -CFormFile::~CFormFile() -{ -} - -void CFormFile::serial( NLMISC::IStream& s ) -{ - s.xmlPush( "File_of_forms" ); - s.serialCheck( (uint32)'FORM' ); - s.serialVersion( 0 ); - s.serialCont( lform ); - s.xmlPop(); -} - -void CFormFile::Load( const CStringEx _sxfullname ) -{ - NLMISC::CIFile fileIn; - fileIn.open( CStringEx( _sxfullname ) ); - NLMISC::CIXml input; - input.init( fileIn ); - serial( input ); -} // Exception if fileIn.close(); - -void CFormFile::Save( const CStringEx _sxfullname ) -{ - lform.front().SetDate( "Temporary out of date" ); - NLMISC::COFile fileOut; - fileOut.open( CStringEx( _sxfullname ) ); - NLMISC::COXml output; - output.init( &fileOut ); - serial( output ); - output.flush(); - fileOut.close(); -} // Exception if fileOut.close(); - -void CFormFile::GetForm( CForm& _f ) const -{ - _f = lform.front(); // The first form is copying -} - -void CFormFile::GetForm( CForm& _f, const CStringEx& _sxdate ) const -{ - std::list< CForm >::const_iterator cit = lform.begin(); - _f = *cit; // The first form is copying - while( (cit != lform.end())&&( _sxdate <= cit->GetDate() ) ) - _f += *(++cit); // While history's date is after the date, add history's form. -} - -void CFormFile::SetForm( CForm& _f ) -{ - if( lform.empty() ) - { - lform.push_front( _f ); - return; - } - - if( ( !_f.GetModified() )||( _f == lform.front() ) ) - return; // It's the same! Don't save... - - CForm f = lform.front(); // Copy the old first form - f -= _f; // overwrite with differences - lform.pop_front(); // Delete the old fist form - lform.push_front( f ); // Replace it by differences - lform.push_front( _f ); // Place the new form in first position -} - +// 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 "stdgeorgesconvert.h" +#include "nel/misc/file.h" +#include "nel/misc/i_xml.h" +#include "nel/misc/o_xml.h" +#include "form_file.h" + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CFormFile::CFormFile() +{ +} + +CFormFile::~CFormFile() +{ +} + +void CFormFile::serial( NLMISC::IStream& s ) +{ + s.xmlPush( "File_of_forms" ); + s.serialCheck( (uint32)'FORM' ); + s.serialVersion( 0 ); + s.serialCont( lform ); + s.xmlPop(); +} + +void CFormFile::Load( const CStringEx _sxfullname ) +{ + NLMISC::CIFile fileIn; + fileIn.open( CStringEx( _sxfullname ) ); + NLMISC::CIXml input; + input.init( fileIn ); + serial( input ); +} // Exception if fileIn.close(); + +void CFormFile::Save( const CStringEx _sxfullname ) +{ + lform.front().SetDate( "Temporary out of date" ); + NLMISC::COFile fileOut; + fileOut.open( CStringEx( _sxfullname ) ); + NLMISC::COXml output; + output.init( &fileOut ); + serial( output ); + output.flush(); + fileOut.close(); +} // Exception if fileOut.close(); + +void CFormFile::GetForm( CForm& _f ) const +{ + _f = lform.front(); // The first form is copying +} + +void CFormFile::GetForm( CForm& _f, const CStringEx& _sxdate ) const +{ + std::list< CForm >::const_iterator cit = lform.begin(); + _f = *cit; // The first form is copying + while( (cit != lform.end())&&( _sxdate <= cit->GetDate() ) ) + _f += *(++cit); // While history's date is after the date, add history's form. +} + +void CFormFile::SetForm( CForm& _f ) +{ + if( lform.empty() ) + { + lform.push_front( _f ); + return; + } + + if( ( !_f.GetModified() )||( _f == lform.front() ) ) + return; // It's the same! Don't save... + + CForm f = lform.front(); // Copy the old first form + f -= _f; // overwrite with differences + lform.pop_front(); // Delete the old fist form + lform.push_front( f ); // Replace it by differences + lform.push_front( _f ); // Place the new form in first position +} + } \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_convert/form_file.h b/code/ryzom/tools/leveldesign/georges_convert/form_file.h index 45b0a5597..e93f2c55e 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/form_file.h +++ b/code/ryzom/tools/leveldesign/georges_convert/form_file.h @@ -1,48 +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 NLGEORGES_FORM_FILE_H -#define NLGEORGES_FORM_FILE_H - -#include "nel/misc/stream.h" -#include "string_ex.h" -#include "form.h" - -namespace NLOLDGEORGES -{ - - -// La classe CFormFile représente un fichier composé d'un ensemble de fiches représentés par des fiches CForm. -class CFormFile -{ -public: - std::list< CForm > lform; - - CFormFile(); - virtual ~CFormFile(); - void serial( NLMISC::IStream& s ); - - void Load( const CStringEx _sxfullname ); - void Save( const CStringEx _sxfullname ); - void GetForm( CForm& _f ) const; - void GetForm( CForm& _f, const CStringEx& _sxdate ) const; - void SetForm( CForm& _f ); -}; - -} // NLGEORGES - -#endif // NLGEORGES_FORM_FILE_H - +// 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 NLGEORGES_FORM_FILE_H +#define NLGEORGES_FORM_FILE_H + +#include "nel/misc/stream.h" +#include "string_ex.h" +#include "form.h" + +namespace NLOLDGEORGES +{ + + +// La classe CFormFile représente un fichier composé d'un ensemble de fiches représentés par des fiches CForm. +class CFormFile +{ +public: + std::list< CForm > lform; + + CFormFile(); + virtual ~CFormFile(); + void serial( NLMISC::IStream& s ); + + void Load( const CStringEx _sxfullname ); + void Save( const CStringEx _sxfullname ); + void GetForm( CForm& _f ) const; + void GetForm( CForm& _f, const CStringEx& _sxdate ) const; + void SetForm( CForm& _f ); +}; + +} // NLGEORGES + +#endif // NLGEORGES_FORM_FILE_H + diff --git a/code/ryzom/tools/leveldesign/georges_convert/form_head.cpp b/code/ryzom/tools/leveldesign/georges_convert/form_head.cpp index 8d1b50228..c0bb609be 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/form_head.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/form_head.cpp @@ -1,97 +1,97 @@ -// 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 "stdgeorgesconvert.h" -#include "form_head.h" - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CFormHead::CFormHead() -{ - sxuser = "Anonymous"; - sxversion = "0.0"; - sxdate = "unknow"; -} - -CFormHead::CFormHead( const CFormHead& _fh ) -{ - sxuser = _fh.sxuser; - sxversion = _fh.sxversion; - sxdate = _fh.sxdate; -} - -CFormHead::~CFormHead() -{ -} - -CStringEx CFormHead::GetUser() const -{ - return( sxuser ); -} - -CStringEx CFormHead::GetVersion() const -{ - return( sxversion ); -} - -CStringEx CFormHead::GetDate() const -{ - return( sxdate ); -} - -void CFormHead::SetUser( const CStringEx _sxuser ) -{ - sxuser = _sxuser; -} - -void CFormHead::SetVersion( const CStringEx _sxversion ) -{ - sxversion = _sxversion; -} - -void CFormHead::SetDate( const CStringEx _sxdate ) -{ - sxdate = _sxdate; -} - -void CFormHead::serial( NLMISC::IStream& s ) -{ - - s.xmlPushBegin( "Head" ); - s.xmlSetAttrib( "User_name" ); - s.serial( sxuser ); - s.xmlSetAttrib( "Version_number" ); - s.serial( sxversion ); - s.xmlSetAttrib( "Date" ); - s.serial( sxdate ); - s.xmlPushEnd(); - s.xmlPop(); -} - -CFormHead& CFormHead::operator =( const CFormHead& _fh ) -{ - sxuser = _fh.sxuser; - sxversion = _fh.sxversion; - sxdate = _fh.sxdate; - return( *this ); -} - +// 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 "stdgeorgesconvert.h" +#include "form_head.h" + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CFormHead::CFormHead() +{ + sxuser = "Anonymous"; + sxversion = "0.0"; + sxdate = "unknow"; +} + +CFormHead::CFormHead( const CFormHead& _fh ) +{ + sxuser = _fh.sxuser; + sxversion = _fh.sxversion; + sxdate = _fh.sxdate; +} + +CFormHead::~CFormHead() +{ +} + +CStringEx CFormHead::GetUser() const +{ + return( sxuser ); +} + +CStringEx CFormHead::GetVersion() const +{ + return( sxversion ); +} + +CStringEx CFormHead::GetDate() const +{ + return( sxdate ); +} + +void CFormHead::SetUser( const CStringEx _sxuser ) +{ + sxuser = _sxuser; +} + +void CFormHead::SetVersion( const CStringEx _sxversion ) +{ + sxversion = _sxversion; +} + +void CFormHead::SetDate( const CStringEx _sxdate ) +{ + sxdate = _sxdate; +} + +void CFormHead::serial( NLMISC::IStream& s ) +{ + + s.xmlPushBegin( "Head" ); + s.xmlSetAttrib( "User_name" ); + s.serial( sxuser ); + s.xmlSetAttrib( "Version_number" ); + s.serial( sxversion ); + s.xmlSetAttrib( "Date" ); + s.serial( sxdate ); + s.xmlPushEnd(); + s.xmlPop(); +} + +CFormHead& CFormHead::operator =( const CFormHead& _fh ) +{ + sxuser = _fh.sxuser; + sxversion = _fh.sxversion; + sxdate = _fh.sxdate; + return( *this ); +} + } \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_convert/form_head.h b/code/ryzom/tools/leveldesign/georges_convert/form_head.h index 43900560a..3fda8b049 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/form_head.h +++ b/code/ryzom/tools/leveldesign/georges_convert/form_head.h @@ -1,51 +1,51 @@ -// 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 NLGEORGES_FORM_HEAD_H -#define NLGEORGES_FORM_HEAD_H - -#include "nel/misc/stream.h" -#include "string_ex.h" - -namespace NLOLDGEORGES -{ - -// La classe CFormHead comprend trois strings: le nom de l'utilisateur, la date de dernière modif et la version. -class CFormHead -{ -protected: - CStringEx sxuser; - CStringEx sxversion; - CStringEx sxdate; - -public: - CFormHead(); - CFormHead( const CFormHead& _fh ); - virtual ~CFormHead(); - void serial( NLMISC::IStream& s ); - CStringEx GetUser() const; - CStringEx GetVersion() const; - CStringEx GetDate() const; - void SetUser( const CStringEx _sxuser ); - void SetVersion( const CStringEx _sxversion ); - void SetDate( const CStringEx _sxdate ); - - CFormHead& operator =( const CFormHead& _f ); -}; - -} // NLGEORGES - -#endif // NLGEORGES_FORM_HEAD_H +// 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 NLGEORGES_FORM_HEAD_H +#define NLGEORGES_FORM_HEAD_H + +#include "nel/misc/stream.h" +#include "string_ex.h" + +namespace NLOLDGEORGES +{ + +// La classe CFormHead comprend trois strings: le nom de l'utilisateur, la date de dernière modif et la version. +class CFormHead +{ +protected: + CStringEx sxuser; + CStringEx sxversion; + CStringEx sxdate; + +public: + CFormHead(); + CFormHead( const CFormHead& _fh ); + virtual ~CFormHead(); + void serial( NLMISC::IStream& s ); + CStringEx GetUser() const; + CStringEx GetVersion() const; + CStringEx GetDate() const; + void SetUser( const CStringEx _sxuser ); + void SetVersion( const CStringEx _sxversion ); + void SetDate( const CStringEx _sxdate ); + + CFormHead& operator =( const CFormHead& _f ); +}; + +} // NLGEORGES + +#endif // NLGEORGES_FORM_HEAD_H diff --git a/code/ryzom/tools/leveldesign/georges_convert/form_loader.cpp b/code/ryzom/tools/leveldesign/georges_convert/form_loader.cpp index 077549335..976dffe0f 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/form_loader.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/form_loader.cpp @@ -1,65 +1,65 @@ -// 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 "stdgeorgesconvert.h" -#include "form_loader.h" - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CFormLoader::CFormLoader() -{ -} - -CFormLoader::~CFormLoader() -{ -} - -void CFormLoader::LoadForm( CForm& _f, const CStringEx& _sxfilename ) -{ - if( _sxfilename.empty() ) - return; - CFormFile* pff = new CFormFile; - pff->Load( _sxfilename ); - pff->GetForm( _f ); - delete pff; -} - -void CFormLoader::LoadForm( CForm& _f, const CStringEx& _sxfilename, const CStringEx& _sxdate ) -{ - if( _sxfilename.empty() ) - return; - CFormFile* pff = new CFormFile; - pff->Load( _sxfilename ); - pff->GetForm( _f, _sxdate ); - delete pff; -} - -void CFormLoader::SaveForm( CForm& _f, const CStringEx& _sxfilename ) -{ - if( _sxfilename.empty() ) - return; - CFormFile* pff = new CFormFile; - pff->SetForm( _f ); - pff->Save( _sxfilename ); - delete pff; -} - +// 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 "stdgeorgesconvert.h" +#include "form_loader.h" + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CFormLoader::CFormLoader() +{ +} + +CFormLoader::~CFormLoader() +{ +} + +void CFormLoader::LoadForm( CForm& _f, const CStringEx& _sxfilename ) +{ + if( _sxfilename.empty() ) + return; + CFormFile* pff = new CFormFile; + pff->Load( _sxfilename ); + pff->GetForm( _f ); + delete pff; +} + +void CFormLoader::LoadForm( CForm& _f, const CStringEx& _sxfilename, const CStringEx& _sxdate ) +{ + if( _sxfilename.empty() ) + return; + CFormFile* pff = new CFormFile; + pff->Load( _sxfilename ); + pff->GetForm( _f, _sxdate ); + delete pff; +} + +void CFormLoader::SaveForm( CForm& _f, const CStringEx& _sxfilename ) +{ + if( _sxfilename.empty() ) + return; + CFormFile* pff = new CFormFile; + pff->SetForm( _f ); + pff->Save( _sxfilename ); + delete pff; +} + } \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_convert/form_loader.h b/code/ryzom/tools/leveldesign/georges_convert/form_loader.h index 0e70c49d2..60acf3010 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/form_loader.h +++ b/code/ryzom/tools/leveldesign/georges_convert/form_loader.h @@ -1,45 +1,45 @@ -// 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 NLGEORGES_FORM_LOADER_H -#define NLGEORGES_FORM_LOADER_H - -#include "string_ex.h" -#include "form_file.h" - -namespace NLOLDGEORGES -{ - -// La classe CFormLoader est le point d'entrée des classes CForm pour charger une fiche. -// Il y a deux fonctions load: -// Sans date: donne directement la dernière fiche historiquement parlant -// Avec date: donne une fiche composée de la dernière additionnés des historiques postérieurs ou égaux à la date. -class CFormLoader -{ -protected: - -public: - CFormLoader(); - virtual ~CFormLoader(); - - void LoadForm( CForm& _f, const CStringEx& _sxfilename ); - void LoadForm( CForm& _f, const CStringEx& _sxfilename, const CStringEx& _sxdate ); - void SaveForm( CForm& _f, const CStringEx& _sxfilename ); -}; - -} // NLGEORGES - -#endif // NLGEORGES_FORM_LOADER_H +// 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 NLGEORGES_FORM_LOADER_H +#define NLGEORGES_FORM_LOADER_H + +#include "string_ex.h" +#include "form_file.h" + +namespace NLOLDGEORGES +{ + +// La classe CFormLoader est le point d'entrée des classes CForm pour charger une fiche. +// Il y a deux fonctions load: +// Sans date: donne directement la dernière fiche historiquement parlant +// Avec date: donne une fiche composée de la dernière additionnés des historiques postérieurs ou égaux à la date. +class CFormLoader +{ +protected: + +public: + CFormLoader(); + virtual ~CFormLoader(); + + void LoadForm( CForm& _f, const CStringEx& _sxfilename ); + void LoadForm( CForm& _f, const CStringEx& _sxfilename, const CStringEx& _sxdate ); + void SaveForm( CForm& _f, const CStringEx& _sxfilename ); +}; + +} // NLGEORGES + +#endif // NLGEORGES_FORM_LOADER_H diff --git a/code/ryzom/tools/leveldesign/georges_convert/georges_convert.cpp b/code/ryzom/tools/leveldesign/georges_convert/georges_convert.cpp index b265e69e5..09b0b0629 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/georges_convert.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/georges_convert.cpp @@ -1,649 +1,649 @@ -// 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 "stdgeorgesconvert.h" - -#include "nel/misc/file.h" -#include "nel/misc/i_xml.h" -#include "nel/misc/o_xml.h" - -#include "nel/georges/type.h" -#include "nel/georges/form.h" -#include "nel/georges/form_dfn.h" - -#include "form_body_elt_atom.h" -#include "form_body_elt_list.h" -#include "form_body_elt_struct.h" -#include "form_file.h" - -using namespace NLMISC; -using namespace std; - -// Return the string value of a field in the structure -NLOLDGEORGES::CFormBodyElt *getValue (const char *key, const NLOLDGEORGES::CFormBodyEltStruct& str) -{ - for (uint elm=0; elmsxname == key) - return str.vpbodyelt[elm]; - } - - // Not found - return NULL; -} - -bool convertTypeFile (const char *oldFileName, const char *newFileName) -{ - // Load the form file - - // File stream - CIFile file; - if (file.open (oldFileName)) - { - // Catch errors - try - { - // Init the xml stream - CIXml xmlFile; - xmlFile.init (file); - - // Read the old file format - NLOLDGEORGES::CFormFile oldFileFormat; - oldFileFormat.serial (xmlFile); - - // Get a form pointer - if (oldFileFormat.lform.size () != 1) - { - // Warning - nlwarning ("Invalid old type file format in file %s", oldFileName); - return false; - } - else - { - NLOLDGEORGES::CFormBodyEltStruct &str = oldFileFormat.lform.begin ()->body; - - // New file format - NLGEORGES::CType newType; - - // Get type - NLOLDGEORGES::CFormBodyEltAtom *eltType = dynamic_cast (getValue ("Type", str)); - NLOLDGEORGES::CFormBodyEltAtom *eltEnum = dynamic_cast (getValue ("Enum", str)); - NLOLDGEORGES::CFormBodyEltAtom *eltFormula = dynamic_cast (getValue ("Formula", str)); - NLOLDGEORGES::CFormBodyEltAtom *eltDefaultValue = dynamic_cast (getValue ("DefaultValue", str)); - NLOLDGEORGES::CFormBodyEltAtom *eltLowlimit = dynamic_cast (getValue ("Lowlimit", str)); - NLOLDGEORGES::CFormBodyEltAtom *eltHighlimit = dynamic_cast (getValue ("Highlimit", str)); - NLOLDGEORGES::CFormBodyEltList *eltPredef = dynamic_cast (getValue ("Predef", str)); - - // All needed is present ? - if (eltType && eltPredef) - { - // Convert enum - bool _enum = ( eltEnum && (eltEnum->sxvalue == "true") ); - - // Have predef ? - bool predef = eltPredef->vpbodyelt.size() != 0; - - // Convert the type - eltType->sxvalue = strlwr (eltType->sxvalue); - if (eltType->sxvalue == "uint") - { - newType.Type = NLGEORGES::CType::UnsignedInt; - newType.UIType = _enum ? NLGEORGES::CType::NonEditableCombo : NLGEORGES::CType::EditSpin; - } - else if (eltType->sxvalue == "sint") - { - newType.Type = NLGEORGES::CType::SignedInt; - newType.UIType = _enum ? NLGEORGES::CType::NonEditableCombo : NLGEORGES::CType::EditSpin; - } - else if (eltType->sxvalue == "string") - { - newType.Type = NLGEORGES::CType::String; - newType.UIType = _enum ? NLGEORGES::CType::NonEditableCombo : NLGEORGES::CType::Edit; - } - else if (eltType->sxvalue == "double") - { - newType.Type = NLGEORGES::CType::Double; - newType.UIType = _enum ? NLGEORGES::CType::NonEditableCombo : NLGEORGES::CType::EditSpin; - } - else if (eltType->sxvalue == "filename") - { - newType.Type = NLGEORGES::CType::String; - newType.UIType = NLGEORGES::CType::FileBrowser; - } - else - { - // Warning - nlwarning ("Invalid old type file format in file %s", oldFileName); - return false; - } - - // Convert predef - if (predef) - { - // Resize the predef array - newType.Definitions.resize (eltPredef->vpbodyelt.size()); - - // For each predef - uint pre; - for (pre=0; prevpbodyelt.size(); pre++) - { - NLOLDGEORGES::CFormBodyEltStruct *eltPre = dynamic_cast (eltPredef->vpbodyelt[pre]); - if (eltPre) - { - // Get the label - NLOLDGEORGES::CFormBodyEltAtom *eltLabel = dynamic_cast (getValue ("Designation", *eltPre)); - - // Get the value - NLOLDGEORGES::CFormBodyEltAtom *eltValue = dynamic_cast (getValue ("Substitute", *eltPre)); - - // Ok ? - if (eltLabel && eltValue) - { - newType.Definitions[pre].Label = eltLabel->sxvalue; - newType.Definitions[pre].Value = eltValue->sxvalue; - } - else - { - // Warning - nlwarning ("Invalid old type file format in file %s", oldFileName); - return false; - } - } - else - { - // Warning - nlwarning ("Invalid old type file format in file %s", oldFileName); - return false; - } - } - } - - // Default value - newType.Default = eltDefaultValue ? eltDefaultValue->sxvalue : ""; - - // Min - newType.Min = eltLowlimit ? eltLowlimit->sxvalue : ""; - - // Max - newType.Max = eltHighlimit ? eltHighlimit->sxvalue : ""; - - // Some log - newType.Header.addLog ("File converted from old format"); - newType.Header.setComments ("Converted from old format"); - - // ** Type ok, save it - - // Output file - COFile output; - if (output.open (newFileName)) - { - try - { - // Xml file - COXml outputXml; - outputXml.init (&output); - - // Write the document - newType.write (outputXml.getDocument ()); - - // Flush the document - outputXml.flush (); - } - catch (Exception &e) - { - // Warning - nlwarning ("Error while writing xmlFile %s (%s)", oldFileName, e.what ()); - return false; - } - } - else - { - // Warning - nlwarning ("Can't open the TYPE file %s for writing", oldFileName); - return false; - } - } - else - { - // Warning - nlwarning ("Invalid old type file format in file %s", oldFileName); - return false; - } - } - } - catch (Exception &e) - { - // Warning - nlwarning ("Error while loading xmlFile %s (%s)", oldFileName, e.what ()); - return false; - } - } - else - { - // Warning - nlwarning ("Can't open the TYPE file %s for reading", oldFileName); - return false; - } - - return true; -} - -bool convertDfnFile (const char *oldFileName, const char *newFileName) -{ - // Load the form file - - // File stream - CIFile file; - if (file.open (oldFileName)) - { - // Catch errors - try - { - // Init the xml stream - CIXml xmlFile; - xmlFile.init (file); - - // Read the old file format - NLOLDGEORGES::CFormFile oldFileFormat; - oldFileFormat.serial (xmlFile); - - // Get a form pointer - if (oldFileFormat.lform.size () != 1) - { - // Warning - nlwarning ("Invalid old dfn file format in file %s", oldFileName); - return false; - } - else - { - NLOLDGEORGES::CFormBodyEltStruct &str = oldFileFormat.lform.begin ()->body; - - // New file format - NLGEORGES::CFormDfn newDfn; - newDfn.Entries.resize (str.vpbodyelt.size()); - - // For each element of the struct - for (uint elm=0; elm (str.vpbodyelt[elm]); - if (eltAtom) - { - // Get name and value - string name = eltAtom->sxname; - string value = eltAtom->sxvalue; - string value_lwr = strlwr (value); - - // Is a list ? - bool isArray = ( value_lwr.find ( "list<" ) != -1 ); - - // Get list value - if ( isArray ) - { - unsigned int ipos = value_lwr.find( ">" ); - if( ipos < 0 ) - { - // Warning - nlwarning ("Invalid old dfn file format in file %s", oldFileName); - return false; - } - value = value.substr ( 6, ipos-7 ); - value_lwr = value_lwr.substr ( 6, ipos-7 ); - } - - // Is a typ ? - bool type = ( value_lwr.find ( ".typ" ) != -1 ); - - // Is a dfn ? - bool dfn = ( value_lwr.find ( ".dfn" ) != -1 ); - - // Valid ? - if (type || dfn) - { - // Create a new array - newDfn.Entries[elm].TypeElement = type ? NLGEORGES::UFormDfn::EntryType : NLGEORGES::UFormDfn::EntryDfn; - newDfn.Entries[elm].Name = name; - newDfn.Entries[elm].Filename = value; - newDfn.Entries[elm].Array = isArray; - } - else - { - // Warning - nlwarning ("Invalid old dfn file format in file %s", oldFileName); - return false; - } - } - else - { - // Warning - nlwarning ("Invalid old dfn file format in file %s", oldFileName); - return false; - } - } - - // Some log - newDfn.Header.addLog ("File converted from old format"); - newDfn.Header.setComments ("Converted from old format"); - - // ** Type ok, save it - - // Output file - COFile output; - if (output.open (newFileName)) - { - try - { - // Xml file - COXml outputXml; - outputXml.init (&output); - - // Write the document - newDfn.write (outputXml.getDocument ()); - - // Flush the document - outputXml.flush (); - } - catch (Exception &e) - { - // Warning - nlwarning ("Error while writing xmlFile %s (%s)", oldFileName, e.what ()); - return false; - } - } - else - { - // Warning - nlwarning ("Can't open the dfn file %s for writing", oldFileName); - return false; - } - } - } - catch (Exception &e) - { - // Warning - nlwarning ("Error while loading xmlFile %s (%s)", oldFileName, e.what ()); - return false; - } - } - else - { - // Warning - nlwarning ("Can't open the dfn file %s for reading", oldFileName); - return false; - } - - return true; -} - -bool convertFormAtom (const NLOLDGEORGES::CFormBodyEltAtom &_atom, NLGEORGES::CFormElmAtom &dst) -{ - // Copy the value - dst.setValue (((string)_atom.sxvalue).c_str ()); - - // Ok - return true; -} - -bool convertFormStruct (const NLOLDGEORGES::CFormBodyEltStruct &_struct, NLGEORGES::CFormElmStruct &dst, NLGEORGES::CForm *form); - -bool convertFormArray (const NLOLDGEORGES::CFormBodyEltList &listSrc, NLGEORGES::CFormElmArray &array, NLGEORGES::CForm *form) -{ - // Resize the destination struct - array.Elements.resize (listSrc.vpbodyelt.size ()); - - // For each sub-element - uint i; - for (i=0; i (listSrc.vpbodyelt[i]); - if (_atom) - { - // New atom - NLGEORGES::CFormElmAtom *atomDst = new NLGEORGES::CFormElmAtom (form, NULL, NULL, 0xffffffff); - array.Elements[i] = atomDst; - - // Convert the atom - if (!convertFormAtom (*_atom, *atomDst)) - return false; - } - else - { - const NLOLDGEORGES::CFormBodyEltStruct *_struct = dynamic_cast (listSrc.vpbodyelt[i]); - if (_struct) - { - // New struct - NLGEORGES::CFormElmStruct *_newStruct = new NLGEORGES::CFormElmStruct (form, NULL, NULL, 0xffffffff); - array.Elements[i] = _newStruct; - - // Build this struct - if (!convertFormStruct (*_struct, *_newStruct, form)) - return false; - } - else - { - const NLOLDGEORGES::CFormBodyEltList *_list = dynamic_cast (listSrc.vpbodyelt[i]); - if (_list) - { - // New array - NLGEORGES::CFormElmArray *_array = new NLGEORGES::CFormElmArray (form, NULL, NULL, NULL, NULL, 0xffffffff); - array.Elements[i] = _array; - - // Build this struct - if (!convertFormArray (*_list, *_array, form)) - return false; - } - else - return false; - } - } - } - - return true; -} - -bool convertFormStruct (const NLOLDGEORGES::CFormBodyEltStruct &structSrc, NLGEORGES::CFormElmStruct &dst, NLGEORGES::CForm *form) -{ - // Resize the destination struct - dst.Elements.resize (structSrc.vpbodyelt.size ()); - - // For each sub-element - uint i; - for (i=0; isxname; - - // Cast - const NLOLDGEORGES::CFormBodyEltAtom *_atom = dynamic_cast (structSrc.vpbodyelt[i]); - if (_atom) - { - // New atom - NLGEORGES::CFormElmAtom *atomDst = new NLGEORGES::CFormElmAtom (form, NULL, NULL, 0xffffffff); - dst.Elements[i].Element = atomDst; - - // Convert the atom - if (!convertFormAtom (*_atom, *atomDst)) - return false; - } - else - { - const NLOLDGEORGES::CFormBodyEltStruct *_struct = dynamic_cast (structSrc.vpbodyelt[i]); - if (_struct) - { - // New struct - NLGEORGES::CFormElmStruct *_newStruct = new NLGEORGES::CFormElmStruct (form, NULL, NULL, 0xffffffff); - dst.Elements[i].Element = _newStruct; - - // Build this struct - if (!convertFormStruct (*_struct, *_newStruct, form)) - return false; - } - else - { - const NLOLDGEORGES::CFormBodyEltList *_list = dynamic_cast (structSrc.vpbodyelt[i]); - if (_list) - { - // New array - NLGEORGES::CFormElmArray *_array = new NLGEORGES::CFormElmArray (form, NULL, NULL, NULL, NULL, 0xffffffff); - dst.Elements[i].Element = _array; - - // Build this struct - if (!convertFormArray (*_list, *_array, form)) - return false; - } - else - return false; - } - } - } - - return true; -} - -bool convertFormFile (const char *oldFileName, const char *newFileName) -{ - // Load the form file - - // File stream - CIFile file; - if (file.open (oldFileName)) - { - // Catch errors - try - { - // Init the xml stream - CIXml xmlFile; - xmlFile.init (file); - - // Read the old file format - NLOLDGEORGES::CFormFile oldFileFormat; - oldFileFormat.serial (xmlFile); - - // Get a form pointer - if (oldFileFormat.lform.size () != 1) - { - // Warning - nlwarning ("Invalid old form file format in file %s", oldFileName); - return false; - } - else - { - // Struct ref - NLOLDGEORGES::CFormBodyEltStruct &str = oldFileFormat.lform.begin ()->body; - - // Build this struct - NLGEORGES::CForm newForm; - if (convertFormStruct (str, newForm.Elements, &newForm)) - { - string parent = str.GetParent( 0 ); - if (!parent.empty()) - { - newForm.ParentFilename = parent; - } - - // Some log - newForm.Header.addLog ("File converted from old format"); - newForm.Header.setComments ("Converted from old format"); - - // Output file - COFile output; - if (output.open (newFileName)) - { - try - { - // Xml file - COXml outputXml; - outputXml.init (&output); - - // Write the document - newForm.write (outputXml.getDocument ()); - - // Flush the document - outputXml.flush (); - } - catch (Exception &e) - { - // Warning - nlwarning ("Error while writing xmlFile %s (%s)", oldFileName, e.what ()); - return false; - } - } - else - { - // Warning - nlwarning ("Can't open the dfn file %s for writing", oldFileName); - return false; - } - } - else - { - // Warning - nlwarning ("Invalid old form file format in file %s", oldFileName); - return false; - } - } - } - catch (Exception &e) - { - // Warning - nlwarning ("Error while loading xmlFile %s (%s)", oldFileName, e.what ()); - return false; - } - } - else - { - // Warning - nlwarning ("Can't open the form file %s for reading", oldFileName); - return false; - } - - return true; -} - -using namespace NLOLDGEORGES; - -int main (int argc, void **argv) -{ - new NLMISC::CApplicationContext; - - // Register classes - NLMISC_REGISTER_CLASS (CFormBodyElt); - NLMISC_REGISTER_CLASS (CFormBodyEltAtom); - NLMISC_REGISTER_CLASS (CFormBodyEltList); - NLMISC_REGISTER_CLASS (CFormBodyEltStruct); - - // Help ? - if (argc!=3) - { - printf ("georges_convert [old_file] [new_file]"); - return 0; - } - else - { - strlwr ((const char*)argv[1]); - bool isType = strstr ((const char*)argv[1], ".typ") != NULL; - bool isDfn = strstr ((const char*)argv[1], ".dfn") != NULL; - if (isType) - return convertTypeFile ((const char*) argv[1], (const char*) argv[2]) ? 1 : 0; - else if (isDfn) - return convertDfnFile ((const char*) argv[1], (const char*) argv[2]) ? 1 : 0; - else - return convertFormFile ((const char*) argv[1], (const char*) argv[2]) ? 1 : 0; - } - - return 1; +// 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 "stdgeorgesconvert.h" + +#include "nel/misc/file.h" +#include "nel/misc/i_xml.h" +#include "nel/misc/o_xml.h" + +#include "nel/georges/type.h" +#include "nel/georges/form.h" +#include "nel/georges/form_dfn.h" + +#include "form_body_elt_atom.h" +#include "form_body_elt_list.h" +#include "form_body_elt_struct.h" +#include "form_file.h" + +using namespace NLMISC; +using namespace std; + +// Return the string value of a field in the structure +NLOLDGEORGES::CFormBodyElt *getValue (const char *key, const NLOLDGEORGES::CFormBodyEltStruct& str) +{ + for (uint elm=0; elmsxname == key) + return str.vpbodyelt[elm]; + } + + // Not found + return NULL; +} + +bool convertTypeFile (const char *oldFileName, const char *newFileName) +{ + // Load the form file + + // File stream + CIFile file; + if (file.open (oldFileName)) + { + // Catch errors + try + { + // Init the xml stream + CIXml xmlFile; + xmlFile.init (file); + + // Read the old file format + NLOLDGEORGES::CFormFile oldFileFormat; + oldFileFormat.serial (xmlFile); + + // Get a form pointer + if (oldFileFormat.lform.size () != 1) + { + // Warning + nlwarning ("Invalid old type file format in file %s", oldFileName); + return false; + } + else + { + NLOLDGEORGES::CFormBodyEltStruct &str = oldFileFormat.lform.begin ()->body; + + // New file format + NLGEORGES::CType newType; + + // Get type + NLOLDGEORGES::CFormBodyEltAtom *eltType = dynamic_cast (getValue ("Type", str)); + NLOLDGEORGES::CFormBodyEltAtom *eltEnum = dynamic_cast (getValue ("Enum", str)); + NLOLDGEORGES::CFormBodyEltAtom *eltFormula = dynamic_cast (getValue ("Formula", str)); + NLOLDGEORGES::CFormBodyEltAtom *eltDefaultValue = dynamic_cast (getValue ("DefaultValue", str)); + NLOLDGEORGES::CFormBodyEltAtom *eltLowlimit = dynamic_cast (getValue ("Lowlimit", str)); + NLOLDGEORGES::CFormBodyEltAtom *eltHighlimit = dynamic_cast (getValue ("Highlimit", str)); + NLOLDGEORGES::CFormBodyEltList *eltPredef = dynamic_cast (getValue ("Predef", str)); + + // All needed is present ? + if (eltType && eltPredef) + { + // Convert enum + bool _enum = ( eltEnum && (eltEnum->sxvalue == "true") ); + + // Have predef ? + bool predef = eltPredef->vpbodyelt.size() != 0; + + // Convert the type + eltType->sxvalue = strlwr (eltType->sxvalue); + if (eltType->sxvalue == "uint") + { + newType.Type = NLGEORGES::CType::UnsignedInt; + newType.UIType = _enum ? NLGEORGES::CType::NonEditableCombo : NLGEORGES::CType::EditSpin; + } + else if (eltType->sxvalue == "sint") + { + newType.Type = NLGEORGES::CType::SignedInt; + newType.UIType = _enum ? NLGEORGES::CType::NonEditableCombo : NLGEORGES::CType::EditSpin; + } + else if (eltType->sxvalue == "string") + { + newType.Type = NLGEORGES::CType::String; + newType.UIType = _enum ? NLGEORGES::CType::NonEditableCombo : NLGEORGES::CType::Edit; + } + else if (eltType->sxvalue == "double") + { + newType.Type = NLGEORGES::CType::Double; + newType.UIType = _enum ? NLGEORGES::CType::NonEditableCombo : NLGEORGES::CType::EditSpin; + } + else if (eltType->sxvalue == "filename") + { + newType.Type = NLGEORGES::CType::String; + newType.UIType = NLGEORGES::CType::FileBrowser; + } + else + { + // Warning + nlwarning ("Invalid old type file format in file %s", oldFileName); + return false; + } + + // Convert predef + if (predef) + { + // Resize the predef array + newType.Definitions.resize (eltPredef->vpbodyelt.size()); + + // For each predef + uint pre; + for (pre=0; prevpbodyelt.size(); pre++) + { + NLOLDGEORGES::CFormBodyEltStruct *eltPre = dynamic_cast (eltPredef->vpbodyelt[pre]); + if (eltPre) + { + // Get the label + NLOLDGEORGES::CFormBodyEltAtom *eltLabel = dynamic_cast (getValue ("Designation", *eltPre)); + + // Get the value + NLOLDGEORGES::CFormBodyEltAtom *eltValue = dynamic_cast (getValue ("Substitute", *eltPre)); + + // Ok ? + if (eltLabel && eltValue) + { + newType.Definitions[pre].Label = eltLabel->sxvalue; + newType.Definitions[pre].Value = eltValue->sxvalue; + } + else + { + // Warning + nlwarning ("Invalid old type file format in file %s", oldFileName); + return false; + } + } + else + { + // Warning + nlwarning ("Invalid old type file format in file %s", oldFileName); + return false; + } + } + } + + // Default value + newType.Default = eltDefaultValue ? eltDefaultValue->sxvalue : ""; + + // Min + newType.Min = eltLowlimit ? eltLowlimit->sxvalue : ""; + + // Max + newType.Max = eltHighlimit ? eltHighlimit->sxvalue : ""; + + // Some log + newType.Header.addLog ("File converted from old format"); + newType.Header.setComments ("Converted from old format"); + + // ** Type ok, save it + + // Output file + COFile output; + if (output.open (newFileName)) + { + try + { + // Xml file + COXml outputXml; + outputXml.init (&output); + + // Write the document + newType.write (outputXml.getDocument ()); + + // Flush the document + outputXml.flush (); + } + catch (Exception &e) + { + // Warning + nlwarning ("Error while writing xmlFile %s (%s)", oldFileName, e.what ()); + return false; + } + } + else + { + // Warning + nlwarning ("Can't open the TYPE file %s for writing", oldFileName); + return false; + } + } + else + { + // Warning + nlwarning ("Invalid old type file format in file %s", oldFileName); + return false; + } + } + } + catch (Exception &e) + { + // Warning + nlwarning ("Error while loading xmlFile %s (%s)", oldFileName, e.what ()); + return false; + } + } + else + { + // Warning + nlwarning ("Can't open the TYPE file %s for reading", oldFileName); + return false; + } + + return true; +} + +bool convertDfnFile (const char *oldFileName, const char *newFileName) +{ + // Load the form file + + // File stream + CIFile file; + if (file.open (oldFileName)) + { + // Catch errors + try + { + // Init the xml stream + CIXml xmlFile; + xmlFile.init (file); + + // Read the old file format + NLOLDGEORGES::CFormFile oldFileFormat; + oldFileFormat.serial (xmlFile); + + // Get a form pointer + if (oldFileFormat.lform.size () != 1) + { + // Warning + nlwarning ("Invalid old dfn file format in file %s", oldFileName); + return false; + } + else + { + NLOLDGEORGES::CFormBodyEltStruct &str = oldFileFormat.lform.begin ()->body; + + // New file format + NLGEORGES::CFormDfn newDfn; + newDfn.Entries.resize (str.vpbodyelt.size()); + + // For each element of the struct + for (uint elm=0; elm (str.vpbodyelt[elm]); + if (eltAtom) + { + // Get name and value + string name = eltAtom->sxname; + string value = eltAtom->sxvalue; + string value_lwr = strlwr (value); + + // Is a list ? + bool isArray = ( value_lwr.find ( "list<" ) != -1 ); + + // Get list value + if ( isArray ) + { + unsigned int ipos = value_lwr.find( ">" ); + if( ipos < 0 ) + { + // Warning + nlwarning ("Invalid old dfn file format in file %s", oldFileName); + return false; + } + value = value.substr ( 6, ipos-7 ); + value_lwr = value_lwr.substr ( 6, ipos-7 ); + } + + // Is a typ ? + bool type = ( value_lwr.find ( ".typ" ) != -1 ); + + // Is a dfn ? + bool dfn = ( value_lwr.find ( ".dfn" ) != -1 ); + + // Valid ? + if (type || dfn) + { + // Create a new array + newDfn.Entries[elm].TypeElement = type ? NLGEORGES::UFormDfn::EntryType : NLGEORGES::UFormDfn::EntryDfn; + newDfn.Entries[elm].Name = name; + newDfn.Entries[elm].Filename = value; + newDfn.Entries[elm].Array = isArray; + } + else + { + // Warning + nlwarning ("Invalid old dfn file format in file %s", oldFileName); + return false; + } + } + else + { + // Warning + nlwarning ("Invalid old dfn file format in file %s", oldFileName); + return false; + } + } + + // Some log + newDfn.Header.addLog ("File converted from old format"); + newDfn.Header.setComments ("Converted from old format"); + + // ** Type ok, save it + + // Output file + COFile output; + if (output.open (newFileName)) + { + try + { + // Xml file + COXml outputXml; + outputXml.init (&output); + + // Write the document + newDfn.write (outputXml.getDocument ()); + + // Flush the document + outputXml.flush (); + } + catch (Exception &e) + { + // Warning + nlwarning ("Error while writing xmlFile %s (%s)", oldFileName, e.what ()); + return false; + } + } + else + { + // Warning + nlwarning ("Can't open the dfn file %s for writing", oldFileName); + return false; + } + } + } + catch (Exception &e) + { + // Warning + nlwarning ("Error while loading xmlFile %s (%s)", oldFileName, e.what ()); + return false; + } + } + else + { + // Warning + nlwarning ("Can't open the dfn file %s for reading", oldFileName); + return false; + } + + return true; +} + +bool convertFormAtom (const NLOLDGEORGES::CFormBodyEltAtom &_atom, NLGEORGES::CFormElmAtom &dst) +{ + // Copy the value + dst.setValue (((string)_atom.sxvalue).c_str ()); + + // Ok + return true; +} + +bool convertFormStruct (const NLOLDGEORGES::CFormBodyEltStruct &_struct, NLGEORGES::CFormElmStruct &dst, NLGEORGES::CForm *form); + +bool convertFormArray (const NLOLDGEORGES::CFormBodyEltList &listSrc, NLGEORGES::CFormElmArray &array, NLGEORGES::CForm *form) +{ + // Resize the destination struct + array.Elements.resize (listSrc.vpbodyelt.size ()); + + // For each sub-element + uint i; + for (i=0; i (listSrc.vpbodyelt[i]); + if (_atom) + { + // New atom + NLGEORGES::CFormElmAtom *atomDst = new NLGEORGES::CFormElmAtom (form, NULL, NULL, 0xffffffff); + array.Elements[i] = atomDst; + + // Convert the atom + if (!convertFormAtom (*_atom, *atomDst)) + return false; + } + else + { + const NLOLDGEORGES::CFormBodyEltStruct *_struct = dynamic_cast (listSrc.vpbodyelt[i]); + if (_struct) + { + // New struct + NLGEORGES::CFormElmStruct *_newStruct = new NLGEORGES::CFormElmStruct (form, NULL, NULL, 0xffffffff); + array.Elements[i] = _newStruct; + + // Build this struct + if (!convertFormStruct (*_struct, *_newStruct, form)) + return false; + } + else + { + const NLOLDGEORGES::CFormBodyEltList *_list = dynamic_cast (listSrc.vpbodyelt[i]); + if (_list) + { + // New array + NLGEORGES::CFormElmArray *_array = new NLGEORGES::CFormElmArray (form, NULL, NULL, NULL, NULL, 0xffffffff); + array.Elements[i] = _array; + + // Build this struct + if (!convertFormArray (*_list, *_array, form)) + return false; + } + else + return false; + } + } + } + + return true; +} + +bool convertFormStruct (const NLOLDGEORGES::CFormBodyEltStruct &structSrc, NLGEORGES::CFormElmStruct &dst, NLGEORGES::CForm *form) +{ + // Resize the destination struct + dst.Elements.resize (structSrc.vpbodyelt.size ()); + + // For each sub-element + uint i; + for (i=0; isxname; + + // Cast + const NLOLDGEORGES::CFormBodyEltAtom *_atom = dynamic_cast (structSrc.vpbodyelt[i]); + if (_atom) + { + // New atom + NLGEORGES::CFormElmAtom *atomDst = new NLGEORGES::CFormElmAtom (form, NULL, NULL, 0xffffffff); + dst.Elements[i].Element = atomDst; + + // Convert the atom + if (!convertFormAtom (*_atom, *atomDst)) + return false; + } + else + { + const NLOLDGEORGES::CFormBodyEltStruct *_struct = dynamic_cast (structSrc.vpbodyelt[i]); + if (_struct) + { + // New struct + NLGEORGES::CFormElmStruct *_newStruct = new NLGEORGES::CFormElmStruct (form, NULL, NULL, 0xffffffff); + dst.Elements[i].Element = _newStruct; + + // Build this struct + if (!convertFormStruct (*_struct, *_newStruct, form)) + return false; + } + else + { + const NLOLDGEORGES::CFormBodyEltList *_list = dynamic_cast (structSrc.vpbodyelt[i]); + if (_list) + { + // New array + NLGEORGES::CFormElmArray *_array = new NLGEORGES::CFormElmArray (form, NULL, NULL, NULL, NULL, 0xffffffff); + dst.Elements[i].Element = _array; + + // Build this struct + if (!convertFormArray (*_list, *_array, form)) + return false; + } + else + return false; + } + } + } + + return true; +} + +bool convertFormFile (const char *oldFileName, const char *newFileName) +{ + // Load the form file + + // File stream + CIFile file; + if (file.open (oldFileName)) + { + // Catch errors + try + { + // Init the xml stream + CIXml xmlFile; + xmlFile.init (file); + + // Read the old file format + NLOLDGEORGES::CFormFile oldFileFormat; + oldFileFormat.serial (xmlFile); + + // Get a form pointer + if (oldFileFormat.lform.size () != 1) + { + // Warning + nlwarning ("Invalid old form file format in file %s", oldFileName); + return false; + } + else + { + // Struct ref + NLOLDGEORGES::CFormBodyEltStruct &str = oldFileFormat.lform.begin ()->body; + + // Build this struct + NLGEORGES::CForm newForm; + if (convertFormStruct (str, newForm.Elements, &newForm)) + { + string parent = str.GetParent( 0 ); + if (!parent.empty()) + { + newForm.ParentFilename = parent; + } + + // Some log + newForm.Header.addLog ("File converted from old format"); + newForm.Header.setComments ("Converted from old format"); + + // Output file + COFile output; + if (output.open (newFileName)) + { + try + { + // Xml file + COXml outputXml; + outputXml.init (&output); + + // Write the document + newForm.write (outputXml.getDocument ()); + + // Flush the document + outputXml.flush (); + } + catch (Exception &e) + { + // Warning + nlwarning ("Error while writing xmlFile %s (%s)", oldFileName, e.what ()); + return false; + } + } + else + { + // Warning + nlwarning ("Can't open the dfn file %s for writing", oldFileName); + return false; + } + } + else + { + // Warning + nlwarning ("Invalid old form file format in file %s", oldFileName); + return false; + } + } + } + catch (Exception &e) + { + // Warning + nlwarning ("Error while loading xmlFile %s (%s)", oldFileName, e.what ()); + return false; + } + } + else + { + // Warning + nlwarning ("Can't open the form file %s for reading", oldFileName); + return false; + } + + return true; +} + +using namespace NLOLDGEORGES; + +int main (int argc, void **argv) +{ + new NLMISC::CApplicationContext; + + // Register classes + NLMISC_REGISTER_CLASS (CFormBodyElt); + NLMISC_REGISTER_CLASS (CFormBodyEltAtom); + NLMISC_REGISTER_CLASS (CFormBodyEltList); + NLMISC_REGISTER_CLASS (CFormBodyEltStruct); + + // Help ? + if (argc!=3) + { + printf ("georges_convert [old_file] [new_file]"); + return 0; + } + else + { + strlwr ((const char*)argv[1]); + bool isType = strstr ((const char*)argv[1], ".typ") != NULL; + bool isDfn = strstr ((const char*)argv[1], ".dfn") != NULL; + if (isType) + return convertTypeFile ((const char*) argv[1], (const char*) argv[2]) ? 1 : 0; + else if (isDfn) + return convertDfnFile ((const char*) argv[1], (const char*) argv[2]) ? 1 : 0; + else + return convertFormFile ((const char*) argv[1], (const char*) argv[2]) ? 1 : 0; + } + + return 1; } \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_convert/georges_loader.cpp b/code/ryzom/tools/leveldesign/georges_convert/georges_loader.cpp index ea4890a60..b803c7137 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/georges_loader.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/georges_loader.cpp @@ -1,329 +1,329 @@ -// 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 "stdgeorgesconvert.h" -#include "georges_loader.h" - -#include "nel/misc/path.h" -#include "form_body_elt_atom.h" -#include "form_body_elt_struct.h" -#include "form_body_elt_list.h" -#include "mold_elt_type.h" - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -bool CLoader::_Initialized = false; - -CLoader::CLoader() -{ - ml.SetLoader( this ); - if (!CLoader::_Initialized) - { - NLMISC::IClassable *p = NLMISC::CClassRegistry::create("CFormBodyElt"); - if(p == NULL) - { - NLMISC_REGISTER_CLASS (CFormBodyElt); - } - else - delete p; - p = NLMISC::CClassRegistry::create("CFormBodyEltAtom"); - if(p == NULL) - { - NLMISC_REGISTER_CLASS (CFormBodyEltAtom); - } - else - delete p; - p = NLMISC::CClassRegistry::create("CFormBodyEltList"); - if(p == NULL) - { - NLMISC_REGISTER_CLASS (CFormBodyEltList); - } - else - delete p; - p = NLMISC::CClassRegistry::create("CFormBodyEltStruct"); - if(p == NULL) - { - NLMISC_REGISTER_CLASS (CFormBodyEltStruct); - } - else - delete p; - CLoader::_Initialized = true; - } -} - -CLoader::~CLoader() -{ -} - -void CLoader::LoadForm( CForm& _f, const CStringEx& _sxfullname ) -{ - fl.LoadForm( _f, _sxfullname ); -} - -void CLoader::LoadForm( CForm& _f, const CStringEx& _sxfullname, const CStringEx& _sxdate ) -{ - fl.LoadForm( _f, _sxfullname, _sxdate ); -} - -void CLoader::LoadSearchForm( CForm& _f, const CStringEx& _sxfilename ) -{ - fl.LoadForm( _f, WhereIsForm( _sxfilename ) ); -} - -void CLoader::LoadSearchForm( CForm& _f, const CStringEx& _sxfilename, const CStringEx& _sxdate ) -{ - fl.LoadForm( _f, WhereIsForm( _sxfilename ), _sxdate ); -} - -void CLoader::SaveForm( CForm& _f, const CStringEx& _sxfullname ) -{ - fl.SaveForm( _f, _sxfullname ); -} - -CMoldElt* CLoader::LoadMold( const CStringEx &_sxfilename ) -{ - return( ml.LoadMold( _sxfilename ) ); -} - -CMoldElt* CLoader::LoadMold( const CStringEx &_sxfilename, const CStringEx &_sxdate ) -{ - return( ml.LoadMold( _sxfilename, _sxdate ) ); -} - -void CLoader::SetWorkDirectory( const CStringEx &_sxworkdirectory ) -{ - if( sxworkdirectory != _sxworkdirectory ) - { - sxworkdirectory = _sxworkdirectory; - NLMISC::CPath::removeAllAlternativeSearchPath(); - NLMISC::CPath::addSearchPath( sxworkdirectory, true, true ); - NLMISC::CPath::addSearchPath( sxrootdirectory, true, true ); - } -} - -void CLoader::SetRootDirectory( const CStringEx &_sxrootdirectory ) -{ - if( sxrootdirectory != _sxrootdirectory ) - { - sxrootdirectory = _sxrootdirectory; - NLMISC::CPath::removeAllAlternativeSearchPath(); - NLMISC::CPath::addSearchPath( sxworkdirectory, true, true ); - NLMISC::CPath::addSearchPath( sxrootdirectory, true, true ); - } -} - -CStringEx CLoader::GetWorkDirectory() const -{ - return( sxworkdirectory ); -} - -CStringEx CLoader::GetRootDirectory() const -{ - return( sxrootdirectory ); -} - -CStringEx CLoader::WhereIsDfnTyp( const CStringEx &_sxfilename ) -{ - return( NLMISC::CPath::lookup( _sxfilename, false ) ); -} - -CStringEx CLoader::WhereIsForm( const CStringEx &_sxfilename ) -{ - return( NLMISC::CPath::lookup( _sxfilename, false ) ); -} - -void CLoader::MakeDfn( const CStringEx &_sxfullname, const std::vector< std::pair< CStringEx, CStringEx > >* const _pvdefine ) -{ - CFormFile pff; - CForm f; - - CFormBodyEltStruct* pbody = f.GetBody(); - CFormBodyEltAtom* pfbea; - - if( ( _pvdefine )&&( !_pvdefine->empty() ) ) - for( std::vector< std::pair< CStringEx, CStringEx > >::const_iterator it = _pvdefine->begin(); it != _pvdefine->end(); ++it ) - { - pfbea = new CFormBodyEltAtom; - pfbea->SetName( it->first ); - pfbea->SetValue( it->second ); - pbody->AddElt( pfbea ); - } - - pff.SetForm( f ); - pff.Save( _sxfullname ); -} - -void CLoader::MakeTyp( const CStringEx &_sxfullname, const CStringEx &_sxtype, const CStringEx &_sxformula, const CStringEx &_sxenum, const CStringEx &_sxlow, const CStringEx &_sxhigh, const CStringEx &_sxdefault, const std::vector< std::pair< CStringEx, CStringEx > >* const _pvpredef , const std::vector< std::pair< CStringEx, CStringEx > >* const _pvparent ) -{ - CFormFile pff; - CForm f; - - CFormBodyEltStruct* pbody = f.GetBody(); - CFormBodyEltAtom* pfbea; - CFormBodyEltList* pfbel; - CFormBodyEltStruct* pfbes; - - pfbea = new CFormBodyEltAtom; - pfbea->SetName( "Type" ); - pfbea->SetValue( _sxtype ); - pbody->AddElt( pfbea ); - - pfbea = new CFormBodyEltAtom; - pfbea->SetName( "Enum" ); - pfbea->SetValue( _sxenum ); - pbody->AddElt( pfbea ); - - pfbea = new CFormBodyEltAtom; - pfbea->SetName( "Formula" ); - pfbea->SetValue( _sxformula ); - pbody->AddElt( pfbea ); - - pfbea = new CFormBodyEltAtom; - pfbea->SetName( "Lowlimit" ); - pfbea->SetValue( _sxlow ); - pbody->AddElt( pfbea ); - - pfbea = new CFormBodyEltAtom; - pfbea->SetName( "Highlimit" ); - pfbea->SetValue( _sxhigh ); - pbody->AddElt( pfbea ); - - pfbea = new CFormBodyEltAtom; - pfbea->SetName( "DefaultValue" ); - pfbea->SetValue( _sxdefault ); - pbody->AddElt( pfbea ); - - CStringEx sx; - - if( ( _pvpredef )&&( !_pvpredef->empty() ) ) - { - pfbel = new CFormBodyEltList; - pfbel->SetName( "Predef" ); - int i = 0; - for( std::vector< std::pair< CStringEx, CStringEx > >::const_iterator it = _pvpredef->begin(); it != _pvpredef->end(); ++it ) - { - pfbes = new CFormBodyEltStruct; - sx.format( "#%d", i++ ); - pfbes->SetName( sx ); - pfbel->AddElt( pfbes ); - - pfbea = new CFormBodyEltAtom; - pfbea->SetName( "Designation" ); - pfbea->SetValue( it->first ); - pfbes->AddElt( pfbea ); - - pfbea = new CFormBodyEltAtom; - pfbea->SetName( "Substitute" ); - pfbea->SetValue( it->second ); - pfbes->AddElt( pfbea ); - } - pbody->AddElt( pfbel ); - } - - if( ( _pvparent )&&( !_pvparent->empty() ) ) - { - pfbel = new CFormBodyEltList; - pfbel->SetName( "Parents" ); - int i = 0; - for( std::vector< std::pair< CStringEx, CStringEx > >::const_iterator it = _pvparent->begin(); it != _pvparent->end(); ++it ) - { - pfbes = new CFormBodyEltStruct; - sx.format( "#%d", i++ ); - pfbes->SetName( sx ); - pfbel->AddElt( pfbes ); - - pfbea = new CFormBodyEltAtom; - pfbea->SetName( "Activity" ); - pfbea->SetValue( it->first ); - pfbes->AddElt( pfbea ); - - pfbea = new CFormBodyEltAtom; - pfbea->SetName( "Filename" ); - pfbea->SetValue( it->second ); - pfbes->AddElt( pfbea ); - } - pbody->AddElt( pfbel ); - } - - pff.SetForm( f ); - pff.Save( _sxfullname ); -} - -void CLoader::SetTypPredef( const CStringEx &_sxfilename, const std::vector< CStringEx >& _pvsx ) -{ - CMoldElt*pme = LoadMold( _sxfilename ); - CMoldEltType* pmet = dynamic_cast< CMoldEltType* >( pme ); - pmet->SetTypPredef( _pvsx ); - pmet->Save(); -} - - -/* -CStringEx CLoader::WhereIs( const CStringEx _sxdirectory, const CStringEx _sxfilename ) -{ - if( _sxfilename.empty() ) - return( CStringEx() ); - - _finddata_t info; - CStringEx searchname = _sxdirectory +_sxfilename; - long lhandle = _findfirst( searchname.c_str(), &info ); - if( lhandle != -1 ) - { - _findclose( lhandle ); - return( searchname ); - } - - searchname = CStringEx( _sxdirectory + "*.*" ); - lhandle = _findfirst( searchname.c_str(), &info ); - do - { - if( !(info.attrib & _A_SUBDIR ) ) - continue; - if( ( info.name == "." )||( info.name == ".." ) ) - continue; - CStringEx sxresult = WhereIs( CStringEx( _sxdirectory + info.name ), _sxfilename ); - if( !sxresult.empty() ) - return( sxresult ); - } - while( _findnext( lhandle, &info ) != -1 ); - - _findclose( lhandle ); - return( CStringEx() ); -} - -CStringEx CLoader::WhereIsDfnTyp( const CStringEx _sxfilename ) -{ - CStringEx sxfullname = WhereIs( CStringEx( sxworkdirectory +"dfn/" ), _sxfilename ); - if( sxfullname.empty() && ( sxrootdirectory != sxworkdirectory ) ) - sxfullname = WhereIs( CStringEx( sxrootdirectory +"dfn/" ), _sxfilename ); - return( sxfullname ); -} - -CStringEx CLoader::WhereIsForm( const CStringEx _sxfilename ) -{ - CStringEx sxfullname = WhereIs( sxworkdirectory, _sxfilename ); - if( sxfullname.empty() && ( sxrootdirectory != sxworkdirectory ) ) - sxfullname = WhereIs( sxrootdirectory, _sxfilename ); - return( sxfullname ); -} -*/ - +// 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 "stdgeorgesconvert.h" +#include "georges_loader.h" + +#include "nel/misc/path.h" +#include "form_body_elt_atom.h" +#include "form_body_elt_struct.h" +#include "form_body_elt_list.h" +#include "mold_elt_type.h" + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +bool CLoader::_Initialized = false; + +CLoader::CLoader() +{ + ml.SetLoader( this ); + if (!CLoader::_Initialized) + { + NLMISC::IClassable *p = NLMISC::CClassRegistry::create("CFormBodyElt"); + if(p == NULL) + { + NLMISC_REGISTER_CLASS (CFormBodyElt); + } + else + delete p; + p = NLMISC::CClassRegistry::create("CFormBodyEltAtom"); + if(p == NULL) + { + NLMISC_REGISTER_CLASS (CFormBodyEltAtom); + } + else + delete p; + p = NLMISC::CClassRegistry::create("CFormBodyEltList"); + if(p == NULL) + { + NLMISC_REGISTER_CLASS (CFormBodyEltList); + } + else + delete p; + p = NLMISC::CClassRegistry::create("CFormBodyEltStruct"); + if(p == NULL) + { + NLMISC_REGISTER_CLASS (CFormBodyEltStruct); + } + else + delete p; + CLoader::_Initialized = true; + } +} + +CLoader::~CLoader() +{ +} + +void CLoader::LoadForm( CForm& _f, const CStringEx& _sxfullname ) +{ + fl.LoadForm( _f, _sxfullname ); +} + +void CLoader::LoadForm( CForm& _f, const CStringEx& _sxfullname, const CStringEx& _sxdate ) +{ + fl.LoadForm( _f, _sxfullname, _sxdate ); +} + +void CLoader::LoadSearchForm( CForm& _f, const CStringEx& _sxfilename ) +{ + fl.LoadForm( _f, WhereIsForm( _sxfilename ) ); +} + +void CLoader::LoadSearchForm( CForm& _f, const CStringEx& _sxfilename, const CStringEx& _sxdate ) +{ + fl.LoadForm( _f, WhereIsForm( _sxfilename ), _sxdate ); +} + +void CLoader::SaveForm( CForm& _f, const CStringEx& _sxfullname ) +{ + fl.SaveForm( _f, _sxfullname ); +} + +CMoldElt* CLoader::LoadMold( const CStringEx &_sxfilename ) +{ + return( ml.LoadMold( _sxfilename ) ); +} + +CMoldElt* CLoader::LoadMold( const CStringEx &_sxfilename, const CStringEx &_sxdate ) +{ + return( ml.LoadMold( _sxfilename, _sxdate ) ); +} + +void CLoader::SetWorkDirectory( const CStringEx &_sxworkdirectory ) +{ + if( sxworkdirectory != _sxworkdirectory ) + { + sxworkdirectory = _sxworkdirectory; + NLMISC::CPath::removeAllAlternativeSearchPath(); + NLMISC::CPath::addSearchPath( sxworkdirectory, true, true ); + NLMISC::CPath::addSearchPath( sxrootdirectory, true, true ); + } +} + +void CLoader::SetRootDirectory( const CStringEx &_sxrootdirectory ) +{ + if( sxrootdirectory != _sxrootdirectory ) + { + sxrootdirectory = _sxrootdirectory; + NLMISC::CPath::removeAllAlternativeSearchPath(); + NLMISC::CPath::addSearchPath( sxworkdirectory, true, true ); + NLMISC::CPath::addSearchPath( sxrootdirectory, true, true ); + } +} + +CStringEx CLoader::GetWorkDirectory() const +{ + return( sxworkdirectory ); +} + +CStringEx CLoader::GetRootDirectory() const +{ + return( sxrootdirectory ); +} + +CStringEx CLoader::WhereIsDfnTyp( const CStringEx &_sxfilename ) +{ + return( NLMISC::CPath::lookup( _sxfilename, false ) ); +} + +CStringEx CLoader::WhereIsForm( const CStringEx &_sxfilename ) +{ + return( NLMISC::CPath::lookup( _sxfilename, false ) ); +} + +void CLoader::MakeDfn( const CStringEx &_sxfullname, const std::vector< std::pair< CStringEx, CStringEx > >* const _pvdefine ) +{ + CFormFile pff; + CForm f; + + CFormBodyEltStruct* pbody = f.GetBody(); + CFormBodyEltAtom* pfbea; + + if( ( _pvdefine )&&( !_pvdefine->empty() ) ) + for( std::vector< std::pair< CStringEx, CStringEx > >::const_iterator it = _pvdefine->begin(); it != _pvdefine->end(); ++it ) + { + pfbea = new CFormBodyEltAtom; + pfbea->SetName( it->first ); + pfbea->SetValue( it->second ); + pbody->AddElt( pfbea ); + } + + pff.SetForm( f ); + pff.Save( _sxfullname ); +} + +void CLoader::MakeTyp( const CStringEx &_sxfullname, const CStringEx &_sxtype, const CStringEx &_sxformula, const CStringEx &_sxenum, const CStringEx &_sxlow, const CStringEx &_sxhigh, const CStringEx &_sxdefault, const std::vector< std::pair< CStringEx, CStringEx > >* const _pvpredef , const std::vector< std::pair< CStringEx, CStringEx > >* const _pvparent ) +{ + CFormFile pff; + CForm f; + + CFormBodyEltStruct* pbody = f.GetBody(); + CFormBodyEltAtom* pfbea; + CFormBodyEltList* pfbel; + CFormBodyEltStruct* pfbes; + + pfbea = new CFormBodyEltAtom; + pfbea->SetName( "Type" ); + pfbea->SetValue( _sxtype ); + pbody->AddElt( pfbea ); + + pfbea = new CFormBodyEltAtom; + pfbea->SetName( "Enum" ); + pfbea->SetValue( _sxenum ); + pbody->AddElt( pfbea ); + + pfbea = new CFormBodyEltAtom; + pfbea->SetName( "Formula" ); + pfbea->SetValue( _sxformula ); + pbody->AddElt( pfbea ); + + pfbea = new CFormBodyEltAtom; + pfbea->SetName( "Lowlimit" ); + pfbea->SetValue( _sxlow ); + pbody->AddElt( pfbea ); + + pfbea = new CFormBodyEltAtom; + pfbea->SetName( "Highlimit" ); + pfbea->SetValue( _sxhigh ); + pbody->AddElt( pfbea ); + + pfbea = new CFormBodyEltAtom; + pfbea->SetName( "DefaultValue" ); + pfbea->SetValue( _sxdefault ); + pbody->AddElt( pfbea ); + + CStringEx sx; + + if( ( _pvpredef )&&( !_pvpredef->empty() ) ) + { + pfbel = new CFormBodyEltList; + pfbel->SetName( "Predef" ); + int i = 0; + for( std::vector< std::pair< CStringEx, CStringEx > >::const_iterator it = _pvpredef->begin(); it != _pvpredef->end(); ++it ) + { + pfbes = new CFormBodyEltStruct; + sx.format( "#%d", i++ ); + pfbes->SetName( sx ); + pfbel->AddElt( pfbes ); + + pfbea = new CFormBodyEltAtom; + pfbea->SetName( "Designation" ); + pfbea->SetValue( it->first ); + pfbes->AddElt( pfbea ); + + pfbea = new CFormBodyEltAtom; + pfbea->SetName( "Substitute" ); + pfbea->SetValue( it->second ); + pfbes->AddElt( pfbea ); + } + pbody->AddElt( pfbel ); + } + + if( ( _pvparent )&&( !_pvparent->empty() ) ) + { + pfbel = new CFormBodyEltList; + pfbel->SetName( "Parents" ); + int i = 0; + for( std::vector< std::pair< CStringEx, CStringEx > >::const_iterator it = _pvparent->begin(); it != _pvparent->end(); ++it ) + { + pfbes = new CFormBodyEltStruct; + sx.format( "#%d", i++ ); + pfbes->SetName( sx ); + pfbel->AddElt( pfbes ); + + pfbea = new CFormBodyEltAtom; + pfbea->SetName( "Activity" ); + pfbea->SetValue( it->first ); + pfbes->AddElt( pfbea ); + + pfbea = new CFormBodyEltAtom; + pfbea->SetName( "Filename" ); + pfbea->SetValue( it->second ); + pfbes->AddElt( pfbea ); + } + pbody->AddElt( pfbel ); + } + + pff.SetForm( f ); + pff.Save( _sxfullname ); +} + +void CLoader::SetTypPredef( const CStringEx &_sxfilename, const std::vector< CStringEx >& _pvsx ) +{ + CMoldElt*pme = LoadMold( _sxfilename ); + CMoldEltType* pmet = dynamic_cast< CMoldEltType* >( pme ); + pmet->SetTypPredef( _pvsx ); + pmet->Save(); +} + + +/* +CStringEx CLoader::WhereIs( const CStringEx _sxdirectory, const CStringEx _sxfilename ) +{ + if( _sxfilename.empty() ) + return( CStringEx() ); + + _finddata_t info; + CStringEx searchname = _sxdirectory +_sxfilename; + long lhandle = _findfirst( searchname.c_str(), &info ); + if( lhandle != -1 ) + { + _findclose( lhandle ); + return( searchname ); + } + + searchname = CStringEx( _sxdirectory + "*.*" ); + lhandle = _findfirst( searchname.c_str(), &info ); + do + { + if( !(info.attrib & _A_SUBDIR ) ) + continue; + if( ( info.name == "." )||( info.name == ".." ) ) + continue; + CStringEx sxresult = WhereIs( CStringEx( _sxdirectory + info.name ), _sxfilename ); + if( !sxresult.empty() ) + return( sxresult ); + } + while( _findnext( lhandle, &info ) != -1 ); + + _findclose( lhandle ); + return( CStringEx() ); +} + +CStringEx CLoader::WhereIsDfnTyp( const CStringEx _sxfilename ) +{ + CStringEx sxfullname = WhereIs( CStringEx( sxworkdirectory +"dfn/" ), _sxfilename ); + if( sxfullname.empty() && ( sxrootdirectory != sxworkdirectory ) ) + sxfullname = WhereIs( CStringEx( sxrootdirectory +"dfn/" ), _sxfilename ); + return( sxfullname ); +} + +CStringEx CLoader::WhereIsForm( const CStringEx _sxfilename ) +{ + CStringEx sxfullname = WhereIs( sxworkdirectory, _sxfilename ); + if( sxfullname.empty() && ( sxrootdirectory != sxworkdirectory ) ) + sxfullname = WhereIs( sxrootdirectory, _sxfilename ); + return( sxfullname ); +} +*/ + } \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_convert/georges_loader.h b/code/ryzom/tools/leveldesign/georges_convert/georges_loader.h index 26f1fbd3d..7529be777 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/georges_loader.h +++ b/code/ryzom/tools/leveldesign/georges_convert/georges_loader.h @@ -1,66 +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 . - -#ifndef NLGEORGES_LOADER_H -#define NLGEORGES_LOADER_H - -#include "form_loader.h" -#include "mold_loader.h" - -namespace NLOLDGEORGES -{ - -class CLoader -{ - static bool _Initialized; -protected: - CFormLoader fl; - CMoldLoader ml; - CStringEx sxworkdirectory; - CStringEx sxrootdirectory; - CStringEx WhereIs( const CStringEx &_sxdirectory, const CStringEx &_sxfilename ); - -public: - CLoader(); - virtual ~CLoader(); - - void LoadForm( CForm& _f, const CStringEx& _sxfullname ); - void LoadForm( CForm& _f, const CStringEx& _sxfullname, const CStringEx& _sxdate ); - void LoadSearchForm( CForm& _f, const CStringEx& _sxfilename ); - void LoadSearchForm( CForm& _f, const CStringEx& _sxfilename, const CStringEx& _sxdate ); - void SaveForm( CForm& _f, const CStringEx& _sxfullename ); - CMoldElt* LoadMold( const CStringEx &_sxfilename ); - CMoldElt* LoadMold( const CStringEx &_sxfilename, const CStringEx &_sxdate ); - - CStringEx WhereIsDfnTyp( const CStringEx &_sxfilename ); - CStringEx WhereIsForm( const CStringEx &_sxfilename ); - - CStringEx GetWorkDirectory() const; - CStringEx GetRootDirectory() const; - -// interface: - void SetWorkDirectory( const CStringEx &_sxworkdirectory ); - void SetRootDirectory( const CStringEx &_sxrootdirectory ); - void SetTypPredef( const CStringEx& _sxfilename, const std::vector< CStringEx >& _pvsx ); - -// temporaire: - void MakeDfn( const CStringEx &_sxfullname, const std::vector< std::pair< CStringEx, CStringEx > >* const _pvdefine = 0 ); - void MakeTyp( const CStringEx &_sxfullname, const CStringEx &_sxtype, const CStringEx &_sxformula, const CStringEx &_sxenum, const CStringEx &_sxlow, const CStringEx &_sxhigh, const CStringEx &_sxdefault, const std::vector< std::pair< CStringEx, CStringEx > >* const _pvpredef = 0, const std::vector< std::pair< CStringEx, CStringEx > >* const _pvparent = 0 ); -}; - -} // NLGEORGES - -#endif // NLGEORGES_LOADER_H +// 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 NLGEORGES_LOADER_H +#define NLGEORGES_LOADER_H + +#include "form_loader.h" +#include "mold_loader.h" + +namespace NLOLDGEORGES +{ + +class CLoader +{ + static bool _Initialized; +protected: + CFormLoader fl; + CMoldLoader ml; + CStringEx sxworkdirectory; + CStringEx sxrootdirectory; + CStringEx WhereIs( const CStringEx &_sxdirectory, const CStringEx &_sxfilename ); + +public: + CLoader(); + virtual ~CLoader(); + + void LoadForm( CForm& _f, const CStringEx& _sxfullname ); + void LoadForm( CForm& _f, const CStringEx& _sxfullname, const CStringEx& _sxdate ); + void LoadSearchForm( CForm& _f, const CStringEx& _sxfilename ); + void LoadSearchForm( CForm& _f, const CStringEx& _sxfilename, const CStringEx& _sxdate ); + void SaveForm( CForm& _f, const CStringEx& _sxfullename ); + CMoldElt* LoadMold( const CStringEx &_sxfilename ); + CMoldElt* LoadMold( const CStringEx &_sxfilename, const CStringEx &_sxdate ); + + CStringEx WhereIsDfnTyp( const CStringEx &_sxfilename ); + CStringEx WhereIsForm( const CStringEx &_sxfilename ); + + CStringEx GetWorkDirectory() const; + CStringEx GetRootDirectory() const; + +// interface: + void SetWorkDirectory( const CStringEx &_sxworkdirectory ); + void SetRootDirectory( const CStringEx &_sxrootdirectory ); + void SetTypPredef( const CStringEx& _sxfilename, const std::vector< CStringEx >& _pvsx ); + +// temporaire: + void MakeDfn( const CStringEx &_sxfullname, const std::vector< std::pair< CStringEx, CStringEx > >* const _pvdefine = 0 ); + void MakeTyp( const CStringEx &_sxfullname, const CStringEx &_sxtype, const CStringEx &_sxformula, const CStringEx &_sxenum, const CStringEx &_sxlow, const CStringEx &_sxhigh, const CStringEx &_sxdefault, const std::vector< std::pair< CStringEx, CStringEx > >* const _pvpredef = 0, const std::vector< std::pair< CStringEx, CStringEx > >* const _pvparent = 0 ); +}; + +} // NLGEORGES + +#endif // NLGEORGES_LOADER_H diff --git a/code/ryzom/tools/leveldesign/georges_convert/item.cpp b/code/ryzom/tools/leveldesign/georges_convert/item.cpp index 4c0f79235..0f703828a 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/item.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/item.cpp @@ -1,475 +1,475 @@ -// 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 "stdgeorgesconvert.h" -#include "item.h" -#include "georges_loader.h" -#include "mold_elt_define.h" -#include "mold_elt_type.h" -#include "item_elt_atom.h" -#include "item_elt_struct.h" -#include "item_elt_list.h" -#include "common.h" - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CItem:: CItem() -{ - pitemes = 0; -// pitemelparents = 0; -// pitemeacomments = 0; -} - -CItem::~CItem() -{ - Clear(); -} - -void CItem::Clear() -{ - if( pitemes ) - delete( pitemes ); - pitemes = 0; - vsxparents.clear(); -/* - if( pitemelparents ) - delete( pitemelparents ); - pitemes = 0; - if( pitemeacomments ) - delete( pitemeacomments ); - pitemes = 0; -*/ -} - -void CItem::SetLoader( CLoader* const _pl ) -{ - nlassert( _pl ); - pl = _pl; -} - -void CItem::Load( const CStringEx& _sxfullname ) -{ - Clear(); - - // Load the form - CForm form, formcurrent, formparent; - pl->LoadForm( formcurrent, _sxfullname ); - - // Load Parents - unsigned int i = 0; - CStringEx sxparent = formcurrent.GetParent( 0 ); - CStringEx sxactivity = formcurrent.GetActivity( 0 ); - while( !sxparent.empty() ) - { - vsxparents.push_back( std::make_pair( sxactivity, sxparent ) ); - if( sxactivity == "true" ) - { - pl->LoadSearchForm( form, sxparent ); - formparent += form; - } - i++; - sxparent = formcurrent.GetParent( i ); - sxactivity = formcurrent.GetActivity( i ); - } - - // Find the name of the dfn file - int ipos = _sxfullname.reverse_find('.'); - if( ipos == -1 ) - return; - moldfilename = _sxfullname.get_right(_sxfullname.length()-ipos-1); - moldfilename += ".dfn"; - - // Load the mold and build the item's tree - CMoldElt* pme = pl->LoadMold( moldfilename ); - CMoldEltDefine* pmed = dynamic_cast< CMoldEltDefine* >( pme ); - nlassert( pmed ); - pitemes = new CItemEltStruct( pl ); - pitemes->BuildItem( pmed ); - - // Fill the tree with parents' form fields - pitemes->FillParent( formparent.GetBody() ); - - // Fill the tree with current's form - pitemes->FillCurrent( formcurrent.GetBody() ); -} - -// Convert CItem to a CForm (in is this) -void CItem::MakeForm (CForm &out) -{ - if( !pitemes ) - return; - pitemes->BuildForm( out.GetBody(), vsxparents ); -} - -// Convert CForm to CItem (out is this) -void CItem::MakeItem (CForm &in) -{ - CForm form, formparent; - - Clear(); - unsigned int i = 0; - CStringEx sxparent = in.GetParent( 0 ); - CStringEx sxactivity = in.GetActivity( 0 ); - while( !sxparent.empty() ) - { - vsxparents.push_back( std::make_pair( sxactivity, sxparent ) ); - if( sxactivity == "true" ) - { - pl->LoadSearchForm( form, sxparent ); - formparent += form; - } - i++; - sxparent = in.GetParent( i ); - sxactivity = in.GetActivity( i ); - } - - CMoldElt* pme = pl->LoadMold( moldfilename ); - CMoldEltDefine* pmed = dynamic_cast< CMoldEltDefine* >( pme ); - nlassert( pmed ); - pitemes = new CItemEltStruct( pl ); - pitemes->BuildItem( pmed ); - - pitemes->FillParent( formparent.GetBody() ); - pitemes->FillCurrent( in.GetBody() ); -} - -void CItem::VirtualSaveLoad() -{ -//-------save - if( !pitemes ) - return; - CForm form, formcurrent, formparent; - pitemes->BuildForm( formcurrent.GetBody(), vsxparents ); -//------load - Clear(); - unsigned int i = 0; - CStringEx sxparent = formcurrent.GetParent( 0 ); - CStringEx sxactivity = formcurrent.GetActivity( 0 ); - while( !sxparent.empty() ) - { - vsxparents.push_back( std::make_pair( sxactivity, sxparent ) ); - if( sxactivity == "true" ) - { - pl->LoadSearchForm( form, sxparent ); - formparent += form; - } - i++; - sxparent = formcurrent.GetParent( i ); - sxactivity = formcurrent.GetActivity( i ); - } - - CMoldElt* pme = pl->LoadMold( moldfilename ); - CMoldEltDefine* pmed = dynamic_cast< CMoldEltDefine* >( pme ); - nlassert( pmed ); - pitemes = new CItemEltStruct( pl ); - pitemes->BuildItem( pmed ); - - pitemes->FillParent( formparent.GetBody() ); - pitemes->FillCurrent( formcurrent.GetBody() ); -} - -void CItem::New( const CStringEx& _sxdfnfilename ) -{ - Clear(); - - moldfilename = _sxdfnfilename; - - CMoldElt* pme = pl->LoadMold( _sxdfnfilename ); - CMoldEltDefine* pmed = dynamic_cast< CMoldEltDefine* >( pme ); - nlassert( pmed ); - pitemes = new CItemEltStruct( pl ); - pitemes->BuildItem( pmed ); -} - -void CItem::Load( const CStringEx& _sxfilename, const CStringEx _sxdate ) -{ -} - -void CItem::Save( const CStringEx& _sxfilename ) -{ - if( !pitemes ) - return; - CForm form; - pitemes->BuildForm( form.GetBody(), vsxparents ); - pl->SaveForm( form, _sxfilename ); -} - -CItemElt* CItem::GetElt( const unsigned int _index ) const -{ - if( pitemes ) - return( pitemes->GetElt( _index ) ); - return( 0 ); -} - -CItemElt* CItem::GetElt( const CStringEx _sxname ) const -{ - if( pitemes ) - return( pitemes->GetElt( _sxname ) ); - return( 0 ); -} - -void CItem::SetCurrentValue( const unsigned int _index, const CStringEx s ) -{ - CItemElt* pie = GetElt( _index ); - if( !pie ) - return; - pie->SetCurrentValue( s ); - pitemes->SetModified( _index ); -} - -uint CItem::GetNbElt() const -{ - if( pitemes ) - return( pitemes->GetNbElt() ); - return( 0 ); -} - -uint CItem::GetNbParents() const -{ - return (uint)vsxparents.size(); -} - -uint CItem::GetNbElt( const unsigned int _index ) const -{ - CItemElt* pie = GetElt( _index ); - if( !pie ) - return( 0 ); - return( pie->GetNbElt() ); -} - -uint CItem::GetInfos( const unsigned int _index ) const -{ - CItemElt* pie = GetElt( _index ); - if( !pie ) - return( 0 ); - return( pie->GetInfos() ); -} - -CStringEx CItem::GetName( const unsigned int _index ) const -{ - - CItemElt* pie = GetElt( _index ); - if( !pie ) - { - CStringEx object; - return( object ); - } - return( pie->GetName() ); -} - -CStringEx CItem::GetCurrentResult( const unsigned int _index ) const -{ - CItemElt* pie = GetElt( _index ); - if( !pie ) - { - CStringEx object; - return( object ); - } - return( pie->GetCurrentResult() ); -} - -CStringEx CItem::GetCurrentValue( const unsigned int _index ) const -{ - CItemElt* pie = GetElt( _index ); - if( !pie ) - { - CStringEx object; - return( object ); - } - return( pie->GetCurrentValue() ); -} - -bool CItem::Update() -{ - if( !pitemes ) - return false; - bool b = false; - unsigned int i = 0; - CItemElt* pie = pitemes->GetElt( i++ ); - while( pie ) - { - CStringEx sxold = pie->GetCurrentValue(); - pie->SetParentValue( pie->GetParentValue() ); - pie->SetCurrentValue( pie->GetCurrentValue() ); - b |= ( sxold != pie->GetCurrentValue() ); - pie = pitemes->GetElt( i++ ); - } - return b; -} - -CStringEx CItem::GetFormula( const unsigned int _index ) const -{ - CItemElt* pie = GetElt( _index ); - if( !pie ) - { - CStringEx object; - return( object ); - } - return( pie->GetFormula() ); -} - -bool CItem::IsEnum( const unsigned int _index ) const -{ - CItemElt* pie = GetElt( _index ); - if( !pie ) - return( false ); - return( ( pie->GetInfos() & ITEM_ISENUM ) != 0 ); -} - -bool CItem::IsPredef( const unsigned int _index ) const -{ - CItemElt* pie = GetElt( _index ); - if( !pie ) - return( false ); - CItemEltAtom* piea = dynamic_cast< CItemEltAtom* >( pie ); - if( !piea ) - return( false ); - CMoldEltType* pmet = piea->GetMoldType(); - CStringEx sx = pmet->GetPredefDesignation( 0 ); - return( !sx.empty() ); -} - -bool CItem::CanEdit( const unsigned int _index ) const -{ - CItemElt* pie = GetElt( _index ); - if( !pie ) - return( false ); - CItemEltAtom* piea = dynamic_cast< CItemEltAtom* >( pie ); - if( !piea ) - return( false ); - return( !( pie->GetInfos() & ITEM_ISENUM ) ); -} - -void CItem::GetListPredef( const unsigned int _index, std::vector< CStringEx >& _vsx ) const -{ - CItemElt* pie = GetElt( _index ); - if( !pie ) - return; - CItemEltAtom* piea = dynamic_cast< CItemEltAtom* >( pie ); - if( !piea ) - return; - - CMoldEltType* pmet = piea->GetMoldType(); - - unsigned int i = 0; - CStringEx sx = pmet->GetPredefDesignation( i++ ); - while( !sx.empty() ) - { - _vsx.push_back( sx ); - sx = pmet->GetPredefDesignation( i++ ); - } -} - -CStringEx CItem::GetParent( const unsigned int _index ) const -{ - if( _index >= vsxparents.size() ) - { - CStringEx object; - return( object ); - } - return( vsxparents[_index].second ); -} - -void CItem::SetParent( const unsigned int _index, const CStringEx _sx ) -{ - if( _index >= vsxparents.size() ) - return; - vsxparents[_index].second = _sx; -} - -CStringEx CItem::GetActivity( const unsigned int _index ) const -{ - if( _index >= vsxparents.size() ) - { - CStringEx object; - return( object ); - } - return( vsxparents[_index].first ); -} - -void CItem::SetActivity( const unsigned int _index, const CStringEx _sx ) -{ - if( _index >= vsxparents.size() ) - return; - vsxparents[_index].first = _sx; -} - -void CItem::AddList( const unsigned int _index ) const -{ - CItemElt* pie = GetElt( _index ); - if( !pie ) - return; - CItemEltList* piel = dynamic_cast< CItemEltList* >( pie ); - if( !piel ) - return; - piel->NewElt(); -} -/* -void CItem::AddListChild( const unsigned int _index ) const -{ - CItemElt* pie = GetElt( _index ); - if( !pie ) - return; - CItemElt* piep = pie->GetListParent(); - if( !piep ) - return; - CItemEltList* piel = dynamic_cast< CItemEltList* >( piep ); - if( !piel ) - return; - piel->AddElt( pie ); -} -*/ -void CItem::DelListChild( const unsigned int _index ) const -{ - CItemElt* pie = GetElt( _index ); - if( !pie ) - return; - CItemElt* piep = pie->GetListParent(); - if( !piep ) - return; - CItemEltList* piel = dynamic_cast< CItemEltList* >( piep ); - if( !piel ) - return; - piel->DelElt( pie ); -} - -void CItem::AddParent( const unsigned int _index ) -{ - vsxparents.push_back( std::make_pair( CStringEx("false"), CStringEx("filename.extension") ) ); -} - -void CItem::DelParent( const unsigned int _index ) -{ - unsigned int i = 0; - for( std::vector< std::pair< CStringEx, CStringEx > >::iterator it = vsxparents.begin(); it != vsxparents.end(); ++it ) - if( i++ == _index ) - { - vsxparents.erase( it ); - return; - } -} - -void CItem::ClearParents () -{ - vsxparents.clear(); -} - -} +// 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 "stdgeorgesconvert.h" +#include "item.h" +#include "georges_loader.h" +#include "mold_elt_define.h" +#include "mold_elt_type.h" +#include "item_elt_atom.h" +#include "item_elt_struct.h" +#include "item_elt_list.h" +#include "common.h" + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CItem:: CItem() +{ + pitemes = 0; +// pitemelparents = 0; +// pitemeacomments = 0; +} + +CItem::~CItem() +{ + Clear(); +} + +void CItem::Clear() +{ + if( pitemes ) + delete( pitemes ); + pitemes = 0; + vsxparents.clear(); +/* + if( pitemelparents ) + delete( pitemelparents ); + pitemes = 0; + if( pitemeacomments ) + delete( pitemeacomments ); + pitemes = 0; +*/ +} + +void CItem::SetLoader( CLoader* const _pl ) +{ + nlassert( _pl ); + pl = _pl; +} + +void CItem::Load( const CStringEx& _sxfullname ) +{ + Clear(); + + // Load the form + CForm form, formcurrent, formparent; + pl->LoadForm( formcurrent, _sxfullname ); + + // Load Parents + unsigned int i = 0; + CStringEx sxparent = formcurrent.GetParent( 0 ); + CStringEx sxactivity = formcurrent.GetActivity( 0 ); + while( !sxparent.empty() ) + { + vsxparents.push_back( std::make_pair( sxactivity, sxparent ) ); + if( sxactivity == "true" ) + { + pl->LoadSearchForm( form, sxparent ); + formparent += form; + } + i++; + sxparent = formcurrent.GetParent( i ); + sxactivity = formcurrent.GetActivity( i ); + } + + // Find the name of the dfn file + int ipos = _sxfullname.reverse_find('.'); + if( ipos == -1 ) + return; + moldfilename = _sxfullname.get_right(_sxfullname.length()-ipos-1); + moldfilename += ".dfn"; + + // Load the mold and build the item's tree + CMoldElt* pme = pl->LoadMold( moldfilename ); + CMoldEltDefine* pmed = dynamic_cast< CMoldEltDefine* >( pme ); + nlassert( pmed ); + pitemes = new CItemEltStruct( pl ); + pitemes->BuildItem( pmed ); + + // Fill the tree with parents' form fields + pitemes->FillParent( formparent.GetBody() ); + + // Fill the tree with current's form + pitemes->FillCurrent( formcurrent.GetBody() ); +} + +// Convert CItem to a CForm (in is this) +void CItem::MakeForm (CForm &out) +{ + if( !pitemes ) + return; + pitemes->BuildForm( out.GetBody(), vsxparents ); +} + +// Convert CForm to CItem (out is this) +void CItem::MakeItem (CForm &in) +{ + CForm form, formparent; + + Clear(); + unsigned int i = 0; + CStringEx sxparent = in.GetParent( 0 ); + CStringEx sxactivity = in.GetActivity( 0 ); + while( !sxparent.empty() ) + { + vsxparents.push_back( std::make_pair( sxactivity, sxparent ) ); + if( sxactivity == "true" ) + { + pl->LoadSearchForm( form, sxparent ); + formparent += form; + } + i++; + sxparent = in.GetParent( i ); + sxactivity = in.GetActivity( i ); + } + + CMoldElt* pme = pl->LoadMold( moldfilename ); + CMoldEltDefine* pmed = dynamic_cast< CMoldEltDefine* >( pme ); + nlassert( pmed ); + pitemes = new CItemEltStruct( pl ); + pitemes->BuildItem( pmed ); + + pitemes->FillParent( formparent.GetBody() ); + pitemes->FillCurrent( in.GetBody() ); +} + +void CItem::VirtualSaveLoad() +{ +//-------save + if( !pitemes ) + return; + CForm form, formcurrent, formparent; + pitemes->BuildForm( formcurrent.GetBody(), vsxparents ); +//------load + Clear(); + unsigned int i = 0; + CStringEx sxparent = formcurrent.GetParent( 0 ); + CStringEx sxactivity = formcurrent.GetActivity( 0 ); + while( !sxparent.empty() ) + { + vsxparents.push_back( std::make_pair( sxactivity, sxparent ) ); + if( sxactivity == "true" ) + { + pl->LoadSearchForm( form, sxparent ); + formparent += form; + } + i++; + sxparent = formcurrent.GetParent( i ); + sxactivity = formcurrent.GetActivity( i ); + } + + CMoldElt* pme = pl->LoadMold( moldfilename ); + CMoldEltDefine* pmed = dynamic_cast< CMoldEltDefine* >( pme ); + nlassert( pmed ); + pitemes = new CItemEltStruct( pl ); + pitemes->BuildItem( pmed ); + + pitemes->FillParent( formparent.GetBody() ); + pitemes->FillCurrent( formcurrent.GetBody() ); +} + +void CItem::New( const CStringEx& _sxdfnfilename ) +{ + Clear(); + + moldfilename = _sxdfnfilename; + + CMoldElt* pme = pl->LoadMold( _sxdfnfilename ); + CMoldEltDefine* pmed = dynamic_cast< CMoldEltDefine* >( pme ); + nlassert( pmed ); + pitemes = new CItemEltStruct( pl ); + pitemes->BuildItem( pmed ); +} + +void CItem::Load( const CStringEx& _sxfilename, const CStringEx _sxdate ) +{ +} + +void CItem::Save( const CStringEx& _sxfilename ) +{ + if( !pitemes ) + return; + CForm form; + pitemes->BuildForm( form.GetBody(), vsxparents ); + pl->SaveForm( form, _sxfilename ); +} + +CItemElt* CItem::GetElt( const unsigned int _index ) const +{ + if( pitemes ) + return( pitemes->GetElt( _index ) ); + return( 0 ); +} + +CItemElt* CItem::GetElt( const CStringEx _sxname ) const +{ + if( pitemes ) + return( pitemes->GetElt( _sxname ) ); + return( 0 ); +} + +void CItem::SetCurrentValue( const unsigned int _index, const CStringEx s ) +{ + CItemElt* pie = GetElt( _index ); + if( !pie ) + return; + pie->SetCurrentValue( s ); + pitemes->SetModified( _index ); +} + +uint CItem::GetNbElt() const +{ + if( pitemes ) + return( pitemes->GetNbElt() ); + return( 0 ); +} + +uint CItem::GetNbParents() const +{ + return (uint)vsxparents.size(); +} + +uint CItem::GetNbElt( const unsigned int _index ) const +{ + CItemElt* pie = GetElt( _index ); + if( !pie ) + return( 0 ); + return( pie->GetNbElt() ); +} + +uint CItem::GetInfos( const unsigned int _index ) const +{ + CItemElt* pie = GetElt( _index ); + if( !pie ) + return( 0 ); + return( pie->GetInfos() ); +} + +CStringEx CItem::GetName( const unsigned int _index ) const +{ + + CItemElt* pie = GetElt( _index ); + if( !pie ) + { + CStringEx object; + return( object ); + } + return( pie->GetName() ); +} + +CStringEx CItem::GetCurrentResult( const unsigned int _index ) const +{ + CItemElt* pie = GetElt( _index ); + if( !pie ) + { + CStringEx object; + return( object ); + } + return( pie->GetCurrentResult() ); +} + +CStringEx CItem::GetCurrentValue( const unsigned int _index ) const +{ + CItemElt* pie = GetElt( _index ); + if( !pie ) + { + CStringEx object; + return( object ); + } + return( pie->GetCurrentValue() ); +} + +bool CItem::Update() +{ + if( !pitemes ) + return false; + bool b = false; + unsigned int i = 0; + CItemElt* pie = pitemes->GetElt( i++ ); + while( pie ) + { + CStringEx sxold = pie->GetCurrentValue(); + pie->SetParentValue( pie->GetParentValue() ); + pie->SetCurrentValue( pie->GetCurrentValue() ); + b |= ( sxold != pie->GetCurrentValue() ); + pie = pitemes->GetElt( i++ ); + } + return b; +} + +CStringEx CItem::GetFormula( const unsigned int _index ) const +{ + CItemElt* pie = GetElt( _index ); + if( !pie ) + { + CStringEx object; + return( object ); + } + return( pie->GetFormula() ); +} + +bool CItem::IsEnum( const unsigned int _index ) const +{ + CItemElt* pie = GetElt( _index ); + if( !pie ) + return( false ); + return( ( pie->GetInfos() & ITEM_ISENUM ) != 0 ); +} + +bool CItem::IsPredef( const unsigned int _index ) const +{ + CItemElt* pie = GetElt( _index ); + if( !pie ) + return( false ); + CItemEltAtom* piea = dynamic_cast< CItemEltAtom* >( pie ); + if( !piea ) + return( false ); + CMoldEltType* pmet = piea->GetMoldType(); + CStringEx sx = pmet->GetPredefDesignation( 0 ); + return( !sx.empty() ); +} + +bool CItem::CanEdit( const unsigned int _index ) const +{ + CItemElt* pie = GetElt( _index ); + if( !pie ) + return( false ); + CItemEltAtom* piea = dynamic_cast< CItemEltAtom* >( pie ); + if( !piea ) + return( false ); + return( !( pie->GetInfos() & ITEM_ISENUM ) ); +} + +void CItem::GetListPredef( const unsigned int _index, std::vector< CStringEx >& _vsx ) const +{ + CItemElt* pie = GetElt( _index ); + if( !pie ) + return; + CItemEltAtom* piea = dynamic_cast< CItemEltAtom* >( pie ); + if( !piea ) + return; + + CMoldEltType* pmet = piea->GetMoldType(); + + unsigned int i = 0; + CStringEx sx = pmet->GetPredefDesignation( i++ ); + while( !sx.empty() ) + { + _vsx.push_back( sx ); + sx = pmet->GetPredefDesignation( i++ ); + } +} + +CStringEx CItem::GetParent( const unsigned int _index ) const +{ + if( _index >= vsxparents.size() ) + { + CStringEx object; + return( object ); + } + return( vsxparents[_index].second ); +} + +void CItem::SetParent( const unsigned int _index, const CStringEx _sx ) +{ + if( _index >= vsxparents.size() ) + return; + vsxparents[_index].second = _sx; +} + +CStringEx CItem::GetActivity( const unsigned int _index ) const +{ + if( _index >= vsxparents.size() ) + { + CStringEx object; + return( object ); + } + return( vsxparents[_index].first ); +} + +void CItem::SetActivity( const unsigned int _index, const CStringEx _sx ) +{ + if( _index >= vsxparents.size() ) + return; + vsxparents[_index].first = _sx; +} + +void CItem::AddList( const unsigned int _index ) const +{ + CItemElt* pie = GetElt( _index ); + if( !pie ) + return; + CItemEltList* piel = dynamic_cast< CItemEltList* >( pie ); + if( !piel ) + return; + piel->NewElt(); +} +/* +void CItem::AddListChild( const unsigned int _index ) const +{ + CItemElt* pie = GetElt( _index ); + if( !pie ) + return; + CItemElt* piep = pie->GetListParent(); + if( !piep ) + return; + CItemEltList* piel = dynamic_cast< CItemEltList* >( piep ); + if( !piel ) + return; + piel->AddElt( pie ); +} +*/ +void CItem::DelListChild( const unsigned int _index ) const +{ + CItemElt* pie = GetElt( _index ); + if( !pie ) + return; + CItemElt* piep = pie->GetListParent(); + if( !piep ) + return; + CItemEltList* piel = dynamic_cast< CItemEltList* >( piep ); + if( !piel ) + return; + piel->DelElt( pie ); +} + +void CItem::AddParent( const unsigned int _index ) +{ + vsxparents.push_back( std::make_pair( CStringEx("false"), CStringEx("filename.extension") ) ); +} + +void CItem::DelParent( const unsigned int _index ) +{ + unsigned int i = 0; + for( std::vector< std::pair< CStringEx, CStringEx > >::iterator it = vsxparents.begin(); it != vsxparents.end(); ++it ) + if( i++ == _index ) + { + vsxparents.erase( it ); + return; + } +} + +void CItem::ClearParents () +{ + vsxparents.clear(); +} + +} diff --git a/code/ryzom/tools/leveldesign/georges_convert/item.h b/code/ryzom/tools/leveldesign/georges_convert/item.h index 72e685f92..8b461bd62 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/item.h +++ b/code/ryzom/tools/leveldesign/georges_convert/item.h @@ -1,91 +1,91 @@ -// 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 NLGEORGES_ITEM_H -#define NLGEORGES_ITEM_H - -#include "string_ex.h" -#include "form.h" - -namespace NLOLDGEORGES -{ - -class CLoader; -class CItemElt; -class CItemEltAtom; -class CItemEltStruct; -class CItemEltList; - -class CItem -{ -protected: - CLoader* pl; - CItemEltStruct* pitemes; -// CItemEltList* pitemelparents; -// CItemEltAtom* pitemeacomments; - std::vector< std::pair< CStringEx, CStringEx > > vsxparents; - CStringEx moldfilename; - -public: - CItem(); - virtual ~CItem(); - - void Clear(); - void SetLoader( CLoader* const _pl ); - void New( const CStringEx& _sxdfnfilename ); - void Load( const CStringEx& _sxfilename ); - void Load( const CStringEx& _sxfilename, const CStringEx _sxdate ); - void Save( const CStringEx& _sxfilename ); - bool Update(); - - // Convert CItem to a CForm (in is this) - void MakeForm (CForm &out); - // Convert CForm to CItem (out is this) - void MakeItem (CForm &in); - - void SetCurrentValue( const unsigned int _index, const CStringEx s ); - uint GetNbElt() const; - uint GetNbParents() const; - uint GetNbElt( const unsigned int _index ) const; - uint GetInfos( const unsigned int _index ) const; - CStringEx GetName( const unsigned int _index ) const; - CStringEx GetCurrentResult( const unsigned int _index ) const; - CStringEx GetCurrentValue( const unsigned int _index ) const; - CStringEx GetFormula( const unsigned int _index ) const; - bool IsEnum( const unsigned int _index ) const; - bool IsPredef( const unsigned int _index ) const; - bool CanEdit( const unsigned int _index ) const; - void GetListPredef( const unsigned int _index, std::vector< CStringEx >& _vsx ) const; - - CItemElt* GetElt( const unsigned int _index ) const; - CItemElt* GetElt( const CStringEx _sxname ) const; - - void AddList( const unsigned int _index ) const; - void DelListChild( const unsigned int _index ) const; - void VirtualSaveLoad(); - - void AddParent( const unsigned int _index = 0); - void DelParent( const unsigned int _index ); - void ClearParents (); - CStringEx GetParent( const unsigned int _index ) const; - void SetParent( const unsigned int _index, const CStringEx _sx ); - CStringEx GetActivity( const unsigned int _index ) const; - void SetActivity( const unsigned int _index, const CStringEx _sx ); -}; - -} // NLGEORGES - -#endif // NLGEORGES_ITEM_H +// 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 NLGEORGES_ITEM_H +#define NLGEORGES_ITEM_H + +#include "string_ex.h" +#include "form.h" + +namespace NLOLDGEORGES +{ + +class CLoader; +class CItemElt; +class CItemEltAtom; +class CItemEltStruct; +class CItemEltList; + +class CItem +{ +protected: + CLoader* pl; + CItemEltStruct* pitemes; +// CItemEltList* pitemelparents; +// CItemEltAtom* pitemeacomments; + std::vector< std::pair< CStringEx, CStringEx > > vsxparents; + CStringEx moldfilename; + +public: + CItem(); + virtual ~CItem(); + + void Clear(); + void SetLoader( CLoader* const _pl ); + void New( const CStringEx& _sxdfnfilename ); + void Load( const CStringEx& _sxfilename ); + void Load( const CStringEx& _sxfilename, const CStringEx _sxdate ); + void Save( const CStringEx& _sxfilename ); + bool Update(); + + // Convert CItem to a CForm (in is this) + void MakeForm (CForm &out); + // Convert CForm to CItem (out is this) + void MakeItem (CForm &in); + + void SetCurrentValue( const unsigned int _index, const CStringEx s ); + uint GetNbElt() const; + uint GetNbParents() const; + uint GetNbElt( const unsigned int _index ) const; + uint GetInfos( const unsigned int _index ) const; + CStringEx GetName( const unsigned int _index ) const; + CStringEx GetCurrentResult( const unsigned int _index ) const; + CStringEx GetCurrentValue( const unsigned int _index ) const; + CStringEx GetFormula( const unsigned int _index ) const; + bool IsEnum( const unsigned int _index ) const; + bool IsPredef( const unsigned int _index ) const; + bool CanEdit( const unsigned int _index ) const; + void GetListPredef( const unsigned int _index, std::vector< CStringEx >& _vsx ) const; + + CItemElt* GetElt( const unsigned int _index ) const; + CItemElt* GetElt( const CStringEx _sxname ) const; + + void AddList( const unsigned int _index ) const; + void DelListChild( const unsigned int _index ) const; + void VirtualSaveLoad(); + + void AddParent( const unsigned int _index = 0); + void DelParent( const unsigned int _index ); + void ClearParents (); + CStringEx GetParent( const unsigned int _index ) const; + void SetParent( const unsigned int _index, const CStringEx _sx ); + CStringEx GetActivity( const unsigned int _index ) const; + void SetActivity( const unsigned int _index, const CStringEx _sx ); +}; + +} // NLGEORGES + +#endif // NLGEORGES_ITEM_H diff --git a/code/ryzom/tools/leveldesign/georges_convert/item_elt.cpp b/code/ryzom/tools/leveldesign/georges_convert/item_elt.cpp index 74440d902..f9b1ec96d 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/item_elt.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/item_elt.cpp @@ -1,165 +1,165 @@ -// 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 "stdgeorgesconvert.h" -#include "item_elt.h" - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CItemElt::CItemElt( CLoader* const _pl ) -{ - nlassert( _pl ); - pl = _pl; - listparent = 0; - bmodified = false; -} - -CItemElt::~CItemElt() -{ -} - -bool CItemElt::SetModified( const unsigned int _index ) -{ - if( !_index ) - bmodified = true; - return( !_index ); -} - -void CItemElt::SetModified( const bool _b ) -{ - bmodified = _b; -} - -unsigned int CItemElt::GetInfos() const -{ - return( infos ); -} - -void CItemElt::AddInfos( const unsigned int _infos ) -{ - infos |= _infos; -} - -void CItemElt::SetListParent( CItemElt* const _listparent ) -{ - listparent = _listparent; -} - -CItemElt* CItemElt::GetListParent() const -{ - return( listparent ); -} - -void CItemElt::SetName( const CStringEx _sxname ) -{ - sxname = _sxname; -} - -CStringEx CItemElt::GetName() const -{ - return( sxname ); -} - -CStringEx CItemElt::GetParent() const -{ - return( sxparent ); -} - -CStringEx CItemElt::GetFormula() const -{ - CStringEx object; - return( object ); -} - -CStringEx CItemElt::GetParentResult() const -{ - return( sxparentresult ); -} - -CStringEx CItemElt::GetParentValue() const -{ - return( sxparentvalue ); -} - -CStringEx CItemElt::GetCurrentResult() const -{ - return( sxcurrentresult ); -} - -CStringEx CItemElt::GetCurrentValue() const -{ - return( sxcurrentvalue ); -} - -void CItemElt::SetParentValue( const CStringEx _sxparentvalue ) -{ -} - -void CItemElt::SetCurrentValue( const CStringEx _sxcurrentvalue ) -{ -} - -void CItemElt::FillParent( const CFormBodyElt* const _pfbe ) -{ -} - -void CItemElt::FillCurrent( const CFormBodyElt* const _pfbe ) -{ -} - -CItemElt* CItemElt::Clone() -{ - return( 0 ); -} - -CFormBodyElt* CItemElt::BuildForm() -{ - return( 0 ); -} - -unsigned int CItemElt::GetNbElt() const -{ - return( 0 ); -} - -CItemElt* CItemElt::GetElt( const unsigned int _index ) const -{ - if( !_index ) - return( ( CItemElt* )( this ) ); - return( 0 ); -} - -CItemElt* CItemElt::GetElt( const CStringEx _sxname ) const -{ - return( 0 ); -} - -unsigned int CItemElt::GetNbChild () -{ - return 0; -} - -CItemElt* CItemElt::GetChild (unsigned int _index) -{ - return NULL; -} - -} +// 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 "stdgeorgesconvert.h" +#include "item_elt.h" + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CItemElt::CItemElt( CLoader* const _pl ) +{ + nlassert( _pl ); + pl = _pl; + listparent = 0; + bmodified = false; +} + +CItemElt::~CItemElt() +{ +} + +bool CItemElt::SetModified( const unsigned int _index ) +{ + if( !_index ) + bmodified = true; + return( !_index ); +} + +void CItemElt::SetModified( const bool _b ) +{ + bmodified = _b; +} + +unsigned int CItemElt::GetInfos() const +{ + return( infos ); +} + +void CItemElt::AddInfos( const unsigned int _infos ) +{ + infos |= _infos; +} + +void CItemElt::SetListParent( CItemElt* const _listparent ) +{ + listparent = _listparent; +} + +CItemElt* CItemElt::GetListParent() const +{ + return( listparent ); +} + +void CItemElt::SetName( const CStringEx _sxname ) +{ + sxname = _sxname; +} + +CStringEx CItemElt::GetName() const +{ + return( sxname ); +} + +CStringEx CItemElt::GetParent() const +{ + return( sxparent ); +} + +CStringEx CItemElt::GetFormula() const +{ + CStringEx object; + return( object ); +} + +CStringEx CItemElt::GetParentResult() const +{ + return( sxparentresult ); +} + +CStringEx CItemElt::GetParentValue() const +{ + return( sxparentvalue ); +} + +CStringEx CItemElt::GetCurrentResult() const +{ + return( sxcurrentresult ); +} + +CStringEx CItemElt::GetCurrentValue() const +{ + return( sxcurrentvalue ); +} + +void CItemElt::SetParentValue( const CStringEx _sxparentvalue ) +{ +} + +void CItemElt::SetCurrentValue( const CStringEx _sxcurrentvalue ) +{ +} + +void CItemElt::FillParent( const CFormBodyElt* const _pfbe ) +{ +} + +void CItemElt::FillCurrent( const CFormBodyElt* const _pfbe ) +{ +} + +CItemElt* CItemElt::Clone() +{ + return( 0 ); +} + +CFormBodyElt* CItemElt::BuildForm() +{ + return( 0 ); +} + +unsigned int CItemElt::GetNbElt() const +{ + return( 0 ); +} + +CItemElt* CItemElt::GetElt( const unsigned int _index ) const +{ + if( !_index ) + return( ( CItemElt* )( this ) ); + return( 0 ); +} + +CItemElt* CItemElt::GetElt( const CStringEx _sxname ) const +{ + return( 0 ); +} + +unsigned int CItemElt::GetNbChild () +{ + return 0; +} + +CItemElt* CItemElt::GetChild (unsigned int _index) +{ + return NULL; +} + +} diff --git a/code/ryzom/tools/leveldesign/georges_convert/item_elt.h b/code/ryzom/tools/leveldesign/georges_convert/item_elt.h index 07d063190..2f8e11e65 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/item_elt.h +++ b/code/ryzom/tools/leveldesign/georges_convert/item_elt.h @@ -1,82 +1,82 @@ -// 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 NLGEORGES_ITEM_ELT_H -#define NLGEORGES_ITEM_ELT_H - -#include "string_ex.h" -#include "common.h" - -namespace NLOLDGEORGES -{ - -class CLoader; -class CFormBodyElt; - -class CItemElt -{ -protected: - CLoader* pl; - unsigned int infos; - CStringEx sxname; - CStringEx sxparent; - CStringEx sxcurrentresult; - CStringEx sxcurrentvalue; - CStringEx sxoldcurrentvalue; - CStringEx sxparentresult; - CStringEx sxparentvalue; - CStringEx sxoldparentvalue; - CItemElt* listparent; - bool bmodified; - -public: - CItemElt( CLoader* const _pl ); - virtual ~CItemElt(); - - void SetName( const CStringEx _sxname ); - void AddInfos( const unsigned int _infos ); - void SetListParent( CItemElt* const _listparent ); - CItemElt* GetListParent() const; - - unsigned int GetInfos() const; - CStringEx GetName() const; - CStringEx GetParent() const; - CStringEx GetParentResult() const; - CStringEx GetParentValue() const; - CStringEx GetCurrentResult() const; - CStringEx GetCurrentValue() const; - - virtual CStringEx GetFormula() const; - virtual void SetParentValue( const CStringEx _sxparentvalue ); - virtual void SetCurrentValue( const CStringEx _sxcurrentvalue ); - virtual void FillParent( const CFormBodyElt* const _pfbe ); - virtual void FillCurrent(const CFormBodyElt* const _pfbe ); - virtual CItemElt* Clone(); - virtual CFormBodyElt* BuildForm(); - - virtual unsigned int GetNbElt() const; - virtual CItemElt* GetElt( const unsigned int _index ) const; - virtual CItemElt* GetElt( const CStringEx sxname ) const; - virtual bool SetModified( const unsigned int _index ); - virtual void SetModified( const bool _b ); - - virtual unsigned int GetNbChild (); - virtual CItemElt* GetChild (unsigned int _index); -}; - -} // NLGEORGES - -#endif // NLGEORGES_ITEM_ELT_H +// 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 NLGEORGES_ITEM_ELT_H +#define NLGEORGES_ITEM_ELT_H + +#include "string_ex.h" +#include "common.h" + +namespace NLOLDGEORGES +{ + +class CLoader; +class CFormBodyElt; + +class CItemElt +{ +protected: + CLoader* pl; + unsigned int infos; + CStringEx sxname; + CStringEx sxparent; + CStringEx sxcurrentresult; + CStringEx sxcurrentvalue; + CStringEx sxoldcurrentvalue; + CStringEx sxparentresult; + CStringEx sxparentvalue; + CStringEx sxoldparentvalue; + CItemElt* listparent; + bool bmodified; + +public: + CItemElt( CLoader* const _pl ); + virtual ~CItemElt(); + + void SetName( const CStringEx _sxname ); + void AddInfos( const unsigned int _infos ); + void SetListParent( CItemElt* const _listparent ); + CItemElt* GetListParent() const; + + unsigned int GetInfos() const; + CStringEx GetName() const; + CStringEx GetParent() const; + CStringEx GetParentResult() const; + CStringEx GetParentValue() const; + CStringEx GetCurrentResult() const; + CStringEx GetCurrentValue() const; + + virtual CStringEx GetFormula() const; + virtual void SetParentValue( const CStringEx _sxparentvalue ); + virtual void SetCurrentValue( const CStringEx _sxcurrentvalue ); + virtual void FillParent( const CFormBodyElt* const _pfbe ); + virtual void FillCurrent(const CFormBodyElt* const _pfbe ); + virtual CItemElt* Clone(); + virtual CFormBodyElt* BuildForm(); + + virtual unsigned int GetNbElt() const; + virtual CItemElt* GetElt( const unsigned int _index ) const; + virtual CItemElt* GetElt( const CStringEx sxname ) const; + virtual bool SetModified( const unsigned int _index ); + virtual void SetModified( const bool _b ); + + virtual unsigned int GetNbChild (); + virtual CItemElt* GetChild (unsigned int _index); +}; + +} // NLGEORGES + +#endif // NLGEORGES_ITEM_ELT_H diff --git a/code/ryzom/tools/leveldesign/georges_convert/item_elt_atom.cpp b/code/ryzom/tools/leveldesign/georges_convert/item_elt_atom.cpp index 48bd1516e..e7d940b1a 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/item_elt_atom.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/item_elt_atom.cpp @@ -1,139 +1,139 @@ -// 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 "stdgeorgesconvert.h" -#include "item_elt_atom.h" -#include "mold_elt_type.h" -#include "mold_elt_type_list.h" -#include "form_body_elt.h" -#include "form_body_elt_atom.h" - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CItemEltAtom::CItemEltAtom( CLoader* const _pl ) : CItemElt( _pl ) -{ - infos = ITEM_ISATOM; - pmet = 0; -} - -CItemEltAtom::~CItemEltAtom() -{ -} - -void CItemEltAtom::BuildItem( CMoldElt* const _pme ) -{ - if( _pme->IsList() ) - pmet = dynamic_cast< CMoldEltTypeList* >( _pme ); - else - pmet = dynamic_cast< CMoldEltType* >( _pme ); - nlassert( pmet ); - sxparentvalue.clear(); - sxcurrentvalue.clear(); - sxoldparentvalue.clear(); - sxoldcurrentvalue.clear(); - - sxparentresult = pmet->GetDefaultValue(); - sxcurrentresult = pmet->GetDefaultValue(); - - //SetParentValue(pmet->GetDefaultValue()); - - if( pmet->IsEnum() ) - infos |= ITEM_ISENUM; -} - -CStringEx CItemEltAtom::GetFormula() const -{ - nlassert( pmet ); - return( pmet->GetFormula() ); -} - -void CItemEltAtom::SetParentValue( const CStringEx _sxparentvalue ) -{ - nlassert( pmet ); - sxparentvalue = pmet->Format( _sxparentvalue ); - sxparentresult = pmet->CalculateResult( pmet->GetDefaultValue(), sxparentvalue ); - if( sxparentvalue.empty() ) - sxparentresult = pmet->GetDefaultValue(); -} - -void CItemEltAtom::SetCurrentValue( const CStringEx _sxcurrentvalue ) -{ - nlassert( pmet ); - bmodified = true; - sxcurrentvalue = pmet->Format( _sxcurrentvalue ); - sxcurrentresult = pmet->CalculateResult( sxparentresult, sxcurrentvalue ); - if( !sxcurrentvalue.empty() ) - return; - sxcurrentvalue.clear(); - sxcurrentresult = sxparentresult; -} - -void CItemEltAtom::FillParent( const CFormBodyElt* const _pfbe ) -{ - SetParentValue( _pfbe->GetValue() ); - sxoldparentvalue = sxparentvalue; - SetCurrentValue( sxparentvalue ); -} - -void CItemEltAtom::FillCurrent( const CFormBodyElt* const _pfbe ) -{ - SetCurrentValue( _pfbe->GetValue() ); - sxoldcurrentvalue = sxcurrentvalue; -} - -CItemElt* CItemEltAtom::Clone() -{ - CItemEltAtom* piea = new CItemEltAtom( pl ); - piea->BuildItem( pmet ); - return( piea ); -} - -CFormBodyElt* CItemEltAtom::BuildForm() -{ - if( !bmodified && sxoldcurrentvalue.empty() ) /* && sxcurrentvalue.empty() ??? */ - return( 0 ); - CFormBodyEltAtom* pfbea = new CFormBodyEltAtom(); - pfbea->SetName( sxname ); - pfbea->SetValue( sxcurrentvalue ); - return( pfbea ); -} - -unsigned int CItemEltAtom::GetNbElt() const -{ - return( 1 ); -} - -CMoldEltType* CItemEltAtom::GetMoldType() const -{ - return( pmet ); -} - -unsigned int CItemEltAtom::GetNbChild () -{ - return 0; -} - -CItemElt* CItemEltAtom::GetChild (unsigned int _index) -{ - return NULL; -} - +// 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 "stdgeorgesconvert.h" +#include "item_elt_atom.h" +#include "mold_elt_type.h" +#include "mold_elt_type_list.h" +#include "form_body_elt.h" +#include "form_body_elt_atom.h" + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CItemEltAtom::CItemEltAtom( CLoader* const _pl ) : CItemElt( _pl ) +{ + infos = ITEM_ISATOM; + pmet = 0; +} + +CItemEltAtom::~CItemEltAtom() +{ +} + +void CItemEltAtom::BuildItem( CMoldElt* const _pme ) +{ + if( _pme->IsList() ) + pmet = dynamic_cast< CMoldEltTypeList* >( _pme ); + else + pmet = dynamic_cast< CMoldEltType* >( _pme ); + nlassert( pmet ); + sxparentvalue.clear(); + sxcurrentvalue.clear(); + sxoldparentvalue.clear(); + sxoldcurrentvalue.clear(); + + sxparentresult = pmet->GetDefaultValue(); + sxcurrentresult = pmet->GetDefaultValue(); + + //SetParentValue(pmet->GetDefaultValue()); + + if( pmet->IsEnum() ) + infos |= ITEM_ISENUM; +} + +CStringEx CItemEltAtom::GetFormula() const +{ + nlassert( pmet ); + return( pmet->GetFormula() ); +} + +void CItemEltAtom::SetParentValue( const CStringEx _sxparentvalue ) +{ + nlassert( pmet ); + sxparentvalue = pmet->Format( _sxparentvalue ); + sxparentresult = pmet->CalculateResult( pmet->GetDefaultValue(), sxparentvalue ); + if( sxparentvalue.empty() ) + sxparentresult = pmet->GetDefaultValue(); +} + +void CItemEltAtom::SetCurrentValue( const CStringEx _sxcurrentvalue ) +{ + nlassert( pmet ); + bmodified = true; + sxcurrentvalue = pmet->Format( _sxcurrentvalue ); + sxcurrentresult = pmet->CalculateResult( sxparentresult, sxcurrentvalue ); + if( !sxcurrentvalue.empty() ) + return; + sxcurrentvalue.clear(); + sxcurrentresult = sxparentresult; +} + +void CItemEltAtom::FillParent( const CFormBodyElt* const _pfbe ) +{ + SetParentValue( _pfbe->GetValue() ); + sxoldparentvalue = sxparentvalue; + SetCurrentValue( sxparentvalue ); +} + +void CItemEltAtom::FillCurrent( const CFormBodyElt* const _pfbe ) +{ + SetCurrentValue( _pfbe->GetValue() ); + sxoldcurrentvalue = sxcurrentvalue; +} + +CItemElt* CItemEltAtom::Clone() +{ + CItemEltAtom* piea = new CItemEltAtom( pl ); + piea->BuildItem( pmet ); + return( piea ); +} + +CFormBodyElt* CItemEltAtom::BuildForm() +{ + if( !bmodified && sxoldcurrentvalue.empty() ) /* && sxcurrentvalue.empty() ??? */ + return( 0 ); + CFormBodyEltAtom* pfbea = new CFormBodyEltAtom(); + pfbea->SetName( sxname ); + pfbea->SetValue( sxcurrentvalue ); + return( pfbea ); +} + +unsigned int CItemEltAtom::GetNbElt() const +{ + return( 1 ); +} + +CMoldEltType* CItemEltAtom::GetMoldType() const +{ + return( pmet ); +} + +unsigned int CItemEltAtom::GetNbChild () +{ + return 0; +} + +CItemElt* CItemEltAtom::GetChild (unsigned int _index) +{ + return NULL; +} + } \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_convert/item_elt_atom.h b/code/ryzom/tools/leveldesign/georges_convert/item_elt_atom.h index 8cda524e0..a23224859 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/item_elt_atom.h +++ b/code/ryzom/tools/leveldesign/georges_convert/item_elt_atom.h @@ -1,56 +1,56 @@ -// 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 NLGEORGES_ITEM_ELT_ATOM_H -#define NLGEORGES_ITEM_ELT_ATOM_H - -#include "item_elt.h" - -namespace NLOLDGEORGES -{ - -class CMoldElt; -class CMoldEltType; - -class CItemEltAtom : public CItemElt -{ -protected: - CMoldEltType* pmet; - -public: - CItemEltAtom( CLoader* const _pl ); - virtual ~CItemEltAtom(); - - void BuildItem( CMoldElt* const _pme ); - - virtual CStringEx GetFormula() const; - virtual void SetParentValue( const CStringEx _sxparentvalue ); - virtual void SetCurrentValue( const CStringEx _sxcurrentvalue ); - virtual void FillParent( const CFormBodyElt* const _pfbe ); - virtual void FillCurrent(const CFormBodyElt* const _pfbe ); - virtual CItemElt* Clone(); - virtual CFormBodyElt* BuildForm(); - virtual unsigned int GetNbElt() const; - - CMoldEltType* GetMoldType() const; - - virtual unsigned int GetNbChild (); - virtual CItemElt* GetChild (unsigned int _index); -}; - -} // NLGEORGES - -#endif // NLGEORGES_ITEM_ELT_ATOM_H +// 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 NLGEORGES_ITEM_ELT_ATOM_H +#define NLGEORGES_ITEM_ELT_ATOM_H + +#include "item_elt.h" + +namespace NLOLDGEORGES +{ + +class CMoldElt; +class CMoldEltType; + +class CItemEltAtom : public CItemElt +{ +protected: + CMoldEltType* pmet; + +public: + CItemEltAtom( CLoader* const _pl ); + virtual ~CItemEltAtom(); + + void BuildItem( CMoldElt* const _pme ); + + virtual CStringEx GetFormula() const; + virtual void SetParentValue( const CStringEx _sxparentvalue ); + virtual void SetCurrentValue( const CStringEx _sxcurrentvalue ); + virtual void FillParent( const CFormBodyElt* const _pfbe ); + virtual void FillCurrent(const CFormBodyElt* const _pfbe ); + virtual CItemElt* Clone(); + virtual CFormBodyElt* BuildForm(); + virtual unsigned int GetNbElt() const; + + CMoldEltType* GetMoldType() const; + + virtual unsigned int GetNbChild (); + virtual CItemElt* GetChild (unsigned int _index); +}; + +} // NLGEORGES + +#endif // NLGEORGES_ITEM_ELT_ATOM_H diff --git a/code/ryzom/tools/leveldesign/georges_convert/item_elt_list.cpp b/code/ryzom/tools/leveldesign/georges_convert/item_elt_list.cpp index 4ac37f654..e2b85bdc9 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/item_elt_list.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/item_elt_list.cpp @@ -1,242 +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 "stdgeorgesconvert.h" -#include "item_elt_list.h" -#include "item_elt_atom.h" -#include "item_elt_struct.h" -#include "form_body_elt.h" -#include "form_body_elt_list.h" - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CItemEltList::CItemEltList( CLoader* const _pl ) : CItemElt( _pl ) -{ - infos = ITEM_ISLIST; - piemodel = 0; -} - -CItemEltList::~CItemEltList() -{ - if( piemodel ) - delete piemodel; - piemodel = 0; - Clear(); -} - -void CItemEltList::Clear() -{ - for( std::vector< CItemElt* >::iterator it = vpie.begin(); it != vpie.end(); ++it ) - if( *it ) - delete( *it ); - vpie.clear(); -} - -void CItemEltList::BuildItem( CItemElt* const _pie ) -{ - piemodel = _pie; - piemodel->AddInfos( ITEM_ISLISTCHILD ); - piemodel->SetListParent( this ); - nlassert( piemodel ); -} - -CStringEx CItemEltList::GetFormula() const -{ - nlassert( piemodel ); - return( CStringEx("list<") + piemodel->GetFormula() + ">" ); -} - -void CItemEltList::FillParent( const CFormBodyElt* const _pfbe ) -{ - unsigned int i = 0; - CStringEx sx; - CFormBodyElt* pfbe = _pfbe->GetElt(0); - if( pfbe ) - Clear(); - while( pfbe ) - { - CItemElt* pie = piemodel->Clone(); - pie->AddInfos( ITEM_ISLISTCHILD ); - pie->SetListParent( this ); - pie->FillParent( pfbe ); - sx.format( "#%d", i ); - pie->SetName( sx ); - vpie.push_back( pie ); - pfbe = _pfbe->GetElt(++i); - } -} - -void CItemEltList::FillCurrent( const CFormBodyElt* const _pfbe ) -{ - unsigned int i = 0; - CStringEx sx; - CFormBodyElt* pfbe = _pfbe->GetElt(0); - if( pfbe ) - Clear(); - if( !pfbe ) - return; - while( pfbe ) - { - CItemElt* pie = piemodel->Clone(); - pie->AddInfos( ITEM_ISLISTCHILD ); - pie->SetListParent( this ); - pie->FillCurrent( pfbe ); - sx.format( "#%d", i ); - pie->SetName( sx ); - vpie.push_back( pie ); - pfbe = _pfbe->GetElt(++i); - } - SetModified( true ); -} - -CItemElt* CItemEltList::Clone() -{ - CItemEltList* piel = new CItemEltList( pl ); - piel->BuildItem( piemodel ); - return( piel ); -} - -CFormBodyElt* CItemEltList::BuildForm() -{ - if( bmodified ) - for( std::vector< CItemElt* >::iterator it = vpie.begin(); it != vpie.end(); ++it ) - (*it)->SetModified( true ); - CFormBodyEltList* pfbel = new CFormBodyEltList(); - pfbel->SetName( sxname ); - for( std::vector< CItemElt* >::iterator it = vpie.begin(); it != vpie.end(); ++it ) - pfbel->AddElt( (*it)->BuildForm() ); - return( pfbel ); -} - -unsigned int CItemEltList::GetNbElt() const -{ - unsigned int nb = 0; - for( std::vector< CItemElt* >::const_iterator it = vpie.begin(); it != vpie.end(); ++it ) - nb += (*it)->GetNbElt(); - return( ++nb ); -} - -CItemElt* CItemEltList::GetElt( const unsigned int _index ) const -{ - if( !_index ) - return( ( CItemElt * )( this ) ); - unsigned int isum = 1; - for( std::vector< CItemElt* >::const_iterator it = vpie.begin(); it != vpie.end(); ++it ) - { - unsigned int nb = (*it)->GetNbElt(); - if( isum+nb > _index ) - return( (*it)->GetElt( _index-isum ) ); - isum += nb; - } - return( 0 ); -} - -CItemElt* CItemEltList::GetElt( const CStringEx _sxname ) const -{ - for( std::vector< CItemElt* >::const_iterator it = vpie.begin(); it != vpie.end(); ++it ) - if( (*it)->GetName() == _sxname ) - return( *it ); - return( 0 ); -} - -bool CItemEltList::SetModified( const unsigned int _index ) -{ - SetModified( true ); - if( !_index ) - return( true ); - unsigned int isum = 1; - for( std::vector< CItemElt* >::const_iterator it = vpie.begin(); it != vpie.end(); ++it ) - { - unsigned int nb = (*it)->GetNbElt(); - if( isum+nb > _index ) - return( (*it)->SetModified( _index-isum ) ); - isum += nb; - } - return( false ); -} - -void CItemEltList::SetModified( const bool _b ) -{ - bmodified = _b; - for( std::vector< CItemElt* >::const_iterator it = vpie.begin(); it != vpie.end(); ++it ) - (*it)->SetModified( _b ); -} - -void CItemEltList::NewElt() -{ - CItemElt* pie = piemodel->Clone(); - pie->AddInfos( ITEM_ISLISTCHILD ); - pie->SetListParent( this ); - CStringEx sx; - sx.format( "#%d", vpie.size() ); - pie->SetName( sx ); - vpie.push_back( pie ); - SetModified( true ); -} - -void CItemEltList::AddElt( const CItemElt* const _pie ) -{ - for( std::vector< CItemElt* >::iterator it = vpie.begin(); it != vpie.end(); ++it ) - if( (*it) == _pie ) - { - CItemElt* pie = piemodel->Clone(); - pie->AddInfos( ITEM_ISLISTCHILD ); - pie->SetListParent( this ); - vpie.insert( it, pie ); - VerifyName(); - return; - } -} - -void CItemEltList::DelElt( CItemElt* const _pie ) -{ - for( std::vector< CItemElt* >::iterator it = vpie.begin(); it != vpie.end(); ++it ) - if( (*it) == _pie ) - { - delete( _pie ); - vpie.erase( it ); - VerifyName(); - return; - } -} - -void CItemEltList::VerifyName() -{ - unsigned int i = 0; - for( std::vector< CItemElt* >::iterator it = vpie.begin(); it != vpie.end(); ++it ) - { - CStringEx sx; - sx.format( "#%d", i++ ); - (*it)->SetName( sx ); - } -} - -unsigned int CItemEltList::GetNbChild () -{ - return vpie.size(); -} - -CItemElt* CItemEltList::GetChild (unsigned int _index) -{ - return vpie[_index]; -} - -} +// 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 "stdgeorgesconvert.h" +#include "item_elt_list.h" +#include "item_elt_atom.h" +#include "item_elt_struct.h" +#include "form_body_elt.h" +#include "form_body_elt_list.h" + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CItemEltList::CItemEltList( CLoader* const _pl ) : CItemElt( _pl ) +{ + infos = ITEM_ISLIST; + piemodel = 0; +} + +CItemEltList::~CItemEltList() +{ + if( piemodel ) + delete piemodel; + piemodel = 0; + Clear(); +} + +void CItemEltList::Clear() +{ + for( std::vector< CItemElt* >::iterator it = vpie.begin(); it != vpie.end(); ++it ) + if( *it ) + delete( *it ); + vpie.clear(); +} + +void CItemEltList::BuildItem( CItemElt* const _pie ) +{ + piemodel = _pie; + piemodel->AddInfos( ITEM_ISLISTCHILD ); + piemodel->SetListParent( this ); + nlassert( piemodel ); +} + +CStringEx CItemEltList::GetFormula() const +{ + nlassert( piemodel ); + return( CStringEx("list<") + piemodel->GetFormula() + ">" ); +} + +void CItemEltList::FillParent( const CFormBodyElt* const _pfbe ) +{ + unsigned int i = 0; + CStringEx sx; + CFormBodyElt* pfbe = _pfbe->GetElt(0); + if( pfbe ) + Clear(); + while( pfbe ) + { + CItemElt* pie = piemodel->Clone(); + pie->AddInfos( ITEM_ISLISTCHILD ); + pie->SetListParent( this ); + pie->FillParent( pfbe ); + sx.format( "#%d", i ); + pie->SetName( sx ); + vpie.push_back( pie ); + pfbe = _pfbe->GetElt(++i); + } +} + +void CItemEltList::FillCurrent( const CFormBodyElt* const _pfbe ) +{ + unsigned int i = 0; + CStringEx sx; + CFormBodyElt* pfbe = _pfbe->GetElt(0); + if( pfbe ) + Clear(); + if( !pfbe ) + return; + while( pfbe ) + { + CItemElt* pie = piemodel->Clone(); + pie->AddInfos( ITEM_ISLISTCHILD ); + pie->SetListParent( this ); + pie->FillCurrent( pfbe ); + sx.format( "#%d", i ); + pie->SetName( sx ); + vpie.push_back( pie ); + pfbe = _pfbe->GetElt(++i); + } + SetModified( true ); +} + +CItemElt* CItemEltList::Clone() +{ + CItemEltList* piel = new CItemEltList( pl ); + piel->BuildItem( piemodel ); + return( piel ); +} + +CFormBodyElt* CItemEltList::BuildForm() +{ + if( bmodified ) + for( std::vector< CItemElt* >::iterator it = vpie.begin(); it != vpie.end(); ++it ) + (*it)->SetModified( true ); + CFormBodyEltList* pfbel = new CFormBodyEltList(); + pfbel->SetName( sxname ); + for( std::vector< CItemElt* >::iterator it = vpie.begin(); it != vpie.end(); ++it ) + pfbel->AddElt( (*it)->BuildForm() ); + return( pfbel ); +} + +unsigned int CItemEltList::GetNbElt() const +{ + unsigned int nb = 0; + for( std::vector< CItemElt* >::const_iterator it = vpie.begin(); it != vpie.end(); ++it ) + nb += (*it)->GetNbElt(); + return( ++nb ); +} + +CItemElt* CItemEltList::GetElt( const unsigned int _index ) const +{ + if( !_index ) + return( ( CItemElt * )( this ) ); + unsigned int isum = 1; + for( std::vector< CItemElt* >::const_iterator it = vpie.begin(); it != vpie.end(); ++it ) + { + unsigned int nb = (*it)->GetNbElt(); + if( isum+nb > _index ) + return( (*it)->GetElt( _index-isum ) ); + isum += nb; + } + return( 0 ); +} + +CItemElt* CItemEltList::GetElt( const CStringEx _sxname ) const +{ + for( std::vector< CItemElt* >::const_iterator it = vpie.begin(); it != vpie.end(); ++it ) + if( (*it)->GetName() == _sxname ) + return( *it ); + return( 0 ); +} + +bool CItemEltList::SetModified( const unsigned int _index ) +{ + SetModified( true ); + if( !_index ) + return( true ); + unsigned int isum = 1; + for( std::vector< CItemElt* >::const_iterator it = vpie.begin(); it != vpie.end(); ++it ) + { + unsigned int nb = (*it)->GetNbElt(); + if( isum+nb > _index ) + return( (*it)->SetModified( _index-isum ) ); + isum += nb; + } + return( false ); +} + +void CItemEltList::SetModified( const bool _b ) +{ + bmodified = _b; + for( std::vector< CItemElt* >::const_iterator it = vpie.begin(); it != vpie.end(); ++it ) + (*it)->SetModified( _b ); +} + +void CItemEltList::NewElt() +{ + CItemElt* pie = piemodel->Clone(); + pie->AddInfos( ITEM_ISLISTCHILD ); + pie->SetListParent( this ); + CStringEx sx; + sx.format( "#%d", vpie.size() ); + pie->SetName( sx ); + vpie.push_back( pie ); + SetModified( true ); +} + +void CItemEltList::AddElt( const CItemElt* const _pie ) +{ + for( std::vector< CItemElt* >::iterator it = vpie.begin(); it != vpie.end(); ++it ) + if( (*it) == _pie ) + { + CItemElt* pie = piemodel->Clone(); + pie->AddInfos( ITEM_ISLISTCHILD ); + pie->SetListParent( this ); + vpie.insert( it, pie ); + VerifyName(); + return; + } +} + +void CItemEltList::DelElt( CItemElt* const _pie ) +{ + for( std::vector< CItemElt* >::iterator it = vpie.begin(); it != vpie.end(); ++it ) + if( (*it) == _pie ) + { + delete( _pie ); + vpie.erase( it ); + VerifyName(); + return; + } +} + +void CItemEltList::VerifyName() +{ + unsigned int i = 0; + for( std::vector< CItemElt* >::iterator it = vpie.begin(); it != vpie.end(); ++it ) + { + CStringEx sx; + sx.format( "#%d", i++ ); + (*it)->SetName( sx ); + } +} + +unsigned int CItemEltList::GetNbChild () +{ + return vpie.size(); +} + +CItemElt* CItemEltList::GetChild (unsigned int _index) +{ + return vpie[_index]; +} + +} diff --git a/code/ryzom/tools/leveldesign/georges_convert/item_elt_list.h b/code/ryzom/tools/leveldesign/georges_convert/item_elt_list.h index a990e5d16..d769931bd 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/item_elt_list.h +++ b/code/ryzom/tools/leveldesign/georges_convert/item_elt_list.h @@ -1,64 +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 NLGEORGES_ITEM_ELT_LIST_H -#define NLGEORGES_ITEM_ELT_LIST_H - -#include "item_elt.h" - -namespace NLOLDGEORGES -{ - -class CItemEltAtom; -class CItemEltStruct; - -class CItemEltList : public CItemElt -{ -protected: - CItemElt* piemodel; - std::vector< CItemElt* > vpie; - -public: - CItemEltList( CLoader* const _pl ); - virtual ~CItemEltList(); - - void BuildItem( CItemElt* const _pie ); - - void Clear(); - - virtual CStringEx GetFormula() const; - virtual void FillParent( const CFormBodyElt* const _pfbe ); - virtual void FillCurrent(const CFormBodyElt* const _pfbe ); - virtual CItemElt* Clone(); - virtual CFormBodyElt* BuildForm(); - virtual unsigned int GetNbElt() const; - virtual CItemElt* GetElt( const unsigned int _index ) const; - virtual CItemElt* GetElt( const CStringEx sxname ) const; - - void NewElt(); - void AddElt( const CItemElt* const _pie ); - void DelElt( CItemElt* const _pie ); - void VerifyName(); - virtual bool SetModified( const unsigned int _index ); - virtual void SetModified( const bool _b ); - - virtual unsigned int GetNbChild (); - virtual CItemElt* GetChild (unsigned int _index); -}; - -} // NLGEORGES - -#endif // NLGEORGES_ITEM_ELT_LIST_H +// 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 NLGEORGES_ITEM_ELT_LIST_H +#define NLGEORGES_ITEM_ELT_LIST_H + +#include "item_elt.h" + +namespace NLOLDGEORGES +{ + +class CItemEltAtom; +class CItemEltStruct; + +class CItemEltList : public CItemElt +{ +protected: + CItemElt* piemodel; + std::vector< CItemElt* > vpie; + +public: + CItemEltList( CLoader* const _pl ); + virtual ~CItemEltList(); + + void BuildItem( CItemElt* const _pie ); + + void Clear(); + + virtual CStringEx GetFormula() const; + virtual void FillParent( const CFormBodyElt* const _pfbe ); + virtual void FillCurrent(const CFormBodyElt* const _pfbe ); + virtual CItemElt* Clone(); + virtual CFormBodyElt* BuildForm(); + virtual unsigned int GetNbElt() const; + virtual CItemElt* GetElt( const unsigned int _index ) const; + virtual CItemElt* GetElt( const CStringEx sxname ) const; + + void NewElt(); + void AddElt( const CItemElt* const _pie ); + void DelElt( CItemElt* const _pie ); + void VerifyName(); + virtual bool SetModified( const unsigned int _index ); + virtual void SetModified( const bool _b ); + + virtual unsigned int GetNbChild (); + virtual CItemElt* GetChild (unsigned int _index); +}; + +} // NLGEORGES + +#endif // NLGEORGES_ITEM_ELT_LIST_H diff --git a/code/ryzom/tools/leveldesign/georges_convert/item_elt_struct.cpp b/code/ryzom/tools/leveldesign/georges_convert/item_elt_struct.cpp index 199c62c77..9c118a009 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/item_elt_struct.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/item_elt_struct.cpp @@ -1,268 +1,268 @@ -// 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 "stdgeorgesconvert.h" -#include "item_elt_atom.h" -#include "item_elt_list.h" -#include "item_elt_struct.h" -#include "mold_elt_define.h" -#include "mold_elt_define_list.h" -#include "form_body_elt.h" -#include "form_body_elt_atom.h" -#include "form_body_elt_struct.h" -#include "form_body_elt_list.h" - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CItemEltStruct::CItemEltStruct( CLoader* const _pl ) : CItemElt( _pl ) -{ - infos = ITEM_ISSTRUCT; - pmed = 0; -} - -CItemEltStruct::~CItemEltStruct() -{ - Clear(); -} - -void CItemEltStruct::Clear() -{ - for( std::vector< CItemElt* >::iterator it = vpie.begin(); it != vpie.end(); ++it ) - if( *it ) - delete( *it ); - vpie.clear(); -} - -void CItemEltStruct::BuildItem( CMoldElt* const _pme ) -{ - if( _pme->IsList() ) - pmed = dynamic_cast< CMoldEltDefineList* >( _pme ); - else - pmed = dynamic_cast< CMoldEltDefine* >( _pme ); - nlassert( pmed ); - - int i = 0; - CMoldElt* pme = pmed->GetEltPtr( i ); - while( pme ) - { - switch( pme->GetType() ) - { - case 0: - { - CItemEltAtom* piea = new CItemEltAtom( pl ); - piea->BuildItem( pme ); - if( pme->IsList() ) - { - CItemEltList* piel = new CItemEltList( pl ); - piel->BuildItem( piea ); - piel->SetName( pmed->GetEltName( i ) ); - vpie.push_back( piel ); - } - else - { - piea->SetName( pmed->GetEltName( i ) ); - vpie.push_back( piea ); - } - break; - } - case 1: - { - CItemEltStruct* pies = new CItemEltStruct( pl ); - pies->BuildItem( pme ); - if( pme->IsList() ) - { - CItemEltList* piel = new CItemEltList( pl ); - piel->BuildItem( pies ); - piel->SetName( pmed->GetEltName( i ) ); - vpie.push_back( piel ); - } - else - { - pies->SetName( pmed->GetEltName( i ) ); - vpie.push_back( pies ); - } - break; - } - } - pme = pmed->GetEltPtr( ++i ); - } -} - -CStringEx CItemEltStruct::GetFormula() const -{ - nlassert( pmed ); - return( pmed->GetFormula() ); -} - -void CItemEltStruct::FillParent( const CFormBodyElt* const _pfbe ) -{ - for( std::vector< CItemElt* >::iterator it = vpie.begin(); it != vpie.end(); ++it ) - { - CFormBodyElt* pfbe = _pfbe->GetElt( (*it)->GetName() ); - if( pfbe ) - (*it)->FillParent( pfbe ); - } -} - -void CItemEltStruct::FillCurrent( const CFormBodyElt* const _pfbe ) -{ - for( std::vector< CItemElt* >::iterator it = vpie.begin(); it != vpie.end(); ++it ) - { - CFormBodyElt* pfbe = _pfbe->GetElt( (*it)->GetName() ); - if( pfbe ) - (*it)->FillCurrent( pfbe ); - } -} - -CItemElt* CItemEltStruct::Clone() -{ - CItemEltStruct* pies = new CItemEltStruct( pl ); - pies->BuildItem( pmed ); - return( pies ); -} - -CFormBodyElt* CItemEltStruct::BuildForm() -{ - CFormBodyEltStruct* pfbes = new CFormBodyEltStruct(); - pfbes->SetName( sxname ); - BuildForm( pfbes ); - if( !pfbes->Empty() ) - return( pfbes ); - delete pfbes; - return( 0 ); -} - -void CItemEltStruct::BuildForm( CFormBodyEltStruct* const _pfbes ) -{ - if( bmodified ) - for( std::vector< CItemElt* >::iterator it = vpie.begin(); it != vpie.end(); ++it ) - (*it)->SetModified( true ); - for( std::vector< CItemElt* >::iterator it = vpie.begin(); it != vpie.end(); ++it ) - _pfbes->AddElt( (*it)->BuildForm() ); -} - -void CItemEltStruct::BuildForm( CFormBodyEltStruct* const _pfbes, const std::vector< std::pair< CStringEx, CStringEx > >& _vsxparents ) -{ - BuildForm( _pfbes ); - - if( !_vsxparents.empty() ) - { - CFormBodyEltList* pfbel = new CFormBodyEltList; - pfbel->SetName( "Parents" ); - int i = 0; - CStringEx sx; - for( std::vector< std::pair< CStringEx, CStringEx > >::const_iterator it = _vsxparents.begin(); it != _vsxparents.end(); ++it ) - { - CFormBodyEltStruct* pfbes = new CFormBodyEltStruct; - sx.format( "#%d", i++ ); - pfbes->SetName( sx ); - pfbel->AddElt( pfbes ); - - CFormBodyEltAtom* pfbea = new CFormBodyEltAtom; - pfbea->SetName( "Activity" ); - pfbea->SetValue( it->first ); - pfbes->AddElt( pfbea ); - - pfbea = new CFormBodyEltAtom; - pfbea->SetName( "Filename" ); - pfbea->SetValue( it->second ); - pfbes->AddElt( pfbea ); - } - _pfbes->AddElt( pfbel ); - } -} - -unsigned int CItemEltStruct::GetNbElt() const -{ - unsigned int nb = 0; - for( std::vector< CItemElt* >::const_iterator it = vpie.begin(); it != vpie.end(); ++it ) - nb += (*it)->GetNbElt(); - return( ++nb ); -} - -CItemElt* CItemEltStruct::GetElt( const unsigned int _index ) const -{ - if( !_index ) - return( ( CItemElt * )( this ) ); - unsigned int isum = 1; - for( std::vector< CItemElt* >::const_iterator it = vpie.begin(); it != vpie.end(); ++it ) - { - unsigned int nb = (*it)->GetNbElt(); - if( isum+nb > _index ) - return( (*it)->GetElt( _index-isum ) ); - isum += nb; - } - return( 0 ); -} - -CItemElt* CItemEltStruct::GetElt( const CStringEx _sxname ) const -{ - for( std::vector< CItemElt* >::const_iterator it = vpie.begin(); it != vpie.end(); ++it ) - if( (*it)->GetName() == _sxname ) - return( *it ); - return( 0 ); -} - -bool CItemEltStruct::SetModified( const unsigned int _index ) -{ -// SetModified( true ); - if( !_index ) - return( true ); - unsigned int isum = 1; - for( std::vector< CItemElt* >::const_iterator it = vpie.begin(); it != vpie.end(); ++it ) - { - unsigned int nb = (*it)->GetNbElt(); - if( isum+nb > _index ) - return( (*it)->SetModified( _index-isum ) ); - isum += nb; - } - return( false ); -} - -void CItemEltStruct::SetModified( const bool _b ) -{ - bmodified = _b; - if( !_b ) - for( std::vector< CItemElt* >::const_iterator it = vpie.begin(); it != vpie.end(); ++it ) - (*it)->SetModified( _b ); -} - -unsigned int CItemEltStruct::GetNbChild () -{ - return 0; -} - -CItemElt* CItemEltStruct::GetChild (unsigned int _index) -{ - return NULL; -} - -unsigned int CItemEltStruct::GetNbStructElt () -{ - return vpie.size(); -} - -CItemElt* CItemEltStruct::GetStructElt (unsigned int _index) -{ - return vpie[_index]; -} - +// 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 "stdgeorgesconvert.h" +#include "item_elt_atom.h" +#include "item_elt_list.h" +#include "item_elt_struct.h" +#include "mold_elt_define.h" +#include "mold_elt_define_list.h" +#include "form_body_elt.h" +#include "form_body_elt_atom.h" +#include "form_body_elt_struct.h" +#include "form_body_elt_list.h" + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CItemEltStruct::CItemEltStruct( CLoader* const _pl ) : CItemElt( _pl ) +{ + infos = ITEM_ISSTRUCT; + pmed = 0; +} + +CItemEltStruct::~CItemEltStruct() +{ + Clear(); +} + +void CItemEltStruct::Clear() +{ + for( std::vector< CItemElt* >::iterator it = vpie.begin(); it != vpie.end(); ++it ) + if( *it ) + delete( *it ); + vpie.clear(); +} + +void CItemEltStruct::BuildItem( CMoldElt* const _pme ) +{ + if( _pme->IsList() ) + pmed = dynamic_cast< CMoldEltDefineList* >( _pme ); + else + pmed = dynamic_cast< CMoldEltDefine* >( _pme ); + nlassert( pmed ); + + int i = 0; + CMoldElt* pme = pmed->GetEltPtr( i ); + while( pme ) + { + switch( pme->GetType() ) + { + case 0: + { + CItemEltAtom* piea = new CItemEltAtom( pl ); + piea->BuildItem( pme ); + if( pme->IsList() ) + { + CItemEltList* piel = new CItemEltList( pl ); + piel->BuildItem( piea ); + piel->SetName( pmed->GetEltName( i ) ); + vpie.push_back( piel ); + } + else + { + piea->SetName( pmed->GetEltName( i ) ); + vpie.push_back( piea ); + } + break; + } + case 1: + { + CItemEltStruct* pies = new CItemEltStruct( pl ); + pies->BuildItem( pme ); + if( pme->IsList() ) + { + CItemEltList* piel = new CItemEltList( pl ); + piel->BuildItem( pies ); + piel->SetName( pmed->GetEltName( i ) ); + vpie.push_back( piel ); + } + else + { + pies->SetName( pmed->GetEltName( i ) ); + vpie.push_back( pies ); + } + break; + } + } + pme = pmed->GetEltPtr( ++i ); + } +} + +CStringEx CItemEltStruct::GetFormula() const +{ + nlassert( pmed ); + return( pmed->GetFormula() ); +} + +void CItemEltStruct::FillParent( const CFormBodyElt* const _pfbe ) +{ + for( std::vector< CItemElt* >::iterator it = vpie.begin(); it != vpie.end(); ++it ) + { + CFormBodyElt* pfbe = _pfbe->GetElt( (*it)->GetName() ); + if( pfbe ) + (*it)->FillParent( pfbe ); + } +} + +void CItemEltStruct::FillCurrent( const CFormBodyElt* const _pfbe ) +{ + for( std::vector< CItemElt* >::iterator it = vpie.begin(); it != vpie.end(); ++it ) + { + CFormBodyElt* pfbe = _pfbe->GetElt( (*it)->GetName() ); + if( pfbe ) + (*it)->FillCurrent( pfbe ); + } +} + +CItemElt* CItemEltStruct::Clone() +{ + CItemEltStruct* pies = new CItemEltStruct( pl ); + pies->BuildItem( pmed ); + return( pies ); +} + +CFormBodyElt* CItemEltStruct::BuildForm() +{ + CFormBodyEltStruct* pfbes = new CFormBodyEltStruct(); + pfbes->SetName( sxname ); + BuildForm( pfbes ); + if( !pfbes->Empty() ) + return( pfbes ); + delete pfbes; + return( 0 ); +} + +void CItemEltStruct::BuildForm( CFormBodyEltStruct* const _pfbes ) +{ + if( bmodified ) + for( std::vector< CItemElt* >::iterator it = vpie.begin(); it != vpie.end(); ++it ) + (*it)->SetModified( true ); + for( std::vector< CItemElt* >::iterator it = vpie.begin(); it != vpie.end(); ++it ) + _pfbes->AddElt( (*it)->BuildForm() ); +} + +void CItemEltStruct::BuildForm( CFormBodyEltStruct* const _pfbes, const std::vector< std::pair< CStringEx, CStringEx > >& _vsxparents ) +{ + BuildForm( _pfbes ); + + if( !_vsxparents.empty() ) + { + CFormBodyEltList* pfbel = new CFormBodyEltList; + pfbel->SetName( "Parents" ); + int i = 0; + CStringEx sx; + for( std::vector< std::pair< CStringEx, CStringEx > >::const_iterator it = _vsxparents.begin(); it != _vsxparents.end(); ++it ) + { + CFormBodyEltStruct* pfbes = new CFormBodyEltStruct; + sx.format( "#%d", i++ ); + pfbes->SetName( sx ); + pfbel->AddElt( pfbes ); + + CFormBodyEltAtom* pfbea = new CFormBodyEltAtom; + pfbea->SetName( "Activity" ); + pfbea->SetValue( it->first ); + pfbes->AddElt( pfbea ); + + pfbea = new CFormBodyEltAtom; + pfbea->SetName( "Filename" ); + pfbea->SetValue( it->second ); + pfbes->AddElt( pfbea ); + } + _pfbes->AddElt( pfbel ); + } +} + +unsigned int CItemEltStruct::GetNbElt() const +{ + unsigned int nb = 0; + for( std::vector< CItemElt* >::const_iterator it = vpie.begin(); it != vpie.end(); ++it ) + nb += (*it)->GetNbElt(); + return( ++nb ); +} + +CItemElt* CItemEltStruct::GetElt( const unsigned int _index ) const +{ + if( !_index ) + return( ( CItemElt * )( this ) ); + unsigned int isum = 1; + for( std::vector< CItemElt* >::const_iterator it = vpie.begin(); it != vpie.end(); ++it ) + { + unsigned int nb = (*it)->GetNbElt(); + if( isum+nb > _index ) + return( (*it)->GetElt( _index-isum ) ); + isum += nb; + } + return( 0 ); +} + +CItemElt* CItemEltStruct::GetElt( const CStringEx _sxname ) const +{ + for( std::vector< CItemElt* >::const_iterator it = vpie.begin(); it != vpie.end(); ++it ) + if( (*it)->GetName() == _sxname ) + return( *it ); + return( 0 ); +} + +bool CItemEltStruct::SetModified( const unsigned int _index ) +{ +// SetModified( true ); + if( !_index ) + return( true ); + unsigned int isum = 1; + for( std::vector< CItemElt* >::const_iterator it = vpie.begin(); it != vpie.end(); ++it ) + { + unsigned int nb = (*it)->GetNbElt(); + if( isum+nb > _index ) + return( (*it)->SetModified( _index-isum ) ); + isum += nb; + } + return( false ); +} + +void CItemEltStruct::SetModified( const bool _b ) +{ + bmodified = _b; + if( !_b ) + for( std::vector< CItemElt* >::const_iterator it = vpie.begin(); it != vpie.end(); ++it ) + (*it)->SetModified( _b ); +} + +unsigned int CItemEltStruct::GetNbChild () +{ + return 0; +} + +CItemElt* CItemEltStruct::GetChild (unsigned int _index) +{ + return NULL; +} + +unsigned int CItemEltStruct::GetNbStructElt () +{ + return vpie.size(); +} + +CItemElt* CItemEltStruct::GetStructElt (unsigned int _index) +{ + return vpie[_index]; +} + } \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_convert/item_elt_struct.h b/code/ryzom/tools/leveldesign/georges_convert/item_elt_struct.h index 5e1b5c48e..8ab51ea73 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/item_elt_struct.h +++ b/code/ryzom/tools/leveldesign/georges_convert/item_elt_struct.h @@ -1,63 +1,63 @@ -// 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 NLGEORGES_ITEM_ELT_STRUCT_H -#define NLGEORGES_ITEM_ELT_STRUCT_H - -#include "item_elt.h" - -namespace NLOLDGEORGES -{ - -class CMoldElt; -class CMoldEltDefine; -class CFormBodyEltStruct; - -class CItemEltStruct : public CItemElt -{ -protected: - CMoldEltDefine* pmed; - std::vector< CItemElt* > vpie; - void Clear(); - -public: - CItemEltStruct( CLoader* const _pl ); - virtual ~CItemEltStruct(); - - void BuildItem( CMoldElt* const _pme ); - - virtual CStringEx GetFormula() const; - virtual void FillParent( const CFormBodyElt* const _pfbe ); - virtual void FillCurrent(const CFormBodyElt* const _pfbe ); - virtual CItemElt* Clone(); - virtual CFormBodyElt* BuildForm(); - void BuildForm( CFormBodyEltStruct* const _pfbes ); - void BuildForm( CFormBodyEltStruct* const _pfbes, const std::vector< std::pair< CStringEx, CStringEx > >& _vsxparents ); - virtual unsigned int GetNbElt() const; - virtual CItemElt* GetElt( const unsigned int _index ) const; - virtual CItemElt* GetElt( const CStringEx sxname ) const; - virtual bool SetModified( const unsigned int _index ); - virtual void SetModified( const bool _b ); - - virtual unsigned int GetNbChild (); - virtual CItemElt* GetChild (unsigned int _index); - unsigned int GetNbStructElt (); - CItemElt* GetStructElt (unsigned int _index); -}; - -} // NLGEORGES - -#endif // NLGEORGES_ITEM_ELT_STRUCT_H +// 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 NLGEORGES_ITEM_ELT_STRUCT_H +#define NLGEORGES_ITEM_ELT_STRUCT_H + +#include "item_elt.h" + +namespace NLOLDGEORGES +{ + +class CMoldElt; +class CMoldEltDefine; +class CFormBodyEltStruct; + +class CItemEltStruct : public CItemElt +{ +protected: + CMoldEltDefine* pmed; + std::vector< CItemElt* > vpie; + void Clear(); + +public: + CItemEltStruct( CLoader* const _pl ); + virtual ~CItemEltStruct(); + + void BuildItem( CMoldElt* const _pme ); + + virtual CStringEx GetFormula() const; + virtual void FillParent( const CFormBodyElt* const _pfbe ); + virtual void FillCurrent(const CFormBodyElt* const _pfbe ); + virtual CItemElt* Clone(); + virtual CFormBodyElt* BuildForm(); + void BuildForm( CFormBodyEltStruct* const _pfbes ); + void BuildForm( CFormBodyEltStruct* const _pfbes, const std::vector< std::pair< CStringEx, CStringEx > >& _vsxparents ); + virtual unsigned int GetNbElt() const; + virtual CItemElt* GetElt( const unsigned int _index ) const; + virtual CItemElt* GetElt( const CStringEx sxname ) const; + virtual bool SetModified( const unsigned int _index ); + virtual void SetModified( const bool _b ); + + virtual unsigned int GetNbChild (); + virtual CItemElt* GetChild (unsigned int _index); + unsigned int GetNbStructElt (); + CItemElt* GetStructElt (unsigned int _index); +}; + +} // NLGEORGES + +#endif // NLGEORGES_ITEM_ELT_STRUCT_H diff --git a/code/ryzom/tools/leveldesign/georges_convert/item_loader.cpp b/code/ryzom/tools/leveldesign/georges_convert/item_loader.cpp index 76387ce55..c522bf829 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/item_loader.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/item_loader.cpp @@ -1,50 +1,50 @@ -// 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 "stdgeorgesconvert.h" -#include "item_loader.h" - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CItemLoader::CItemLoader() -{ -} - -CItemLoader::~CItemLoader() -{ -} - -void CItemLoader::LoadItem( CItem& _item, const CStringEx& _sxfilename ) -{ - _item.Load( _sxfilename ); -} - -void CItemLoader::LoadItem( CItem& _item, const CStringEx& _sxfilename, const CStringEx& _sxdate ) -{ - _item.Load( _sxfilename, _sxdate ); -} - -void CItemLoader::SaveItem( CItem& _item, const CStringEx& _sxfilename ) -{ - _item.Save( _sxfilename ); -} - +// 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 "stdgeorgesconvert.h" +#include "item_loader.h" + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CItemLoader::CItemLoader() +{ +} + +CItemLoader::~CItemLoader() +{ +} + +void CItemLoader::LoadItem( CItem& _item, const CStringEx& _sxfilename ) +{ + _item.Load( _sxfilename ); +} + +void CItemLoader::LoadItem( CItem& _item, const CStringEx& _sxfilename, const CStringEx& _sxdate ) +{ + _item.Load( _sxfilename, _sxdate ); +} + +void CItemLoader::SaveItem( CItem& _item, const CStringEx& _sxfilename ) +{ + _item.Save( _sxfilename ); +} + } \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_convert/item_loader.h b/code/ryzom/tools/leveldesign/georges_convert/item_loader.h index da34050f9..a94b08096 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/item_loader.h +++ b/code/ryzom/tools/leveldesign/georges_convert/item_loader.h @@ -1,40 +1,40 @@ -// 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 NLGEORGES_ITEM_LOADER_H -#define NLGEORGES_ITEM_LOADER_H - -#include "item.h" - -namespace NLOLDGEORGES -{ - -class CItemLoader -{ -// std::map< CStringEx, CFormFile* >; - -public: - CItemLoader(); - virtual ~CItemLoader(); - - void LoadItem( CItem& _item, const CStringEx& _sxfilename ); - void LoadItem( CItem& _item, const CStringEx& _sxfilename, const CStringEx& _sxdate ); - void SaveItem( CItem& _item, const CStringEx& _sxfilename ); -}; - -} // NLGEORGES - -#endif // NLGEORGES_ITEM_LOADER_H +// 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 NLGEORGES_ITEM_LOADER_H +#define NLGEORGES_ITEM_LOADER_H + +#include "item.h" + +namespace NLOLDGEORGES +{ + +class CItemLoader +{ +// std::map< CStringEx, CFormFile* >; + +public: + CItemLoader(); + virtual ~CItemLoader(); + + void LoadItem( CItem& _item, const CStringEx& _sxfilename ); + void LoadItem( CItem& _item, const CStringEx& _sxfilename, const CStringEx& _sxdate ); + void SaveItem( CItem& _item, const CStringEx& _sxfilename ); +}; + +} // NLGEORGES + +#endif // NLGEORGES_ITEM_LOADER_H diff --git a/code/ryzom/tools/leveldesign/georges_convert/mold_elt.cpp b/code/ryzom/tools/leveldesign/georges_convert/mold_elt.cpp index 1a5f0dc8d..7501ac1ed 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/mold_elt.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/mold_elt.cpp @@ -1,92 +1,92 @@ -// 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 "stdgeorgesconvert.h" -#include "mold_elt.h" - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CMoldElt::CMoldElt( CLoader* const _pl ) -{ - pl = _pl; - benum = false; - blist = false; -} - -CMoldElt::~CMoldElt() -{ -} - -CStringEx CMoldElt::GetFormula() -{ - return sxname; -} - -void CMoldElt::Load( const CStringEx _sxfullname ) -{ -} - -void CMoldElt::Load( const CStringEx _sxfullname, const CStringEx _sxdate ) -{ -} - -CStringEx CMoldElt::GetEltName( const unsigned int _index ) const -{ - CStringEx object; - return( object ); -} - -CMoldElt* CMoldElt::GetEltPtr( const unsigned int _index ) const -{ - return( 0 ); -} - -unsigned int CMoldElt::GetType() const -{ - return( -1 ); -} - -CStringEx CMoldElt::GetName() const -{ - return( sxname ); -} - -void CMoldElt::SetName( const CStringEx& _sxname ) -{ - sxname = _sxname; -} - -bool CMoldElt::IsEnum() const -{ - return( benum ); -} - -bool CMoldElt::IsList() const -{ - return( blist ); -} - -CMoldElt* CMoldElt::GetMold() -{ - return( this ); -} - -} +// 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 "stdgeorgesconvert.h" +#include "mold_elt.h" + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CMoldElt::CMoldElt( CLoader* const _pl ) +{ + pl = _pl; + benum = false; + blist = false; +} + +CMoldElt::~CMoldElt() +{ +} + +CStringEx CMoldElt::GetFormula() +{ + return sxname; +} + +void CMoldElt::Load( const CStringEx _sxfullname ) +{ +} + +void CMoldElt::Load( const CStringEx _sxfullname, const CStringEx _sxdate ) +{ +} + +CStringEx CMoldElt::GetEltName( const unsigned int _index ) const +{ + CStringEx object; + return( object ); +} + +CMoldElt* CMoldElt::GetEltPtr( const unsigned int _index ) const +{ + return( 0 ); +} + +unsigned int CMoldElt::GetType() const +{ + return( -1 ); +} + +CStringEx CMoldElt::GetName() const +{ + return( sxname ); +} + +void CMoldElt::SetName( const CStringEx& _sxname ) +{ + sxname = _sxname; +} + +bool CMoldElt::IsEnum() const +{ + return( benum ); +} + +bool CMoldElt::IsList() const +{ + return( blist ); +} + +CMoldElt* CMoldElt::GetMold() +{ + return( this ); +} + +} diff --git a/code/ryzom/tools/leveldesign/georges_convert/mold_elt.h b/code/ryzom/tools/leveldesign/georges_convert/mold_elt.h index 8956394e3..297c50aab 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/mold_elt.h +++ b/code/ryzom/tools/leveldesign/georges_convert/mold_elt.h @@ -1,61 +1,61 @@ -// 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 NLGEORGES_MOLD_ELT_H -#define NLGEORGES_MOLD_ELT_H - -#include "string_ex.h" - -namespace NLOLDGEORGES -{ - -class CLoader; - -class CMoldElt -{ -protected: - CLoader* pl; - bool benum; - bool blist; - CStringEx sxname; - CStringEx sxfullname; - -public: - CMoldElt( CLoader* const _pl ); - virtual ~CMoldElt(); - - CStringEx GetName() const; - void SetName( const CStringEx& _sxname ); - bool IsEnum() const; - bool IsList() const; -/* - virtual CStringEx GetName() const; - virtual void SetName( const CStringEx& _sxname ); - virtual bool IsEnum() const; - virtual bool IsList() const; -*/ - virtual CStringEx GetFormula(); - virtual void Load( const CStringEx _sxfullname ); - virtual void Load( const CStringEx _sxfullname, const CStringEx _sxdate ); - virtual CStringEx GetEltName( const unsigned int _index ) const; - virtual CMoldElt* GetEltPtr( const unsigned int _index ) const; - virtual unsigned int GetType() const; - virtual CMoldElt* GetMold(); -}; - -} // NLGEORGES - -#endif // NLGEORGES_MOLD_ELT_H +// 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 NLGEORGES_MOLD_ELT_H +#define NLGEORGES_MOLD_ELT_H + +#include "string_ex.h" + +namespace NLOLDGEORGES +{ + +class CLoader; + +class CMoldElt +{ +protected: + CLoader* pl; + bool benum; + bool blist; + CStringEx sxname; + CStringEx sxfullname; + +public: + CMoldElt( CLoader* const _pl ); + virtual ~CMoldElt(); + + CStringEx GetName() const; + void SetName( const CStringEx& _sxname ); + bool IsEnum() const; + bool IsList() const; +/* + virtual CStringEx GetName() const; + virtual void SetName( const CStringEx& _sxname ); + virtual bool IsEnum() const; + virtual bool IsList() const; +*/ + virtual CStringEx GetFormula(); + virtual void Load( const CStringEx _sxfullname ); + virtual void Load( const CStringEx _sxfullname, const CStringEx _sxdate ); + virtual CStringEx GetEltName( const unsigned int _index ) const; + virtual CMoldElt* GetEltPtr( const unsigned int _index ) const; + virtual unsigned int GetType() const; + virtual CMoldElt* GetMold(); +}; + +} // NLGEORGES + +#endif // NLGEORGES_MOLD_ELT_H diff --git a/code/ryzom/tools/leveldesign/georges_convert/mold_elt_define.cpp b/code/ryzom/tools/leveldesign/georges_convert/mold_elt_define.cpp index 19e5593c8..b81ec75ee 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/mold_elt_define.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/mold_elt_define.cpp @@ -1,84 +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 . - -#include "stdgeorgesconvert.h" -#include "georges_loader.h" -#include "mold_elt_define.h" -#include "form_body_elt_struct.h" - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CMoldEltDefine::CMoldEltDefine( CLoader* const _pl ) : CMoldElt( _pl ) -{ -} - -CMoldEltDefine::~CMoldEltDefine() -{ -} - -void CMoldEltDefine::Load( const CStringEx _sxfilename ) -{ - CForm f; - pl->LoadForm( f, _sxfilename ); - CFormBodyElt* pbody = f.GetBody(); - - unsigned int i = 0; - CFormBodyElt* pfbeatom = pbody->GetElt( i++ ); - while( pfbeatom ) - { - CStringEx sxvalue = pfbeatom->GetValue(); - CStringEx sxname = pfbeatom->GetName(); - pfbeatom = pbody->GetElt( i++ ); - CMoldElt* pme = pl->LoadMold( sxvalue ); - if( pme ) - vpair.push_back( std::make_pair( sxname, pme ) ); - } -} - -void CMoldEltDefine::Load( const CStringEx _sxfilename, const CStringEx _sxdate ) -{ -} - -CStringEx CMoldEltDefine::GetEltName( const unsigned int _index ) const -{ - if( _index < vpair.size() ) - return( vpair[_index].first ); - return( 0 ); -} - -CMoldElt* CMoldEltDefine::GetEltPtr( const unsigned int _index ) const -{ - if( _index < vpair.size() ) - return( vpair[_index].second ); - return( 0 ); -} - -unsigned int CMoldEltDefine::GetType() const -{ - return( 1 ); -} - -CMoldElt* CMoldEltDefine::GetMold() -{ - return( this ); -} - +// 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 "stdgeorgesconvert.h" +#include "georges_loader.h" +#include "mold_elt_define.h" +#include "form_body_elt_struct.h" + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CMoldEltDefine::CMoldEltDefine( CLoader* const _pl ) : CMoldElt( _pl ) +{ +} + +CMoldEltDefine::~CMoldEltDefine() +{ +} + +void CMoldEltDefine::Load( const CStringEx _sxfilename ) +{ + CForm f; + pl->LoadForm( f, _sxfilename ); + CFormBodyElt* pbody = f.GetBody(); + + unsigned int i = 0; + CFormBodyElt* pfbeatom = pbody->GetElt( i++ ); + while( pfbeatom ) + { + CStringEx sxvalue = pfbeatom->GetValue(); + CStringEx sxname = pfbeatom->GetName(); + pfbeatom = pbody->GetElt( i++ ); + CMoldElt* pme = pl->LoadMold( sxvalue ); + if( pme ) + vpair.push_back( std::make_pair( sxname, pme ) ); + } +} + +void CMoldEltDefine::Load( const CStringEx _sxfilename, const CStringEx _sxdate ) +{ +} + +CStringEx CMoldEltDefine::GetEltName( const unsigned int _index ) const +{ + if( _index < vpair.size() ) + return( vpair[_index].first ); + return( 0 ); +} + +CMoldElt* CMoldEltDefine::GetEltPtr( const unsigned int _index ) const +{ + if( _index < vpair.size() ) + return( vpair[_index].second ); + return( 0 ); +} + +unsigned int CMoldEltDefine::GetType() const +{ + return( 1 ); +} + +CMoldElt* CMoldEltDefine::GetMold() +{ + return( this ); +} + } \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_convert/mold_elt_define.h b/code/ryzom/tools/leveldesign/georges_convert/mold_elt_define.h index 07ed74d35..fd11a8cc4 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/mold_elt_define.h +++ b/code/ryzom/tools/leveldesign/georges_convert/mold_elt_define.h @@ -1,46 +1,46 @@ -// 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 NLGEORGES_MOLD_ELT_DEFINE_H -#define NLGEORGES_MOLD_ELT_DEFINE_H - -#include "mold_elt.h" - -namespace NLOLDGEORGES -{ - -class CLoader; - -class CMoldEltDefine : public CMoldElt -{ -protected: - std::vector< std::pair< CStringEx, CMoldElt* > > vpair; - -public: - CMoldEltDefine( CLoader* const _pl ); - virtual ~CMoldEltDefine(); - - virtual CMoldElt* GetMold(); - virtual void Load( const CStringEx _sxfilename ); - virtual void Load( const CStringEx _sxfilename, const CStringEx _sxdate ); - virtual CStringEx GetEltName( const unsigned int _index ) const; - virtual CMoldElt* GetEltPtr( const unsigned int _index ) const; - virtual unsigned int GetType() const; -}; - -} // NLGEORGES - -#endif // NLGEORGES_MOLD_ELT_DEFINE_H +// 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 NLGEORGES_MOLD_ELT_DEFINE_H +#define NLGEORGES_MOLD_ELT_DEFINE_H + +#include "mold_elt.h" + +namespace NLOLDGEORGES +{ + +class CLoader; + +class CMoldEltDefine : public CMoldElt +{ +protected: + std::vector< std::pair< CStringEx, CMoldElt* > > vpair; + +public: + CMoldEltDefine( CLoader* const _pl ); + virtual ~CMoldEltDefine(); + + virtual CMoldElt* GetMold(); + virtual void Load( const CStringEx _sxfilename ); + virtual void Load( const CStringEx _sxfilename, const CStringEx _sxdate ); + virtual CStringEx GetEltName( const unsigned int _index ) const; + virtual CMoldElt* GetEltPtr( const unsigned int _index ) const; + virtual unsigned int GetType() const; +}; + +} // NLGEORGES + +#endif // NLGEORGES_MOLD_ELT_DEFINE_H diff --git a/code/ryzom/tools/leveldesign/georges_convert/mold_elt_define_list.cpp b/code/ryzom/tools/leveldesign/georges_convert/mold_elt_define_list.cpp index 49905c933..8d221185b 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/mold_elt_define_list.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/mold_elt_define_list.cpp @@ -1,94 +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 . - -#include "stdgeorgesconvert.h" -#include "georges_loader.h" -#include "mold_elt_define_list.h" -#include "form_body_elt_struct.h" - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CMoldEltDefineList::CMoldEltDefineList( CLoader* const _pl, CMoldEltDefine* const _pmed ) : CMoldEltDefine( _pl ) -{ - pmed = _pmed; - blist = true; - benum = pmed->IsEnum(); - sxname = pmed->GetName(); -} - -CMoldEltDefineList::~CMoldEltDefineList() -{ -} - -void CMoldEltDefineList::Load( const CStringEx _sxfullname ) -{ - pmed->Load( _sxfullname ); -} - -void CMoldEltDefineList::Load( const CStringEx _sxfullname, const CStringEx _sxdate ) -{ - pmed->Load( _sxfullname, _sxdate ); - benum = pmed->IsEnum(); - sxname = pmed->GetName(); -} - -CStringEx CMoldEltDefineList::GetEltName( const unsigned int _index ) const -{ - return( pmed->GetEltName( _index ) ); -} - -CMoldElt* CMoldEltDefineList::GetEltPtr( const unsigned int _index ) const -{ - return( pmed->GetEltPtr( _index ) ); -} - -unsigned int CMoldEltDefineList::GetType() const -{ - return( pmed->GetType() ); -} - -CMoldElt* CMoldEltDefineList::GetMold() -{ - return( pmed ); -} -/* -CStringEx CMoldEltDefineList::GetName() const -{ - return( pmed->GetName() ); -} - -void CMoldEltDefineList::SetName( const CStringEx& _sxname ) -{ - pmed->SetName( _sxname ); -} - -bool CMoldEltDefineList::IsEnum() const -{ - return( pmed->IsEnum() ); -} - -bool CMoldEltDefineList::IsList() const -{ - return( pmed->IsList() ); -} -*/ - +// 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 "stdgeorgesconvert.h" +#include "georges_loader.h" +#include "mold_elt_define_list.h" +#include "form_body_elt_struct.h" + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CMoldEltDefineList::CMoldEltDefineList( CLoader* const _pl, CMoldEltDefine* const _pmed ) : CMoldEltDefine( _pl ) +{ + pmed = _pmed; + blist = true; + benum = pmed->IsEnum(); + sxname = pmed->GetName(); +} + +CMoldEltDefineList::~CMoldEltDefineList() +{ +} + +void CMoldEltDefineList::Load( const CStringEx _sxfullname ) +{ + pmed->Load( _sxfullname ); +} + +void CMoldEltDefineList::Load( const CStringEx _sxfullname, const CStringEx _sxdate ) +{ + pmed->Load( _sxfullname, _sxdate ); + benum = pmed->IsEnum(); + sxname = pmed->GetName(); +} + +CStringEx CMoldEltDefineList::GetEltName( const unsigned int _index ) const +{ + return( pmed->GetEltName( _index ) ); +} + +CMoldElt* CMoldEltDefineList::GetEltPtr( const unsigned int _index ) const +{ + return( pmed->GetEltPtr( _index ) ); +} + +unsigned int CMoldEltDefineList::GetType() const +{ + return( pmed->GetType() ); +} + +CMoldElt* CMoldEltDefineList::GetMold() +{ + return( pmed ); +} +/* +CStringEx CMoldEltDefineList::GetName() const +{ + return( pmed->GetName() ); +} + +void CMoldEltDefineList::SetName( const CStringEx& _sxname ) +{ + pmed->SetName( _sxname ); +} + +bool CMoldEltDefineList::IsEnum() const +{ + return( pmed->IsEnum() ); +} + +bool CMoldEltDefineList::IsList() const +{ + return( pmed->IsList() ); +} +*/ + } \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_convert/mold_elt_define_list.h b/code/ryzom/tools/leveldesign/georges_convert/mold_elt_define_list.h index 82ffde0eb..79a3ced5f 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/mold_elt_define_list.h +++ b/code/ryzom/tools/leveldesign/georges_convert/mold_elt_define_list.h @@ -1,46 +1,46 @@ -// 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 NLGEORGES_MOLD_ELT_DEFINE_LIST_H -#define NLGEORGES_MOLD_ELT_DEFINE_LIST_H - -#include "mold_elt_define.h" - -namespace NLOLDGEORGES -{ - -class CLoader; - -class CMoldEltDefineList : public CMoldEltDefine -{ -protected: - CMoldEltDefine* pmed; - -public: - CMoldEltDefineList( CLoader* const _pl, CMoldEltDefine* const _pmed ); - virtual ~CMoldEltDefineList(); - - virtual CMoldElt* GetMold(); - virtual void Load( const CStringEx _sxfullname ); - virtual void Load( const CStringEx _sxfullname, const CStringEx _sxdate ); - virtual CStringEx GetEltName( const unsigned int _index ) const; - virtual CMoldElt* GetEltPtr( const unsigned int _index ) const; - virtual unsigned int GetType() const; -}; - -} // NLGEORGES - -#endif // NLGEORGES_MOLD_ELT_DEFINE_LIST_H +// 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 NLGEORGES_MOLD_ELT_DEFINE_LIST_H +#define NLGEORGES_MOLD_ELT_DEFINE_LIST_H + +#include "mold_elt_define.h" + +namespace NLOLDGEORGES +{ + +class CLoader; + +class CMoldEltDefineList : public CMoldEltDefine +{ +protected: + CMoldEltDefine* pmed; + +public: + CMoldEltDefineList( CLoader* const _pl, CMoldEltDefine* const _pmed ); + virtual ~CMoldEltDefineList(); + + virtual CMoldElt* GetMold(); + virtual void Load( const CStringEx _sxfullname ); + virtual void Load( const CStringEx _sxfullname, const CStringEx _sxdate ); + virtual CStringEx GetEltName( const unsigned int _index ) const; + virtual CMoldElt* GetEltPtr( const unsigned int _index ) const; + virtual unsigned int GetType() const; +}; + +} // NLGEORGES + +#endif // NLGEORGES_MOLD_ELT_DEFINE_LIST_H diff --git a/code/ryzom/tools/leveldesign/georges_convert/mold_elt_type.cpp b/code/ryzom/tools/leveldesign/georges_convert/mold_elt_type.cpp index f295b2e4a..3d5f5aeae 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/mold_elt_type.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/mold_elt_type.cpp @@ -1,323 +1,323 @@ -// 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 "stdgeorgesconvert.h" -#include "mold_elt_type.h" -#include "georges_loader.h" -#include "form_body_elt.h" -#include "type_unit_int_unsigned.h" -#include "type_unit_int_signed.h" -#include "type_unit_double.h" -#include "type_unit_string.h" -#include "type_unit_file_name.h" - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CMoldEltType::CMoldEltType( CLoader* const _pl ) : CMoldElt( _pl ) -{ -} - -CMoldEltType::~CMoldEltType() -{ -} - -void CMoldEltType::Load( const CStringEx _sxfullname ) -{ - sxfullname = _sxfullname; - CForm f; - pl->LoadForm( f, _sxfullname ); - - CStringEx sxll, sxhl, sxdv; - CFormBodyElt* pfbe; - pfbe = f.GetElt("Type"); - if( pfbe ) - sxtype = pfbe->GetValue(); - pfbe = f.GetElt("Lowlimit"); - if( pfbe ) - sxll = pfbe->GetValue(); - pfbe = f.GetElt("Highlimit"); - if( pfbe ) - sxhl = pfbe->GetValue(); - pfbe = f.GetElt("DefaultValue"); - if( pfbe ) - sxdv = pfbe->GetValue(); - pfbe = f.GetElt("Formula"); - if( pfbe ) - sxformula = pfbe->GetValue(); - pfbe = f.GetElt("Enum"); - if( pfbe ) - sxenum = pfbe->GetValue(); - - ptu = NULL; - if( sxtype == "uint" ) - ptu = new CTypeUnitIntUnsigned( sxll, sxhl, sxdv, sxformula ); - else if( sxtype == "sint" ) - ptu = new CTypeUnitIntSigned( sxll, sxhl, sxdv, sxformula ); - else if( sxtype == "double" ) - ptu = new CTypeUnitDouble( sxll, sxhl, sxdv, sxformula ); - else if( sxtype == "filename" ) - ptu = new CTypeUnitFileName( sxll, sxhl, sxdv, sxformula ); - else if( sxtype == "string" ) - ptu = new CTypeUnitString( sxll, sxhl, sxdv, sxformula ); - - benum = ( sxenum == "true" ); - - CFormBodyElt* pfbepredef = f.GetElt("Predef"); - if( pfbepredef ) - { - unsigned int i = 0; - CFormBodyElt* pfbe = pfbepredef->GetElt( i++ ); - while( pfbe ) - { - CFormBodyElt* pfbedesignation = pfbe->GetElt( "Designation" ); - CFormBodyElt* pfbesubstitute = pfbe->GetElt( "Substitute" ); - nlassert( pfbedesignation ); - nlassert( pfbesubstitute ); - vpredef.push_back( std::make_pair( pfbedesignation->GetValue(), pfbesubstitute->GetValue() ) ); - pfbe = pfbepredef->GetElt( i++ ); - } - } -} - -void CMoldEltType::Load( const CStringEx _sxfullname, const CStringEx _sxdate ) -{ -} - -CStringEx CMoldEltType::GetFormula() -{ - return( ptu->GetFormula() ); -} - -CStringEx CMoldEltType::Format( const CStringEx _sxvalue ) const -{ - if( _sxvalue.empty() ) - return( _sxvalue ); - CStringEx sx = GetPredefSubstitute( _sxvalue ); - if( sx.empty() ) - if( benum ) - { - CStringEx object; - return( object ); - } - else - return( ptu->Format( _sxvalue ) ); - return( GetPredefDesignation( sx ) ); -} - -CStringEx CMoldEltType::CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const -{ -// if( _sxvalue.empty() ) -// return( _sxbasevalue ); -// CStringEx sx = GetPredefSubstitute( _sxvalue ); - - CStringEx sx; - if (_sxvalue.empty()) - sx = _sxbasevalue; - else - sx = _sxvalue; - sx = GetPredefSubstitute (sx); - - - if( benum ) - { - CStringEx sx2 = ptu->CalculateResult( _sxbasevalue, sx ); -// return( GetPredefDesignation( sx2 ) ); - return sx2; - } - if( sx.empty() ) - return( ptu->CalculateResult( _sxbasevalue, _sxvalue ) ); - return( ptu->CalculateResult( _sxbasevalue, sx ) ); -} - -CStringEx CMoldEltType::GetDefaultValue() const -{ - return( ptu->GetDefaultValue() ); -} - -unsigned int CMoldEltType::GetType() const -{ - return( 0 ); -} - -CStringEx CMoldEltType::GetPredefSubstitute( const CStringEx _sxdesignation ) const -{ - if( !_sxdesignation.empty() ) - for( std::vector< std::pair< CStringEx, CStringEx > >::const_iterator it = vpredef.begin(); it != vpredef.end(); ++it ) - if( it->first == _sxdesignation ) - return( it->second ); - CStringEx object; - return( object ); -} - -CStringEx CMoldEltType::GetPredefDesignation( const CStringEx _sxsubstitute ) const -{ - for( std::vector< std::pair< CStringEx, CStringEx > >::const_iterator it = vpredef.begin(); it != vpredef.end(); ++it ) - if( it->second == _sxsubstitute ) - return( it->first ); - CStringEx object; - return( object ); -} - -CStringEx CMoldEltType::GetPredefDesignation( const unsigned int _index ) const -{ - if( _index < vpredef.size() ) - return( vpredef[_index].first ); - CStringEx object; - return( object ); -} - -CMoldElt* CMoldEltType::GetMold() -{ - return( this ); -} - -void CMoldEltType::SetTypPredef( const std::vector< CStringEx >& _pvsx ) -{ - - CStringEx sxdv = GetPredefSubstitute( ptu->GetDefaultValue() ); - - vpredef.clear(); - if( sxtype == "string" || sxtype == "filename" ) - for( std::vector< CStringEx >::const_iterator it = _pvsx.begin(); it != _pvsx.end(); ++it ) - vpredef.push_back( std::make_pair( *it, *it ) ); - else if( sxtype == "uint" || sxtype == "sint" ) - { - CStringEx sx; - int i = 0; - for( std::vector< CStringEx >::const_iterator it = _pvsx.begin(); it != _pvsx.end(); ++it ) - { - sx.format( "%d", i++ ); - vpredef.push_back( std::make_pair( *it, sx ) ); - } - if( ( benum )&&( !vpredef.empty() ) ) - { - ptu->SetLowLimit( vpredef[0].first ); - ptu->SetHighLimit( vpredef[_pvsx.size()-1].first ); - ptu->SetDefaultValue( vpredef[0].first ); - } - } - - if( ! sxdv.empty() ) - ptu->SetDefaultValue( vpredef[0].first ); -} - -void CMoldEltType::Save() -{ - if( sxfullname.empty() ) - return; - - std::vector< std::pair< CStringEx, CStringEx > > lpsxparent; - pl->MakeTyp( sxfullname, sxtype, sxformula, sxenum, ptu->GetLowLimit(), ptu->GetHighLimit(), ptu->GetDefaultValue(), &vpredef, &lpsxparent ); - -} - -/* - CStringEx sxfullname = WhereIsDfnTyp( _sxfilename ); - - CForm f; - fl.LoadForm( f, sxfullname ); - if( sxfullname.empty() ) - return; - CFormBodyElt* pfbetype = f.GetElt("Type"); - nlassert( pfbetype ); - CFormBodyEltList* pfbepredef = dynamic_cast< CFormBodyEltList* >( f.GetElt("Predef") ); - if( !pfbepredef ) - { - pfbepredef = new CFormBodyEltList; - f.GetBody()->AddElt( pfbepredef ); - } - pfbepredef->Clear(); - - int i = 0; - CFormBodyEltStruct* pfbes; - CFormBodyEltAtom* pfbea; - CStringEx sx; - CStringEx sxtype = pfbetype->GetValue(); - if( sxtype == "string" ) - { - for( std::vector< CStringEx >::const_iterator it = _pvsx.begin(); it != _pvsx.end(); ++it ) - { - pfbes = new CFormBodyEltStruct; - sx.format( "#%d", i++ ); - pfbes->SetName( sx ); - pfbepredef->AddElt( pfbes ); - - pfbea = new CFormBodyEltAtom; - pfbea->SetName( "Designation" ); - pfbea->SetValue( *it ); - pfbes->AddElt( pfbea ); - - pfbea = new CFormBodyEltAtom; - pfbea->SetName( "Substitute" ); - pfbea->SetValue( *it ); - pfbes->AddElt( pfbea ); - } - pfbea = dynamic_cast< CFormBodyEltAtom* >( f.GetElt("DefaultValue") ); - nlassert( pfbea ); - pfbea->SetValue( _pvsx[0] ); - } - else - { - if( ( sxtype == "uint" )||( sxtype == "sint" ) ) - { - CStringEx sx2; - for( std::vector< CStringEx >::const_iterator it = _pvsx.begin(); it != _pvsx.end(); ++it ) - { - pfbes = new CFormBodyEltStruct; - sx.format( "#%d", i ); - pfbes->SetName( sx ); - pfbepredef->AddElt( pfbes ); - - pfbea = new CFormBodyEltAtom; - pfbea->SetName( "Designation" ); - pfbea->SetValue( *it ); - pfbes->AddElt( pfbea ); - - pfbea = new CFormBodyEltAtom; - pfbea->SetName( "Substitute" ); - sx.format( "%d", i++ ); - pfbea->SetValue( sx2 ); - pfbes->AddElt( pfbea ); - } - CFormBodyElt* pfbeenum = f.GetElt("Enum"); - nlassert( pfbeenum ); - pfbea = dynamic_cast< CFormBodyEltAtom* >( f.GetElt("DefaultValue") ); - nlassert( pfbea ); - if( pfbeenum->GetValue() == "true" ) - pfbea->SetValue( _pvsx[0] ); - pfbea = dynamic_cast< CFormBodyEltAtom* >( f.GetElt("Lowlimit") ); - nlassert( pfbea ); - pfbea->SetValue( _pvsx[0] ); - pfbea = dynamic_cast< CFormBodyEltAtom* >( f.GetElt("Highlimit") ); - nlassert( pfbea ); - pfbea->SetValue( _pvsx[_pvsx.size()-1] ); - } - } -} - -void CMoldEltType::Save() -{ - - fl.SaveForm( f, sxfullname ); -} -*/ - -} +// 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 "stdgeorgesconvert.h" +#include "mold_elt_type.h" +#include "georges_loader.h" +#include "form_body_elt.h" +#include "type_unit_int_unsigned.h" +#include "type_unit_int_signed.h" +#include "type_unit_double.h" +#include "type_unit_string.h" +#include "type_unit_file_name.h" + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CMoldEltType::CMoldEltType( CLoader* const _pl ) : CMoldElt( _pl ) +{ +} + +CMoldEltType::~CMoldEltType() +{ +} + +void CMoldEltType::Load( const CStringEx _sxfullname ) +{ + sxfullname = _sxfullname; + CForm f; + pl->LoadForm( f, _sxfullname ); + + CStringEx sxll, sxhl, sxdv; + CFormBodyElt* pfbe; + pfbe = f.GetElt("Type"); + if( pfbe ) + sxtype = pfbe->GetValue(); + pfbe = f.GetElt("Lowlimit"); + if( pfbe ) + sxll = pfbe->GetValue(); + pfbe = f.GetElt("Highlimit"); + if( pfbe ) + sxhl = pfbe->GetValue(); + pfbe = f.GetElt("DefaultValue"); + if( pfbe ) + sxdv = pfbe->GetValue(); + pfbe = f.GetElt("Formula"); + if( pfbe ) + sxformula = pfbe->GetValue(); + pfbe = f.GetElt("Enum"); + if( pfbe ) + sxenum = pfbe->GetValue(); + + ptu = NULL; + if( sxtype == "uint" ) + ptu = new CTypeUnitIntUnsigned( sxll, sxhl, sxdv, sxformula ); + else if( sxtype == "sint" ) + ptu = new CTypeUnitIntSigned( sxll, sxhl, sxdv, sxformula ); + else if( sxtype == "double" ) + ptu = new CTypeUnitDouble( sxll, sxhl, sxdv, sxformula ); + else if( sxtype == "filename" ) + ptu = new CTypeUnitFileName( sxll, sxhl, sxdv, sxformula ); + else if( sxtype == "string" ) + ptu = new CTypeUnitString( sxll, sxhl, sxdv, sxformula ); + + benum = ( sxenum == "true" ); + + CFormBodyElt* pfbepredef = f.GetElt("Predef"); + if( pfbepredef ) + { + unsigned int i = 0; + CFormBodyElt* pfbe = pfbepredef->GetElt( i++ ); + while( pfbe ) + { + CFormBodyElt* pfbedesignation = pfbe->GetElt( "Designation" ); + CFormBodyElt* pfbesubstitute = pfbe->GetElt( "Substitute" ); + nlassert( pfbedesignation ); + nlassert( pfbesubstitute ); + vpredef.push_back( std::make_pair( pfbedesignation->GetValue(), pfbesubstitute->GetValue() ) ); + pfbe = pfbepredef->GetElt( i++ ); + } + } +} + +void CMoldEltType::Load( const CStringEx _sxfullname, const CStringEx _sxdate ) +{ +} + +CStringEx CMoldEltType::GetFormula() +{ + return( ptu->GetFormula() ); +} + +CStringEx CMoldEltType::Format( const CStringEx _sxvalue ) const +{ + if( _sxvalue.empty() ) + return( _sxvalue ); + CStringEx sx = GetPredefSubstitute( _sxvalue ); + if( sx.empty() ) + if( benum ) + { + CStringEx object; + return( object ); + } + else + return( ptu->Format( _sxvalue ) ); + return( GetPredefDesignation( sx ) ); +} + +CStringEx CMoldEltType::CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const +{ +// if( _sxvalue.empty() ) +// return( _sxbasevalue ); +// CStringEx sx = GetPredefSubstitute( _sxvalue ); + + CStringEx sx; + if (_sxvalue.empty()) + sx = _sxbasevalue; + else + sx = _sxvalue; + sx = GetPredefSubstitute (sx); + + + if( benum ) + { + CStringEx sx2 = ptu->CalculateResult( _sxbasevalue, sx ); +// return( GetPredefDesignation( sx2 ) ); + return sx2; + } + if( sx.empty() ) + return( ptu->CalculateResult( _sxbasevalue, _sxvalue ) ); + return( ptu->CalculateResult( _sxbasevalue, sx ) ); +} + +CStringEx CMoldEltType::GetDefaultValue() const +{ + return( ptu->GetDefaultValue() ); +} + +unsigned int CMoldEltType::GetType() const +{ + return( 0 ); +} + +CStringEx CMoldEltType::GetPredefSubstitute( const CStringEx _sxdesignation ) const +{ + if( !_sxdesignation.empty() ) + for( std::vector< std::pair< CStringEx, CStringEx > >::const_iterator it = vpredef.begin(); it != vpredef.end(); ++it ) + if( it->first == _sxdesignation ) + return( it->second ); + CStringEx object; + return( object ); +} + +CStringEx CMoldEltType::GetPredefDesignation( const CStringEx _sxsubstitute ) const +{ + for( std::vector< std::pair< CStringEx, CStringEx > >::const_iterator it = vpredef.begin(); it != vpredef.end(); ++it ) + if( it->second == _sxsubstitute ) + return( it->first ); + CStringEx object; + return( object ); +} + +CStringEx CMoldEltType::GetPredefDesignation( const unsigned int _index ) const +{ + if( _index < vpredef.size() ) + return( vpredef[_index].first ); + CStringEx object; + return( object ); +} + +CMoldElt* CMoldEltType::GetMold() +{ + return( this ); +} + +void CMoldEltType::SetTypPredef( const std::vector< CStringEx >& _pvsx ) +{ + + CStringEx sxdv = GetPredefSubstitute( ptu->GetDefaultValue() ); + + vpredef.clear(); + if( sxtype == "string" || sxtype == "filename" ) + for( std::vector< CStringEx >::const_iterator it = _pvsx.begin(); it != _pvsx.end(); ++it ) + vpredef.push_back( std::make_pair( *it, *it ) ); + else if( sxtype == "uint" || sxtype == "sint" ) + { + CStringEx sx; + int i = 0; + for( std::vector< CStringEx >::const_iterator it = _pvsx.begin(); it != _pvsx.end(); ++it ) + { + sx.format( "%d", i++ ); + vpredef.push_back( std::make_pair( *it, sx ) ); + } + if( ( benum )&&( !vpredef.empty() ) ) + { + ptu->SetLowLimit( vpredef[0].first ); + ptu->SetHighLimit( vpredef[_pvsx.size()-1].first ); + ptu->SetDefaultValue( vpredef[0].first ); + } + } + + if( ! sxdv.empty() ) + ptu->SetDefaultValue( vpredef[0].first ); +} + +void CMoldEltType::Save() +{ + if( sxfullname.empty() ) + return; + + std::vector< std::pair< CStringEx, CStringEx > > lpsxparent; + pl->MakeTyp( sxfullname, sxtype, sxformula, sxenum, ptu->GetLowLimit(), ptu->GetHighLimit(), ptu->GetDefaultValue(), &vpredef, &lpsxparent ); + +} + +/* + CStringEx sxfullname = WhereIsDfnTyp( _sxfilename ); + + CForm f; + fl.LoadForm( f, sxfullname ); + if( sxfullname.empty() ) + return; + CFormBodyElt* pfbetype = f.GetElt("Type"); + nlassert( pfbetype ); + CFormBodyEltList* pfbepredef = dynamic_cast< CFormBodyEltList* >( f.GetElt("Predef") ); + if( !pfbepredef ) + { + pfbepredef = new CFormBodyEltList; + f.GetBody()->AddElt( pfbepredef ); + } + pfbepredef->Clear(); + + int i = 0; + CFormBodyEltStruct* pfbes; + CFormBodyEltAtom* pfbea; + CStringEx sx; + CStringEx sxtype = pfbetype->GetValue(); + if( sxtype == "string" ) + { + for( std::vector< CStringEx >::const_iterator it = _pvsx.begin(); it != _pvsx.end(); ++it ) + { + pfbes = new CFormBodyEltStruct; + sx.format( "#%d", i++ ); + pfbes->SetName( sx ); + pfbepredef->AddElt( pfbes ); + + pfbea = new CFormBodyEltAtom; + pfbea->SetName( "Designation" ); + pfbea->SetValue( *it ); + pfbes->AddElt( pfbea ); + + pfbea = new CFormBodyEltAtom; + pfbea->SetName( "Substitute" ); + pfbea->SetValue( *it ); + pfbes->AddElt( pfbea ); + } + pfbea = dynamic_cast< CFormBodyEltAtom* >( f.GetElt("DefaultValue") ); + nlassert( pfbea ); + pfbea->SetValue( _pvsx[0] ); + } + else + { + if( ( sxtype == "uint" )||( sxtype == "sint" ) ) + { + CStringEx sx2; + for( std::vector< CStringEx >::const_iterator it = _pvsx.begin(); it != _pvsx.end(); ++it ) + { + pfbes = new CFormBodyEltStruct; + sx.format( "#%d", i ); + pfbes->SetName( sx ); + pfbepredef->AddElt( pfbes ); + + pfbea = new CFormBodyEltAtom; + pfbea->SetName( "Designation" ); + pfbea->SetValue( *it ); + pfbes->AddElt( pfbea ); + + pfbea = new CFormBodyEltAtom; + pfbea->SetName( "Substitute" ); + sx.format( "%d", i++ ); + pfbea->SetValue( sx2 ); + pfbes->AddElt( pfbea ); + } + CFormBodyElt* pfbeenum = f.GetElt("Enum"); + nlassert( pfbeenum ); + pfbea = dynamic_cast< CFormBodyEltAtom* >( f.GetElt("DefaultValue") ); + nlassert( pfbea ); + if( pfbeenum->GetValue() == "true" ) + pfbea->SetValue( _pvsx[0] ); + pfbea = dynamic_cast< CFormBodyEltAtom* >( f.GetElt("Lowlimit") ); + nlassert( pfbea ); + pfbea->SetValue( _pvsx[0] ); + pfbea = dynamic_cast< CFormBodyEltAtom* >( f.GetElt("Highlimit") ); + nlassert( pfbea ); + pfbea->SetValue( _pvsx[_pvsx.size()-1] ); + } + } +} + +void CMoldEltType::Save() +{ + + fl.SaveForm( f, sxfullname ); +} +*/ + +} diff --git a/code/ryzom/tools/leveldesign/georges_convert/mold_elt_type.h b/code/ryzom/tools/leveldesign/georges_convert/mold_elt_type.h index b395563b3..68a2a778a 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/mold_elt_type.h +++ b/code/ryzom/tools/leveldesign/georges_convert/mold_elt_type.h @@ -1,59 +1,59 @@ -// 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 NLGEORGES_MOLD_ELT_TYPE_H -#define NLGEORGES_MOLD_ELT_TYPE_H - -#include "mold_elt.h" - -namespace NLOLDGEORGES -{ - -class CLoader; -class CTypeUnit; - -class CMoldEltType : public CMoldElt -{ -protected: - CTypeUnit* ptu; - std::vector< std::pair< CStringEx, CStringEx > > vpredef; - CStringEx sxtype; - CStringEx sxformula; - CStringEx sxenum; - -public: - CMoldEltType( CLoader* const _pl ); - virtual ~CMoldEltType(); - - virtual void Load( const CStringEx _sxfullname ); - virtual void Load( const CStringEx _sxfullname, const CStringEx _sxdate ); - - virtual CMoldElt* GetMold(); - virtual CStringEx GetDefaultValue() const; // Give the default value of the type - virtual CStringEx CalculateResult( const CStringEx _sxvalue, const CStringEx _sxbasevalue ) const; // Calculate the final result - virtual CStringEx Format( const CStringEx _sxvalue ) const; // Transform any value in the good format - virtual CStringEx GetPredefSubstitute( const CStringEx _sxdesignation ) const; - virtual CStringEx GetPredefDesignation( const CStringEx _sxdesignation ) const; // Give the value corresponding to the string - virtual CStringEx GetPredefDesignation( const unsigned int _index ) const; - virtual CStringEx GetFormula(); // Give the formula of the type : int(0,100) - virtual unsigned int GetType() const; // Give the type ( typ or dfn or nothing ) - void SetTypPredef( const std::vector< CStringEx >& _pvsx ); - void Save(); -}; - -} // NLGEORGES - -#endif // NLGEORGES_MOLD_ELT_TYPE_H +// 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 NLGEORGES_MOLD_ELT_TYPE_H +#define NLGEORGES_MOLD_ELT_TYPE_H + +#include "mold_elt.h" + +namespace NLOLDGEORGES +{ + +class CLoader; +class CTypeUnit; + +class CMoldEltType : public CMoldElt +{ +protected: + CTypeUnit* ptu; + std::vector< std::pair< CStringEx, CStringEx > > vpredef; + CStringEx sxtype; + CStringEx sxformula; + CStringEx sxenum; + +public: + CMoldEltType( CLoader* const _pl ); + virtual ~CMoldEltType(); + + virtual void Load( const CStringEx _sxfullname ); + virtual void Load( const CStringEx _sxfullname, const CStringEx _sxdate ); + + virtual CMoldElt* GetMold(); + virtual CStringEx GetDefaultValue() const; // Give the default value of the type + virtual CStringEx CalculateResult( const CStringEx _sxvalue, const CStringEx _sxbasevalue ) const; // Calculate the final result + virtual CStringEx Format( const CStringEx _sxvalue ) const; // Transform any value in the good format + virtual CStringEx GetPredefSubstitute( const CStringEx _sxdesignation ) const; + virtual CStringEx GetPredefDesignation( const CStringEx _sxdesignation ) const; // Give the value corresponding to the string + virtual CStringEx GetPredefDesignation( const unsigned int _index ) const; + virtual CStringEx GetFormula(); // Give the formula of the type : int(0,100) + virtual unsigned int GetType() const; // Give the type ( typ or dfn or nothing ) + void SetTypPredef( const std::vector< CStringEx >& _pvsx ); + void Save(); +}; + +} // NLGEORGES + +#endif // NLGEORGES_MOLD_ELT_TYPE_H diff --git a/code/ryzom/tools/leveldesign/georges_convert/mold_elt_type_list.cpp b/code/ryzom/tools/leveldesign/georges_convert/mold_elt_type_list.cpp index 99ad8ec33..57435be93 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/mold_elt_type_list.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/mold_elt_type_list.cpp @@ -1,103 +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 . - -#include "stdgeorgesconvert.h" -#include "mold_elt_type_list.h" -#include "georges_loader.h" -#include "form_body_elt.h" -#include "type_unit_int_unsigned.h" -#include "type_unit_int_signed.h" -#include "type_unit_double.h" -#include "type_unit_string.h" -#include "type_unit_file_name.h" - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CMoldEltTypeList::CMoldEltTypeList( CLoader* const _pl, CMoldEltType* const _pmet ) : CMoldEltType( _pl ) -{ - pmet = _pmet; - blist = true; - benum = pmet->IsEnum(); - sxname = pmet->GetName(); -} - -CMoldEltTypeList::~CMoldEltTypeList() -{ -} - -void CMoldEltTypeList::Load( const CStringEx _sxfullname ) // TODO: Load with parents... -{ - pmet->Load( _sxfullname ); - benum = pmet->IsEnum(); - sxname = pmet->GetName(); -} - -void CMoldEltTypeList::Load( const CStringEx _sxfullname, const CStringEx _sxdate ) -{ - pmet->Load( _sxfullname, _sxdate ); -} - -CStringEx CMoldEltTypeList::GetFormula() -{ - return( pmet->GetFormula() ); -} - -CStringEx CMoldEltTypeList::Format( const CStringEx _sxvalue ) const -{ - return( pmet->Format( _sxvalue ) ); -} - -CStringEx CMoldEltTypeList::CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const -{ - return( pmet->CalculateResult( _sxbasevalue, _sxvalue ) ); -} - -CStringEx CMoldEltTypeList::GetDefaultValue() const -{ - return( pmet->GetDefaultValue() ); -} - -unsigned int CMoldEltTypeList::GetType() const -{ - return( pmet->GetType() ); -} - -CStringEx CMoldEltTypeList::GetPredefSubstitute( const CStringEx _sxdesignation ) const -{ - return( pmet->GetPredefSubstitute( _sxdesignation ) ); -} - -CStringEx CMoldEltTypeList::GetPredefDesignation( const CStringEx _sxsubstitute ) const -{ - return( pmet->GetPredefDesignation( _sxsubstitute ) ); -} - -CStringEx CMoldEltTypeList::GetPredefDesignation( const unsigned int _index ) const -{ - return( pmet->GetPredefDesignation( _index ) ); -} - -CMoldElt* CMoldEltTypeList::GetMold() -{ - return( pmet ); -} - +// 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 "stdgeorgesconvert.h" +#include "mold_elt_type_list.h" +#include "georges_loader.h" +#include "form_body_elt.h" +#include "type_unit_int_unsigned.h" +#include "type_unit_int_signed.h" +#include "type_unit_double.h" +#include "type_unit_string.h" +#include "type_unit_file_name.h" + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CMoldEltTypeList::CMoldEltTypeList( CLoader* const _pl, CMoldEltType* const _pmet ) : CMoldEltType( _pl ) +{ + pmet = _pmet; + blist = true; + benum = pmet->IsEnum(); + sxname = pmet->GetName(); +} + +CMoldEltTypeList::~CMoldEltTypeList() +{ +} + +void CMoldEltTypeList::Load( const CStringEx _sxfullname ) // TODO: Load with parents... +{ + pmet->Load( _sxfullname ); + benum = pmet->IsEnum(); + sxname = pmet->GetName(); +} + +void CMoldEltTypeList::Load( const CStringEx _sxfullname, const CStringEx _sxdate ) +{ + pmet->Load( _sxfullname, _sxdate ); +} + +CStringEx CMoldEltTypeList::GetFormula() +{ + return( pmet->GetFormula() ); +} + +CStringEx CMoldEltTypeList::Format( const CStringEx _sxvalue ) const +{ + return( pmet->Format( _sxvalue ) ); +} + +CStringEx CMoldEltTypeList::CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const +{ + return( pmet->CalculateResult( _sxbasevalue, _sxvalue ) ); +} + +CStringEx CMoldEltTypeList::GetDefaultValue() const +{ + return( pmet->GetDefaultValue() ); +} + +unsigned int CMoldEltTypeList::GetType() const +{ + return( pmet->GetType() ); +} + +CStringEx CMoldEltTypeList::GetPredefSubstitute( const CStringEx _sxdesignation ) const +{ + return( pmet->GetPredefSubstitute( _sxdesignation ) ); +} + +CStringEx CMoldEltTypeList::GetPredefDesignation( const CStringEx _sxsubstitute ) const +{ + return( pmet->GetPredefDesignation( _sxsubstitute ) ); +} + +CStringEx CMoldEltTypeList::GetPredefDesignation( const unsigned int _index ) const +{ + return( pmet->GetPredefDesignation( _index ) ); +} + +CMoldElt* CMoldEltTypeList::GetMold() +{ + return( pmet ); +} + } \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_convert/mold_elt_type_list.h b/code/ryzom/tools/leveldesign/georges_convert/mold_elt_type_list.h index 0ef2d6c3e..f1d920b7e 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/mold_elt_type_list.h +++ b/code/ryzom/tools/leveldesign/georges_convert/mold_elt_type_list.h @@ -1,53 +1,53 @@ -// 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 NLGEORGES_MOLD_ELT_TYPE_LIST_H -#define NLGEORGES_MOLD_ELT_TYPE_LIST_H - -#include "mold_elt_type.h" - -namespace NLOLDGEORGES -{ - -class CLoader; -class CTypeUnit; - -class CMoldEltTypeList : public CMoldEltType -{ -protected: - CMoldEltType* pmet; - -public: - CMoldEltTypeList( CLoader* const _pl, CMoldEltType* const _pmet ); - virtual ~CMoldEltTypeList(); - - virtual void Load( const CStringEx _sxfullname ); - virtual void Load( const CStringEx _sxfullname, const CStringEx _sxdate ); - - virtual CMoldElt* GetMold(); - virtual CStringEx GetDefaultValue() const; // Give the default value of the type - virtual CStringEx CalculateResult( const CStringEx _sxvalue, const CStringEx _sxbasevalue ) const; // Calculate the final result - virtual CStringEx Format( const CStringEx _sxvalue ) const; // Transform any value in the good format - virtual CStringEx GetPredefSubstitute( const CStringEx _sxdesignation ) const; - virtual CStringEx GetPredefDesignation( const CStringEx _sxdesignation ) const; // Give the value corresponding to the string - virtual CStringEx GetPredefDesignation( const unsigned int _index ) const; - virtual CStringEx GetFormula(); // Give the formula of the type : int(0,100) - virtual unsigned int GetType() const; // Give the type ( typ or dfn or nothing ) -}; - -} // NLGEORGES - -#endif // NLGEORGES_MOLD_ELT_TYPE_LIST_H +// 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 NLGEORGES_MOLD_ELT_TYPE_LIST_H +#define NLGEORGES_MOLD_ELT_TYPE_LIST_H + +#include "mold_elt_type.h" + +namespace NLOLDGEORGES +{ + +class CLoader; +class CTypeUnit; + +class CMoldEltTypeList : public CMoldEltType +{ +protected: + CMoldEltType* pmet; + +public: + CMoldEltTypeList( CLoader* const _pl, CMoldEltType* const _pmet ); + virtual ~CMoldEltTypeList(); + + virtual void Load( const CStringEx _sxfullname ); + virtual void Load( const CStringEx _sxfullname, const CStringEx _sxdate ); + + virtual CMoldElt* GetMold(); + virtual CStringEx GetDefaultValue() const; // Give the default value of the type + virtual CStringEx CalculateResult( const CStringEx _sxvalue, const CStringEx _sxbasevalue ) const; // Calculate the final result + virtual CStringEx Format( const CStringEx _sxvalue ) const; // Transform any value in the good format + virtual CStringEx GetPredefSubstitute( const CStringEx _sxdesignation ) const; + virtual CStringEx GetPredefDesignation( const CStringEx _sxdesignation ) const; // Give the value corresponding to the string + virtual CStringEx GetPredefDesignation( const unsigned int _index ) const; + virtual CStringEx GetFormula(); // Give the formula of the type : int(0,100) + virtual unsigned int GetType() const; // Give the type ( typ or dfn or nothing ) +}; + +} // NLGEORGES + +#endif // NLGEORGES_MOLD_ELT_TYPE_LIST_H diff --git a/code/ryzom/tools/leveldesign/georges_convert/mold_loader.cpp b/code/ryzom/tools/leveldesign/georges_convert/mold_loader.cpp index 2cd92582d..27751fcf3 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/mold_loader.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/mold_loader.cpp @@ -1,164 +1,164 @@ -// 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 "stdgeorgesconvert.h" -#include "mold_loader.h" -#include "mold_elt.h" -#include "mold_elt_define.h" -#include "mold_elt_type.h" -#include "mold_elt_define_list.h" -#include "mold_elt_type_list.h" -#include "georges_loader.h" - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CMoldLoader::CMoldLoader() -{ -} - -CMoldLoader::~CMoldLoader() -{ - Clear(); -} - -void CMoldLoader::Clear() -{ - for( std::vector< CMoldElt* >::iterator it = vpme.begin(); it != vpme.end(); ++it ) - if( *it ) - delete( *it ); - vpme.clear(); - mmold.clear(); -} - -void CMoldLoader::SetLoader( CLoader* const _pl ) -{ - nlassert( _pl ); - pl = _pl; -} - -CMoldElt* CMoldLoader::LoadMold( const CStringEx _sxfilename ) -{ - CStringEx sxfn = _sxfilename; - sxfn.purge(); - if( sxfn.empty() ) - return( 0 ); - - // liste? - bool blst = ( sxfn.find( "list<" ) != -1 ); - if( blst ) - { - unsigned int ipos = sxfn.find( ">" ); - if( ipos < 0 ) - return( 0 ); - sxfn.mid( 5, ipos-5 ); - } - - // find extension - int ipos = sxfn.reverse_find('.'); - if( ipos < 0 ) - return( 0 ); - CStringEx sxfileextension = sxfn.get_right( sxfn.length()-ipos-1 ); - - // Get only the filename - ipos = sxfn.reverse_find('\\'); - if (ipos >= 0) - sxfn = sxfn.get_right (sxfn.length()-ipos-1); - - // find if loaded - CMoldElt* pme; - CStringEx sxfullname = pl->WhereIsDfnTyp( sxfn ); - if (sxfullname == "") - throw NLMISC::Exception ("Unable to find " + sxfn); - - sxfullname.make_lower(); - std::map< CStringEx, CMoldElt* >::iterator it; - - // DEBUG - /*for (it = mmold.begin(); it != mmold.end(); ++it) - { - CMoldElt *pME = it->second; - CStringEx sTmp = it->first + " Name:" + pME->GetName() + " formula:" + pME->GetFormula(); - nlwarning (sTmp.c_str()); - }*/ - // DEBUG - - it = mmold.find( sxfullname ); - if( it != mmold.end() ) - if( blst ) - { - if( sxfileextension == "dfn" ) - pme = new CMoldEltDefineList( pl, dynamic_cast< CMoldEltDefine* >( it->second ) ); - else if( sxfileextension == "typ" ) - pme = new CMoldEltTypeList( pl, dynamic_cast< CMoldEltType* >( it->second ) ); - else - return 0; - pme->SetName( it->second->GetName() ); - vpme.push_back( pme ); - return( pme ); - } - else - return( it->second ); - - // load - if( sxfileextension == "dfn" ) - { - pme = new CMoldEltDefine( pl ); - vpme.push_back( pme ); - if( blst ) - { - pme = new CMoldEltDefineList( pl, dynamic_cast< CMoldEltDefine* >( pme ) ); - vpme.push_back( pme ); - } - } - else if( sxfileextension == "typ" ) - { - pme = new CMoldEltType( pl ); - vpme.push_back( pme ); - if( blst ) - { - pme = new CMoldEltTypeList( pl, dynamic_cast< CMoldEltType* >( pme ) ); - vpme.push_back( pme ); - } - } - else - return( 0 ); - - pme->SetName( sxfn ); - pme->Load( sxfullname ); - mmold.insert( std::make_pair( sxfullname, pme->GetMold() ) ); - return( pme ); -} - -CMoldElt* CMoldLoader::LoadMold( const CStringEx _sxfilename, const CStringEx _sxdate ) -{ - return( 0 ); -} -/* -CMoldElt* CMoldLoader::Find( const CStringEx _sxfullname ) -{ - std::map< CStringEx, CMoldElt* >::iterator it = mmold.find( _sxfullname ); - if( it != mmold.end() ) - return( it->second ); - return( 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 "stdgeorgesconvert.h" +#include "mold_loader.h" +#include "mold_elt.h" +#include "mold_elt_define.h" +#include "mold_elt_type.h" +#include "mold_elt_define_list.h" +#include "mold_elt_type_list.h" +#include "georges_loader.h" + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CMoldLoader::CMoldLoader() +{ +} + +CMoldLoader::~CMoldLoader() +{ + Clear(); +} + +void CMoldLoader::Clear() +{ + for( std::vector< CMoldElt* >::iterator it = vpme.begin(); it != vpme.end(); ++it ) + if( *it ) + delete( *it ); + vpme.clear(); + mmold.clear(); +} + +void CMoldLoader::SetLoader( CLoader* const _pl ) +{ + nlassert( _pl ); + pl = _pl; +} + +CMoldElt* CMoldLoader::LoadMold( const CStringEx _sxfilename ) +{ + CStringEx sxfn = _sxfilename; + sxfn.purge(); + if( sxfn.empty() ) + return( 0 ); + + // liste? + bool blst = ( sxfn.find( "list<" ) != -1 ); + if( blst ) + { + unsigned int ipos = sxfn.find( ">" ); + if( ipos < 0 ) + return( 0 ); + sxfn.mid( 5, ipos-5 ); + } + + // find extension + int ipos = sxfn.reverse_find('.'); + if( ipos < 0 ) + return( 0 ); + CStringEx sxfileextension = sxfn.get_right( sxfn.length()-ipos-1 ); + + // Get only the filename + ipos = sxfn.reverse_find('\\'); + if (ipos >= 0) + sxfn = sxfn.get_right (sxfn.length()-ipos-1); + + // find if loaded + CMoldElt* pme; + CStringEx sxfullname = pl->WhereIsDfnTyp( sxfn ); + if (sxfullname == "") + throw NLMISC::Exception ("Unable to find " + sxfn); + + sxfullname.make_lower(); + std::map< CStringEx, CMoldElt* >::iterator it; + + // DEBUG + /*for (it = mmold.begin(); it != mmold.end(); ++it) + { + CMoldElt *pME = it->second; + CStringEx sTmp = it->first + " Name:" + pME->GetName() + " formula:" + pME->GetFormula(); + nlwarning (sTmp.c_str()); + }*/ + // DEBUG + + it = mmold.find( sxfullname ); + if( it != mmold.end() ) + if( blst ) + { + if( sxfileextension == "dfn" ) + pme = new CMoldEltDefineList( pl, dynamic_cast< CMoldEltDefine* >( it->second ) ); + else if( sxfileextension == "typ" ) + pme = new CMoldEltTypeList( pl, dynamic_cast< CMoldEltType* >( it->second ) ); + else + return 0; + pme->SetName( it->second->GetName() ); + vpme.push_back( pme ); + return( pme ); + } + else + return( it->second ); + + // load + if( sxfileextension == "dfn" ) + { + pme = new CMoldEltDefine( pl ); + vpme.push_back( pme ); + if( blst ) + { + pme = new CMoldEltDefineList( pl, dynamic_cast< CMoldEltDefine* >( pme ) ); + vpme.push_back( pme ); + } + } + else if( sxfileextension == "typ" ) + { + pme = new CMoldEltType( pl ); + vpme.push_back( pme ); + if( blst ) + { + pme = new CMoldEltTypeList( pl, dynamic_cast< CMoldEltType* >( pme ) ); + vpme.push_back( pme ); + } + } + else + return( 0 ); + + pme->SetName( sxfn ); + pme->Load( sxfullname ); + mmold.insert( std::make_pair( sxfullname, pme->GetMold() ) ); + return( pme ); +} + +CMoldElt* CMoldLoader::LoadMold( const CStringEx _sxfilename, const CStringEx _sxdate ) +{ + return( 0 ); +} +/* +CMoldElt* CMoldLoader::Find( const CStringEx _sxfullname ) +{ + std::map< CStringEx, CMoldElt* >::iterator it = mmold.find( _sxfullname ); + if( it != mmold.end() ) + return( it->second ); + return( 0 ); +} +*/ + } \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_convert/mold_loader.h b/code/ryzom/tools/leveldesign/georges_convert/mold_loader.h index 3aaa1340c..c44efd4a0 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/mold_loader.h +++ b/code/ryzom/tools/leveldesign/georges_convert/mold_loader.h @@ -1,59 +1,59 @@ -// 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 NLGEORGES_MOLD_LOADER_H -#define NLGEORGES_MOLD_LOADER_H - -#include "string_ex.h" - -namespace NLOLDGEORGES -{ - -class CMoldElt; -class CLoader; - -class CMoldLoader -{ -protected: - std::map< CStringEx, CMoldElt* > mmold; - std::vector< CMoldElt* > vpme; - CLoader* pl; - -public: - CMoldLoader(); - virtual ~CMoldLoader(); - - void Clear(); - void SetLoader( CLoader* const _pl ); - CMoldElt* LoadMold( const CStringEx _sxfilename ); - CMoldElt* LoadMold( const CStringEx _sxfilename, const CStringEx _sxdate ); -// CMoldElt* Find( const CStringEx _sxfullname ); -}; - -/* -struct StringExGreater : public std::binary_function< CStringEx, CStringEx, bool > -{ - bool operator()( const CStringEx& x, const CStringEx& y ) const - { - return( y <= x ); - } -}; -// std::map< CStringEx, CMoldElt*, StringExGreater > moldmap; -*/ - -} // NLGEORGES - -#endif // NLGEORGES_MOLD_LOADER_H +// 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 NLGEORGES_MOLD_LOADER_H +#define NLGEORGES_MOLD_LOADER_H + +#include "string_ex.h" + +namespace NLOLDGEORGES +{ + +class CMoldElt; +class CLoader; + +class CMoldLoader +{ +protected: + std::map< CStringEx, CMoldElt* > mmold; + std::vector< CMoldElt* > vpme; + CLoader* pl; + +public: + CMoldLoader(); + virtual ~CMoldLoader(); + + void Clear(); + void SetLoader( CLoader* const _pl ); + CMoldElt* LoadMold( const CStringEx _sxfilename ); + CMoldElt* LoadMold( const CStringEx _sxfilename, const CStringEx _sxdate ); +// CMoldElt* Find( const CStringEx _sxfullname ); +}; + +/* +struct StringExGreater : public std::binary_function< CStringEx, CStringEx, bool > +{ + bool operator()( const CStringEx& x, const CStringEx& y ) const + { + return( y <= x ); + } +}; +// std::map< CStringEx, CMoldElt*, StringExGreater > moldmap; +*/ + +} // NLGEORGES + +#endif // NLGEORGES_MOLD_LOADER_H diff --git a/code/ryzom/tools/leveldesign/georges_convert/stdgeorgesconvert.cpp b/code/ryzom/tools/leveldesign/georges_convert/stdgeorgesconvert.cpp index 9ec361168..06a16a1c8 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/stdgeorgesconvert.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/stdgeorgesconvert.cpp @@ -1,18 +1,18 @@ -// 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 "stdgeorgesconvert.h" - +// 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 "stdgeorgesconvert.h" + diff --git a/code/ryzom/tools/leveldesign/georges_convert/stdgeorgesconvert.h b/code/ryzom/tools/leveldesign/georges_convert/stdgeorgesconvert.h index 531e229e1..ed50f2873 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/stdgeorgesconvert.h +++ b/code/ryzom/tools/leveldesign/georges_convert/stdgeorgesconvert.h @@ -1,27 +1,27 @@ -// 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 -#include -#include -#include "nel/misc/types_nl.h" -#include "nel/misc/debug.h" -#include "nel/misc/common.h" - -// Include from libxml2 -#include +// 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 +#include +#include +#include "nel/misc/types_nl.h" +#include "nel/misc/debug.h" +#include "nel/misc/common.h" + +// Include from libxml2 +#include diff --git a/code/ryzom/tools/leveldesign/georges_convert/string_ex.cpp b/code/ryzom/tools/leveldesign/georges_convert/string_ex.cpp index 86ac505f3..a3987dada 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/string_ex.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/string_ex.cpp @@ -1,357 +1,357 @@ -// 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 "stdgeorgesconvert.h" -#include "string_ex.h" - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// -using namespace std; -CStringEx::~CStringEx() -{ - -} - -void CStringEx::remove( const char _c ) -{ - if( empty() ) - return; - iterator it = begin(); - while( it != end() ) - { - if( (*it) == _c ) - it = erase( it ); - else - ++it; - } -} - -void CStringEx::remove() -{ - remove(' '); - remove('\t'); - remove('\n'); -} - -void CStringEx::make_lower( ) -{ - for( iterator it = begin(); it != end(); ++it ) - if( (*it >= 'A')&&(*it <= 'Z') ) - *it += 'a'-'A'; -} - -void CStringEx::make_upper( ) -{ - for( iterator it = begin(); it != end(); ++it ) - if( (*it >= 'a')&&(*it <= 'z') ) - *it += 'A'-'a'; -} - -void CStringEx::trim_left( ) -{ - if( empty() ) - return; - iterator it; - for( it = begin(); (it != end())&&( (*it==' ')||(*it=='\t')||(*it=='\n') ); ++it ); - erase( begin(), it ); -} - -void CStringEx::trim_left( const char _c ) -{ - if( empty() ) - return; - iterator it; - for( it = begin(); (it != end())&&( *it == _c ); ++it ); - erase( begin(), it ); -} - -void CStringEx::trim_right( ) -{ - if( empty() ) - return; - iterator it = end(); - --it; - while( it != begin() ) - { - iterator i = it--; - if( (*i==' ')||(*i=='\t')||(*i=='\n') ) - erase( i ); - else - break; - } - if( (*it==' ')||(*it=='\t')||(*it=='\n') ) - erase( it ); -} - -void CStringEx::trim_right( char c ) -{ - if( empty() ) - return; - iterator it = end(); - while( it != begin() ) - { - iterator i = it--; - if( *i == c ) - erase( i ); - else - break; - } - if( *it == c ) - erase( it ); -} - -void CStringEx::trim() -{ - trim_left(); - trim_right(); -} - -void CStringEx::purge() -{ - make_lower(); - remove(' '); - remove('\t'); - remove('\n'); -} - -void CStringEx::trim( const char _c ) -{ - trim_left( _c ); - trim_right( _c ); -} - -void CStringEx::mid( const int nFirst ) -{ - CStringEx s( *this ); - erase(); - append( s.get_mid( nFirst )); -} - -void CStringEx::mid( const int nFirst, const int nCount ) -{ - CStringEx s( *this ); - erase(); - append( s.get_mid( nFirst, nCount )); -} - -void CStringEx::left( const int nCount ) -{ - CStringEx s( *this ); - erase(); - append( s.get_left( nCount )); -} - -void CStringEx::right( const int nCount ) -{ - CStringEx s( *this ); - erase(); - append( s.get_right( nCount )); -} - - -CStringEx CStringEx::get_remove( const char _c ) const -{ - CStringEx s( *this ); - s.remove( _c ); - return( s ); -} - -CStringEx CStringEx::get_remove() const -{ - CStringEx s( *this ); - s.remove(); - return( s ); -} - -CStringEx CStringEx::get_make_lower() const -{ - CStringEx s( *this ); - s.make_lower(); - return( s ); -} - -CStringEx CStringEx::get_make_upper() const -{ - CStringEx s( *this ); - s.make_upper(); - return( s ); -} - -CStringEx CStringEx::get_trim_left() const -{ - CStringEx s( *this ); - s.trim_left(); - return( s ); -} - -CStringEx CStringEx::get_trim_left( const char _c ) const -{ - CStringEx s( *this ); - s.trim_left( _c ); - return( s ); -} - -CStringEx CStringEx::get_trim_right() const -{ - CStringEx s( *this ); - s.trim_right(); - return( s ); -} - -CStringEx CStringEx::get_trim_right( const char _c ) const -{ - CStringEx s( *this ); - s.trim_right( _c ); - return( s ); -} - -CStringEx CStringEx::get_trim() const -{ - CStringEx s( *this ); - s.trim(); - return( s ); -} - -CStringEx CStringEx::get_purge() const -{ - CStringEx s( *this ); - s.purge(); - return( s ); -} - -CStringEx CStringEx::get_trim( const char _c ) const -{ - CStringEx s( *this ); - s.trim( _c ); - return( s ); -} - -CStringEx CStringEx::get_mid( const int nFirst ) const -{ - if( !size() ) - { - CStringEx object; - return( object ); - } - return( get_right( size()-nFirst ) ); -} - -CStringEx CStringEx::get_mid( const int nFirst, const int nCount ) const -{ - if( !size() ) - { - CStringEx object; - return( object ); - } - return( substr( nFirst, nCount ) ); -} - -CStringEx CStringEx::get_left( const int nCount ) const -{ - if( !size() ) - { - CStringEx object; - return( object ); - } - return( substr( 0, nCount ) ); -} - -CStringEx CStringEx::get_right( const int nCount ) const -{ - if( !size() ) - { - CStringEx object; - return( object ); - } - return( substr( size()-nCount, nCount ) ); -} - - -bool CStringEx::operator <= ( const CStringEx& s ) const -{ - const_iterator it = begin(); - const_iterator is = s.begin(); - while( ( it != end() )&&( is != s.end() ) ) - { - if( *it != *is ) - return( *it < *is ); - it++; - is++; - } - return( ( it == end() )&&( is == s.end() ) ); -} - -bool CStringEx::operator < ( const CStringEx& s ) const -{ - const_iterator it = begin(); - const_iterator is = s.begin(); - while( ( it != end() )&&( is != s.end() ) ) - { - if( *it != *is ) - return( *it < *is ); - it++; - is++; - } - return( is != s.end() ); -} - -std::string::size_type CStringEx::reverse_find( const char _c ) const -{ - size_type i = length(); - const_iterator it = end(); - while( it != begin() ) - { - --it; - --i; - if( *it == _c ) - return i ; - } - return npos; -} - -void CStringEx::format( const char* s, ... ) -{ - char *p = new char[256]; - va_list ap; - va_start(ap, s); - int x = vsprintf( p, s, ap); - erase(); - append(p); - delete[] p; -} - -/* - #include - #include - #include - char *newfmt(const char *fmt, ...) - { - char *p; - va_list ap; - if ((p = malloc(128)) == NULL) - return (NULL); - va_start(ap, fmt); - (void) vsnprintf(p, 128, fmt, ap); - va_end(ap); - return (p); - } -*/ - -} +// 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 "stdgeorgesconvert.h" +#include "string_ex.h" + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// +using namespace std; +CStringEx::~CStringEx() +{ + +} + +void CStringEx::remove( const char _c ) +{ + if( empty() ) + return; + iterator it = begin(); + while( it != end() ) + { + if( (*it) == _c ) + it = erase( it ); + else + ++it; + } +} + +void CStringEx::remove() +{ + remove(' '); + remove('\t'); + remove('\n'); +} + +void CStringEx::make_lower( ) +{ + for( iterator it = begin(); it != end(); ++it ) + if( (*it >= 'A')&&(*it <= 'Z') ) + *it += 'a'-'A'; +} + +void CStringEx::make_upper( ) +{ + for( iterator it = begin(); it != end(); ++it ) + if( (*it >= 'a')&&(*it <= 'z') ) + *it += 'A'-'a'; +} + +void CStringEx::trim_left( ) +{ + if( empty() ) + return; + iterator it; + for( it = begin(); (it != end())&&( (*it==' ')||(*it=='\t')||(*it=='\n') ); ++it ); + erase( begin(), it ); +} + +void CStringEx::trim_left( const char _c ) +{ + if( empty() ) + return; + iterator it; + for( it = begin(); (it != end())&&( *it == _c ); ++it ); + erase( begin(), it ); +} + +void CStringEx::trim_right( ) +{ + if( empty() ) + return; + iterator it = end(); + --it; + while( it != begin() ) + { + iterator i = it--; + if( (*i==' ')||(*i=='\t')||(*i=='\n') ) + erase( i ); + else + break; + } + if( (*it==' ')||(*it=='\t')||(*it=='\n') ) + erase( it ); +} + +void CStringEx::trim_right( char c ) +{ + if( empty() ) + return; + iterator it = end(); + while( it != begin() ) + { + iterator i = it--; + if( *i == c ) + erase( i ); + else + break; + } + if( *it == c ) + erase( it ); +} + +void CStringEx::trim() +{ + trim_left(); + trim_right(); +} + +void CStringEx::purge() +{ + make_lower(); + remove(' '); + remove('\t'); + remove('\n'); +} + +void CStringEx::trim( const char _c ) +{ + trim_left( _c ); + trim_right( _c ); +} + +void CStringEx::mid( const int nFirst ) +{ + CStringEx s( *this ); + erase(); + append( s.get_mid( nFirst )); +} + +void CStringEx::mid( const int nFirst, const int nCount ) +{ + CStringEx s( *this ); + erase(); + append( s.get_mid( nFirst, nCount )); +} + +void CStringEx::left( const int nCount ) +{ + CStringEx s( *this ); + erase(); + append( s.get_left( nCount )); +} + +void CStringEx::right( const int nCount ) +{ + CStringEx s( *this ); + erase(); + append( s.get_right( nCount )); +} + + +CStringEx CStringEx::get_remove( const char _c ) const +{ + CStringEx s( *this ); + s.remove( _c ); + return( s ); +} + +CStringEx CStringEx::get_remove() const +{ + CStringEx s( *this ); + s.remove(); + return( s ); +} + +CStringEx CStringEx::get_make_lower() const +{ + CStringEx s( *this ); + s.make_lower(); + return( s ); +} + +CStringEx CStringEx::get_make_upper() const +{ + CStringEx s( *this ); + s.make_upper(); + return( s ); +} + +CStringEx CStringEx::get_trim_left() const +{ + CStringEx s( *this ); + s.trim_left(); + return( s ); +} + +CStringEx CStringEx::get_trim_left( const char _c ) const +{ + CStringEx s( *this ); + s.trim_left( _c ); + return( s ); +} + +CStringEx CStringEx::get_trim_right() const +{ + CStringEx s( *this ); + s.trim_right(); + return( s ); +} + +CStringEx CStringEx::get_trim_right( const char _c ) const +{ + CStringEx s( *this ); + s.trim_right( _c ); + return( s ); +} + +CStringEx CStringEx::get_trim() const +{ + CStringEx s( *this ); + s.trim(); + return( s ); +} + +CStringEx CStringEx::get_purge() const +{ + CStringEx s( *this ); + s.purge(); + return( s ); +} + +CStringEx CStringEx::get_trim( const char _c ) const +{ + CStringEx s( *this ); + s.trim( _c ); + return( s ); +} + +CStringEx CStringEx::get_mid( const int nFirst ) const +{ + if( !size() ) + { + CStringEx object; + return( object ); + } + return( get_right( size()-nFirst ) ); +} + +CStringEx CStringEx::get_mid( const int nFirst, const int nCount ) const +{ + if( !size() ) + { + CStringEx object; + return( object ); + } + return( substr( nFirst, nCount ) ); +} + +CStringEx CStringEx::get_left( const int nCount ) const +{ + if( !size() ) + { + CStringEx object; + return( object ); + } + return( substr( 0, nCount ) ); +} + +CStringEx CStringEx::get_right( const int nCount ) const +{ + if( !size() ) + { + CStringEx object; + return( object ); + } + return( substr( size()-nCount, nCount ) ); +} + + +bool CStringEx::operator <= ( const CStringEx& s ) const +{ + const_iterator it = begin(); + const_iterator is = s.begin(); + while( ( it != end() )&&( is != s.end() ) ) + { + if( *it != *is ) + return( *it < *is ); + it++; + is++; + } + return( ( it == end() )&&( is == s.end() ) ); +} + +bool CStringEx::operator < ( const CStringEx& s ) const +{ + const_iterator it = begin(); + const_iterator is = s.begin(); + while( ( it != end() )&&( is != s.end() ) ) + { + if( *it != *is ) + return( *it < *is ); + it++; + is++; + } + return( is != s.end() ); +} + +std::string::size_type CStringEx::reverse_find( const char _c ) const +{ + size_type i = length(); + const_iterator it = end(); + while( it != begin() ) + { + --it; + --i; + if( *it == _c ) + return i ; + } + return npos; +} + +void CStringEx::format( const char* s, ... ) +{ + char *p = new char[256]; + va_list ap; + va_start(ap, s); + int x = vsprintf( p, s, ap); + erase(); + append(p); + delete[] p; +} + +/* + #include + #include + #include + char *newfmt(const char *fmt, ...) + { + char *p; + va_list ap; + if ((p = malloc(128)) == NULL) + return (NULL); + va_start(ap, fmt); + (void) vsnprintf(p, 128, fmt, ap); + va_end(ap); + return (p); + } +*/ + +} diff --git a/code/ryzom/tools/leveldesign/georges_convert/string_ex.h b/code/ryzom/tools/leveldesign/georges_convert/string_ex.h index a395e8f42..7ca4e52e2 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/string_ex.h +++ b/code/ryzom/tools/leveldesign/georges_convert/string_ex.h @@ -1,78 +1,78 @@ -// 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 NLGEORGES_STRING_EX_H -#define NLGEORGES_STRING_EX_H - -#include "nel/misc/stream.h" - -namespace NLOLDGEORGES -{ - -class CStringEx : public std::basic_string, std::allocator > -{ - -public: - CStringEx() : std::basic_string, std::allocator >() {} - CStringEx( char* _pc ) : std::basic_string, std::allocator >( (char *)_pc ) {} - CStringEx( std::string _s ) : std::basic_string, std::allocator >( (std::string)_s) {} - CStringEx( const char _c, int _i ) { append( _i, _c ); } - - virtual ~CStringEx(); - CStringEx get_remove() const; - CStringEx get_remove( const char ) const; - CStringEx get_make_lower() const; - CStringEx get_make_upper() const; - CStringEx get_trim_left() const; - CStringEx get_trim_left( const char _c ) const; - CStringEx get_trim_right() const; - CStringEx get_trim_right( const char _c ) const; - CStringEx get_trim() const; - CStringEx get_trim( const char _c ) const; - CStringEx get_mid( const int nFirst, const int nCount ) const; - CStringEx get_mid( const int nFirst ) const; - CStringEx get_left( const int nCount ) const; - CStringEx get_right( const int nCount ) const; - CStringEx get_purge() const; - - void remove(); - void remove( const char _c ); - void make_lower(); - void make_upper(); - void trim_left(); - void trim_left( const char _c ); - void trim_right(); - void trim_right( const char _c ); - void trim(); - void trim( const char _c ); - void mid( const int nFirst, const int nCount ); - void mid( const int nFirst ); - void left( const int nCount ); - void right( const int nCount ); - void purge(); - - void format( const char*, ... ); - std::string::size_type reverse_find( const char _c ) const; - - void serial( NLMISC::IStream& s ) { s.serial( (std::string&)(*this) );} - - bool operator <= ( const CStringEx& s ) const; - bool operator < ( const CStringEx& s ) const; -}; - -} // NLGEORGES - -#endif // NLGEORGES_STRING_EX_H +// 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 NLGEORGES_STRING_EX_H +#define NLGEORGES_STRING_EX_H + +#include "nel/misc/stream.h" + +namespace NLOLDGEORGES +{ + +class CStringEx : public std::basic_string, std::allocator > +{ + +public: + CStringEx() : std::basic_string, std::allocator >() {} + CStringEx( char* _pc ) : std::basic_string, std::allocator >( (char *)_pc ) {} + CStringEx( std::string _s ) : std::basic_string, std::allocator >( (std::string)_s) {} + CStringEx( const char _c, int _i ) { append( _i, _c ); } + + virtual ~CStringEx(); + CStringEx get_remove() const; + CStringEx get_remove( const char ) const; + CStringEx get_make_lower() const; + CStringEx get_make_upper() const; + CStringEx get_trim_left() const; + CStringEx get_trim_left( const char _c ) const; + CStringEx get_trim_right() const; + CStringEx get_trim_right( const char _c ) const; + CStringEx get_trim() const; + CStringEx get_trim( const char _c ) const; + CStringEx get_mid( const int nFirst, const int nCount ) const; + CStringEx get_mid( const int nFirst ) const; + CStringEx get_left( const int nCount ) const; + CStringEx get_right( const int nCount ) const; + CStringEx get_purge() const; + + void remove(); + void remove( const char _c ); + void make_lower(); + void make_upper(); + void trim_left(); + void trim_left( const char _c ); + void trim_right(); + void trim_right( const char _c ); + void trim(); + void trim( const char _c ); + void mid( const int nFirst, const int nCount ); + void mid( const int nFirst ); + void left( const int nCount ); + void right( const int nCount ); + void purge(); + + void format( const char*, ... ); + std::string::size_type reverse_find( const char _c ) const; + + void serial( NLMISC::IStream& s ) { s.serial( (std::string&)(*this) );} + + bool operator <= ( const CStringEx& s ) const; + bool operator < ( const CStringEx& s ) const; +}; + +} // NLGEORGES + +#endif // NLGEORGES_STRING_EX_H diff --git a/code/ryzom/tools/leveldesign/georges_convert/type_unit.cpp b/code/ryzom/tools/leveldesign/georges_convert/type_unit.cpp index 80ac59687..df931f4e7 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/type_unit.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/type_unit.cpp @@ -1,84 +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 . - -#include "stdgeorgesconvert.h" -#include "type_unit.h" - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CTypeUnit::CTypeUnit( const CStringEx _sxll, const CStringEx _sxhl, const CStringEx _sxdv, const CStringEx _sxf ) -{ - sxlowlimit = _sxll; - sxhighlimit = _sxhl; - sxdefaultvalue = _sxdv; - sxformula = _sxf; -} - -CTypeUnit::~CTypeUnit() -{ -} - -CStringEx CTypeUnit::GetFormula() const -{ - return sxformula; -} - -CStringEx CTypeUnit::GetDefaultValue() const -{ - return sxdefaultvalue; -} - -CStringEx CTypeUnit::GetLowLimit() const -{ - return sxlowlimit; -} - -CStringEx CTypeUnit::GetHighLimit() const -{ - return sxhighlimit; -} - -CStringEx CTypeUnit::Format( const CStringEx _sxvalue ) const -{ - return( _sxvalue ); -} - -CStringEx CTypeUnit::CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const -{ - return( _sxbasevalue ); -} - -void CTypeUnit::SetDefaultValue( const CStringEx _sxdv ) -{ - sxdefaultvalue = _sxdv; -} - -void CTypeUnit::SetLowLimit( const CStringEx _sxll ) -{ - sxlowlimit = _sxll; -} - -void CTypeUnit::SetHighLimit( const CStringEx _sxhl ) -{ - sxhighlimit = _sxhl; -} - +// 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 "stdgeorgesconvert.h" +#include "type_unit.h" + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CTypeUnit::CTypeUnit( const CStringEx _sxll, const CStringEx _sxhl, const CStringEx _sxdv, const CStringEx _sxf ) +{ + sxlowlimit = _sxll; + sxhighlimit = _sxhl; + sxdefaultvalue = _sxdv; + sxformula = _sxf; +} + +CTypeUnit::~CTypeUnit() +{ +} + +CStringEx CTypeUnit::GetFormula() const +{ + return sxformula; +} + +CStringEx CTypeUnit::GetDefaultValue() const +{ + return sxdefaultvalue; +} + +CStringEx CTypeUnit::GetLowLimit() const +{ + return sxlowlimit; +} + +CStringEx CTypeUnit::GetHighLimit() const +{ + return sxhighlimit; +} + +CStringEx CTypeUnit::Format( const CStringEx _sxvalue ) const +{ + return( _sxvalue ); +} + +CStringEx CTypeUnit::CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const +{ + return( _sxbasevalue ); +} + +void CTypeUnit::SetDefaultValue( const CStringEx _sxdv ) +{ + sxdefaultvalue = _sxdv; +} + +void CTypeUnit::SetLowLimit( const CStringEx _sxll ) +{ + sxlowlimit = _sxll; +} + +void CTypeUnit::SetHighLimit( const CStringEx _sxhl ) +{ + sxhighlimit = _sxhl; +} + } \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_convert/type_unit.h b/code/ryzom/tools/leveldesign/georges_convert/type_unit.h index bc212a628..ec2228fb9 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/type_unit.h +++ b/code/ryzom/tools/leveldesign/georges_convert/type_unit.h @@ -1,50 +1,50 @@ -// 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 NLGEORGES_TYPE_UNIT_H -#define NLGEORGES_TYPE_UNIT_H - -#include "string_ex.h" - -namespace NLOLDGEORGES -{ - -class CTypeUnit -{ -protected: - CStringEx sxformula; - CStringEx sxhighlimit; - CStringEx sxlowlimit; - CStringEx sxdefaultvalue; - -public: - CTypeUnit( const CStringEx _sxll, const CStringEx _sxhl, const CStringEx _sxdv, const CStringEx _sxf ); - virtual ~CTypeUnit(); - - CStringEx GetFormula() const; - CStringEx GetDefaultValue() const; - CStringEx GetLowLimit() const; - CStringEx GetHighLimit() const; - virtual void SetDefaultValue( const CStringEx _sxdv ); - virtual void SetLowLimit( const CStringEx _sxll ); - virtual void SetHighLimit( const CStringEx _sxhl ); - virtual CStringEx Format( const CStringEx _sxvalue ) const; - virtual CStringEx CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const; -}; - -} // NLGEORGES - -#endif // NLGEORGES_TYPE_UNIT_H +// 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 NLGEORGES_TYPE_UNIT_H +#define NLGEORGES_TYPE_UNIT_H + +#include "string_ex.h" + +namespace NLOLDGEORGES +{ + +class CTypeUnit +{ +protected: + CStringEx sxformula; + CStringEx sxhighlimit; + CStringEx sxlowlimit; + CStringEx sxdefaultvalue; + +public: + CTypeUnit( const CStringEx _sxll, const CStringEx _sxhl, const CStringEx _sxdv, const CStringEx _sxf ); + virtual ~CTypeUnit(); + + CStringEx GetFormula() const; + CStringEx GetDefaultValue() const; + CStringEx GetLowLimit() const; + CStringEx GetHighLimit() const; + virtual void SetDefaultValue( const CStringEx _sxdv ); + virtual void SetLowLimit( const CStringEx _sxll ); + virtual void SetHighLimit( const CStringEx _sxhl ); + virtual CStringEx Format( const CStringEx _sxvalue ) const; + virtual CStringEx CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const; +}; + +} // NLGEORGES + +#endif // NLGEORGES_TYPE_UNIT_H diff --git a/code/ryzom/tools/leveldesign/georges_convert/type_unit_double.cpp b/code/ryzom/tools/leveldesign/georges_convert/type_unit_double.cpp index 777878875..6244c0f4a 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/type_unit_double.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/type_unit_double.cpp @@ -1,209 +1,209 @@ -// 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 "stdgeorgesconvert.h" -#include "type_unit_double.h" - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CTypeUnitDouble::CTypeUnitDouble( const CStringEx _sxll, const CStringEx _sxhl, const CStringEx _sxdv, const CStringEx _sxf ) : CTypeUnit( _sxll, _sxhl, _sxdv, _sxf ) -{ - dlowlimit = atof( sxlowlimit.c_str() ); - dhighlimit = atof( sxhighlimit.c_str() ); - ddefaultvalue = atof( sxdefaultvalue.c_str() ); - if( sxformula.empty() ) - sxformula.format( "double(%s,%s)", FormatDouble( dlowlimit ).c_str(), FormatDouble( dhighlimit ).c_str() ); -} - -CTypeUnitDouble::~CTypeUnitDouble() -{ -} - -CStringEx CTypeUnitDouble::FormatDouble( const double dvalue ) const -{ - int decimal, sign; - char *buffer; - - if( dvalue == 0 ) - return( CStringEx( "0.0" )); - -#ifdef NL_OS_WINDOWS - buffer = _fcvt( dvalue, 5, &decimal, &sign ); -#else - buffer = fcvt( dvalue, 5, &decimal, &sign ); -#endif // NL_OS_WINDOWS - CStringEx sx( buffer ); - if( decimal <= 0 ) - { - sx = (std::string)(CStringEx( "0." ) + CStringEx( '0', -decimal ) + sx); - } - else - sx.insert(decimal,"."); - - while( sx[sx.length()-1] == '0' ) - sx.left( (int)sx.length() -1 ); - - if( sx[sx.length()-1] == '.' ) - sx += '0'; - - if( sign ) - sx = CStringEx( "-" + sx ); - - return sx; -} - -/* -CStringEx CTypeUnitDouble::Format( const CStringEx _sxvalue ) const -{ - if( _sxvalue.empty() ) - return( sxdefaultvalue ); - - double dvalue = atof( _sxvalue.c_str() ); - if( dvalue < dlowlimit ) - dvalue = dlowlimit; - if( dvalue > dhighlimit ) - dvalue = dhighlimit; - return( FormatDouble( dvalue ) ); -} -*/ -CStringEx CTypeUnitDouble::Format( const CStringEx _sxvalue ) const -{ - if( _sxvalue.empty() ) - return( sxdefaultvalue ); - - std::vector< std::pair< CStringEx, CStringEx > > modificationValues; - CStringEx value( _sxvalue ); - value.purge(); - while( value[0] == '<' ) - { - std::string::size_type pos = value.find( '>' ); - if( pos == std::string::npos ) - break; - CStringEx sxoperateur = value.get_mid( 1, 1 ); - CStringEx sxoperande = value.get_mid( 2, (int)pos-2); - value.right( (int)(value.size()-pos-1) ); - modificationValues.push_back( std::make_pair( sxoperateur, sxoperande ) ); - } - if( modificationValues.size() ) - { - CStringEx sxr; - for( std::vector< std::pair< CStringEx, CStringEx > >::iterator it = modificationValues.begin(); it != modificationValues.end(); ++it ) - { - sxr += CStringEx( "<" ); - sxr += it->first; - sxr += it->second; - sxr += CStringEx( ">" ); - } - return( sxr ); - } - else - { - double dvalue = atof( _sxvalue.c_str() ); - if( dvalue < dlowlimit ) - dvalue = dlowlimit; - if( dvalue > dhighlimit ) - dvalue = dhighlimit; - return( FormatDouble( dvalue ) ); - } -} -/* -CStringEx CTypeUnitDouble::CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const -{ - nlassert( !_sxbasevalue.empty() ); - if( _sxvalue.empty() ) - return( _sxbasevalue ); - return( Format( _sxvalue ) ); -} -*/ -CStringEx CTypeUnitDouble::CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const -{ - nlassert( !_sxbasevalue.empty() ); - if( _sxvalue.empty() ) - return( _sxbasevalue ); - - std::vector< std::pair< CStringEx, CStringEx > > modificationValues; - CStringEx value( _sxvalue ); - value.purge(); - while( value[0] == '<' ) - { - std::string::size_type pos = value.find( '>' ); - if( pos == std::string::npos ) - break; - CStringEx sxoperateur = value.get_mid( 1, 1 ); - CStringEx sxoperande = value.get_mid( 2, (int)pos-2); - value.right( (int)(value.size()-pos-1) ); - modificationValues.push_back( std::make_pair( sxoperateur, sxoperande ) ); - } - if( modificationValues.size() ) - { - double dr = atof( _sxbasevalue.c_str() ); - for( std::vector< std::pair< CStringEx, CStringEx > >::iterator it = modificationValues.begin(); it != modificationValues.end(); ++it ) - { - double dvalue = atof( it->second.c_str() ); - if( it->first == "+" ) - dr += dvalue; - else if( it->first == "*" ) - dr *= dvalue; - else if( it->first == "-" ) - dr -= dvalue; - else if( it->first == "/" ) - dr /= dvalue; - else if( it->first == "^" ) - dr = pow( dr, dvalue ); - } - if( dr < dlowlimit ) - dr = dlowlimit; - if( dr > dhighlimit ) - dr = dhighlimit; - return( FormatDouble( dr ) ); - } - else - { - double dvalue = atof( _sxvalue.c_str() ); - if( dvalue < dlowlimit ) - dvalue = dlowlimit; - if( dvalue > dhighlimit ) - dvalue = dhighlimit; - return( FormatDouble( dvalue ) ); - } - - return( Format( _sxvalue ) ); -} - -void CTypeUnitDouble::SetDefaultValue( const CStringEx _sxdv ) -{ - sxdefaultvalue = _sxdv; - ddefaultvalue = atof( sxdefaultvalue.c_str() ); -} - -void CTypeUnitDouble::SetLowLimit( const CStringEx _sxll ) -{ - sxlowlimit = _sxll; - dlowlimit = atof( sxlowlimit.c_str() ); -} - -void CTypeUnitDouble::SetHighLimit( const CStringEx _sxhl ) -{ - sxhighlimit = _sxhl; - dhighlimit = atof( sxhighlimit.c_str() ); -} - -} +// 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 "stdgeorgesconvert.h" +#include "type_unit_double.h" + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CTypeUnitDouble::CTypeUnitDouble( const CStringEx _sxll, const CStringEx _sxhl, const CStringEx _sxdv, const CStringEx _sxf ) : CTypeUnit( _sxll, _sxhl, _sxdv, _sxf ) +{ + dlowlimit = atof( sxlowlimit.c_str() ); + dhighlimit = atof( sxhighlimit.c_str() ); + ddefaultvalue = atof( sxdefaultvalue.c_str() ); + if( sxformula.empty() ) + sxformula.format( "double(%s,%s)", FormatDouble( dlowlimit ).c_str(), FormatDouble( dhighlimit ).c_str() ); +} + +CTypeUnitDouble::~CTypeUnitDouble() +{ +} + +CStringEx CTypeUnitDouble::FormatDouble( const double dvalue ) const +{ + int decimal, sign; + char *buffer; + + if( dvalue == 0 ) + return( CStringEx( "0.0" )); + +#ifdef NL_OS_WINDOWS + buffer = _fcvt( dvalue, 5, &decimal, &sign ); +#else + buffer = fcvt( dvalue, 5, &decimal, &sign ); +#endif // NL_OS_WINDOWS + CStringEx sx( buffer ); + if( decimal <= 0 ) + { + sx = (std::string)(CStringEx( "0." ) + CStringEx( '0', -decimal ) + sx); + } + else + sx.insert(decimal,"."); + + while( sx[sx.length()-1] == '0' ) + sx.left( (int)sx.length() -1 ); + + if( sx[sx.length()-1] == '.' ) + sx += '0'; + + if( sign ) + sx = CStringEx( "-" + sx ); + + return sx; +} + +/* +CStringEx CTypeUnitDouble::Format( const CStringEx _sxvalue ) const +{ + if( _sxvalue.empty() ) + return( sxdefaultvalue ); + + double dvalue = atof( _sxvalue.c_str() ); + if( dvalue < dlowlimit ) + dvalue = dlowlimit; + if( dvalue > dhighlimit ) + dvalue = dhighlimit; + return( FormatDouble( dvalue ) ); +} +*/ +CStringEx CTypeUnitDouble::Format( const CStringEx _sxvalue ) const +{ + if( _sxvalue.empty() ) + return( sxdefaultvalue ); + + std::vector< std::pair< CStringEx, CStringEx > > modificationValues; + CStringEx value( _sxvalue ); + value.purge(); + while( value[0] == '<' ) + { + std::string::size_type pos = value.find( '>' ); + if( pos == std::string::npos ) + break; + CStringEx sxoperateur = value.get_mid( 1, 1 ); + CStringEx sxoperande = value.get_mid( 2, (int)pos-2); + value.right( (int)(value.size()-pos-1) ); + modificationValues.push_back( std::make_pair( sxoperateur, sxoperande ) ); + } + if( modificationValues.size() ) + { + CStringEx sxr; + for( std::vector< std::pair< CStringEx, CStringEx > >::iterator it = modificationValues.begin(); it != modificationValues.end(); ++it ) + { + sxr += CStringEx( "<" ); + sxr += it->first; + sxr += it->second; + sxr += CStringEx( ">" ); + } + return( sxr ); + } + else + { + double dvalue = atof( _sxvalue.c_str() ); + if( dvalue < dlowlimit ) + dvalue = dlowlimit; + if( dvalue > dhighlimit ) + dvalue = dhighlimit; + return( FormatDouble( dvalue ) ); + } +} +/* +CStringEx CTypeUnitDouble::CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const +{ + nlassert( !_sxbasevalue.empty() ); + if( _sxvalue.empty() ) + return( _sxbasevalue ); + return( Format( _sxvalue ) ); +} +*/ +CStringEx CTypeUnitDouble::CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const +{ + nlassert( !_sxbasevalue.empty() ); + if( _sxvalue.empty() ) + return( _sxbasevalue ); + + std::vector< std::pair< CStringEx, CStringEx > > modificationValues; + CStringEx value( _sxvalue ); + value.purge(); + while( value[0] == '<' ) + { + std::string::size_type pos = value.find( '>' ); + if( pos == std::string::npos ) + break; + CStringEx sxoperateur = value.get_mid( 1, 1 ); + CStringEx sxoperande = value.get_mid( 2, (int)pos-2); + value.right( (int)(value.size()-pos-1) ); + modificationValues.push_back( std::make_pair( sxoperateur, sxoperande ) ); + } + if( modificationValues.size() ) + { + double dr = atof( _sxbasevalue.c_str() ); + for( std::vector< std::pair< CStringEx, CStringEx > >::iterator it = modificationValues.begin(); it != modificationValues.end(); ++it ) + { + double dvalue = atof( it->second.c_str() ); + if( it->first == "+" ) + dr += dvalue; + else if( it->first == "*" ) + dr *= dvalue; + else if( it->first == "-" ) + dr -= dvalue; + else if( it->first == "/" ) + dr /= dvalue; + else if( it->first == "^" ) + dr = pow( dr, dvalue ); + } + if( dr < dlowlimit ) + dr = dlowlimit; + if( dr > dhighlimit ) + dr = dhighlimit; + return( FormatDouble( dr ) ); + } + else + { + double dvalue = atof( _sxvalue.c_str() ); + if( dvalue < dlowlimit ) + dvalue = dlowlimit; + if( dvalue > dhighlimit ) + dvalue = dhighlimit; + return( FormatDouble( dvalue ) ); + } + + return( Format( _sxvalue ) ); +} + +void CTypeUnitDouble::SetDefaultValue( const CStringEx _sxdv ) +{ + sxdefaultvalue = _sxdv; + ddefaultvalue = atof( sxdefaultvalue.c_str() ); +} + +void CTypeUnitDouble::SetLowLimit( const CStringEx _sxll ) +{ + sxlowlimit = _sxll; + dlowlimit = atof( sxlowlimit.c_str() ); +} + +void CTypeUnitDouble::SetHighLimit( const CStringEx _sxhl ) +{ + sxhighlimit = _sxhl; + dhighlimit = atof( sxhighlimit.c_str() ); +} + +} diff --git a/code/ryzom/tools/leveldesign/georges_convert/type_unit_double.h b/code/ryzom/tools/leveldesign/georges_convert/type_unit_double.h index af14f449f..88c8c9423 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/type_unit_double.h +++ b/code/ryzom/tools/leveldesign/georges_convert/type_unit_double.h @@ -1,47 +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 NLGEORGES_TYPE_UNIT_DOUBLE_H -#define NLGEORGES_TYPE_UNIT_DOUBLE_H - -#include "type_unit.h" - -namespace NLOLDGEORGES -{ - -class CTypeUnitDouble : public CTypeUnit -{ -protected: - double dlowlimit; - double dhighlimit; - double ddefaultvalue; - CStringEx FormatDouble( const double dvalue ) const; - -public: - CTypeUnitDouble( const CStringEx _sxll, const CStringEx _sxhl, const CStringEx _sxdv, const CStringEx _sxf ); - virtual ~CTypeUnitDouble(); - - virtual CStringEx Format( const CStringEx _sxvalue ) const; - virtual CStringEx CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const; - virtual void SetDefaultValue( const CStringEx _sxdv ); - virtual void SetLowLimit( const CStringEx _sxll ); - virtual void SetHighLimit( const CStringEx _sxhl ); - -}; - -} // NLGEORGES - -#endif // NLGEORGES_TYPE_UNIT_DOUBLE_H +// 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 NLGEORGES_TYPE_UNIT_DOUBLE_H +#define NLGEORGES_TYPE_UNIT_DOUBLE_H + +#include "type_unit.h" + +namespace NLOLDGEORGES +{ + +class CTypeUnitDouble : public CTypeUnit +{ +protected: + double dlowlimit; + double dhighlimit; + double ddefaultvalue; + CStringEx FormatDouble( const double dvalue ) const; + +public: + CTypeUnitDouble( const CStringEx _sxll, const CStringEx _sxhl, const CStringEx _sxdv, const CStringEx _sxf ); + virtual ~CTypeUnitDouble(); + + virtual CStringEx Format( const CStringEx _sxvalue ) const; + virtual CStringEx CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const; + virtual void SetDefaultValue( const CStringEx _sxdv ); + virtual void SetLowLimit( const CStringEx _sxll ); + virtual void SetHighLimit( const CStringEx _sxhl ); + +}; + +} // NLGEORGES + +#endif // NLGEORGES_TYPE_UNIT_DOUBLE_H diff --git a/code/ryzom/tools/leveldesign/georges_convert/type_unit_file_name.cpp b/code/ryzom/tools/leveldesign/georges_convert/type_unit_file_name.cpp index a686fe479..5dd635242 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/type_unit_file_name.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/type_unit_file_name.cpp @@ -1,66 +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 "stdgeorgesconvert.h" -#include "type_unit_file_name.h" - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CTypeUnitFileName::CTypeUnitFileName( const CStringEx _sxll, const CStringEx _sxhl, const CStringEx _sxdv, const CStringEx _sxf ) : CTypeUnit( _sxhl, _sxll, _sxdv, _sxf ) -{ - if( sxformula.empty() ) - sxformula = "file name"; -} - -CTypeUnitFileName::~CTypeUnitFileName() -{ -} - -CStringEx CTypeUnitFileName::Format( const CStringEx _sxvalue ) const -{ - if( _sxvalue.empty() ) - return( sxdefaultvalue ); - return( _sxvalue ); -} - -CStringEx CTypeUnitFileName::CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const -{ - if( _sxvalue.empty() ) - return( Format( _sxbasevalue ) ); - return( Format( _sxvalue ) ); -} - -void CTypeUnitFileName::SetDefaultValue( const CStringEx _sxdv ) -{ - sxdefaultvalue = _sxdv; -} - -void CTypeUnitFileName::SetLowLimit( const CStringEx _sxll ) -{ - sxlowlimit = _sxll; -} - -void CTypeUnitFileName::SetHighLimit( const CStringEx _sxhl ) -{ - sxhighlimit = _sxhl; -} - +// 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 "stdgeorgesconvert.h" +#include "type_unit_file_name.h" + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CTypeUnitFileName::CTypeUnitFileName( const CStringEx _sxll, const CStringEx _sxhl, const CStringEx _sxdv, const CStringEx _sxf ) : CTypeUnit( _sxhl, _sxll, _sxdv, _sxf ) +{ + if( sxformula.empty() ) + sxformula = "file name"; +} + +CTypeUnitFileName::~CTypeUnitFileName() +{ +} + +CStringEx CTypeUnitFileName::Format( const CStringEx _sxvalue ) const +{ + if( _sxvalue.empty() ) + return( sxdefaultvalue ); + return( _sxvalue ); +} + +CStringEx CTypeUnitFileName::CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const +{ + if( _sxvalue.empty() ) + return( Format( _sxbasevalue ) ); + return( Format( _sxvalue ) ); +} + +void CTypeUnitFileName::SetDefaultValue( const CStringEx _sxdv ) +{ + sxdefaultvalue = _sxdv; +} + +void CTypeUnitFileName::SetLowLimit( const CStringEx _sxll ) +{ + sxlowlimit = _sxll; +} + +void CTypeUnitFileName::SetHighLimit( const CStringEx _sxhl ) +{ + sxhighlimit = _sxhl; +} + } \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_convert/type_unit_file_name.h b/code/ryzom/tools/leveldesign/georges_convert/type_unit_file_name.h index 80110cfd7..84c642a63 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/type_unit_file_name.h +++ b/code/ryzom/tools/leveldesign/georges_convert/type_unit_file_name.h @@ -1,43 +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 . - -#ifndef NLGEORGES_TYPE_UNIT_FILE_NAME_H -#define NLGEORGES_TYPE_UNIT_FILE_NAME_H - -#include "type_unit.h" - -namespace NLOLDGEORGES -{ - -class CTypeUnitFileName : public CTypeUnit -{ -protected: - unsigned short int usihighlimit; - -public: - CTypeUnitFileName( const CStringEx _sxll, const CStringEx _sxhl, const CStringEx _sxdv, const CStringEx _sxf ); - virtual ~CTypeUnitFileName(); - - virtual CStringEx Format( const CStringEx _sxvalue ) const; - virtual CStringEx CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const; - virtual void SetDefaultValue( const CStringEx _sxdv ); - virtual void SetLowLimit( const CStringEx _sxll ); - virtual void SetHighLimit( const CStringEx _sxhl ); -}; - -} // NLGEORGES - -#endif // NLGEORGES_TYPE_UNIT_FILE_NAME_H +// 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 NLGEORGES_TYPE_UNIT_FILE_NAME_H +#define NLGEORGES_TYPE_UNIT_FILE_NAME_H + +#include "type_unit.h" + +namespace NLOLDGEORGES +{ + +class CTypeUnitFileName : public CTypeUnit +{ +protected: + unsigned short int usihighlimit; + +public: + CTypeUnitFileName( const CStringEx _sxll, const CStringEx _sxhl, const CStringEx _sxdv, const CStringEx _sxf ); + virtual ~CTypeUnitFileName(); + + virtual CStringEx Format( const CStringEx _sxvalue ) const; + virtual CStringEx CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const; + virtual void SetDefaultValue( const CStringEx _sxdv ); + virtual void SetLowLimit( const CStringEx _sxll ); + virtual void SetHighLimit( const CStringEx _sxhl ); +}; + +} // NLGEORGES + +#endif // NLGEORGES_TYPE_UNIT_FILE_NAME_H diff --git a/code/ryzom/tools/leveldesign/georges_convert/type_unit_int_signed.cpp b/code/ryzom/tools/leveldesign/georges_convert/type_unit_int_signed.cpp index ab845a251..6e4783d60 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/type_unit_int_signed.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/type_unit_int_signed.cpp @@ -1,165 +1,165 @@ -// 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 "stdgeorgesconvert.h" -#include "type_unit_int_signed.h" -#include - -using namespace NLMISC; - - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CTypeUnitIntSigned::CTypeUnitIntSigned( const CStringEx _sxll, const CStringEx _sxhl, const CStringEx _sxdv, const CStringEx _sxf ) : CTypeUnit( _sxll, _sxhl, _sxdv, _sxf ) -{ - ilowlimit = atoiInt64( sxlowlimit.c_str() ); - ihighlimit = atoiInt64( sxhighlimit.c_str() ); - idefaultvalue = atoiInt64( sxdefaultvalue.c_str() ); - if( sxformula.empty() ) - sxformula = CStringEx( "sint(" +_sxll +"," +_sxhl +")" ); -} - -CTypeUnitIntSigned::~CTypeUnitIntSigned() -{ -} - -CStringEx CTypeUnitIntSigned::Format( const CStringEx _sxvalue ) const -{ - if( _sxvalue.empty() ) - return( sxdefaultvalue ); - - std::vector< std::pair< CStringEx, CStringEx > > modificationValues; - CStringEx value( _sxvalue ); - value.purge(); - while( value[0] == '<' ) - { - std::string::size_type pos = value.find( '>' ); - if( pos == std::string::npos ) - break; - CStringEx sxoperateur = value.get_mid( 1, 1 ); - CStringEx sxoperande = value.get_mid( 2, pos-2); - value.right( (int)(value.size()-pos-1) ); - modificationValues.push_back( std::make_pair( sxoperateur, sxoperande ) ); - } - if( modificationValues.size() ) - { - CStringEx sxr; - for( std::vector< std::pair< CStringEx, CStringEx > >::iterator it = modificationValues.begin(); it != modificationValues.end(); ++it ) - { - sxr += CStringEx( "<" ); - sxr += it->first; - sxr += it->second; - sxr += CStringEx( ">" ); - } - return( sxr ); - } - else - { - sint64 ivalue = atoiInt64( _sxvalue.c_str() ); - if( ivalue < ilowlimit ) - ivalue = ilowlimit; - if( ivalue > ihighlimit ) - ivalue = ihighlimit; - - char pc[256]; - itoaInt64( ivalue, pc, 10 ); - return( CStringEx( pc ) ); - } -} - -CStringEx CTypeUnitIntSigned::CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const -{ - nlassert( !_sxbasevalue.empty() ); - if( _sxvalue.empty() ) - return( _sxbasevalue ); - - std::vector< std::pair< CStringEx, CStringEx > > modificationValues; - CStringEx value( _sxvalue ); - value.purge(); - while( value[0] == '<' ) - { - std::string::size_type pos = value.find( '>' ); - if( pos == std::string::npos ) - break; - CStringEx sxoperateur = value.get_mid( 1, 1 ); - CStringEx sxoperande = value.get_mid( 2, (int)pos-2); - value.right( (int)(value.size()-pos-1) ); - modificationValues.push_back( std::make_pair( sxoperateur, sxoperande ) ); - } - if( modificationValues.size() ) - { - sint64 ir = atoiInt64( _sxbasevalue.c_str() ); - for( std::vector< std::pair< CStringEx, CStringEx > >::iterator it = modificationValues.begin(); it != modificationValues.end(); ++it ) - { - sint64 ivalue = atoiInt64( it->second.c_str() ); - if( it->first == "+" ) - ir += ivalue; - else if( it->first == "*" ) - ir *= ivalue; - else if( it->first == "-" ) - ir -= ivalue; - else if( it->first == "/" ) - ir /= ivalue; - else if( it->first == "^" ) - ir = (sint64)( pow( (double)(ir), (double)(ivalue) ) ); - } - if( ir < ilowlimit ) - ir = ilowlimit; - if( ir > ihighlimit ) - ir = ihighlimit; - char pc[256]; - itoaInt64( ir, pc, 10 ); - return( CStringEx( pc ) ); - } - else - { - sint64 ivalue = atoiInt64( _sxvalue.c_str() ); - if( ivalue < ilowlimit ) - ivalue = ilowlimit; - if( ivalue > ihighlimit ) - ivalue = ihighlimit; - char pc[256]; - itoaInt64( ivalue, pc, 10 ); - return( CStringEx( pc ) ); - } - - return( Format( _sxvalue ) ); -} - -void CTypeUnitIntSigned::SetDefaultValue( const CStringEx _sxdv ) -{ - sxdefaultvalue = _sxdv; - idefaultvalue = atoiInt64( sxdefaultvalue.c_str() ); -} - -void CTypeUnitIntSigned::SetLowLimit( const CStringEx _sxll ) -{ - sxlowlimit = _sxll; - ilowlimit = atoiInt64( sxlowlimit.c_str() ); -} - -void CTypeUnitIntSigned::SetHighLimit( const CStringEx _sxhl ) -{ - sxhighlimit = _sxhl; - ihighlimit = atoiInt64( sxhighlimit.c_str() ); -} - -} +// 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 "stdgeorgesconvert.h" +#include "type_unit_int_signed.h" +#include + +using namespace NLMISC; + + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CTypeUnitIntSigned::CTypeUnitIntSigned( const CStringEx _sxll, const CStringEx _sxhl, const CStringEx _sxdv, const CStringEx _sxf ) : CTypeUnit( _sxll, _sxhl, _sxdv, _sxf ) +{ + ilowlimit = atoiInt64( sxlowlimit.c_str() ); + ihighlimit = atoiInt64( sxhighlimit.c_str() ); + idefaultvalue = atoiInt64( sxdefaultvalue.c_str() ); + if( sxformula.empty() ) + sxformula = CStringEx( "sint(" +_sxll +"," +_sxhl +")" ); +} + +CTypeUnitIntSigned::~CTypeUnitIntSigned() +{ +} + +CStringEx CTypeUnitIntSigned::Format( const CStringEx _sxvalue ) const +{ + if( _sxvalue.empty() ) + return( sxdefaultvalue ); + + std::vector< std::pair< CStringEx, CStringEx > > modificationValues; + CStringEx value( _sxvalue ); + value.purge(); + while( value[0] == '<' ) + { + std::string::size_type pos = value.find( '>' ); + if( pos == std::string::npos ) + break; + CStringEx sxoperateur = value.get_mid( 1, 1 ); + CStringEx sxoperande = value.get_mid( 2, pos-2); + value.right( (int)(value.size()-pos-1) ); + modificationValues.push_back( std::make_pair( sxoperateur, sxoperande ) ); + } + if( modificationValues.size() ) + { + CStringEx sxr; + for( std::vector< std::pair< CStringEx, CStringEx > >::iterator it = modificationValues.begin(); it != modificationValues.end(); ++it ) + { + sxr += CStringEx( "<" ); + sxr += it->first; + sxr += it->second; + sxr += CStringEx( ">" ); + } + return( sxr ); + } + else + { + sint64 ivalue = atoiInt64( _sxvalue.c_str() ); + if( ivalue < ilowlimit ) + ivalue = ilowlimit; + if( ivalue > ihighlimit ) + ivalue = ihighlimit; + + char pc[256]; + itoaInt64( ivalue, pc, 10 ); + return( CStringEx( pc ) ); + } +} + +CStringEx CTypeUnitIntSigned::CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const +{ + nlassert( !_sxbasevalue.empty() ); + if( _sxvalue.empty() ) + return( _sxbasevalue ); + + std::vector< std::pair< CStringEx, CStringEx > > modificationValues; + CStringEx value( _sxvalue ); + value.purge(); + while( value[0] == '<' ) + { + std::string::size_type pos = value.find( '>' ); + if( pos == std::string::npos ) + break; + CStringEx sxoperateur = value.get_mid( 1, 1 ); + CStringEx sxoperande = value.get_mid( 2, (int)pos-2); + value.right( (int)(value.size()-pos-1) ); + modificationValues.push_back( std::make_pair( sxoperateur, sxoperande ) ); + } + if( modificationValues.size() ) + { + sint64 ir = atoiInt64( _sxbasevalue.c_str() ); + for( std::vector< std::pair< CStringEx, CStringEx > >::iterator it = modificationValues.begin(); it != modificationValues.end(); ++it ) + { + sint64 ivalue = atoiInt64( it->second.c_str() ); + if( it->first == "+" ) + ir += ivalue; + else if( it->first == "*" ) + ir *= ivalue; + else if( it->first == "-" ) + ir -= ivalue; + else if( it->first == "/" ) + ir /= ivalue; + else if( it->first == "^" ) + ir = (sint64)( pow( (double)(ir), (double)(ivalue) ) ); + } + if( ir < ilowlimit ) + ir = ilowlimit; + if( ir > ihighlimit ) + ir = ihighlimit; + char pc[256]; + itoaInt64( ir, pc, 10 ); + return( CStringEx( pc ) ); + } + else + { + sint64 ivalue = atoiInt64( _sxvalue.c_str() ); + if( ivalue < ilowlimit ) + ivalue = ilowlimit; + if( ivalue > ihighlimit ) + ivalue = ihighlimit; + char pc[256]; + itoaInt64( ivalue, pc, 10 ); + return( CStringEx( pc ) ); + } + + return( Format( _sxvalue ) ); +} + +void CTypeUnitIntSigned::SetDefaultValue( const CStringEx _sxdv ) +{ + sxdefaultvalue = _sxdv; + idefaultvalue = atoiInt64( sxdefaultvalue.c_str() ); +} + +void CTypeUnitIntSigned::SetLowLimit( const CStringEx _sxll ) +{ + sxlowlimit = _sxll; + ilowlimit = atoiInt64( sxlowlimit.c_str() ); +} + +void CTypeUnitIntSigned::SetHighLimit( const CStringEx _sxhl ) +{ + sxhighlimit = _sxhl; + ihighlimit = atoiInt64( sxhighlimit.c_str() ); +} + +} diff --git a/code/ryzom/tools/leveldesign/georges_convert/type_unit_int_signed.h b/code/ryzom/tools/leveldesign/georges_convert/type_unit_int_signed.h index e1ebec8a9..5365cfa04 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/type_unit_int_signed.h +++ b/code/ryzom/tools/leveldesign/georges_convert/type_unit_int_signed.h @@ -1,45 +1,45 @@ -// 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 NLGEORGES_TYPE_UNIT_SIGNED_H -#define NLGEORGES_TYPE_UNIT_SIGNED_H - -#include "type_unit.h" - -namespace NLOLDGEORGES -{ - -class CTypeUnitIntSigned : public CTypeUnit -{ -protected: - sint64 ilowlimit; - sint64 ihighlimit; - sint64 idefaultvalue; - -public: - CTypeUnitIntSigned( const CStringEx _sxll, const CStringEx _sxhl, const CStringEx _sxdv, const CStringEx _sxf ); - virtual ~CTypeUnitIntSigned(); - - virtual CStringEx Format( const CStringEx _sxvalue ) const; - virtual CStringEx CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const; - virtual void SetDefaultValue( const CStringEx _sxdv ); - virtual void SetLowLimit( const CStringEx _sxll ); - virtual void SetHighLimit( const CStringEx _sxhl ); -}; - -} // NLGEORGES - -#endif // NLGEORGES_TYPE_UNIT_SIGNED_H +// 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 NLGEORGES_TYPE_UNIT_SIGNED_H +#define NLGEORGES_TYPE_UNIT_SIGNED_H + +#include "type_unit.h" + +namespace NLOLDGEORGES +{ + +class CTypeUnitIntSigned : public CTypeUnit +{ +protected: + sint64 ilowlimit; + sint64 ihighlimit; + sint64 idefaultvalue; + +public: + CTypeUnitIntSigned( const CStringEx _sxll, const CStringEx _sxhl, const CStringEx _sxdv, const CStringEx _sxf ); + virtual ~CTypeUnitIntSigned(); + + virtual CStringEx Format( const CStringEx _sxvalue ) const; + virtual CStringEx CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const; + virtual void SetDefaultValue( const CStringEx _sxdv ); + virtual void SetLowLimit( const CStringEx _sxll ); + virtual void SetHighLimit( const CStringEx _sxhl ); +}; + +} // NLGEORGES + +#endif // NLGEORGES_TYPE_UNIT_SIGNED_H diff --git a/code/ryzom/tools/leveldesign/georges_convert/type_unit_int_unsigned.cpp b/code/ryzom/tools/leveldesign/georges_convert/type_unit_int_unsigned.cpp index 01312b9b4..0e65af463 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/type_unit_int_unsigned.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/type_unit_int_unsigned.cpp @@ -1,197 +1,197 @@ -// 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 "stdgeorgesconvert.h" -#include "type_unit_int_unsigned.h" -#include "nel/misc/common.h" - -using namespace NLMISC; - - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CTypeUnitIntUnsigned::CTypeUnitIntUnsigned( const CStringEx _sxll, const CStringEx _sxhl, const CStringEx _sxdv, const CStringEx _sxf ) : CTypeUnit( _sxll, _sxhl, _sxdv, _sxf ) -{ - ilowlimit = atoiInt64( sxlowlimit.c_str() ); - ihighlimit = atoiInt64( sxhighlimit.c_str() ); - idefaultvalue = atoiInt64( sxdefaultvalue.c_str() ); - if( sxformula.empty() ) - sxformula = CStringEx( "uint(" +_sxll +"," +_sxhl +")" ); -} - -CTypeUnitIntUnsigned::~CTypeUnitIntUnsigned() -{ -} - -/* -CStringEx CTypeUnitIntUnsigned::Format( const CStringEx _sxvalue ) const -{ - if( _sxvalue.empty() ) - return( sxdefaultvalue ); - - unsigned __int64 ivalue = _atoi64( _sxvalue.c_str() ); - if( ivalue < ilowlimit ) - ivalue = ilowlimit; - if( ivalue > ihighlimit ) - ivalue = ihighlimit; - - char pc[256]; - _ui64toa( ivalue, pc, 10 ); - return( CStringEx( pc ) ); -} -*/ - -CStringEx CTypeUnitIntUnsigned::Format( const CStringEx _sxvalue ) const -{ - if( _sxvalue.empty() ) - return( sxdefaultvalue ); - - std::vector< std::pair< CStringEx, CStringEx > > modificationValues; - CStringEx value( _sxvalue ); - value.purge(); - while( value[0] == '<' ) - { - std::string::size_type pos = value.find( '>' ); - if( pos == std::string::npos ) - break; - CStringEx sxoperateur = value.get_mid( 1, 1 ); - CStringEx sxoperande = value.get_mid( 2, (int)pos-2); - value.right( (int)(value.size()-pos-1) ); - modificationValues.push_back( std::make_pair( sxoperateur, sxoperande ) ); - } - if( modificationValues.size() ) - { - CStringEx sxr; - for( std::vector< std::pair< CStringEx, CStringEx > >::iterator it = modificationValues.begin(); it != modificationValues.end(); ++it ) - { - sxr += CStringEx( "<" ); - sxr += it->first; - sxr += it->second; - sxr += CStringEx( ">" ); - } - return( sxr ); - } - else - { - uint64 ivalue = atoiInt64( _sxvalue.c_str() ); - if( ivalue < ilowlimit ) - ivalue = ilowlimit; - if( ivalue > ihighlimit ) - ivalue = ihighlimit; - - char pc[256]; - itoaInt64( ivalue, pc, 10 ); - return( CStringEx( pc ) ); - } -} - -/* -CStringEx CTypeUnitIntUnsigned::CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const -{ - nlassert( !_sxbasevalue.empty() ); - if( _sxvalue.empty() ) - return( _sxbasevalue ); - return( Format( _sxvalue ) ); -} -*/ - -CStringEx CTypeUnitIntUnsigned::CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const -{ - nlassert( !_sxbasevalue.empty() ); - if( _sxvalue.empty() ) - return( _sxbasevalue ); - - std::vector< std::pair< CStringEx, CStringEx > > modificationValues; - CStringEx value( _sxvalue ); - value.purge(); - while( value[0] == '<' ) - { - std::string::size_type pos = value.find( '>' ); - if( pos == std::string::npos ) - break; - CStringEx sxoperateur = value.get_mid( 1, 1 ); - CStringEx sxoperande = value.get_mid( 2, (int)pos-2); - value.right( (int)(value.size()-pos-1) ); - modificationValues.push_back( std::make_pair( sxoperateur, sxoperande ) ); - } - if( modificationValues.size() ) - { - sint64 ir = atoiInt64( _sxbasevalue.c_str() ); - for( std::vector< std::pair< CStringEx, CStringEx > >::iterator it = modificationValues.begin(); it != modificationValues.end(); ++it ) - { - sint64 ivalue = atoiInt64( it->second.c_str() ); - if( it->first == "+" ) - ir += ivalue; - else if( it->first == "*" ) - ir *= ivalue; - else if( it->first == "-" ) - ir -= ivalue; - else if( it->first == "/" ) - ir /= ivalue; - else if( it->first == "^" ) - { - ir = (sint64)( pow( (double)(ir), (double)(ivalue) ) ); - } - } - uint64 uir = ir; - if( uir < ilowlimit ) - uir = ilowlimit; - if( uir > ihighlimit ) - uir = ihighlimit; - char pc[256]; - itoaInt64( uir, pc, 10 ); - return( CStringEx( pc ) ); - } - else - { - uint64 ivalue = atoiInt64( _sxvalue.c_str() ); - if( ivalue < ilowlimit ) - ivalue = ilowlimit; - if( ivalue > ihighlimit ) - ivalue = ihighlimit; - char pc[256]; - itoaInt64( ivalue, pc, 10 ); - return( CStringEx( pc ) ); - } - return( Format( _sxvalue ) ); -} - -void CTypeUnitIntUnsigned::SetDefaultValue( const CStringEx _sxdv ) -{ - sxdefaultvalue = _sxdv; - idefaultvalue = atoiInt64( sxdefaultvalue.c_str() ); -} - -void CTypeUnitIntUnsigned::SetLowLimit( const CStringEx _sxll ) -{ - sxlowlimit = _sxll; - ilowlimit = atoiInt64( sxlowlimit.c_str() ); -} - -void CTypeUnitIntUnsigned::SetHighLimit( const CStringEx _sxhl ) -{ - sxhighlimit = _sxhl; - ihighlimit = atoiInt64( sxhighlimit.c_str() ); -} - -} - - +// 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 "stdgeorgesconvert.h" +#include "type_unit_int_unsigned.h" +#include "nel/misc/common.h" + +using namespace NLMISC; + + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CTypeUnitIntUnsigned::CTypeUnitIntUnsigned( const CStringEx _sxll, const CStringEx _sxhl, const CStringEx _sxdv, const CStringEx _sxf ) : CTypeUnit( _sxll, _sxhl, _sxdv, _sxf ) +{ + ilowlimit = atoiInt64( sxlowlimit.c_str() ); + ihighlimit = atoiInt64( sxhighlimit.c_str() ); + idefaultvalue = atoiInt64( sxdefaultvalue.c_str() ); + if( sxformula.empty() ) + sxformula = CStringEx( "uint(" +_sxll +"," +_sxhl +")" ); +} + +CTypeUnitIntUnsigned::~CTypeUnitIntUnsigned() +{ +} + +/* +CStringEx CTypeUnitIntUnsigned::Format( const CStringEx _sxvalue ) const +{ + if( _sxvalue.empty() ) + return( sxdefaultvalue ); + + unsigned __int64 ivalue = _atoi64( _sxvalue.c_str() ); + if( ivalue < ilowlimit ) + ivalue = ilowlimit; + if( ivalue > ihighlimit ) + ivalue = ihighlimit; + + char pc[256]; + _ui64toa( ivalue, pc, 10 ); + return( CStringEx( pc ) ); +} +*/ + +CStringEx CTypeUnitIntUnsigned::Format( const CStringEx _sxvalue ) const +{ + if( _sxvalue.empty() ) + return( sxdefaultvalue ); + + std::vector< std::pair< CStringEx, CStringEx > > modificationValues; + CStringEx value( _sxvalue ); + value.purge(); + while( value[0] == '<' ) + { + std::string::size_type pos = value.find( '>' ); + if( pos == std::string::npos ) + break; + CStringEx sxoperateur = value.get_mid( 1, 1 ); + CStringEx sxoperande = value.get_mid( 2, (int)pos-2); + value.right( (int)(value.size()-pos-1) ); + modificationValues.push_back( std::make_pair( sxoperateur, sxoperande ) ); + } + if( modificationValues.size() ) + { + CStringEx sxr; + for( std::vector< std::pair< CStringEx, CStringEx > >::iterator it = modificationValues.begin(); it != modificationValues.end(); ++it ) + { + sxr += CStringEx( "<" ); + sxr += it->first; + sxr += it->second; + sxr += CStringEx( ">" ); + } + return( sxr ); + } + else + { + uint64 ivalue = atoiInt64( _sxvalue.c_str() ); + if( ivalue < ilowlimit ) + ivalue = ilowlimit; + if( ivalue > ihighlimit ) + ivalue = ihighlimit; + + char pc[256]; + itoaInt64( ivalue, pc, 10 ); + return( CStringEx( pc ) ); + } +} + +/* +CStringEx CTypeUnitIntUnsigned::CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const +{ + nlassert( !_sxbasevalue.empty() ); + if( _sxvalue.empty() ) + return( _sxbasevalue ); + return( Format( _sxvalue ) ); +} +*/ + +CStringEx CTypeUnitIntUnsigned::CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const +{ + nlassert( !_sxbasevalue.empty() ); + if( _sxvalue.empty() ) + return( _sxbasevalue ); + + std::vector< std::pair< CStringEx, CStringEx > > modificationValues; + CStringEx value( _sxvalue ); + value.purge(); + while( value[0] == '<' ) + { + std::string::size_type pos = value.find( '>' ); + if( pos == std::string::npos ) + break; + CStringEx sxoperateur = value.get_mid( 1, 1 ); + CStringEx sxoperande = value.get_mid( 2, (int)pos-2); + value.right( (int)(value.size()-pos-1) ); + modificationValues.push_back( std::make_pair( sxoperateur, sxoperande ) ); + } + if( modificationValues.size() ) + { + sint64 ir = atoiInt64( _sxbasevalue.c_str() ); + for( std::vector< std::pair< CStringEx, CStringEx > >::iterator it = modificationValues.begin(); it != modificationValues.end(); ++it ) + { + sint64 ivalue = atoiInt64( it->second.c_str() ); + if( it->first == "+" ) + ir += ivalue; + else if( it->first == "*" ) + ir *= ivalue; + else if( it->first == "-" ) + ir -= ivalue; + else if( it->first == "/" ) + ir /= ivalue; + else if( it->first == "^" ) + { + ir = (sint64)( pow( (double)(ir), (double)(ivalue) ) ); + } + } + uint64 uir = ir; + if( uir < ilowlimit ) + uir = ilowlimit; + if( uir > ihighlimit ) + uir = ihighlimit; + char pc[256]; + itoaInt64( uir, pc, 10 ); + return( CStringEx( pc ) ); + } + else + { + uint64 ivalue = atoiInt64( _sxvalue.c_str() ); + if( ivalue < ilowlimit ) + ivalue = ilowlimit; + if( ivalue > ihighlimit ) + ivalue = ihighlimit; + char pc[256]; + itoaInt64( ivalue, pc, 10 ); + return( CStringEx( pc ) ); + } + return( Format( _sxvalue ) ); +} + +void CTypeUnitIntUnsigned::SetDefaultValue( const CStringEx _sxdv ) +{ + sxdefaultvalue = _sxdv; + idefaultvalue = atoiInt64( sxdefaultvalue.c_str() ); +} + +void CTypeUnitIntUnsigned::SetLowLimit( const CStringEx _sxll ) +{ + sxlowlimit = _sxll; + ilowlimit = atoiInt64( sxlowlimit.c_str() ); +} + +void CTypeUnitIntUnsigned::SetHighLimit( const CStringEx _sxhl ) +{ + sxhighlimit = _sxhl; + ihighlimit = atoiInt64( sxhighlimit.c_str() ); +} + +} + + diff --git a/code/ryzom/tools/leveldesign/georges_convert/type_unit_int_unsigned.h b/code/ryzom/tools/leveldesign/georges_convert/type_unit_int_unsigned.h index b4f5b9a0a..6790dfbca 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/type_unit_int_unsigned.h +++ b/code/ryzom/tools/leveldesign/georges_convert/type_unit_int_unsigned.h @@ -1,45 +1,45 @@ -// 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 NLGEORGES_TYPE_UNIT_INT_SIGNED_H -#define NLGEORGES_TYPE_UNIT_INT_SIGNED_H - -#include "type_unit.h" - -namespace NLOLDGEORGES -{ - -class CTypeUnitIntUnsigned : public CTypeUnit -{ -protected: - uint64 ilowlimit; - uint64 ihighlimit; - uint64 idefaultvalue; - -public: - CTypeUnitIntUnsigned( const CStringEx _sxll, const CStringEx _sxhl, const CStringEx _sxdv, const CStringEx _sxf ); - virtual ~CTypeUnitIntUnsigned(); - - virtual CStringEx Format( const CStringEx _sxvalue ) const; - virtual CStringEx CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const; - virtual void SetDefaultValue( const CStringEx _sxdv ); - virtual void SetLowLimit( const CStringEx _sxll ); - virtual void SetHighLimit( const CStringEx _sxhl ); -}; - -} // NLGEORGES - -#endif // NLGEORGES_TYPE_UNIT_INT_SIGNED_H +// 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 NLGEORGES_TYPE_UNIT_INT_SIGNED_H +#define NLGEORGES_TYPE_UNIT_INT_SIGNED_H + +#include "type_unit.h" + +namespace NLOLDGEORGES +{ + +class CTypeUnitIntUnsigned : public CTypeUnit +{ +protected: + uint64 ilowlimit; + uint64 ihighlimit; + uint64 idefaultvalue; + +public: + CTypeUnitIntUnsigned( const CStringEx _sxll, const CStringEx _sxhl, const CStringEx _sxdv, const CStringEx _sxf ); + virtual ~CTypeUnitIntUnsigned(); + + virtual CStringEx Format( const CStringEx _sxvalue ) const; + virtual CStringEx CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const; + virtual void SetDefaultValue( const CStringEx _sxdv ); + virtual void SetLowLimit( const CStringEx _sxll ); + virtual void SetHighLimit( const CStringEx _sxhl ); +}; + +} // NLGEORGES + +#endif // NLGEORGES_TYPE_UNIT_INT_SIGNED_H diff --git a/code/ryzom/tools/leveldesign/georges_convert/type_unit_string.cpp b/code/ryzom/tools/leveldesign/georges_convert/type_unit_string.cpp index 6917c7ad7..80045949b 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/type_unit_string.cpp +++ b/code/ryzom/tools/leveldesign/georges_convert/type_unit_string.cpp @@ -1,79 +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 . - -#include "stdgeorgesconvert.h" -#include "type_unit_string.h" - -namespace NLOLDGEORGES -{ - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CTypeUnitString::CTypeUnitString( const CStringEx _sxll, const CStringEx _sxhl, const CStringEx _sxdv, const CStringEx _sxf ) : CTypeUnit( _sxhl, _sxll, _sxdv, _sxf ) -{ - if( sxhighlimit.empty() ) - { - usihighlimit = 0xFFFF; - sxformula = "string"; - } - else - { - usihighlimit = atoi( sxhighlimit.c_str() ); - sxformula.format( "string[%d]", usihighlimit ); - } -} - -CTypeUnitString::~CTypeUnitString() -{ -} - -CStringEx CTypeUnitString::Format( const CStringEx _sxvalue ) const -{ - if( _sxvalue.empty() ) - return( sxdefaultvalue ); - - if( _sxvalue.length() > usihighlimit ) - return( _sxvalue.get_left( usihighlimit ) ); - else - return( _sxvalue ); -} - -CStringEx CTypeUnitString::CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const -{ - if( _sxvalue.empty() ) - return( Format( _sxbasevalue ) ); - return( Format( _sxvalue ) ); -} - -void CTypeUnitString::SetDefaultValue( const CStringEx _sxdv ) -{ - sxdefaultvalue = _sxdv; -} - -void CTypeUnitString::SetLowLimit( const CStringEx _sxll ) -{ - sxlowlimit = _sxll; -} - -void CTypeUnitString::SetHighLimit( const CStringEx _sxhl ) -{ - sxhighlimit = _sxhl; - usihighlimit = atoi( sxhighlimit.c_str() ); -} - +// 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 "stdgeorgesconvert.h" +#include "type_unit_string.h" + +namespace NLOLDGEORGES +{ + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CTypeUnitString::CTypeUnitString( const CStringEx _sxll, const CStringEx _sxhl, const CStringEx _sxdv, const CStringEx _sxf ) : CTypeUnit( _sxhl, _sxll, _sxdv, _sxf ) +{ + if( sxhighlimit.empty() ) + { + usihighlimit = 0xFFFF; + sxformula = "string"; + } + else + { + usihighlimit = atoi( sxhighlimit.c_str() ); + sxformula.format( "string[%d]", usihighlimit ); + } +} + +CTypeUnitString::~CTypeUnitString() +{ +} + +CStringEx CTypeUnitString::Format( const CStringEx _sxvalue ) const +{ + if( _sxvalue.empty() ) + return( sxdefaultvalue ); + + if( _sxvalue.length() > usihighlimit ) + return( _sxvalue.get_left( usihighlimit ) ); + else + return( _sxvalue ); +} + +CStringEx CTypeUnitString::CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const +{ + if( _sxvalue.empty() ) + return( Format( _sxbasevalue ) ); + return( Format( _sxvalue ) ); +} + +void CTypeUnitString::SetDefaultValue( const CStringEx _sxdv ) +{ + sxdefaultvalue = _sxdv; +} + +void CTypeUnitString::SetLowLimit( const CStringEx _sxll ) +{ + sxlowlimit = _sxll; +} + +void CTypeUnitString::SetHighLimit( const CStringEx _sxhl ) +{ + sxhighlimit = _sxhl; + usihighlimit = atoi( sxhighlimit.c_str() ); +} + } \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_convert/type_unit_string.h b/code/ryzom/tools/leveldesign/georges_convert/type_unit_string.h index e0a1005ac..d4a3e5362 100644 --- a/code/ryzom/tools/leveldesign/georges_convert/type_unit_string.h +++ b/code/ryzom/tools/leveldesign/georges_convert/type_unit_string.h @@ -1,43 +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 . - -#ifndef NLGEORGES_TYPE_UNIT_STRING_H -#define NLGEORGES_TYPE_UNIT_STRING_H - -#include "type_unit.h" - -namespace NLOLDGEORGES -{ - -class CTypeUnitString : public CTypeUnit -{ -protected: - unsigned short int usihighlimit; - -public: - CTypeUnitString( const CStringEx _sxll, const CStringEx _sxhl, const CStringEx _sxdv, const CStringEx _sxf ); - virtual ~CTypeUnitString(); - - virtual CStringEx Format( const CStringEx _sxvalue ) const; - virtual CStringEx CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const; - virtual void SetDefaultValue( const CStringEx _sxdv ); - virtual void SetLowLimit( const CStringEx _sxll ); - virtual void SetHighLimit( const CStringEx _sxhl ); -}; - -} // NLGEORGES - -#endif // NLGEORGES_TYPE_UNIT_STRING_H +// 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 NLGEORGES_TYPE_UNIT_STRING_H +#define NLGEORGES_TYPE_UNIT_STRING_H + +#include "type_unit.h" + +namespace NLOLDGEORGES +{ + +class CTypeUnitString : public CTypeUnit +{ +protected: + unsigned short int usihighlimit; + +public: + CTypeUnitString( const CStringEx _sxll, const CStringEx _sxhl, const CStringEx _sxdv, const CStringEx _sxf ); + virtual ~CTypeUnitString(); + + virtual CStringEx Format( const CStringEx _sxvalue ) const; + virtual CStringEx CalculateResult( const CStringEx _sxbasevalue, const CStringEx _sxvalue ) const; + virtual void SetDefaultValue( const CStringEx _sxdv ); + virtual void SetLowLimit( const CStringEx _sxll ); + virtual void SetHighLimit( const CStringEx _sxhl ); +}; + +} // NLGEORGES + +#endif // NLGEORGES_TYPE_UNIT_STRING_H diff --git a/code/ryzom/tools/leveldesign/georges_dll/Resource.h b/code/ryzom/tools/leveldesign/georges_dll/Resource.h index b97e087d2..27840d8cc 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/Resource.h +++ b/code/ryzom/tools/leveldesign/georges_dll/Resource.h @@ -1,98 +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 . - -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by georges_edit.rc -// -#define IDC_BROWSE 3 -#define IDC_BROWSE2 4 -#define IDD_ABOUTBOX 100 -#define ID_VIEW_ARRANGE 127 -#define IDR_MAINFRAME 128 -#define IDR_TYPETYPE 129 -#define IDD_BASE_DIALOG 130 -#define IDD_SETTINGS 131 -#define IDR_TYPEDFN 132 -#define IDD_FILE_BROWSER 132 -#define IDR_TYPEFORM 133 -#define IDD_OUTPUT_CONSOLE 133 -#define IDR_LEFT_VIEW_CONTEXT 134 -#define IDR_ARRAY 140 -#define IDR_STRUCT 141 -#define IDR_HOLD 142 -#define IDR_HEADER 143 -#define IDR_VSTRUCT 144 -#define IDR_ROOT 145 -#define IDD_SPLASHSCREEN 146 -#define IDC_ROOT_SEARCH_PATH 1009 -#define IDC_REMEMBER_LIST_SIZE 1010 -#define IDC_DEFAULT_TYPE 1011 -#define IDC_DEFAULT_DFN 1012 -#define IDC_TYP_DFN_PATH 1013 -#define IDC_MAX_UNDO 1014 -#define IDC_BUTTON2 1015 -#define IDC_TAB_FILE 1019 -#define IDC_OUTPUT_CONSOLE 1021 -#define IDC_START_EXPANDED 1023 -#define IDC_GEORGES_4_CVS 1024 -#define IDC_LOAD_GEORGES 1024 -#define ID_VIEW_SETTINGS 32773 -#define ID_OPEN_SELECTED 32774 -#define ID_VIEW_DOCKINGDIALOGBAR 32775 -#define ID_VIEW_OUTPUT_CONSOLE 32776 -#define ID_VIEW_GOTO_OUTPUT_CONSOLE 32778 -#define ID_VIEW_GOTO_FILE_BROWSER 32779 -#define ID_DELETE 32781 -#define ID_INSERT 32782 -#define ID_MODULES_0 32783 -#define ID_MODULES_1 32784 -#define ID_MODULES_2 32785 -#define ID_MODULES_3 32786 -#define ID_VIEW_REFRESH 32787 -#define ID_FILE_CLOSE_ALL 32788 -#define ID_FILE_SAVE_ALL 32789 -#define ID_VIEW_PROPERTIES 32790 -#define ID_EDIT_RENAME 32791 -#define ID_EDIT_HOLD1 32792 -#define ID_EDIT_HOLD2 32793 -#define ID_EDIT_HOLD3 32794 -#define ID_EDIT_HOLD4 32795 -#define ID_EDIT_FETCH1 32796 -#define ID_EDIT_FETCH2 32797 -#define ID_EDIT_FETCH3 32798 -#define ID_EDIT_FETCH4 32799 -#define ID_BUTTON32800 32800 -#define ID_BUTTON32801 32801 -#define ID_BUTTON32802 32802 -#define ID_BUTTON32803 32803 -#define ID_BUTTON32805 32805 -#define ID_EDIT_EXPANDALL 32807 -#define ID_EDIT_COLLAPSEALL 32808 -#define ID_BROWSER_SORTED_BY_TYPE 32809 -#define IDS_TYPE 61216 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_3D_CONTROLS 1 -#define _APS_NEXT_RESOURCE_VALUE 147 -#define _APS_NEXT_COMMAND_VALUE 32810 -#define _APS_NEXT_CONTROL_VALUE 1025 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif +// 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 . + +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by georges_edit.rc +// +#define IDC_BROWSE 3 +#define IDC_BROWSE2 4 +#define IDD_ABOUTBOX 100 +#define ID_VIEW_ARRANGE 127 +#define IDR_MAINFRAME 128 +#define IDR_TYPETYPE 129 +#define IDD_BASE_DIALOG 130 +#define IDD_SETTINGS 131 +#define IDR_TYPEDFN 132 +#define IDD_FILE_BROWSER 132 +#define IDR_TYPEFORM 133 +#define IDD_OUTPUT_CONSOLE 133 +#define IDR_LEFT_VIEW_CONTEXT 134 +#define IDR_ARRAY 140 +#define IDR_STRUCT 141 +#define IDR_HOLD 142 +#define IDR_HEADER 143 +#define IDR_VSTRUCT 144 +#define IDR_ROOT 145 +#define IDD_SPLASHSCREEN 146 +#define IDC_ROOT_SEARCH_PATH 1009 +#define IDC_REMEMBER_LIST_SIZE 1010 +#define IDC_DEFAULT_TYPE 1011 +#define IDC_DEFAULT_DFN 1012 +#define IDC_TYP_DFN_PATH 1013 +#define IDC_MAX_UNDO 1014 +#define IDC_BUTTON2 1015 +#define IDC_TAB_FILE 1019 +#define IDC_OUTPUT_CONSOLE 1021 +#define IDC_START_EXPANDED 1023 +#define IDC_GEORGES_4_CVS 1024 +#define IDC_LOAD_GEORGES 1024 +#define ID_VIEW_SETTINGS 32773 +#define ID_OPEN_SELECTED 32774 +#define ID_VIEW_DOCKINGDIALOGBAR 32775 +#define ID_VIEW_OUTPUT_CONSOLE 32776 +#define ID_VIEW_GOTO_OUTPUT_CONSOLE 32778 +#define ID_VIEW_GOTO_FILE_BROWSER 32779 +#define ID_DELETE 32781 +#define ID_INSERT 32782 +#define ID_MODULES_0 32783 +#define ID_MODULES_1 32784 +#define ID_MODULES_2 32785 +#define ID_MODULES_3 32786 +#define ID_VIEW_REFRESH 32787 +#define ID_FILE_CLOSE_ALL 32788 +#define ID_FILE_SAVE_ALL 32789 +#define ID_VIEW_PROPERTIES 32790 +#define ID_EDIT_RENAME 32791 +#define ID_EDIT_HOLD1 32792 +#define ID_EDIT_HOLD2 32793 +#define ID_EDIT_HOLD3 32794 +#define ID_EDIT_HOLD4 32795 +#define ID_EDIT_FETCH1 32796 +#define ID_EDIT_FETCH2 32797 +#define ID_EDIT_FETCH3 32798 +#define ID_EDIT_FETCH4 32799 +#define ID_BUTTON32800 32800 +#define ID_BUTTON32801 32801 +#define ID_BUTTON32802 32802 +#define ID_BUTTON32803 32803 +#define ID_BUTTON32805 32805 +#define ID_EDIT_EXPANDALL 32807 +#define ID_EDIT_COLLAPSEALL 32808 +#define ID_BROWSER_SORTED_BY_TYPE 32809 +#define IDS_TYPE 61216 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_3D_CONTROLS 1 +#define _APS_NEXT_RESOURCE_VALUE 147 +#define _APS_NEXT_COMMAND_VALUE 32810 +#define _APS_NEXT_CONTROL_VALUE 1025 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/code/ryzom/tools/leveldesign/georges_dll/action.cpp b/code/ryzom/tools/leveldesign/georges_dll/action.cpp index af9f2eb10..3bb3483a1 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/action.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/action.cpp @@ -1,1231 +1,1231 @@ -// 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 "stdafx.h" -#include "georges_edit.h" -#include "georges_edit_doc.h" -#include "georges_edit_view.h" -#include "left_view.h" - -#include "nel/georges/type.h" -#include "nel/georges/form_dfn.h" -#include "nel/georges/form_elm.h" - -#include "action.h" - -using namespace std; -using namespace NLMISC; -using namespace NLGEORGES; - -#define _OldValue (_Value[0]) -#define _NewValue (_Value[1]) - -// *************************************************************************** - -IAction::IAction (TTypeAction type, uint selId, uint slot) -{ - _Type = type; - _SelId = selId; - _Slot = slot; -} - -// *************************************************************************** - -void IAction::setLabel (const char *logLabel, CGeorgesEditDoc &doc) -{ - _LogLabel = logLabel; - - // New log present - _LogPresent[1] = true; - - // Find log.. - std::map::iterator ite = doc._LastLogs.find (logLabel); - if (ite != doc._LastLogs.end ()) - { - _LogPresent[0] = true; - _Log[0] = logLabel; - } - else - { - _LogPresent[0] = false; - } -} - -// *************************************************************************** - -bool IAction::doAction (CGeorgesEditDoc &doc, bool redo, bool &modified, bool firstTime) -{ - uint index = (uint)redo; - doc.logValueChange (_LogLabel.c_str (), _Log[index].c_str (), _LogPresent[index]); - return true; -} - -// *************************************************************************** - -void IAction::update (bool updateLeftView, TUpdateRightView rightViewFlag, CGeorgesEditDoc &doc, const char *_FormName) -{ - // Right and left view - CGeorgesEditView *rightView = doc.getRightView (); - nlassert (rightView); - CLeftView *leftView = doc.getLeftView (); - nlassert (leftView); - - // Update left view ? - if (updateLeftView) - doc.updateDocumentStructure (); - - // Set the current view.. - uint subSelection = leftView->getCurrentSelectionId (); - if (subSelection != _SelId) - { - doc.changeSubSelection (_SelId, NULL); - return; - } - - if (leftView->getCurrentSelectionId () == 1) - { - rightView->HeaderDialog.getFromDocument (*doc.getHeaderPtr ()); - } - else if (doc.isType ()) - { - rightView->TypeDialog.getFromDocument (*(doc.getTypePtr())); - } - else if (doc.isDfn ()) - { - rightView->DfnDialog.getFromDocument (*(doc.getDfnPtr())); - } - else if (doc.isForm ()) - { - if (rightViewFlag == DoNothing) - { - } - else if (rightViewFlag == UpdateLabels) - { - rightView->FormDialog.updateLabels (); - } - else if (rightViewFlag == UpdateValues) - { - rightView->FormDialog.updateValues (); - } - else if (rightViewFlag == Redraw) - { - rightView->FormDialog.getFromDocument (); - } - } -} - -// *************************************************************************** - -CActionString::CActionString (IAction::TTypeAction type, const char *newValue, CGeorgesEditDoc &doc, const char *formName, const char *userData, uint selId, uint slot) : IAction (type, selId, slot) -{ - // Set the new value - _NewValue = newValue; - _FormName = formName; - _Log[1] = newValue; - _UserData = userData; - - // Backup old value - switch (_Type) - { - case TypeType: - { - CType *type = doc.getTypePtr (); - _OldValue = toString ((int)(type->Type)); - setLabel ("Type Type", doc); - _Log[1] = type->getTypeName ((UType::TType)atoi (newValue)); - } - break; - case TypeUI: - { - CType *type = doc.getTypePtr (); - _OldValue = toString ((int)(type->UIType)); - setLabel ("Type UI", doc); - _Log[1] = type->getUIName ((CType::TUI)atoi (newValue)); - } - break; - case TypeDefault: - { - CType *type = doc.getTypePtr (); - _OldValue = type->Default; - setLabel ("Type Default", doc); - } - break; - case TypeMin: - { - CType *type = doc.getTypePtr (); - _OldValue = type->Min; - setLabel ("Type Min", doc); - } - break; - case TypeMax: - { - CType *type = doc.getTypePtr (); - _OldValue = type->Max; - setLabel ("Type Max", doc); - } - break; - case TypeIncrement: - { - CType *type = doc.getTypePtr (); - _OldValue = type->Increment; - setLabel ("Type Increment", doc); - } - break; - case FormTypeValue: - case FormValue: - { - // Form - const NLGEORGES::CForm &form = *(doc.getFormPtr ()); - nlverify (doc.getRootNode (_Slot)->getValueByName (_OldValue, formName, UFormElm::NoEval, NULL)); - setLabel (formName, doc); - } - break; - case HeaderVersion: - { - CFileHeader *header = doc.getHeaderPtr (); - char versionText[512]; - smprintf (versionText, 512, "Version %d.%d", header->MajorVersion, header->MinorVersion); - _OldValue = versionText; - setLabel ("Header Version", doc); - } - break; - case HeaderState: - { - CFileHeader *header = doc.getHeaderPtr (); - _OldValue = toString ((int)(header->State)).c_str (); - setLabel ("Header State", doc); - } - break; - case HeaderComments: - { - _OldValue = doc.getHeaderPtr ()->Comments; - setLabel ("Header Comments", doc); - } - break; - case FormArrayRename: - { - setLabel ((formName+string (" Renamed")).c_str (), doc); - int idInParent = atoi (_UserData.c_str ()); - - // Get the parent node - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - bool vdfnArray; - CForm *form=doc.getFormPtr (); - CFormElm *elm = doc.getRootNode (slot); - nlverify ( elm->getNodeByName (_FormName.c_str (), &parentDfn, indexDfn, - &nodeDfn, &nodeType, &node, type, array, vdfnArray, true, NLGEORGES_FIRST_ROUND) ); - if (node) - { - CFormElmArray* array = safe_cast (node->getParent ()); - _OldValue = array->Elements[idInParent].Name; - } - } - break; - case FormArrayInsert: - { - // do nothing - setLabel ("Array Insert", doc); - } - break; - default: - nlstop; - } -} - -// *************************************************************************** - -bool CActionString::doAction (CGeorgesEditDoc &doc, bool redo, bool &modified, bool firstTime) -{ - IAction::doAction (doc, redo, modified, firstTime); - - modified = false; - bool ok = true; - uint index = (uint)redo; - switch (_Type) - { - case TypeType: - { - CType *type = doc.getTypePtr (); - type->Type = (CType::TType)(atoi (_Value[index].c_str ())); - modified = true; - update (false, Redraw, doc, _FormName.c_str ()); - } - break; - case TypeUI: - { - CType *type = doc.getTypePtr (); - type->UIType = (CType::TUI)(atoi (_Value[index].c_str ())); - modified = true; - update (false, Redraw, doc, _FormName.c_str ()); - } - break; - case TypeDefault: - { - CType *type = doc.getTypePtr (); - type->Default = _Value[index]; - modified = true; - if (!firstTime) - update (false, Redraw, doc, _FormName.c_str ()); - } - break; - case TypeMin: - { - CType *type = doc.getTypePtr (); - type->Min = _Value[index]; - modified = true; - if (!firstTime) - update (false, Redraw, doc, _FormName.c_str ()); - } - break; - case TypeMax: - { - CType *type = doc.getTypePtr (); - type->Max = _Value[index]; - modified = true; - if (!firstTime) - update (false, Redraw, doc, _FormName.c_str ()); - } - break; - case TypeIncrement: - { - CType *type = doc.getTypePtr (); - type->Increment = _Value[index]; - modified = true; - if (!firstTime) - update (false, Redraw, doc, _FormName.c_str ()); - } - break; - case FormTypeValue: - case FormValue: - { - // Empty ? - if (!_Value[index].empty ()) - { - // Get / create the node - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - bool created; - CForm *form=doc.getFormPtr (); - CFormElm *elm = doc.getRootNode (_Slot); - nlverify ( elm->createNodeByName (_FormName.c_str (), &parentDfn, indexDfn, - &nodeDfn, &nodeType, &node, type, array, created) ); - nlassert (node); - - // Set the atom value - CFormElmAtom *atom = safe_cast (node); - atom->setValue (_Value[index].c_str ()); - modified = true; - - if (firstTime) - update (created, UpdateLabels, doc, _FormName.c_str ()); - else - update (created, UpdateValues, doc, _FormName.c_str ()); - } - else - { - if (FormTypeValue == _Type) - { - // Get the node - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - bool parentVDnfArray; - CForm *form=doc.getFormPtr (); - CFormElm *elm = doc.getRootNode (_Slot); - nlverify ( elm->getNodeByName (_FormName.c_str (), &parentDfn, indexDfn, - &nodeDfn, &nodeType, &node, type, array, parentVDnfArray, true, NLGEORGES_FIRST_ROUND) ); - nlassert (node); - CFormElmAtom *atom = safe_cast (node); - atom->setValue (""); - } - else - { - // Remove the node - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - CForm *form=doc.getFormPtr (); - CFormElm *elm = doc.getRootNode (_Slot); - nlverify ( elm->deleteNodeByName (_FormName.c_str (), &parentDfn, indexDfn, - &nodeDfn, &nodeType, &node, type, array) ); - nlassert ((FormTypeValue == _Type)||(node == NULL)); - } - - modified = true; - - update (true, UpdateValues, doc, _FormName.c_str ()); - } - } - break; - case HeaderVersion: - { - uint v0, v1; - if (sscanf (_Value[index].c_str (), "Version %d.%d", &v0, &v1)==2) - { - CFileHeader *header = doc.getHeaderPtr (); - header->MajorVersion = v0; - header->MinorVersion = v1; - modified = true; - update (false, Redraw, doc, _FormName.c_str ()); - } - } - break; - case HeaderState: - { - CFileHeader *header = doc.getHeaderPtr (); - header->State = (CFileHeader::TState)atoi (_Value[index].c_str ()); - modified = true; - update (false, Redraw, doc, _FormName.c_str ()); - } - break; - case HeaderComments: - { - doc.getHeaderPtr ()->Comments = _Value[index]; - modified = true; - if (!firstTime) - update (false, Redraw, doc, _FormName.c_str ()); - } - break; - case FormArrayRename: - { - int idInParent = atoi (_UserData.c_str ()); - - // Get the parent node - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - bool vdfnArray; - CForm *form=doc.getFormPtr (); - CFormElm *elm = doc.getRootNode (_Slot); - nlverify ( elm->getNodeByName (_FormName.c_str (), &parentDfn, indexDfn, - &nodeDfn, &nodeType, &node, type, array, vdfnArray, true, NLGEORGES_FIRST_ROUND) ); - if (node) - { - CFormElmArray* array = safe_cast (node->getParent ()); - array->Elements[idInParent].Name = _Value[index]; - modified = true; - update (true, DoNothing, doc, _FormName.c_str ()); - } - } - break; - case FormArrayInsert: - { - int idInParent = atoi (_NewValue.c_str ()); - - // Insert ? - if (redo) - { - // Get the parent node - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *parentNode; - UFormDfn::TEntryType type; - bool array; - CForm *form=doc.getFormPtr (); - CFormElm *elm = doc.getRootNode (_Slot); - nlverify ( elm->arrayInsertNodeByName (_FormName.c_str (), &parentDfn, indexDfn, - &nodeDfn, &nodeType, &parentNode, type, array, true, idInParent) ); - modified = true; - } - else - { - // Get the parent node - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *parentNode; - UFormDfn::TEntryType type; - bool array; - CForm *form=doc.getFormPtr (); - CFormElm *elm = doc.getRootNode (_Slot); - nlverify ( elm->arrayDeleteNodeByName (_FormName.c_str (), &parentDfn, indexDfn, - &nodeDfn, &nodeType, &parentNode, type, array, true, idInParent) ); - modified = true; - } - - update (true, Redraw, doc, _FormName.c_str ()); - } - break; - default: - nlstop; - } - - return ok; -} - -// *************************************************************************** - -CActionStringVector::CActionStringVector (IAction::TTypeAction type, const std::vector &stringVector, CGeorgesEditDoc &doc, const char *formName, uint selId, uint slot) : IAction (type, selId, slot) -{ - // Set the new value - _FormName = formName; - _NewValue = stringVector; - - // Backup old value - switch (_Type) - { - case DfnParents: - { - // Dfn - const NLGEORGES::CFormDfn &dfn = *(doc.getDfnPtr ()); - - // Add the parents - _OldValue.resize (dfn.getNumParent ()); - uint parent; - for (parent=0; parentgetNodeByName (formName, &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true) ); - - // Get the atom - _OldValue.clear (); - if (node) - { - // Get the atom - CFormElmArray *arrayPtr = safe_cast(node); - - uint size; - nlverify (arrayPtr->getArraySize (size)); - _OldValue.resize (size); - uint elm; - for (elm=0; elm<_OldValue.size (); elm++) - { - if (arrayPtr->Elements[elm]) - { - CFormElmAtom *atom = safe_cast(arrayPtr->Elements[elm]); - atom->getValue (_OldValue[elm], false); - } - } - } - if (_Type == FormArrayReplace) - setLabel ("Form Array Replace", doc); - else - setLabel ("Form Array Append", doc); - } - break;*/ - default: - nlstop; - } -} - -// *************************************************************************** - -bool CActionStringVector::doAction (CGeorgesEditDoc &doc, bool redo, bool &modified, bool firstTime) -{ - IAction::doAction (doc, redo, modified, firstTime); - - modified = false; - bool ok = true; - uint index = (uint)redo; - switch (_Type) - { - case DfnParents: - { - // Get document pointer - CFormDfn *dfn = doc.getDfnPtr (); - nlassert (dfn); - - // Add the parents - dfn->setNumParent (_Value[index].size ()); - - uint parent; - for (parent=0; parent<_Value[index].size (); parent++) - { - try - { - // Set the parent - dfn->setParent (parent, doc.FormLoader, _Value[index][parent].c_str ()); - - modified = true; - } - catch (Exception &e) - { - ok = false; - char message[512]; - smprintf (message, 512, "Error while loading Dfn file (%s): %s", _Value[index][parent].c_str (), e.what()); - theApp.outputError (message); - - // Next parent - parent--; - } - } - modified = true; - if (!firstTime) - update (false, Redraw, doc, ""); - } - break; - case FormParents: - { - // Get the form - NLGEORGES::CForm &form = *(doc.getFormPtr ()); - - // Remove parent - form.clearParents (); - - // Get the result value - uint count = _Value[index].size (); - uint value; - for (value = 0; value parentForm = (CForm*)doc.FormLoader.loadForm (_Value[index][value].c_str ()); - if (parentForm) - { - if ((&form) != parentForm) - { - // Check it is the same dfn - if (parentForm->Elements.FormDfn == form.Elements.FormDfn) - { - // This is the parent form selector - if (form.insertParent (value, _Value[index][value].c_str(), parentForm)) - { - } - else - { - ok = false; - char msg[512]; - smprintf (msg, 512, "Internal error while assign the form (%s) as parent.", _Value[index][value].c_str()); - theApp.outputError (msg); - } - } - else - { - ok = false; - char msg[512]; - smprintf (msg, 512, "The parent form (%s) doesn't use the same DFN than the current form.", _Value[index][value].c_str()); - theApp.outputError (msg); - } - } - else - { - ok = false; - char msg[512]; - smprintf (msg, 512, "Can't assign a form it self as parent."); - theApp.outputError (msg); - } - } - else - { - ok = false; - char msg[512]; - smprintf (msg, 512, "Can't read the form %s.", _Value[index][value].c_str()); - theApp.outputError (msg); - } - } - } - modified = true; - update (true, Redraw, doc, _FormName.c_str ()); - } - break; - /*case FormArrayReplace: - case FormArrayAppend: - { - // Get the node - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - bool parentVDfnArray; - CForm *form=doc.getFormPtr (); - CFormElm *elm = doc.getRootNode (slot); - nlverify ( elm->getNodeByName (_FormName.c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true) ); - - // Is a type entry ? - if ((type == UFormDfn::EntryType) && array) - { - // Create the array - bool created; - nlverify ( elm->createNodeByName (_FormName.c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, created) ); - nlassert (node); - - // Get the atom - CFormElmArray *arrayPtr = safe_cast(node); - - // Replace ? - if (_Type == FormArrayReplace) - { - arrayPtr->clean (); - } - - // For each element - uint arraySize = arrayPtr->Elements.size(); - for (uint i=0; i<_Value[index].size (); i++) - { - // Name - char name[512]; - smprintf (name, 512, "[%d]", i+arraySize); - - // Create the atom node - nlverify ( arrayPtr->createNodeByName (name, &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, created) ); - nlassert (node); - - // Get the atom - CFormElmAtom *atom = safe_cast(node); - - // Set the value - atom->setValue (_Value[index][i].c_str()); - } - - modified = true; - update (true, Redraw, doc, _FormName.c_str ()); - } - } - break;*/ - } - - return ok; -} - -// *************************************************************************** - -CActionStringVectorVector::CActionStringVectorVector (IAction::TTypeAction type, const std::vector > &stringVector, - CGeorgesEditDoc &doc, uint selId, uint slot) : IAction (type, selId, slot) -{ - // Set the new value - _NewValue = stringVector; - - // Backup old value - switch (_Type) - { - case DfnStructure: - { - // Dfn - const NLGEORGES::CFormDfn &dfn = *(doc.getDfnPtr ()); - - // Add the struct element - _OldValue.resize (dfn.getNumEntry ()); - uint elm; - for (elm=0; elm<_OldValue.size (); elm++) - { - // Resize the entry - _OldValue[elm].resize (5); - - // Add the label and value - _OldValue[elm][0] = dfn.getEntry (elm).getName (); - switch (elm, dfn.getEntry (elm).getType ()) - { - case UFormDfn::EntryType: - _OldValue[elm][1] = dfn.getEntry (elm).getArrayFlag () ? "Type array" : "Type"; - _OldValue[elm][4] = dfn.getEntry (elm).getFilenameExt (); - break; - case UFormDfn::EntryDfn: - _OldValue[elm][1] = dfn.getEntry (elm).getArrayFlag () ? "Dfn array" : "Dfn"; - break; - case UFormDfn::EntryVirtualDfn: - _OldValue[elm][1] = "Virtual Dfn"; - break; - } - _OldValue[elm][2] = dfn.getEntry (elm).getFilename (); - _OldValue[elm][3] = dfn.getEntry (elm).getDefault (); - } - setLabel ("Dfn Structure", doc); - } - break; - case TypePredef: - { - // Type - const NLGEORGES::CType &type = *(doc.getTypePtr ()); - - uint predef; - _OldValue.resize (type.Definitions.size()); - for (predef=0; predef<_OldValue.size(); predef++) - { - // Add the label and value - _OldValue[predef].resize (2); - _OldValue[predef][0] = type.Definitions[predef].Label; - _OldValue[predef][1] = type.Definitions[predef].Value; - } - setLabel ("Type Predef", doc); - } - break; - } -} - -// *************************************************************************** - -bool CActionStringVectorVector::doAction (CGeorgesEditDoc &doc, bool redo, bool &modified, bool firstTime) -{ - IAction::doAction (doc, redo, modified, firstTime); - - modified = false; - bool ok = true; - uint index = (uint)redo; - - // Backup old value - switch (_Type) - { - case DfnStructure: - { - // Dfn - NLGEORGES::CFormDfn &dfn = *(doc.getDfnPtr ()); - - // Add the entries - dfn.setNumEntry (_Value[index].size ()); - uint elm; - for (elm=0; elm<_Value[index].size (); elm++) - { - // Ref on the entry - CFormDfn::CEntry &entry = dfn.getEntry (elm); - - // Get the name - entry.setName (_Value[index][elm][0].c_str ()); - - // Get the filename - string &filename = _Value[index][elm][2]; - - // Get the type - string &type= _Value[index][elm][1]; - if ((type == "Type") || (type == "Type array")) - { - // Set the type - entry.setType (doc.FormLoader, filename.c_str ()); - - // Set the default value - string &def = _Value[index][elm][3]; - entry.setDefault (def.c_str ()); - - // Set the default extension - string &ext = _Value[index][elm][4]; - entry.setFilenameExt (ext.c_str ()); - } - else if ((type == "Dfn") || (type == "Dfn array")) - { - // Set the type - entry.setDfn (doc.FormLoader, filename.c_str ()); - } - else if (type == "Virtual Dfn") - { - // Set the type - entry.setDfnPointer (); - } - entry.setArrayFlag ((type == "Type array") || (type == "Dfn array")); - } - modified = true; - if (!firstTime) - update (false, Redraw, doc, ""); - } - break; - case TypePredef: - { - // Type - CType &type = *(doc.getTypePtr ()); - - // Add the predef - type.Definitions.resize (_Value[index].size ()); - uint predef; - for (predef=0; predefarrayDeleteNodeByName (_FormName.c_str (), &parentDfn, indexDfn, - &nodeDfn, &nodeType, &parentNode, type, array, true, atoi (_UserData.c_str ())) ); - modified = true; - } - else - { - // Insert a node - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *parentNode; - UFormDfn::TEntryType type; - bool array; - CForm *form=doc.getFormPtr (); - CFormElm *elm = doc.getRootNode (_Slot); - nlverify ( elm->arrayInsertNodeByName (_FormName.c_str (), &parentDfn, indexDfn, - &nodeDfn, &nodeType, &parentNode, type, array, true, atoi (_UserData.c_str ())) ); - - // Paste the node - - // Fill memstream with the new buffer - theApp.FillMemStreamWithBuffer (&_OldValue[0], _OldValue.size ()); - - // Reserial the document - nlverify (theApp.SerialFromMemStream (_FormName.c_str (), &doc, _Slot)); - modified = true; - } - - update (true, Redraw, doc, _FormName.c_str ()); - } - break; - case FormArraySize: - { - if (redo) - { - // Get the size - int size = 0; - if ( _UserData.empty() || (sscanf (_UserData.c_str(), "%d", &size) == 1) ) - { - if (size < 0) - size = 0; - - // Array exist ? - if (size > 0) - { - // Get / create the node - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - bool created; - CForm *form=doc.getFormPtr (); - CFormElm *elm = doc.getRootNode (_Slot); - nlverify ( elm->createNodeByName (_FormName.c_str (), &parentDfn, indexDfn, - &nodeDfn, &nodeType, &node, type, array, created) ); - nlassert (node); - - // Get the array node - CFormElmArray *arrayPtr = safe_cast (node); - - // Backup old size - uint oldSize = arrayPtr->Elements.size (); - - // Erase old element - uint i; - for (i=size; iElements[i].Element) - delete arrayPtr->Elements[i].Element; - } - - // Resize the array - arrayPtr->Elements.resize (size); - - // Insert element - for (i=oldSize; i<(uint)size; i++) - { - // Create empty sub node - char index[512]; - smprintf (index, 512, "[%d]", i); - nlverify ( arrayPtr->createNodeByName (index, &parentDfn, indexDfn, - &nodeDfn, &nodeType, &node, type, array, created) ); - } - - // Document modified - modified = true; - update (true, UpdateValues, doc, _FormName.c_str ()); - } - else - { - // Remove the node - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - CForm *form=doc.getFormPtr (); - CFormElm *elm = doc.getRootNode (_Slot); - nlverify ( elm->deleteNodeByName (_FormName.c_str (), &parentDfn, indexDfn, - &nodeDfn, &nodeType, &node, type, array) ); - nlassert ( (node == NULL) || (node->getForm () != doc.getFormPtr ()) ); - - // Document modified - modified = true; - update (true, UpdateValues, doc, _FormName.c_str ()); - } - } - } - else - { - // Fill memstream with the new buffer - theApp.FillMemStreamWithBuffer (&_OldValue[0], _OldValue.size ()); - - // Reserial the document - nlverify (theApp.SerialFromMemStream (_FormName.c_str (), &doc, _Slot)); - modified = true; - update (true, UpdateValues, doc, _FormName.c_str ()); - } - } - break; - case FormVirtualDfnName: - { - if (redo) - { - // Result ok ? - if (!_UserData.empty()) - { - // Try to load the DFN - CSmartPtr newDfn = doc.FormLoader.loadFormDfn (_UserData.c_str (), false); - if (newDfn) - { - // Get / create the node - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - bool created; - CForm *form=doc.getFormPtr (); - CFormElm *elm = doc.getRootNode (_Slot); - nlverify ( elm->createNodeByName (_FormName.c_str (), &parentDfn, indexDfn, - &nodeDfn, &nodeType, &node, type, array, created) ); - nlassert (node); - - // Get the atom - CFormElmVirtualStruct *vStruct = safe_cast (node); - - // Assign it - vStruct->DfnFilename = _UserData.c_str (); - - // Build the dfn - vStruct->build (newDfn); - modified = true; - - update (true, Redraw, doc, _FormName.c_str ()); - } - else - { - ok = false; - - // Output error - char msg[512]; - smprintf (msg, 512, "Can't read the dfn %s.", _UserData.c_str()); - theApp.outputError (msg); - update (false, Redraw, doc, _FormName.c_str ()); - } - } - else - { - // Delete the node - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - CForm *form=doc.getFormPtr (); - CFormElm *elm = doc.getRootNode (_Slot); - nlverify ( elm->deleteNodeByName (_FormName.c_str (), &parentDfn, indexDfn, - &nodeDfn, &nodeType, &node, type, array) ); - - // Document is modified by this view - modified = true; - update (true, Redraw, doc, _FormName.c_str ()); - } - } - else - { - // Fill memstream with the new buffer - theApp.FillMemStreamWithBuffer (&_OldValue[0], _OldValue.size ()); - - // Reserial the document - nlverify (theApp.SerialFromMemStream (_FormName.c_str (), &doc, _Slot)); - modified = true; - update (true, Redraw, doc, _FormName.c_str ()); - } - } - break; - default: - nlstop; - } - - return ok; -} - -// *************************************************************************** - - +// 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 "stdafx.h" +#include "georges_edit.h" +#include "georges_edit_doc.h" +#include "georges_edit_view.h" +#include "left_view.h" + +#include "nel/georges/type.h" +#include "nel/georges/form_dfn.h" +#include "nel/georges/form_elm.h" + +#include "action.h" + +using namespace std; +using namespace NLMISC; +using namespace NLGEORGES; + +#define _OldValue (_Value[0]) +#define _NewValue (_Value[1]) + +// *************************************************************************** + +IAction::IAction (TTypeAction type, uint selId, uint slot) +{ + _Type = type; + _SelId = selId; + _Slot = slot; +} + +// *************************************************************************** + +void IAction::setLabel (const char *logLabel, CGeorgesEditDoc &doc) +{ + _LogLabel = logLabel; + + // New log present + _LogPresent[1] = true; + + // Find log.. + std::map::iterator ite = doc._LastLogs.find (logLabel); + if (ite != doc._LastLogs.end ()) + { + _LogPresent[0] = true; + _Log[0] = logLabel; + } + else + { + _LogPresent[0] = false; + } +} + +// *************************************************************************** + +bool IAction::doAction (CGeorgesEditDoc &doc, bool redo, bool &modified, bool firstTime) +{ + uint index = (uint)redo; + doc.logValueChange (_LogLabel.c_str (), _Log[index].c_str (), _LogPresent[index]); + return true; +} + +// *************************************************************************** + +void IAction::update (bool updateLeftView, TUpdateRightView rightViewFlag, CGeorgesEditDoc &doc, const char *_FormName) +{ + // Right and left view + CGeorgesEditView *rightView = doc.getRightView (); + nlassert (rightView); + CLeftView *leftView = doc.getLeftView (); + nlassert (leftView); + + // Update left view ? + if (updateLeftView) + doc.updateDocumentStructure (); + + // Set the current view.. + uint subSelection = leftView->getCurrentSelectionId (); + if (subSelection != _SelId) + { + doc.changeSubSelection (_SelId, NULL); + return; + } + + if (leftView->getCurrentSelectionId () == 1) + { + rightView->HeaderDialog.getFromDocument (*doc.getHeaderPtr ()); + } + else if (doc.isType ()) + { + rightView->TypeDialog.getFromDocument (*(doc.getTypePtr())); + } + else if (doc.isDfn ()) + { + rightView->DfnDialog.getFromDocument (*(doc.getDfnPtr())); + } + else if (doc.isForm ()) + { + if (rightViewFlag == DoNothing) + { + } + else if (rightViewFlag == UpdateLabels) + { + rightView->FormDialog.updateLabels (); + } + else if (rightViewFlag == UpdateValues) + { + rightView->FormDialog.updateValues (); + } + else if (rightViewFlag == Redraw) + { + rightView->FormDialog.getFromDocument (); + } + } +} + +// *************************************************************************** + +CActionString::CActionString (IAction::TTypeAction type, const char *newValue, CGeorgesEditDoc &doc, const char *formName, const char *userData, uint selId, uint slot) : IAction (type, selId, slot) +{ + // Set the new value + _NewValue = newValue; + _FormName = formName; + _Log[1] = newValue; + _UserData = userData; + + // Backup old value + switch (_Type) + { + case TypeType: + { + CType *type = doc.getTypePtr (); + _OldValue = toString ((int)(type->Type)); + setLabel ("Type Type", doc); + _Log[1] = type->getTypeName ((UType::TType)atoi (newValue)); + } + break; + case TypeUI: + { + CType *type = doc.getTypePtr (); + _OldValue = toString ((int)(type->UIType)); + setLabel ("Type UI", doc); + _Log[1] = type->getUIName ((CType::TUI)atoi (newValue)); + } + break; + case TypeDefault: + { + CType *type = doc.getTypePtr (); + _OldValue = type->Default; + setLabel ("Type Default", doc); + } + break; + case TypeMin: + { + CType *type = doc.getTypePtr (); + _OldValue = type->Min; + setLabel ("Type Min", doc); + } + break; + case TypeMax: + { + CType *type = doc.getTypePtr (); + _OldValue = type->Max; + setLabel ("Type Max", doc); + } + break; + case TypeIncrement: + { + CType *type = doc.getTypePtr (); + _OldValue = type->Increment; + setLabel ("Type Increment", doc); + } + break; + case FormTypeValue: + case FormValue: + { + // Form + const NLGEORGES::CForm &form = *(doc.getFormPtr ()); + nlverify (doc.getRootNode (_Slot)->getValueByName (_OldValue, formName, UFormElm::NoEval, NULL)); + setLabel (formName, doc); + } + break; + case HeaderVersion: + { + CFileHeader *header = doc.getHeaderPtr (); + char versionText[512]; + smprintf (versionText, 512, "Version %d.%d", header->MajorVersion, header->MinorVersion); + _OldValue = versionText; + setLabel ("Header Version", doc); + } + break; + case HeaderState: + { + CFileHeader *header = doc.getHeaderPtr (); + _OldValue = toString ((int)(header->State)).c_str (); + setLabel ("Header State", doc); + } + break; + case HeaderComments: + { + _OldValue = doc.getHeaderPtr ()->Comments; + setLabel ("Header Comments", doc); + } + break; + case FormArrayRename: + { + setLabel ((formName+string (" Renamed")).c_str (), doc); + int idInParent = atoi (_UserData.c_str ()); + + // Get the parent node + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + bool vdfnArray; + CForm *form=doc.getFormPtr (); + CFormElm *elm = doc.getRootNode (slot); + nlverify ( elm->getNodeByName (_FormName.c_str (), &parentDfn, indexDfn, + &nodeDfn, &nodeType, &node, type, array, vdfnArray, true, NLGEORGES_FIRST_ROUND) ); + if (node) + { + CFormElmArray* array = safe_cast (node->getParent ()); + _OldValue = array->Elements[idInParent].Name; + } + } + break; + case FormArrayInsert: + { + // do nothing + setLabel ("Array Insert", doc); + } + break; + default: + nlstop; + } +} + +// *************************************************************************** + +bool CActionString::doAction (CGeorgesEditDoc &doc, bool redo, bool &modified, bool firstTime) +{ + IAction::doAction (doc, redo, modified, firstTime); + + modified = false; + bool ok = true; + uint index = (uint)redo; + switch (_Type) + { + case TypeType: + { + CType *type = doc.getTypePtr (); + type->Type = (CType::TType)(atoi (_Value[index].c_str ())); + modified = true; + update (false, Redraw, doc, _FormName.c_str ()); + } + break; + case TypeUI: + { + CType *type = doc.getTypePtr (); + type->UIType = (CType::TUI)(atoi (_Value[index].c_str ())); + modified = true; + update (false, Redraw, doc, _FormName.c_str ()); + } + break; + case TypeDefault: + { + CType *type = doc.getTypePtr (); + type->Default = _Value[index]; + modified = true; + if (!firstTime) + update (false, Redraw, doc, _FormName.c_str ()); + } + break; + case TypeMin: + { + CType *type = doc.getTypePtr (); + type->Min = _Value[index]; + modified = true; + if (!firstTime) + update (false, Redraw, doc, _FormName.c_str ()); + } + break; + case TypeMax: + { + CType *type = doc.getTypePtr (); + type->Max = _Value[index]; + modified = true; + if (!firstTime) + update (false, Redraw, doc, _FormName.c_str ()); + } + break; + case TypeIncrement: + { + CType *type = doc.getTypePtr (); + type->Increment = _Value[index]; + modified = true; + if (!firstTime) + update (false, Redraw, doc, _FormName.c_str ()); + } + break; + case FormTypeValue: + case FormValue: + { + // Empty ? + if (!_Value[index].empty ()) + { + // Get / create the node + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + bool created; + CForm *form=doc.getFormPtr (); + CFormElm *elm = doc.getRootNode (_Slot); + nlverify ( elm->createNodeByName (_FormName.c_str (), &parentDfn, indexDfn, + &nodeDfn, &nodeType, &node, type, array, created) ); + nlassert (node); + + // Set the atom value + CFormElmAtom *atom = safe_cast (node); + atom->setValue (_Value[index].c_str ()); + modified = true; + + if (firstTime) + update (created, UpdateLabels, doc, _FormName.c_str ()); + else + update (created, UpdateValues, doc, _FormName.c_str ()); + } + else + { + if (FormTypeValue == _Type) + { + // Get the node + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + bool parentVDnfArray; + CForm *form=doc.getFormPtr (); + CFormElm *elm = doc.getRootNode (_Slot); + nlverify ( elm->getNodeByName (_FormName.c_str (), &parentDfn, indexDfn, + &nodeDfn, &nodeType, &node, type, array, parentVDnfArray, true, NLGEORGES_FIRST_ROUND) ); + nlassert (node); + CFormElmAtom *atom = safe_cast (node); + atom->setValue (""); + } + else + { + // Remove the node + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + CForm *form=doc.getFormPtr (); + CFormElm *elm = doc.getRootNode (_Slot); + nlverify ( elm->deleteNodeByName (_FormName.c_str (), &parentDfn, indexDfn, + &nodeDfn, &nodeType, &node, type, array) ); + nlassert ((FormTypeValue == _Type)||(node == NULL)); + } + + modified = true; + + update (true, UpdateValues, doc, _FormName.c_str ()); + } + } + break; + case HeaderVersion: + { + uint v0, v1; + if (sscanf (_Value[index].c_str (), "Version %d.%d", &v0, &v1)==2) + { + CFileHeader *header = doc.getHeaderPtr (); + header->MajorVersion = v0; + header->MinorVersion = v1; + modified = true; + update (false, Redraw, doc, _FormName.c_str ()); + } + } + break; + case HeaderState: + { + CFileHeader *header = doc.getHeaderPtr (); + header->State = (CFileHeader::TState)atoi (_Value[index].c_str ()); + modified = true; + update (false, Redraw, doc, _FormName.c_str ()); + } + break; + case HeaderComments: + { + doc.getHeaderPtr ()->Comments = _Value[index]; + modified = true; + if (!firstTime) + update (false, Redraw, doc, _FormName.c_str ()); + } + break; + case FormArrayRename: + { + int idInParent = atoi (_UserData.c_str ()); + + // Get the parent node + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + bool vdfnArray; + CForm *form=doc.getFormPtr (); + CFormElm *elm = doc.getRootNode (_Slot); + nlverify ( elm->getNodeByName (_FormName.c_str (), &parentDfn, indexDfn, + &nodeDfn, &nodeType, &node, type, array, vdfnArray, true, NLGEORGES_FIRST_ROUND) ); + if (node) + { + CFormElmArray* array = safe_cast (node->getParent ()); + array->Elements[idInParent].Name = _Value[index]; + modified = true; + update (true, DoNothing, doc, _FormName.c_str ()); + } + } + break; + case FormArrayInsert: + { + int idInParent = atoi (_NewValue.c_str ()); + + // Insert ? + if (redo) + { + // Get the parent node + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *parentNode; + UFormDfn::TEntryType type; + bool array; + CForm *form=doc.getFormPtr (); + CFormElm *elm = doc.getRootNode (_Slot); + nlverify ( elm->arrayInsertNodeByName (_FormName.c_str (), &parentDfn, indexDfn, + &nodeDfn, &nodeType, &parentNode, type, array, true, idInParent) ); + modified = true; + } + else + { + // Get the parent node + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *parentNode; + UFormDfn::TEntryType type; + bool array; + CForm *form=doc.getFormPtr (); + CFormElm *elm = doc.getRootNode (_Slot); + nlverify ( elm->arrayDeleteNodeByName (_FormName.c_str (), &parentDfn, indexDfn, + &nodeDfn, &nodeType, &parentNode, type, array, true, idInParent) ); + modified = true; + } + + update (true, Redraw, doc, _FormName.c_str ()); + } + break; + default: + nlstop; + } + + return ok; +} + +// *************************************************************************** + +CActionStringVector::CActionStringVector (IAction::TTypeAction type, const std::vector &stringVector, CGeorgesEditDoc &doc, const char *formName, uint selId, uint slot) : IAction (type, selId, slot) +{ + // Set the new value + _FormName = formName; + _NewValue = stringVector; + + // Backup old value + switch (_Type) + { + case DfnParents: + { + // Dfn + const NLGEORGES::CFormDfn &dfn = *(doc.getDfnPtr ()); + + // Add the parents + _OldValue.resize (dfn.getNumParent ()); + uint parent; + for (parent=0; parentgetNodeByName (formName, &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true) ); + + // Get the atom + _OldValue.clear (); + if (node) + { + // Get the atom + CFormElmArray *arrayPtr = safe_cast(node); + + uint size; + nlverify (arrayPtr->getArraySize (size)); + _OldValue.resize (size); + uint elm; + for (elm=0; elm<_OldValue.size (); elm++) + { + if (arrayPtr->Elements[elm]) + { + CFormElmAtom *atom = safe_cast(arrayPtr->Elements[elm]); + atom->getValue (_OldValue[elm], false); + } + } + } + if (_Type == FormArrayReplace) + setLabel ("Form Array Replace", doc); + else + setLabel ("Form Array Append", doc); + } + break;*/ + default: + nlstop; + } +} + +// *************************************************************************** + +bool CActionStringVector::doAction (CGeorgesEditDoc &doc, bool redo, bool &modified, bool firstTime) +{ + IAction::doAction (doc, redo, modified, firstTime); + + modified = false; + bool ok = true; + uint index = (uint)redo; + switch (_Type) + { + case DfnParents: + { + // Get document pointer + CFormDfn *dfn = doc.getDfnPtr (); + nlassert (dfn); + + // Add the parents + dfn->setNumParent (_Value[index].size ()); + + uint parent; + for (parent=0; parent<_Value[index].size (); parent++) + { + try + { + // Set the parent + dfn->setParent (parent, doc.FormLoader, _Value[index][parent].c_str ()); + + modified = true; + } + catch (Exception &e) + { + ok = false; + char message[512]; + smprintf (message, 512, "Error while loading Dfn file (%s): %s", _Value[index][parent].c_str (), e.what()); + theApp.outputError (message); + + // Next parent + parent--; + } + } + modified = true; + if (!firstTime) + update (false, Redraw, doc, ""); + } + break; + case FormParents: + { + // Get the form + NLGEORGES::CForm &form = *(doc.getFormPtr ()); + + // Remove parent + form.clearParents (); + + // Get the result value + uint count = _Value[index].size (); + uint value; + for (value = 0; value parentForm = (CForm*)doc.FormLoader.loadForm (_Value[index][value].c_str ()); + if (parentForm) + { + if ((&form) != parentForm) + { + // Check it is the same dfn + if (parentForm->Elements.FormDfn == form.Elements.FormDfn) + { + // This is the parent form selector + if (form.insertParent (value, _Value[index][value].c_str(), parentForm)) + { + } + else + { + ok = false; + char msg[512]; + smprintf (msg, 512, "Internal error while assign the form (%s) as parent.", _Value[index][value].c_str()); + theApp.outputError (msg); + } + } + else + { + ok = false; + char msg[512]; + smprintf (msg, 512, "The parent form (%s) doesn't use the same DFN than the current form.", _Value[index][value].c_str()); + theApp.outputError (msg); + } + } + else + { + ok = false; + char msg[512]; + smprintf (msg, 512, "Can't assign a form it self as parent."); + theApp.outputError (msg); + } + } + else + { + ok = false; + char msg[512]; + smprintf (msg, 512, "Can't read the form %s.", _Value[index][value].c_str()); + theApp.outputError (msg); + } + } + } + modified = true; + update (true, Redraw, doc, _FormName.c_str ()); + } + break; + /*case FormArrayReplace: + case FormArrayAppend: + { + // Get the node + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + bool parentVDfnArray; + CForm *form=doc.getFormPtr (); + CFormElm *elm = doc.getRootNode (slot); + nlverify ( elm->getNodeByName (_FormName.c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true) ); + + // Is a type entry ? + if ((type == UFormDfn::EntryType) && array) + { + // Create the array + bool created; + nlverify ( elm->createNodeByName (_FormName.c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, created) ); + nlassert (node); + + // Get the atom + CFormElmArray *arrayPtr = safe_cast(node); + + // Replace ? + if (_Type == FormArrayReplace) + { + arrayPtr->clean (); + } + + // For each element + uint arraySize = arrayPtr->Elements.size(); + for (uint i=0; i<_Value[index].size (); i++) + { + // Name + char name[512]; + smprintf (name, 512, "[%d]", i+arraySize); + + // Create the atom node + nlverify ( arrayPtr->createNodeByName (name, &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, created) ); + nlassert (node); + + // Get the atom + CFormElmAtom *atom = safe_cast(node); + + // Set the value + atom->setValue (_Value[index][i].c_str()); + } + + modified = true; + update (true, Redraw, doc, _FormName.c_str ()); + } + } + break;*/ + } + + return ok; +} + +// *************************************************************************** + +CActionStringVectorVector::CActionStringVectorVector (IAction::TTypeAction type, const std::vector > &stringVector, + CGeorgesEditDoc &doc, uint selId, uint slot) : IAction (type, selId, slot) +{ + // Set the new value + _NewValue = stringVector; + + // Backup old value + switch (_Type) + { + case DfnStructure: + { + // Dfn + const NLGEORGES::CFormDfn &dfn = *(doc.getDfnPtr ()); + + // Add the struct element + _OldValue.resize (dfn.getNumEntry ()); + uint elm; + for (elm=0; elm<_OldValue.size (); elm++) + { + // Resize the entry + _OldValue[elm].resize (5); + + // Add the label and value + _OldValue[elm][0] = dfn.getEntry (elm).getName (); + switch (elm, dfn.getEntry (elm).getType ()) + { + case UFormDfn::EntryType: + _OldValue[elm][1] = dfn.getEntry (elm).getArrayFlag () ? "Type array" : "Type"; + _OldValue[elm][4] = dfn.getEntry (elm).getFilenameExt (); + break; + case UFormDfn::EntryDfn: + _OldValue[elm][1] = dfn.getEntry (elm).getArrayFlag () ? "Dfn array" : "Dfn"; + break; + case UFormDfn::EntryVirtualDfn: + _OldValue[elm][1] = "Virtual Dfn"; + break; + } + _OldValue[elm][2] = dfn.getEntry (elm).getFilename (); + _OldValue[elm][3] = dfn.getEntry (elm).getDefault (); + } + setLabel ("Dfn Structure", doc); + } + break; + case TypePredef: + { + // Type + const NLGEORGES::CType &type = *(doc.getTypePtr ()); + + uint predef; + _OldValue.resize (type.Definitions.size()); + for (predef=0; predef<_OldValue.size(); predef++) + { + // Add the label and value + _OldValue[predef].resize (2); + _OldValue[predef][0] = type.Definitions[predef].Label; + _OldValue[predef][1] = type.Definitions[predef].Value; + } + setLabel ("Type Predef", doc); + } + break; + } +} + +// *************************************************************************** + +bool CActionStringVectorVector::doAction (CGeorgesEditDoc &doc, bool redo, bool &modified, bool firstTime) +{ + IAction::doAction (doc, redo, modified, firstTime); + + modified = false; + bool ok = true; + uint index = (uint)redo; + + // Backup old value + switch (_Type) + { + case DfnStructure: + { + // Dfn + NLGEORGES::CFormDfn &dfn = *(doc.getDfnPtr ()); + + // Add the entries + dfn.setNumEntry (_Value[index].size ()); + uint elm; + for (elm=0; elm<_Value[index].size (); elm++) + { + // Ref on the entry + CFormDfn::CEntry &entry = dfn.getEntry (elm); + + // Get the name + entry.setName (_Value[index][elm][0].c_str ()); + + // Get the filename + string &filename = _Value[index][elm][2]; + + // Get the type + string &type= _Value[index][elm][1]; + if ((type == "Type") || (type == "Type array")) + { + // Set the type + entry.setType (doc.FormLoader, filename.c_str ()); + + // Set the default value + string &def = _Value[index][elm][3]; + entry.setDefault (def.c_str ()); + + // Set the default extension + string &ext = _Value[index][elm][4]; + entry.setFilenameExt (ext.c_str ()); + } + else if ((type == "Dfn") || (type == "Dfn array")) + { + // Set the type + entry.setDfn (doc.FormLoader, filename.c_str ()); + } + else if (type == "Virtual Dfn") + { + // Set the type + entry.setDfnPointer (); + } + entry.setArrayFlag ((type == "Type array") || (type == "Dfn array")); + } + modified = true; + if (!firstTime) + update (false, Redraw, doc, ""); + } + break; + case TypePredef: + { + // Type + CType &type = *(doc.getTypePtr ()); + + // Add the predef + type.Definitions.resize (_Value[index].size ()); + uint predef; + for (predef=0; predefarrayDeleteNodeByName (_FormName.c_str (), &parentDfn, indexDfn, + &nodeDfn, &nodeType, &parentNode, type, array, true, atoi (_UserData.c_str ())) ); + modified = true; + } + else + { + // Insert a node + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *parentNode; + UFormDfn::TEntryType type; + bool array; + CForm *form=doc.getFormPtr (); + CFormElm *elm = doc.getRootNode (_Slot); + nlverify ( elm->arrayInsertNodeByName (_FormName.c_str (), &parentDfn, indexDfn, + &nodeDfn, &nodeType, &parentNode, type, array, true, atoi (_UserData.c_str ())) ); + + // Paste the node + + // Fill memstream with the new buffer + theApp.FillMemStreamWithBuffer (&_OldValue[0], _OldValue.size ()); + + // Reserial the document + nlverify (theApp.SerialFromMemStream (_FormName.c_str (), &doc, _Slot)); + modified = true; + } + + update (true, Redraw, doc, _FormName.c_str ()); + } + break; + case FormArraySize: + { + if (redo) + { + // Get the size + int size = 0; + if ( _UserData.empty() || (sscanf (_UserData.c_str(), "%d", &size) == 1) ) + { + if (size < 0) + size = 0; + + // Array exist ? + if (size > 0) + { + // Get / create the node + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + bool created; + CForm *form=doc.getFormPtr (); + CFormElm *elm = doc.getRootNode (_Slot); + nlverify ( elm->createNodeByName (_FormName.c_str (), &parentDfn, indexDfn, + &nodeDfn, &nodeType, &node, type, array, created) ); + nlassert (node); + + // Get the array node + CFormElmArray *arrayPtr = safe_cast (node); + + // Backup old size + uint oldSize = arrayPtr->Elements.size (); + + // Erase old element + uint i; + for (i=size; iElements[i].Element) + delete arrayPtr->Elements[i].Element; + } + + // Resize the array + arrayPtr->Elements.resize (size); + + // Insert element + for (i=oldSize; i<(uint)size; i++) + { + // Create empty sub node + char index[512]; + smprintf (index, 512, "[%d]", i); + nlverify ( arrayPtr->createNodeByName (index, &parentDfn, indexDfn, + &nodeDfn, &nodeType, &node, type, array, created) ); + } + + // Document modified + modified = true; + update (true, UpdateValues, doc, _FormName.c_str ()); + } + else + { + // Remove the node + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + CForm *form=doc.getFormPtr (); + CFormElm *elm = doc.getRootNode (_Slot); + nlverify ( elm->deleteNodeByName (_FormName.c_str (), &parentDfn, indexDfn, + &nodeDfn, &nodeType, &node, type, array) ); + nlassert ( (node == NULL) || (node->getForm () != doc.getFormPtr ()) ); + + // Document modified + modified = true; + update (true, UpdateValues, doc, _FormName.c_str ()); + } + } + } + else + { + // Fill memstream with the new buffer + theApp.FillMemStreamWithBuffer (&_OldValue[0], _OldValue.size ()); + + // Reserial the document + nlverify (theApp.SerialFromMemStream (_FormName.c_str (), &doc, _Slot)); + modified = true; + update (true, UpdateValues, doc, _FormName.c_str ()); + } + } + break; + case FormVirtualDfnName: + { + if (redo) + { + // Result ok ? + if (!_UserData.empty()) + { + // Try to load the DFN + CSmartPtr newDfn = doc.FormLoader.loadFormDfn (_UserData.c_str (), false); + if (newDfn) + { + // Get / create the node + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + bool created; + CForm *form=doc.getFormPtr (); + CFormElm *elm = doc.getRootNode (_Slot); + nlverify ( elm->createNodeByName (_FormName.c_str (), &parentDfn, indexDfn, + &nodeDfn, &nodeType, &node, type, array, created) ); + nlassert (node); + + // Get the atom + CFormElmVirtualStruct *vStruct = safe_cast (node); + + // Assign it + vStruct->DfnFilename = _UserData.c_str (); + + // Build the dfn + vStruct->build (newDfn); + modified = true; + + update (true, Redraw, doc, _FormName.c_str ()); + } + else + { + ok = false; + + // Output error + char msg[512]; + smprintf (msg, 512, "Can't read the dfn %s.", _UserData.c_str()); + theApp.outputError (msg); + update (false, Redraw, doc, _FormName.c_str ()); + } + } + else + { + // Delete the node + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + CForm *form=doc.getFormPtr (); + CFormElm *elm = doc.getRootNode (_Slot); + nlverify ( elm->deleteNodeByName (_FormName.c_str (), &parentDfn, indexDfn, + &nodeDfn, &nodeType, &node, type, array) ); + + // Document is modified by this view + modified = true; + update (true, Redraw, doc, _FormName.c_str ()); + } + } + else + { + // Fill memstream with the new buffer + theApp.FillMemStreamWithBuffer (&_OldValue[0], _OldValue.size ()); + + // Reserial the document + nlverify (theApp.SerialFromMemStream (_FormName.c_str (), &doc, _Slot)); + modified = true; + update (true, Redraw, doc, _FormName.c_str ()); + } + } + break; + default: + nlstop; + } + + return ok; +} + +// *************************************************************************** + + diff --git a/code/ryzom/tools/leveldesign/georges_dll/action.h b/code/ryzom/tools/leveldesign/georges_dll/action.h index 0525cca96..317f81e1a 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/action.h +++ b/code/ryzom/tools/leveldesign/georges_dll/action.h @@ -1,185 +1,185 @@ -// 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 GEORGES_EDIT_ACTION_H -#define GEORGES_EDIT_ACTION_H - -#include "nel/misc/types_nl.h" - -// Document modification action -class IAction -{ - friend class CGeorgesEditDoc; -public: - - // Type of modification performed - enum TTypeAction - { - HeaderVersion, - HeaderState, - HeaderComments, - TypeType, - TypeUI, - TypeDefault, - TypeMin, - TypeMax, - TypeIncrement, - TypePredef, - DfnParents, - DfnStructure, - FormParents, - FormArraySize, - FormArrayRename, - /*FormArrayReplace, - FormArrayAppend,*/ - FormArrayInsert, - FormArrayDelete, - FormVirtualDfnName, - FormValue, - FormTypeValue, - FormPaste, - }; - -protected: - - // Constructor - IAction (TTypeAction type, uint selId, uint slot); - - // Init log label - void setLabel (const char *logLabel, CGeorgesEditDoc &doc); - -public: - - // Virtual destructor - virtual ~IAction () {}; - -protected: - - // Action type - TTypeAction _Type; - - // Original value ? - bool _Original; - - // Selection Id of the Undo - uint _SelId; - - // Action slot - uint _Slot; - - // Old and new value - bool _LogPresent[2]; - std::string _Log[2]; - std::string _LogLabel; - - // Do the modification - virtual bool doAction (CGeorgesEditDoc &doc, bool redo, bool &modified, bool firstTime); - - // Update the views - enum TUpdateRightView - { - DoNothing, - UpdateLabels, - UpdateValues, - Redraw - }; - void update (bool updateLeftView, TUpdateRightView rightView, CGeorgesEditDoc &doc, const char *_FormName); -}; - -// String modification action -class CActionString : public IAction -{ -public: - - // Constructor - CActionString (IAction::TTypeAction type, const char *newValue, CGeorgesEditDoc &doc, const char *formName, const char *userData, uint selId, uint slot); - -protected: - - // Old and new value - std::string _Value[2]; - - // The form name - std::string _FormName; - - // The form name - std::string _UserData; - - // Do the modification - virtual bool doAction (CGeorgesEditDoc &doc, bool redo, bool &modified, bool firstTime); -}; - -// Vector string modification action -class CActionStringVector : public IAction -{ -public: - - // Constructor - CActionStringVector (IAction::TTypeAction type, const std::vector &stringVector, CGeorgesEditDoc &doc, const char *formName, uint selId, uint slot); - -protected: - - // Old and new value - std::vector _Value[2]; - - // The form name - std::string _FormName; - - // Do the modification - virtual bool doAction (CGeorgesEditDoc &doc, bool redo, bool &modified, bool firstTime); -}; - -// Vector vector string modification action -class CActionStringVectorVector : public IAction -{ -public: - - // Constructor - CActionStringVectorVector (IAction::TTypeAction type, const std::vector > &stringVectorVector, CGeorgesEditDoc &doc, uint selId, uint slot); - -protected: - - // Old and new value - std::vector > _Value[2]; - - // Do the modification - virtual bool doAction (CGeorgesEditDoc &doc, bool redo, bool &modified, bool firstTime); -}; - -// Vector vector string modification action -class CActionBuffer : public IAction -{ -public: - - // Constructor - CActionBuffer (IAction::TTypeAction type, const uint8 *buffer, uint bufferSize, CGeorgesEditDoc &doc, const char *formName, const char *userData, uint selId, uint slot); - -protected: - - // Old and new value - std::vector _Value[2]; - - // The form name - std::string _FormName; - - // User data - std::string _UserData; - - // Do the modification - virtual bool doAction (CGeorgesEditDoc &doc, bool redo, bool &modified, bool firstTime); -}; - -#endif GEORGES_EDIT_ACTION_H +// 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 GEORGES_EDIT_ACTION_H +#define GEORGES_EDIT_ACTION_H + +#include "nel/misc/types_nl.h" + +// Document modification action +class IAction +{ + friend class CGeorgesEditDoc; +public: + + // Type of modification performed + enum TTypeAction + { + HeaderVersion, + HeaderState, + HeaderComments, + TypeType, + TypeUI, + TypeDefault, + TypeMin, + TypeMax, + TypeIncrement, + TypePredef, + DfnParents, + DfnStructure, + FormParents, + FormArraySize, + FormArrayRename, + /*FormArrayReplace, + FormArrayAppend,*/ + FormArrayInsert, + FormArrayDelete, + FormVirtualDfnName, + FormValue, + FormTypeValue, + FormPaste, + }; + +protected: + + // Constructor + IAction (TTypeAction type, uint selId, uint slot); + + // Init log label + void setLabel (const char *logLabel, CGeorgesEditDoc &doc); + +public: + + // Virtual destructor + virtual ~IAction () {}; + +protected: + + // Action type + TTypeAction _Type; + + // Original value ? + bool _Original; + + // Selection Id of the Undo + uint _SelId; + + // Action slot + uint _Slot; + + // Old and new value + bool _LogPresent[2]; + std::string _Log[2]; + std::string _LogLabel; + + // Do the modification + virtual bool doAction (CGeorgesEditDoc &doc, bool redo, bool &modified, bool firstTime); + + // Update the views + enum TUpdateRightView + { + DoNothing, + UpdateLabels, + UpdateValues, + Redraw + }; + void update (bool updateLeftView, TUpdateRightView rightView, CGeorgesEditDoc &doc, const char *_FormName); +}; + +// String modification action +class CActionString : public IAction +{ +public: + + // Constructor + CActionString (IAction::TTypeAction type, const char *newValue, CGeorgesEditDoc &doc, const char *formName, const char *userData, uint selId, uint slot); + +protected: + + // Old and new value + std::string _Value[2]; + + // The form name + std::string _FormName; + + // The form name + std::string _UserData; + + // Do the modification + virtual bool doAction (CGeorgesEditDoc &doc, bool redo, bool &modified, bool firstTime); +}; + +// Vector string modification action +class CActionStringVector : public IAction +{ +public: + + // Constructor + CActionStringVector (IAction::TTypeAction type, const std::vector &stringVector, CGeorgesEditDoc &doc, const char *formName, uint selId, uint slot); + +protected: + + // Old and new value + std::vector _Value[2]; + + // The form name + std::string _FormName; + + // Do the modification + virtual bool doAction (CGeorgesEditDoc &doc, bool redo, bool &modified, bool firstTime); +}; + +// Vector vector string modification action +class CActionStringVectorVector : public IAction +{ +public: + + // Constructor + CActionStringVectorVector (IAction::TTypeAction type, const std::vector > &stringVectorVector, CGeorgesEditDoc &doc, uint selId, uint slot); + +protected: + + // Old and new value + std::vector > _Value[2]; + + // Do the modification + virtual bool doAction (CGeorgesEditDoc &doc, bool redo, bool &modified, bool firstTime); +}; + +// Vector vector string modification action +class CActionBuffer : public IAction +{ +public: + + // Constructor + CActionBuffer (IAction::TTypeAction type, const uint8 *buffer, uint bufferSize, CGeorgesEditDoc &doc, const char *formName, const char *userData, uint selId, uint slot); + +protected: + + // Old and new value + std::vector _Value[2]; + + // The form name + std::string _FormName; + + // User data + std::string _UserData; + + // Do the modification + virtual bool doAction (CGeorgesEditDoc &doc, bool redo, bool &modified, bool firstTime); +}; + +#endif GEORGES_EDIT_ACTION_H diff --git a/code/ryzom/tools/leveldesign/georges_dll/base_dialog.cpp b/code/ryzom/tools/leveldesign/georges_dll/base_dialog.cpp index 97cafceae..7d1f58e55 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/base_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/base_dialog.cpp @@ -1,303 +1,303 @@ -// 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 . - -// base_dialog.cpp : implementation file -// - -#include "stdafx.h" -#include "georges_edit.h" -#include "georges_edit_doc.h" -#include "georges_edit_view.h" -#include "base_dialog.h" -#include "main_frm.h" - -using namespace std; - -///////////////////////////////////////////////////////////////////////////// -// CBaseDialog dialog - -CBaseDialog::CBaseDialog(int accelResource) - : CDialog(CBaseDialog::IDD) -{ - //{{AFX_DATA_INIT(CBaseDialog) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT - Accelerator = LoadAccelerators ( theApp.m_hInstance, MAKEINTRESOURCE (accelResource) ); -} - - -void CBaseDialog::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CBaseDialog) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CBaseDialog, CDialog) - //{{AFX_MSG_MAP(CBaseDialog) - ON_WM_SIZE() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -BEGIN_MESSAGE_MAP(CDoomyControl, CStatic) - //{{AFX_MSG_MAP(CDoomyControl) - ON_WM_SETFOCUS() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CBaseDialog message handlers - -BOOL CBaseDialog::OnInitDialog() -{ - CDialog::OnInitDialog(); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void CBaseDialog::OnSize(UINT nType, int cx, int cy) -{ - CDialog::OnSize(nType, cx, cy); - -} - -void CBaseDialog::getFirstItemPos (RECT &rect) -{ - rect.left = 0; - rect.top = 0; -} - -void CBaseDialog::setComboSize (RECT &rect, uint width, uint height) -{ - rect.right = rect.left + width; - rect.bottom = rect.top + height; -} - -void CBaseDialog::setComboSpinSize (RECT &rect) -{ - rect.right = rect.left + SmallWidget-SpinWidth; - rect.bottom = rect.top + ComboHeight; -} - -void CBaseDialog::setComboBrowseSize (RECT &rect) -{ - rect.right = rect.left + SmallWidget-BrowseWidth; - rect.bottom = rect.top + ComboHeight; -} - -void CBaseDialog::adjusteComboSize (RECT &rect) -{ - rect.bottom += ComboDropDownHeight; -} - -void CBaseDialog::setStaticSize (RECT &rect) -{ - rect.right = rect.left + SmallWidget; - rect.bottom = rect.top + StaticHeight; -} - -void CBaseDialog::setEditSize (RECT &rect, uint width, uint height) -{ - rect.right = rect.left + width; - rect.bottom = rect.top + height; -} - -void CBaseDialog::setColorSize (RECT &rect, uint width, uint height) -{ - rect.right = rect.left + width - ResetColorWidth; - rect.bottom = rect.top + height; -} - -void CBaseDialog::setBigEditSize (RECT &rect, uint width, uint height) -{ - rect.right = rect.left + width; - rect.bottom = rect.top + height; -} - -void CBaseDialog::getNextPos (RECT &rect) -{ - rect.top = rect.bottom + WidgetSpaceHeight; -} - -void CBaseDialog::getNextPosLabel (RECT &rect) -{ - rect.top = rect.bottom + LabelSpaceHeight; -} - -void CBaseDialog::initWidget (CWnd &wnd) -{ - CFont* font = GetFont (); - wnd.SetFont (font); - wnd.ShowWindow (SW_SHOW); -} - -void CBaseDialog::setListSize (RECT &rect, uint width, uint height) -{ - rect.right = rect.left + width; - rect.bottom = rect.top + height; -} - -void CBaseDialog::setEditSpinSize (RECT &rect, uint width, uint height) -{ - rect.right = rect.left + width; - rect.bottom = rect.top + height; -} - -void CBaseDialog::setSpinSize (RECT &rect, uint width, uint height) -{ - rect.right = rect.left + width; - rect.bottom = rect.top + height; -} - -void CBaseDialog::setBrowseSize (RECT &rect, uint width, uint height) -{ - rect.right = rect.left + width; - rect.bottom = rect.top + height; -} - -void CBaseDialog::setResetColorSize (RECT &rect, uint width, uint height) -{ - rect.right = rect.left + width; - rect.bottom = rect.top + height; -} - -void CBaseDialog::getNextColumn (RECT &rect) -{ - rect.left += SmallWidgetNotLimited + WidgetSpaceWidth; - rect.top = 0; -} - -void CBaseDialog::getFirstColumn (RECT &rect) -{ - rect.left = 0; -} - -void CBaseDialog::getNextSpinPos (RECT &rect) -{ - rect.left = rect.right; -} - -void CBaseDialog::getNextBrowsePos (RECT &rect) -{ - rect.left = rect.right; -} - -void CBaseDialog::getNextColorPos (RECT &rect) -{ - rect.left = rect.right; -} - -void CBaseDialog::setButtonSize (RECT &rect, uint width, uint height) -{ - rect.right = rect.left + width; - rect.bottom = rect.top + height; -} - -void CBaseDialog::OnOK () -{ - int toot=0; -} - -void CBaseDialog::OnCancel () -{ - ((CMainFrame*)theApp.m_pMainWnd)->showOutputConsole (false); -} - -BOOL CBaseDialog::PreTranslateMessage(MSG* pMsg) -{ - // Check if it is a hotkey - /*if ( TranslateAccelerator (theApp.m_pMainWnd->m_hWnd, Accelerator, pMsg) ) - return TRUE;*/ - if (theApp.m_pMainWnd->PreTranslateMessage(pMsg)) - return TRUE; - - return CDialog::PreTranslateMessage(pMsg); -} - -void CBaseDialog::setEditTextMultiLine (CEdit &edit, const char *text) -{ - string temp; - uint size = strlen (text); - temp.reserve (2*size); - bool previousR=false; - for (uint c=0; conLastFocus (); - else - Dlg->onFirstFocus (); -} - -void CBaseDialog::setFocusLastWidget () -{ - CWnd *wnd = GetNextDlgTabItem ( &DummyStatic0, TRUE); - if (wnd) - wnd->SetFocus (); -} - -void CBaseDialog::resizeWidgets (uint virtualWidth, uint evaluatedHeight) -{ - // Get the window size - RECT rect; - View->GetClientRect (&rect); - int height = rect.bottom - rect.top - View->WidgetTopMargin - View->WidgetBottomMargin; - AdjusteHeight = (uint)std::max (0, (int)(height - evaluatedHeight)); - - Width = virtualWidth - View->WidgetRightMargin - View->WidgetLeftMargin; - SmallWidget = std::min ( (Width-WidgetSpaceWidth) /2, (uint)MaxWidgetWidth); - SmallWidgetNotLimited = (Width-WidgetSpaceWidth) /2; -} +// 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 . + +// base_dialog.cpp : implementation file +// + +#include "stdafx.h" +#include "georges_edit.h" +#include "georges_edit_doc.h" +#include "georges_edit_view.h" +#include "base_dialog.h" +#include "main_frm.h" + +using namespace std; + +///////////////////////////////////////////////////////////////////////////// +// CBaseDialog dialog + +CBaseDialog::CBaseDialog(int accelResource) + : CDialog(CBaseDialog::IDD) +{ + //{{AFX_DATA_INIT(CBaseDialog) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + Accelerator = LoadAccelerators ( theApp.m_hInstance, MAKEINTRESOURCE (accelResource) ); +} + + +void CBaseDialog::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CBaseDialog) + // NOTE: the ClassWizard will add DDX and DDV calls here + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CBaseDialog, CDialog) + //{{AFX_MSG_MAP(CBaseDialog) + ON_WM_SIZE() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +BEGIN_MESSAGE_MAP(CDoomyControl, CStatic) + //{{AFX_MSG_MAP(CDoomyControl) + ON_WM_SETFOCUS() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CBaseDialog message handlers + +BOOL CBaseDialog::OnInitDialog() +{ + CDialog::OnInitDialog(); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void CBaseDialog::OnSize(UINT nType, int cx, int cy) +{ + CDialog::OnSize(nType, cx, cy); + +} + +void CBaseDialog::getFirstItemPos (RECT &rect) +{ + rect.left = 0; + rect.top = 0; +} + +void CBaseDialog::setComboSize (RECT &rect, uint width, uint height) +{ + rect.right = rect.left + width; + rect.bottom = rect.top + height; +} + +void CBaseDialog::setComboSpinSize (RECT &rect) +{ + rect.right = rect.left + SmallWidget-SpinWidth; + rect.bottom = rect.top + ComboHeight; +} + +void CBaseDialog::setComboBrowseSize (RECT &rect) +{ + rect.right = rect.left + SmallWidget-BrowseWidth; + rect.bottom = rect.top + ComboHeight; +} + +void CBaseDialog::adjusteComboSize (RECT &rect) +{ + rect.bottom += ComboDropDownHeight; +} + +void CBaseDialog::setStaticSize (RECT &rect) +{ + rect.right = rect.left + SmallWidget; + rect.bottom = rect.top + StaticHeight; +} + +void CBaseDialog::setEditSize (RECT &rect, uint width, uint height) +{ + rect.right = rect.left + width; + rect.bottom = rect.top + height; +} + +void CBaseDialog::setColorSize (RECT &rect, uint width, uint height) +{ + rect.right = rect.left + width - ResetColorWidth; + rect.bottom = rect.top + height; +} + +void CBaseDialog::setBigEditSize (RECT &rect, uint width, uint height) +{ + rect.right = rect.left + width; + rect.bottom = rect.top + height; +} + +void CBaseDialog::getNextPos (RECT &rect) +{ + rect.top = rect.bottom + WidgetSpaceHeight; +} + +void CBaseDialog::getNextPosLabel (RECT &rect) +{ + rect.top = rect.bottom + LabelSpaceHeight; +} + +void CBaseDialog::initWidget (CWnd &wnd) +{ + CFont* font = GetFont (); + wnd.SetFont (font); + wnd.ShowWindow (SW_SHOW); +} + +void CBaseDialog::setListSize (RECT &rect, uint width, uint height) +{ + rect.right = rect.left + width; + rect.bottom = rect.top + height; +} + +void CBaseDialog::setEditSpinSize (RECT &rect, uint width, uint height) +{ + rect.right = rect.left + width; + rect.bottom = rect.top + height; +} + +void CBaseDialog::setSpinSize (RECT &rect, uint width, uint height) +{ + rect.right = rect.left + width; + rect.bottom = rect.top + height; +} + +void CBaseDialog::setBrowseSize (RECT &rect, uint width, uint height) +{ + rect.right = rect.left + width; + rect.bottom = rect.top + height; +} + +void CBaseDialog::setResetColorSize (RECT &rect, uint width, uint height) +{ + rect.right = rect.left + width; + rect.bottom = rect.top + height; +} + +void CBaseDialog::getNextColumn (RECT &rect) +{ + rect.left += SmallWidgetNotLimited + WidgetSpaceWidth; + rect.top = 0; +} + +void CBaseDialog::getFirstColumn (RECT &rect) +{ + rect.left = 0; +} + +void CBaseDialog::getNextSpinPos (RECT &rect) +{ + rect.left = rect.right; +} + +void CBaseDialog::getNextBrowsePos (RECT &rect) +{ + rect.left = rect.right; +} + +void CBaseDialog::getNextColorPos (RECT &rect) +{ + rect.left = rect.right; +} + +void CBaseDialog::setButtonSize (RECT &rect, uint width, uint height) +{ + rect.right = rect.left + width; + rect.bottom = rect.top + height; +} + +void CBaseDialog::OnOK () +{ + int toot=0; +} + +void CBaseDialog::OnCancel () +{ + ((CMainFrame*)theApp.m_pMainWnd)->showOutputConsole (false); +} + +BOOL CBaseDialog::PreTranslateMessage(MSG* pMsg) +{ + // Check if it is a hotkey + /*if ( TranslateAccelerator (theApp.m_pMainWnd->m_hWnd, Accelerator, pMsg) ) + return TRUE;*/ + if (theApp.m_pMainWnd->PreTranslateMessage(pMsg)) + return TRUE; + + return CDialog::PreTranslateMessage(pMsg); +} + +void CBaseDialog::setEditTextMultiLine (CEdit &edit, const char *text) +{ + string temp; + uint size = strlen (text); + temp.reserve (2*size); + bool previousR=false; + for (uint c=0; conLastFocus (); + else + Dlg->onFirstFocus (); +} + +void CBaseDialog::setFocusLastWidget () +{ + CWnd *wnd = GetNextDlgTabItem ( &DummyStatic0, TRUE); + if (wnd) + wnd->SetFocus (); +} + +void CBaseDialog::resizeWidgets (uint virtualWidth, uint evaluatedHeight) +{ + // Get the window size + RECT rect; + View->GetClientRect (&rect); + int height = rect.bottom - rect.top - View->WidgetTopMargin - View->WidgetBottomMargin; + AdjusteHeight = (uint)std::max (0, (int)(height - evaluatedHeight)); + + Width = virtualWidth - View->WidgetRightMargin - View->WidgetLeftMargin; + SmallWidget = std::min ( (Width-WidgetSpaceWidth) /2, (uint)MaxWidgetWidth); + SmallWidgetNotLimited = (Width-WidgetSpaceWidth) /2; +} diff --git a/code/ryzom/tools/leveldesign/georges_dll/base_dialog.h b/code/ryzom/tools/leveldesign/georges_dll/base_dialog.h index c0111ea02..5f96d8229 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/base_dialog.h +++ b/code/ryzom/tools/leveldesign/georges_dll/base_dialog.h @@ -1,167 +1,167 @@ -// 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 . - -#if !defined(AFX_BASE_DIALOG_H__C9035AC0_2958_4540_9FFD_D1DD434CFF9F__INCLUDED_) -#define AFX_BASE_DIALOG_H__C9035AC0_2958_4540_9FFD_D1DD434CFF9F__INCLUDED_ - -#include "nel/misc/types_nl.h" - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// base_dialog.h : header file -// - -class CGeorgesEditView; - -///////////////////////////////////////////////////////////////////////////// -// CBaseDialog dialog - -class CBaseDialog; - -class CDoomyControl : public CStatic -{ -public: - CBaseDialog *Dlg; - uint Index; - void OnSetFocus( CWnd* pOldWnd ); - DECLARE_MESSAGE_MAP() -}; - -class CBaseDialog : public CDialog -{ -// Construction -public: - CBaseDialog(int accelResource); // standard constructor - -// Dialog Data - //{{AFX_DATA(CBaseDialog) - enum { IDD = IDD_BASE_DIALOG }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - CGeorgesEditView *View; - - enum - { - MinViewWidth = 400, - MinViewHeight = 400, - StaticHeight = 15, - MaxWidgetWidth = 350, - BigEditHeight = 40, - }; - - enum - { - WidgetSpaceWidth = 20, - WidgetSpaceHeight = 15, - - LabelSpaceHeight = 2, - - EditHeight = 20, - - ListHeight = 200, - - ComboHeight = 25, - ComboDropDownHeight = 100, - - ButtonHeight = 20, - - SpinWidth = 13, - SpinHeight = 20, - - BrowseWidth = 30, - BrowseHeight = 20, - - ResetColorWidth = 40, - - ColorHeight = 20, - IconHeight = 40, - }; - - void resizeWidgets (uint virtualWidth, uint evaluatedHeight); - - void initWidget (CWnd &wnd); - - void getFirstItemPos (RECT &rect); - void getNextPos (RECT &rect); - void getNextPosLabel (RECT &rect); - void getNextColumn (RECT &rect); - void getFirstColumn (RECT &rect); - void getNextSpinPos (RECT &rect); - void getNextBrowsePos (RECT &rect); - void getNextColorPos (RECT &rect); - - void setComboSize (RECT &rect, uint width, uint height=ComboHeight); - void setComboSpinSize (RECT &rect); - void setComboBrowseSize (RECT &rect); - void adjusteComboSize (RECT &rect); - void setButtonSize (RECT &rect, uint width, uint height=ButtonHeight); - void setStaticSize (RECT &rect); - void setEditSize (RECT &rect, uint width, uint height=EditHeight); - void setColorSize (RECT &rect, uint width, uint height=ColorHeight); - void setBigEditSize (RECT &rect, uint width, uint height=BigEditHeight); - void setEditSpinSize (RECT &rect, uint width, uint height=EditHeight); - void setListSize (RECT &rect, uint width, uint height=ListHeight); - void setSpinSize (RECT &rect, uint width=SpinWidth, uint height=SpinHeight); - void setBrowseSize (RECT &rect, uint width=BrowseWidth, uint height=BrowseHeight); - void setResetColorSize (RECT &rect, uint width=ResetColorWidth, uint height=ColorHeight); - - virtual void onFirstFocus ()=0; - virtual void onLastFocus ()=0; - - void registerLastControl (); - void unRegisterLastControl (); - - static void setEditTextMultiLine (CEdit &edit, const char *text); - - virtual void onOpenSelected (); - virtual void setFocusLastWidget (); - - virtual void OnOK (); - virtual void OnCancel (); - - HACCEL Accelerator; - - CDoomyControl DummyStatic0; - CDoomyControl DummyStatic1; - - uint Width, SmallWidget, SmallWidgetNotLimited, AdjusteHeight; - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CBaseDialog) - public: - virtual BOOL PreTranslateMessage(MSG* pMsg); - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CBaseDialog) - virtual BOOL OnInitDialog(); - afx_msg void OnSize(UINT nType, int cx, int cy); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_BASE_DIALOG_H__C9035AC0_2958_4540_9FFD_D1DD434CFF9F__INCLUDED_) +// 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 . + +#if !defined(AFX_BASE_DIALOG_H__C9035AC0_2958_4540_9FFD_D1DD434CFF9F__INCLUDED_) +#define AFX_BASE_DIALOG_H__C9035AC0_2958_4540_9FFD_D1DD434CFF9F__INCLUDED_ + +#include "nel/misc/types_nl.h" + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// base_dialog.h : header file +// + +class CGeorgesEditView; + +///////////////////////////////////////////////////////////////////////////// +// CBaseDialog dialog + +class CBaseDialog; + +class CDoomyControl : public CStatic +{ +public: + CBaseDialog *Dlg; + uint Index; + void OnSetFocus( CWnd* pOldWnd ); + DECLARE_MESSAGE_MAP() +}; + +class CBaseDialog : public CDialog +{ +// Construction +public: + CBaseDialog(int accelResource); // standard constructor + +// Dialog Data + //{{AFX_DATA(CBaseDialog) + enum { IDD = IDD_BASE_DIALOG }; + // NOTE: the ClassWizard will add data members here + //}}AFX_DATA + + CGeorgesEditView *View; + + enum + { + MinViewWidth = 400, + MinViewHeight = 400, + StaticHeight = 15, + MaxWidgetWidth = 350, + BigEditHeight = 40, + }; + + enum + { + WidgetSpaceWidth = 20, + WidgetSpaceHeight = 15, + + LabelSpaceHeight = 2, + + EditHeight = 20, + + ListHeight = 200, + + ComboHeight = 25, + ComboDropDownHeight = 100, + + ButtonHeight = 20, + + SpinWidth = 13, + SpinHeight = 20, + + BrowseWidth = 30, + BrowseHeight = 20, + + ResetColorWidth = 40, + + ColorHeight = 20, + IconHeight = 40, + }; + + void resizeWidgets (uint virtualWidth, uint evaluatedHeight); + + void initWidget (CWnd &wnd); + + void getFirstItemPos (RECT &rect); + void getNextPos (RECT &rect); + void getNextPosLabel (RECT &rect); + void getNextColumn (RECT &rect); + void getFirstColumn (RECT &rect); + void getNextSpinPos (RECT &rect); + void getNextBrowsePos (RECT &rect); + void getNextColorPos (RECT &rect); + + void setComboSize (RECT &rect, uint width, uint height=ComboHeight); + void setComboSpinSize (RECT &rect); + void setComboBrowseSize (RECT &rect); + void adjusteComboSize (RECT &rect); + void setButtonSize (RECT &rect, uint width, uint height=ButtonHeight); + void setStaticSize (RECT &rect); + void setEditSize (RECT &rect, uint width, uint height=EditHeight); + void setColorSize (RECT &rect, uint width, uint height=ColorHeight); + void setBigEditSize (RECT &rect, uint width, uint height=BigEditHeight); + void setEditSpinSize (RECT &rect, uint width, uint height=EditHeight); + void setListSize (RECT &rect, uint width, uint height=ListHeight); + void setSpinSize (RECT &rect, uint width=SpinWidth, uint height=SpinHeight); + void setBrowseSize (RECT &rect, uint width=BrowseWidth, uint height=BrowseHeight); + void setResetColorSize (RECT &rect, uint width=ResetColorWidth, uint height=ColorHeight); + + virtual void onFirstFocus ()=0; + virtual void onLastFocus ()=0; + + void registerLastControl (); + void unRegisterLastControl (); + + static void setEditTextMultiLine (CEdit &edit, const char *text); + + virtual void onOpenSelected (); + virtual void setFocusLastWidget (); + + virtual void OnOK (); + virtual void OnCancel (); + + HACCEL Accelerator; + + CDoomyControl DummyStatic0; + CDoomyControl DummyStatic1; + + uint Width, SmallWidget, SmallWidgetNotLimited, AdjusteHeight; + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CBaseDialog) + public: + virtual BOOL PreTranslateMessage(MSG* pMsg); + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CBaseDialog) + virtual BOOL OnInitDialog(); + afx_msg void OnSize(UINT nType, int cx, int cy); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_BASE_DIALOG_H__C9035AC0_2958_4540_9FFD_D1DD434CFF9F__INCLUDED_) diff --git a/code/ryzom/tools/leveldesign/georges_dll/child_frm.cpp b/code/ryzom/tools/leveldesign/georges_dll/child_frm.cpp index 808210c37..37a85329d 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/child_frm.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/child_frm.cpp @@ -1,243 +1,243 @@ -// 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 "stdafx.h" -#include "georges_edit.h" - -#include "child_frm.h" -#include "main_frm.h" -#include "left_view.h" -#include "georges_edit_view.h" -#include "georges_edit_doc.h" - -///////////////////////////////////////////////////////////////////////////// -// CChildFrame -IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd) - -BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd) - //{{AFX_MSG_MAP(CChildFrame) - ON_WM_MDIACTIVATE() - //}}AFX_MSG_MAP - ON_UPDATE_COMMAND_UI_RANGE(AFX_ID_VIEW_MINIMUM, AFX_ID_VIEW_MAXIMUM, OnUpdateViewStyles) - ON_COMMAND_RANGE(AFX_ID_VIEW_MINIMUM, AFX_ID_VIEW_MAXIMUM, OnViewStyle) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CChildFrame construction/destruction - -CChildFrame::CChildFrame() -{ - // TODO: add member initialization code here - -} - -CChildFrame::~CChildFrame() -{ -} - -BOOL CChildFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/, - CCreateContext* pContext) -{ - // create splitter window - if (!m_wndSplitter.CreateStatic(this, 1, 2)) - return FALSE; - - if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeftView), CSize(300, 100), pContext) || - !m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CGeorgesEditView), CSize(100, 100), pContext)) - { - m_wndSplitter.DestroyWindow(); - return FALSE; - } - - // Load state - theApp.loadWindowState (this, "child", true, false); - - return TRUE; -} - -BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - if( !CMDIChildWnd::PreCreateWindow(cs) ) - return FALSE; - - return TRUE; -} - - - -///////////////////////////////////////////////////////////////////////////// -// CChildFrame diagnostics - -#ifdef _DEBUG -void CChildFrame::AssertValid() const -{ - CMDIChildWnd::AssertValid(); -} - -void CChildFrame::Dump(CDumpContext& dc) const -{ - CMDIChildWnd::Dump(dc); -} - -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CChildFrame message handlers -CGeorgesEditView* CChildFrame::GetRightPane() -{ - CWnd* pWnd = m_wndSplitter.GetPane(0, 1); - CGeorgesEditView* pView = DYNAMIC_DOWNCAST(CGeorgesEditView, pWnd); - return pView; -} - -void CChildFrame::OnUpdateViewStyles(CCmdUI* pCmdUI) -{ - // TODO: customize or extend this code to handle choices on the - // View menu. - - CGeorgesEditView* pView = GetRightPane(); - - // if the right-hand pane hasn't been created or isn't a view, - // disable commands in our range - - if (pView == NULL) - pCmdUI->Enable(FALSE); - else - { - DWORD dwStyle = pView->GetStyle() & LVS_TYPEMASK; - - // if the command is ID_VIEW_LINEUP, only enable command - // when we're in LVS_ICON or LVS_SMALLICON mode - - if (pCmdUI->m_nID == ID_VIEW_LINEUP) - { - if (dwStyle == LVS_ICON || dwStyle == LVS_SMALLICON) - pCmdUI->Enable(); - else - pCmdUI->Enable(FALSE); - } - else - { - // otherwise, use dots to reflect the style of the view - pCmdUI->Enable(); - BOOL bChecked = FALSE; - - switch (pCmdUI->m_nID) - { - case ID_VIEW_DETAILS: - bChecked = (dwStyle == LVS_REPORT); - break; - - case ID_VIEW_SMALLICON: - bChecked = (dwStyle == LVS_SMALLICON); - break; - - case ID_VIEW_LARGEICON: - bChecked = (dwStyle == LVS_ICON); - break; - - case ID_VIEW_LIST: - bChecked = (dwStyle == LVS_LIST); - break; - - default: - bChecked = FALSE; - break; - } - - pCmdUI->SetRadio(bChecked ? 1 : 0); - } - } -} - - -void CChildFrame::OnViewStyle(UINT nCommandID) -{ - // TODO: customize or extend this code to handle choices on the - // View menu. - CGeorgesEditView* pView = GetRightPane(); - - // if the right-hand pane has been created and is a CGeorgesEditView, - // process the menu commands... - if (pView != NULL) - { - DWORD dwStyle = -1; - - switch (nCommandID) - { - case ID_VIEW_LINEUP: - { - // ask the list control to snap to grid - /*CListCtrl& refListCtrl = pView->GetListCtrl(); - refListCtrl.Arrange(LVA_SNAPTOGRID);*/ - } - break; - - // other commands change the style on the list control - case ID_VIEW_DETAILS: - dwStyle = LVS_REPORT; - break; - - case ID_VIEW_SMALLICON: - dwStyle = LVS_SMALLICON; - break; - - case ID_VIEW_LARGEICON: - dwStyle = LVS_ICON; - break; - - case ID_VIEW_LIST: - dwStyle = LVS_LIST; - break; - } - - // change the style; window will repaint automatically - if (dwStyle != -1) - pView->ModifyStyle(LVS_TYPEMASK, dwStyle); - } -} - -void CChildFrame::OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd) -{ - CMDIChildWnd::OnMDIActivate(bActivate, pActivateWnd, pDeactivateWnd); - - // Get the doc - CGeorgesEditDoc* pDoc = GetRightPane()->GetDocument(); - if (pDoc) - { - pDoc->onActivateView ((bActivate==TRUE)); - } -} - -BOOL CChildFrame::PreTranslateMessage(MSG* pMsg) -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)(GetRightPane()->GetDocument( )); - if (doc) - { - uint i; - for (i=0; iPluginArray.size (); i++) - { - if (doc->PluginArray[i].PluginInterface->pretranslateMessage (pMsg)) - return TRUE; - } - } - - return CMDIChildWnd::PreTranslateMessage(pMsg); -} - +// 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 "stdafx.h" +#include "georges_edit.h" + +#include "child_frm.h" +#include "main_frm.h" +#include "left_view.h" +#include "georges_edit_view.h" +#include "georges_edit_doc.h" + +///////////////////////////////////////////////////////////////////////////// +// CChildFrame +IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd) + +BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd) + //{{AFX_MSG_MAP(CChildFrame) + ON_WM_MDIACTIVATE() + //}}AFX_MSG_MAP + ON_UPDATE_COMMAND_UI_RANGE(AFX_ID_VIEW_MINIMUM, AFX_ID_VIEW_MAXIMUM, OnUpdateViewStyles) + ON_COMMAND_RANGE(AFX_ID_VIEW_MINIMUM, AFX_ID_VIEW_MAXIMUM, OnViewStyle) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CChildFrame construction/destruction + +CChildFrame::CChildFrame() +{ + // TODO: add member initialization code here + +} + +CChildFrame::~CChildFrame() +{ +} + +BOOL CChildFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/, + CCreateContext* pContext) +{ + // create splitter window + if (!m_wndSplitter.CreateStatic(this, 1, 2)) + return FALSE; + + if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeftView), CSize(300, 100), pContext) || + !m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CGeorgesEditView), CSize(100, 100), pContext)) + { + m_wndSplitter.DestroyWindow(); + return FALSE; + } + + // Load state + theApp.loadWindowState (this, "child", true, false); + + return TRUE; +} + +BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + // TODO: Modify the Window class or styles here by modifying + // the CREATESTRUCT cs + + if( !CMDIChildWnd::PreCreateWindow(cs) ) + return FALSE; + + return TRUE; +} + + + +///////////////////////////////////////////////////////////////////////////// +// CChildFrame diagnostics + +#ifdef _DEBUG +void CChildFrame::AssertValid() const +{ + CMDIChildWnd::AssertValid(); +} + +void CChildFrame::Dump(CDumpContext& dc) const +{ + CMDIChildWnd::Dump(dc); +} + +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CChildFrame message handlers +CGeorgesEditView* CChildFrame::GetRightPane() +{ + CWnd* pWnd = m_wndSplitter.GetPane(0, 1); + CGeorgesEditView* pView = DYNAMIC_DOWNCAST(CGeorgesEditView, pWnd); + return pView; +} + +void CChildFrame::OnUpdateViewStyles(CCmdUI* pCmdUI) +{ + // TODO: customize or extend this code to handle choices on the + // View menu. + + CGeorgesEditView* pView = GetRightPane(); + + // if the right-hand pane hasn't been created or isn't a view, + // disable commands in our range + + if (pView == NULL) + pCmdUI->Enable(FALSE); + else + { + DWORD dwStyle = pView->GetStyle() & LVS_TYPEMASK; + + // if the command is ID_VIEW_LINEUP, only enable command + // when we're in LVS_ICON or LVS_SMALLICON mode + + if (pCmdUI->m_nID == ID_VIEW_LINEUP) + { + if (dwStyle == LVS_ICON || dwStyle == LVS_SMALLICON) + pCmdUI->Enable(); + else + pCmdUI->Enable(FALSE); + } + else + { + // otherwise, use dots to reflect the style of the view + pCmdUI->Enable(); + BOOL bChecked = FALSE; + + switch (pCmdUI->m_nID) + { + case ID_VIEW_DETAILS: + bChecked = (dwStyle == LVS_REPORT); + break; + + case ID_VIEW_SMALLICON: + bChecked = (dwStyle == LVS_SMALLICON); + break; + + case ID_VIEW_LARGEICON: + bChecked = (dwStyle == LVS_ICON); + break; + + case ID_VIEW_LIST: + bChecked = (dwStyle == LVS_LIST); + break; + + default: + bChecked = FALSE; + break; + } + + pCmdUI->SetRadio(bChecked ? 1 : 0); + } + } +} + + +void CChildFrame::OnViewStyle(UINT nCommandID) +{ + // TODO: customize or extend this code to handle choices on the + // View menu. + CGeorgesEditView* pView = GetRightPane(); + + // if the right-hand pane has been created and is a CGeorgesEditView, + // process the menu commands... + if (pView != NULL) + { + DWORD dwStyle = -1; + + switch (nCommandID) + { + case ID_VIEW_LINEUP: + { + // ask the list control to snap to grid + /*CListCtrl& refListCtrl = pView->GetListCtrl(); + refListCtrl.Arrange(LVA_SNAPTOGRID);*/ + } + break; + + // other commands change the style on the list control + case ID_VIEW_DETAILS: + dwStyle = LVS_REPORT; + break; + + case ID_VIEW_SMALLICON: + dwStyle = LVS_SMALLICON; + break; + + case ID_VIEW_LARGEICON: + dwStyle = LVS_ICON; + break; + + case ID_VIEW_LIST: + dwStyle = LVS_LIST; + break; + } + + // change the style; window will repaint automatically + if (dwStyle != -1) + pView->ModifyStyle(LVS_TYPEMASK, dwStyle); + } +} + +void CChildFrame::OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd) +{ + CMDIChildWnd::OnMDIActivate(bActivate, pActivateWnd, pDeactivateWnd); + + // Get the doc + CGeorgesEditDoc* pDoc = GetRightPane()->GetDocument(); + if (pDoc) + { + pDoc->onActivateView ((bActivate==TRUE)); + } +} + +BOOL CChildFrame::PreTranslateMessage(MSG* pMsg) +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)(GetRightPane()->GetDocument( )); + if (doc) + { + uint i; + for (i=0; iPluginArray.size (); i++) + { + if (doc->PluginArray[i].PluginInterface->pretranslateMessage (pMsg)) + return TRUE; + } + } + + return CMDIChildWnd::PreTranslateMessage(pMsg); +} + diff --git a/code/ryzom/tools/leveldesign/georges_dll/child_frm.h b/code/ryzom/tools/leveldesign/georges_dll/child_frm.h index 206696b8c..b2dc3a051 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/child_frm.h +++ b/code/ryzom/tools/leveldesign/georges_dll/child_frm.h @@ -1,74 +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 . - -#if !defined(AFX_CHILDFRM_H__A4ED8F6E_DDAD_4196_8315_A61246D6202C__INCLUDED_) -#define AFX_CHILDFRM_H__A4ED8F6E_DDAD_4196_8315_A61246D6202C__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -class CGeorgesEditView; - -class CChildFrame : public CMDIChildWnd -{ - DECLARE_DYNCREATE(CChildFrame) -public: - CChildFrame(); - -// Attributes -public: - CSplitterWnd m_wndSplitter; -public: - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CChildFrame) - public: - virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext); - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - virtual BOOL PreTranslateMessage(MSG* pMsg); - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CChildFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - CGeorgesEditView* GetRightPane(); -// Generated message map functions -protected: - //{{AFX_MSG(CChildFrame) - afx_msg void OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd); - //}}AFX_MSG - afx_msg void OnUpdateViewStyles(CCmdUI* pCmdUI); - afx_msg void OnViewStyle(UINT nCommandID); - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_CHILDFRM_H__A4ED8F6E_DDAD_4196_8315_A61246D6202C__INCLUDED_) +// 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 . + +#if !defined(AFX_CHILDFRM_H__A4ED8F6E_DDAD_4196_8315_A61246D6202C__INCLUDED_) +#define AFX_CHILDFRM_H__A4ED8F6E_DDAD_4196_8315_A61246D6202C__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +class CGeorgesEditView; + +class CChildFrame : public CMDIChildWnd +{ + DECLARE_DYNCREATE(CChildFrame) +public: + CChildFrame(); + +// Attributes +public: + CSplitterWnd m_wndSplitter; +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CChildFrame) + public: + virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext); + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + virtual BOOL PreTranslateMessage(MSG* pMsg); + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CChildFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + CGeorgesEditView* GetRightPane(); +// Generated message map functions +protected: + //{{AFX_MSG(CChildFrame) + afx_msg void OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd); + //}}AFX_MSG + afx_msg void OnUpdateViewStyles(CCmdUI* pCmdUI); + afx_msg void OnViewStyle(UINT nCommandID); + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_CHILDFRM_H__A4ED8F6E_DDAD_4196_8315_A61246D6202C__INCLUDED_) diff --git a/code/ryzom/tools/leveldesign/georges_dll/color_wnd.cpp b/code/ryzom/tools/leveldesign/georges_dll/color_wnd.cpp index f85f5b947..9be44082e 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/color_wnd.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/color_wnd.cpp @@ -1,180 +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 . - -// color_wnd.cpp : implementation file -// - -#include "stdafx.h" -#include "georges_edit.h" -#include "color_wnd.h" - -using namespace NLMISC; - -///////////////////////////////////////////////////////////////////////////// -// CColorWnd - -CColorWnd::CColorWnd() -{ - Color = CRGBA::Black; -} - -CColorWnd::~CColorWnd() -{ -} - - -BEGIN_MESSAGE_MAP(CColorWnd, CWnd) - //{{AFX_MSG_MAP(CColorWnd) - ON_WM_PAINT() - ON_WM_SETFOCUS() - ON_WM_KILLFOCUS() - ON_WM_LBUTTONDBLCLK() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - -///////////////////////////////////////////////////////////////////////////// -// CColorWnd message handlers - -void CColorWnd::OnPaint() -{ - CPaintDC dc(this); // device context for painting - - // Get client dc - RECT client; - GetClientRect (&client); - - COLORREF color = RGB (Color.R, Color.G, Color.B); - - CBrush brush; - brush.CreateSolidBrush (color); - CBrush *old = dc.SelectObject (&brush); - dc.Rectangle (&client); - dc.SelectObject (old); - - if (GetFocus ()== this) - dc.DrawFocusRect (&client); - - // Do not call CWnd::OnPaint() for painting messages -} - -void CColorWnd::create (DWORD wStyle, RECT &pos, CWnd *parent, uint dialogIndex) -{ - Id = dialogIndex; - // Register window class - LPCTSTR className = AfxRegisterWndClass(CS_DBLCLKS); - - // Create this window - if (CWnd::Create (className, "empty", wStyle, pos, parent, dialogIndex)) - { - } -} - - -void CColorWnd::OnSetFocus(CWnd* pOldWnd) -{ - CWnd::OnSetFocus(pOldWnd); - - // Force redraw - Invalidate (); - - // Send the notify message to the parent - NMHDR strNotify; - strNotify.hwndFrom = *this; - strNotify.idFrom = Id; - strNotify.code = NM_SETFOCUS; - GetParent ()->SendMessage (WM_NOTIFY, Id, (LPARAM)&strNotify); -} - -void CColorWnd::OnKillFocus(CWnd* pNewWnd) -{ - CWnd::OnKillFocus(pNewWnd); - - // Force redraw - Invalidate (); - - // Send the notify message to the parent - NMHDR strNotify; - strNotify.hwndFrom = *this; - strNotify.idFrom = Id; - strNotify.code = NM_KILLFOCUS; - GetParent ()->SendMessage (WM_NOTIFY, Id, (LPARAM)&strNotify); -} - -void CColorWnd::setColor (const NLMISC::CRGBA &color) -{ - Color = color; - - char buffer[256]; - sprintf(buffer, "%d,%d,%d", Color.R, Color.G, Color.B); - SetWindowText(buffer); - - Invalidate (); - GetParent()->PostMessage (CBN_CHANGED, 0, 0); -} - -NLMISC::CRGBA CColorWnd::getColor () const -{ - return Color; -} - -void CColorWnd::OnLButtonDblClk(UINT nFlags, CPoint point) -{ - // Select a color - if (theApp.getColor (Color)) - { - colorChanged (); - } - - CWnd::OnLButtonDblClk(nFlags, point); -} - -BOOL CColorWnd::PreTranslateMessage(MSG* pMsg) -{ - if ( (pMsg->message==WM_KEYDOWN) && (pMsg->wParam == VK_RETURN)) - { - if (theApp.getColor (Color)) - { - colorChanged (); - } - } - - return CWnd::PreTranslateMessage(pMsg); -} - -void CColorWnd::colorChanged () -{ - updateEdit(); - Invalidate (); - - char buffer[256]; - sprintf(buffer, "%d,%d,%d", Color.R, Color.G, Color.B); - SetWindowText(buffer); - - CWnd *wnd = GetParent (); - if (wnd) - { - wnd->SendMessage (CL_CHANGED, Id, 0); - wnd->PostMessage (CBN_CHANGED, 0, 0); - } -} - -void CColorWnd::updateEdit() -{ - char buffer[256]; - sprintf(buffer, "%d,%d,%d", Color.R, Color.G, Color.B); - pEdit->SetWindowText(buffer); +// 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 . + +// color_wnd.cpp : implementation file +// + +#include "stdafx.h" +#include "georges_edit.h" +#include "color_wnd.h" + +using namespace NLMISC; + +///////////////////////////////////////////////////////////////////////////// +// CColorWnd + +CColorWnd::CColorWnd() +{ + Color = CRGBA::Black; +} + +CColorWnd::~CColorWnd() +{ +} + + +BEGIN_MESSAGE_MAP(CColorWnd, CWnd) + //{{AFX_MSG_MAP(CColorWnd) + ON_WM_PAINT() + ON_WM_SETFOCUS() + ON_WM_KILLFOCUS() + ON_WM_LBUTTONDBLCLK() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + + +///////////////////////////////////////////////////////////////////////////// +// CColorWnd message handlers + +void CColorWnd::OnPaint() +{ + CPaintDC dc(this); // device context for painting + + // Get client dc + RECT client; + GetClientRect (&client); + + COLORREF color = RGB (Color.R, Color.G, Color.B); + + CBrush brush; + brush.CreateSolidBrush (color); + CBrush *old = dc.SelectObject (&brush); + dc.Rectangle (&client); + dc.SelectObject (old); + + if (GetFocus ()== this) + dc.DrawFocusRect (&client); + + // Do not call CWnd::OnPaint() for painting messages +} + +void CColorWnd::create (DWORD wStyle, RECT &pos, CWnd *parent, uint dialogIndex) +{ + Id = dialogIndex; + // Register window class + LPCTSTR className = AfxRegisterWndClass(CS_DBLCLKS); + + // Create this window + if (CWnd::Create (className, "empty", wStyle, pos, parent, dialogIndex)) + { + } +} + + +void CColorWnd::OnSetFocus(CWnd* pOldWnd) +{ + CWnd::OnSetFocus(pOldWnd); + + // Force redraw + Invalidate (); + + // Send the notify message to the parent + NMHDR strNotify; + strNotify.hwndFrom = *this; + strNotify.idFrom = Id; + strNotify.code = NM_SETFOCUS; + GetParent ()->SendMessage (WM_NOTIFY, Id, (LPARAM)&strNotify); +} + +void CColorWnd::OnKillFocus(CWnd* pNewWnd) +{ + CWnd::OnKillFocus(pNewWnd); + + // Force redraw + Invalidate (); + + // Send the notify message to the parent + NMHDR strNotify; + strNotify.hwndFrom = *this; + strNotify.idFrom = Id; + strNotify.code = NM_KILLFOCUS; + GetParent ()->SendMessage (WM_NOTIFY, Id, (LPARAM)&strNotify); +} + +void CColorWnd::setColor (const NLMISC::CRGBA &color) +{ + Color = color; + + char buffer[256]; + sprintf(buffer, "%d,%d,%d", Color.R, Color.G, Color.B); + SetWindowText(buffer); + + Invalidate (); + GetParent()->PostMessage (CBN_CHANGED, 0, 0); +} + +NLMISC::CRGBA CColorWnd::getColor () const +{ + return Color; +} + +void CColorWnd::OnLButtonDblClk(UINT nFlags, CPoint point) +{ + // Select a color + if (theApp.getColor (Color)) + { + colorChanged (); + } + + CWnd::OnLButtonDblClk(nFlags, point); +} + +BOOL CColorWnd::PreTranslateMessage(MSG* pMsg) +{ + if ( (pMsg->message==WM_KEYDOWN) && (pMsg->wParam == VK_RETURN)) + { + if (theApp.getColor (Color)) + { + colorChanged (); + } + } + + return CWnd::PreTranslateMessage(pMsg); +} + +void CColorWnd::colorChanged () +{ + updateEdit(); + Invalidate (); + + char buffer[256]; + sprintf(buffer, "%d,%d,%d", Color.R, Color.G, Color.B); + SetWindowText(buffer); + + CWnd *wnd = GetParent (); + if (wnd) + { + wnd->SendMessage (CL_CHANGED, Id, 0); + wnd->PostMessage (CBN_CHANGED, 0, 0); + } +} + +void CColorWnd::updateEdit() +{ + char buffer[256]; + sprintf(buffer, "%d,%d,%d", Color.R, Color.G, Color.B); + pEdit->SetWindowText(buffer); } \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_dll/color_wnd.h b/code/ryzom/tools/leveldesign/georges_dll/color_wnd.h index 5d1c0a6df..ee12448b0 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/color_wnd.h +++ b/code/ryzom/tools/leveldesign/georges_dll/color_wnd.h @@ -1,87 +1,87 @@ -// 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 . - -#if !defined(AFX_COLOR_WND_H__E8BA0021_DBC1_4E3C_9D8A_D13A8FCE7B0C__INCLUDED_) -#define AFX_COLOR_WND_H__E8BA0021_DBC1_4E3C_9D8A_D13A8FCE7B0C__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// color_wnd.h : header file -// - -#include "nel/misc/rgba.h" - -///////////////////////////////////////////////////////////////////////////// -// CColorWnd window - -#define CL_CHANGED (WM_APP+0x3a) -#define CBN_CHANGED (WM_APP+0x3b) - -class CColorWnd : public CWnd -{ -// Construction -public: - CColorWnd(); - - void create (DWORD wStyle, RECT &pos, CWnd *window, uint dialogIndex); - - void setColor (const NLMISC::CRGBA &color); - NLMISC::CRGBA getColor () const; - void colorChanged (); - void setEdit(CEdit *pEdit) { this->pEdit = pEdit; } - void updateEdit(); - -// Attributes -public: - - NLMISC::CRGBA Color; - uint Id; - -private: - CEdit* pEdit; - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CColorWnd) - public: - virtual BOOL PreTranslateMessage(MSG* pMsg); - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CColorWnd(); - - // Generated message map functions -protected: - //{{AFX_MSG(CColorWnd) - afx_msg void OnPaint(); - afx_msg void OnSetFocus(CWnd* pOldWnd); - afx_msg void OnKillFocus(CWnd* pNewWnd); - afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_COLOR_WND_H__E8BA0021_DBC1_4E3C_9D8A_D13A8FCE7B0C__INCLUDED_) +// 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 . + +#if !defined(AFX_COLOR_WND_H__E8BA0021_DBC1_4E3C_9D8A_D13A8FCE7B0C__INCLUDED_) +#define AFX_COLOR_WND_H__E8BA0021_DBC1_4E3C_9D8A_D13A8FCE7B0C__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// color_wnd.h : header file +// + +#include "nel/misc/rgba.h" + +///////////////////////////////////////////////////////////////////////////// +// CColorWnd window + +#define CL_CHANGED (WM_APP+0x3a) +#define CBN_CHANGED (WM_APP+0x3b) + +class CColorWnd : public CWnd +{ +// Construction +public: + CColorWnd(); + + void create (DWORD wStyle, RECT &pos, CWnd *window, uint dialogIndex); + + void setColor (const NLMISC::CRGBA &color); + NLMISC::CRGBA getColor () const; + void colorChanged (); + void setEdit(CEdit *pEdit) { this->pEdit = pEdit; } + void updateEdit(); + +// Attributes +public: + + NLMISC::CRGBA Color; + uint Id; + +private: + CEdit* pEdit; + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CColorWnd) + public: + virtual BOOL PreTranslateMessage(MSG* pMsg); + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CColorWnd(); + + // Generated message map functions +protected: + //{{AFX_MSG(CColorWnd) + afx_msg void OnPaint(); + afx_msg void OnSetFocus(CWnd* pOldWnd); + afx_msg void OnKillFocus(CWnd* pNewWnd); + afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_COLOR_WND_H__E8BA0021_DBC1_4E3C_9D8A_D13A8FCE7B0C__INCLUDED_) diff --git a/code/ryzom/tools/leveldesign/georges_dll/cool_dialog_bar.cpp b/code/ryzom/tools/leveldesign/georges_dll/cool_dialog_bar.cpp index 765c7c272..8bcac472c 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/cool_dialog_bar.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/cool_dialog_bar.cpp @@ -1,646 +1,646 @@ -// 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 . - -// CoolDialogBar.cpp : implementation file -// http://www.codeguru.com/docking/devstudio_like_controlbar_2.shtml - -#include "stdafx.h" -#include "afxpriv.h" // for CDockContext -#include "cool_dialog_bar.h" - -#define max(a,b) ((a>b)?a:b) -#define min(a,b) ((aCreate(nID, this); - - // JC: added patch to fix the problem with LoadBarState - SetDlgCtrlID(nID); - - // use the dialog dimensions as default base dimensions - CRect rc; - m_cDialog->GetWindowRect(rc); - m_sizeHorz = m_sizeVert = m_sizeFloat = rc.Size(); - m_sizeHorz.cy += m_cxEdge + m_cxBorder; - m_sizeVert.cx += m_cxEdge + m_cxBorder; - return TRUE; -} - -CSize CCoolDialogBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz) -{ - CRect rc; - - m_pDockSite->GetControlBar(AFX_IDW_DOCKBAR_TOP)->GetWindowRect(rc); - int nHorzDockBarWidth = bStretch ? 32767 : rc.Width() + 4; - m_pDockSite->GetControlBar(AFX_IDW_DOCKBAR_LEFT)->GetWindowRect(rc); - int nVertDockBarHeight = bStretch ? 32767 : rc.Height() + 4; - - if(IsFloating()) - return m_sizeFloat; - else if (bHorz) - return CSize(nHorzDockBarWidth, m_sizeHorz.cy); - else - return CSize(m_sizeVert.cx, nVertDockBarHeight); -} - -CSize CCoolDialogBar::CalcDynamicLayout(int nLength, DWORD dwMode) -{ - // Rob Wolpov 10/15/98 Added support for diagonal sizing - if (IsFloating()) - { - // Enable diagonal arrow cursor for resizing - GetParent()->GetParent()->ModifyStyle(MFS_4THICKFRAME,0); - } - if (dwMode & (LM_HORZDOCK | LM_VERTDOCK)) - { - SetWindowPos(NULL, 0, 0, 0, 0, - SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | - SWP_NOACTIVATE | SWP_FRAMECHANGED); - m_pDockSite->RecalcLayout(); - return CControlBar::CalcDynamicLayout(nLength,dwMode); - } - - if (dwMode & LM_MRUWIDTH) - return m_sizeFloat; - - if (dwMode & LM_COMMIT) - { - m_sizeFloat.cx = nLength; - return m_sizeFloat; - } - - // Rob Wolpov 10/15/98 Added support for diagonal sizing - if (IsFloating()) - { - RECT window_rect; - POINT cursor_pt; - - GetCursorPos(&cursor_pt); - GetParent()->GetParent()->GetWindowRect(&window_rect); - - switch (m_pDockContext->m_nHitTest) - { - case HTTOPLEFT: - m_sizeFloat.cx = max(window_rect.right - cursor_pt.x, - m_cMinWidth) - m_cxBorder; - m_sizeFloat.cy = max(window_rect.bottom - m_cCaptionSize - - cursor_pt.y,m_cMinHeight) - 1; - m_pDockContext->m_rectFrameDragHorz.top = min(cursor_pt.y, - window_rect.bottom - m_cCaptionSize - m_cMinHeight) - - m_cyBorder; - m_pDockContext->m_rectFrameDragHorz.left = min(cursor_pt.x, - window_rect.right - m_cMinWidth) - 1; - return m_sizeFloat; - - case HTTOPRIGHT: - m_sizeFloat.cx = max(cursor_pt.x - window_rect.left, - m_cMinWidth); - m_sizeFloat.cy = max(window_rect.bottom - m_cCaptionSize - - cursor_pt.y,m_cMinHeight) - 1; - m_pDockContext->m_rectFrameDragHorz.top = min(cursor_pt.y, - window_rect.bottom - m_cCaptionSize - m_cMinHeight) - - m_cyBorder; - return m_sizeFloat; - - case HTBOTTOMLEFT: - m_sizeFloat.cx = max(window_rect.right - cursor_pt.x, - m_cMinWidth) - m_cxBorder; - m_sizeFloat.cy = max(cursor_pt.y - window_rect.top - - m_cCaptionSize,m_cMinHeight); - m_pDockContext->m_rectFrameDragHorz.left = min(cursor_pt.x, - window_rect.right - m_cMinWidth) - 1; - return m_sizeFloat; - - case HTBOTTOMRIGHT: - m_sizeFloat.cx = max(cursor_pt.x - window_rect.left, - m_cMinWidth); - m_sizeFloat.cy = max(cursor_pt.y - window_rect.top - - m_cCaptionSize,m_cMinHeight); - return m_sizeFloat; - } - } - - if (dwMode & LM_LENGTHY) - return CSize(m_sizeFloat.cx, - m_sizeFloat.cy = max(m_sizeMin.cy, nLength)); - else - return CSize(max(m_sizeMin.cx, nLength), m_sizeFloat.cy); -} - -void CCoolDialogBar::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos) -{ - CControlBar::OnWindowPosChanged(lpwndpos); - - if(!::IsWindow(m_hWnd) || m_cDialog==NULL) - return; - if(!::IsWindow(m_cDialog->m_hWnd)) - return; - if (m_bInRecalcNC) - { - CRect rc; - GetClientRect(rc); - m_cDialog->MoveWindow(rc); - return; - } - - // Find on which side are we docked - UINT nDockBarID = GetParent()->GetDlgCtrlID(); - - // Return if dropped at same location - if (nDockBarID == m_nDockBarID // no docking side change - && (lpwndpos->flags & SWP_NOSIZE) // no size change - && ((m_dwStyle & CBRS_BORDER_ANY) != CBRS_BORDER_ANY)) - return; - - m_nDockBarID = nDockBarID; - - // Force recalc the non-client area - m_bInRecalcNC = TRUE; - SetWindowPos(NULL, 0,0,0,0, - SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED); - m_bInRecalcNC = FALSE; -} - -BOOL CCoolDialogBar::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) -{ - if ((nHitTest != HTSIZE) || m_bTracking) - return CControlBar::OnSetCursor(pWnd, nHitTest, message); - - if (IsHorz()) - SetCursor(LoadCursor(NULL, IDC_SIZENS)); - else - SetCursor(LoadCursor(NULL, IDC_SIZEWE)); - return TRUE; -} - -///////////////////////////////////////////////////////////////////////// -// Mouse Handling -// -void CCoolDialogBar::OnLButtonUp(UINT nFlags, CPoint point) -{ - if (!m_bTracking) - CControlBar::OnLButtonUp(nFlags, point); - else - { - ClientToWnd(point); - StopTracking(TRUE); - } -} - -void CCoolDialogBar::OnMouseMove(UINT nFlags, CPoint point) -{ - if (IsFloating() || !m_bTracking) - { - CControlBar::OnMouseMove(nFlags, point); - return; - } - - CPoint cpt = m_rectTracker.CenterPoint(); - - ClientToWnd(point); - - if (IsHorz()) - { - if (cpt.y != point.y) - { - OnInvertTracker(m_rectTracker); - m_rectTracker.OffsetRect(0, point.y - cpt.y); - OnInvertTracker(m_rectTracker); - } - } - else - { - if (cpt.x != point.x) - { - OnInvertTracker(m_rectTracker); - m_rectTracker.OffsetRect(point.x - cpt.x, 0); - OnInvertTracker(m_rectTracker); - } - } -} - -void CCoolDialogBar::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp) -{ - // Compute the rectangle of the mobile edge - GetWindowRect(m_rectBorder); - m_rectBorder = CRect(0, 0, m_rectBorder.Width(), m_rectBorder.Height()); - - DWORD dwBorderStyle = m_dwStyle | CBRS_BORDER_ANY; - - switch(m_nDockBarID) - { - case AFX_IDW_DOCKBAR_TOP: - dwBorderStyle &= ~CBRS_BORDER_BOTTOM; - lpncsp->rgrc[0].left += m_cxGripper; - lpncsp->rgrc[0].bottom += -m_cxEdge; - lpncsp->rgrc[0].top += m_cxBorder; - lpncsp->rgrc[0].right += -m_cxBorder; - m_rectBorder.top = m_rectBorder.bottom - m_cxEdge; - break; - case AFX_IDW_DOCKBAR_BOTTOM: - dwBorderStyle &= ~CBRS_BORDER_TOP; - lpncsp->rgrc[0].left += m_cxGripper; - lpncsp->rgrc[0].top += m_cxEdge; - lpncsp->rgrc[0].bottom += -m_cxBorder; - lpncsp->rgrc[0].right += -m_cxBorder; - m_rectBorder.bottom = m_rectBorder.top + m_cxEdge; - break; - case AFX_IDW_DOCKBAR_LEFT: - dwBorderStyle &= ~CBRS_BORDER_RIGHT; - lpncsp->rgrc[0].right += -m_cxEdge; - lpncsp->rgrc[0].left += m_cxBorder; - lpncsp->rgrc[0].bottom += -m_cxBorder; - lpncsp->rgrc[0].top += m_cxGripper; - m_rectBorder.left = m_rectBorder.right - m_cxEdge; - break; - case AFX_IDW_DOCKBAR_RIGHT: - dwBorderStyle &= ~CBRS_BORDER_LEFT; - lpncsp->rgrc[0].left += m_cxEdge; - lpncsp->rgrc[0].right += -m_cxBorder; - lpncsp->rgrc[0].bottom += -m_cxBorder; - lpncsp->rgrc[0].top += m_cxGripper; - m_rectBorder.right = m_rectBorder.left + m_cxEdge; - break; - default: - m_rectBorder.SetRectEmpty(); - break; - } - - SetBarStyle(dwBorderStyle); -} - -void CCoolDialogBar::OnNcPaint() -{ - EraseNonClient(); - - CWindowDC dc(this); - dc.Draw3dRect(m_rectBorder, GetSysColor(COLOR_BTNHIGHLIGHT), - GetSysColor(COLOR_BTNSHADOW)); - - DrawGripper(dc); - - CRect pRect; - GetClientRect( &pRect ); - InvalidateRect( &pRect, TRUE ); -} - -void CCoolDialogBar::OnNcLButtonDown(UINT nHitTest, CPoint point) -{ - if (m_bTracking) return; - - if((nHitTest == HTSYSMENU) && !IsFloating()) - GetDockingFrame()->ShowControlBar(this, FALSE, FALSE); - else if ((nHitTest == HTMINBUTTON) && !IsFloating()) - m_pDockContext->ToggleDocking(); - else if ((nHitTest == HTCAPTION) && !IsFloating() && (m_pDockBar != NULL)) - { - // start the drag - ASSERT(m_pDockContext != NULL); - m_pDockContext->StartDrag(point); - } - else if ((nHitTest == HTSIZE) && !IsFloating()) - StartTracking(); - else - CControlBar::OnNcLButtonDown(nHitTest, point); -} - -LRESULT CCoolDialogBar::OnNcHitTest(CPoint point) -{ - if (IsFloating()) - return CControlBar::OnNcHitTest(point); - - CRect rc; - GetWindowRect(rc); - point.Offset(-rc.left, -rc.top); - if(m_rectClose.PtInRect(point)) - return HTSYSMENU; - else if (m_rectUndock.PtInRect(point)) - return HTMINBUTTON; - else if (m_rectGripper.PtInRect(point)) - return HTCAPTION; - else if (m_rectBorder.PtInRect(point)) - return HTSIZE; - else - return CControlBar::OnNcHitTest(point); -} - -void CCoolDialogBar::OnLButtonDown(UINT nFlags, CPoint point) -{ - // only start dragging if clicked in "void" space - if (m_pDockBar != NULL) - { - // start the drag - ASSERT(m_pDockContext != NULL); - ClientToScreen(&point); - m_pDockContext->StartDrag(point); - } - else - { - CWnd::OnLButtonDown(nFlags, point); - } -} - -void CCoolDialogBar::OnLButtonDblClk(UINT nFlags, CPoint point) -{ - // only toggle docking if clicked in "void" space - if (m_pDockBar != NULL) - { - // toggle docking - ASSERT(m_pDockContext != NULL); - m_pDockContext->ToggleDocking(); - } - else - { - CWnd::OnLButtonDblClk(nFlags, point); - } -} - -void CCoolDialogBar::StartTracking() -{ - SetCapture(); - - // make sure no updates are pending - RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW); - m_pDockSite->LockWindowUpdate(); - - m_ptOld = m_rectBorder.CenterPoint(); - m_bTracking = TRUE; - - m_rectTracker = m_rectBorder; - if (!IsHorz()) m_rectTracker.bottom -= 4; - - OnInvertTracker(m_rectTracker); -} - -void CCoolDialogBar::OnCaptureChanged(CWnd *pWnd) -{ - if (m_bTracking && pWnd != this) - StopTracking(FALSE); // cancel tracking - - CControlBar::OnCaptureChanged(pWnd); -} - -void CCoolDialogBar::StopTracking(BOOL bAccept) -{ - OnInvertTracker(m_rectTracker); - m_pDockSite->UnlockWindowUpdate(); - m_bTracking = FALSE; - ReleaseCapture(); - - if (!bAccept) return; - - int maxsize, minsize, newsize; - CRect rcc; - m_pDockSite->GetWindowRect(rcc); - - newsize = IsHorz() ? m_sizeHorz.cy : m_sizeVert.cx; - maxsize = newsize + (IsHorz() ? rcc.Height() : rcc.Width()); - minsize = IsHorz() ? m_sizeMin.cy : m_sizeMin.cx; - - CPoint point = m_rectTracker.CenterPoint(); - switch (m_nDockBarID) - { - case AFX_IDW_DOCKBAR_TOP: - newsize += point.y - m_ptOld.y; break; - case AFX_IDW_DOCKBAR_BOTTOM: - newsize += -point.y + m_ptOld.y; break; - case AFX_IDW_DOCKBAR_LEFT: - newsize += point.x - m_ptOld.x; break; - case AFX_IDW_DOCKBAR_RIGHT: - newsize += -point.x + m_ptOld.x; break; - } - - newsize = max(minsize, min(maxsize, newsize)); - - if (IsHorz()) - m_sizeHorz.cy = newsize; - else - m_sizeVert.cx = newsize; - - m_pDockSite->RecalcLayout(); -} - -void CCoolDialogBar::OnInvertTracker(const CRect& rect) -{ - ASSERT_VALID(this); - ASSERT(!rect.IsRectEmpty()); - ASSERT(m_bTracking); - - CRect rct = rect, rcc, rcf; - GetWindowRect(rcc); - m_pDockSite->GetWindowRect(rcf); - - rct.OffsetRect(rcc.left - rcf.left, rcc.top - rcf.top); - rct.DeflateRect(1, 1); - - CDC *pDC = m_pDockSite->GetDCEx(NULL, - DCX_WINDOW|DCX_CACHE|DCX_LOCKWINDOWUPDATE); - - CBrush* pBrush = CDC::GetHalftoneBrush(); - HBRUSH hOldBrush = NULL; - if (pBrush != NULL) - hOldBrush = (HBRUSH)SelectObject(pDC->m_hDC, pBrush->m_hObject); - - pDC->PatBlt(rct.left, rct.top, rct.Width(), rct.Height(), PATINVERT); - - if (hOldBrush != NULL) - SelectObject(pDC->m_hDC, hOldBrush); - - m_pDockSite->ReleaseDC(pDC); -} - -BOOL CCoolDialogBar::IsHorz() const -{ - return (m_nDockBarID == AFX_IDW_DOCKBAR_TOP || - m_nDockBarID == AFX_IDW_DOCKBAR_BOTTOM); -} - -CPoint& CCoolDialogBar::ClientToWnd(CPoint& point) -{ - if (m_nDockBarID == AFX_IDW_DOCKBAR_BOTTOM) - point.y += m_cxEdge; - else if (m_nDockBarID == AFX_IDW_DOCKBAR_RIGHT) - point.x += m_cxEdge; - - return point; -} - -void CCoolDialogBar::DrawGripper(CDC & dc) -{ - // no gripper if floating - if( m_dwStyle & CBRS_FLOATING ) - return; - - // -==HACK==- - // in order to calculate the client area properly after docking, - // the client area must be recalculated twice (I have no idea why) - m_pDockSite->RecalcLayout(); - // -==END HACK==- - - CRect gripper; - GetWindowRect( gripper ); - ScreenToClient( gripper ); - gripper.OffsetRect( -gripper.left, -gripper.top ); - - if( m_dwStyle & CBRS_ORIENT_HORZ ) - { - // gripper at left - m_rectGripper.top = gripper.top + 40; - m_rectGripper.bottom = gripper.bottom; - m_rectGripper.left = gripper.left; - m_rectGripper.right = gripper.left + 20; - - // draw close box - m_rectClose.left = gripper.left + 7; - m_rectClose.right = m_rectClose.left + 12; - m_rectClose.top = gripper.top + 10; - m_rectClose.bottom = m_rectClose.top + 12; - dc.DrawFrameControl(m_rectClose, DFC_CAPTION, DFCS_CAPTIONCLOSE); - - // draw docking toggle box - m_rectUndock = m_rectClose; - m_rectUndock.OffsetRect(0,13); - dc.DrawFrameControl(m_rectUndock, DFC_CAPTION, DFCS_CAPTIONMAX); - - gripper.top += 38; - gripper.bottom -= 10; - gripper.left += 10; - gripper.right = gripper.left+3; - dc.Draw3dRect( gripper, m_clrBtnHilight, m_clrBtnShadow ); - - gripper.OffsetRect(4, 0); - dc.Draw3dRect( gripper, m_clrBtnHilight, m_clrBtnShadow ); - } - else - { - // gripper at top - m_rectGripper.top = gripper.top; - m_rectGripper.bottom = gripper.top + 20; - m_rectGripper.left = gripper.left; - m_rectGripper.right = gripper.right - 40; - - // draw close box - m_rectClose.right = gripper.right - 10; - m_rectClose.left = m_rectClose.right - 11; - m_rectClose.top = gripper.top + 7; - m_rectClose.bottom = m_rectClose.top + 11; - dc.DrawFrameControl(m_rectClose, DFC_CAPTION, DFCS_CAPTIONCLOSE); - - - // draw docking toggle box - m_rectUndock = m_rectClose; - m_rectUndock.OffsetRect(-13,0); - dc.DrawFrameControl(m_rectUndock, DFC_CAPTION, DFCS_CAPTIONMAX); - - gripper.right -= 38; - gripper.left += 10; - gripper.top += 10; - gripper.bottom = gripper.top+3; - dc.Draw3dRect( gripper, m_clrBtnHilight, m_clrBtnShadow ); - - gripper.OffsetRect(0, 4); - dc.Draw3dRect( gripper, m_clrBtnHilight, m_clrBtnShadow ); - } - -} - -void CCoolDialogBar::OnNcLButtonDblClk(UINT nHitTest, CPoint point) -{ - // TODO: Add your message handler code here and/or call default - if ((m_pDockBar != NULL) && (nHitTest == HTCAPTION)) - { - // toggle docking - ASSERT(m_pDockContext != NULL); - m_pDockContext->ToggleDocking(); - } - else - { - CWnd::OnNcLButtonDblClk(nHitTest, point); - } -} +// 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 . + +// CoolDialogBar.cpp : implementation file +// http://www.codeguru.com/docking/devstudio_like_controlbar_2.shtml + +#include "stdafx.h" +#include "afxpriv.h" // for CDockContext +#include "cool_dialog_bar.h" + +#define max(a,b) ((a>b)?a:b) +#define min(a,b) ((aCreate(nID, this); + + // JC: added patch to fix the problem with LoadBarState + SetDlgCtrlID(nID); + + // use the dialog dimensions as default base dimensions + CRect rc; + m_cDialog->GetWindowRect(rc); + m_sizeHorz = m_sizeVert = m_sizeFloat = rc.Size(); + m_sizeHorz.cy += m_cxEdge + m_cxBorder; + m_sizeVert.cx += m_cxEdge + m_cxBorder; + return TRUE; +} + +CSize CCoolDialogBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz) +{ + CRect rc; + + m_pDockSite->GetControlBar(AFX_IDW_DOCKBAR_TOP)->GetWindowRect(rc); + int nHorzDockBarWidth = bStretch ? 32767 : rc.Width() + 4; + m_pDockSite->GetControlBar(AFX_IDW_DOCKBAR_LEFT)->GetWindowRect(rc); + int nVertDockBarHeight = bStretch ? 32767 : rc.Height() + 4; + + if(IsFloating()) + return m_sizeFloat; + else if (bHorz) + return CSize(nHorzDockBarWidth, m_sizeHorz.cy); + else + return CSize(m_sizeVert.cx, nVertDockBarHeight); +} + +CSize CCoolDialogBar::CalcDynamicLayout(int nLength, DWORD dwMode) +{ + // Rob Wolpov 10/15/98 Added support for diagonal sizing + if (IsFloating()) + { + // Enable diagonal arrow cursor for resizing + GetParent()->GetParent()->ModifyStyle(MFS_4THICKFRAME,0); + } + if (dwMode & (LM_HORZDOCK | LM_VERTDOCK)) + { + SetWindowPos(NULL, 0, 0, 0, 0, + SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | + SWP_NOACTIVATE | SWP_FRAMECHANGED); + m_pDockSite->RecalcLayout(); + return CControlBar::CalcDynamicLayout(nLength,dwMode); + } + + if (dwMode & LM_MRUWIDTH) + return m_sizeFloat; + + if (dwMode & LM_COMMIT) + { + m_sizeFloat.cx = nLength; + return m_sizeFloat; + } + + // Rob Wolpov 10/15/98 Added support for diagonal sizing + if (IsFloating()) + { + RECT window_rect; + POINT cursor_pt; + + GetCursorPos(&cursor_pt); + GetParent()->GetParent()->GetWindowRect(&window_rect); + + switch (m_pDockContext->m_nHitTest) + { + case HTTOPLEFT: + m_sizeFloat.cx = max(window_rect.right - cursor_pt.x, + m_cMinWidth) - m_cxBorder; + m_sizeFloat.cy = max(window_rect.bottom - m_cCaptionSize - + cursor_pt.y,m_cMinHeight) - 1; + m_pDockContext->m_rectFrameDragHorz.top = min(cursor_pt.y, + window_rect.bottom - m_cCaptionSize - m_cMinHeight) - + m_cyBorder; + m_pDockContext->m_rectFrameDragHorz.left = min(cursor_pt.x, + window_rect.right - m_cMinWidth) - 1; + return m_sizeFloat; + + case HTTOPRIGHT: + m_sizeFloat.cx = max(cursor_pt.x - window_rect.left, + m_cMinWidth); + m_sizeFloat.cy = max(window_rect.bottom - m_cCaptionSize - + cursor_pt.y,m_cMinHeight) - 1; + m_pDockContext->m_rectFrameDragHorz.top = min(cursor_pt.y, + window_rect.bottom - m_cCaptionSize - m_cMinHeight) - + m_cyBorder; + return m_sizeFloat; + + case HTBOTTOMLEFT: + m_sizeFloat.cx = max(window_rect.right - cursor_pt.x, + m_cMinWidth) - m_cxBorder; + m_sizeFloat.cy = max(cursor_pt.y - window_rect.top - + m_cCaptionSize,m_cMinHeight); + m_pDockContext->m_rectFrameDragHorz.left = min(cursor_pt.x, + window_rect.right - m_cMinWidth) - 1; + return m_sizeFloat; + + case HTBOTTOMRIGHT: + m_sizeFloat.cx = max(cursor_pt.x - window_rect.left, + m_cMinWidth); + m_sizeFloat.cy = max(cursor_pt.y - window_rect.top - + m_cCaptionSize,m_cMinHeight); + return m_sizeFloat; + } + } + + if (dwMode & LM_LENGTHY) + return CSize(m_sizeFloat.cx, + m_sizeFloat.cy = max(m_sizeMin.cy, nLength)); + else + return CSize(max(m_sizeMin.cx, nLength), m_sizeFloat.cy); +} + +void CCoolDialogBar::OnWindowPosChanged(WINDOWPOS FAR* lpwndpos) +{ + CControlBar::OnWindowPosChanged(lpwndpos); + + if(!::IsWindow(m_hWnd) || m_cDialog==NULL) + return; + if(!::IsWindow(m_cDialog->m_hWnd)) + return; + if (m_bInRecalcNC) + { + CRect rc; + GetClientRect(rc); + m_cDialog->MoveWindow(rc); + return; + } + + // Find on which side are we docked + UINT nDockBarID = GetParent()->GetDlgCtrlID(); + + // Return if dropped at same location + if (nDockBarID == m_nDockBarID // no docking side change + && (lpwndpos->flags & SWP_NOSIZE) // no size change + && ((m_dwStyle & CBRS_BORDER_ANY) != CBRS_BORDER_ANY)) + return; + + m_nDockBarID = nDockBarID; + + // Force recalc the non-client area + m_bInRecalcNC = TRUE; + SetWindowPos(NULL, 0,0,0,0, + SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED); + m_bInRecalcNC = FALSE; +} + +BOOL CCoolDialogBar::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) +{ + if ((nHitTest != HTSIZE) || m_bTracking) + return CControlBar::OnSetCursor(pWnd, nHitTest, message); + + if (IsHorz()) + SetCursor(LoadCursor(NULL, IDC_SIZENS)); + else + SetCursor(LoadCursor(NULL, IDC_SIZEWE)); + return TRUE; +} + +///////////////////////////////////////////////////////////////////////// +// Mouse Handling +// +void CCoolDialogBar::OnLButtonUp(UINT nFlags, CPoint point) +{ + if (!m_bTracking) + CControlBar::OnLButtonUp(nFlags, point); + else + { + ClientToWnd(point); + StopTracking(TRUE); + } +} + +void CCoolDialogBar::OnMouseMove(UINT nFlags, CPoint point) +{ + if (IsFloating() || !m_bTracking) + { + CControlBar::OnMouseMove(nFlags, point); + return; + } + + CPoint cpt = m_rectTracker.CenterPoint(); + + ClientToWnd(point); + + if (IsHorz()) + { + if (cpt.y != point.y) + { + OnInvertTracker(m_rectTracker); + m_rectTracker.OffsetRect(0, point.y - cpt.y); + OnInvertTracker(m_rectTracker); + } + } + else + { + if (cpt.x != point.x) + { + OnInvertTracker(m_rectTracker); + m_rectTracker.OffsetRect(point.x - cpt.x, 0); + OnInvertTracker(m_rectTracker); + } + } +} + +void CCoolDialogBar::OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp) +{ + // Compute the rectangle of the mobile edge + GetWindowRect(m_rectBorder); + m_rectBorder = CRect(0, 0, m_rectBorder.Width(), m_rectBorder.Height()); + + DWORD dwBorderStyle = m_dwStyle | CBRS_BORDER_ANY; + + switch(m_nDockBarID) + { + case AFX_IDW_DOCKBAR_TOP: + dwBorderStyle &= ~CBRS_BORDER_BOTTOM; + lpncsp->rgrc[0].left += m_cxGripper; + lpncsp->rgrc[0].bottom += -m_cxEdge; + lpncsp->rgrc[0].top += m_cxBorder; + lpncsp->rgrc[0].right += -m_cxBorder; + m_rectBorder.top = m_rectBorder.bottom - m_cxEdge; + break; + case AFX_IDW_DOCKBAR_BOTTOM: + dwBorderStyle &= ~CBRS_BORDER_TOP; + lpncsp->rgrc[0].left += m_cxGripper; + lpncsp->rgrc[0].top += m_cxEdge; + lpncsp->rgrc[0].bottom += -m_cxBorder; + lpncsp->rgrc[0].right += -m_cxBorder; + m_rectBorder.bottom = m_rectBorder.top + m_cxEdge; + break; + case AFX_IDW_DOCKBAR_LEFT: + dwBorderStyle &= ~CBRS_BORDER_RIGHT; + lpncsp->rgrc[0].right += -m_cxEdge; + lpncsp->rgrc[0].left += m_cxBorder; + lpncsp->rgrc[0].bottom += -m_cxBorder; + lpncsp->rgrc[0].top += m_cxGripper; + m_rectBorder.left = m_rectBorder.right - m_cxEdge; + break; + case AFX_IDW_DOCKBAR_RIGHT: + dwBorderStyle &= ~CBRS_BORDER_LEFT; + lpncsp->rgrc[0].left += m_cxEdge; + lpncsp->rgrc[0].right += -m_cxBorder; + lpncsp->rgrc[0].bottom += -m_cxBorder; + lpncsp->rgrc[0].top += m_cxGripper; + m_rectBorder.right = m_rectBorder.left + m_cxEdge; + break; + default: + m_rectBorder.SetRectEmpty(); + break; + } + + SetBarStyle(dwBorderStyle); +} + +void CCoolDialogBar::OnNcPaint() +{ + EraseNonClient(); + + CWindowDC dc(this); + dc.Draw3dRect(m_rectBorder, GetSysColor(COLOR_BTNHIGHLIGHT), + GetSysColor(COLOR_BTNSHADOW)); + + DrawGripper(dc); + + CRect pRect; + GetClientRect( &pRect ); + InvalidateRect( &pRect, TRUE ); +} + +void CCoolDialogBar::OnNcLButtonDown(UINT nHitTest, CPoint point) +{ + if (m_bTracking) return; + + if((nHitTest == HTSYSMENU) && !IsFloating()) + GetDockingFrame()->ShowControlBar(this, FALSE, FALSE); + else if ((nHitTest == HTMINBUTTON) && !IsFloating()) + m_pDockContext->ToggleDocking(); + else if ((nHitTest == HTCAPTION) && !IsFloating() && (m_pDockBar != NULL)) + { + // start the drag + ASSERT(m_pDockContext != NULL); + m_pDockContext->StartDrag(point); + } + else if ((nHitTest == HTSIZE) && !IsFloating()) + StartTracking(); + else + CControlBar::OnNcLButtonDown(nHitTest, point); +} + +LRESULT CCoolDialogBar::OnNcHitTest(CPoint point) +{ + if (IsFloating()) + return CControlBar::OnNcHitTest(point); + + CRect rc; + GetWindowRect(rc); + point.Offset(-rc.left, -rc.top); + if(m_rectClose.PtInRect(point)) + return HTSYSMENU; + else if (m_rectUndock.PtInRect(point)) + return HTMINBUTTON; + else if (m_rectGripper.PtInRect(point)) + return HTCAPTION; + else if (m_rectBorder.PtInRect(point)) + return HTSIZE; + else + return CControlBar::OnNcHitTest(point); +} + +void CCoolDialogBar::OnLButtonDown(UINT nFlags, CPoint point) +{ + // only start dragging if clicked in "void" space + if (m_pDockBar != NULL) + { + // start the drag + ASSERT(m_pDockContext != NULL); + ClientToScreen(&point); + m_pDockContext->StartDrag(point); + } + else + { + CWnd::OnLButtonDown(nFlags, point); + } +} + +void CCoolDialogBar::OnLButtonDblClk(UINT nFlags, CPoint point) +{ + // only toggle docking if clicked in "void" space + if (m_pDockBar != NULL) + { + // toggle docking + ASSERT(m_pDockContext != NULL); + m_pDockContext->ToggleDocking(); + } + else + { + CWnd::OnLButtonDblClk(nFlags, point); + } +} + +void CCoolDialogBar::StartTracking() +{ + SetCapture(); + + // make sure no updates are pending + RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW); + m_pDockSite->LockWindowUpdate(); + + m_ptOld = m_rectBorder.CenterPoint(); + m_bTracking = TRUE; + + m_rectTracker = m_rectBorder; + if (!IsHorz()) m_rectTracker.bottom -= 4; + + OnInvertTracker(m_rectTracker); +} + +void CCoolDialogBar::OnCaptureChanged(CWnd *pWnd) +{ + if (m_bTracking && pWnd != this) + StopTracking(FALSE); // cancel tracking + + CControlBar::OnCaptureChanged(pWnd); +} + +void CCoolDialogBar::StopTracking(BOOL bAccept) +{ + OnInvertTracker(m_rectTracker); + m_pDockSite->UnlockWindowUpdate(); + m_bTracking = FALSE; + ReleaseCapture(); + + if (!bAccept) return; + + int maxsize, minsize, newsize; + CRect rcc; + m_pDockSite->GetWindowRect(rcc); + + newsize = IsHorz() ? m_sizeHorz.cy : m_sizeVert.cx; + maxsize = newsize + (IsHorz() ? rcc.Height() : rcc.Width()); + minsize = IsHorz() ? m_sizeMin.cy : m_sizeMin.cx; + + CPoint point = m_rectTracker.CenterPoint(); + switch (m_nDockBarID) + { + case AFX_IDW_DOCKBAR_TOP: + newsize += point.y - m_ptOld.y; break; + case AFX_IDW_DOCKBAR_BOTTOM: + newsize += -point.y + m_ptOld.y; break; + case AFX_IDW_DOCKBAR_LEFT: + newsize += point.x - m_ptOld.x; break; + case AFX_IDW_DOCKBAR_RIGHT: + newsize += -point.x + m_ptOld.x; break; + } + + newsize = max(minsize, min(maxsize, newsize)); + + if (IsHorz()) + m_sizeHorz.cy = newsize; + else + m_sizeVert.cx = newsize; + + m_pDockSite->RecalcLayout(); +} + +void CCoolDialogBar::OnInvertTracker(const CRect& rect) +{ + ASSERT_VALID(this); + ASSERT(!rect.IsRectEmpty()); + ASSERT(m_bTracking); + + CRect rct = rect, rcc, rcf; + GetWindowRect(rcc); + m_pDockSite->GetWindowRect(rcf); + + rct.OffsetRect(rcc.left - rcf.left, rcc.top - rcf.top); + rct.DeflateRect(1, 1); + + CDC *pDC = m_pDockSite->GetDCEx(NULL, + DCX_WINDOW|DCX_CACHE|DCX_LOCKWINDOWUPDATE); + + CBrush* pBrush = CDC::GetHalftoneBrush(); + HBRUSH hOldBrush = NULL; + if (pBrush != NULL) + hOldBrush = (HBRUSH)SelectObject(pDC->m_hDC, pBrush->m_hObject); + + pDC->PatBlt(rct.left, rct.top, rct.Width(), rct.Height(), PATINVERT); + + if (hOldBrush != NULL) + SelectObject(pDC->m_hDC, hOldBrush); + + m_pDockSite->ReleaseDC(pDC); +} + +BOOL CCoolDialogBar::IsHorz() const +{ + return (m_nDockBarID == AFX_IDW_DOCKBAR_TOP || + m_nDockBarID == AFX_IDW_DOCKBAR_BOTTOM); +} + +CPoint& CCoolDialogBar::ClientToWnd(CPoint& point) +{ + if (m_nDockBarID == AFX_IDW_DOCKBAR_BOTTOM) + point.y += m_cxEdge; + else if (m_nDockBarID == AFX_IDW_DOCKBAR_RIGHT) + point.x += m_cxEdge; + + return point; +} + +void CCoolDialogBar::DrawGripper(CDC & dc) +{ + // no gripper if floating + if( m_dwStyle & CBRS_FLOATING ) + return; + + // -==HACK==- + // in order to calculate the client area properly after docking, + // the client area must be recalculated twice (I have no idea why) + m_pDockSite->RecalcLayout(); + // -==END HACK==- + + CRect gripper; + GetWindowRect( gripper ); + ScreenToClient( gripper ); + gripper.OffsetRect( -gripper.left, -gripper.top ); + + if( m_dwStyle & CBRS_ORIENT_HORZ ) + { + // gripper at left + m_rectGripper.top = gripper.top + 40; + m_rectGripper.bottom = gripper.bottom; + m_rectGripper.left = gripper.left; + m_rectGripper.right = gripper.left + 20; + + // draw close box + m_rectClose.left = gripper.left + 7; + m_rectClose.right = m_rectClose.left + 12; + m_rectClose.top = gripper.top + 10; + m_rectClose.bottom = m_rectClose.top + 12; + dc.DrawFrameControl(m_rectClose, DFC_CAPTION, DFCS_CAPTIONCLOSE); + + // draw docking toggle box + m_rectUndock = m_rectClose; + m_rectUndock.OffsetRect(0,13); + dc.DrawFrameControl(m_rectUndock, DFC_CAPTION, DFCS_CAPTIONMAX); + + gripper.top += 38; + gripper.bottom -= 10; + gripper.left += 10; + gripper.right = gripper.left+3; + dc.Draw3dRect( gripper, m_clrBtnHilight, m_clrBtnShadow ); + + gripper.OffsetRect(4, 0); + dc.Draw3dRect( gripper, m_clrBtnHilight, m_clrBtnShadow ); + } + else + { + // gripper at top + m_rectGripper.top = gripper.top; + m_rectGripper.bottom = gripper.top + 20; + m_rectGripper.left = gripper.left; + m_rectGripper.right = gripper.right - 40; + + // draw close box + m_rectClose.right = gripper.right - 10; + m_rectClose.left = m_rectClose.right - 11; + m_rectClose.top = gripper.top + 7; + m_rectClose.bottom = m_rectClose.top + 11; + dc.DrawFrameControl(m_rectClose, DFC_CAPTION, DFCS_CAPTIONCLOSE); + + + // draw docking toggle box + m_rectUndock = m_rectClose; + m_rectUndock.OffsetRect(-13,0); + dc.DrawFrameControl(m_rectUndock, DFC_CAPTION, DFCS_CAPTIONMAX); + + gripper.right -= 38; + gripper.left += 10; + gripper.top += 10; + gripper.bottom = gripper.top+3; + dc.Draw3dRect( gripper, m_clrBtnHilight, m_clrBtnShadow ); + + gripper.OffsetRect(0, 4); + dc.Draw3dRect( gripper, m_clrBtnHilight, m_clrBtnShadow ); + } + +} + +void CCoolDialogBar::OnNcLButtonDblClk(UINT nHitTest, CPoint point) +{ + // TODO: Add your message handler code here and/or call default + if ((m_pDockBar != NULL) && (nHitTest == HTCAPTION)) + { + // toggle docking + ASSERT(m_pDockContext != NULL); + m_pDockContext->ToggleDocking(); + } + else + { + CWnd::OnNcLButtonDblClk(nHitTest, point); + } +} diff --git a/code/ryzom/tools/leveldesign/georges_dll/cool_dialog_bar.h b/code/ryzom/tools/leveldesign/georges_dll/cool_dialog_bar.h index 4ec6fd280..532c028dc 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/cool_dialog_bar.h +++ b/code/ryzom/tools/leveldesign/georges_dll/cool_dialog_bar.h @@ -1,121 +1,121 @@ -// 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 . - -#if !defined(AFX_COOLDIALOGBAR_H__6EB5FA61_FFAD_11D1_98D4_444553540000__INCLUDED_) -#define AFX_COOLDIALOGBAR_H__6EB5FA61_FFAD_11D1_98D4_444553540000__INCLUDED_ - -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -// CoolDialogBar.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// CCoolDialogBar window - -class CCoolDialogBar : public CControlBar -{ - const COLORREF m_clrBtnHilight; - const COLORREF m_clrBtnShadow; - - // Construction / destruction -public: - CCoolDialogBar(); - -// Attributes -public: - BOOL IsHorz() const; - -// Operations -public: - -// Overridables - virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler); - -// Overrides -public: - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CCoolDialogBar) - public: - virtual BOOL Create(CWnd* pParentWnd, CDialog *pDialog, CString &pTitle, UINT nID, DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_LEFT); - virtual CSize CalcFixedLayout( BOOL bStretch, BOOL bHorz ); - virtual CSize CalcDynamicLayout( int nLength, DWORD dwMode ); - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CCoolDialogBar(); - void StartTracking(); - void StopTracking(BOOL bAccept); - void OnInvertTracker(const CRect& rect); - - // implementation helpers - CPoint& ClientToWnd(CPoint& point); - -protected: - void DrawGripper(CDC &dc); - - CSize m_sizeMin; - CSize m_sizeHorz; - CSize m_sizeVert; - CSize m_sizeFloat; - CRect m_rectBorder; - CRect m_rectTracker; - UINT m_nDockBarID; - CPoint m_ptOld; - BOOL m_bTracking; - BOOL m_bInRecalcNC; - int m_cxEdge; - CRect m_rectUndock; - CRect m_rectClose; - CRect m_rectGripper; - int m_cxGripper; - int m_cxBorder; - CDialog* m_cDialog; - CBrush m_brushBkgd; - - // Rob Wolpov 10/15/98 Added support for diagonal resizing - int m_cyBorder; - int m_cMinWidth; - int m_cMinHeight; - int m_cCaptionSize; - -// Generated message map functions -protected: - //{{AFX_MSG(CCoolDialogBar) - afx_msg void OnLButtonUp(UINT nFlags, CPoint point); - afx_msg void OnMouseMove(UINT nFlags, CPoint point); - afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); - afx_msg void OnWindowPosChanged(WINDOWPOS FAR* lpwndpos); - afx_msg void OnNcPaint(); - afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point); - afx_msg LRESULT OnNcHitTest(CPoint point); - afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp); - afx_msg void OnLButtonDown(UINT nFlags, CPoint point); - afx_msg void OnCaptureChanged(CWnd *pWnd); - afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); - afx_msg void OnNcLButtonDblClk(UINT nHitTest, CPoint point); - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_COOLDIALOGBAR_H__6EB5FA61_FFAD_11D1_98D4_444553540000__INCLUDED_) +// 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 . + +#if !defined(AFX_COOLDIALOGBAR_H__6EB5FA61_FFAD_11D1_98D4_444553540000__INCLUDED_) +#define AFX_COOLDIALOGBAR_H__6EB5FA61_FFAD_11D1_98D4_444553540000__INCLUDED_ + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 +// CoolDialogBar.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// CCoolDialogBar window + +class CCoolDialogBar : public CControlBar +{ + const COLORREF m_clrBtnHilight; + const COLORREF m_clrBtnShadow; + + // Construction / destruction +public: + CCoolDialogBar(); + +// Attributes +public: + BOOL IsHorz() const; + +// Operations +public: + +// Overridables + virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler); + +// Overrides +public: + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CCoolDialogBar) + public: + virtual BOOL Create(CWnd* pParentWnd, CDialog *pDialog, CString &pTitle, UINT nID, DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_LEFT); + virtual CSize CalcFixedLayout( BOOL bStretch, BOOL bHorz ); + virtual CSize CalcDynamicLayout( int nLength, DWORD dwMode ); + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CCoolDialogBar(); + void StartTracking(); + void StopTracking(BOOL bAccept); + void OnInvertTracker(const CRect& rect); + + // implementation helpers + CPoint& ClientToWnd(CPoint& point); + +protected: + void DrawGripper(CDC &dc); + + CSize m_sizeMin; + CSize m_sizeHorz; + CSize m_sizeVert; + CSize m_sizeFloat; + CRect m_rectBorder; + CRect m_rectTracker; + UINT m_nDockBarID; + CPoint m_ptOld; + BOOL m_bTracking; + BOOL m_bInRecalcNC; + int m_cxEdge; + CRect m_rectUndock; + CRect m_rectClose; + CRect m_rectGripper; + int m_cxGripper; + int m_cxBorder; + CDialog* m_cDialog; + CBrush m_brushBkgd; + + // Rob Wolpov 10/15/98 Added support for diagonal resizing + int m_cyBorder; + int m_cMinWidth; + int m_cMinHeight; + int m_cCaptionSize; + +// Generated message map functions +protected: + //{{AFX_MSG(CCoolDialogBar) + afx_msg void OnLButtonUp(UINT nFlags, CPoint point); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); + afx_msg void OnWindowPosChanged(WINDOWPOS FAR* lpwndpos); + afx_msg void OnNcPaint(); + afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point); + afx_msg LRESULT OnNcHitTest(CPoint point); + afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg void OnCaptureChanged(CWnd *pWnd); + afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); + afx_msg void OnNcLButtonDblClk(UINT nHitTest, CPoint point); + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Developer Studio will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_COOLDIALOGBAR_H__6EB5FA61_FFAD_11D1_98D4_444553540000__INCLUDED_) diff --git a/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.cpp b/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.cpp index 00ffadac3..1acd105fd 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.cpp @@ -1,632 +1,632 @@ -// 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 . - -// dfn_dialog.cpp : implementation file -// - -#include "stdafx.h" -#include "georges_edit.h" -#include "georges_edit_view.h" -#include "georges_edit_doc.h" -#include "dfn_dialog.h" -#include "left_view.h" -#include "action.h" - -#include "nel/misc/path.h" -#include "nel/georges/type.h" - -using namespace std; -using namespace NLMISC; -using namespace NLGEORGES; - - -// *************************************************************************** - -CDfnDialog::CDfnDialog () : CBaseDialog (IDR_MAINFRAME) -{ - //{{AFX_DATA_INIT(CDfnDialog) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT - View = NULL; -} - -// *************************************************************************** - -void CDfnDialog::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CDfnDialog) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - -// *************************************************************************** - -BEGIN_MESSAGE_MAP(CDfnDialog, CDialog) - //{{AFX_MSG_MAP(CDfnDialog) - ON_WM_SIZE() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// *************************************************************************** - -void CDfnDialog::OnSize(UINT nType, int cx, int cy) -{ - CBaseDialog::OnSize(nType, cx, cy); - - // TODO: Add your message handler code here - -} - -// *************************************************************************** - -BOOL CDfnDialog::OnInitDialog() -{ - CBaseDialog::OnInitDialog(); - - RECT viewRect; - View->GetClientRect (&viewRect); - uint virtualWidth = std::max ((uint)MinViewWidth, (uint)(viewRect.right-viewRect.left)); - - // Refresh sizes - CBaseDialog::resizeWidgets (virtualWidth, 0); - - // Get first item coordinate - RECT currentPos; - getFirstItemPos (currentPos); - - // Create the type combo - setStaticSize (currentPos); - LabelParents.Create ("Parents:", WS_VISIBLE, currentPos, this); - initWidget (LabelParents); - getNextPosLabel (currentPos); - - setListSize (currentPos, SmallWidget, ParentHeight); - Parents.create (WS_TABSTOP, currentPos, this, LtParents); - Parents.insertColumn (0, "Parent Dfn"); - Parents.Dialog = this; - Parents.recalcColumn (); - initWidget (Parents); - getNextPos (currentPos); - - - // Create the type combo - setStaticSize (currentPos); - LabelStruct.Create ("Structure:", WS_VISIBLE, currentPos, this); - initWidget (LabelStruct); - getNextPosLabel (currentPos); - - setListSize (currentPos, Width, DfnHeight); - Struct.create (WS_TABSTOP, currentPos, this, LtStruct); - Struct.insertColumn (0, "Name"); - Struct.insertColumn (1, "Type"); - Struct.insertColumn (2, "Value"); - Struct.insertColumn (3, "Default"); - Struct.insertColumn (4, "FilenameExt"); - Struct.Dialog = this; - Struct.recalcColumn (); - initWidget (Struct); - getNextPos (currentPos); - - registerLastControl (); - - resizeWidgets (); - - UpdateData (FALSE); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -// *************************************************************************** - -void CDfnDialog::OnOK () -{ - Parents.UpdateData (); - Struct.UpdateData (); - - CWnd *focusWnd = CWnd::GetFocus (); - if (focusWnd) - { - focusWnd = focusWnd->GetParent (); - if (focusWnd) - { - if (focusWnd->m_hWnd == Parents.m_hWnd) - { - Parents.onOK (); - } - else if (focusWnd->m_hWnd == Struct.m_hWnd) - { - Struct.onOK (); - } - } - } -} - -// *************************************************************************** - -void CDfnDialog::OnCancel () -{ - CWnd *focusWnd = CWnd::GetFocus (); - if (focusWnd) - { - focusWnd = focusWnd->GetParent (); - if (focusWnd) - { - if (focusWnd->m_hWnd == Parents.m_hWnd) - { - Parents.onCancel (); - return; - } - else if (focusWnd->m_hWnd == Struct.m_hWnd) - { - Struct.onCancel (); - return; - } - } - } - CBaseDialog::OnCancel (); -} - -// *************************************************************************** - -void CDfnDialog::getFromDocument (const NLGEORGES::CFormDfn &dfn) -{ - if (View) - { - // Add the parents - Parents.ListCtrl.DeleteAllItems (); - uint parent; - for (parent=0; parentGetDocument (); - if (doc) - { - // Build a vector of string - vector vectValue (Parents.ListCtrl.GetItemCount ()); - - // For each string - uint parent; - for (parent=0; parent<(uint)Parents.ListCtrl.GetItemCount (); parent++) - { - // Add the label and value - CString str = Parents.ListCtrl.GetItemText ( parent, 0); - vectValue[parent] = str; - } - - // Modify the document - if (!doc->modify (new CActionStringVector (IAction::DfnParents, vectValue, *doc, "", doc->getLeftView ()->getCurrentSelectionId (), 0))) - getFromDocument (*doc->getDfnPtr ()); - } -} - -// *************************************************************************** - -void CDfnDialog::setStructToDocument () -{ - CGeorgesEditDoc *doc = View->GetDocument (); - if (doc) - { - // Add the entries - vector > stringVector (Struct.ListCtrl.GetItemCount ()); - uint elm; - for (elm=0; elmmodify (new CActionStringVectorVector (IAction::DfnStructure, stringVector, *doc, doc->getLeftView ()->getCurrentSelectionId (), 0)); - } -} - -// *************************************************************************** - -LRESULT CDfnDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case LC_CHANGE: - if (wParam == LtParents) - setParentsToDocument (); - else - setStructToDocument (); - break; - } - - return CDialog::WindowProc(message, wParam, lParam); -} - -// *************************************************************************** - -CEditListCtrl::TItemEdit CDfnEditListCtrl::getItemEditMode (uint item, uint subItem) -{ - if (subItem == 0) - return CEditListCtrl::EditMemCombo; - else if (subItem == 1) - return CEditListCtrl::EditFixedCombo; - else if (subItem == 2) - { - string type = ListCtrl.GetItemText (item, 1); - if (type != "Virtual Dfn") - return CEditListCtrl::EditMemCombo; - } - else if (subItem == 3) - { - string type = ListCtrl.GetItemText (item, 1); - if ((type == "Type") || (type == "Type array")) - return CEditListCtrl::EditMemCombo; - } - else if (subItem == 4) - { - string type = ListCtrl.GetItemText (item, 1); - if ((type == "Type") || (type == "Type array")) - return CEditListCtrl::EditMemCombo; - } - return CEditListCtrl::NoEdit; -} - -// *************************************************************************** - -void CDfnEditListCtrl::getComboBoxStrings (uint item, uint subItem, std::vector &retStrings) -{ - if (subItem == 1) - { - retStrings.reserve (5); - retStrings.push_back ("Type"); - retStrings.push_back ("Dfn"); - retStrings.push_back ("Virtual Dfn"); - retStrings.push_back ("Type array"); - retStrings.push_back ("Dfn array"); - } -} - -// *************************************************************************** - -void CDfnEditListCtrl::getMemComboBoxProp (uint item, uint subItem, std::string ®Adr, bool &browse) -{ - if (subItem == 0) - { - browse = false; - regAdr = GEORGES_EDIT_BASE_REG_KEY"\\Label MemCombo"; - } - else if (subItem == 2) - { - browse = true; - - // Get type string - string type = ListCtrl.GetItemText (item, 1); - if ((type == "Type") || (type == "Type array")) - regAdr = GEORGES_EDIT_BASE_REG_KEY"\\Type MemCombo"; - else if ((type == "Dfn") || (type == "Dfn array")) - regAdr = GEORGES_EDIT_BASE_REG_KEY"\\Dfn MemCombo"; - } - else if (subItem == 3) - { - browse = false; - regAdr = GEORGES_EDIT_BASE_REG_KEY"\\Default MemCombo"; - } - else if (subItem == 3) - { - browse = false; - regAdr = GEORGES_EDIT_BASE_REG_KEY"\\FilenameExt MemCombo"; - } -} - -// *************************************************************************** - -void CDfnEditListCtrl::getNewItemText (uint item, uint subItem, std::string &ret) -{ - if (subItem == 0) - ret = "new"; - else if (subItem == 1) - ret = "Type"; - else if (subItem == 2) - ret = theApp.DefaultType; - else if (subItem == 3) - ret = ""; - else if (subItem == 4) - ret = ""; -} - -// *************************************************************************** - -void CDfnEditListCtrl::getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::string &filter) -{ - if (subItem == 2) - { - // Get type string - string type = ListCtrl.GetItemText (item, 1); - if ((type == "Type") || (type == "Type array")) - { - filter = TypeFilter; - defDir = theApp.RootSearchPath; - defFilename = "*.typ"; - defExt = "*.typ"; - } - else if ((type == "Dfn") || (type == "Dfn array")) - { - filter = DfnFilter; - defDir = theApp.RootSearchPath; - defFilename = "*.dfn"; - defExt = "*.dfn"; - } - } -} - -// *************************************************************************** - -void CDfnEditListCtrl::onItemChanged (uint item, uint subItem) -{ - if (subItem == 1) - { - // Get type string - string type = ListCtrl.GetItemText (item, 1); - if ((type == "Type") || (type == "Type array")) - { - CString str; - str = Dialog->Struct.ListCtrl.GetItemText (item, 2); - char ext[MAX_PATH]; - _splitpath (str, NULL, NULL, NULL, ext); - if (stricmp (ext, ".typ") != 0) - Dialog->Struct.ListCtrl.SetItemText (item, 2, theApp.DefaultType.c_str ()); - } - else if ((type == "Dfn") || (type == "Dfn array")) - { - CString str; - str = Dialog->Struct.ListCtrl.GetItemText (item, 2); - char ext[MAX_PATH]; - _splitpath (str, NULL, NULL, NULL, ext); - if (stricmp (ext, ".dfn") != 0) - Dialog->Struct.ListCtrl.SetItemText (item, 2, theApp.DefaultDfn.c_str ()); - - // Clear default value - Dialog->Struct.ListCtrl.SetItemText (item, 3, ""); - } - else if (type == "Virtual Dfn") - { - // Clear the value - Dialog->Struct.ListCtrl.SetItemText (item, 2, ""); - - // Clear default value - Dialog->Struct.ListCtrl.SetItemText (item, 3, ""); - } - } -} - -// *************************************************************************** - -void CDfnDialog::onOpenSelected () -{ - Parents.UpdateData (); - Struct.UpdateData (); - - CWnd *focusWnd = CWnd::GetFocus (); - if (focusWnd) - { - focusWnd = focusWnd->GetParent (); - if (focusWnd) - { - if (focusWnd->m_hWnd == Parents.m_hWnd) - { - // For each selected - POSITION pos = Parents.ListCtrl.GetFirstSelectedItemPosition(); - while (pos) - { - int nItem = Parents.ListCtrl.GetNextSelectedItem(pos); - - // Get the string - CString str = Parents.ListCtrl.GetItemText (nItem, 0); - if (str != "") - { - // Look for the file - string name = CPath::lookup ((const char*)str, false, false); - if (name.empty ()) - name = str; - - // Open the file - theApp.OpenDocumentFile (name.c_str ()); - } - } - } - else if (focusWnd->m_hWnd == Struct.m_hWnd) - { - // For each selected - POSITION pos = Struct.ListCtrl.GetFirstSelectedItemPosition(); - while (pos) - { - int nItem = Struct.ListCtrl.GetNextSelectedItem(pos); - - // Get the string - CString str = Struct.ListCtrl.GetItemText (nItem, 2); - if (str != "") - { - // Look for the file - string name = CPath::lookup ((const char*)str, false, false); - if (name.empty ()) - name = str; - - // Open the file - theApp.OpenDocumentFile (name.c_str ()); - } - } - } - } - } -} - -// *************************************************************************** - -void CDfnDialog::OnSetFocus(CWnd* pOldWnd) -{ - CBaseDialog::OnSetFocus(pOldWnd); -} - -// *************************************************************************** - -CWnd* CDfnDialog::GetNextDlgTabItem( CWnd* pWndCtl, BOOL bPrevious) const -{ - return NULL; -} - -// *************************************************************************** - -void CDfnDialog::onFirstFocus () -{ - View->SetFocus (); -} - -// *************************************************************************** - -void CDfnDialog::onLastFocus () -{ - View->setFocusLeftView (); -} - -// *************************************************************************** - -void CDfnDialog::resizeWidgets () -{ - RECT viewRect; - View->GetClientRect (&viewRect); - uint virtualWidth = std::max ((uint)MinViewWidth, (uint)(viewRect.right-viewRect.left)); - - // Refresh sizes - CBaseDialog::resizeWidgets (virtualWidth, 0); - - // Get first item coordinate - RECT currentPos; - getFirstItemPos (currentPos); - setStaticSize (currentPos); - getNextPosLabel (currentPos); - setListSize (currentPos, SmallWidget, ParentHeight); - getNextPos (currentPos); - setStaticSize (currentPos); - getNextPosLabel (currentPos); - setListSize (currentPos, Width, DfnHeight); - getNextPos (currentPos); - - // Refresh sizes - CBaseDialog::resizeWidgets (virtualWidth, currentPos.bottom); - - // Get first item coordinate - currentPos; - getFirstItemPos (currentPos); - - // Create the type combo - setStaticSize (currentPos); - LabelParents.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - getNextPosLabel (currentPos); - - setListSize (currentPos, SmallWidget, ParentHeight); - Parents.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - Parents.recalcColumn (); - getNextPos (currentPos); - - // Create the type combo - setStaticSize (currentPos); - LabelStruct.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - getNextPosLabel (currentPos); - - setListSize (currentPos, Width, DfnHeight + AdjusteHeight); - Struct.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - Struct.recalcColumn (); - getNextPos (currentPos); - - // Resize the current view - View->setViewSize ( - virtualWidth, - currentPos.bottom+CGeorgesEditView::WidgetTopMargin+CGeorgesEditView::WidgetBottomMargin); -} - -// *************************************************************************** -// CDfnParentEditListCtrl -// *************************************************************************** - -CEditListCtrl::TItemEdit CDfnParentEditListCtrl::getItemEditMode (uint item, uint subItem) -{ - return CEditListCtrl::EditMemCombo; -} - -// *************************************************************************** - -void CDfnParentEditListCtrl::getMemComboBoxProp (uint item, uint subItem, std::string ®Adr, bool &browse) -{ - browse = true; - regAdr = GEORGES_EDIT_BASE_REG_KEY"\\Dfn MemCombo"; -} - -// *************************************************************************** - -void CDfnParentEditListCtrl::getNewItemText (uint item, uint subItem, std::string &ret) -{ - ret = theApp.DefaultDfn; -} - -// *************************************************************************** - -void CDfnParentEditListCtrl::getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::string &filter) -{ - filter = DfnFilter; - defDir = theApp.RootSearchPath; - defFilename = "*.dfn"; - defExt = "*.dfn"; -} +// 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 . + +// dfn_dialog.cpp : implementation file +// + +#include "stdafx.h" +#include "georges_edit.h" +#include "georges_edit_view.h" +#include "georges_edit_doc.h" +#include "dfn_dialog.h" +#include "left_view.h" +#include "action.h" + +#include "nel/misc/path.h" +#include "nel/georges/type.h" + +using namespace std; +using namespace NLMISC; +using namespace NLGEORGES; + + +// *************************************************************************** + +CDfnDialog::CDfnDialog () : CBaseDialog (IDR_MAINFRAME) +{ + //{{AFX_DATA_INIT(CDfnDialog) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + View = NULL; +} + +// *************************************************************************** + +void CDfnDialog::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CDfnDialog) + // NOTE: the ClassWizard will add DDX and DDV calls here + //}}AFX_DATA_MAP +} + +// *************************************************************************** + +BEGIN_MESSAGE_MAP(CDfnDialog, CDialog) + //{{AFX_MSG_MAP(CDfnDialog) + ON_WM_SIZE() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +// *************************************************************************** + +void CDfnDialog::OnSize(UINT nType, int cx, int cy) +{ + CBaseDialog::OnSize(nType, cx, cy); + + // TODO: Add your message handler code here + +} + +// *************************************************************************** + +BOOL CDfnDialog::OnInitDialog() +{ + CBaseDialog::OnInitDialog(); + + RECT viewRect; + View->GetClientRect (&viewRect); + uint virtualWidth = std::max ((uint)MinViewWidth, (uint)(viewRect.right-viewRect.left)); + + // Refresh sizes + CBaseDialog::resizeWidgets (virtualWidth, 0); + + // Get first item coordinate + RECT currentPos; + getFirstItemPos (currentPos); + + // Create the type combo + setStaticSize (currentPos); + LabelParents.Create ("Parents:", WS_VISIBLE, currentPos, this); + initWidget (LabelParents); + getNextPosLabel (currentPos); + + setListSize (currentPos, SmallWidget, ParentHeight); + Parents.create (WS_TABSTOP, currentPos, this, LtParents); + Parents.insertColumn (0, "Parent Dfn"); + Parents.Dialog = this; + Parents.recalcColumn (); + initWidget (Parents); + getNextPos (currentPos); + + + // Create the type combo + setStaticSize (currentPos); + LabelStruct.Create ("Structure:", WS_VISIBLE, currentPos, this); + initWidget (LabelStruct); + getNextPosLabel (currentPos); + + setListSize (currentPos, Width, DfnHeight); + Struct.create (WS_TABSTOP, currentPos, this, LtStruct); + Struct.insertColumn (0, "Name"); + Struct.insertColumn (1, "Type"); + Struct.insertColumn (2, "Value"); + Struct.insertColumn (3, "Default"); + Struct.insertColumn (4, "FilenameExt"); + Struct.Dialog = this; + Struct.recalcColumn (); + initWidget (Struct); + getNextPos (currentPos); + + registerLastControl (); + + resizeWidgets (); + + UpdateData (FALSE); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +// *************************************************************************** + +void CDfnDialog::OnOK () +{ + Parents.UpdateData (); + Struct.UpdateData (); + + CWnd *focusWnd = CWnd::GetFocus (); + if (focusWnd) + { + focusWnd = focusWnd->GetParent (); + if (focusWnd) + { + if (focusWnd->m_hWnd == Parents.m_hWnd) + { + Parents.onOK (); + } + else if (focusWnd->m_hWnd == Struct.m_hWnd) + { + Struct.onOK (); + } + } + } +} + +// *************************************************************************** + +void CDfnDialog::OnCancel () +{ + CWnd *focusWnd = CWnd::GetFocus (); + if (focusWnd) + { + focusWnd = focusWnd->GetParent (); + if (focusWnd) + { + if (focusWnd->m_hWnd == Parents.m_hWnd) + { + Parents.onCancel (); + return; + } + else if (focusWnd->m_hWnd == Struct.m_hWnd) + { + Struct.onCancel (); + return; + } + } + } + CBaseDialog::OnCancel (); +} + +// *************************************************************************** + +void CDfnDialog::getFromDocument (const NLGEORGES::CFormDfn &dfn) +{ + if (View) + { + // Add the parents + Parents.ListCtrl.DeleteAllItems (); + uint parent; + for (parent=0; parentGetDocument (); + if (doc) + { + // Build a vector of string + vector vectValue (Parents.ListCtrl.GetItemCount ()); + + // For each string + uint parent; + for (parent=0; parent<(uint)Parents.ListCtrl.GetItemCount (); parent++) + { + // Add the label and value + CString str = Parents.ListCtrl.GetItemText ( parent, 0); + vectValue[parent] = str; + } + + // Modify the document + if (!doc->modify (new CActionStringVector (IAction::DfnParents, vectValue, *doc, "", doc->getLeftView ()->getCurrentSelectionId (), 0))) + getFromDocument (*doc->getDfnPtr ()); + } +} + +// *************************************************************************** + +void CDfnDialog::setStructToDocument () +{ + CGeorgesEditDoc *doc = View->GetDocument (); + if (doc) + { + // Add the entries + vector > stringVector (Struct.ListCtrl.GetItemCount ()); + uint elm; + for (elm=0; elmmodify (new CActionStringVectorVector (IAction::DfnStructure, stringVector, *doc, doc->getLeftView ()->getCurrentSelectionId (), 0)); + } +} + +// *************************************************************************** + +LRESULT CDfnDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case LC_CHANGE: + if (wParam == LtParents) + setParentsToDocument (); + else + setStructToDocument (); + break; + } + + return CDialog::WindowProc(message, wParam, lParam); +} + +// *************************************************************************** + +CEditListCtrl::TItemEdit CDfnEditListCtrl::getItemEditMode (uint item, uint subItem) +{ + if (subItem == 0) + return CEditListCtrl::EditMemCombo; + else if (subItem == 1) + return CEditListCtrl::EditFixedCombo; + else if (subItem == 2) + { + string type = ListCtrl.GetItemText (item, 1); + if (type != "Virtual Dfn") + return CEditListCtrl::EditMemCombo; + } + else if (subItem == 3) + { + string type = ListCtrl.GetItemText (item, 1); + if ((type == "Type") || (type == "Type array")) + return CEditListCtrl::EditMemCombo; + } + else if (subItem == 4) + { + string type = ListCtrl.GetItemText (item, 1); + if ((type == "Type") || (type == "Type array")) + return CEditListCtrl::EditMemCombo; + } + return CEditListCtrl::NoEdit; +} + +// *************************************************************************** + +void CDfnEditListCtrl::getComboBoxStrings (uint item, uint subItem, std::vector &retStrings) +{ + if (subItem == 1) + { + retStrings.reserve (5); + retStrings.push_back ("Type"); + retStrings.push_back ("Dfn"); + retStrings.push_back ("Virtual Dfn"); + retStrings.push_back ("Type array"); + retStrings.push_back ("Dfn array"); + } +} + +// *************************************************************************** + +void CDfnEditListCtrl::getMemComboBoxProp (uint item, uint subItem, std::string ®Adr, bool &browse) +{ + if (subItem == 0) + { + browse = false; + regAdr = GEORGES_EDIT_BASE_REG_KEY"\\Label MemCombo"; + } + else if (subItem == 2) + { + browse = true; + + // Get type string + string type = ListCtrl.GetItemText (item, 1); + if ((type == "Type") || (type == "Type array")) + regAdr = GEORGES_EDIT_BASE_REG_KEY"\\Type MemCombo"; + else if ((type == "Dfn") || (type == "Dfn array")) + regAdr = GEORGES_EDIT_BASE_REG_KEY"\\Dfn MemCombo"; + } + else if (subItem == 3) + { + browse = false; + regAdr = GEORGES_EDIT_BASE_REG_KEY"\\Default MemCombo"; + } + else if (subItem == 3) + { + browse = false; + regAdr = GEORGES_EDIT_BASE_REG_KEY"\\FilenameExt MemCombo"; + } +} + +// *************************************************************************** + +void CDfnEditListCtrl::getNewItemText (uint item, uint subItem, std::string &ret) +{ + if (subItem == 0) + ret = "new"; + else if (subItem == 1) + ret = "Type"; + else if (subItem == 2) + ret = theApp.DefaultType; + else if (subItem == 3) + ret = ""; + else if (subItem == 4) + ret = ""; +} + +// *************************************************************************** + +void CDfnEditListCtrl::getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::string &filter) +{ + if (subItem == 2) + { + // Get type string + string type = ListCtrl.GetItemText (item, 1); + if ((type == "Type") || (type == "Type array")) + { + filter = TypeFilter; + defDir = theApp.RootSearchPath; + defFilename = "*.typ"; + defExt = "*.typ"; + } + else if ((type == "Dfn") || (type == "Dfn array")) + { + filter = DfnFilter; + defDir = theApp.RootSearchPath; + defFilename = "*.dfn"; + defExt = "*.dfn"; + } + } +} + +// *************************************************************************** + +void CDfnEditListCtrl::onItemChanged (uint item, uint subItem) +{ + if (subItem == 1) + { + // Get type string + string type = ListCtrl.GetItemText (item, 1); + if ((type == "Type") || (type == "Type array")) + { + CString str; + str = Dialog->Struct.ListCtrl.GetItemText (item, 2); + char ext[MAX_PATH]; + _splitpath (str, NULL, NULL, NULL, ext); + if (stricmp (ext, ".typ") != 0) + Dialog->Struct.ListCtrl.SetItemText (item, 2, theApp.DefaultType.c_str ()); + } + else if ((type == "Dfn") || (type == "Dfn array")) + { + CString str; + str = Dialog->Struct.ListCtrl.GetItemText (item, 2); + char ext[MAX_PATH]; + _splitpath (str, NULL, NULL, NULL, ext); + if (stricmp (ext, ".dfn") != 0) + Dialog->Struct.ListCtrl.SetItemText (item, 2, theApp.DefaultDfn.c_str ()); + + // Clear default value + Dialog->Struct.ListCtrl.SetItemText (item, 3, ""); + } + else if (type == "Virtual Dfn") + { + // Clear the value + Dialog->Struct.ListCtrl.SetItemText (item, 2, ""); + + // Clear default value + Dialog->Struct.ListCtrl.SetItemText (item, 3, ""); + } + } +} + +// *************************************************************************** + +void CDfnDialog::onOpenSelected () +{ + Parents.UpdateData (); + Struct.UpdateData (); + + CWnd *focusWnd = CWnd::GetFocus (); + if (focusWnd) + { + focusWnd = focusWnd->GetParent (); + if (focusWnd) + { + if (focusWnd->m_hWnd == Parents.m_hWnd) + { + // For each selected + POSITION pos = Parents.ListCtrl.GetFirstSelectedItemPosition(); + while (pos) + { + int nItem = Parents.ListCtrl.GetNextSelectedItem(pos); + + // Get the string + CString str = Parents.ListCtrl.GetItemText (nItem, 0); + if (str != "") + { + // Look for the file + string name = CPath::lookup ((const char*)str, false, false); + if (name.empty ()) + name = str; + + // Open the file + theApp.OpenDocumentFile (name.c_str ()); + } + } + } + else if (focusWnd->m_hWnd == Struct.m_hWnd) + { + // For each selected + POSITION pos = Struct.ListCtrl.GetFirstSelectedItemPosition(); + while (pos) + { + int nItem = Struct.ListCtrl.GetNextSelectedItem(pos); + + // Get the string + CString str = Struct.ListCtrl.GetItemText (nItem, 2); + if (str != "") + { + // Look for the file + string name = CPath::lookup ((const char*)str, false, false); + if (name.empty ()) + name = str; + + // Open the file + theApp.OpenDocumentFile (name.c_str ()); + } + } + } + } + } +} + +// *************************************************************************** + +void CDfnDialog::OnSetFocus(CWnd* pOldWnd) +{ + CBaseDialog::OnSetFocus(pOldWnd); +} + +// *************************************************************************** + +CWnd* CDfnDialog::GetNextDlgTabItem( CWnd* pWndCtl, BOOL bPrevious) const +{ + return NULL; +} + +// *************************************************************************** + +void CDfnDialog::onFirstFocus () +{ + View->SetFocus (); +} + +// *************************************************************************** + +void CDfnDialog::onLastFocus () +{ + View->setFocusLeftView (); +} + +// *************************************************************************** + +void CDfnDialog::resizeWidgets () +{ + RECT viewRect; + View->GetClientRect (&viewRect); + uint virtualWidth = std::max ((uint)MinViewWidth, (uint)(viewRect.right-viewRect.left)); + + // Refresh sizes + CBaseDialog::resizeWidgets (virtualWidth, 0); + + // Get first item coordinate + RECT currentPos; + getFirstItemPos (currentPos); + setStaticSize (currentPos); + getNextPosLabel (currentPos); + setListSize (currentPos, SmallWidget, ParentHeight); + getNextPos (currentPos); + setStaticSize (currentPos); + getNextPosLabel (currentPos); + setListSize (currentPos, Width, DfnHeight); + getNextPos (currentPos); + + // Refresh sizes + CBaseDialog::resizeWidgets (virtualWidth, currentPos.bottom); + + // Get first item coordinate + currentPos; + getFirstItemPos (currentPos); + + // Create the type combo + setStaticSize (currentPos); + LabelParents.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + getNextPosLabel (currentPos); + + setListSize (currentPos, SmallWidget, ParentHeight); + Parents.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + Parents.recalcColumn (); + getNextPos (currentPos); + + // Create the type combo + setStaticSize (currentPos); + LabelStruct.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + getNextPosLabel (currentPos); + + setListSize (currentPos, Width, DfnHeight + AdjusteHeight); + Struct.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + Struct.recalcColumn (); + getNextPos (currentPos); + + // Resize the current view + View->setViewSize ( + virtualWidth, + currentPos.bottom+CGeorgesEditView::WidgetTopMargin+CGeorgesEditView::WidgetBottomMargin); +} + +// *************************************************************************** +// CDfnParentEditListCtrl +// *************************************************************************** + +CEditListCtrl::TItemEdit CDfnParentEditListCtrl::getItemEditMode (uint item, uint subItem) +{ + return CEditListCtrl::EditMemCombo; +} + +// *************************************************************************** + +void CDfnParentEditListCtrl::getMemComboBoxProp (uint item, uint subItem, std::string ®Adr, bool &browse) +{ + browse = true; + regAdr = GEORGES_EDIT_BASE_REG_KEY"\\Dfn MemCombo"; +} + +// *************************************************************************** + +void CDfnParentEditListCtrl::getNewItemText (uint item, uint subItem, std::string &ret) +{ + ret = theApp.DefaultDfn; +} + +// *************************************************************************** + +void CDfnParentEditListCtrl::getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::string &filter) +{ + filter = DfnFilter; + defDir = theApp.RootSearchPath; + defFilename = "*.dfn"; + defExt = "*.dfn"; +} diff --git a/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.h b/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.h index 8ee0aaf3c..174001aaa 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.h +++ b/code/ryzom/tools/leveldesign/georges_dll/dfn_dialog.h @@ -1,132 +1,132 @@ -// 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 . - -#if !defined(DFN_TYPE_H_INCLUDED) -#define DFN_TYPE_H_INCLUDED - -#include "base_dialog.h" -#include "edit_list_ctrl.h" - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// dfn_dialog.h : header file -// - -class CGeorgesEditView; - -///////////////////////////////////////////////////////////////////////////// -// CDfnDialog dialog - -class CDfnParentEditListCtrl : public CEditListCtrl -{ - CEditListCtrl::TItemEdit getItemEditMode (uint item, uint subItem); - void getMemComboBoxProp (uint item, uint subItem, std::string ®Adr, bool &browse); - void getNewItemText (uint item, uint subItem, std::string &ret); - void getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::string &filter); -public: - class CDfnDialog *Dialog; -}; - -class CDfnEditListCtrl : public CEditListCtrl -{ - CEditListCtrl::TItemEdit getItemEditMode (uint item, uint subItem); - void getComboBoxStrings (uint item, uint subItem, std::vector &retStrings); - void getMemComboBoxProp (uint item, uint subItem, std::string ®Adr, bool &browse); - void getNewItemText (uint item, uint subItem, std::string &ret); - void getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::string &filter); - void onItemChanged (uint item, uint subItem); -public: - class CDfnDialog *Dialog; -}; - -/** - * The dialog class for a DFN edition right window. - */ -class CDfnDialog : public CBaseDialog -{ -// Construction -public: - CDfnDialog (); // standard constructor - - enum - { - TypeCombo= 100, - }; - - enum - { - LtParents, - LtStruct, - }; - - enum - { - ParentHeight = 80, - DfnHeight = 80, - }; - - // The widgets - CStatic LabelParents; - CDfnParentEditListCtrl Parents; - CStatic LabelStruct; - CDfnEditListCtrl Struct; - - // From CDialog - virtual void OnOK (); - virtual void OnCancel (); - - // From CBaseDialog - void onOpenSelected (); - void onFirstFocus (); - void onLastFocus (); - - // Get from document, update rightview UI - void getFromDocument (const NLGEORGES::CFormDfn &type); - - // Set to document, update document with rightview UI - void setParentsToDocument (); - void setStructToDocument (); - - // Resize widget callback - void resizeWidgets (); - - CWnd* GetNextDlgTabItem( CWnd* pWndCtl, BOOL bPrevious = FALSE ) const; - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CDfnDialog) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CDfnDialog) - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg BOOL OnInitDialog(); - afx_msg void OnSetFocus(CWnd* pOldWnd); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(DFN_TYPE_H_INCLUDED) +// 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 . + +#if !defined(DFN_TYPE_H_INCLUDED) +#define DFN_TYPE_H_INCLUDED + +#include "base_dialog.h" +#include "edit_list_ctrl.h" + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// dfn_dialog.h : header file +// + +class CGeorgesEditView; + +///////////////////////////////////////////////////////////////////////////// +// CDfnDialog dialog + +class CDfnParentEditListCtrl : public CEditListCtrl +{ + CEditListCtrl::TItemEdit getItemEditMode (uint item, uint subItem); + void getMemComboBoxProp (uint item, uint subItem, std::string ®Adr, bool &browse); + void getNewItemText (uint item, uint subItem, std::string &ret); + void getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::string &filter); +public: + class CDfnDialog *Dialog; +}; + +class CDfnEditListCtrl : public CEditListCtrl +{ + CEditListCtrl::TItemEdit getItemEditMode (uint item, uint subItem); + void getComboBoxStrings (uint item, uint subItem, std::vector &retStrings); + void getMemComboBoxProp (uint item, uint subItem, std::string ®Adr, bool &browse); + void getNewItemText (uint item, uint subItem, std::string &ret); + void getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::string &filter); + void onItemChanged (uint item, uint subItem); +public: + class CDfnDialog *Dialog; +}; + +/** + * The dialog class for a DFN edition right window. + */ +class CDfnDialog : public CBaseDialog +{ +// Construction +public: + CDfnDialog (); // standard constructor + + enum + { + TypeCombo= 100, + }; + + enum + { + LtParents, + LtStruct, + }; + + enum + { + ParentHeight = 80, + DfnHeight = 80, + }; + + // The widgets + CStatic LabelParents; + CDfnParentEditListCtrl Parents; + CStatic LabelStruct; + CDfnEditListCtrl Struct; + + // From CDialog + virtual void OnOK (); + virtual void OnCancel (); + + // From CBaseDialog + void onOpenSelected (); + void onFirstFocus (); + void onLastFocus (); + + // Get from document, update rightview UI + void getFromDocument (const NLGEORGES::CFormDfn &type); + + // Set to document, update document with rightview UI + void setParentsToDocument (); + void setStructToDocument (); + + // Resize widget callback + void resizeWidgets (); + + CWnd* GetNextDlgTabItem( CWnd* pWndCtl, BOOL bPrevious = FALSE ) const; + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CDfnDialog) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CDfnDialog) + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg BOOL OnInitDialog(); + afx_msg void OnSetFocus(CWnd* pOldWnd); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(DFN_TYPE_H_INCLUDED) diff --git a/code/ryzom/tools/leveldesign/georges_dll/displayer.cpp b/code/ryzom/tools/leveldesign/georges_dll/displayer.cpp index 334e8ef4f..f8c948095 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/displayer.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/displayer.cpp @@ -1,45 +1,45 @@ -// 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 "stdafx.h" -#include "displayer.h" -#include "georges_edit.h" -#include "main_frm.h" - -using namespace std; -using namespace NLMISC; - -CGeorgesDisplayer::CGeorgesDisplayer () : IDisplayer ("Georges edit output console") -{ -} - -void CGeorgesDisplayer::doDisplay( const CLog::TDisplayInfo& args, const char *message) -{ - string temp; - uint size = strlen (message); - temp.reserve (2*size); - bool previousR=false; - for (uint c=0; coutputConsoleString (temp.c_str ()); -} +// 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 "stdafx.h" +#include "displayer.h" +#include "georges_edit.h" +#include "main_frm.h" + +using namespace std; +using namespace NLMISC; + +CGeorgesDisplayer::CGeorgesDisplayer () : IDisplayer ("Georges edit output console") +{ +} + +void CGeorgesDisplayer::doDisplay( const CLog::TDisplayInfo& args, const char *message) +{ + string temp; + uint size = strlen (message); + temp.reserve (2*size); + bool previousR=false; + for (uint c=0; coutputConsoleString (temp.c_str ()); +} diff --git a/code/ryzom/tools/leveldesign/georges_dll/displayer.h b/code/ryzom/tools/leveldesign/georges_dll/displayer.h index db1fbd8df..1662234e5 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/displayer.h +++ b/code/ryzom/tools/leveldesign/georges_dll/displayer.h @@ -1,33 +1,33 @@ -// 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 GEOREGES_EDIT_DISPLAYER_H -#define GEOREGES_EDIT_DISPLAYER_H - -#include "nel/misc/displayer.h" - -class CGeorgesDisplayer : public NLMISC::IDisplayer -{ -public: - // Constructor - CGeorgesDisplayer (); - -protected: - // From IDisplayer - virtual void doDisplay( const NLMISC::CLog::TDisplayInfo& args, const char *message); -}; - -#endif // GEOREGES_EDIT_DISPLAYER_H +// 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 GEOREGES_EDIT_DISPLAYER_H +#define GEOREGES_EDIT_DISPLAYER_H + +#include "nel/misc/displayer.h" + +class CGeorgesDisplayer : public NLMISC::IDisplayer +{ +public: + // Constructor + CGeorgesDisplayer (); + +protected: + // From IDisplayer + virtual void doDisplay( const NLMISC::CLog::TDisplayInfo& args, const char *message); +}; + +#endif // GEOREGES_EDIT_DISPLAYER_H diff --git a/code/ryzom/tools/leveldesign/georges_dll/edit_list_ctrl.cpp b/code/ryzom/tools/leveldesign/georges_dll/edit_list_ctrl.cpp index 8a6c2a10a..8e565dd5e 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/edit_list_ctrl.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/edit_list_ctrl.cpp @@ -1,568 +1,568 @@ -// 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 . - -// edit_list_ctrl.cpp : implementation file -// - -#include "stdafx.h" -#include "georges_edit.h" -#include "edit_list_ctrl.h" - -using namespace std; - -///////////////////////////////////////////////////////////////////////////// -// CEditListCtrl - -CEditListCtrl::CEditListCtrl() -{ - ListCtrl.Ctrl = this; - ColumnCount = 0; - OnBrowse = false; -} - -CEditListCtrl::~CEditListCtrl() -{ -} - -bool CEditListCtrl::create (DWORD wStyle, RECT &rect, CWnd *parent, uint dialog_index) -{ - DlgIndex = dialog_index; - - // Register window class - LPCTSTR className = AfxRegisterWndClass( 0 ); - - // Create this window - if (CWnd::Create (className, "empty", WS_CHILD|wStyle, rect, parent, dialog_index)) - { - RECT subRect; - subRect.left = 0; - subRect.top = 0; - subRect.right = rect.right-rect.left; - subRect.bottom = rect.bottom-rect.top; -#if defined(NL_COMP_VC8) || defined(NL_COMP_VC9) - if (ListCtrl.CreateEx ( WS_EX_CLIENTEDGE, /*WC_LISTVIEW, "",*/ WS_CHILD|LVS_REPORT, subRect, this, 0)) -#else - if (ListCtrl.CreateEx ( WS_EX_CLIENTEDGE, WC_LISTVIEW, "", WS_CHILD|LVS_REPORT, subRect, this, 0)) -#endif - { - ListCtrl.ShowWindow ( SW_SHOW ); - - RECT rect; - rect.left = 0; - rect.top = 0; - rect.right = 100; - rect.bottom = 100; - Edit.Create (WS_BORDER, rect, &ListCtrl, 0); - Edit.SetFont (ListCtrl.GetFont()); - Combo.Create (WS_BORDER|CBS_DROPDOWNLIST, rect, &ListCtrl, IdCombo); - Combo.SetFont (ListCtrl.GetFont()); - MemCombo.create (WS_CHILD, rect, &ListCtrl, IdMemCombo, "", theApp.RememberListSize); - MemCombo.SetFont (ListCtrl.GetFont()); - return true; - } - } - - return false; -} - -BEGIN_MESSAGE_MAP(CEditListCtrl, CWnd) - //{{AFX_MSG_MAP(CEditListCtrl) - ON_WM_SHOWWINDOW() - ON_WM_SETFOCUS() - ON_WM_KEYDOWN() - ON_WM_SYSKEYDOWN() - ON_WM_SIZE() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - -///////////////////////////////////////////////////////////////////////////// -// CEditListCtrl message handlers - - -BOOL CEditListCtrl::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) -{ - // Item double click ? - UpdateData (); - - NMHDR *gPtr = (NMHDR*)lParam; - switch (gPtr->code) - { - case NM_DBLCLK: - { - LPNMLISTVIEW ptr = (LPNMLISTVIEW)lParam; - // Get the item - SubItem = ptr->iSubItem; - for (Item =0; Item<(uint)ListCtrl.GetItemCount(); Item++) - { - CRect ref; - ListCtrl.GetItemRect( Item, ref, LVIR_BOUNDS ); - if ((ref.top <= ptr->ptAction.y) && (ref.bottom >= ptr->ptAction.y)) - break; - } - if (Item != (uint)ListCtrl.GetItemCount ()) - { - editItem (Item, SubItem); - } - else - { - // Insert an item at the end - string text; - getNewItemText (ListCtrl.GetItemCount (), 0, text); - ListCtrl.InsertItem (ListCtrl.GetItemCount (), text.c_str ()); - for (uint i=1; iwVKey) - { - case VK_INSERT: - { - POSITION pos = ListCtrl.GetFirstSelectedItemPosition(); - int item = 0; - if (pos) - { - item = ListCtrl.GetNextSelectedItem(pos); - string text; - getNewItemText (item, 0, text); - ListCtrl.InsertItem (item, text.c_str ()); - for (uint i=1; i=ListCtrl.GetItemCount()) - firstItem--; - if ((firstItem != -1) && (firstItem>=0)) - { - // Select an item - ListCtrl.SetItemState (firstItem, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED); - } - notifyParentChange (); - } - break; - case VK_F2: - { - int firstItem = -1; - POSITION pos = ListCtrl.GetFirstSelectedItemPosition(); - if (pos) - firstItem = ListCtrl.GetNextSelectedItem(pos); - if (firstItem != -1) - editItem (firstItem, 0); - } - break; - } - } - break; - case NM_CLICK: - { - LPNMLISTVIEW ptr = (LPNMLISTVIEW)lParam; - // Get the item - SubItem = ptr->iSubItem; - for (Item =0; Item<(uint)ListCtrl.GetItemCount(); Item++) - { - CRect ref; - ListCtrl.GetItemRect( Item, ref, LVIR_BOUNDS ); - if ((ref.top <= ptr->ptAction.y) && (ref.bottom >= ptr->ptAction.y)) - break; - } - if ((Item != (uint)ListCtrl.GetItemCount ()) && (SubItem>0)) - { - editItem (Item, SubItem); - } - } - break; - } - - UpdateData (FALSE); - - return CWnd::OnNotify(wParam, lParam, pResult); -} - -BOOL CMyListCtrl::OnCommand(WPARAM wParam, LPARAM lParam) -{ - if (!Ctrl->OnBrowse) - { - Ctrl->ListCtrl.UpdateData (); - switch (HIWORD(wParam)) - { - case EN_KILLFOCUS: - { - if (Ctrl->Edit.IsWindowVisible ()) - { - CString str; - Ctrl->Edit.GetWindowText (str); - Ctrl->ListCtrl.SetItemText (Ctrl->Item, Ctrl->SubItem, str); - Ctrl->Edit.ShowWindow (SW_HIDE); - Ctrl->notifyParentChange (); - Ctrl->onItemChanged (Ctrl->Item, Ctrl->SubItem); - } - } - break; - case CBN_SELENDOK: - { - switch (LOWORD(wParam)) - { - case CEditListCtrl::IdCombo: - { - if (Ctrl->Combo.IsWindowVisible ()) - { - CString str; - Ctrl->Combo.GetWindowText (str); - Ctrl->ListCtrl.SetItemText (Ctrl->Item, Ctrl->SubItem, str); - Ctrl->Combo.ShowWindow (SW_HIDE); - Ctrl->notifyParentChange (); - Ctrl->onItemChanged (Ctrl->Item, Ctrl->SubItem); - Ctrl->ListCtrl.SetFocus (); - } - } - break; - } - } - case CBN_SELENDCANCEL: - { - switch (LOWORD(wParam)) - { - case CEditListCtrl::IdCombo: - { - if (Ctrl->Combo.IsWindowVisible ()) - { - Ctrl->Combo.ShowWindow (SW_HIDE); - Ctrl->ListCtrl.SetFocus (); - } - } - break; - } - } - break; - } - - Ctrl->ListCtrl.UpdateData (FALSE); - } - - return CWnd::OnCommand(wParam, lParam); -} - -LRESULT CMyListCtrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case MC_COMMAND: - { - if (wParam == CEditListCtrl::CmdBrowse) - { - std::string defExt; - std::string defFilename; - std::string filter; - std::string defDir; - Ctrl->getBrowseInfo (Ctrl->Item, Ctrl->SubItem, defExt, defFilename, defDir, filter); - - CFileDialog dlgFile (TRUE, defExt.c_str (), defFilename.c_str (), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, filter.c_str (), theApp.m_pMainWnd); - dlgFile.m_ofn.lpstrInitialDir = defDir.c_str (); - Ctrl->OnBrowse = true; - if (dlgFile.DoModal () == IDOK) - { - Ctrl->MemCombo.UpdateData (); - Ctrl->MemCombo.SetWindowText (dlgFile.GetFileName ()); - Ctrl->MemCombo.UpdateData (FALSE); - Ctrl->ListCtrl.SetItemText (Ctrl->Item, Ctrl->SubItem, dlgFile.GetFileName ()); - Ctrl->notifyParentChange (); - Ctrl->onItemChanged (Ctrl->Item, Ctrl->SubItem); - Ctrl->MemCombo.ShowWindow (SW_HIDE); - Ctrl->ListCtrl.SetFocus (); - } - else - { - Ctrl->MemCombo.ShowWindow (SW_HIDE); - Ctrl->ListCtrl.SetFocus (); - } - Ctrl->OnBrowse = false; - } - } - break; - case MC_STRINGCHANGE: - { - if (Ctrl->MemCombo.IsWindowVisible ()) - { - // nlinfo ("closeMemComboBox"); - Ctrl->closeMemComboBox (true); - } - } - break; - case MC_ESCAPE: - { - Ctrl->MemCombo.ShowWindow (SW_HIDE); - } - break; - } - - return CListCtrl::WindowProc(message, wParam, lParam); -} - -void CEditListCtrl::onOK () -{ - if (Edit.IsWindowVisible ()) - { - CString str; - Edit.GetWindowText (str); - ListCtrl.SetItemText (Item, SubItem, str); - Edit.ShowWindow (SW_HIDE); - notifyParentChange (); - onItemChanged (Item, SubItem); - } - else if (Combo.IsWindowVisible ()) - { - CString str; - Combo.GetWindowText (str); - ListCtrl.SetItemText (Item, SubItem, str); - Combo.ShowWindow (SW_HIDE); - notifyParentChange (); - onItemChanged (Item, SubItem); - } - else if (MemCombo.IsWindowVisible ()) - { - memComboBoxAsChange (false); - CString str; - MemCombo.GetWindowText (str); - ListCtrl.SetItemText (Item, SubItem, str); - MemCombo.ShowWindow (SW_HIDE); - notifyParentChange (); - onItemChanged (Item, SubItem); - } - else - { - if (ListCtrl.GetSelectedCount() == 1) - { - POSITION pos = ListCtrl.GetFirstSelectedItemPosition(); - int item = ListCtrl.GetNextSelectedItem (pos); - editItem (item, 0); - } - } -} - -void CEditListCtrl::onCancel () -{ - if (Edit.IsWindowVisible ()) - { - Edit.ShowWindow (SW_HIDE); - } - else if (Combo.IsWindowVisible ()) - { - Combo.ShowWindow (SW_HIDE); - } - else if (MemCombo.IsWindowVisible ()) - { - MemCombo.ShowWindow (SW_HIDE); - } -} - -void CEditListCtrl::editItem (uint item, uint subitem) -{ - // Get the sub Item rect - Item = item; - SubItem = subitem; - CRect subItemRect; - ListCtrl.GetSubItemRect( Item, SubItem, LVIR_BOUNDS, subItemRect ); - - if ( (SubItem == 0) && (ColumnCount>1) ) - { - CRect subItemLeft; - if (ListCtrl.GetSubItemRect( Item, 1, LVIR_BOUNDS, subItemLeft)) - subItemRect.right = subItemLeft.left; - } - - // Get edit mode - TItemEdit editMode = getItemEditMode (Item, SubItem); - if (editMode == EditEdit) - { - // Move the editbox - Edit.SetWindowPos (NULL, subItemRect.left, subItemRect.top, subItemRect.right-subItemRect.left, subItemRect.bottom-subItemRect.top, SWP_SHOWWINDOW); - char tmp[512]; - ListCtrl.GetItemText (Item, SubItem, tmp, 512); - Edit.SetWindowText (tmp); - Edit.SetSel( 0, -1); - Edit.SetFocus (); - } - else if (editMode == EditFixedCombo) - { - // Get item string - char tmp[512]; - ListCtrl.GetItemText (Item, SubItem, tmp, 512); - - // Get the combo string - Combo.UpdateData (); - Combo.ResetContent (); - std::vector retStrings; - getComboBoxStrings (Item, SubItem, retStrings); - for (uint i=0; iPostMessage (LC_CHANGE, DlgIndex, 0); -} - -void CEditListCtrl::OnSetFocus( CWnd* pOldWnd ) -{ - if (pOldWnd != this) - { - // Set the focus - ListCtrl.SetFocus (); - - // Something selected ? - POSITION pos = ListCtrl.GetFirstSelectedItemPosition(); - int item = 0; - if (!pos && ListCtrl.GetItemCount ()) - { - ListCtrl.SetItemState (0, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED); - } - } -} - -void CEditListCtrl::insertColumn (uint id, const char *name) -{ - ListCtrl.InsertColumn (id, name); - ColumnCount++; -} - -void CEditListCtrl::getComboBoxStrings (uint item, uint subItem, std::vector &retStrings) -{ - retStrings.reserve (3); - retStrings.push_back ("String0"); - retStrings.push_back ("String1"); - retStrings.push_back ("String2"); -} - - -void CEditListCtrl::closeMemComboBox (bool update) -{ - if (update) - memComboBoxAsChange (false); - MemCombo.ShowWindow (SW_HIDE); - ListCtrl.SetFocus (); -} - -void CEditListCtrl::memComboBoxAsChange (bool selChange) -{ - MemCombo.UpdateData (); - - CString str; - MemCombo.GetWindowText (str); - ListCtrl.SetItemText (Item, SubItem, str); - notifyParentChange (); - onItemChanged (Item, SubItem); -} - -void CEditListCtrl::OnSize(UINT nType, int cx, int cy) -{ - CWnd::OnSize(nType, cx, cy); - - if (IsWindow (ListCtrl)) - ListCtrl.SetWindowPos (NULL, 0, 0, cx, cy, SWP_NOZORDER|SWP_NOOWNERZORDER); -} - -void CEditListCtrl::recalcColumn () -{ - if (ColumnCount>0) - { - RECT listRect; - ListCtrl.GetClientRect (&listRect); - int width = listRect.right/ColumnCount; - int i; - for (i=0; i<(int)ColumnCount-1; i++) - { - ListCtrl.SetColumnWidth( i, width ); - listRect.right -= width; - } - ListCtrl.SetColumnWidth( i, listRect.right); - } -} +// 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 . + +// edit_list_ctrl.cpp : implementation file +// + +#include "stdafx.h" +#include "georges_edit.h" +#include "edit_list_ctrl.h" + +using namespace std; + +///////////////////////////////////////////////////////////////////////////// +// CEditListCtrl + +CEditListCtrl::CEditListCtrl() +{ + ListCtrl.Ctrl = this; + ColumnCount = 0; + OnBrowse = false; +} + +CEditListCtrl::~CEditListCtrl() +{ +} + +bool CEditListCtrl::create (DWORD wStyle, RECT &rect, CWnd *parent, uint dialog_index) +{ + DlgIndex = dialog_index; + + // Register window class + LPCTSTR className = AfxRegisterWndClass( 0 ); + + // Create this window + if (CWnd::Create (className, "empty", WS_CHILD|wStyle, rect, parent, dialog_index)) + { + RECT subRect; + subRect.left = 0; + subRect.top = 0; + subRect.right = rect.right-rect.left; + subRect.bottom = rect.bottom-rect.top; +#if defined(NL_COMP_VC8) || defined(NL_COMP_VC9) + if (ListCtrl.CreateEx ( WS_EX_CLIENTEDGE, /*WC_LISTVIEW, "",*/ WS_CHILD|LVS_REPORT, subRect, this, 0)) +#else + if (ListCtrl.CreateEx ( WS_EX_CLIENTEDGE, WC_LISTVIEW, "", WS_CHILD|LVS_REPORT, subRect, this, 0)) +#endif + { + ListCtrl.ShowWindow ( SW_SHOW ); + + RECT rect; + rect.left = 0; + rect.top = 0; + rect.right = 100; + rect.bottom = 100; + Edit.Create (WS_BORDER, rect, &ListCtrl, 0); + Edit.SetFont (ListCtrl.GetFont()); + Combo.Create (WS_BORDER|CBS_DROPDOWNLIST, rect, &ListCtrl, IdCombo); + Combo.SetFont (ListCtrl.GetFont()); + MemCombo.create (WS_CHILD, rect, &ListCtrl, IdMemCombo, "", theApp.RememberListSize); + MemCombo.SetFont (ListCtrl.GetFont()); + return true; + } + } + + return false; +} + +BEGIN_MESSAGE_MAP(CEditListCtrl, CWnd) + //{{AFX_MSG_MAP(CEditListCtrl) + ON_WM_SHOWWINDOW() + ON_WM_SETFOCUS() + ON_WM_KEYDOWN() + ON_WM_SYSKEYDOWN() + ON_WM_SIZE() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + + +///////////////////////////////////////////////////////////////////////////// +// CEditListCtrl message handlers + + +BOOL CEditListCtrl::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) +{ + // Item double click ? + UpdateData (); + + NMHDR *gPtr = (NMHDR*)lParam; + switch (gPtr->code) + { + case NM_DBLCLK: + { + LPNMLISTVIEW ptr = (LPNMLISTVIEW)lParam; + // Get the item + SubItem = ptr->iSubItem; + for (Item =0; Item<(uint)ListCtrl.GetItemCount(); Item++) + { + CRect ref; + ListCtrl.GetItemRect( Item, ref, LVIR_BOUNDS ); + if ((ref.top <= ptr->ptAction.y) && (ref.bottom >= ptr->ptAction.y)) + break; + } + if (Item != (uint)ListCtrl.GetItemCount ()) + { + editItem (Item, SubItem); + } + else + { + // Insert an item at the end + string text; + getNewItemText (ListCtrl.GetItemCount (), 0, text); + ListCtrl.InsertItem (ListCtrl.GetItemCount (), text.c_str ()); + for (uint i=1; iwVKey) + { + case VK_INSERT: + { + POSITION pos = ListCtrl.GetFirstSelectedItemPosition(); + int item = 0; + if (pos) + { + item = ListCtrl.GetNextSelectedItem(pos); + string text; + getNewItemText (item, 0, text); + ListCtrl.InsertItem (item, text.c_str ()); + for (uint i=1; i=ListCtrl.GetItemCount()) + firstItem--; + if ((firstItem != -1) && (firstItem>=0)) + { + // Select an item + ListCtrl.SetItemState (firstItem, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED); + } + notifyParentChange (); + } + break; + case VK_F2: + { + int firstItem = -1; + POSITION pos = ListCtrl.GetFirstSelectedItemPosition(); + if (pos) + firstItem = ListCtrl.GetNextSelectedItem(pos); + if (firstItem != -1) + editItem (firstItem, 0); + } + break; + } + } + break; + case NM_CLICK: + { + LPNMLISTVIEW ptr = (LPNMLISTVIEW)lParam; + // Get the item + SubItem = ptr->iSubItem; + for (Item =0; Item<(uint)ListCtrl.GetItemCount(); Item++) + { + CRect ref; + ListCtrl.GetItemRect( Item, ref, LVIR_BOUNDS ); + if ((ref.top <= ptr->ptAction.y) && (ref.bottom >= ptr->ptAction.y)) + break; + } + if ((Item != (uint)ListCtrl.GetItemCount ()) && (SubItem>0)) + { + editItem (Item, SubItem); + } + } + break; + } + + UpdateData (FALSE); + + return CWnd::OnNotify(wParam, lParam, pResult); +} + +BOOL CMyListCtrl::OnCommand(WPARAM wParam, LPARAM lParam) +{ + if (!Ctrl->OnBrowse) + { + Ctrl->ListCtrl.UpdateData (); + switch (HIWORD(wParam)) + { + case EN_KILLFOCUS: + { + if (Ctrl->Edit.IsWindowVisible ()) + { + CString str; + Ctrl->Edit.GetWindowText (str); + Ctrl->ListCtrl.SetItemText (Ctrl->Item, Ctrl->SubItem, str); + Ctrl->Edit.ShowWindow (SW_HIDE); + Ctrl->notifyParentChange (); + Ctrl->onItemChanged (Ctrl->Item, Ctrl->SubItem); + } + } + break; + case CBN_SELENDOK: + { + switch (LOWORD(wParam)) + { + case CEditListCtrl::IdCombo: + { + if (Ctrl->Combo.IsWindowVisible ()) + { + CString str; + Ctrl->Combo.GetWindowText (str); + Ctrl->ListCtrl.SetItemText (Ctrl->Item, Ctrl->SubItem, str); + Ctrl->Combo.ShowWindow (SW_HIDE); + Ctrl->notifyParentChange (); + Ctrl->onItemChanged (Ctrl->Item, Ctrl->SubItem); + Ctrl->ListCtrl.SetFocus (); + } + } + break; + } + } + case CBN_SELENDCANCEL: + { + switch (LOWORD(wParam)) + { + case CEditListCtrl::IdCombo: + { + if (Ctrl->Combo.IsWindowVisible ()) + { + Ctrl->Combo.ShowWindow (SW_HIDE); + Ctrl->ListCtrl.SetFocus (); + } + } + break; + } + } + break; + } + + Ctrl->ListCtrl.UpdateData (FALSE); + } + + return CWnd::OnCommand(wParam, lParam); +} + +LRESULT CMyListCtrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case MC_COMMAND: + { + if (wParam == CEditListCtrl::CmdBrowse) + { + std::string defExt; + std::string defFilename; + std::string filter; + std::string defDir; + Ctrl->getBrowseInfo (Ctrl->Item, Ctrl->SubItem, defExt, defFilename, defDir, filter); + + CFileDialog dlgFile (TRUE, defExt.c_str (), defFilename.c_str (), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, filter.c_str (), theApp.m_pMainWnd); + dlgFile.m_ofn.lpstrInitialDir = defDir.c_str (); + Ctrl->OnBrowse = true; + if (dlgFile.DoModal () == IDOK) + { + Ctrl->MemCombo.UpdateData (); + Ctrl->MemCombo.SetWindowText (dlgFile.GetFileName ()); + Ctrl->MemCombo.UpdateData (FALSE); + Ctrl->ListCtrl.SetItemText (Ctrl->Item, Ctrl->SubItem, dlgFile.GetFileName ()); + Ctrl->notifyParentChange (); + Ctrl->onItemChanged (Ctrl->Item, Ctrl->SubItem); + Ctrl->MemCombo.ShowWindow (SW_HIDE); + Ctrl->ListCtrl.SetFocus (); + } + else + { + Ctrl->MemCombo.ShowWindow (SW_HIDE); + Ctrl->ListCtrl.SetFocus (); + } + Ctrl->OnBrowse = false; + } + } + break; + case MC_STRINGCHANGE: + { + if (Ctrl->MemCombo.IsWindowVisible ()) + { + // nlinfo ("closeMemComboBox"); + Ctrl->closeMemComboBox (true); + } + } + break; + case MC_ESCAPE: + { + Ctrl->MemCombo.ShowWindow (SW_HIDE); + } + break; + } + + return CListCtrl::WindowProc(message, wParam, lParam); +} + +void CEditListCtrl::onOK () +{ + if (Edit.IsWindowVisible ()) + { + CString str; + Edit.GetWindowText (str); + ListCtrl.SetItemText (Item, SubItem, str); + Edit.ShowWindow (SW_HIDE); + notifyParentChange (); + onItemChanged (Item, SubItem); + } + else if (Combo.IsWindowVisible ()) + { + CString str; + Combo.GetWindowText (str); + ListCtrl.SetItemText (Item, SubItem, str); + Combo.ShowWindow (SW_HIDE); + notifyParentChange (); + onItemChanged (Item, SubItem); + } + else if (MemCombo.IsWindowVisible ()) + { + memComboBoxAsChange (false); + CString str; + MemCombo.GetWindowText (str); + ListCtrl.SetItemText (Item, SubItem, str); + MemCombo.ShowWindow (SW_HIDE); + notifyParentChange (); + onItemChanged (Item, SubItem); + } + else + { + if (ListCtrl.GetSelectedCount() == 1) + { + POSITION pos = ListCtrl.GetFirstSelectedItemPosition(); + int item = ListCtrl.GetNextSelectedItem (pos); + editItem (item, 0); + } + } +} + +void CEditListCtrl::onCancel () +{ + if (Edit.IsWindowVisible ()) + { + Edit.ShowWindow (SW_HIDE); + } + else if (Combo.IsWindowVisible ()) + { + Combo.ShowWindow (SW_HIDE); + } + else if (MemCombo.IsWindowVisible ()) + { + MemCombo.ShowWindow (SW_HIDE); + } +} + +void CEditListCtrl::editItem (uint item, uint subitem) +{ + // Get the sub Item rect + Item = item; + SubItem = subitem; + CRect subItemRect; + ListCtrl.GetSubItemRect( Item, SubItem, LVIR_BOUNDS, subItemRect ); + + if ( (SubItem == 0) && (ColumnCount>1) ) + { + CRect subItemLeft; + if (ListCtrl.GetSubItemRect( Item, 1, LVIR_BOUNDS, subItemLeft)) + subItemRect.right = subItemLeft.left; + } + + // Get edit mode + TItemEdit editMode = getItemEditMode (Item, SubItem); + if (editMode == EditEdit) + { + // Move the editbox + Edit.SetWindowPos (NULL, subItemRect.left, subItemRect.top, subItemRect.right-subItemRect.left, subItemRect.bottom-subItemRect.top, SWP_SHOWWINDOW); + char tmp[512]; + ListCtrl.GetItemText (Item, SubItem, tmp, 512); + Edit.SetWindowText (tmp); + Edit.SetSel( 0, -1); + Edit.SetFocus (); + } + else if (editMode == EditFixedCombo) + { + // Get item string + char tmp[512]; + ListCtrl.GetItemText (Item, SubItem, tmp, 512); + + // Get the combo string + Combo.UpdateData (); + Combo.ResetContent (); + std::vector retStrings; + getComboBoxStrings (Item, SubItem, retStrings); + for (uint i=0; iPostMessage (LC_CHANGE, DlgIndex, 0); +} + +void CEditListCtrl::OnSetFocus( CWnd* pOldWnd ) +{ + if (pOldWnd != this) + { + // Set the focus + ListCtrl.SetFocus (); + + // Something selected ? + POSITION pos = ListCtrl.GetFirstSelectedItemPosition(); + int item = 0; + if (!pos && ListCtrl.GetItemCount ()) + { + ListCtrl.SetItemState (0, LVIS_SELECTED|LVIS_FOCUSED, LVIS_SELECTED|LVIS_FOCUSED); + } + } +} + +void CEditListCtrl::insertColumn (uint id, const char *name) +{ + ListCtrl.InsertColumn (id, name); + ColumnCount++; +} + +void CEditListCtrl::getComboBoxStrings (uint item, uint subItem, std::vector &retStrings) +{ + retStrings.reserve (3); + retStrings.push_back ("String0"); + retStrings.push_back ("String1"); + retStrings.push_back ("String2"); +} + + +void CEditListCtrl::closeMemComboBox (bool update) +{ + if (update) + memComboBoxAsChange (false); + MemCombo.ShowWindow (SW_HIDE); + ListCtrl.SetFocus (); +} + +void CEditListCtrl::memComboBoxAsChange (bool selChange) +{ + MemCombo.UpdateData (); + + CString str; + MemCombo.GetWindowText (str); + ListCtrl.SetItemText (Item, SubItem, str); + notifyParentChange (); + onItemChanged (Item, SubItem); +} + +void CEditListCtrl::OnSize(UINT nType, int cx, int cy) +{ + CWnd::OnSize(nType, cx, cy); + + if (IsWindow (ListCtrl)) + ListCtrl.SetWindowPos (NULL, 0, 0, cx, cy, SWP_NOZORDER|SWP_NOOWNERZORDER); +} + +void CEditListCtrl::recalcColumn () +{ + if (ColumnCount>0) + { + RECT listRect; + ListCtrl.GetClientRect (&listRect); + int width = listRect.right/ColumnCount; + int i; + for (i=0; i<(int)ColumnCount-1; i++) + { + ListCtrl.SetColumnWidth( i, width ); + listRect.right -= width; + } + ListCtrl.SetColumnWidth( i, listRect.right); + } +} diff --git a/code/ryzom/tools/leveldesign/georges_dll/edit_list_ctrl.h b/code/ryzom/tools/leveldesign/georges_dll/edit_list_ctrl.h index 08b477e38..4dc4d1ddf 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/edit_list_ctrl.h +++ b/code/ryzom/tools/leveldesign/georges_dll/edit_list_ctrl.h @@ -1,135 +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 . - -#if !defined(AFX_EDIT_LIST_CTRL_H__49812C0E_3696_49D3_92A9_6AF18E4FD689__INCLUDED_) -#define AFX_EDIT_LIST_CTRL_H__49812C0E_3696_49D3_92A9_6AF18E4FD689__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// edit_list_ctrl.h : header file -// - -#include "memory_combo_box.h" - -///////////////////////////////////////////////////////////////////////////// -// CEditListCtrl window - -class CEditListCtrl; - -#define LC_CHANGE (WM_APP+0x28) - -// Derived class of CListCtrl used for CEditListCtrl -class CMyListCtrl : public CListCtrl -{ -public: - virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam); - virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); - - CEditListCtrl *Ctrl; -}; - -class CEditListCtrl : public CWnd -{ -// Construction -public: - CEditListCtrl(); - - enum TItemEdit - { - EditEdit, - EditFixedCombo, - EditMemCombo, - NoEdit, - }; - - enum - { - DropDown = 200 - }; - - enum - { - IdCombo = 0, - IdMemCombo, - }; - - enum - { - CmdBrowse = 0, - }; - - // Create method - bool create (DWORD wStyle, RECT &rect, CWnd *parent, uint dialog_index); - - // The CListCtrl - CMyListCtrl ListCtrl; - CEdit Edit; - CComboBox Combo; - CMemoryComboBox MemCombo; - bool OnBrowse; - uint Item, SubItem, ColumnCount; - uint DlgIndex; - - virtual TItemEdit getItemEditMode (uint item, uint subItem) {return EditFixedCombo;} - virtual void getComboBoxStrings (uint item, uint subItem, std::vector &retStrings); - virtual void getMemComboBoxProp (uint item, uint subItem, std::string ®Adr, bool &browse) { regAdr = ""; browse = false; } - virtual void getNewItemText (uint item, uint subItem, std::string &ret) { ret = "new"; } - virtual void getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::string &filter) { defExt=""; defFilename=""; filter=""; defDir="";} - virtual void onItemChanged (uint item, uint subItem) {} - - void memComboBoxAsChange (bool selChange); - void closeMemComboBox (bool update); - void recalcColumn (); - -// Attributes -public: - -// Operations -public: - - void onOK (); - void onCancel (); - void editItem (uint item, uint subitem); - void notifyParentChange (); - void insertColumn (uint id, const char*name); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CEditListCtrl) - protected: - virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); - virtual void OnSetFocus( CWnd* pOldWnd ); - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CEditListCtrl(); - - // Generated message map functions -protected: - //{{AFX_MSG(CEditListCtrl) - afx_msg void OnSize(UINT nType, int cx, int cy); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_EDIT_LIST_CTRL_H__49812C0E_3696_49D3_92A9_6AF18E4FD689__INCLUDED_) +// 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 . + +#if !defined(AFX_EDIT_LIST_CTRL_H__49812C0E_3696_49D3_92A9_6AF18E4FD689__INCLUDED_) +#define AFX_EDIT_LIST_CTRL_H__49812C0E_3696_49D3_92A9_6AF18E4FD689__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// edit_list_ctrl.h : header file +// + +#include "memory_combo_box.h" + +///////////////////////////////////////////////////////////////////////////// +// CEditListCtrl window + +class CEditListCtrl; + +#define LC_CHANGE (WM_APP+0x28) + +// Derived class of CListCtrl used for CEditListCtrl +class CMyListCtrl : public CListCtrl +{ +public: + virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam); + virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); + + CEditListCtrl *Ctrl; +}; + +class CEditListCtrl : public CWnd +{ +// Construction +public: + CEditListCtrl(); + + enum TItemEdit + { + EditEdit, + EditFixedCombo, + EditMemCombo, + NoEdit, + }; + + enum + { + DropDown = 200 + }; + + enum + { + IdCombo = 0, + IdMemCombo, + }; + + enum + { + CmdBrowse = 0, + }; + + // Create method + bool create (DWORD wStyle, RECT &rect, CWnd *parent, uint dialog_index); + + // The CListCtrl + CMyListCtrl ListCtrl; + CEdit Edit; + CComboBox Combo; + CMemoryComboBox MemCombo; + bool OnBrowse; + uint Item, SubItem, ColumnCount; + uint DlgIndex; + + virtual TItemEdit getItemEditMode (uint item, uint subItem) {return EditFixedCombo;} + virtual void getComboBoxStrings (uint item, uint subItem, std::vector &retStrings); + virtual void getMemComboBoxProp (uint item, uint subItem, std::string ®Adr, bool &browse) { regAdr = ""; browse = false; } + virtual void getNewItemText (uint item, uint subItem, std::string &ret) { ret = "new"; } + virtual void getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::string &filter) { defExt=""; defFilename=""; filter=""; defDir="";} + virtual void onItemChanged (uint item, uint subItem) {} + + void memComboBoxAsChange (bool selChange); + void closeMemComboBox (bool update); + void recalcColumn (); + +// Attributes +public: + +// Operations +public: + + void onOK (); + void onCancel (); + void editItem (uint item, uint subitem); + void notifyParentChange (); + void insertColumn (uint id, const char*name); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CEditListCtrl) + protected: + virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); + virtual void OnSetFocus( CWnd* pOldWnd ); + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CEditListCtrl(); + + // Generated message map functions +protected: + //{{AFX_MSG(CEditListCtrl) + afx_msg void OnSize(UINT nType, int cx, int cy); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_EDIT_LIST_CTRL_H__49812C0E_3696_49D3_92A9_6AF18E4FD689__INCLUDED_) diff --git a/code/ryzom/tools/leveldesign/georges_dll/file_browser_dialog.cpp b/code/ryzom/tools/leveldesign/georges_dll/file_browser_dialog.cpp index 36c50a1bf..f63e967ee 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/file_browser_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/file_browser_dialog.cpp @@ -1,337 +1,337 @@ -// 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 . - -// file_browser_dialog.cpp : implementation file -// - -#include "stdafx.h" -#include "georges_edit.h" -#include "file_browser_dialog.h" -#include "file_browser_dialog.h" -#include "main_frm.h" -#include "nel/misc/path.h" - -using namespace std; -using namespace NLMISC; - -///////////////////////////////////////////////////////////////////////////// -// CFileBrowserDialog dialog - - -CFileBrowserDialog::CFileBrowserDialog(CWnd* pParent /*=NULL*/) - : CDialog(CFileBrowserDialog::IDD, pParent) -{ - //{{AFX_DATA_INIT(CFileBrowserDialog) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - -CFileBrowserDialog::~CFileBrowserDialog() -{ - int toto=0; -} - -void CFileBrowserDialog::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CFileBrowserDialog) - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CFileBrowserDialog, CDialog) - //{{AFX_MSG_MAP(CFileBrowserDialog) - ON_WM_SIZE() - ON_NOTIFY(NM_CLICK, IDC_TAB_FILE, OnClickTabFile) - ON_NOTIFY(TCN_SELCHANGE, IDC_TAB_FILE, OnSelchangeTabFile) - ON_WM_MOVE() - ON_WM_SETFOCUS() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CFileBrowserDialog message handlers - -BOOL CFileBrowserDialog::OnInitDialog() -{ - CDialog::OnInitDialog(); - - CRect sz; - GetClientRect(sz); - // sz.DeflateRect(5,5); - - // The tab - CTabCtrl *TabFile = (CTabCtrl*)GetDlgItem (IDC_TAB_FILE); - nlassert (TabFile); - int tabCount = 0; - if (theApp.Superuser) - { - TabFile->InsertItem (0, "Type"); - TabFile->InsertItem (1, "Dfn"); - tabCount += 2; - - TreeCtrlType.create( sz, TabFile, 0); - TreeCtrlType.ShowWindow (SW_HIDE); - TreeCtrlType.addExclusiveExtFilter (".typ"); - TreeCtrlType.setRootDirectory ((theApp.RootSearchPath + theApp.TypeDfnSubDirectory).c_str ()); - TreeCtrlType.setNotifyWindow (m_hWnd, 0); - - TreeCtrlDfn.create( sz, TabFile, 1); - TreeCtrlDfn.ShowWindow (SW_HIDE); - TreeCtrlDfn.addExclusiveExtFilter (".dfn"); - TreeCtrlDfn.setRootDirectory ((theApp.RootSearchPath + theApp.TypeDfnSubDirectory).c_str ()); - TreeCtrlDfn.setNotifyWindow (m_hWnd, 1); - } - - TabFile->InsertItem (tabCount, "Form"); - TabFile->SetCurSel (tabCount); - - TreeCtrlForm.create( sz, TabFile, 2); - TreeCtrlForm.ShowWindow (SW_SHOW); - if (theApp.Superuser) - { - TreeCtrlForm.addNegativeExtFilter (".typ"); - TreeCtrlForm.addNegativeExtFilter (".dfn"); - TreeCtrlForm.addNegativeExtFilter (".ico"); - } - else - { - uint i; - for (i=0; iMoveWindow(sz); - } - if (IsWindow (TreeCtrlType)) - { - TabFile->GetClientRect(sz); - - sz.top += 2; - sz.left += 2; - sz.right -= 2; - sz.bottom -= 22; - TreeCtrlType.MoveWindow(sz); - } - if (IsWindow (TreeCtrlDfn)) - { - TabFile->GetClientRect(sz); - - sz.top += 2; - sz.left += 2; - sz.right -= 2; - sz.bottom -= 22; - TreeCtrlDfn.MoveWindow(sz); - } - if (IsWindow (TreeCtrlForm)) - { - TabFile->GetClientRect(sz); - - sz.top += 2; - sz.left += 2; - sz.right -= 2; - sz.bottom -= 22; - TreeCtrlForm.MoveWindow(sz); - } - } -} - -void CFileBrowserDialog::OnClickTabFile(NMHDR* pNMHDR, LRESULT* pResult) -{ - CTabCtrl *TabFile = (CTabCtrl*)GetDlgItem (IDC_TAB_FILE); - - // Hide every body - if (theApp.Superuser) - { - TreeCtrlType.ShowWindow (SW_HIDE); - TreeCtrlDfn.ShowWindow (SW_HIDE); - TreeCtrlForm.ShowWindow (SW_HIDE); - - // Get the current selection - uint sel = (uint)TabFile->GetCurSel (); - if (sel == 0) - TreeCtrlType.ShowWindow (SW_SHOW); - else if (sel == 1) - TreeCtrlDfn.ShowWindow (SW_SHOW); - else if (sel == 2) - TreeCtrlForm.ShowWindow (SW_SHOW); - - *pResult = 0; - } -} - -LRESULT CFileBrowserDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) -{ - if (message == WM_FILE_TREE_VIEW_LDBLCLICK) - { - // No folder - if (wParam == 0) - { - openDocument (); - } - } - - return CDialog::WindowProc(message, wParam, lParam); -} - -void CFileBrowserDialog::OnSelchangeTabFile(NMHDR* pNMHDR, LRESULT* pResult) -{ - OnClickTabFile(pNMHDR, pResult); -} - -BOOL CFileBrowserDialog::PreTranslateMessage(MSG* pMsg) -{ - if (theApp.m_pMainWnd->PreTranslateMessage(pMsg)) - return TRUE; - - if ((pMsg->message == WM_KEYDOWN) && ((int) pMsg->wParam == VK_TAB) ) - { - // Tab focus ? - CTabCtrl *TabFile = (CTabCtrl*)GetDlgItem (IDC_TAB_FILE); - if (TabFile->GetFocus () == TabFile) - { - if (TreeCtrlType.IsWindowVisible ()) - TreeCtrlType.SetFocus (); - else if (TreeCtrlDfn.IsWindowVisible ()) - TreeCtrlDfn.SetFocus (); - else if (TreeCtrlForm.IsWindowVisible ()) - TreeCtrlForm.SetFocus (); - } - else - { - TabFile->SetFocus (); - } - return TRUE; - } - - return CDialog::PreTranslateMessage(pMsg); -} - -void CFileBrowserDialog::OnOK () -{ - if (TreeCtrlType.IsWindowVisible () && TreeCtrlType.haveFocus () ) - openDocument (); - else if (TreeCtrlDfn.IsWindowVisible () && TreeCtrlDfn.haveFocus () ) - openDocument (); - else if (TreeCtrlForm.IsWindowVisible () && TreeCtrlForm.haveFocus () ) - openDocument (); -} - -void CFileBrowserDialog::OnCancel () -{ - // Select document - CMDIChildWnd *child = ((CMainFrame*)theApp.m_pMainWnd)->MDIGetActive(); - if (child) - { - child->SetFocus (); - } -} - -void CFileBrowserDialog::openDocument () -{ - // Get the file name - string filename; - if (IsWindow (TreeCtrlType) && (TreeCtrlType.IsWindowVisible ())) - { - if (TreeCtrlType.getCurrentFilename (filename) && !filename.empty ()) - { - string pathName = CPath::lookup (filename.c_str (), false, false); - if (pathName.empty ()) - pathName = filename; - theApp.OpenDocumentFile (pathName.c_str()); - } - } - else if (IsWindow (TreeCtrlType) && TreeCtrlDfn.IsWindowVisible ()) - { - if (TreeCtrlDfn.getCurrentFilename (filename) && !filename.empty ()) - { - string pathName = CPath::lookup (filename.c_str (), false, false); - if (pathName.empty ()) - pathName = filename; - theApp.OpenDocumentFile (pathName.c_str()); - } - } - else if (TreeCtrlForm.IsWindowVisible ()) - { - if (TreeCtrlForm.getCurrentFilename (filename) && !filename.empty ()) - { - string pathName = CPath::lookup (filename.c_str (), false, false); - if (pathName.empty ()) - pathName = filename; - theApp.OpenDocumentFile (pathName.c_str()); - } - } -} - -void CFileBrowserDialog::OnSetFocus(CWnd* pNewWnd) -{ - CDialog::OnSetFocus(pNewWnd); - - // Set the focus to the list - if (TreeCtrlType.IsWindowVisible ()) - TreeCtrlType.SetFocus (); - else if (TreeCtrlDfn.IsWindowVisible ()) - TreeCtrlDfn.SetFocus (); - else if (TreeCtrlForm.IsWindowVisible ()) - TreeCtrlForm.SetFocus (); -} - -void CFileBrowserDialog::refresh () -{ - if (IsWindow (TreeCtrlType)) - TreeCtrlType.setRootDirectory ((theApp.RootSearchPath + theApp.TypeDfnSubDirectory).c_str ()); - if (IsWindow (TreeCtrlDfn)) - TreeCtrlDfn.setRootDirectory ((theApp.RootSearchPath + theApp.TypeDfnSubDirectory).c_str ()); - if (IsWindow (TreeCtrlForm)) - TreeCtrlForm.setRootDirectory (theApp.RootSearchPath.c_str ()); -} - -void CFileBrowserDialog::setSortedByType (bool sortedByType) -{ - CFileTreeCtrl::TArrange type = sortedByType ? CFileTreeCtrl::ByType : CFileTreeCtrl::ByName; - TreeCtrlType.setArrangeMode (type); - TreeCtrlDfn.setArrangeMode (type); - TreeCtrlForm.setArrangeMode (type); - refresh (); +// 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 . + +// file_browser_dialog.cpp : implementation file +// + +#include "stdafx.h" +#include "georges_edit.h" +#include "file_browser_dialog.h" +#include "file_browser_dialog.h" +#include "main_frm.h" +#include "nel/misc/path.h" + +using namespace std; +using namespace NLMISC; + +///////////////////////////////////////////////////////////////////////////// +// CFileBrowserDialog dialog + + +CFileBrowserDialog::CFileBrowserDialog(CWnd* pParent /*=NULL*/) + : CDialog(CFileBrowserDialog::IDD, pParent) +{ + //{{AFX_DATA_INIT(CFileBrowserDialog) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT +} + +CFileBrowserDialog::~CFileBrowserDialog() +{ + int toto=0; +} + +void CFileBrowserDialog::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CFileBrowserDialog) + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CFileBrowserDialog, CDialog) + //{{AFX_MSG_MAP(CFileBrowserDialog) + ON_WM_SIZE() + ON_NOTIFY(NM_CLICK, IDC_TAB_FILE, OnClickTabFile) + ON_NOTIFY(TCN_SELCHANGE, IDC_TAB_FILE, OnSelchangeTabFile) + ON_WM_MOVE() + ON_WM_SETFOCUS() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CFileBrowserDialog message handlers + +BOOL CFileBrowserDialog::OnInitDialog() +{ + CDialog::OnInitDialog(); + + CRect sz; + GetClientRect(sz); + // sz.DeflateRect(5,5); + + // The tab + CTabCtrl *TabFile = (CTabCtrl*)GetDlgItem (IDC_TAB_FILE); + nlassert (TabFile); + int tabCount = 0; + if (theApp.Superuser) + { + TabFile->InsertItem (0, "Type"); + TabFile->InsertItem (1, "Dfn"); + tabCount += 2; + + TreeCtrlType.create( sz, TabFile, 0); + TreeCtrlType.ShowWindow (SW_HIDE); + TreeCtrlType.addExclusiveExtFilter (".typ"); + TreeCtrlType.setRootDirectory ((theApp.RootSearchPath + theApp.TypeDfnSubDirectory).c_str ()); + TreeCtrlType.setNotifyWindow (m_hWnd, 0); + + TreeCtrlDfn.create( sz, TabFile, 1); + TreeCtrlDfn.ShowWindow (SW_HIDE); + TreeCtrlDfn.addExclusiveExtFilter (".dfn"); + TreeCtrlDfn.setRootDirectory ((theApp.RootSearchPath + theApp.TypeDfnSubDirectory).c_str ()); + TreeCtrlDfn.setNotifyWindow (m_hWnd, 1); + } + + TabFile->InsertItem (tabCount, "Form"); + TabFile->SetCurSel (tabCount); + + TreeCtrlForm.create( sz, TabFile, 2); + TreeCtrlForm.ShowWindow (SW_SHOW); + if (theApp.Superuser) + { + TreeCtrlForm.addNegativeExtFilter (".typ"); + TreeCtrlForm.addNegativeExtFilter (".dfn"); + TreeCtrlForm.addNegativeExtFilter (".ico"); + } + else + { + uint i; + for (i=0; iMoveWindow(sz); + } + if (IsWindow (TreeCtrlType)) + { + TabFile->GetClientRect(sz); + + sz.top += 2; + sz.left += 2; + sz.right -= 2; + sz.bottom -= 22; + TreeCtrlType.MoveWindow(sz); + } + if (IsWindow (TreeCtrlDfn)) + { + TabFile->GetClientRect(sz); + + sz.top += 2; + sz.left += 2; + sz.right -= 2; + sz.bottom -= 22; + TreeCtrlDfn.MoveWindow(sz); + } + if (IsWindow (TreeCtrlForm)) + { + TabFile->GetClientRect(sz); + + sz.top += 2; + sz.left += 2; + sz.right -= 2; + sz.bottom -= 22; + TreeCtrlForm.MoveWindow(sz); + } + } +} + +void CFileBrowserDialog::OnClickTabFile(NMHDR* pNMHDR, LRESULT* pResult) +{ + CTabCtrl *TabFile = (CTabCtrl*)GetDlgItem (IDC_TAB_FILE); + + // Hide every body + if (theApp.Superuser) + { + TreeCtrlType.ShowWindow (SW_HIDE); + TreeCtrlDfn.ShowWindow (SW_HIDE); + TreeCtrlForm.ShowWindow (SW_HIDE); + + // Get the current selection + uint sel = (uint)TabFile->GetCurSel (); + if (sel == 0) + TreeCtrlType.ShowWindow (SW_SHOW); + else if (sel == 1) + TreeCtrlDfn.ShowWindow (SW_SHOW); + else if (sel == 2) + TreeCtrlForm.ShowWindow (SW_SHOW); + + *pResult = 0; + } +} + +LRESULT CFileBrowserDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) +{ + if (message == WM_FILE_TREE_VIEW_LDBLCLICK) + { + // No folder + if (wParam == 0) + { + openDocument (); + } + } + + return CDialog::WindowProc(message, wParam, lParam); +} + +void CFileBrowserDialog::OnSelchangeTabFile(NMHDR* pNMHDR, LRESULT* pResult) +{ + OnClickTabFile(pNMHDR, pResult); +} + +BOOL CFileBrowserDialog::PreTranslateMessage(MSG* pMsg) +{ + if (theApp.m_pMainWnd->PreTranslateMessage(pMsg)) + return TRUE; + + if ((pMsg->message == WM_KEYDOWN) && ((int) pMsg->wParam == VK_TAB) ) + { + // Tab focus ? + CTabCtrl *TabFile = (CTabCtrl*)GetDlgItem (IDC_TAB_FILE); + if (TabFile->GetFocus () == TabFile) + { + if (TreeCtrlType.IsWindowVisible ()) + TreeCtrlType.SetFocus (); + else if (TreeCtrlDfn.IsWindowVisible ()) + TreeCtrlDfn.SetFocus (); + else if (TreeCtrlForm.IsWindowVisible ()) + TreeCtrlForm.SetFocus (); + } + else + { + TabFile->SetFocus (); + } + return TRUE; + } + + return CDialog::PreTranslateMessage(pMsg); +} + +void CFileBrowserDialog::OnOK () +{ + if (TreeCtrlType.IsWindowVisible () && TreeCtrlType.haveFocus () ) + openDocument (); + else if (TreeCtrlDfn.IsWindowVisible () && TreeCtrlDfn.haveFocus () ) + openDocument (); + else if (TreeCtrlForm.IsWindowVisible () && TreeCtrlForm.haveFocus () ) + openDocument (); +} + +void CFileBrowserDialog::OnCancel () +{ + // Select document + CMDIChildWnd *child = ((CMainFrame*)theApp.m_pMainWnd)->MDIGetActive(); + if (child) + { + child->SetFocus (); + } +} + +void CFileBrowserDialog::openDocument () +{ + // Get the file name + string filename; + if (IsWindow (TreeCtrlType) && (TreeCtrlType.IsWindowVisible ())) + { + if (TreeCtrlType.getCurrentFilename (filename) && !filename.empty ()) + { + string pathName = CPath::lookup (filename.c_str (), false, false); + if (pathName.empty ()) + pathName = filename; + theApp.OpenDocumentFile (pathName.c_str()); + } + } + else if (IsWindow (TreeCtrlType) && TreeCtrlDfn.IsWindowVisible ()) + { + if (TreeCtrlDfn.getCurrentFilename (filename) && !filename.empty ()) + { + string pathName = CPath::lookup (filename.c_str (), false, false); + if (pathName.empty ()) + pathName = filename; + theApp.OpenDocumentFile (pathName.c_str()); + } + } + else if (TreeCtrlForm.IsWindowVisible ()) + { + if (TreeCtrlForm.getCurrentFilename (filename) && !filename.empty ()) + { + string pathName = CPath::lookup (filename.c_str (), false, false); + if (pathName.empty ()) + pathName = filename; + theApp.OpenDocumentFile (pathName.c_str()); + } + } +} + +void CFileBrowserDialog::OnSetFocus(CWnd* pNewWnd) +{ + CDialog::OnSetFocus(pNewWnd); + + // Set the focus to the list + if (TreeCtrlType.IsWindowVisible ()) + TreeCtrlType.SetFocus (); + else if (TreeCtrlDfn.IsWindowVisible ()) + TreeCtrlDfn.SetFocus (); + else if (TreeCtrlForm.IsWindowVisible ()) + TreeCtrlForm.SetFocus (); +} + +void CFileBrowserDialog::refresh () +{ + if (IsWindow (TreeCtrlType)) + TreeCtrlType.setRootDirectory ((theApp.RootSearchPath + theApp.TypeDfnSubDirectory).c_str ()); + if (IsWindow (TreeCtrlDfn)) + TreeCtrlDfn.setRootDirectory ((theApp.RootSearchPath + theApp.TypeDfnSubDirectory).c_str ()); + if (IsWindow (TreeCtrlForm)) + TreeCtrlForm.setRootDirectory (theApp.RootSearchPath.c_str ()); +} + +void CFileBrowserDialog::setSortedByType (bool sortedByType) +{ + CFileTreeCtrl::TArrange type = sortedByType ? CFileTreeCtrl::ByType : CFileTreeCtrl::ByName; + TreeCtrlType.setArrangeMode (type); + TreeCtrlDfn.setArrangeMode (type); + TreeCtrlForm.setArrangeMode (type); + refresh (); } \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_dll/file_browser_dialog.h b/code/ryzom/tools/leveldesign/georges_dll/file_browser_dialog.h index 20567dcce..6095093e8 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/file_browser_dialog.h +++ b/code/ryzom/tools/leveldesign/georges_dll/file_browser_dialog.h @@ -1,87 +1,87 @@ -// 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 . - -#if !defined(AFX_FILE_BROWSER_DIALOG_H__89ACFC97_4AF1_4A4D_A7F7_199D1F9B2BFB__INCLUDED_) -#define AFX_FILE_BROWSER_DIALOG_H__89ACFC97_4AF1_4A4D_A7F7_199D1F9B2BFB__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// file_browser_dialog.h : header file -// - -#include "file_tree_view.h" - -///////////////////////////////////////////////////////////////////////////// -// CFileBrowserDialog dialog - -class CFileBrowserDialog : public CDialog -{ -// Construction -public: - CFileBrowserDialog(CWnd* pParent = NULL); // standard constructor - ~CFileBrowserDialog(); // standard constructor - - // Open currently selected document - void openDocument (); - - // From CDialog - void OnOK (); - void OnCancel (); - - // Refresh the list - void refresh (); - - // Set tree sorted by name or type - void setSortedByType (bool sortedByType); - -// Dialog Data - //{{AFX_DATA(CFileBrowserDialog) - enum { IDD = IDD_FILE_BROWSER }; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CFileBrowserDialog) - public: - virtual BOOL PreTranslateMessage(MSG* pMsg); - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); - //}}AFX_VIRTUAL - -// Implementation -protected: - CFileTreeCtrl TreeCtrlType; - CFileTreeCtrl TreeCtrlDfn; - CFileTreeCtrl TreeCtrlForm; - - // Generated message map functions - //{{AFX_MSG(CFileBrowserDialog) - virtual BOOL OnInitDialog(); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnClickTabFile(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnSelchangeTabFile(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnSetFocus(CWnd* pNewWnd); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_FILE_BROWSER_DIALOG_H__89ACFC97_4AF1_4A4D_A7F7_199D1F9B2BFB__INCLUDED_) +// 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 . + +#if !defined(AFX_FILE_BROWSER_DIALOG_H__89ACFC97_4AF1_4A4D_A7F7_199D1F9B2BFB__INCLUDED_) +#define AFX_FILE_BROWSER_DIALOG_H__89ACFC97_4AF1_4A4D_A7F7_199D1F9B2BFB__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// file_browser_dialog.h : header file +// + +#include "file_tree_view.h" + +///////////////////////////////////////////////////////////////////////////// +// CFileBrowserDialog dialog + +class CFileBrowserDialog : public CDialog +{ +// Construction +public: + CFileBrowserDialog(CWnd* pParent = NULL); // standard constructor + ~CFileBrowserDialog(); // standard constructor + + // Open currently selected document + void openDocument (); + + // From CDialog + void OnOK (); + void OnCancel (); + + // Refresh the list + void refresh (); + + // Set tree sorted by name or type + void setSortedByType (bool sortedByType); + +// Dialog Data + //{{AFX_DATA(CFileBrowserDialog) + enum { IDD = IDD_FILE_BROWSER }; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CFileBrowserDialog) + public: + virtual BOOL PreTranslateMessage(MSG* pMsg); + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); + //}}AFX_VIRTUAL + +// Implementation +protected: + CFileTreeCtrl TreeCtrlType; + CFileTreeCtrl TreeCtrlDfn; + CFileTreeCtrl TreeCtrlForm; + + // Generated message map functions + //{{AFX_MSG(CFileBrowserDialog) + virtual BOOL OnInitDialog(); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnClickTabFile(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnSelchangeTabFile(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnSetFocus(CWnd* pNewWnd); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_FILE_BROWSER_DIALOG_H__89ACFC97_4AF1_4A4D_A7F7_199D1F9B2BFB__INCLUDED_) diff --git a/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp b/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp index c01986bc0..9eb467b97 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.cpp @@ -1,741 +1,741 @@ -// 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 "stdafx.h" - -#include "file_tree_view.h" - -using namespace std; - -CFileTreeCtrl::CFileTreeCtrl() -{ - //{{AFX_DATA_INIT(CFileTreeCtrl) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT - SHFILEINFO sfi; - _ImageListSmall = (HIMAGELIST)SHGetFileInfo( TEXT("C:\\"),0,&sfi,sizeof(SHFILEINFO),SHGFI_SYSICONINDEX | SHGFI_SMALLICON); - _ArrangeMode = ByName; - _HWndNotify = NULL; -} - -CFileTreeCtrl::~CFileTreeCtrl() -{ -} - -BEGIN_MESSAGE_MAP(CFileTreeCtrl, CWnd) - //{{AFX_MSG_MAP(CFileTreeCtrl) - ON_WM_SIZE() - ON_WM_SETFOCUS() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CFileTreeCtrl message handlers - -bool CFileTreeCtrl::create( const RECT& rect, CWnd* pParentWnd, UINT nID ) -{ - // Register window class - LPCTSTR className = AfxRegisterWndClass( 0 ); - // Create this window - - if (CWnd::Create (className, "empty", WS_CHILD, rect, pParentWnd, nID )) - - -#if defined(NL_COMP_VC8) || defined(NL_COMP_VC9) - if (_TreeCtrl.CreateEx (WS_EX_CLIENTEDGE, /*_T("SysTreeView32"), "",*/ TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS|TVS_EDITLABELS|WS_CHILD|WS_TABSTOP, rect, this, 0)) -#else - if (_TreeCtrl.CreateEx (WS_EX_CLIENTEDGE, _T("SysTreeView32"), "", TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS|TVS_EDITLABELS|WS_CHILD|WS_TABSTOP, rect, this, 0)) -#endif - //if (_TreeCtrl.Create( TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS|TVS_EDITLABELS, rect, this, 0)) - return true; - - // Set the directory - setRootDirectory (_RootDirectory.c_str()); - - return false; -} - -struct CTreeItemInfo -{ - CTreeItemInfo() - { - pidlSelf=NULL; - pidlFullyQual=NULL; - pParentFolder=NULL; - dwFlags=NULL; - } - ITEMIDLIST* pidlSelf; - ITEMIDLIST* pidlFullyQual; - IShellFolder* pParentFolder; - DWORD dwFlags; - std::string displayName; -}; - -bool CFileTreeCtrl::setRootDirectory (const char *dir) -{ - // Save the string - _RootDirectory = dir; - if (!_RootDirectory.empty ()) - { - // Is a window ? - if (IsWindow (m_hWnd)) - { - // Clrear the tree - _TreeCtrl.DeleteAllItems (); - - IShellFolder* pDesktop; - ITEMIDLIST* pidl; - ITEMIDLIST* pidlDir; - TV_ITEM tvItem={0}; - TV_INSERTSTRUCT tvInsert={0}; - - // Create tmp image list - CImageList *imageList = CImageList::FromHandle( _ImageListSmall ); - - _TreeCtrl.SetImageList( imageList, TVSIL_NORMAL); - - if(SUCCEEDED(SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl))) - { - if(FAILED(SHGetDesktopFolder(&pDesktop))) - { - //TODO: free the pidl through IMalloc - return false; - } - - CTreeItemInfo* pItemInfo = new CTreeItemInfo; - if(pItemInfo == NULL) - { - //TODO: free the pidl through IMalloc - pDesktop->Release(); - return false; - } - - // String null ? - if (_RootDirectory == "") - { - pidlDir = pidl; - } - else - { - OLECHAR olePath[MAX_PATH]; - ULONG chEaten; - ULONG dwAttributes; - HRESULT hr; - - // IShellFolder::ParseDisplayName requires the file name be in - // Unicode. - MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, _RootDirectory.c_str(), -1, olePath, MAX_PATH); - - // Convert the path to an ITEMIDLIST. - hr = pDesktop->ParseDisplayName(m_hWnd, NULL, olePath, &chEaten, &pidlDir, &dwAttributes); - if (FAILED(hr)) - { - return false; - } - } - - pItemInfo->pidlSelf = pidlDir; - pItemInfo->pidlFullyQual = pidlDir; - tvItem.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN; - tvItem.lParam= (LPARAM)pItemInfo; - tvItem.pszText = LPSTR_TEXTCALLBACK; - tvItem.iImage = tvItem.iSelectedImage = I_IMAGECALLBACK; - tvItem.cChildren = TRUE; - tvInsert.item = tvItem; - tvInsert.hInsertAfter = TVI_LAST; - HTREEITEM hItem = _TreeCtrl.InsertItem(&tvInsert); - _TreeCtrl.SelectItem (hItem); - _TreeCtrl.Expand (hItem, TVE_EXPAND); - pDesktop->Release(); - return true; - } - } - } - return false; -} - -BOOL CFileTreeCtrl::ShowWindow(int nCmdShow) -{ - BOOL res=CWnd::ShowWindow(nCmdShow); - _TreeCtrl.ShowWindow(nCmdShow); - return res; -} - -int CFileTreeCtrl::OnCreate ( LPCREATESTRUCT lpCreateStruct ) -{ - int toto=0; - return CWnd::OnCreate ( lpCreateStruct ); -} - -BOOL CFileTreeCtrl::OnNotify ( WPARAM wParam, LPARAM lParam, LRESULT* pResult ) -{ - LPNMHDR pnmh = (LPNMHDR) lParam; - // Tree ? - if (wParam == 0) - { - switch (pnmh->code) - { - case TVN_GETDISPINFO: - { - LPNMTVDISPINFO lpdi = (LPNMTVDISPINFO)pnmh; - CTreeItemInfo* pItemInfo = (CTreeItemInfo*)lpdi->item.lParam; - SHFILEINFO sfi; - if (pItemInfo) - { - if(lpdi->item.mask & TVIF_TEXT) - { - if(SHGetFileInfo((LPCTSTR)pItemInfo->pidlFullyQual, 0, &sfi, sizeof(sfi), SHGFI_PIDL | SHGFI_DISPLAYNAME)) - lstrcpy(lpdi->item.pszText, sfi.szDisplayName); - } - - if(lpdi->item.mask & TVIF_IMAGE) - { - if(SHGetFileInfo((LPCTSTR)pItemInfo->pidlFullyQual, 0, &sfi, sizeof(sfi), SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_LINKOVERLAY)) - lpdi->item.iImage = sfi.iIcon; - } - if(lpdi->item.mask & TVIF_SELECTEDIMAGE) - { - if(SHGetFileInfo((LPCTSTR)pItemInfo->pidlFullyQual, 0, &sfi, sizeof(sfi), SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_OPENICON)) - lpdi->item.iSelectedImage = sfi.iIcon; - } - } - } - break; - case TVN_ITEMEXPANDING: - { - LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)pnmh; - IShellFolder *pParentFolder; - - if(pnmtv->action == TVE_COLLAPSE) - _TreeCtrl.Expand(pnmtv->itemNew.hItem, TVE_COLLAPSE | TVE_COLLAPSERESET); - else if(pnmtv->action == TVE_EXPAND) - { - HCURSOR hCursor; - TVITEM tvItem = {0}; - tvItem.mask = TVIF_PARAM; - tvItem.hItem = pnmtv->itemNew.hItem; - if(!_TreeCtrl.GetItem(&tvItem)) - return FALSE; - CTreeItemInfo* pItemInfo = (CTreeItemInfo*)tvItem.lParam; - hCursor = SetCursor(LoadCursor(NULL, IDC_WAIT)); - - if(pItemInfo->pParentFolder == 0) - { - if(FAILED(SHGetDesktopFolder(&pParentFolder))) - return FALSE; - if (_RootDirectory != "") - { - SHGetDesktopFolder(&pParentFolder); - if(FAILED(pParentFolder->BindToObject(pItemInfo->pidlSelf, NULL, IID_IShellFolder, (void**)&pParentFolder))) - return 0; - } - } - else if(FAILED(pItemInfo->pParentFolder->BindToObject(pItemInfo->pidlSelf, NULL, IID_IShellFolder, (void**)&pParentFolder))) - return 0; - - _TreeCtrl.SetRedraw(FALSE); - enumObjects (pnmtv->itemNew.hItem, pParentFolder, pItemInfo->pidlFullyQual); - - _TreeCtrl.SetRedraw(TRUE); - pParentFolder->Release(); - SetCursor(hCursor); - } - } - break; - case TVN_DELETEITEM: - { - LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)pnmh; - IMalloc* pMalloc; - CTreeItemInfo* pItemInfo = (CTreeItemInfo*)pnmtv->itemOld.lParam; - if (pItemInfo) - { - if (SUCCEEDED(SHGetMalloc(&pMalloc))) - { - if (pItemInfo->dwFlags == 0) - { - pMalloc->Free(pItemInfo->pidlSelf); - pMalloc->Release(); - if (pItemInfo->pParentFolder) - { - pItemInfo->pParentFolder->Release(); - pMalloc->Free(pItemInfo->pidlFullyQual); - } - } - } - delete pItemInfo; - } - } - break; - case NM_RCLICK: - { - TVHITTESTINFO tvhti; - GetCursorPos(&tvhti.pt); - ::ScreenToClient(_TreeCtrl, &tvhti.pt); - tvhti.flags = LVHT_NOWHERE; - TreeView_HitTest(_TreeCtrl, &tvhti); - - if(TVHT_ONITEM & tvhti.flags) - { - ::ClientToScreen(_TreeCtrl, &tvhti.pt); - doItemMenu(_TreeCtrl, tvhti.hItem , &tvhti.pt); - } - } - break; - case NM_DBLCLK: - { - // Get the item - TVHITTESTINFO tvhti; - GetCursorPos(&tvhti.pt); - ::ScreenToClient(_TreeCtrl, &tvhti.pt); - tvhti.flags = LVHT_NOWHERE; - TreeView_HitTest(_TreeCtrl, &tvhti); - - if(TVHT_ONITEM & tvhti.flags) - { - if (_TreeCtrl.GetRootItem () != tvhti.hItem) - { - ::ClientToScreen(_TreeCtrl, &tvhti.pt); - doClick(_TreeCtrl, tvhti.hItem); - } - } - } - break; - } - } - return CWnd::OnNotify ( wParam, lParam, pResult ); -} - -inline ITEMIDLIST* Pidl_GetNextItem(LPCITEMIDLIST pidl) -{ - if(pidl) - { - return (ITEMIDLIST*)(BYTE*)(((BYTE*)pidl) + pidl->mkid.cb); - } - else - return NULL; -} - -LPITEMIDLIST Pidl_Create(UINT cbSize) -{ - LPITEMIDLIST pidl = NULL; - - IMalloc* pMalloc; - if(FAILED(SHGetMalloc(&pMalloc))) - return false; - - pidl = (LPITEMIDLIST) pMalloc->Alloc(cbSize); - if(pidl) - ZeroMemory(pidl, cbSize); - - pMalloc->Release(); -return pidl; -} - -UINT Pidl_GetSize(LPCITEMIDLIST pidl) -{ - UINT cbTotal = 0; - ITEMIDLIST* pidlTemp = (ITEMIDLIST*) pidl; - - if(pidlTemp) - { - while(pidlTemp->mkid.cb) - { - cbTotal += pidlTemp->mkid.cb; - pidlTemp = Pidl_GetNextItem(pidlTemp); - } - - // Requires a 16 bit zero value for the NULL terminator - cbTotal += 2 * sizeof(BYTE); - } - - return cbTotal; -} - -LPITEMIDLIST Pidl_Concatenate(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) -{ - LPITEMIDLIST pidlNew; - UINT cb1, - cb2 = 0; - if(pidl1) - cb1 = Pidl_GetSize(pidl1) - (2 * sizeof(BYTE)); - - cb2 = Pidl_GetSize(pidl2); - pidlNew = Pidl_Create(cb1 + cb2); - if(pidlNew) - { - if(pidl1) - CopyMemory(pidlNew, pidl1, cb1); - - CopyMemory(((LPBYTE)pidlNew) + cb1, pidl2, cb2); - } - return pidlNew; -} - -int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) -{ - CFileTreeCtrl* pfileTreeCtrl = (CFileTreeCtrl*)lParamSort; - CTreeItemInfo* pItemInfo1 = (CTreeItemInfo*)lParam1; - CTreeItemInfo* pItemInfo2 = (CTreeItemInfo*)lParam2; - - if (pItemInfo1 && pItemInfo2) - { - // File or directory ? - if ( ( (pItemInfo1->dwFlags&SFGAO_FOLDER)!=0) && ( (pItemInfo2->dwFlags&SFGAO_FOLDER)==0) ) - return -1; - if ( ( (pItemInfo1->dwFlags&SFGAO_FOLDER)==0) && ( (pItemInfo2->dwFlags&SFGAO_FOLDER)!=0) ) - return 1; - - // By file name ? - if (pfileTreeCtrl->_ArrangeMode == CFileTreeCtrl::ByName) - return stricmp (pItemInfo1->displayName.c_str(), pItemInfo2->displayName.c_str()); - if (pfileTreeCtrl->_ArrangeMode == CFileTreeCtrl::ByType) - { - char ext1[_MAX_EXT]; - _splitpath (pItemInfo1->displayName.c_str(), NULL, NULL, NULL, ext1); - char ext2[_MAX_EXT]; - _splitpath (pItemInfo2->displayName.c_str(), NULL, NULL, NULL, ext2); - int res = stricmp (ext1, ext2); - if ( res == 0) - return stricmp (pItemInfo1->displayName.c_str(), pItemInfo2->displayName.c_str()); - else - return res; - } - } - return 0; -} - -bool CFileTreeCtrl::enumObjects(HTREEITEM hParentItem,IShellFolder* pParentFolder, ITEMIDLIST* pidlParent) -{ - IEnumIDList* pEnum; - if(SUCCEEDED(pParentFolder->EnumObjects(NULL, SHCONTF_NONFOLDERS |SHCONTF_FOLDERS|SHCONTF_INCLUDEHIDDEN, &pEnum))) - { - ITEMIDLIST* pidl; - DWORD dwFetched = 1; - TV_ITEM tvItem={0}; - TV_INSERTSTRUCT tvInsert={0}; - bool inserted = false; - while(SUCCEEDED(pEnum->Next(1, &pidl, &dwFetched)) && dwFetched) - { - CTreeItemInfo* pItemInfo = new CTreeItemInfo; - pItemInfo->pidlSelf = pidl; - pItemInfo->pidlFullyQual = Pidl_Concatenate(pidlParent,pidl); - pParentFolder->AddRef(); - pItemInfo->pParentFolder = pParentFolder; - ZeroMemory(&tvItem, sizeof(tvItem)); - tvItem.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN; - tvItem.pszText = LPSTR_TEXTCALLBACK; - tvItem.iImage = tvItem.iSelectedImage = I_IMAGECALLBACK; - tvItem.lParam= (LPARAM)pItemInfo; - pItemInfo->dwFlags = SFGAO_LINK | SFGAO_HASSUBFOLDER | SFGAO_FOLDER | SFGAO_DISPLAYATTRMASK | SFGAO_CANRENAME; - pParentFolder->GetAttributesOf(1, (LPCITEMIDLIST*)&pidl, &pItemInfo->dwFlags); - - // Convert display name in file system path - char name[MAX_PATH]; - nlverify ( SHGetPathFromIDList ( pidl, name ) ); - - // Save it - pItemInfo->displayName = name; - - // Is a folder ? - bool folder = (pItemInfo->dwFlags&SFGAO_FOLDER) !=0; - - // No CVS directory - uint displayNameSize = pItemInfo->displayName.size (); - string ext3 = pItemInfo->displayName.substr(displayNameSize-3); - string ext4 = pItemInfo->displayName.substr(displayNameSize-4); - string ext5 = pItemInfo->displayName.substr(displayNameSize-5); - - bool cvs = ext3 == "CVS" || ext4 == "CVS\\" || ext4 == "CVS/" || - ext4 == ".svn" || ext5 == ".svn\\" || ext5 == ".svn/"; - -/* bool cvs = ( pItemInfo->displayName[displayNameSize-3] == 'C') && - (pItemInfo->displayName[displayNameSize-2] == 'V') && - (pItemInfo->displayName[displayNameSize-1] == 'S'); - if (!cvs) - { - cvs = ( pItemInfo->displayName[displayNameSize-4] == 'C') && - (pItemInfo->displayName[displayNameSize-3] == 'V') && - (pItemInfo->displayName[displayNameSize-2] == 'S') && - ( (pItemInfo->displayName[displayNameSize-1] == '\\') || (pItemInfo->displayName[displayNameSize-1] == '/') ); - }*/ - - // Continue ? - if (!folder || !cvs) - { - // Filter - uint filter; - uint filterCount = _ExclusiveExtFilter.size (); - - // Get the extension - uint pos = pItemInfo->displayName.rfind ('.'); - const char *extName = NULL; - if (pos != string::npos) - extName = pItemInfo->displayName.c_str ()+pos; - - if (!folder) - for (filter=0; filterdwFlags & SFGAO_FOLDER) && ((pItemInfo->dwFlags & SFGAO_LINK) ==0); - if(pItemInfo->dwFlags & SFGAO_SHARE) - { - tvItem.mask |= TVIF_STATE; - tvItem.stateMask |= TVIS_OVERLAYMASK; - tvItem.state |= INDEXTOOVERLAYMASK(1); - } - tvInsert.item = tvItem; - tvInsert.hInsertAfter = TVI_LAST; - tvInsert.hParent = hParentItem; - _TreeCtrl.InsertItem(&tvInsert); - dwFetched = 0; - inserted = true; - } - } - } - } - if (!inserted) - { - /*tvInsert.item.mask = LVIF_IMAGE; - tvInsert.item.stateMask = 0; - tvInsert.item.state = 0; - tvInsert.item.mask = 0; - tvInsert.item.pszText = 0; - tvInsert.item.iImage = tvInsert.item.iSelectedImage = 10; - tvInsert.item.lParam = NULL; - tvInsert.item.cChildren = 0; - tvInsert.hInsertAfter = TVI_LAST; - tvInsert.hParent = hParentItem; - _TreeCtrl.InsertItem(&tvInsert);*/ - /*HTREEITEM hItem = _TreeCtrl.InsertItem ("", hParentItem ); - _TreeCtrl.SetItemImage( hItem, 0xffffffff, 0xffffffff );*/ - /*memset (&tvItem, 0, sizeof (TVITEM)); - tvItem.hItem = hParentItem; - nlverify (_TreeCtrl.GetItem( &tvItem )); - tvItem.cChildren = 0; - nlverify (_TreeCtrl.SetItem( &tvItem ));*/ - } - - // Sort the list - if (_ArrangeMode != None) - { - TVSORTCB tvSort; - tvSort.hParent = hParentItem; - tvSort.lpfnCompare = CompareFunc; - tvSort.lParam = (LPARAM)this; - _TreeCtrl.SortChildrenCB( &tvSort ); - } - - pEnum->Release(); - return true; - } - return false; -} - -void CFileTreeCtrl::doItemMenu (HWND hwndTreeView, HTREEITEM hItem, LPPOINT pptScreen) -{ - TVITEM tvItem; - - ZeroMemory(&tvItem, sizeof(tvItem)); - tvItem.mask = TVIF_PARAM; - tvItem.hItem = hItem; - - if(TreeView_GetItem(hwndTreeView, &tvItem)) - { - HWND hwndParent = ::GetParent(hwndTreeView); - HRESULT hr; - CTreeItemInfo* pInfo = (CTreeItemInfo*)tvItem.lParam; - IContextMenu *pcm; - IShellFolder *psfFolder = pInfo->pParentFolder; - - if(!psfFolder) - { - SHGetDesktopFolder(&psfFolder); - } - else - { - psfFolder->AddRef(); - } - - if(psfFolder) - { - hr = psfFolder->GetUIObjectOf( hwndParent, - 1, - (LPCITEMIDLIST*)&pInfo->pidlSelf, - IID_IContextMenu, - NULL, - (LPVOID*)&pcm); - - if(SUCCEEDED(hr)) - { - HMENU hPopup; - - hPopup = CreatePopupMenu(); - if(hPopup) - { - hr = pcm->QueryContextMenu(hPopup, 0, 1, 0x7fff, CMF_NORMAL | CMF_EXPLORE); - - if(SUCCEEDED(hr)) - { - IContextMenu2* pcm2; - pcm->QueryInterface(IID_IContextMenu2, (LPVOID*)&pcm2); - - UINT idCmd; - - idCmd = TrackPopupMenu( hPopup, - TPM_LEFTALIGN | TPM_RETURNCMD | TPM_RIGHTBUTTON, - pptScreen->x, - pptScreen->y, - 0, - hwndParent, - NULL); - - if(pcm2) - { - pcm2->Release(); - pcm2 = NULL; - } - - if(idCmd) - { - CMINVOKECOMMANDINFO cmi; - cmi.cbSize = sizeof(CMINVOKECOMMANDINFO); - cmi.fMask = 0; - cmi.hwnd = hwndParent; - cmi.lpVerb = (LPCSTR)(INT_PTR)(idCmd - 1); - cmi.lpParameters = NULL; - cmi.lpDirectory = NULL; - cmi.nShow = SW_SHOWNORMAL; - cmi.dwHotKey = 0; - cmi.hIcon = NULL; - hr = pcm->InvokeCommand(&cmi); - } - } - } - pcm->Release(); - } - psfFolder->Release(); - } - } -} - -void CFileTreeCtrl::doClick (HWND hwndTreeView, HTREEITEM hItem) -{ - TVITEM tvItem; - - ZeroMemory(&tvItem, sizeof(tvItem)); - tvItem.mask = TVIF_PARAM; - tvItem.hItem = hItem; - - if(TreeView_GetItem(hwndTreeView, &tvItem)) - { - HWND hwndParent = ::GetParent(hwndTreeView); - CTreeItemInfo* pItemInfo = (CTreeItemInfo*)tvItem.lParam; - - // Notify parent - if (pItemInfo) - if (_HWndNotify) - ::SendMessage (_HWndNotify, WM_FILE_TREE_VIEW_LDBLCLICK, (pItemInfo->dwFlags&SFGAO_FOLDER)!=0, _NotifyParam); - } -} - -void CFileTreeCtrl::setArrangeMode (TArrange arrangeMode) -{ - _ArrangeMode = arrangeMode; - - // Set the directory - setRootDirectory (_RootDirectory.c_str()); -} - -void CFileTreeCtrl::OnSize(UINT nType, int cx, int cy) -{ - CWnd::OnSize(nType, cx, cy); - - CRect sz; - GetClientRect(sz); - //sz.DeflateRect(5,0); - if (IsWindow (_TreeCtrl)) - _TreeCtrl.MoveWindow(sz); -} - -void CFileTreeCtrl::addExclusiveExtFilter (const char *ext) -{ - _ExclusiveExtFilter.push_back (ext); -} - -void CFileTreeCtrl::addNegativeExtFilter (const char *ext) -{ - _NegativeExtFilter.push_back (ext); -} - -void CFileTreeCtrl::clearExtFilters () -{ - _ExclusiveExtFilter.clear (); - _NegativeExtFilter.clear (); -} - -void CFileTreeCtrl::setNotifyWindow (HWND hWnd, uint32 param) -{ - _HWndNotify = hWnd; - _NotifyParam = param; -} - -bool CFileTreeCtrl::getCurrentFilename (std::string &result) -{ - HTREEITEM curSel = _TreeCtrl.GetSelectedItem (); - if (curSel) - { - CString str = _TreeCtrl.GetItemText (curSel); - result = str; - return true; - } - return false; -} - -void CFileTreeCtrl::OnSetFocus(CWnd* pOldWnd) -{ - CWnd::OnSetFocus(pOldWnd); - - _TreeCtrl.SetFocus (); -} - -bool CFileTreeCtrl::haveFocus () -{ - return _TreeCtrl.GetFocus () == &_TreeCtrl; -} +// 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 "stdafx.h" + +#include "file_tree_view.h" + +using namespace std; + +CFileTreeCtrl::CFileTreeCtrl() +{ + //{{AFX_DATA_INIT(CFileTreeCtrl) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + SHFILEINFO sfi; + _ImageListSmall = (HIMAGELIST)SHGetFileInfo( TEXT("C:\\"),0,&sfi,sizeof(SHFILEINFO),SHGFI_SYSICONINDEX | SHGFI_SMALLICON); + _ArrangeMode = ByName; + _HWndNotify = NULL; +} + +CFileTreeCtrl::~CFileTreeCtrl() +{ +} + +BEGIN_MESSAGE_MAP(CFileTreeCtrl, CWnd) + //{{AFX_MSG_MAP(CFileTreeCtrl) + ON_WM_SIZE() + ON_WM_SETFOCUS() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CFileTreeCtrl message handlers + +bool CFileTreeCtrl::create( const RECT& rect, CWnd* pParentWnd, UINT nID ) +{ + // Register window class + LPCTSTR className = AfxRegisterWndClass( 0 ); + // Create this window + + if (CWnd::Create (className, "empty", WS_CHILD, rect, pParentWnd, nID )) + + +#if defined(NL_COMP_VC8) || defined(NL_COMP_VC9) + if (_TreeCtrl.CreateEx (WS_EX_CLIENTEDGE, /*_T("SysTreeView32"), "",*/ TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS|TVS_EDITLABELS|WS_CHILD|WS_TABSTOP, rect, this, 0)) +#else + if (_TreeCtrl.CreateEx (WS_EX_CLIENTEDGE, _T("SysTreeView32"), "", TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS|TVS_EDITLABELS|WS_CHILD|WS_TABSTOP, rect, this, 0)) +#endif + //if (_TreeCtrl.Create( TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS|TVS_EDITLABELS, rect, this, 0)) + return true; + + // Set the directory + setRootDirectory (_RootDirectory.c_str()); + + return false; +} + +struct CTreeItemInfo +{ + CTreeItemInfo() + { + pidlSelf=NULL; + pidlFullyQual=NULL; + pParentFolder=NULL; + dwFlags=NULL; + } + ITEMIDLIST* pidlSelf; + ITEMIDLIST* pidlFullyQual; + IShellFolder* pParentFolder; + DWORD dwFlags; + std::string displayName; +}; + +bool CFileTreeCtrl::setRootDirectory (const char *dir) +{ + // Save the string + _RootDirectory = dir; + if (!_RootDirectory.empty ()) + { + // Is a window ? + if (IsWindow (m_hWnd)) + { + // Clrear the tree + _TreeCtrl.DeleteAllItems (); + + IShellFolder* pDesktop; + ITEMIDLIST* pidl; + ITEMIDLIST* pidlDir; + TV_ITEM tvItem={0}; + TV_INSERTSTRUCT tvInsert={0}; + + // Create tmp image list + CImageList *imageList = CImageList::FromHandle( _ImageListSmall ); + + _TreeCtrl.SetImageList( imageList, TVSIL_NORMAL); + + if(SUCCEEDED(SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidl))) + { + if(FAILED(SHGetDesktopFolder(&pDesktop))) + { + //TODO: free the pidl through IMalloc + return false; + } + + CTreeItemInfo* pItemInfo = new CTreeItemInfo; + if(pItemInfo == NULL) + { + //TODO: free the pidl through IMalloc + pDesktop->Release(); + return false; + } + + // String null ? + if (_RootDirectory == "") + { + pidlDir = pidl; + } + else + { + OLECHAR olePath[MAX_PATH]; + ULONG chEaten; + ULONG dwAttributes; + HRESULT hr; + + // IShellFolder::ParseDisplayName requires the file name be in + // Unicode. + MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, _RootDirectory.c_str(), -1, olePath, MAX_PATH); + + // Convert the path to an ITEMIDLIST. + hr = pDesktop->ParseDisplayName(m_hWnd, NULL, olePath, &chEaten, &pidlDir, &dwAttributes); + if (FAILED(hr)) + { + return false; + } + } + + pItemInfo->pidlSelf = pidlDir; + pItemInfo->pidlFullyQual = pidlDir; + tvItem.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN; + tvItem.lParam= (LPARAM)pItemInfo; + tvItem.pszText = LPSTR_TEXTCALLBACK; + tvItem.iImage = tvItem.iSelectedImage = I_IMAGECALLBACK; + tvItem.cChildren = TRUE; + tvInsert.item = tvItem; + tvInsert.hInsertAfter = TVI_LAST; + HTREEITEM hItem = _TreeCtrl.InsertItem(&tvInsert); + _TreeCtrl.SelectItem (hItem); + _TreeCtrl.Expand (hItem, TVE_EXPAND); + pDesktop->Release(); + return true; + } + } + } + return false; +} + +BOOL CFileTreeCtrl::ShowWindow(int nCmdShow) +{ + BOOL res=CWnd::ShowWindow(nCmdShow); + _TreeCtrl.ShowWindow(nCmdShow); + return res; +} + +int CFileTreeCtrl::OnCreate ( LPCREATESTRUCT lpCreateStruct ) +{ + int toto=0; + return CWnd::OnCreate ( lpCreateStruct ); +} + +BOOL CFileTreeCtrl::OnNotify ( WPARAM wParam, LPARAM lParam, LRESULT* pResult ) +{ + LPNMHDR pnmh = (LPNMHDR) lParam; + // Tree ? + if (wParam == 0) + { + switch (pnmh->code) + { + case TVN_GETDISPINFO: + { + LPNMTVDISPINFO lpdi = (LPNMTVDISPINFO)pnmh; + CTreeItemInfo* pItemInfo = (CTreeItemInfo*)lpdi->item.lParam; + SHFILEINFO sfi; + if (pItemInfo) + { + if(lpdi->item.mask & TVIF_TEXT) + { + if(SHGetFileInfo((LPCTSTR)pItemInfo->pidlFullyQual, 0, &sfi, sizeof(sfi), SHGFI_PIDL | SHGFI_DISPLAYNAME)) + lstrcpy(lpdi->item.pszText, sfi.szDisplayName); + } + + if(lpdi->item.mask & TVIF_IMAGE) + { + if(SHGetFileInfo((LPCTSTR)pItemInfo->pidlFullyQual, 0, &sfi, sizeof(sfi), SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_LINKOVERLAY)) + lpdi->item.iImage = sfi.iIcon; + } + if(lpdi->item.mask & TVIF_SELECTEDIMAGE) + { + if(SHGetFileInfo((LPCTSTR)pItemInfo->pidlFullyQual, 0, &sfi, sizeof(sfi), SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_OPENICON)) + lpdi->item.iSelectedImage = sfi.iIcon; + } + } + } + break; + case TVN_ITEMEXPANDING: + { + LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)pnmh; + IShellFolder *pParentFolder; + + if(pnmtv->action == TVE_COLLAPSE) + _TreeCtrl.Expand(pnmtv->itemNew.hItem, TVE_COLLAPSE | TVE_COLLAPSERESET); + else if(pnmtv->action == TVE_EXPAND) + { + HCURSOR hCursor; + TVITEM tvItem = {0}; + tvItem.mask = TVIF_PARAM; + tvItem.hItem = pnmtv->itemNew.hItem; + if(!_TreeCtrl.GetItem(&tvItem)) + return FALSE; + CTreeItemInfo* pItemInfo = (CTreeItemInfo*)tvItem.lParam; + hCursor = SetCursor(LoadCursor(NULL, IDC_WAIT)); + + if(pItemInfo->pParentFolder == 0) + { + if(FAILED(SHGetDesktopFolder(&pParentFolder))) + return FALSE; + if (_RootDirectory != "") + { + SHGetDesktopFolder(&pParentFolder); + if(FAILED(pParentFolder->BindToObject(pItemInfo->pidlSelf, NULL, IID_IShellFolder, (void**)&pParentFolder))) + return 0; + } + } + else if(FAILED(pItemInfo->pParentFolder->BindToObject(pItemInfo->pidlSelf, NULL, IID_IShellFolder, (void**)&pParentFolder))) + return 0; + + _TreeCtrl.SetRedraw(FALSE); + enumObjects (pnmtv->itemNew.hItem, pParentFolder, pItemInfo->pidlFullyQual); + + _TreeCtrl.SetRedraw(TRUE); + pParentFolder->Release(); + SetCursor(hCursor); + } + } + break; + case TVN_DELETEITEM: + { + LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)pnmh; + IMalloc* pMalloc; + CTreeItemInfo* pItemInfo = (CTreeItemInfo*)pnmtv->itemOld.lParam; + if (pItemInfo) + { + if (SUCCEEDED(SHGetMalloc(&pMalloc))) + { + if (pItemInfo->dwFlags == 0) + { + pMalloc->Free(pItemInfo->pidlSelf); + pMalloc->Release(); + if (pItemInfo->pParentFolder) + { + pItemInfo->pParentFolder->Release(); + pMalloc->Free(pItemInfo->pidlFullyQual); + } + } + } + delete pItemInfo; + } + } + break; + case NM_RCLICK: + { + TVHITTESTINFO tvhti; + GetCursorPos(&tvhti.pt); + ::ScreenToClient(_TreeCtrl, &tvhti.pt); + tvhti.flags = LVHT_NOWHERE; + TreeView_HitTest(_TreeCtrl, &tvhti); + + if(TVHT_ONITEM & tvhti.flags) + { + ::ClientToScreen(_TreeCtrl, &tvhti.pt); + doItemMenu(_TreeCtrl, tvhti.hItem , &tvhti.pt); + } + } + break; + case NM_DBLCLK: + { + // Get the item + TVHITTESTINFO tvhti; + GetCursorPos(&tvhti.pt); + ::ScreenToClient(_TreeCtrl, &tvhti.pt); + tvhti.flags = LVHT_NOWHERE; + TreeView_HitTest(_TreeCtrl, &tvhti); + + if(TVHT_ONITEM & tvhti.flags) + { + if (_TreeCtrl.GetRootItem () != tvhti.hItem) + { + ::ClientToScreen(_TreeCtrl, &tvhti.pt); + doClick(_TreeCtrl, tvhti.hItem); + } + } + } + break; + } + } + return CWnd::OnNotify ( wParam, lParam, pResult ); +} + +inline ITEMIDLIST* Pidl_GetNextItem(LPCITEMIDLIST pidl) +{ + if(pidl) + { + return (ITEMIDLIST*)(BYTE*)(((BYTE*)pidl) + pidl->mkid.cb); + } + else + return NULL; +} + +LPITEMIDLIST Pidl_Create(UINT cbSize) +{ + LPITEMIDLIST pidl = NULL; + + IMalloc* pMalloc; + if(FAILED(SHGetMalloc(&pMalloc))) + return false; + + pidl = (LPITEMIDLIST) pMalloc->Alloc(cbSize); + if(pidl) + ZeroMemory(pidl, cbSize); + + pMalloc->Release(); +return pidl; +} + +UINT Pidl_GetSize(LPCITEMIDLIST pidl) +{ + UINT cbTotal = 0; + ITEMIDLIST* pidlTemp = (ITEMIDLIST*) pidl; + + if(pidlTemp) + { + while(pidlTemp->mkid.cb) + { + cbTotal += pidlTemp->mkid.cb; + pidlTemp = Pidl_GetNextItem(pidlTemp); + } + + // Requires a 16 bit zero value for the NULL terminator + cbTotal += 2 * sizeof(BYTE); + } + + return cbTotal; +} + +LPITEMIDLIST Pidl_Concatenate(LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2) +{ + LPITEMIDLIST pidlNew; + UINT cb1, + cb2 = 0; + if(pidl1) + cb1 = Pidl_GetSize(pidl1) - (2 * sizeof(BYTE)); + + cb2 = Pidl_GetSize(pidl2); + pidlNew = Pidl_Create(cb1 + cb2); + if(pidlNew) + { + if(pidl1) + CopyMemory(pidlNew, pidl1, cb1); + + CopyMemory(((LPBYTE)pidlNew) + cb1, pidl2, cb2); + } + return pidlNew; +} + +int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) +{ + CFileTreeCtrl* pfileTreeCtrl = (CFileTreeCtrl*)lParamSort; + CTreeItemInfo* pItemInfo1 = (CTreeItemInfo*)lParam1; + CTreeItemInfo* pItemInfo2 = (CTreeItemInfo*)lParam2; + + if (pItemInfo1 && pItemInfo2) + { + // File or directory ? + if ( ( (pItemInfo1->dwFlags&SFGAO_FOLDER)!=0) && ( (pItemInfo2->dwFlags&SFGAO_FOLDER)==0) ) + return -1; + if ( ( (pItemInfo1->dwFlags&SFGAO_FOLDER)==0) && ( (pItemInfo2->dwFlags&SFGAO_FOLDER)!=0) ) + return 1; + + // By file name ? + if (pfileTreeCtrl->_ArrangeMode == CFileTreeCtrl::ByName) + return stricmp (pItemInfo1->displayName.c_str(), pItemInfo2->displayName.c_str()); + if (pfileTreeCtrl->_ArrangeMode == CFileTreeCtrl::ByType) + { + char ext1[_MAX_EXT]; + _splitpath (pItemInfo1->displayName.c_str(), NULL, NULL, NULL, ext1); + char ext2[_MAX_EXT]; + _splitpath (pItemInfo2->displayName.c_str(), NULL, NULL, NULL, ext2); + int res = stricmp (ext1, ext2); + if ( res == 0) + return stricmp (pItemInfo1->displayName.c_str(), pItemInfo2->displayName.c_str()); + else + return res; + } + } + return 0; +} + +bool CFileTreeCtrl::enumObjects(HTREEITEM hParentItem,IShellFolder* pParentFolder, ITEMIDLIST* pidlParent) +{ + IEnumIDList* pEnum; + if(SUCCEEDED(pParentFolder->EnumObjects(NULL, SHCONTF_NONFOLDERS |SHCONTF_FOLDERS|SHCONTF_INCLUDEHIDDEN, &pEnum))) + { + ITEMIDLIST* pidl; + DWORD dwFetched = 1; + TV_ITEM tvItem={0}; + TV_INSERTSTRUCT tvInsert={0}; + bool inserted = false; + while(SUCCEEDED(pEnum->Next(1, &pidl, &dwFetched)) && dwFetched) + { + CTreeItemInfo* pItemInfo = new CTreeItemInfo; + pItemInfo->pidlSelf = pidl; + pItemInfo->pidlFullyQual = Pidl_Concatenate(pidlParent,pidl); + pParentFolder->AddRef(); + pItemInfo->pParentFolder = pParentFolder; + ZeroMemory(&tvItem, sizeof(tvItem)); + tvItem.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN; + tvItem.pszText = LPSTR_TEXTCALLBACK; + tvItem.iImage = tvItem.iSelectedImage = I_IMAGECALLBACK; + tvItem.lParam= (LPARAM)pItemInfo; + pItemInfo->dwFlags = SFGAO_LINK | SFGAO_HASSUBFOLDER | SFGAO_FOLDER | SFGAO_DISPLAYATTRMASK | SFGAO_CANRENAME; + pParentFolder->GetAttributesOf(1, (LPCITEMIDLIST*)&pidl, &pItemInfo->dwFlags); + + // Convert display name in file system path + char name[MAX_PATH]; + nlverify ( SHGetPathFromIDList ( pidl, name ) ); + + // Save it + pItemInfo->displayName = name; + + // Is a folder ? + bool folder = (pItemInfo->dwFlags&SFGAO_FOLDER) !=0; + + // No CVS directory + uint displayNameSize = pItemInfo->displayName.size (); + string ext3 = pItemInfo->displayName.substr(displayNameSize-3); + string ext4 = pItemInfo->displayName.substr(displayNameSize-4); + string ext5 = pItemInfo->displayName.substr(displayNameSize-5); + + bool cvs = ext3 == "CVS" || ext4 == "CVS\\" || ext4 == "CVS/" || + ext4 == ".svn" || ext5 == ".svn\\" || ext5 == ".svn/"; + +/* bool cvs = ( pItemInfo->displayName[displayNameSize-3] == 'C') && + (pItemInfo->displayName[displayNameSize-2] == 'V') && + (pItemInfo->displayName[displayNameSize-1] == 'S'); + if (!cvs) + { + cvs = ( pItemInfo->displayName[displayNameSize-4] == 'C') && + (pItemInfo->displayName[displayNameSize-3] == 'V') && + (pItemInfo->displayName[displayNameSize-2] == 'S') && + ( (pItemInfo->displayName[displayNameSize-1] == '\\') || (pItemInfo->displayName[displayNameSize-1] == '/') ); + }*/ + + // Continue ? + if (!folder || !cvs) + { + // Filter + uint filter; + uint filterCount = _ExclusiveExtFilter.size (); + + // Get the extension + uint pos = pItemInfo->displayName.rfind ('.'); + const char *extName = NULL; + if (pos != string::npos) + extName = pItemInfo->displayName.c_str ()+pos; + + if (!folder) + for (filter=0; filterdwFlags & SFGAO_FOLDER) && ((pItemInfo->dwFlags & SFGAO_LINK) ==0); + if(pItemInfo->dwFlags & SFGAO_SHARE) + { + tvItem.mask |= TVIF_STATE; + tvItem.stateMask |= TVIS_OVERLAYMASK; + tvItem.state |= INDEXTOOVERLAYMASK(1); + } + tvInsert.item = tvItem; + tvInsert.hInsertAfter = TVI_LAST; + tvInsert.hParent = hParentItem; + _TreeCtrl.InsertItem(&tvInsert); + dwFetched = 0; + inserted = true; + } + } + } + } + if (!inserted) + { + /*tvInsert.item.mask = LVIF_IMAGE; + tvInsert.item.stateMask = 0; + tvInsert.item.state = 0; + tvInsert.item.mask = 0; + tvInsert.item.pszText = 0; + tvInsert.item.iImage = tvInsert.item.iSelectedImage = 10; + tvInsert.item.lParam = NULL; + tvInsert.item.cChildren = 0; + tvInsert.hInsertAfter = TVI_LAST; + tvInsert.hParent = hParentItem; + _TreeCtrl.InsertItem(&tvInsert);*/ + /*HTREEITEM hItem = _TreeCtrl.InsertItem ("", hParentItem ); + _TreeCtrl.SetItemImage( hItem, 0xffffffff, 0xffffffff );*/ + /*memset (&tvItem, 0, sizeof (TVITEM)); + tvItem.hItem = hParentItem; + nlverify (_TreeCtrl.GetItem( &tvItem )); + tvItem.cChildren = 0; + nlverify (_TreeCtrl.SetItem( &tvItem ));*/ + } + + // Sort the list + if (_ArrangeMode != None) + { + TVSORTCB tvSort; + tvSort.hParent = hParentItem; + tvSort.lpfnCompare = CompareFunc; + tvSort.lParam = (LPARAM)this; + _TreeCtrl.SortChildrenCB( &tvSort ); + } + + pEnum->Release(); + return true; + } + return false; +} + +void CFileTreeCtrl::doItemMenu (HWND hwndTreeView, HTREEITEM hItem, LPPOINT pptScreen) +{ + TVITEM tvItem; + + ZeroMemory(&tvItem, sizeof(tvItem)); + tvItem.mask = TVIF_PARAM; + tvItem.hItem = hItem; + + if(TreeView_GetItem(hwndTreeView, &tvItem)) + { + HWND hwndParent = ::GetParent(hwndTreeView); + HRESULT hr; + CTreeItemInfo* pInfo = (CTreeItemInfo*)tvItem.lParam; + IContextMenu *pcm; + IShellFolder *psfFolder = pInfo->pParentFolder; + + if(!psfFolder) + { + SHGetDesktopFolder(&psfFolder); + } + else + { + psfFolder->AddRef(); + } + + if(psfFolder) + { + hr = psfFolder->GetUIObjectOf( hwndParent, + 1, + (LPCITEMIDLIST*)&pInfo->pidlSelf, + IID_IContextMenu, + NULL, + (LPVOID*)&pcm); + + if(SUCCEEDED(hr)) + { + HMENU hPopup; + + hPopup = CreatePopupMenu(); + if(hPopup) + { + hr = pcm->QueryContextMenu(hPopup, 0, 1, 0x7fff, CMF_NORMAL | CMF_EXPLORE); + + if(SUCCEEDED(hr)) + { + IContextMenu2* pcm2; + pcm->QueryInterface(IID_IContextMenu2, (LPVOID*)&pcm2); + + UINT idCmd; + + idCmd = TrackPopupMenu( hPopup, + TPM_LEFTALIGN | TPM_RETURNCMD | TPM_RIGHTBUTTON, + pptScreen->x, + pptScreen->y, + 0, + hwndParent, + NULL); + + if(pcm2) + { + pcm2->Release(); + pcm2 = NULL; + } + + if(idCmd) + { + CMINVOKECOMMANDINFO cmi; + cmi.cbSize = sizeof(CMINVOKECOMMANDINFO); + cmi.fMask = 0; + cmi.hwnd = hwndParent; + cmi.lpVerb = (LPCSTR)(INT_PTR)(idCmd - 1); + cmi.lpParameters = NULL; + cmi.lpDirectory = NULL; + cmi.nShow = SW_SHOWNORMAL; + cmi.dwHotKey = 0; + cmi.hIcon = NULL; + hr = pcm->InvokeCommand(&cmi); + } + } + } + pcm->Release(); + } + psfFolder->Release(); + } + } +} + +void CFileTreeCtrl::doClick (HWND hwndTreeView, HTREEITEM hItem) +{ + TVITEM tvItem; + + ZeroMemory(&tvItem, sizeof(tvItem)); + tvItem.mask = TVIF_PARAM; + tvItem.hItem = hItem; + + if(TreeView_GetItem(hwndTreeView, &tvItem)) + { + HWND hwndParent = ::GetParent(hwndTreeView); + CTreeItemInfo* pItemInfo = (CTreeItemInfo*)tvItem.lParam; + + // Notify parent + if (pItemInfo) + if (_HWndNotify) + ::SendMessage (_HWndNotify, WM_FILE_TREE_VIEW_LDBLCLICK, (pItemInfo->dwFlags&SFGAO_FOLDER)!=0, _NotifyParam); + } +} + +void CFileTreeCtrl::setArrangeMode (TArrange arrangeMode) +{ + _ArrangeMode = arrangeMode; + + // Set the directory + setRootDirectory (_RootDirectory.c_str()); +} + +void CFileTreeCtrl::OnSize(UINT nType, int cx, int cy) +{ + CWnd::OnSize(nType, cx, cy); + + CRect sz; + GetClientRect(sz); + //sz.DeflateRect(5,0); + if (IsWindow (_TreeCtrl)) + _TreeCtrl.MoveWindow(sz); +} + +void CFileTreeCtrl::addExclusiveExtFilter (const char *ext) +{ + _ExclusiveExtFilter.push_back (ext); +} + +void CFileTreeCtrl::addNegativeExtFilter (const char *ext) +{ + _NegativeExtFilter.push_back (ext); +} + +void CFileTreeCtrl::clearExtFilters () +{ + _ExclusiveExtFilter.clear (); + _NegativeExtFilter.clear (); +} + +void CFileTreeCtrl::setNotifyWindow (HWND hWnd, uint32 param) +{ + _HWndNotify = hWnd; + _NotifyParam = param; +} + +bool CFileTreeCtrl::getCurrentFilename (std::string &result) +{ + HTREEITEM curSel = _TreeCtrl.GetSelectedItem (); + if (curSel) + { + CString str = _TreeCtrl.GetItemText (curSel); + result = str; + return true; + } + return false; +} + +void CFileTreeCtrl::OnSetFocus(CWnd* pOldWnd) +{ + CWnd::OnSetFocus(pOldWnd); + + _TreeCtrl.SetFocus (); +} + +bool CFileTreeCtrl::haveFocus () +{ + return _TreeCtrl.GetFocus () == &_TreeCtrl; +} diff --git a/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.h b/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.h index 849120ae5..bdfb5b050 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.h +++ b/code/ryzom/tools/leveldesign/georges_dll/file_tree_view.h @@ -1,92 +1,92 @@ -// 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 __FILE_TREE_VIEW_H -#define __FILE_TREE_VIEW_H - -#include - -/** - * Send to notify window (registered with setNotifyWindow() ). - * wParam is TRUE if the item is a directory - */ -#define WM_FILE_TREE_VIEW_LDBLCLICK (WM_APP+0x40) - -class CFileTreeCtrl : public CWnd -{ -public: - friend int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CFileTreeCtrl) - protected: - virtual int OnCreate ( LPCREATESTRUCT lpCreateStruct ); - virtual BOOL OnNotify ( WPARAM wParam, LPARAM lParam, LRESULT* pResult ); - //}}AFX_VIRTUAL - -public: - CFileTreeCtrl (); - - enum TArrange - { - None = 0, - ByName, - ByType - }; - - bool create( const RECT& rect, CWnd* pParentWnd, UINT nID ); - bool setRootDirectory (const char *dir); - void setArrangeMode (TArrange arrangeMode); - bool enumObjects (HTREEITEM hParentItem,IShellFolder* pParentFolder, ITEMIDLIST* pidlParent); - void doItemMenu (HWND hwndTreeView, HTREEITEM hItem, LPPOINT pptScreen); - void doClick (HWND hwndTreeView, HTREEITEM hItem); - void addExclusiveExtFilter (const char *ext); - void addNegativeExtFilter (const char *ext); - void clearExtFilters (); - void setNotifyWindow (HWND hWnd, uint32 param); - bool getCurrentFilename (std::string &result); - bool haveFocus (); - - virtual ~CFileTreeCtrl(); - - // Overrided - BOOL ShowWindow ( int nCmdShow ); - -private: - HWND _HWndNotify; - uint32 _NotifyParam; - CTreeCtrl _TreeCtrl; - std::string _RootDirectory; - HIMAGELIST _ImageListSmall; - TArrange _ArrangeMode; - - // Filter - std::vector _ExclusiveExtFilter; - std::vector _NegativeExtFilter; - - // Generated message map functions - //{{AFX_MSG(CFileTreeCtrl) - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnSetFocus(CWnd* pOldWnd); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // __FILE_TREE_VIEW_H +// 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 __FILE_TREE_VIEW_H +#define __FILE_TREE_VIEW_H + +#include + +/** + * Send to notify window (registered with setNotifyWindow() ). + * wParam is TRUE if the item is a directory + */ +#define WM_FILE_TREE_VIEW_LDBLCLICK (WM_APP+0x40) + +class CFileTreeCtrl : public CWnd +{ +public: + friend int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CFileTreeCtrl) + protected: + virtual int OnCreate ( LPCREATESTRUCT lpCreateStruct ); + virtual BOOL OnNotify ( WPARAM wParam, LPARAM lParam, LRESULT* pResult ); + //}}AFX_VIRTUAL + +public: + CFileTreeCtrl (); + + enum TArrange + { + None = 0, + ByName, + ByType + }; + + bool create( const RECT& rect, CWnd* pParentWnd, UINT nID ); + bool setRootDirectory (const char *dir); + void setArrangeMode (TArrange arrangeMode); + bool enumObjects (HTREEITEM hParentItem,IShellFolder* pParentFolder, ITEMIDLIST* pidlParent); + void doItemMenu (HWND hwndTreeView, HTREEITEM hItem, LPPOINT pptScreen); + void doClick (HWND hwndTreeView, HTREEITEM hItem); + void addExclusiveExtFilter (const char *ext); + void addNegativeExtFilter (const char *ext); + void clearExtFilters (); + void setNotifyWindow (HWND hWnd, uint32 param); + bool getCurrentFilename (std::string &result); + bool haveFocus (); + + virtual ~CFileTreeCtrl(); + + // Overrided + BOOL ShowWindow ( int nCmdShow ); + +private: + HWND _HWndNotify; + uint32 _NotifyParam; + CTreeCtrl _TreeCtrl; + std::string _RootDirectory; + HIMAGELIST _ImageListSmall; + TArrange _ArrangeMode; + + // Filter + std::vector _ExclusiveExtFilter; + std::vector _NegativeExtFilter; + + // Generated message map functions + //{{AFX_MSG(CFileTreeCtrl) + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnSetFocus(CWnd* pOldWnd); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // __FILE_TREE_VIEW_H diff --git a/code/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp b/code/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp index 0b9181de3..a770c8b8c 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/form_dialog.cpp @@ -1,2870 +1,2870 @@ -// 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 . - -// form_dialog.cpp : implementation file -// - -#include "stdafx.h" -#include "georges_edit.h" -#include "georges_edit_view.h" -#include "georges_edit_doc.h" -#include "form_dialog.h" -#include "action.h" -#include "left_view.h" - -#include "nel/misc/path.h" -#include "nel/georges/type.h" -#include "nel/georges/form_elm.h" - -using namespace std; -using namespace NLMISC; -using namespace NLGEORGES; - - -// Define this to show Formula value evaluation intstead of value evaluation -// #define TEST_EVAL_FORMULA - -// *************************************************************************** -// CFormDialog dialog -// *************************************************************************** - -CFormDialog::CFormDialog () : CBaseDialog (IDR_MAINFRAME) -{ - //{{AFX_DATA_INIT(CFormDialog) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT - View = NULL; - WidgetIndexCount = 0; - WidgetFocused = 0xffffffff; -} - -// *************************************************************************** - -CFormDialog::~CFormDialog () -{ - clear (); -} - -// *************************************************************************** - -void CFormDialog::clear () -{ - unRegisterLastControl (); - for (uint i=0; iupdateData (); - if (Widgets[i]->haveFocus ()) - { - Widgets[i]->onOk (); - } - } -} - -// *************************************************************************** - -void CFormDialog::OnCancel () -{ - for (uint i=0; iupdateData (); - if (Widgets[i]->haveFocus ()) - { - Widgets[i]->onCancel (); - return; - } - } - CBaseDialog::OnCancel (); -} - -// *************************************************************************** - -CWnd* CFormDialog::addTypeWidget (const NLGEORGES::CType &type, uint elmIndex, const char *title, const char *atomName, const char *typeFilename, RECT ¤tPos, CForm &form, IFormWidget::TTypeSrc typeWidget, const char *filenameExt, uint slot) -{ - // What kind of UI ? - switch (type.UIType) - { - case CType::FileBrowser: - case CType::Edit: - case CType::EditSpin: - { - // For edit type, use a memory combobox - CFormMemCombo *memCombo = new CFormMemCombo (this, elmIndex, atomName, typeWidget, slot); - Widgets.push_back (memCombo); - - // Create a reg key - string tfn = typeFilename; - string key = GEORGES_EDIT_BASE_REG_KEY"\\"+strlwr (typeFilename)+" MemCombo"; - - // Create the widget - memCombo->create (WS_CHILD|WS_TABSTOP, currentPos, this, WidgetIndexCount, title, key.c_str(), type.UIType==CType::EditSpin, type.UIType==CType::FileBrowser, filenameExt); - - // Get from document - memCombo->getFromDocument (form); - - return &memCombo->Combo; - } - break; - case CType::NonEditableCombo: - { - // For edit type, use a memory combobox - CFormCombo *memCombo = new CFormCombo (this, elmIndex, atomName, typeWidget, slot); - Widgets.push_back (memCombo); - - // Create the widget - memCombo->create (WS_CHILD|WS_TABSTOP, currentPos, this, WidgetIndexCount, title); - - // Get from document - memCombo->getFromDocument (form); - - return &memCombo->Combo; - } - break; - case CType::BigEdit: - { - // For edit type, use a memory combobox - CFormBigEdit *memCombo = new CFormBigEdit (this, elmIndex, atomName, typeWidget, slot); - Widgets.push_back (memCombo); - - // Create the widget - memCombo->create (WS_CHILD|WS_TABSTOP, currentPos, this, WidgetIndexCount, title); - - // Get from document - memCombo->getFromDocument (form); - - return &memCombo->Edit; - } - break; - case CType::ColorEdit: - { - // For edit type, use a memory combobox - CColorEdit *memCombo = new CColorEdit (this, elmIndex, atomName, typeWidget, slot); - Widgets.push_back (memCombo); - - // Create the widget - memCombo->create (WS_CHILD|WS_TABSTOP, currentPos, this, WidgetIndexCount, title); - - // Get from document - memCombo->getFromDocument (form); - - return &memCombo->Color; - } - break; - } - - return NULL; -} - -// *************************************************************************** - -void CFormDialog::getVirtualDfnFromDocument (const NLGEORGES::CFormDfn *_dfn, const char *structName, uint slot) -{ - if (View) - { - CGeorgesEditDoc *doc = View->GetDocument (); - if (doc) - { - // Clear the current dialog - clear (); - - // Reserve some widget pointers - Widgets.reserve (10); - - // Widget placement - RECT currentPos; - getFirstItemPos (currentPos); - - // For edit type, use a memory combobox - CFormMemCombo *memCombo = new CFormMemCombo (this, 0xffffffff, structName, IFormWidget::TypeVirtualDfn, slot); - Widgets.push_back (memCombo); - - // Create the widget - memCombo->create (WS_CHILD|WS_TABSTOP, currentPos, this, WidgetIndexCount, "Dfn:", - GEORGES_EDIT_BASE_REG_KEY"\\Virtual Dfn MemCombo", false, true, "*.dfn"); - - // Get from document - memCombo->getFromDocument (*doc->getFormPtr ()); - - // Dfn selected ? - if (_dfn) - { - // Get the parent DFN - std::vector arrayDfn; - arrayDfn.reserve (_dfn->countParentDfn ()); - _dfn->getParentDfn (arrayDfn); - - // Element index - uint elmIndex = 0; - - // For each DFN - for (uint dfnIndex=0; dfnIndexgetFormPtr (), IFormWidget::TypeForm, - entry.getFilenameExt ().c_str (), slot); - } - - // Next form index - elmIndex++; - } - } - } - - // Register last control for tab selection - registerLastControl (); - } - } -} - -// *************************************************************************** -void CFormDialog::getDfnFromDocument (const NLGEORGES::CFormDfn &_dfn, const char *structName, uint slot) -{ - if (View) - { - CGeorgesEditDoc *doc = View->GetDocument (); - if (doc) - { - // Clear the current dialog - clear (); - - // Reserve some widget pointers - Widgets.reserve (10); - - // Widget placement - RECT currentPos; - getFirstItemPos (currentPos); - - // Get the parent DFN - std::vector arrayDfn; - arrayDfn.reserve (_dfn.countParentDfn ()); - _dfn.getParentDfn (arrayDfn); - - // For edit type, use a memory combobox - if (strcmp (structName, "") == 0) - { - CListWidget *listWidget = new CListWidget (this, 0xffffffff, "", IFormWidget::TypeFormParent, slot); - Widgets.push_back (listWidget); - - // Create the widget - listWidget->create (WS_CHILD|WS_TABSTOP, currentPos, this, WidgetIndexCount, "Parent Form:", - GEORGES_EDIT_BASE_REG_KEY"\\Parent Form MemCombo", 1); - - // Add one column - listWidget->addColumn ("Parent filename"); - - // Get from document - listWidget->getFromDocument (*doc->getFormPtr ()); - } - - // store icon related infos - CWnd *pWnd = NULL; - CWnd *pWndIcon = NULL; - CWnd *pWndIconColor = NULL; - CWnd *pWndIconBack = NULL; - CWnd *pWndIconBackColor = NULL; - CWnd *pWndIconOver = NULL; - CWnd *pWndIconOverColor = NULL; - CWnd *pWndIconOver2 = NULL; - CWnd *pWndIconOver2Color = NULL; - - // Element index - uint elmIndex = 0; - - // For each DFN - for (uint dfnIndex=0; dfnIndexgetFormPtr (), IFormWidget::TypeForm, - entry.getFilenameExt ().c_str (), slot); - - if (entry.getName() == "Icon" || entry.getName() == "icon") - pWndIcon = pWnd; - else if (entry.getName() == "IconColor") - pWndIconColor = pWnd; - else if (entry.getName() == "IconBack" || entry.getName() == "icon background") - pWndIconBack = pWnd; - else if (entry.getName() == "IconBackColor") - pWndIconBackColor = pWnd; - else if (entry.getName() == "IconOver" || entry.getName() == "icon overlay") - pWndIconOver = pWnd; - else if (entry.getName() == "IconOverColor") - pWndIconOverColor = pWnd; - else if (entry.getName() == "IconOver2" || entry.getName() == "icon overlay2") - pWndIconOver2 = pWnd; - else if (entry.getName() == "IconOver2Color") - pWndIconOver2Color = pWnd; - } - - // Next form index - elmIndex++; - } - } - - // Special case for ".Client" and ".3d" : add a widget to draw icons - if ((string(structName) == ".Client") || (string(structName) == ".3d")) - { - string title = "Icon bitmap:"; - - CIconWidget *w = new CIconWidget (this, elmIndex, "", IFormWidget::TypeFormParent, slot); - Widgets.push_back (w); - - // Create the widget - w->create (WS_CHILD|WS_TABSTOP, currentPos, this, WidgetIndexCount, title.c_str()); - - // - w->Icon.pWndIcon = pWndIcon; - w->Icon.pWndIconColor = pWndIconColor; - - w->Icon.pWndIconBack = pWndIconBack; - w->Icon.pWndIconBackColor = pWndIconBackColor; - - w->Icon.pWndIconOver = pWndIconOver; - w->Icon.pWndIconOverColor = pWndIconOverColor; - - w->Icon.pWndIconOver2 = pWndIconOver2; - w->Icon.pWndIconOver2Color = pWndIconOver2Color; - } - - // Register last control for tab selection - registerLastControl (); - } - } -} - -// *************************************************************************** - -void CFormDialog::getArrayFromDocument (const char *structName, uint structId, uint slot) -{ - if (View) - { - CGeorgesEditDoc *doc = View->GetDocument (); - if (doc) - { - // Clear the current dialog - clear (); - - // Reserve some widget pointers - Widgets.reserve (10); - - // Widget placement - RECT currentPos; - getFirstItemPos (currentPos); - - CFormMemCombo *memCombo = new CFormMemCombo (this, structId, structName, IFormWidget::TypeArray, slot); - Widgets.push_back (memCombo); - - // Create the widget - memCombo->create (WS_CHILD|WS_TABSTOP, currentPos, this, WidgetIndexCount, "Array size:", - GEORGES_EDIT_BASE_REG_KEY"\\Array Size MemCombo", true, false, NULL); - - // Get from document - memCombo->getFromDocument (*doc->getFormPtr ()); - - // Register last control for tab selection - registerLastControl (); - } - } -} - -// *************************************************************************** - -void CFormDialog::getTypeFromDocument (const NLGEORGES::CType &_type, const char *name, const char *typeFilename, const char *structName, uint slot) -{ - if (View) - { - CGeorgesEditDoc *doc = View->GetDocument (); - if (doc) - { - // Clear the current dialog - clear (); - - // Reserve some widget pointers - Widgets.reserve (10); - - // Widget placement - RECT currentPos; - getFirstItemPos (currentPos); - - // Some string - addTypeWidget (_type, 0xffffffff, name, structName, typeFilename, currentPos, *doc->getFormPtr (), IFormWidget::TypeType, NULL, slot); - - // Register last control for tab selection - registerLastControl (); - } - } -} - -// *************************************************************************** - -void CFormDialog::updateLabels () -{ - for (uint i=0; iupdateLabel (); - } -} - -// *************************************************************************** - -void CFormDialog::updateValues () -{ - for (uint i=0; iupdateLabel (); - Widgets[i]->getFromDocument (*(View->GetDocument ()->getFormPtr ())); - } -} - -// *************************************************************************** - -void CFormDialog::setToDocument (uint widget) -{ - CGeorgesEditDoc *doc = View->GetDocument (); - if (doc) - { - // discard CIconWidget - CIconWidget *iconWidget = dynamic_cast (Widgets[widget]); - if (iconWidget) - return; - - // Check if this command will build a new array / virtual dfn that was inherited.. - if (Widgets[widget]->getFormName () != "NULL") - { - // Get current node - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - bool parentVDfnArray; - CForm *form=doc->getFormPtr (); - CFormElm *elm = doc->getRootNode (Widgets[widget]->getSlot ()); - nlverify ( elm->getNodeByName (Widgets[widget]->getFormName ().c_str (), &parentDfn, indexDfn, - &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); - - // Must create array or virtual dfn ? - if (parentVDfnArray) - { - // Warn the user - if (!theApp.yesNo ("Warning, this action will create an array/virtual dfn over an inherited array/virtual dfn.\nDo you want to continue ?")) - // Quit - return; - } - } - - // Get the widget type - IFormWidget::TTypeSrc typeSrc = Widgets[widget]->getSrcType (); - if (typeSrc == IFormWidget::TypeForm) - { - // Get the value - std::string result; - Widgets[widget]->getValue (result); - - // Document modified - doc->modify (new CActionString (IAction::FormValue, result.c_str (), *doc, Widgets[widget]->getFormName ().c_str (), "", - doc->getLeftView ()->getCurrentSelectionId (), Widgets[widget]->getSlot ())); - } - else if (typeSrc == IFormWidget::TypeFormParent) - { - // The form - CForm *form = doc->getFormPtr (); - - // Build an array of strings - uint count = Widgets[widget]->getNumValue (); - vector stringVector (count); - for (uint value = 0; valuegetValue (stringVector[value], value); - } - - // Modify document - doc->modify (new CActionStringVector (IAction::FormParents, stringVector, *doc, "", - doc->getLeftView ()->getCurrentSelectionId (), Widgets[widget]->getSlot ())); - } - else if (typeSrc == IFormWidget::TypeArray) - { - // Get the value - std::string result; - Widgets[widget]->getValue (result); - - // Modify document - doc->modify (new CActionBuffer (IAction::FormArraySize, NULL, 0, *doc, Widgets[widget]->getFormName ().c_str(), - result.c_str (), doc->getLeftView ()->getCurrentSelectionId (), Widgets[widget]->getSlot ())); - } - else if (typeSrc == IFormWidget::TypeType) - { - // Get the result value - std::string result; - Widgets[widget]->getValue (result); - - // Document is modified by this view - doc->modify (new CActionString (IAction::FormTypeValue, result.c_str (), *doc, Widgets[widget]->getFormName().c_str(), "", - doc->getLeftView ()->getCurrentSelectionId (), Widgets[widget]->getSlot ())); - } - else if (typeSrc == IFormWidget::TypeVirtualDfn) - { - // Get the value - std::string result; - Widgets[widget]->getValue (result); - - // Modify the document - doc->modify (new CActionBuffer (IAction::FormVirtualDfnName, NULL, 0, *doc, Widgets[widget]->getFormName ().c_str (), - result.c_str (), doc->getLeftView ()->getCurrentSelectionId (), Widgets[widget]->getSlot ())); - } - } - - // Notify the plugin that the value has changed - if (!Widgets[widget]->getFormName ().empty ()) - doc->notifyPlugins (Widgets[widget]->getFormName ().c_str ()); -} - -// *************************************************************************** - -LRESULT CFormDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case CL_CHANGED: - { - uint widgetId = getWidget (wParam); - CColorEdit *colorEdit = safe_cast (Widgets[widgetId]); - colorEdit->Empty = false; - setToDocument (getWidget (wParam)); - } - break; - case MC_STRINGCHANGE: - { - setToDocument (getWidget (wParam)); - } - break; - - case CBN_CHANGED: - { - for (uint i=0 ; i (Widgets[i]); - if (iconWidget) - iconWidget->Icon.Invalidate(); - } - } - break; - } - - return CDialog::WindowProc(message, wParam, lParam); -} - -// *************************************************************************** - -void CFormDialog::onOpenSelected () -{ - // Get the focus windows - for (uint i=0; ihaveFocus ()) - { - Widgets[i]->onOpenSelected (); - /*CFormMemCombo *combo = dynamic_cast (Widgets[i]); - if (combo) - { - CString str; - combo->Combo.GetWindowText (str); - if (combo->Browse && (str != "")) - { - std::string str2=CPath::lookup ((const char*)str, false, false); - if (str2.empty()) - str2 = (const char*)str; - theApp.OpenDocumentFile (str2.c_str ()); - } - }*/ - } - } -} - -// *************************************************************************** - -CWnd* CFormDialog::GetNextDlgTabItem( CWnd* pWndCtl, BOOL bPrevious) const -{ - return NULL; -} - -// *************************************************************************** - -void CFormDialog::onFirstFocus () -{ - View->SetFocus (); - WidgetFocused = 0xffffffff; -} - -// *************************************************************************** - -void CFormDialog::onLastFocus () -{ - View->setFocusLeftView (); - WidgetFocused = 0xffffffff; -} - -// *************************************************************************** - -int CFormDialog::getWidget (uint dialogId) const -{ - for (uint i=0; iisDialog (dialogId)) - return i; - } - return -1; -} - -// *************************************************************************** - -BOOL CFormDialog::OnCommand(WPARAM wParam, LPARAM lParam) -{ - switch (HIWORD(wParam)) - { - case CBN_SETFOCUS: - { - onGetSubFocus (LOWORD(wParam)); - } - return TRUE; - case EN_SETFOCUS: - { - onGetSubFocus (LOWORD(wParam)); - } - return TRUE; - /*case CBN_SELENDOK: - { - // Look for the widget - int widgetId = getWidget (LOWORD(wParam)); - if (widgetId != -1) - setToDocument (widgetId); - } - return TRUE;*/ - case CBN_SELCHANGE: - { - // Look for the widget - int widgetId = getWidget (LOWORD(wParam)); - if (widgetId != -1) - setToDocument (widgetId); - } - return TRUE; - case EN_CHANGE: - { - // Look for the widget - int widgetId = getWidget (LOWORD(wParam)); - if (widgetId != -1) - { - CColorEdit *colorEdit = dynamic_cast (Widgets[widgetId]); - if (colorEdit) - { - CString str; - colorEdit->Edit.GetWindowText (str); - - sint r, g, b; - if (sscanf (str, "%d,%d,%d", &r, &g, &b) == 3) - { - clamp (r, 0, 255); - clamp (g, 0, 255); - clamp (b, 0, 255); - CRGBA color (r, g, b); - colorEdit->Color.setColor (color); - if (r != 255 && g != 255 && b != 255) - colorEdit->Empty = false; - } - } - } - } - return TRUE; - case BN_CLICKED: - { - // Get the window - int widgetId = getWidget (LOWORD(wParam)); - - // Dialog Pointer - if (widgetId != -1) - { - if ( (Widgets[widgetId]->getSrcType () == IFormWidget::TypeForm) || (Widgets[widgetId]->getSrcType () == IFormWidget::TypeType)) - { - CFormMemCombo *combo = dynamic_cast (Widgets[widgetId]); - if (combo && IsWindow (combo->Browse)) - { - CGeorgesEditDoc *doc = View->GetDocument (); - if (doc) - { - // Get current node - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - bool parentVDfnArray; - CForm *form=doc->getFormPtr (); - CFormElm *elm = doc->getRootNode (Widgets[widgetId]->getSlot ()); - nlverify ( elm->getNodeByName (Widgets[widgetId]->getFormName ().c_str (), &parentDfn, indexDfn, - &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); - nlassert (parentDfn); - - // Get the current filename extension - string ext = parentDfn->getEntry (indexDfn).getFilenameExt (); - - // Build a nice type name - char typeName[512]; - smprintf (typeName, 512, "%s", strlwr (ext).c_str()); - uint i=0; - while ((typeName[i] == '.') || (typeName[i] == '*')) - i++; - if (typeName[i]) - typeName[i] = toupper (typeName[i]); - - // Biuld the filter string - char filter[512]; - smprintf (filter, 512, "%s Files (%s)|%s|All Files(*.*)|*.*|", typeName+i, ext.c_str(), ext.c_str()); - - // Open the dialog - CFileDialog dlgFile (TRUE, ext.c_str (), ext.c_str (), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, filter, theApp.m_pMainWnd); - if (dlgFile.DoModal () == IDOK) - { - combo->Combo.UpdateData (); - combo->Combo.SetWindowText (dlgFile.GetFileName ()); - combo->Combo.UpdateData (FALSE); - setToDocument (widgetId); - PostMessage (CBN_CHANGED, 0, 0); - } - } - } - else - { - // Reset button of color edit ? - CColorEdit *colorEdit = dynamic_cast (Widgets[widgetId]); - if (colorEdit && IsWindow (colorEdit->Color)) - { - colorEdit->Empty = true; - colorEdit->Edit.SetWindowText(""); - setToDocument (getWidget (wParam)); - updateValues (); - } - } - } - else if (Widgets[widgetId]->getSrcType () == IFormWidget::TypeVirtualDfn) - { - CFormMemCombo *combo = dynamic_cast (Widgets[widgetId]); - if (combo && IsWindow (combo->Browse)) - { - CGeorgesEditDoc *doc = View->GetDocument (); - if (doc) - { - // Build the filter string - char filter[512]; - smprintf (filter, 512, "Dfn Files (*.dfn)|*.dfn|All Files(*.*)|*.*|"); - - // Open the dialog - CFileDialog dlgFile (TRUE, "*.dfn", "*.dfn", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, filter, theApp.m_pMainWnd); - if (dlgFile.DoModal () == IDOK) - { - combo->Combo.UpdateData (); - combo->Combo.SetWindowText (dlgFile.GetFileName ()); - combo->Combo.UpdateData (FALSE); - setToDocument (widgetId); - } - } - } - } - else if (Widgets[widgetId]->getSrcType () == IFormWidget::TypeFormParent) - { - setToDocument (widgetId); - } - } - } - return TRUE; - } - - return CWnd::OnCommand(wParam, lParam); -} - -// *************************************************************************** - -BOOL CFormDialog::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) -{ - LPNMHDR pnmh = (LPNMHDR) lParam; - - // Get the CTRL ID - int idCtrl = (int) wParam; - - switch (pnmh->code) - { - case NM_SETFOCUS: - { - onGetSubFocus (idCtrl); - } - break; - // Spinner control - case UDN_DELTAPOS: - { - // Get the window - for (uint i=0; iisDialog (idCtrl)) - { - // Get the node type - Widgets[i]->getFormName (); - - // Get the structure - LPNMUPDOWN lpnmud = (LPNMUPDOWN) lParam; - - // Get a good pointer - CFormMemCombo *combo = (CFormMemCombo*)Widgets[i]; - - // Get the widget value - float value; - CString str; - combo->Combo.UpdateData (); - combo->Combo.GetWindowText (str); - if (sscanf (str, "%f", &value) == 1) - { - CGeorgesEditDoc *doc = View->GetDocument(); - if (doc) - { - // Get the node - const CFormDfn *parentDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - uint lastElement; - bool array; - bool parentVDfnArray; - UFormDfn::TEntryType type; - - // Search for the node - nlverify ((const CFormElm*)(doc->getRootNode (Widgets[i]->getSlot ()))->getNodeByName - (Widgets[i]->getFormName ().c_str (), &parentDfn, lastElement, &nodeDfn, &nodeType, - &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND)); - - // Todo: multiply here by the spinner precision - float increment = 1; - if (nodeType) - sscanf (nodeType->Increment.c_str (), "%f", &increment); - - value -= (float)(lpnmud->iDelta) * increment; - - // Print the result - char result[512]; - sprintf (result, "%g", value); - - // Set the windnow text - combo->Combo.SetWindowText (result); - combo->Combo.UpdateData (FALSE); - - // Update the widget - setToDocument (i); - } - } - break; - } - } - } - break; - } - - return CDialog::OnNotify(wParam, lParam, pResult); -} - -// *************************************************************************** - -void CFormDialog::resizeWidgets () -{ - if (Widgets.size ()) - { - RECT viewRect; - View->GetClientRect (&viewRect); - uint virtualWidth = std::max ((uint)MinViewWidth, (uint)(viewRect.right-viewRect.left)); - - // Refresh sizes - CBaseDialog::resizeWidgets (virtualWidth, 0); - - // Get first item coordinate - RECT currentPos; - getFirstItemPos (currentPos); - - // For each widgets - uint bigWidgetCount[2] = {0, 0}; - uint i; - uint biggestBottom[2] = {0, 0}; - uint nextSplit = Widgets.size ()/2; - for (i=0; inextSplit) ? 1:0; - - Widgets[i]->resizeScan (currentPos, bigWidgetCount[column], 0, false); - - if (currentPos.bottom > (int)biggestBottom[column]) - { - biggestBottom[column] = currentPos.bottom; - } - - if (nextSplit == i) - { - getNextColumn (currentPos); - currentPos.top = 0; - } - } - - // Refresh sizes - uint adjust[2]; - CBaseDialog::resizeWidgets (virtualWidth, biggestBottom[0]); - adjust[0] = AdjusteHeight; - CBaseDialog::resizeWidgets (virtualWidth, biggestBottom[1]); - adjust[1] = AdjusteHeight; - - // Get first item coordinate - currentPos; - getFirstItemPos (currentPos); - - uint adjustSum[2] = { - bigWidgetCount[0] ? adjust[0] / bigWidgetCount[0] : 0, - bigWidgetCount[1] ? adjust[1] / bigWidgetCount[1] : 0 }; - biggestBottom[0] = 0; - biggestBottom[1] = 0; - for (i=0; inextSplit) ? 1:0; - - if (Widgets[i]->extendableHeight ()) - { - Widgets[i]->resizeScan (currentPos, bigWidgetCount[column], adjustSum[column], true); - adjust[column] -= adjustSum[column]; - } - else - Widgets[i]->resizeScan (currentPos, bigWidgetCount[column], 0, true); - - if (currentPos.bottom > (int)biggestBottom[column]) - { - biggestBottom[column] = currentPos.bottom; - } - - if (nextSplit == i) - { - getNextColumn (currentPos); - currentPos.top = 0; - } - } - - uint column = (i>nextSplit) ? 1:0; - Widgets[i]->resizeScan (currentPos, bigWidgetCount[column], adjust[column], true); - - if (currentPos.bottom > (int)biggestBottom[column]) - { - biggestBottom[column] = currentPos.bottom; - } - - // Resize the current view - View->setViewSize (virtualWidth, std::max (biggestBottom[0], biggestBottom[1])+CGeorgesEditView::WidgetTopMargin+CGeorgesEditView::WidgetBottomMargin); - } -} - -// *************************************************************************** - -void CFormDialog::getFromDocument () -{ - CGeorgesEditDoc *doc = View->GetDocument(); - if (doc) - { - // Save current focus - uint widgetFocus; - for (widgetFocus=0; widgetFocushaveFocus ()) - break; - } - - // Current selection - CGeorgesEditDocSub *subObject = doc->getSelectedObject (); - - // Get the node - const CFormDfn *parentDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - uint lastElement; - bool array; - bool parentVDfnArray; - UFormDfn::TEntryType type; - - // Search for the node - nlverify (((const CFormElm*)(doc->getRootNode (subObject->getSlot ())))->getNodeByName (subObject->getFormName ().c_str (), &parentDfn, lastElement, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND)); - - // Should have a parent DFN, else it is the root element - if (parentDfn) - { - // Is an array ? - if ( array ) - { - // Must be a dfn - nlassert ( (type==UFormDfn::EntryDfn) || (type==UFormDfn::EntryType)); - getArrayFromDocument (subObject->getFormName ().c_str (), lastElement, subObject->getSlot ()); - } - else - { - // Is a struct ? - switch (parentDfn->getEntry (lastElement).getType ()) - { - // Type - case UFormDfn::EntryType: - nlassert ( !array ); - nlassert ( nodeType ); - nlassert ( parentDfn ); - nlassert (type==UFormDfn::EntryType); - getTypeFromDocument (*nodeType, - (parentDfn->getEntry(lastElement).getName()+":").c_str (), - parentDfn->getEntry(lastElement).getFilename().c_str(), - subObject->getFormName ().c_str (), subObject->getSlot ()); - break; - // Dfn - case UFormDfn::EntryDfn: - nlassert ( !array ); - nlassert ((nodeDfn) && (type==UFormDfn::EntryDfn)); - getDfnFromDocument (*nodeDfn, subObject->getFormName ().c_str (), subObject->getSlot ()); - break; - // Virtual Dfn - case UFormDfn::EntryVirtualDfn: - nlassert ( !array ); - getVirtualDfnFromDocument (nodeDfn, subObject->getFormName ().c_str (), subObject->getSlot ()); - break; - } - } - } - else - { - nlassert ( !array ); - nlassert ((nodeDfn) && (type==UFormDfn::EntryDfn)); - getDfnFromDocument (*nodeDfn, subObject->getFormName ().c_str (), subObject->getSlot ()); - } - - // Update labels - for (uint i=0; iupdateLabel (); - } - - // Set the focus - if (widgetFocussetFocus (); - } - - // Resize the widgets - resizeWidgets (); - } -} - -// *************************************************************************** - -void CFormDialog::getDfnName (string &result) const -{ - CGeorgesEditDoc *doc = View->GetDocument (); - if (doc) - { - // Get the DFN filename - CString str = doc->GetPathName (); - char extension[512]; - _splitpath (str, NULL, NULL, NULL, extension); - result = (*extension == '.') ? extension+1 : extension; - } - else - result = ""; -} - -// *************************************************************************** - -void CFormDialog::OnLButtonDown(UINT nFlags, CPoint point) -{ - // Get the focus - View->TabCtrl.SetFocus (); - - CDialog::OnLButtonDown(nFlags, point); -} - -// *************************************************************************** - -void CFormDialog::onGetSubFocus (uint id) -{ - // Get the widget - int widget = getWidget (id); - WidgetFocused = widget; - - // Window view - RECT widgetRect; - if (Widgets[widget]->getWindowRect (widgetRect)) - { - View->ScreenToClient (&widgetRect); - - // Scroll the view to be visible - RECT viewRect; - View->GetClientRect (&viewRect); - int bottom = viewRect.bottom - viewRect.top; - if (widgetRect.bottom > bottom) - { - CPoint pt = View->GetScrollPosition (); - View->ScrollToPosition (CPoint (pt.x, pt.y + widgetRect.bottom - bottom + 10)); - } - if (widgetRect.top < 0) - { - CPoint pt = View->GetScrollPosition (); - View->ScrollToPosition (CPoint (pt.x, pt.y + widgetRect.top - 10)); - } - } -} - -// *************************************************************************** - -void CFormDialog::OnSetFocus(CWnd* pNewWnd) -{ - CDialog::OnSetFocus(pNewWnd); - if (WidgetFocused != 0xffffffff) - Widgets[WidgetFocused]->setFocus (); -} - -// *************************************************************************** - -void CFormDialog::OnKillFocus(CWnd* pNewWnd) -{ - CDialog::OnKillFocus(pNewWnd); -} - -// *************************************************************************** -// IFormWidget -// *************************************************************************** - -IFormWidget::IFormWidget (CFormDialog *dialog, uint structId, const char *atomName, TTypeSrc typeSrc, uint slot) -{ - FormName = atomName; - Dialog = dialog; - StructId = structId; - SrcType = typeSrc; - Slot = slot; -} - -// *************************************************************************** - -bool IFormWidget::isDialog (uint id) const -{ - return (id>=FirstId) && (id<=LastId); -}; - -// *************************************************************************** - -uint IFormWidget::getSlot () const -{ - return Slot; -}; - -// *************************************************************************** - -uint IFormWidget::getStructId () const -{ - return StructId; -} - -// *************************************************************************** - -void IFormWidget::updateLabel () -{ - // Does the node in the same form ? - CGeorgesEditDoc *doc = Dialog->View->GetDocument (); - if (doc) - { - // Is the label a window ? - if (IsWindow (Label)) - { - // No label for parent widget - if (SrcType != TypeFormParent) - { - // Value type ? - if ((SrcType == TypeForm) || (SrcType == TypeType)) - { - // Get the value - std::string result; - UFormElm::TWhereIsValue where; - CForm *form=doc->getFormPtr (); - CFormElm *elm = doc->getRootNode (getSlot ()); - nlverify (elm->getValueByName (result, FormName.c_str (), UFormElm::NoEval, &where)); - - // Get the value evaluated - std::string resultEvaluated; -#ifdef TEST_EVAL_FORMULA - bool error = !elm->getValueByName (resultEvaluated, FormName.c_str (), UFormElm::Formula, &where); -#else // TEST_EVAL_FORMULA - bool error = !elm->getValueByName (resultEvaluated, FormName.c_str (), UFormElm::Eval, &where); -#endif // TEST_EVAL_FORMULA - - // Complete the array ? - string comp; - if (error) - comp = " (Value = Error)"; - else - { - if (resultEvaluated != result) - comp=" (Value = \""+resultEvaluated+"\")"; - } - - // Does the node exist ? - switch (where) - { - case UFormElm::ValueForm: - Label.SetWindowText ((SavedLabel+comp).c_str()); - break; - case UFormElm::ValueParentForm: - Label.SetWindowText ((SavedLabel+" (in parent form)"+comp).c_str()); - break; - case UFormElm::ValueDefaultDfn: - Label.SetWindowText ((SavedLabel+" (default DFN value)"+comp).c_str()); - break; - case UFormElm::ValueDefaultType: - Label.SetWindowText ((SavedLabel+" (default TYPE value)"+comp).c_str()); - break; - } - } - else - { - // Get the node - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - bool parentVDfnArray; - CForm *form=doc->getFormPtr (); - CFormElm *elm = doc->getRootNode (getSlot ()); - nlverify ( elm->getNodeByName (FormName.c_str (), &parentDfn, indexDfn, - &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); - - // Does the node exist ? - if (node) - { - // Same form ? - if (node->getForm () == doc->getFormPtr ()) - { - // The node exist - Label.SetWindowText (SavedLabel.c_str()); - } - else - { - // The node exist in the parent form - Label.SetWindowText ((SavedLabel+" (in parent form)").c_str()); - } - } - else - { - // The node is empty - Label.SetWindowText ((SavedLabel+" (undefined)").c_str()); - } - } - - // Update widget - Label.UpdateData (FALSE); - } - } - } -} - -// *************************************************************************** - -IFormWidget::TTypeSrc IFormWidget::getSrcType () const -{ - return SrcType; -} - -// *************************************************************************** - -bool IFormWidget::extendableHeight () const -{ - return false; -} - -// *************************************************************************** - -bool IFormWidget::getNode (const CFormDfn **parentDfn, uint &lastElement, const CFormDfn **nodeDfn, const CType **nodeType, - CFormElm **node, UFormDfn::TEntryType &type, bool &array) const -{ - // Get the document - CGeorgesEditDoc *doc = Dialog->View->GetDocument (); - if (doc) - { - // Return the node - bool parentVDfnArray; - CForm *form=doc->getFormPtr (); - CFormElm *elm = doc->getRootNode (getSlot ()); - return (elm->getNodeByName (FormName.c_str (), parentDfn, - lastElement, nodeDfn, nodeType, node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); - } - return false; -} - -// *************************************************************************** - -CFormElm *IFormWidget::getFormElmNode () const -{ - const CFormDfn *parentDfn; - uint parentDfnIndex; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - if (getNode (&parentDfn, parentDfnIndex, &nodeDfn, &nodeType, &node, type, array)) - { - return node; - } - return NULL; -} - -// *************************************************************************** - -CFormElmStruct *IFormWidget::getFormElmStructNode () const -{ - CFormElm *elm = getFormElmNode (); - return elm ? safe_cast (elm) : NULL; -} - -// *************************************************************************** - -CFormElmVirtualStruct *IFormWidget::getFormElmVirtualStructNode () const -{ - CFormElm *elm = getFormElmNode (); - return elm ? safe_cast (elm) : NULL; -} - -// *************************************************************************** - -CFormElmArray *IFormWidget::getFormElmArrayNode () const -{ - CFormElm *elm = getFormElmNode (); - return elm ? safe_cast (elm) : NULL; -} - -// *************************************************************************** - -CFormElmAtom *IFormWidget::getFormElmAtomNode () const -{ - CFormElm *elm = getFormElmNode (); - return elm ? safe_cast (elm) : NULL; -} - -// *************************************************************************** - -const string &IFormWidget::getFormName () const -{ - return FormName; -} - -// *************************************************************************** - -uint IFormWidget::getNumValue () -{ - // Not implemented for this widget - nlstop; - return 0; -} - -// *************************************************************************** - -void IFormWidget::getValue (std::string &result) -{ - // Not implemented for this widget - nlstop; -} - -// *************************************************************************** - -void IFormWidget::getValue (std::string &result, uint value) -{ - // Not implemented for this widget - nlstop; -} - -// *************************************************************************** - -bool IFormWidget::getWindowRect (RECT &rect) const -{ - if (IsWindow (Label)) - { - Label.GetWindowRect (&rect); - return true; - } - else - return false; -} - -// *************************************************************************** - -void IFormWidget::onOpenSelected () -{ - string str; - getValue (str); - - std::string str2=CPath::lookup (str.c_str (), false, false); - if (str2.empty()) - str2 = str.c_str (); - theApp.OpenDocumentFile (str2.c_str ()); -} - -// *************************************************************************** -// CFormMemCombo -// *************************************************************************** - -CFormMemCombo::CFormMemCombo (CFormDialog *dialog, uint structId, const char *atomName, TTypeSrc typeSrc, uint slot) : IFormWidget (dialog, structId, atomName, typeSrc, slot) -{ - UseSpinner = false; - FileBrowser = false; -} - -// *************************************************************************** - -CFormMemCombo::~CFormMemCombo () -{ - if (IsWindow (Label)) - Label.DestroyWindow (); - if (IsWindow (Combo)) - Combo.DestroyWindow (); - if (IsWindow (Spin)) - Spin.DestroyWindow (); - if (IsWindow (Browse)) - Browse.DestroyWindow (); -} - -// *************************************************************************** - -void CFormMemCombo::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label, const char *reg, bool useSpinner, bool fileBrowser, const char *filenameExt) -{ - // Get the doc - CGeorgesEditDoc *doc = Dialog->View->GetDocument (); - nlassert (doc); - - // Get the node type (if any) - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType = NULL; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - bool parentVDfnArray; - CForm *form=doc->getFormPtr (); - CFormElm *elm = doc->getRootNode (getSlot ()); - nlverify ( elm->getNodeByName (FormName.c_str (), &parentDfn, indexDfn, - &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); - - FirstId = dialog_index; - LastId = FirstId+1; - - // Save the label - SavedLabel = label; - - // Create the type combo - parent->setStaticSize (currentPos); - Label.Create (label, WS_VISIBLE, currentPos, parent); - parent->initWidget (Label); - parent->getNextPosLabel (currentPos); - - UseSpinner = useSpinner; - FileBrowser = fileBrowser; - - // Create the spinner - if (useSpinner) - { - // Create the mem combobox - parent->setComboSpinSize (currentPos); - Combo.create (WS_CHILD|WS_TABSTOP, currentPos, parent, dialog_index, reg, theApp.RememberListSize); - parent->initWidget (Combo); - - // Create the spin - RECT spinPos = currentPos; - parent->getNextSpinPos (spinPos); - parent->setSpinSize (spinPos); - Spin.Create (WS_CHILD|WS_VISIBLE, spinPos, parent, dialog_index+1); - //Spin.SetBuddy (&Combo.ComboBox); - parent->getNextPos (currentPos); - } - else if (fileBrowser) - { - // Create the mem combobox - parent->setComboBrowseSize (currentPos); - Combo.create (WS_CHILD|WS_TABSTOP, currentPos, parent, dialog_index, reg, theApp.RememberListSize); - parent->initWidget (Combo); - - // Create the spin - RECT spinPos = currentPos; - parent->getNextBrowsePos (spinPos); - parent->setBrowseSize (spinPos); - Browse.Create ("...", WS_CHILD|WS_VISIBLE|WS_TABSTOP, spinPos, parent, dialog_index+1); - parent->initWidget (Browse); - parent->getNextPos (currentPos); - - // Set autocomplete mode - if (filenameExt) - { - if (strcmp (filenameExt, "*.*") != 0) - Combo.enableAutoCompleteExtension (true, filenameExt); - } - } - else - { - // Create the mem combobox - parent->setComboSize (currentPos, parent->SmallWidget); - Combo.create (WS_CHILD|WS_TABSTOP, currentPos, parent, dialog_index, reg, theApp.RememberListSize); - parent->initWidget (Combo); - parent->getNextPos (currentPos); - } - - // Get predefs - if (nodeType) - { - for (uint predef=0; predefDefinitions.size(); predef++) - { - Combo.addStaticStrings (nodeType->Definitions[predef].Label.c_str()); - } - } - - dialog_index += 2; -} - -// *************************************************************************** - -void CFormMemCombo::updateData (bool update) -{ - Combo.UpdateData (update?TRUE:FALSE); -} - -// *************************************************************************** - -bool CFormMemCombo::haveFocus () -{ - return (Combo.haveFocus ()); -} - -// *************************************************************************** - -void CFormMemCombo::setFocus () -{ - Combo.SetFocus (); -} - -// *************************************************************************** - -void CFormMemCombo::onOk () -{ - Combo.onOK (); -} - -// *************************************************************************** - -void CFormMemCombo::getValue (std::string &result) -{ - Combo.UpdateData (); - - CString str; - Combo.GetWindowText (str); - - Combo.UpdateData (FALSE); - - // Set the atom value - result = (const char*)str; -} - -// *************************************************************************** - -void CFormMemCombo::getFromDocument (CForm &form) -{ - CGeorgesEditDoc *doc = Dialog->View->GetDocument (); - nlassert (doc); - - if ((SrcType == TypeForm) || (SrcType == TypeType)) - { - string result; - if (doc->getRootNode(getSlot ())->getValueByName (result, FormName.c_str(), UFormElm::NoEval, NULL)) - { - Combo.UpdateData (); - Combo.SetWindowText (result.c_str()); - Combo.UpdateData (FALSE); - updateLabel (); - } - else - { - nlstop; - } - } - else if (SrcType == TypeArray) - { - const CFormDfn *parentDfn; - uint lastElement; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - bool parentVDfnArray; - nlverify (((const CFormElm*)doc->getRootNode(getSlot ()))->getNodeByName (FormName.c_str(), &parentDfn, lastElement, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND)); - nlassert (array); - - // Node exist ? - Combo.UpdateData (); - if (node) - { - CFormElmArray *arrayNode = safe_cast (node); - char label[512]; - smprintf (label, 512, "%d", arrayNode->Elements.size ()); - Combo.SetWindowText (label); - - if (arrayNode->getForm () == &form) - Label.SetWindowText ("Array size:"); - else - Label.SetWindowText ("Array size: (in parent form)"); - } - else - { - Combo.SetWindowText ("0"); - } - Combo.UpdateData (FALSE); - } - else if (SrcType == TypeVirtualDfn) - { - const CFormDfn *parentDfn; - uint lastElement; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - bool parentVDfnArray; - nlverify (((const CFormElm*)doc->getRootNode (getSlot ()))->getNodeByName (FormName.c_str(), &parentDfn, lastElement, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND)); - nlassert (!array); - - // Node exist ? - Combo.UpdateData (); - if (node) - { - CFormElmVirtualStruct *virtualNode = safe_cast (node); - Combo.SetWindowText (virtualNode->DfnFilename.c_str()); - } - else - { - Combo.SetWindowText (""); - } - Combo.UpdateData (FALSE); - } -} - -// *************************************************************************** - -bool CFormMemCombo::isWnd (const CWnd *wnd) const -{ - return Combo.isWnd (wnd); -} - -// *************************************************************************** - -void CFormMemCombo::resizeScan (RECT ¤tPos, uint &widgetCount, uint adjust, bool resize) -{ - // Create the type combo - Dialog->setStaticSize (currentPos); - if (resize) - { - Label.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - } - Dialog->getNextPosLabel (currentPos); - - // Create the spinner - if (UseSpinner) - { - // Create the mem combobox - Dialog->setComboSpinSize (currentPos); - if (resize) - { - Combo.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - } - - // Create the spin - RECT spinPos = currentPos; - Dialog->getNextSpinPos (spinPos); - Dialog->setSpinSize (spinPos); - if (resize) - { - Spin.SetWindowPos (NULL, spinPos.left, spinPos.top, spinPos.right - spinPos.left, - spinPos.bottom - spinPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - } - } - else if (FileBrowser) - { - // Create the mem combobox - Dialog->setComboBrowseSize (currentPos); - if (resize) - { - Combo.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - } - - // Create the spin - RECT spinPos = currentPos; - Dialog->getNextBrowsePos (spinPos); - Dialog->setBrowseSize (spinPos); - if (resize) - { - Browse.SetWindowPos (NULL, spinPos.left, spinPos.top, spinPos.right - spinPos.left, - spinPos.bottom - spinPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - } - } - else - { - // Create the mem combobox - Dialog->setComboSize (currentPos, Dialog->SmallWidget); - if (resize) - { - Combo.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - } - } - Dialog->getNextPos (currentPos); -} - -// *************************************************************************** - -bool CFormMemCombo::getWindowRect (RECT &rect) const -{ - if (Combo) - { - // Get parent rect - RECT parentRect; - IFormWidget::getWindowRect (parentRect); - - // Add my rect - RECT myRect; - Combo.GetWindowRect (&myRect); - UnionRect(&rect, &myRect, &parentRect); - return true; - } - else - return false; -} - -// *************************************************************************** -// CFormCombo -// *************************************************************************** - -CFormCombo::CFormCombo (CFormDialog *dialog, uint structId, const char *atomName, IFormWidget::TTypeSrc typeForm, uint slot) : IFormWidget (dialog, structId, atomName, typeForm, slot) -{ -} - -// *************************************************************************** - -CFormCombo::~CFormCombo () -{ - if (IsWindow (Label)) - Label.DestroyWindow (); - if (IsWindow (Combo)) - Combo.DestroyWindow (); -} - -// *************************************************************************** - -void CFormCombo::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label) -{ - // Get the doc - CGeorgesEditDoc *doc = Dialog->View->GetDocument (); - nlassert (doc); - - FirstId = dialog_index; - LastId = FirstId; - - // Get the value for the type pointer (if any) - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - bool parentVDfnArray; - CForm *form=doc->getFormPtr (); - CFormElm *elm = doc->getRootNode (getSlot ()); - nlverify ( elm->getNodeByName (FormName.c_str (), &parentDfn, indexDfn, - &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); - - // Save the label - SavedLabel = label; - - // Create the type combo - parent->setStaticSize (currentPos); - Label.Create (label, WS_VISIBLE, currentPos, parent); - parent->initWidget (Label); - parent->getNextPosLabel (currentPos); - - // Create the mem combobox - parent->setComboSize (currentPos, parent->SmallWidget); - RECT comboPos = currentPos; - parent->adjusteComboSize (comboPos); - Combo.Create (WS_CHILD|WS_VSCROLL|WS_VISIBLE|CBS_DROPDOWNLIST|CBS_HASSTRINGS|WS_CHILD|WS_TABSTOP, comboPos, parent, dialog_index); - parent->initWidget (Combo); - parent->getNextPos (currentPos); - - // Get predefs - if (nodeType) - { - Combo.InsertString (0, ""); - for (uint predef=0; predefDefinitions.size(); predef++) - { - Combo.InsertString (predef+1, nodeType->Definitions[predef].Label.c_str()); - } - } - - dialog_index += 1; -} - -// *************************************************************************** - -void CFormCombo::updateData (bool update) -{ - Combo.UpdateData (update?TRUE:FALSE); -} - -// *************************************************************************** - -bool CFormCombo::haveFocus () -{ - CWnd *focus = CWnd::GetFocus (); - if (focus) - { - return (focus == &Combo); - } - return false; -} - -// *************************************************************************** - -void CFormCombo::setFocus () -{ - Combo.SetFocus (); -} - -// *************************************************************************** - -void CFormCombo::onOk () -{ - //Combo.onOK (); -} - -// *************************************************************************** - -void CFormCombo::getValue (std::string &result) -{ - Combo.UpdateData (); - - CString str; - Combo.GetWindowText (str); - - Combo.UpdateData (FALSE); - - // Set the atom value - result = (const char*)str; -} - -// *************************************************************************** - -void CFormCombo::getFromDocument (CForm &form) -{ - CGeorgesEditDoc *doc = Dialog->View->GetDocument (); - nlassert (doc); - string result; - if (doc->getRootNode (getSlot ())->getValueByName (result, FormName.c_str(), UFormElm::NoEval, NULL)) - { - Combo.UpdateData (); - uint itemCount = Combo.GetCount (); - for (uint i=0; isetStaticSize (currentPos); - if (resize) - { - Label.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - } - Dialog->getNextPosLabel (currentPos); - - // Create the mem combobox - Dialog->setComboSize (currentPos, Dialog->SmallWidget); - if (resize) - { - RECT comboPos = currentPos; - Dialog->adjusteComboSize (comboPos); - Combo.SetWindowPos (NULL, comboPos.left, comboPos.top, comboPos.right - comboPos.left, - comboPos.bottom - comboPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - } - Dialog->getNextPos (currentPos); -} - -// *************************************************************************** - -bool CFormCombo::getWindowRect (RECT &rect) const -{ - if (IsWindow (Combo)) - { - // Get parent rect - RECT parentRect; - IFormWidget::getWindowRect (parentRect); - - // Add my rect - RECT myRect; - Combo.GetWindowRect (&myRect); - UnionRect(&rect, &myRect, &parentRect); - return true; - } - else - return false; -} - -// *************************************************************************** -// CFormBigEdit -// *************************************************************************** - -CFormBigEdit::CFormBigEdit (CFormDialog *dialog, uint structId, const char *atomName, IFormWidget::TTypeSrc typeForm, uint slot) : IFormWidget (dialog, structId, atomName, typeForm, slot) -{ -} - -// *************************************************************************** - -CFormBigEdit::~CFormBigEdit () -{ - if (IsWindow (Label)) - Label.DestroyWindow (); - if (IsWindow (Edit)) - Edit.DestroyWindow (); -} - -// *************************************************************************** - -void CFormBigEdit::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label) -{ - FirstId = dialog_index; - LastId = FirstId; - - // Save the label - SavedLabel = label; - - // Create the type combo - parent->setStaticSize (currentPos); - Label.Create (label, WS_VISIBLE, currentPos, parent); - parent->initWidget (Label); - parent->getNextPosLabel (currentPos); - - // Create the mem combobox - parent->setBigEditSize (currentPos, parent->SmallWidget); - Edit.CreateEx (WS_EX_CLIENTEDGE, _T("EDIT"), "", WS_VSCROLL|ES_OEMCONVERT|ES_MULTILINE|ES_WANTRETURN|WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL|ES_AUTOVSCROLL, currentPos, parent, dialog_index); - parent->initWidget (Edit); - parent->getNextPos (currentPos); - - dialog_index += 1; -} - -// *************************************************************************** - -void CFormBigEdit::updateData (bool update) -{ - Edit.UpdateData (update?TRUE:FALSE); -} - -// *************************************************************************** - -bool CFormBigEdit::haveFocus () -{ - CWnd *focus = CWnd::GetFocus (); - if (focus) - { - return (focus == &Edit); - } - return false; -} - -// *************************************************************************** - -void CFormBigEdit::setFocus () -{ - Edit.SetFocus (); -} - -// *************************************************************************** - -void CFormBigEdit::onOk () -{ - //Combo.onOK (); -} - -// *************************************************************************** - -void CFormBigEdit::getValue (std::string &result) -{ - Edit.UpdateData (); - - CString str; - Edit.GetWindowText (str); - - Edit.UpdateData (FALSE); - - // Set the atom value - result = (const char*)str; -} - -// *************************************************************************** - -void CFormBigEdit::getFromDocument (CForm &form) -{ - CGeorgesEditDoc *doc = Dialog->View->GetDocument (); - nlassert (doc); - string result; - if (doc->getRootNode (getSlot ())->getValueByName (result, FormName.c_str(), UFormElm::NoEval, NULL)) - { - Edit.UpdateData (); - Dialog->setEditTextMultiLine (Edit, result.c_str()); - Edit.UpdateData (FALSE); - updateLabel (); - } - else - { - nlstop; - } -} - -// *************************************************************************** - -bool CFormBigEdit::isWnd (const CWnd *wnd) const -{ - return &Edit == wnd; -} - -// *************************************************************************** - -void CFormBigEdit::resizeScan (RECT ¤tPos, uint &widgetCount, uint adjust, bool resize) -{ - if (!resize) - widgetCount++; - - // Create the type combo - Dialog->setStaticSize (currentPos); - if (resize) - { - Label.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - } - Dialog->getNextPosLabel (currentPos); - - // Create the mem combobox - Dialog->setBigEditSize (currentPos, Dialog->SmallWidgetNotLimited, Dialog->BigEditHeight + adjust); - if (resize) - { - Edit.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - } - Dialog->getNextPos (currentPos); -} - -// *************************************************************************** - -bool CFormBigEdit::extendableHeight () const -{ - return true; -} - -// *************************************************************************** - -bool CFormBigEdit::getWindowRect (RECT &rect) const -{ - if (IsWindow (Edit)) - { - // Get parent rect - RECT parentRect; - IFormWidget::getWindowRect (parentRect); - - // Add my rect - RECT myRect; - Edit.GetWindowRect (&myRect); - UnionRect(&rect, &myRect, &parentRect); - return true; - } - else - return false; -} - -// *************************************************************************** -// CColorEdit -// *************************************************************************** - -CColorEdit::CColorEdit (CFormDialog *dialog, uint structId, const char *atomName, IFormWidget::TTypeSrc typeForm, uint slot) : IFormWidget (dialog, structId, atomName, typeForm, slot) -{ - Empty = true; -} - -// *************************************************************************** - -CColorEdit::~CColorEdit () -{ - if (IsWindow (Label)) - Label.DestroyWindow (); - if (IsWindow (Color)) - Color.DestroyWindow (); - if (IsWindow (Edit)) - Edit.DestroyWindow (); -} - -// *************************************************************************** - -void CColorEdit::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label) -{ - FirstId = dialog_index; - LastId = FirstId+2; - - // Save the label - SavedLabel = label; - - // Create the type combo - parent->setStaticSize (currentPos); - Label.Create (label, WS_VISIBLE, currentPos, parent); - parent->initWidget (Label); - parent->getNextPosLabel (currentPos); - - // Create the mem combobox - parent->setColorSize (currentPos, parent->SmallWidget); - Color.create (WS_CHILD|WS_VISIBLE|WS_TABSTOP, currentPos, parent, dialog_index); - parent->initWidget (Color); - - // Create the reset button - RECT resetPos = currentPos; - parent->getNextColorPos (resetPos); - parent->setResetColorSize (resetPos); - Reset.Create ("Reset", WS_CHILD|WS_VISIBLE|WS_TABSTOP, resetPos, parent, dialog_index+1); - parent->initWidget (Reset); - parent->getNextPosLabel (currentPos); - - // Create the Edit - parent->setBigEditSize (currentPos, parent->SmallWidget); - Edit.CreateEx (WS_EX_CLIENTEDGE, _T("EDIT"), "", ES_OEMCONVERT|ES_WANTRETURN|WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL, currentPos, parent, dialog_index+2); - parent->initWidget (Edit); - parent->getNextPos (currentPos); - - Color.setEdit(&Edit); - - dialog_index += 3; -} - -// *************************************************************************** - -void CColorEdit::updateData (bool update) -{ - Color.UpdateData (update?TRUE:FALSE); - Edit.UpdateData (update?TRUE:FALSE); -} - -// *************************************************************************** - -bool CColorEdit::haveFocus () -{ - CWnd *focus = CWnd::GetFocus (); - if (focus) - { - return (focus == &Color); - } - return false; -} - -// *************************************************************************** - -void CColorEdit::setFocus () -{ - Color.SetFocus (); -} - -// *************************************************************************** - -void CColorEdit::onOk () -{ - // Color.onOk (); -} - -// *************************************************************************** - -void CColorEdit::getValue (std::string &result) -{ - if (!Empty) - { - Color.UpdateData (); - - // Get the color - CRGBA color = Color.getColor (); - - // Make a string - char colorName[512]; - smprintf (colorName, 512, "%d,%d,%d", color.R, color.G, color.B); - - // Set the atom value - result = colorName; - } - else - { - result = ""; - } -} - -// *************************************************************************** - -void CColorEdit::getFromDocument (CForm &form) -{ - CGeorgesEditDoc *doc = Dialog->View->GetDocument (); - nlassert (doc); - string result; - if (doc->getRootNode (getSlot ())->getValueByName (result, FormName.c_str(), UFormElm::NoEval, NULL)) - { - Color.UpdateData (); - - // Make a color - sint r, g, b; - if (sscanf (result.c_str(), "%d,%d,%d", &r, &g, &b) == 3) - { - clamp (r, 0, 255); - clamp (g, 0, 255); - clamp (b, 0, 255); - CRGBA color (r, g, b); - Color.setColor (color); - if (r != 255 && g != 255 && b != 255) - Color.updateEdit(); - } - else - { - Color.setColor (CRGBA::Black); - Color.updateEdit(); - } - Color.UpdateData (FALSE); - updateLabel (); - } - else - { - nlstop; - } -} - - -// *************************************************************************** - -bool CColorEdit::isWnd (const CWnd *wnd) const -{ - return &Color == wnd; -} - -// *************************************************************************** - -void CColorEdit::resizeScan (RECT ¤tPos, uint &widgetCount, uint adjust, bool resize) -{ - // Create the type combo - Dialog->setStaticSize (currentPos); - if (resize) - { - Label.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - } - Dialog->getNextPosLabel (currentPos); - - // Create the mem combobox - Dialog->setColorSize (currentPos, Dialog->SmallWidget); - if (resize) - { - Color.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - } - - // Create the spin - RECT resetPos = currentPos; - Dialog->getNextColorPos (resetPos); - Dialog->setResetColorSize (resetPos); - if (resize) - { - Reset.SetWindowPos (NULL, resetPos.left, resetPos.top, resetPos.right - resetPos.left, - resetPos.bottom - resetPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - } - Dialog->getNextPosLabel (currentPos); - - // Create the Edit - Dialog->setEditSize (currentPos, Dialog->SmallWidget, Dialog->EditHeight); - if (resize) - { - Edit.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - } - - Dialog->getNextPos (currentPos); -} - -// *************************************************************************** - -bool CColorEdit::getWindowRect (RECT &rect) const -{ - if (IsWindow (Color)) - { - // Get parent rect - RECT parentRect; - IFormWidget::getWindowRect (parentRect); - - // Add my rect - RECT myRect; - Color.GetWindowRect (&myRect); - UnionRect(&rect, &myRect, &parentRect); - return true; - } - else - return false; -} - -// *************************************************************************** -// CListWidget -// *************************************************************************** - -CListWidget::CListWidget (CFormDialog *dialog, uint structId, const char *atomName, IFormWidget::TTypeSrc typeForm, uint slot) : IFormWidget (dialog, structId, atomName, typeForm, slot) -{ - ListCtrl.Ctrl = this; -} - -// *************************************************************************** - -CListWidget::~CListWidget () -{ - if (IsWindow (Label)) - Label.DestroyWindow (); - if (IsWindow (ListCtrl)) - ListCtrl.DestroyWindow (); - if (IsWindow (Button)) - Button.DestroyWindow (); -} - -// *************************************************************************** - -void CListWidget::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label, const char *reg, uint divid) -{ - FirstId = dialog_index; - LastId = FirstId+1; - - Divid = divid; - RegAdr = reg; - - // Save the label - SavedLabel = label; - - // Create the type combo - parent->setStaticSize (currentPos); - Label.Create (label, WS_VISIBLE, currentPos, parent); - parent->initWidget (Label); - parent->getNextPosLabel (currentPos); - - // Create the mem combobox - parent->setListSize (currentPos, parent->SmallWidget); - ListCtrl.create (WS_CHILD|WS_VISIBLE|WS_TABSTOP, currentPos, parent, dialog_index); - parent->initWidget (ListCtrl); - parent->getNextPos (currentPos); - - // Create the assign parent - parent->setButtonSize (currentPos, parent->SmallWidget); - Button.Create ("Assign parents", WS_CHILD|WS_VISIBLE|WS_TABSTOP, currentPos, parent, dialog_index+1); - parent->initWidget (Button); - parent->getNextPos (currentPos); - - dialog_index += 2; -} - -// *************************************************************************** - -void CListWidget::addColumn (const char *name) -{ - ListCtrl.insertColumn (0, name); - ListCtrl.recalcColumn (); -} - -// *************************************************************************** - -void CListWidget::onOk () -{ - ListCtrl.onOK (); -} - -// *************************************************************************** - -void CListWidget::updateData (bool update) -{ - ListCtrl.UpdateData (update); -} - -// *************************************************************************** - -bool CListWidget::haveFocus () -{ - CWnd *wnd = Dialog->GetFocus (); - if (wnd) - { - return (wnd->GetParent () == &ListCtrl); - } - return false; -} - -// *************************************************************************** - -void CListWidget::setFocus () -{ - ListCtrl.SetFocus (); -} - -// *************************************************************************** - -void CListWidget::getFromDocument (NLGEORGES::CForm &form) -{ - // Erase the list - ListCtrl.ListCtrl.DeleteAllItems (); - - // For each parent - for (uint parent=0; parentsetStaticSize (currentPos); - if (resize) - { - Label.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - } - Dialog->getNextPosLabel (currentPos); - - // Create the mem combobox - Dialog->setListSize (currentPos, Dialog->SmallWidgetNotLimited / Divid, Dialog->ListHeight + adjust); - if (resize) - { - ListCtrl.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - ListCtrl.recalcColumn (); - } - Dialog->getNextPos (currentPos); - - // Create the mem combobox - Dialog->setButtonSize (currentPos, Dialog->SmallWidget); - if (resize) - { - Button.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - } - Dialog->getNextPos (currentPos); -} - -// *************************************************************************** - -bool CListWidget::extendableHeight () const -{ - return true; -} - -// *************************************************************************** - -CEditListCtrl::TItemEdit CListWidget::CMyEditListCtrl::getItemEditMode (uint item, uint subItem) -{ - return CEditListCtrl::EditMemCombo; -} - -// *************************************************************************** - -void CListWidget::CMyEditListCtrl::getMemComboBoxProp (uint item, uint subItem, std::string ®Adr, bool &browse) -{ - regAdr = Ctrl->RegAdr; - browse = true; -} - -// *************************************************************************** - -void CListWidget::CMyEditListCtrl::getNewItemText (uint item, uint subItem, std::string &ret) -{ - Ctrl->Dialog->getDfnName (ret); - ret = "default." + ret; -} - -// *************************************************************************** - -void CListWidget::CMyEditListCtrl::getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::string &filter) -{ - string ret; - Ctrl->Dialog->getDfnName (ret); - defExt = "*." + ret; - defFilename = defExt; - - filter = "Form Files (*." + ret + ")|*." + ret + "|All Files (*.*)|*.*||"; - defDir = theApp.RootSearchPath; -} - -// *************************************************************************** - -bool CListWidget::getWindowRect (RECT &rect) const -{ - if (IsWindow (ListCtrl)) - { - // Get parent rect - RECT parentRect; - IFormWidget::getWindowRect (parentRect); - - // Add my rect - RECT myRect; - ListCtrl.ListCtrl.GetWindowRect (&myRect); - UnionRect(&rect, &myRect, &parentRect); - return true; - } - else - return false; -} - -// *************************************************************************** - -void CListWidget::onOpenSelected () -{ - // For each selected - POSITION pos = ListCtrl.ListCtrl.GetFirstSelectedItemPosition(); - while (pos) - { - int nItem = ListCtrl.ListCtrl.GetNextSelectedItem(pos); - - // Get the string - CString str = ListCtrl.ListCtrl.GetItemText (nItem, 0); - if (str != "") - { - // Look for the file - string name = CPath::lookup ((const char*)str, false, false); - if (name.empty ()) - name = str; - - // Open the file - theApp.OpenDocumentFile (name.c_str ()); - } - } -} - -// *************************************************************************** - -// *************************************************************************** -// CIconWidget -// *************************************************************************** - -CIconWidget::CIconWidget (CFormDialog *dialog, uint structId, const char *atomName, IFormWidget::TTypeSrc typeForm, uint slot) : IFormWidget (dialog, structId, atomName, typeForm, slot) -{ - -} - -// *************************************************************************** - -CIconWidget::~CIconWidget () -{ - if (IsWindow (Icon)) - Icon.DestroyWindow (); -} - -// *************************************************************************** - -void CIconWidget::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label) -{ - FirstId = dialog_index; - LastId = FirstId; - - // Save the label - SavedLabel = label; - - // Create the type combo - parent->setStaticSize (currentPos); - Label.Create (label, WS_VISIBLE, currentPos, parent); - parent->initWidget (Label); - parent->getNextPosLabel (currentPos); - - // Create the mem combobox - parent->setEditSize (currentPos, parent->IconHeight, parent->IconHeight); - Icon.create (WS_CHILD|WS_VISIBLE|WS_TABSTOP, currentPos, parent, dialog_index); - parent->initWidget (Icon); - - parent->getNextPos (currentPos); - - dialog_index += 1; -} - -// *************************************************************************** - -void CIconWidget::updateData (bool update) -{ - Icon.UpdateData (update?TRUE:FALSE); -} - -// *************************************************************************** - -bool CIconWidget::haveFocus () -{ - CWnd *focus = CWnd::GetFocus (); - if (focus) - { - return (focus == &Icon); - } - return false; -} - -// *************************************************************************** - -void CIconWidget::setFocus () -{ - Icon.SetFocus (); -} - -// *************************************************************************** - -void CIconWidget::onOk () -{ - -} - -// *************************************************************************** - -void CIconWidget::getValue (std::string &result) -{ - result = ""; -} - -// *************************************************************************** - -void CIconWidget::getFromDocument (CForm &form) -{ - -} - - -// *************************************************************************** - -bool CIconWidget::isWnd (const CWnd *wnd) const -{ - return &Icon == wnd; -} - -// *************************************************************************** - -void CIconWidget::resizeScan (RECT ¤tPos, uint &widgetCount, uint adjust, bool resize) -{ - // Create the type combo - Dialog->setStaticSize (currentPos); - if (resize) - { - Label.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - } - Dialog->getNextPosLabel (currentPos); - - // Create the icon - Dialog->setEditSize (currentPos, Dialog->IconHeight, Dialog->IconHeight); - if (resize) - { - Icon.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - } - - Dialog->getNextPos (currentPos); -} - -// *************************************************************************** - -bool CIconWidget::getWindowRect (RECT &rect) const -{ - if (IsWindow (Icon)) - { - // Get parent rect - RECT parentRect; - IFormWidget::getWindowRect (parentRect); - - // Add my rect - RECT myRect; - Icon.GetWindowRect (&myRect); - UnionRect(&rect, &myRect, &parentRect); - return true; - } - else - return false; +// 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 . + +// form_dialog.cpp : implementation file +// + +#include "stdafx.h" +#include "georges_edit.h" +#include "georges_edit_view.h" +#include "georges_edit_doc.h" +#include "form_dialog.h" +#include "action.h" +#include "left_view.h" + +#include "nel/misc/path.h" +#include "nel/georges/type.h" +#include "nel/georges/form_elm.h" + +using namespace std; +using namespace NLMISC; +using namespace NLGEORGES; + + +// Define this to show Formula value evaluation intstead of value evaluation +// #define TEST_EVAL_FORMULA + +// *************************************************************************** +// CFormDialog dialog +// *************************************************************************** + +CFormDialog::CFormDialog () : CBaseDialog (IDR_MAINFRAME) +{ + //{{AFX_DATA_INIT(CFormDialog) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + View = NULL; + WidgetIndexCount = 0; + WidgetFocused = 0xffffffff; +} + +// *************************************************************************** + +CFormDialog::~CFormDialog () +{ + clear (); +} + +// *************************************************************************** + +void CFormDialog::clear () +{ + unRegisterLastControl (); + for (uint i=0; iupdateData (); + if (Widgets[i]->haveFocus ()) + { + Widgets[i]->onOk (); + } + } +} + +// *************************************************************************** + +void CFormDialog::OnCancel () +{ + for (uint i=0; iupdateData (); + if (Widgets[i]->haveFocus ()) + { + Widgets[i]->onCancel (); + return; + } + } + CBaseDialog::OnCancel (); +} + +// *************************************************************************** + +CWnd* CFormDialog::addTypeWidget (const NLGEORGES::CType &type, uint elmIndex, const char *title, const char *atomName, const char *typeFilename, RECT ¤tPos, CForm &form, IFormWidget::TTypeSrc typeWidget, const char *filenameExt, uint slot) +{ + // What kind of UI ? + switch (type.UIType) + { + case CType::FileBrowser: + case CType::Edit: + case CType::EditSpin: + { + // For edit type, use a memory combobox + CFormMemCombo *memCombo = new CFormMemCombo (this, elmIndex, atomName, typeWidget, slot); + Widgets.push_back (memCombo); + + // Create a reg key + string tfn = typeFilename; + string key = GEORGES_EDIT_BASE_REG_KEY"\\"+strlwr (typeFilename)+" MemCombo"; + + // Create the widget + memCombo->create (WS_CHILD|WS_TABSTOP, currentPos, this, WidgetIndexCount, title, key.c_str(), type.UIType==CType::EditSpin, type.UIType==CType::FileBrowser, filenameExt); + + // Get from document + memCombo->getFromDocument (form); + + return &memCombo->Combo; + } + break; + case CType::NonEditableCombo: + { + // For edit type, use a memory combobox + CFormCombo *memCombo = new CFormCombo (this, elmIndex, atomName, typeWidget, slot); + Widgets.push_back (memCombo); + + // Create the widget + memCombo->create (WS_CHILD|WS_TABSTOP, currentPos, this, WidgetIndexCount, title); + + // Get from document + memCombo->getFromDocument (form); + + return &memCombo->Combo; + } + break; + case CType::BigEdit: + { + // For edit type, use a memory combobox + CFormBigEdit *memCombo = new CFormBigEdit (this, elmIndex, atomName, typeWidget, slot); + Widgets.push_back (memCombo); + + // Create the widget + memCombo->create (WS_CHILD|WS_TABSTOP, currentPos, this, WidgetIndexCount, title); + + // Get from document + memCombo->getFromDocument (form); + + return &memCombo->Edit; + } + break; + case CType::ColorEdit: + { + // For edit type, use a memory combobox + CColorEdit *memCombo = new CColorEdit (this, elmIndex, atomName, typeWidget, slot); + Widgets.push_back (memCombo); + + // Create the widget + memCombo->create (WS_CHILD|WS_TABSTOP, currentPos, this, WidgetIndexCount, title); + + // Get from document + memCombo->getFromDocument (form); + + return &memCombo->Color; + } + break; + } + + return NULL; +} + +// *************************************************************************** + +void CFormDialog::getVirtualDfnFromDocument (const NLGEORGES::CFormDfn *_dfn, const char *structName, uint slot) +{ + if (View) + { + CGeorgesEditDoc *doc = View->GetDocument (); + if (doc) + { + // Clear the current dialog + clear (); + + // Reserve some widget pointers + Widgets.reserve (10); + + // Widget placement + RECT currentPos; + getFirstItemPos (currentPos); + + // For edit type, use a memory combobox + CFormMemCombo *memCombo = new CFormMemCombo (this, 0xffffffff, structName, IFormWidget::TypeVirtualDfn, slot); + Widgets.push_back (memCombo); + + // Create the widget + memCombo->create (WS_CHILD|WS_TABSTOP, currentPos, this, WidgetIndexCount, "Dfn:", + GEORGES_EDIT_BASE_REG_KEY"\\Virtual Dfn MemCombo", false, true, "*.dfn"); + + // Get from document + memCombo->getFromDocument (*doc->getFormPtr ()); + + // Dfn selected ? + if (_dfn) + { + // Get the parent DFN + std::vector arrayDfn; + arrayDfn.reserve (_dfn->countParentDfn ()); + _dfn->getParentDfn (arrayDfn); + + // Element index + uint elmIndex = 0; + + // For each DFN + for (uint dfnIndex=0; dfnIndexgetFormPtr (), IFormWidget::TypeForm, + entry.getFilenameExt ().c_str (), slot); + } + + // Next form index + elmIndex++; + } + } + } + + // Register last control for tab selection + registerLastControl (); + } + } +} + +// *************************************************************************** +void CFormDialog::getDfnFromDocument (const NLGEORGES::CFormDfn &_dfn, const char *structName, uint slot) +{ + if (View) + { + CGeorgesEditDoc *doc = View->GetDocument (); + if (doc) + { + // Clear the current dialog + clear (); + + // Reserve some widget pointers + Widgets.reserve (10); + + // Widget placement + RECT currentPos; + getFirstItemPos (currentPos); + + // Get the parent DFN + std::vector arrayDfn; + arrayDfn.reserve (_dfn.countParentDfn ()); + _dfn.getParentDfn (arrayDfn); + + // For edit type, use a memory combobox + if (strcmp (structName, "") == 0) + { + CListWidget *listWidget = new CListWidget (this, 0xffffffff, "", IFormWidget::TypeFormParent, slot); + Widgets.push_back (listWidget); + + // Create the widget + listWidget->create (WS_CHILD|WS_TABSTOP, currentPos, this, WidgetIndexCount, "Parent Form:", + GEORGES_EDIT_BASE_REG_KEY"\\Parent Form MemCombo", 1); + + // Add one column + listWidget->addColumn ("Parent filename"); + + // Get from document + listWidget->getFromDocument (*doc->getFormPtr ()); + } + + // store icon related infos + CWnd *pWnd = NULL; + CWnd *pWndIcon = NULL; + CWnd *pWndIconColor = NULL; + CWnd *pWndIconBack = NULL; + CWnd *pWndIconBackColor = NULL; + CWnd *pWndIconOver = NULL; + CWnd *pWndIconOverColor = NULL; + CWnd *pWndIconOver2 = NULL; + CWnd *pWndIconOver2Color = NULL; + + // Element index + uint elmIndex = 0; + + // For each DFN + for (uint dfnIndex=0; dfnIndexgetFormPtr (), IFormWidget::TypeForm, + entry.getFilenameExt ().c_str (), slot); + + if (entry.getName() == "Icon" || entry.getName() == "icon") + pWndIcon = pWnd; + else if (entry.getName() == "IconColor") + pWndIconColor = pWnd; + else if (entry.getName() == "IconBack" || entry.getName() == "icon background") + pWndIconBack = pWnd; + else if (entry.getName() == "IconBackColor") + pWndIconBackColor = pWnd; + else if (entry.getName() == "IconOver" || entry.getName() == "icon overlay") + pWndIconOver = pWnd; + else if (entry.getName() == "IconOverColor") + pWndIconOverColor = pWnd; + else if (entry.getName() == "IconOver2" || entry.getName() == "icon overlay2") + pWndIconOver2 = pWnd; + else if (entry.getName() == "IconOver2Color") + pWndIconOver2Color = pWnd; + } + + // Next form index + elmIndex++; + } + } + + // Special case for ".Client" and ".3d" : add a widget to draw icons + if ((string(structName) == ".Client") || (string(structName) == ".3d")) + { + string title = "Icon bitmap:"; + + CIconWidget *w = new CIconWidget (this, elmIndex, "", IFormWidget::TypeFormParent, slot); + Widgets.push_back (w); + + // Create the widget + w->create (WS_CHILD|WS_TABSTOP, currentPos, this, WidgetIndexCount, title.c_str()); + + // + w->Icon.pWndIcon = pWndIcon; + w->Icon.pWndIconColor = pWndIconColor; + + w->Icon.pWndIconBack = pWndIconBack; + w->Icon.pWndIconBackColor = pWndIconBackColor; + + w->Icon.pWndIconOver = pWndIconOver; + w->Icon.pWndIconOverColor = pWndIconOverColor; + + w->Icon.pWndIconOver2 = pWndIconOver2; + w->Icon.pWndIconOver2Color = pWndIconOver2Color; + } + + // Register last control for tab selection + registerLastControl (); + } + } +} + +// *************************************************************************** + +void CFormDialog::getArrayFromDocument (const char *structName, uint structId, uint slot) +{ + if (View) + { + CGeorgesEditDoc *doc = View->GetDocument (); + if (doc) + { + // Clear the current dialog + clear (); + + // Reserve some widget pointers + Widgets.reserve (10); + + // Widget placement + RECT currentPos; + getFirstItemPos (currentPos); + + CFormMemCombo *memCombo = new CFormMemCombo (this, structId, structName, IFormWidget::TypeArray, slot); + Widgets.push_back (memCombo); + + // Create the widget + memCombo->create (WS_CHILD|WS_TABSTOP, currentPos, this, WidgetIndexCount, "Array size:", + GEORGES_EDIT_BASE_REG_KEY"\\Array Size MemCombo", true, false, NULL); + + // Get from document + memCombo->getFromDocument (*doc->getFormPtr ()); + + // Register last control for tab selection + registerLastControl (); + } + } +} + +// *************************************************************************** + +void CFormDialog::getTypeFromDocument (const NLGEORGES::CType &_type, const char *name, const char *typeFilename, const char *structName, uint slot) +{ + if (View) + { + CGeorgesEditDoc *doc = View->GetDocument (); + if (doc) + { + // Clear the current dialog + clear (); + + // Reserve some widget pointers + Widgets.reserve (10); + + // Widget placement + RECT currentPos; + getFirstItemPos (currentPos); + + // Some string + addTypeWidget (_type, 0xffffffff, name, structName, typeFilename, currentPos, *doc->getFormPtr (), IFormWidget::TypeType, NULL, slot); + + // Register last control for tab selection + registerLastControl (); + } + } +} + +// *************************************************************************** + +void CFormDialog::updateLabels () +{ + for (uint i=0; iupdateLabel (); + } +} + +// *************************************************************************** + +void CFormDialog::updateValues () +{ + for (uint i=0; iupdateLabel (); + Widgets[i]->getFromDocument (*(View->GetDocument ()->getFormPtr ())); + } +} + +// *************************************************************************** + +void CFormDialog::setToDocument (uint widget) +{ + CGeorgesEditDoc *doc = View->GetDocument (); + if (doc) + { + // discard CIconWidget + CIconWidget *iconWidget = dynamic_cast (Widgets[widget]); + if (iconWidget) + return; + + // Check if this command will build a new array / virtual dfn that was inherited.. + if (Widgets[widget]->getFormName () != "NULL") + { + // Get current node + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + bool parentVDfnArray; + CForm *form=doc->getFormPtr (); + CFormElm *elm = doc->getRootNode (Widgets[widget]->getSlot ()); + nlverify ( elm->getNodeByName (Widgets[widget]->getFormName ().c_str (), &parentDfn, indexDfn, + &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); + + // Must create array or virtual dfn ? + if (parentVDfnArray) + { + // Warn the user + if (!theApp.yesNo ("Warning, this action will create an array/virtual dfn over an inherited array/virtual dfn.\nDo you want to continue ?")) + // Quit + return; + } + } + + // Get the widget type + IFormWidget::TTypeSrc typeSrc = Widgets[widget]->getSrcType (); + if (typeSrc == IFormWidget::TypeForm) + { + // Get the value + std::string result; + Widgets[widget]->getValue (result); + + // Document modified + doc->modify (new CActionString (IAction::FormValue, result.c_str (), *doc, Widgets[widget]->getFormName ().c_str (), "", + doc->getLeftView ()->getCurrentSelectionId (), Widgets[widget]->getSlot ())); + } + else if (typeSrc == IFormWidget::TypeFormParent) + { + // The form + CForm *form = doc->getFormPtr (); + + // Build an array of strings + uint count = Widgets[widget]->getNumValue (); + vector stringVector (count); + for (uint value = 0; valuegetValue (stringVector[value], value); + } + + // Modify document + doc->modify (new CActionStringVector (IAction::FormParents, stringVector, *doc, "", + doc->getLeftView ()->getCurrentSelectionId (), Widgets[widget]->getSlot ())); + } + else if (typeSrc == IFormWidget::TypeArray) + { + // Get the value + std::string result; + Widgets[widget]->getValue (result); + + // Modify document + doc->modify (new CActionBuffer (IAction::FormArraySize, NULL, 0, *doc, Widgets[widget]->getFormName ().c_str(), + result.c_str (), doc->getLeftView ()->getCurrentSelectionId (), Widgets[widget]->getSlot ())); + } + else if (typeSrc == IFormWidget::TypeType) + { + // Get the result value + std::string result; + Widgets[widget]->getValue (result); + + // Document is modified by this view + doc->modify (new CActionString (IAction::FormTypeValue, result.c_str (), *doc, Widgets[widget]->getFormName().c_str(), "", + doc->getLeftView ()->getCurrentSelectionId (), Widgets[widget]->getSlot ())); + } + else if (typeSrc == IFormWidget::TypeVirtualDfn) + { + // Get the value + std::string result; + Widgets[widget]->getValue (result); + + // Modify the document + doc->modify (new CActionBuffer (IAction::FormVirtualDfnName, NULL, 0, *doc, Widgets[widget]->getFormName ().c_str (), + result.c_str (), doc->getLeftView ()->getCurrentSelectionId (), Widgets[widget]->getSlot ())); + } + } + + // Notify the plugin that the value has changed + if (!Widgets[widget]->getFormName ().empty ()) + doc->notifyPlugins (Widgets[widget]->getFormName ().c_str ()); +} + +// *************************************************************************** + +LRESULT CFormDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case CL_CHANGED: + { + uint widgetId = getWidget (wParam); + CColorEdit *colorEdit = safe_cast (Widgets[widgetId]); + colorEdit->Empty = false; + setToDocument (getWidget (wParam)); + } + break; + case MC_STRINGCHANGE: + { + setToDocument (getWidget (wParam)); + } + break; + + case CBN_CHANGED: + { + for (uint i=0 ; i (Widgets[i]); + if (iconWidget) + iconWidget->Icon.Invalidate(); + } + } + break; + } + + return CDialog::WindowProc(message, wParam, lParam); +} + +// *************************************************************************** + +void CFormDialog::onOpenSelected () +{ + // Get the focus windows + for (uint i=0; ihaveFocus ()) + { + Widgets[i]->onOpenSelected (); + /*CFormMemCombo *combo = dynamic_cast (Widgets[i]); + if (combo) + { + CString str; + combo->Combo.GetWindowText (str); + if (combo->Browse && (str != "")) + { + std::string str2=CPath::lookup ((const char*)str, false, false); + if (str2.empty()) + str2 = (const char*)str; + theApp.OpenDocumentFile (str2.c_str ()); + } + }*/ + } + } +} + +// *************************************************************************** + +CWnd* CFormDialog::GetNextDlgTabItem( CWnd* pWndCtl, BOOL bPrevious) const +{ + return NULL; +} + +// *************************************************************************** + +void CFormDialog::onFirstFocus () +{ + View->SetFocus (); + WidgetFocused = 0xffffffff; +} + +// *************************************************************************** + +void CFormDialog::onLastFocus () +{ + View->setFocusLeftView (); + WidgetFocused = 0xffffffff; +} + +// *************************************************************************** + +int CFormDialog::getWidget (uint dialogId) const +{ + for (uint i=0; iisDialog (dialogId)) + return i; + } + return -1; +} + +// *************************************************************************** + +BOOL CFormDialog::OnCommand(WPARAM wParam, LPARAM lParam) +{ + switch (HIWORD(wParam)) + { + case CBN_SETFOCUS: + { + onGetSubFocus (LOWORD(wParam)); + } + return TRUE; + case EN_SETFOCUS: + { + onGetSubFocus (LOWORD(wParam)); + } + return TRUE; + /*case CBN_SELENDOK: + { + // Look for the widget + int widgetId = getWidget (LOWORD(wParam)); + if (widgetId != -1) + setToDocument (widgetId); + } + return TRUE;*/ + case CBN_SELCHANGE: + { + // Look for the widget + int widgetId = getWidget (LOWORD(wParam)); + if (widgetId != -1) + setToDocument (widgetId); + } + return TRUE; + case EN_CHANGE: + { + // Look for the widget + int widgetId = getWidget (LOWORD(wParam)); + if (widgetId != -1) + { + CColorEdit *colorEdit = dynamic_cast (Widgets[widgetId]); + if (colorEdit) + { + CString str; + colorEdit->Edit.GetWindowText (str); + + sint r, g, b; + if (sscanf (str, "%d,%d,%d", &r, &g, &b) == 3) + { + clamp (r, 0, 255); + clamp (g, 0, 255); + clamp (b, 0, 255); + CRGBA color (r, g, b); + colorEdit->Color.setColor (color); + if (r != 255 && g != 255 && b != 255) + colorEdit->Empty = false; + } + } + } + } + return TRUE; + case BN_CLICKED: + { + // Get the window + int widgetId = getWidget (LOWORD(wParam)); + + // Dialog Pointer + if (widgetId != -1) + { + if ( (Widgets[widgetId]->getSrcType () == IFormWidget::TypeForm) || (Widgets[widgetId]->getSrcType () == IFormWidget::TypeType)) + { + CFormMemCombo *combo = dynamic_cast (Widgets[widgetId]); + if (combo && IsWindow (combo->Browse)) + { + CGeorgesEditDoc *doc = View->GetDocument (); + if (doc) + { + // Get current node + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + bool parentVDfnArray; + CForm *form=doc->getFormPtr (); + CFormElm *elm = doc->getRootNode (Widgets[widgetId]->getSlot ()); + nlverify ( elm->getNodeByName (Widgets[widgetId]->getFormName ().c_str (), &parentDfn, indexDfn, + &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); + nlassert (parentDfn); + + // Get the current filename extension + string ext = parentDfn->getEntry (indexDfn).getFilenameExt (); + + // Build a nice type name + char typeName[512]; + smprintf (typeName, 512, "%s", strlwr (ext).c_str()); + uint i=0; + while ((typeName[i] == '.') || (typeName[i] == '*')) + i++; + if (typeName[i]) + typeName[i] = toupper (typeName[i]); + + // Biuld the filter string + char filter[512]; + smprintf (filter, 512, "%s Files (%s)|%s|All Files(*.*)|*.*|", typeName+i, ext.c_str(), ext.c_str()); + + // Open the dialog + CFileDialog dlgFile (TRUE, ext.c_str (), ext.c_str (), OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, filter, theApp.m_pMainWnd); + if (dlgFile.DoModal () == IDOK) + { + combo->Combo.UpdateData (); + combo->Combo.SetWindowText (dlgFile.GetFileName ()); + combo->Combo.UpdateData (FALSE); + setToDocument (widgetId); + PostMessage (CBN_CHANGED, 0, 0); + } + } + } + else + { + // Reset button of color edit ? + CColorEdit *colorEdit = dynamic_cast (Widgets[widgetId]); + if (colorEdit && IsWindow (colorEdit->Color)) + { + colorEdit->Empty = true; + colorEdit->Edit.SetWindowText(""); + setToDocument (getWidget (wParam)); + updateValues (); + } + } + } + else if (Widgets[widgetId]->getSrcType () == IFormWidget::TypeVirtualDfn) + { + CFormMemCombo *combo = dynamic_cast (Widgets[widgetId]); + if (combo && IsWindow (combo->Browse)) + { + CGeorgesEditDoc *doc = View->GetDocument (); + if (doc) + { + // Build the filter string + char filter[512]; + smprintf (filter, 512, "Dfn Files (*.dfn)|*.dfn|All Files(*.*)|*.*|"); + + // Open the dialog + CFileDialog dlgFile (TRUE, "*.dfn", "*.dfn", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, filter, theApp.m_pMainWnd); + if (dlgFile.DoModal () == IDOK) + { + combo->Combo.UpdateData (); + combo->Combo.SetWindowText (dlgFile.GetFileName ()); + combo->Combo.UpdateData (FALSE); + setToDocument (widgetId); + } + } + } + } + else if (Widgets[widgetId]->getSrcType () == IFormWidget::TypeFormParent) + { + setToDocument (widgetId); + } + } + } + return TRUE; + } + + return CWnd::OnCommand(wParam, lParam); +} + +// *************************************************************************** + +BOOL CFormDialog::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) +{ + LPNMHDR pnmh = (LPNMHDR) lParam; + + // Get the CTRL ID + int idCtrl = (int) wParam; + + switch (pnmh->code) + { + case NM_SETFOCUS: + { + onGetSubFocus (idCtrl); + } + break; + // Spinner control + case UDN_DELTAPOS: + { + // Get the window + for (uint i=0; iisDialog (idCtrl)) + { + // Get the node type + Widgets[i]->getFormName (); + + // Get the structure + LPNMUPDOWN lpnmud = (LPNMUPDOWN) lParam; + + // Get a good pointer + CFormMemCombo *combo = (CFormMemCombo*)Widgets[i]; + + // Get the widget value + float value; + CString str; + combo->Combo.UpdateData (); + combo->Combo.GetWindowText (str); + if (sscanf (str, "%f", &value) == 1) + { + CGeorgesEditDoc *doc = View->GetDocument(); + if (doc) + { + // Get the node + const CFormDfn *parentDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + uint lastElement; + bool array; + bool parentVDfnArray; + UFormDfn::TEntryType type; + + // Search for the node + nlverify ((const CFormElm*)(doc->getRootNode (Widgets[i]->getSlot ()))->getNodeByName + (Widgets[i]->getFormName ().c_str (), &parentDfn, lastElement, &nodeDfn, &nodeType, + &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND)); + + // Todo: multiply here by the spinner precision + float increment = 1; + if (nodeType) + sscanf (nodeType->Increment.c_str (), "%f", &increment); + + value -= (float)(lpnmud->iDelta) * increment; + + // Print the result + char result[512]; + sprintf (result, "%g", value); + + // Set the windnow text + combo->Combo.SetWindowText (result); + combo->Combo.UpdateData (FALSE); + + // Update the widget + setToDocument (i); + } + } + break; + } + } + } + break; + } + + return CDialog::OnNotify(wParam, lParam, pResult); +} + +// *************************************************************************** + +void CFormDialog::resizeWidgets () +{ + if (Widgets.size ()) + { + RECT viewRect; + View->GetClientRect (&viewRect); + uint virtualWidth = std::max ((uint)MinViewWidth, (uint)(viewRect.right-viewRect.left)); + + // Refresh sizes + CBaseDialog::resizeWidgets (virtualWidth, 0); + + // Get first item coordinate + RECT currentPos; + getFirstItemPos (currentPos); + + // For each widgets + uint bigWidgetCount[2] = {0, 0}; + uint i; + uint biggestBottom[2] = {0, 0}; + uint nextSplit = Widgets.size ()/2; + for (i=0; inextSplit) ? 1:0; + + Widgets[i]->resizeScan (currentPos, bigWidgetCount[column], 0, false); + + if (currentPos.bottom > (int)biggestBottom[column]) + { + biggestBottom[column] = currentPos.bottom; + } + + if (nextSplit == i) + { + getNextColumn (currentPos); + currentPos.top = 0; + } + } + + // Refresh sizes + uint adjust[2]; + CBaseDialog::resizeWidgets (virtualWidth, biggestBottom[0]); + adjust[0] = AdjusteHeight; + CBaseDialog::resizeWidgets (virtualWidth, biggestBottom[1]); + adjust[1] = AdjusteHeight; + + // Get first item coordinate + currentPos; + getFirstItemPos (currentPos); + + uint adjustSum[2] = { + bigWidgetCount[0] ? adjust[0] / bigWidgetCount[0] : 0, + bigWidgetCount[1] ? adjust[1] / bigWidgetCount[1] : 0 }; + biggestBottom[0] = 0; + biggestBottom[1] = 0; + for (i=0; inextSplit) ? 1:0; + + if (Widgets[i]->extendableHeight ()) + { + Widgets[i]->resizeScan (currentPos, bigWidgetCount[column], adjustSum[column], true); + adjust[column] -= adjustSum[column]; + } + else + Widgets[i]->resizeScan (currentPos, bigWidgetCount[column], 0, true); + + if (currentPos.bottom > (int)biggestBottom[column]) + { + biggestBottom[column] = currentPos.bottom; + } + + if (nextSplit == i) + { + getNextColumn (currentPos); + currentPos.top = 0; + } + } + + uint column = (i>nextSplit) ? 1:0; + Widgets[i]->resizeScan (currentPos, bigWidgetCount[column], adjust[column], true); + + if (currentPos.bottom > (int)biggestBottom[column]) + { + biggestBottom[column] = currentPos.bottom; + } + + // Resize the current view + View->setViewSize (virtualWidth, std::max (biggestBottom[0], biggestBottom[1])+CGeorgesEditView::WidgetTopMargin+CGeorgesEditView::WidgetBottomMargin); + } +} + +// *************************************************************************** + +void CFormDialog::getFromDocument () +{ + CGeorgesEditDoc *doc = View->GetDocument(); + if (doc) + { + // Save current focus + uint widgetFocus; + for (widgetFocus=0; widgetFocushaveFocus ()) + break; + } + + // Current selection + CGeorgesEditDocSub *subObject = doc->getSelectedObject (); + + // Get the node + const CFormDfn *parentDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + uint lastElement; + bool array; + bool parentVDfnArray; + UFormDfn::TEntryType type; + + // Search for the node + nlverify (((const CFormElm*)(doc->getRootNode (subObject->getSlot ())))->getNodeByName (subObject->getFormName ().c_str (), &parentDfn, lastElement, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND)); + + // Should have a parent DFN, else it is the root element + if (parentDfn) + { + // Is an array ? + if ( array ) + { + // Must be a dfn + nlassert ( (type==UFormDfn::EntryDfn) || (type==UFormDfn::EntryType)); + getArrayFromDocument (subObject->getFormName ().c_str (), lastElement, subObject->getSlot ()); + } + else + { + // Is a struct ? + switch (parentDfn->getEntry (lastElement).getType ()) + { + // Type + case UFormDfn::EntryType: + nlassert ( !array ); + nlassert ( nodeType ); + nlassert ( parentDfn ); + nlassert (type==UFormDfn::EntryType); + getTypeFromDocument (*nodeType, + (parentDfn->getEntry(lastElement).getName()+":").c_str (), + parentDfn->getEntry(lastElement).getFilename().c_str(), + subObject->getFormName ().c_str (), subObject->getSlot ()); + break; + // Dfn + case UFormDfn::EntryDfn: + nlassert ( !array ); + nlassert ((nodeDfn) && (type==UFormDfn::EntryDfn)); + getDfnFromDocument (*nodeDfn, subObject->getFormName ().c_str (), subObject->getSlot ()); + break; + // Virtual Dfn + case UFormDfn::EntryVirtualDfn: + nlassert ( !array ); + getVirtualDfnFromDocument (nodeDfn, subObject->getFormName ().c_str (), subObject->getSlot ()); + break; + } + } + } + else + { + nlassert ( !array ); + nlassert ((nodeDfn) && (type==UFormDfn::EntryDfn)); + getDfnFromDocument (*nodeDfn, subObject->getFormName ().c_str (), subObject->getSlot ()); + } + + // Update labels + for (uint i=0; iupdateLabel (); + } + + // Set the focus + if (widgetFocussetFocus (); + } + + // Resize the widgets + resizeWidgets (); + } +} + +// *************************************************************************** + +void CFormDialog::getDfnName (string &result) const +{ + CGeorgesEditDoc *doc = View->GetDocument (); + if (doc) + { + // Get the DFN filename + CString str = doc->GetPathName (); + char extension[512]; + _splitpath (str, NULL, NULL, NULL, extension); + result = (*extension == '.') ? extension+1 : extension; + } + else + result = ""; +} + +// *************************************************************************** + +void CFormDialog::OnLButtonDown(UINT nFlags, CPoint point) +{ + // Get the focus + View->TabCtrl.SetFocus (); + + CDialog::OnLButtonDown(nFlags, point); +} + +// *************************************************************************** + +void CFormDialog::onGetSubFocus (uint id) +{ + // Get the widget + int widget = getWidget (id); + WidgetFocused = widget; + + // Window view + RECT widgetRect; + if (Widgets[widget]->getWindowRect (widgetRect)) + { + View->ScreenToClient (&widgetRect); + + // Scroll the view to be visible + RECT viewRect; + View->GetClientRect (&viewRect); + int bottom = viewRect.bottom - viewRect.top; + if (widgetRect.bottom > bottom) + { + CPoint pt = View->GetScrollPosition (); + View->ScrollToPosition (CPoint (pt.x, pt.y + widgetRect.bottom - bottom + 10)); + } + if (widgetRect.top < 0) + { + CPoint pt = View->GetScrollPosition (); + View->ScrollToPosition (CPoint (pt.x, pt.y + widgetRect.top - 10)); + } + } +} + +// *************************************************************************** + +void CFormDialog::OnSetFocus(CWnd* pNewWnd) +{ + CDialog::OnSetFocus(pNewWnd); + if (WidgetFocused != 0xffffffff) + Widgets[WidgetFocused]->setFocus (); +} + +// *************************************************************************** + +void CFormDialog::OnKillFocus(CWnd* pNewWnd) +{ + CDialog::OnKillFocus(pNewWnd); +} + +// *************************************************************************** +// IFormWidget +// *************************************************************************** + +IFormWidget::IFormWidget (CFormDialog *dialog, uint structId, const char *atomName, TTypeSrc typeSrc, uint slot) +{ + FormName = atomName; + Dialog = dialog; + StructId = structId; + SrcType = typeSrc; + Slot = slot; +} + +// *************************************************************************** + +bool IFormWidget::isDialog (uint id) const +{ + return (id>=FirstId) && (id<=LastId); +}; + +// *************************************************************************** + +uint IFormWidget::getSlot () const +{ + return Slot; +}; + +// *************************************************************************** + +uint IFormWidget::getStructId () const +{ + return StructId; +} + +// *************************************************************************** + +void IFormWidget::updateLabel () +{ + // Does the node in the same form ? + CGeorgesEditDoc *doc = Dialog->View->GetDocument (); + if (doc) + { + // Is the label a window ? + if (IsWindow (Label)) + { + // No label for parent widget + if (SrcType != TypeFormParent) + { + // Value type ? + if ((SrcType == TypeForm) || (SrcType == TypeType)) + { + // Get the value + std::string result; + UFormElm::TWhereIsValue where; + CForm *form=doc->getFormPtr (); + CFormElm *elm = doc->getRootNode (getSlot ()); + nlverify (elm->getValueByName (result, FormName.c_str (), UFormElm::NoEval, &where)); + + // Get the value evaluated + std::string resultEvaluated; +#ifdef TEST_EVAL_FORMULA + bool error = !elm->getValueByName (resultEvaluated, FormName.c_str (), UFormElm::Formula, &where); +#else // TEST_EVAL_FORMULA + bool error = !elm->getValueByName (resultEvaluated, FormName.c_str (), UFormElm::Eval, &where); +#endif // TEST_EVAL_FORMULA + + // Complete the array ? + string comp; + if (error) + comp = " (Value = Error)"; + else + { + if (resultEvaluated != result) + comp=" (Value = \""+resultEvaluated+"\")"; + } + + // Does the node exist ? + switch (where) + { + case UFormElm::ValueForm: + Label.SetWindowText ((SavedLabel+comp).c_str()); + break; + case UFormElm::ValueParentForm: + Label.SetWindowText ((SavedLabel+" (in parent form)"+comp).c_str()); + break; + case UFormElm::ValueDefaultDfn: + Label.SetWindowText ((SavedLabel+" (default DFN value)"+comp).c_str()); + break; + case UFormElm::ValueDefaultType: + Label.SetWindowText ((SavedLabel+" (default TYPE value)"+comp).c_str()); + break; + } + } + else + { + // Get the node + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + bool parentVDfnArray; + CForm *form=doc->getFormPtr (); + CFormElm *elm = doc->getRootNode (getSlot ()); + nlverify ( elm->getNodeByName (FormName.c_str (), &parentDfn, indexDfn, + &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); + + // Does the node exist ? + if (node) + { + // Same form ? + if (node->getForm () == doc->getFormPtr ()) + { + // The node exist + Label.SetWindowText (SavedLabel.c_str()); + } + else + { + // The node exist in the parent form + Label.SetWindowText ((SavedLabel+" (in parent form)").c_str()); + } + } + else + { + // The node is empty + Label.SetWindowText ((SavedLabel+" (undefined)").c_str()); + } + } + + // Update widget + Label.UpdateData (FALSE); + } + } + } +} + +// *************************************************************************** + +IFormWidget::TTypeSrc IFormWidget::getSrcType () const +{ + return SrcType; +} + +// *************************************************************************** + +bool IFormWidget::extendableHeight () const +{ + return false; +} + +// *************************************************************************** + +bool IFormWidget::getNode (const CFormDfn **parentDfn, uint &lastElement, const CFormDfn **nodeDfn, const CType **nodeType, + CFormElm **node, UFormDfn::TEntryType &type, bool &array) const +{ + // Get the document + CGeorgesEditDoc *doc = Dialog->View->GetDocument (); + if (doc) + { + // Return the node + bool parentVDfnArray; + CForm *form=doc->getFormPtr (); + CFormElm *elm = doc->getRootNode (getSlot ()); + return (elm->getNodeByName (FormName.c_str (), parentDfn, + lastElement, nodeDfn, nodeType, node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); + } + return false; +} + +// *************************************************************************** + +CFormElm *IFormWidget::getFormElmNode () const +{ + const CFormDfn *parentDfn; + uint parentDfnIndex; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + if (getNode (&parentDfn, parentDfnIndex, &nodeDfn, &nodeType, &node, type, array)) + { + return node; + } + return NULL; +} + +// *************************************************************************** + +CFormElmStruct *IFormWidget::getFormElmStructNode () const +{ + CFormElm *elm = getFormElmNode (); + return elm ? safe_cast (elm) : NULL; +} + +// *************************************************************************** + +CFormElmVirtualStruct *IFormWidget::getFormElmVirtualStructNode () const +{ + CFormElm *elm = getFormElmNode (); + return elm ? safe_cast (elm) : NULL; +} + +// *************************************************************************** + +CFormElmArray *IFormWidget::getFormElmArrayNode () const +{ + CFormElm *elm = getFormElmNode (); + return elm ? safe_cast (elm) : NULL; +} + +// *************************************************************************** + +CFormElmAtom *IFormWidget::getFormElmAtomNode () const +{ + CFormElm *elm = getFormElmNode (); + return elm ? safe_cast (elm) : NULL; +} + +// *************************************************************************** + +const string &IFormWidget::getFormName () const +{ + return FormName; +} + +// *************************************************************************** + +uint IFormWidget::getNumValue () +{ + // Not implemented for this widget + nlstop; + return 0; +} + +// *************************************************************************** + +void IFormWidget::getValue (std::string &result) +{ + // Not implemented for this widget + nlstop; +} + +// *************************************************************************** + +void IFormWidget::getValue (std::string &result, uint value) +{ + // Not implemented for this widget + nlstop; +} + +// *************************************************************************** + +bool IFormWidget::getWindowRect (RECT &rect) const +{ + if (IsWindow (Label)) + { + Label.GetWindowRect (&rect); + return true; + } + else + return false; +} + +// *************************************************************************** + +void IFormWidget::onOpenSelected () +{ + string str; + getValue (str); + + std::string str2=CPath::lookup (str.c_str (), false, false); + if (str2.empty()) + str2 = str.c_str (); + theApp.OpenDocumentFile (str2.c_str ()); +} + +// *************************************************************************** +// CFormMemCombo +// *************************************************************************** + +CFormMemCombo::CFormMemCombo (CFormDialog *dialog, uint structId, const char *atomName, TTypeSrc typeSrc, uint slot) : IFormWidget (dialog, structId, atomName, typeSrc, slot) +{ + UseSpinner = false; + FileBrowser = false; +} + +// *************************************************************************** + +CFormMemCombo::~CFormMemCombo () +{ + if (IsWindow (Label)) + Label.DestroyWindow (); + if (IsWindow (Combo)) + Combo.DestroyWindow (); + if (IsWindow (Spin)) + Spin.DestroyWindow (); + if (IsWindow (Browse)) + Browse.DestroyWindow (); +} + +// *************************************************************************** + +void CFormMemCombo::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label, const char *reg, bool useSpinner, bool fileBrowser, const char *filenameExt) +{ + // Get the doc + CGeorgesEditDoc *doc = Dialog->View->GetDocument (); + nlassert (doc); + + // Get the node type (if any) + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType = NULL; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + bool parentVDfnArray; + CForm *form=doc->getFormPtr (); + CFormElm *elm = doc->getRootNode (getSlot ()); + nlverify ( elm->getNodeByName (FormName.c_str (), &parentDfn, indexDfn, + &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); + + FirstId = dialog_index; + LastId = FirstId+1; + + // Save the label + SavedLabel = label; + + // Create the type combo + parent->setStaticSize (currentPos); + Label.Create (label, WS_VISIBLE, currentPos, parent); + parent->initWidget (Label); + parent->getNextPosLabel (currentPos); + + UseSpinner = useSpinner; + FileBrowser = fileBrowser; + + // Create the spinner + if (useSpinner) + { + // Create the mem combobox + parent->setComboSpinSize (currentPos); + Combo.create (WS_CHILD|WS_TABSTOP, currentPos, parent, dialog_index, reg, theApp.RememberListSize); + parent->initWidget (Combo); + + // Create the spin + RECT spinPos = currentPos; + parent->getNextSpinPos (spinPos); + parent->setSpinSize (spinPos); + Spin.Create (WS_CHILD|WS_VISIBLE, spinPos, parent, dialog_index+1); + //Spin.SetBuddy (&Combo.ComboBox); + parent->getNextPos (currentPos); + } + else if (fileBrowser) + { + // Create the mem combobox + parent->setComboBrowseSize (currentPos); + Combo.create (WS_CHILD|WS_TABSTOP, currentPos, parent, dialog_index, reg, theApp.RememberListSize); + parent->initWidget (Combo); + + // Create the spin + RECT spinPos = currentPos; + parent->getNextBrowsePos (spinPos); + parent->setBrowseSize (spinPos); + Browse.Create ("...", WS_CHILD|WS_VISIBLE|WS_TABSTOP, spinPos, parent, dialog_index+1); + parent->initWidget (Browse); + parent->getNextPos (currentPos); + + // Set autocomplete mode + if (filenameExt) + { + if (strcmp (filenameExt, "*.*") != 0) + Combo.enableAutoCompleteExtension (true, filenameExt); + } + } + else + { + // Create the mem combobox + parent->setComboSize (currentPos, parent->SmallWidget); + Combo.create (WS_CHILD|WS_TABSTOP, currentPos, parent, dialog_index, reg, theApp.RememberListSize); + parent->initWidget (Combo); + parent->getNextPos (currentPos); + } + + // Get predefs + if (nodeType) + { + for (uint predef=0; predefDefinitions.size(); predef++) + { + Combo.addStaticStrings (nodeType->Definitions[predef].Label.c_str()); + } + } + + dialog_index += 2; +} + +// *************************************************************************** + +void CFormMemCombo::updateData (bool update) +{ + Combo.UpdateData (update?TRUE:FALSE); +} + +// *************************************************************************** + +bool CFormMemCombo::haveFocus () +{ + return (Combo.haveFocus ()); +} + +// *************************************************************************** + +void CFormMemCombo::setFocus () +{ + Combo.SetFocus (); +} + +// *************************************************************************** + +void CFormMemCombo::onOk () +{ + Combo.onOK (); +} + +// *************************************************************************** + +void CFormMemCombo::getValue (std::string &result) +{ + Combo.UpdateData (); + + CString str; + Combo.GetWindowText (str); + + Combo.UpdateData (FALSE); + + // Set the atom value + result = (const char*)str; +} + +// *************************************************************************** + +void CFormMemCombo::getFromDocument (CForm &form) +{ + CGeorgesEditDoc *doc = Dialog->View->GetDocument (); + nlassert (doc); + + if ((SrcType == TypeForm) || (SrcType == TypeType)) + { + string result; + if (doc->getRootNode(getSlot ())->getValueByName (result, FormName.c_str(), UFormElm::NoEval, NULL)) + { + Combo.UpdateData (); + Combo.SetWindowText (result.c_str()); + Combo.UpdateData (FALSE); + updateLabel (); + } + else + { + nlstop; + } + } + else if (SrcType == TypeArray) + { + const CFormDfn *parentDfn; + uint lastElement; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + bool parentVDfnArray; + nlverify (((const CFormElm*)doc->getRootNode(getSlot ()))->getNodeByName (FormName.c_str(), &parentDfn, lastElement, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND)); + nlassert (array); + + // Node exist ? + Combo.UpdateData (); + if (node) + { + CFormElmArray *arrayNode = safe_cast (node); + char label[512]; + smprintf (label, 512, "%d", arrayNode->Elements.size ()); + Combo.SetWindowText (label); + + if (arrayNode->getForm () == &form) + Label.SetWindowText ("Array size:"); + else + Label.SetWindowText ("Array size: (in parent form)"); + } + else + { + Combo.SetWindowText ("0"); + } + Combo.UpdateData (FALSE); + } + else if (SrcType == TypeVirtualDfn) + { + const CFormDfn *parentDfn; + uint lastElement; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + bool parentVDfnArray; + nlverify (((const CFormElm*)doc->getRootNode (getSlot ()))->getNodeByName (FormName.c_str(), &parentDfn, lastElement, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND)); + nlassert (!array); + + // Node exist ? + Combo.UpdateData (); + if (node) + { + CFormElmVirtualStruct *virtualNode = safe_cast (node); + Combo.SetWindowText (virtualNode->DfnFilename.c_str()); + } + else + { + Combo.SetWindowText (""); + } + Combo.UpdateData (FALSE); + } +} + +// *************************************************************************** + +bool CFormMemCombo::isWnd (const CWnd *wnd) const +{ + return Combo.isWnd (wnd); +} + +// *************************************************************************** + +void CFormMemCombo::resizeScan (RECT ¤tPos, uint &widgetCount, uint adjust, bool resize) +{ + // Create the type combo + Dialog->setStaticSize (currentPos); + if (resize) + { + Label.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + } + Dialog->getNextPosLabel (currentPos); + + // Create the spinner + if (UseSpinner) + { + // Create the mem combobox + Dialog->setComboSpinSize (currentPos); + if (resize) + { + Combo.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + } + + // Create the spin + RECT spinPos = currentPos; + Dialog->getNextSpinPos (spinPos); + Dialog->setSpinSize (spinPos); + if (resize) + { + Spin.SetWindowPos (NULL, spinPos.left, spinPos.top, spinPos.right - spinPos.left, + spinPos.bottom - spinPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + } + } + else if (FileBrowser) + { + // Create the mem combobox + Dialog->setComboBrowseSize (currentPos); + if (resize) + { + Combo.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + } + + // Create the spin + RECT spinPos = currentPos; + Dialog->getNextBrowsePos (spinPos); + Dialog->setBrowseSize (spinPos); + if (resize) + { + Browse.SetWindowPos (NULL, spinPos.left, spinPos.top, spinPos.right - spinPos.left, + spinPos.bottom - spinPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + } + } + else + { + // Create the mem combobox + Dialog->setComboSize (currentPos, Dialog->SmallWidget); + if (resize) + { + Combo.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + } + } + Dialog->getNextPos (currentPos); +} + +// *************************************************************************** + +bool CFormMemCombo::getWindowRect (RECT &rect) const +{ + if (Combo) + { + // Get parent rect + RECT parentRect; + IFormWidget::getWindowRect (parentRect); + + // Add my rect + RECT myRect; + Combo.GetWindowRect (&myRect); + UnionRect(&rect, &myRect, &parentRect); + return true; + } + else + return false; +} + +// *************************************************************************** +// CFormCombo +// *************************************************************************** + +CFormCombo::CFormCombo (CFormDialog *dialog, uint structId, const char *atomName, IFormWidget::TTypeSrc typeForm, uint slot) : IFormWidget (dialog, structId, atomName, typeForm, slot) +{ +} + +// *************************************************************************** + +CFormCombo::~CFormCombo () +{ + if (IsWindow (Label)) + Label.DestroyWindow (); + if (IsWindow (Combo)) + Combo.DestroyWindow (); +} + +// *************************************************************************** + +void CFormCombo::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label) +{ + // Get the doc + CGeorgesEditDoc *doc = Dialog->View->GetDocument (); + nlassert (doc); + + FirstId = dialog_index; + LastId = FirstId; + + // Get the value for the type pointer (if any) + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + bool parentVDfnArray; + CForm *form=doc->getFormPtr (); + CFormElm *elm = doc->getRootNode (getSlot ()); + nlverify ( elm->getNodeByName (FormName.c_str (), &parentDfn, indexDfn, + &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); + + // Save the label + SavedLabel = label; + + // Create the type combo + parent->setStaticSize (currentPos); + Label.Create (label, WS_VISIBLE, currentPos, parent); + parent->initWidget (Label); + parent->getNextPosLabel (currentPos); + + // Create the mem combobox + parent->setComboSize (currentPos, parent->SmallWidget); + RECT comboPos = currentPos; + parent->adjusteComboSize (comboPos); + Combo.Create (WS_CHILD|WS_VSCROLL|WS_VISIBLE|CBS_DROPDOWNLIST|CBS_HASSTRINGS|WS_CHILD|WS_TABSTOP, comboPos, parent, dialog_index); + parent->initWidget (Combo); + parent->getNextPos (currentPos); + + // Get predefs + if (nodeType) + { + Combo.InsertString (0, ""); + for (uint predef=0; predefDefinitions.size(); predef++) + { + Combo.InsertString (predef+1, nodeType->Definitions[predef].Label.c_str()); + } + } + + dialog_index += 1; +} + +// *************************************************************************** + +void CFormCombo::updateData (bool update) +{ + Combo.UpdateData (update?TRUE:FALSE); +} + +// *************************************************************************** + +bool CFormCombo::haveFocus () +{ + CWnd *focus = CWnd::GetFocus (); + if (focus) + { + return (focus == &Combo); + } + return false; +} + +// *************************************************************************** + +void CFormCombo::setFocus () +{ + Combo.SetFocus (); +} + +// *************************************************************************** + +void CFormCombo::onOk () +{ + //Combo.onOK (); +} + +// *************************************************************************** + +void CFormCombo::getValue (std::string &result) +{ + Combo.UpdateData (); + + CString str; + Combo.GetWindowText (str); + + Combo.UpdateData (FALSE); + + // Set the atom value + result = (const char*)str; +} + +// *************************************************************************** + +void CFormCombo::getFromDocument (CForm &form) +{ + CGeorgesEditDoc *doc = Dialog->View->GetDocument (); + nlassert (doc); + string result; + if (doc->getRootNode (getSlot ())->getValueByName (result, FormName.c_str(), UFormElm::NoEval, NULL)) + { + Combo.UpdateData (); + uint itemCount = Combo.GetCount (); + for (uint i=0; isetStaticSize (currentPos); + if (resize) + { + Label.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + } + Dialog->getNextPosLabel (currentPos); + + // Create the mem combobox + Dialog->setComboSize (currentPos, Dialog->SmallWidget); + if (resize) + { + RECT comboPos = currentPos; + Dialog->adjusteComboSize (comboPos); + Combo.SetWindowPos (NULL, comboPos.left, comboPos.top, comboPos.right - comboPos.left, + comboPos.bottom - comboPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + } + Dialog->getNextPos (currentPos); +} + +// *************************************************************************** + +bool CFormCombo::getWindowRect (RECT &rect) const +{ + if (IsWindow (Combo)) + { + // Get parent rect + RECT parentRect; + IFormWidget::getWindowRect (parentRect); + + // Add my rect + RECT myRect; + Combo.GetWindowRect (&myRect); + UnionRect(&rect, &myRect, &parentRect); + return true; + } + else + return false; +} + +// *************************************************************************** +// CFormBigEdit +// *************************************************************************** + +CFormBigEdit::CFormBigEdit (CFormDialog *dialog, uint structId, const char *atomName, IFormWidget::TTypeSrc typeForm, uint slot) : IFormWidget (dialog, structId, atomName, typeForm, slot) +{ +} + +// *************************************************************************** + +CFormBigEdit::~CFormBigEdit () +{ + if (IsWindow (Label)) + Label.DestroyWindow (); + if (IsWindow (Edit)) + Edit.DestroyWindow (); +} + +// *************************************************************************** + +void CFormBigEdit::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label) +{ + FirstId = dialog_index; + LastId = FirstId; + + // Save the label + SavedLabel = label; + + // Create the type combo + parent->setStaticSize (currentPos); + Label.Create (label, WS_VISIBLE, currentPos, parent); + parent->initWidget (Label); + parent->getNextPosLabel (currentPos); + + // Create the mem combobox + parent->setBigEditSize (currentPos, parent->SmallWidget); + Edit.CreateEx (WS_EX_CLIENTEDGE, _T("EDIT"), "", WS_VSCROLL|ES_OEMCONVERT|ES_MULTILINE|ES_WANTRETURN|WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL|ES_AUTOVSCROLL, currentPos, parent, dialog_index); + parent->initWidget (Edit); + parent->getNextPos (currentPos); + + dialog_index += 1; +} + +// *************************************************************************** + +void CFormBigEdit::updateData (bool update) +{ + Edit.UpdateData (update?TRUE:FALSE); +} + +// *************************************************************************** + +bool CFormBigEdit::haveFocus () +{ + CWnd *focus = CWnd::GetFocus (); + if (focus) + { + return (focus == &Edit); + } + return false; +} + +// *************************************************************************** + +void CFormBigEdit::setFocus () +{ + Edit.SetFocus (); +} + +// *************************************************************************** + +void CFormBigEdit::onOk () +{ + //Combo.onOK (); +} + +// *************************************************************************** + +void CFormBigEdit::getValue (std::string &result) +{ + Edit.UpdateData (); + + CString str; + Edit.GetWindowText (str); + + Edit.UpdateData (FALSE); + + // Set the atom value + result = (const char*)str; +} + +// *************************************************************************** + +void CFormBigEdit::getFromDocument (CForm &form) +{ + CGeorgesEditDoc *doc = Dialog->View->GetDocument (); + nlassert (doc); + string result; + if (doc->getRootNode (getSlot ())->getValueByName (result, FormName.c_str(), UFormElm::NoEval, NULL)) + { + Edit.UpdateData (); + Dialog->setEditTextMultiLine (Edit, result.c_str()); + Edit.UpdateData (FALSE); + updateLabel (); + } + else + { + nlstop; + } +} + +// *************************************************************************** + +bool CFormBigEdit::isWnd (const CWnd *wnd) const +{ + return &Edit == wnd; +} + +// *************************************************************************** + +void CFormBigEdit::resizeScan (RECT ¤tPos, uint &widgetCount, uint adjust, bool resize) +{ + if (!resize) + widgetCount++; + + // Create the type combo + Dialog->setStaticSize (currentPos); + if (resize) + { + Label.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + } + Dialog->getNextPosLabel (currentPos); + + // Create the mem combobox + Dialog->setBigEditSize (currentPos, Dialog->SmallWidgetNotLimited, Dialog->BigEditHeight + adjust); + if (resize) + { + Edit.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + } + Dialog->getNextPos (currentPos); +} + +// *************************************************************************** + +bool CFormBigEdit::extendableHeight () const +{ + return true; +} + +// *************************************************************************** + +bool CFormBigEdit::getWindowRect (RECT &rect) const +{ + if (IsWindow (Edit)) + { + // Get parent rect + RECT parentRect; + IFormWidget::getWindowRect (parentRect); + + // Add my rect + RECT myRect; + Edit.GetWindowRect (&myRect); + UnionRect(&rect, &myRect, &parentRect); + return true; + } + else + return false; +} + +// *************************************************************************** +// CColorEdit +// *************************************************************************** + +CColorEdit::CColorEdit (CFormDialog *dialog, uint structId, const char *atomName, IFormWidget::TTypeSrc typeForm, uint slot) : IFormWidget (dialog, structId, atomName, typeForm, slot) +{ + Empty = true; +} + +// *************************************************************************** + +CColorEdit::~CColorEdit () +{ + if (IsWindow (Label)) + Label.DestroyWindow (); + if (IsWindow (Color)) + Color.DestroyWindow (); + if (IsWindow (Edit)) + Edit.DestroyWindow (); +} + +// *************************************************************************** + +void CColorEdit::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label) +{ + FirstId = dialog_index; + LastId = FirstId+2; + + // Save the label + SavedLabel = label; + + // Create the type combo + parent->setStaticSize (currentPos); + Label.Create (label, WS_VISIBLE, currentPos, parent); + parent->initWidget (Label); + parent->getNextPosLabel (currentPos); + + // Create the mem combobox + parent->setColorSize (currentPos, parent->SmallWidget); + Color.create (WS_CHILD|WS_VISIBLE|WS_TABSTOP, currentPos, parent, dialog_index); + parent->initWidget (Color); + + // Create the reset button + RECT resetPos = currentPos; + parent->getNextColorPos (resetPos); + parent->setResetColorSize (resetPos); + Reset.Create ("Reset", WS_CHILD|WS_VISIBLE|WS_TABSTOP, resetPos, parent, dialog_index+1); + parent->initWidget (Reset); + parent->getNextPosLabel (currentPos); + + // Create the Edit + parent->setBigEditSize (currentPos, parent->SmallWidget); + Edit.CreateEx (WS_EX_CLIENTEDGE, _T("EDIT"), "", ES_OEMCONVERT|ES_WANTRETURN|WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL, currentPos, parent, dialog_index+2); + parent->initWidget (Edit); + parent->getNextPos (currentPos); + + Color.setEdit(&Edit); + + dialog_index += 3; +} + +// *************************************************************************** + +void CColorEdit::updateData (bool update) +{ + Color.UpdateData (update?TRUE:FALSE); + Edit.UpdateData (update?TRUE:FALSE); +} + +// *************************************************************************** + +bool CColorEdit::haveFocus () +{ + CWnd *focus = CWnd::GetFocus (); + if (focus) + { + return (focus == &Color); + } + return false; +} + +// *************************************************************************** + +void CColorEdit::setFocus () +{ + Color.SetFocus (); +} + +// *************************************************************************** + +void CColorEdit::onOk () +{ + // Color.onOk (); +} + +// *************************************************************************** + +void CColorEdit::getValue (std::string &result) +{ + if (!Empty) + { + Color.UpdateData (); + + // Get the color + CRGBA color = Color.getColor (); + + // Make a string + char colorName[512]; + smprintf (colorName, 512, "%d,%d,%d", color.R, color.G, color.B); + + // Set the atom value + result = colorName; + } + else + { + result = ""; + } +} + +// *************************************************************************** + +void CColorEdit::getFromDocument (CForm &form) +{ + CGeorgesEditDoc *doc = Dialog->View->GetDocument (); + nlassert (doc); + string result; + if (doc->getRootNode (getSlot ())->getValueByName (result, FormName.c_str(), UFormElm::NoEval, NULL)) + { + Color.UpdateData (); + + // Make a color + sint r, g, b; + if (sscanf (result.c_str(), "%d,%d,%d", &r, &g, &b) == 3) + { + clamp (r, 0, 255); + clamp (g, 0, 255); + clamp (b, 0, 255); + CRGBA color (r, g, b); + Color.setColor (color); + if (r != 255 && g != 255 && b != 255) + Color.updateEdit(); + } + else + { + Color.setColor (CRGBA::Black); + Color.updateEdit(); + } + Color.UpdateData (FALSE); + updateLabel (); + } + else + { + nlstop; + } +} + + +// *************************************************************************** + +bool CColorEdit::isWnd (const CWnd *wnd) const +{ + return &Color == wnd; +} + +// *************************************************************************** + +void CColorEdit::resizeScan (RECT ¤tPos, uint &widgetCount, uint adjust, bool resize) +{ + // Create the type combo + Dialog->setStaticSize (currentPos); + if (resize) + { + Label.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + } + Dialog->getNextPosLabel (currentPos); + + // Create the mem combobox + Dialog->setColorSize (currentPos, Dialog->SmallWidget); + if (resize) + { + Color.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + } + + // Create the spin + RECT resetPos = currentPos; + Dialog->getNextColorPos (resetPos); + Dialog->setResetColorSize (resetPos); + if (resize) + { + Reset.SetWindowPos (NULL, resetPos.left, resetPos.top, resetPos.right - resetPos.left, + resetPos.bottom - resetPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + } + Dialog->getNextPosLabel (currentPos); + + // Create the Edit + Dialog->setEditSize (currentPos, Dialog->SmallWidget, Dialog->EditHeight); + if (resize) + { + Edit.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + } + + Dialog->getNextPos (currentPos); +} + +// *************************************************************************** + +bool CColorEdit::getWindowRect (RECT &rect) const +{ + if (IsWindow (Color)) + { + // Get parent rect + RECT parentRect; + IFormWidget::getWindowRect (parentRect); + + // Add my rect + RECT myRect; + Color.GetWindowRect (&myRect); + UnionRect(&rect, &myRect, &parentRect); + return true; + } + else + return false; +} + +// *************************************************************************** +// CListWidget +// *************************************************************************** + +CListWidget::CListWidget (CFormDialog *dialog, uint structId, const char *atomName, IFormWidget::TTypeSrc typeForm, uint slot) : IFormWidget (dialog, structId, atomName, typeForm, slot) +{ + ListCtrl.Ctrl = this; +} + +// *************************************************************************** + +CListWidget::~CListWidget () +{ + if (IsWindow (Label)) + Label.DestroyWindow (); + if (IsWindow (ListCtrl)) + ListCtrl.DestroyWindow (); + if (IsWindow (Button)) + Button.DestroyWindow (); +} + +// *************************************************************************** + +void CListWidget::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label, const char *reg, uint divid) +{ + FirstId = dialog_index; + LastId = FirstId+1; + + Divid = divid; + RegAdr = reg; + + // Save the label + SavedLabel = label; + + // Create the type combo + parent->setStaticSize (currentPos); + Label.Create (label, WS_VISIBLE, currentPos, parent); + parent->initWidget (Label); + parent->getNextPosLabel (currentPos); + + // Create the mem combobox + parent->setListSize (currentPos, parent->SmallWidget); + ListCtrl.create (WS_CHILD|WS_VISIBLE|WS_TABSTOP, currentPos, parent, dialog_index); + parent->initWidget (ListCtrl); + parent->getNextPos (currentPos); + + // Create the assign parent + parent->setButtonSize (currentPos, parent->SmallWidget); + Button.Create ("Assign parents", WS_CHILD|WS_VISIBLE|WS_TABSTOP, currentPos, parent, dialog_index+1); + parent->initWidget (Button); + parent->getNextPos (currentPos); + + dialog_index += 2; +} + +// *************************************************************************** + +void CListWidget::addColumn (const char *name) +{ + ListCtrl.insertColumn (0, name); + ListCtrl.recalcColumn (); +} + +// *************************************************************************** + +void CListWidget::onOk () +{ + ListCtrl.onOK (); +} + +// *************************************************************************** + +void CListWidget::updateData (bool update) +{ + ListCtrl.UpdateData (update); +} + +// *************************************************************************** + +bool CListWidget::haveFocus () +{ + CWnd *wnd = Dialog->GetFocus (); + if (wnd) + { + return (wnd->GetParent () == &ListCtrl); + } + return false; +} + +// *************************************************************************** + +void CListWidget::setFocus () +{ + ListCtrl.SetFocus (); +} + +// *************************************************************************** + +void CListWidget::getFromDocument (NLGEORGES::CForm &form) +{ + // Erase the list + ListCtrl.ListCtrl.DeleteAllItems (); + + // For each parent + for (uint parent=0; parentsetStaticSize (currentPos); + if (resize) + { + Label.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + } + Dialog->getNextPosLabel (currentPos); + + // Create the mem combobox + Dialog->setListSize (currentPos, Dialog->SmallWidgetNotLimited / Divid, Dialog->ListHeight + adjust); + if (resize) + { + ListCtrl.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + ListCtrl.recalcColumn (); + } + Dialog->getNextPos (currentPos); + + // Create the mem combobox + Dialog->setButtonSize (currentPos, Dialog->SmallWidget); + if (resize) + { + Button.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + } + Dialog->getNextPos (currentPos); +} + +// *************************************************************************** + +bool CListWidget::extendableHeight () const +{ + return true; +} + +// *************************************************************************** + +CEditListCtrl::TItemEdit CListWidget::CMyEditListCtrl::getItemEditMode (uint item, uint subItem) +{ + return CEditListCtrl::EditMemCombo; +} + +// *************************************************************************** + +void CListWidget::CMyEditListCtrl::getMemComboBoxProp (uint item, uint subItem, std::string ®Adr, bool &browse) +{ + regAdr = Ctrl->RegAdr; + browse = true; +} + +// *************************************************************************** + +void CListWidget::CMyEditListCtrl::getNewItemText (uint item, uint subItem, std::string &ret) +{ + Ctrl->Dialog->getDfnName (ret); + ret = "default." + ret; +} + +// *************************************************************************** + +void CListWidget::CMyEditListCtrl::getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::string &filter) +{ + string ret; + Ctrl->Dialog->getDfnName (ret); + defExt = "*." + ret; + defFilename = defExt; + + filter = "Form Files (*." + ret + ")|*." + ret + "|All Files (*.*)|*.*||"; + defDir = theApp.RootSearchPath; +} + +// *************************************************************************** + +bool CListWidget::getWindowRect (RECT &rect) const +{ + if (IsWindow (ListCtrl)) + { + // Get parent rect + RECT parentRect; + IFormWidget::getWindowRect (parentRect); + + // Add my rect + RECT myRect; + ListCtrl.ListCtrl.GetWindowRect (&myRect); + UnionRect(&rect, &myRect, &parentRect); + return true; + } + else + return false; +} + +// *************************************************************************** + +void CListWidget::onOpenSelected () +{ + // For each selected + POSITION pos = ListCtrl.ListCtrl.GetFirstSelectedItemPosition(); + while (pos) + { + int nItem = ListCtrl.ListCtrl.GetNextSelectedItem(pos); + + // Get the string + CString str = ListCtrl.ListCtrl.GetItemText (nItem, 0); + if (str != "") + { + // Look for the file + string name = CPath::lookup ((const char*)str, false, false); + if (name.empty ()) + name = str; + + // Open the file + theApp.OpenDocumentFile (name.c_str ()); + } + } +} + +// *************************************************************************** + +// *************************************************************************** +// CIconWidget +// *************************************************************************** + +CIconWidget::CIconWidget (CFormDialog *dialog, uint structId, const char *atomName, IFormWidget::TTypeSrc typeForm, uint slot) : IFormWidget (dialog, structId, atomName, typeForm, slot) +{ + +} + +// *************************************************************************** + +CIconWidget::~CIconWidget () +{ + if (IsWindow (Icon)) + Icon.DestroyWindow (); +} + +// *************************************************************************** + +void CIconWidget::create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label) +{ + FirstId = dialog_index; + LastId = FirstId; + + // Save the label + SavedLabel = label; + + // Create the type combo + parent->setStaticSize (currentPos); + Label.Create (label, WS_VISIBLE, currentPos, parent); + parent->initWidget (Label); + parent->getNextPosLabel (currentPos); + + // Create the mem combobox + parent->setEditSize (currentPos, parent->IconHeight, parent->IconHeight); + Icon.create (WS_CHILD|WS_VISIBLE|WS_TABSTOP, currentPos, parent, dialog_index); + parent->initWidget (Icon); + + parent->getNextPos (currentPos); + + dialog_index += 1; +} + +// *************************************************************************** + +void CIconWidget::updateData (bool update) +{ + Icon.UpdateData (update?TRUE:FALSE); +} + +// *************************************************************************** + +bool CIconWidget::haveFocus () +{ + CWnd *focus = CWnd::GetFocus (); + if (focus) + { + return (focus == &Icon); + } + return false; +} + +// *************************************************************************** + +void CIconWidget::setFocus () +{ + Icon.SetFocus (); +} + +// *************************************************************************** + +void CIconWidget::onOk () +{ + +} + +// *************************************************************************** + +void CIconWidget::getValue (std::string &result) +{ + result = ""; +} + +// *************************************************************************** + +void CIconWidget::getFromDocument (CForm &form) +{ + +} + + +// *************************************************************************** + +bool CIconWidget::isWnd (const CWnd *wnd) const +{ + return &Icon == wnd; +} + +// *************************************************************************** + +void CIconWidget::resizeScan (RECT ¤tPos, uint &widgetCount, uint adjust, bool resize) +{ + // Create the type combo + Dialog->setStaticSize (currentPos); + if (resize) + { + Label.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + } + Dialog->getNextPosLabel (currentPos); + + // Create the icon + Dialog->setEditSize (currentPos, Dialog->IconHeight, Dialog->IconHeight); + if (resize) + { + Icon.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + } + + Dialog->getNextPos (currentPos); +} + +// *************************************************************************** + +bool CIconWidget::getWindowRect (RECT &rect) const +{ + if (IsWindow (Icon)) + { + // Get parent rect + RECT parentRect; + IFormWidget::getWindowRect (parentRect); + + // Add my rect + RECT myRect; + Icon.GetWindowRect (&myRect); + UnionRect(&rect, &myRect, &parentRect); + return true; + } + else + return false; } \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_dll/form_dialog.h b/code/ryzom/tools/leveldesign/georges_dll/form_dialog.h index 29e10aa00..cb9d29bab 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/form_dialog.h +++ b/code/ryzom/tools/leveldesign/georges_dll/form_dialog.h @@ -1,518 +1,518 @@ -// 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 . - -#if !defined(FORM_TYPE_H_INCLUDED) -#define FORM_TYPE_H_INCLUDED - -#include "base_dialog.h" -#include "edit_list_ctrl.h" -#include "color_wnd.h" -#include "icon_wnd.h" - -#include "nel/georges/u_form.h" -#include "nel/georges/u_form_elm.h" -#include "nel/georges/u_form_dfn.h" - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// form_dialog.h : header file -// - -class CGeorgesEditView; - -namespace NLGEORGES -{ -class CFormElmStruct; -class CFormElmVirtualStruct; -class CFormElmAtom; -class CFormElmArray; -class CFormElm; -}; - -class CFormDialog; - -/** - * Base class of form dialog widgets. - */ -class IFormWidget -{ -public: - - // Type of sub parameter to edit - enum TTypeSrc - { - TypeForm = 0, - TypeFormParent, - TypeArray, - TypeType, - TypeVirtualDfn, - }; - - // Constructor - IFormWidget (CFormDialog *dialog, uint structId, const char *formName, TTypeSrc typeSrc, uint slot); - - // Destructor - virtual ~IFormWidget () {} - - // Update the text of the base label - void updateLabel (); - - // Does this id is in this widget ? - bool isDialog (uint id) const; - - // Get the structure ID of this widget - uint getStructId () const; - - // Get the type edited with this widget - TTypeSrc getSrcType () const; - - // Get the form name of the widget - const std::string &getFormName () const; - - // Get the slot number for this widget - uint getSlot () const; - - // This widget is expendable in height (big edit for exemple) - virtual bool extendableHeight () const; - - // Ok / cancel hit - virtual void onOk () {} - virtual void onCancel () {} - - // Update widget date - virtual void updateData (bool update = true) = 0; - - // Does the widget has the focus - virtual bool haveFocus () = 0; - - // Give the focus - virtual void setFocus () = 0; - - // Does the window is in the widget - virtual bool isWnd (const CWnd *wnd) const=0; - - // Resize callback - virtual void resizeScan (RECT ¤tPos, uint &widgetCount, uint adjust, bool resize) = 0; - - // Get from document, update rightview UI - virtual void getFromDocument (NLGEORGES::CForm &form) = 0; - - // Get the widget value - virtual void getValue (std::string &result); - - // Get the widget array value count - virtual uint getNumValue (); - - // Get the widget array value - virtual void getValue (std::string &result, uint value); - - // Get the rect - virtual bool getWindowRect (RECT &rect) const; - - // Open the selected text - virtual void onOpenSelected (); - - // Get the sub object node using current sub object - bool getNode (const NLGEORGES::CFormDfn **parentDfn, uint &indexDfn, const NLGEORGES::CFormDfn **nodeDfn, - const NLGEORGES::CType **nodeType, NLGEORGES::CFormElm **node, NLGEORGES::UFormDfn::TEntryType &type, - bool &array) const; - - // Get the sub object as CFormElm - NLGEORGES::CFormElm *getFormElmNode () const; - - // Get the sub object as CFormElmStruct - NLGEORGES::CFormElmStruct *getFormElmStructNode () const; - - // Get the sub object as CFormElmVirtualStruct - NLGEORGES::CFormElmVirtualStruct *getFormElmVirtualStructNode () const; - - // Get the sub object as CFormElmArray - NLGEORGES::CFormElmArray *getFormElmArrayNode () const; - - // Get the sub object as CFormElmAtom - NLGEORGES::CFormElmAtom *getFormElmAtomNode () const; - -protected: - - // Dialog Id - uint FirstId; - - // Dialog Id - uint LastId; - - // Struct id of the element - uint StructId; - - // Slot id - uint Slot; - - // String atom name - std::string FormName; - - // The label - CStatic Label; - - // String atom name - std::string SavedLabel; - - // Source edit type - TTypeSrc SrcType; - - // Parent dialog - CFormDialog *Dialog; -}; - -/** - * Widgets implementation for memory combo. - */ -class CFormMemCombo : public IFormWidget -{ -public: - - enum - { - CmdBrowse = 0, - }; - - CFormMemCombo (CFormDialog *dialog, uint structId, const char *atomName, TTypeSrc typeSrc, uint slot); - virtual ~CFormMemCombo (); - - // The combo - CMemoryComboBox Combo; - - // The Spin - CSpinButtonCtrl Spin; - - // The Spin - CButton Browse; - - // Use the sipnner - bool UseSpinner; - - // Is a file browser - bool FileBrowser; - - // Create the widget - void create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label, const char *reg, bool spinner, bool fileBrowser, const char *filenameExt); - - // From IFormWidget - void onOk (); - void updateData (bool update = true); - bool haveFocus (); - void setFocus (); - void getFromDocument (NLGEORGES::CForm &form); - void getValue (std::string &result); - bool getWindowRect (RECT &rect) const; - bool isWnd (const CWnd *wnd) const; - void resizeScan (RECT ¤tPos, uint &widgetCount, uint adjust, bool resize); -}; - -/** - * Widgets implementation for combo. - */ -class CFormCombo : public IFormWidget -{ -public: - - enum - { - CmdBrowse, - }; - - CFormCombo (CFormDialog *dialog, uint structId, const char *atomName, IFormWidget::TTypeSrc typeForm, uint slot); - virtual ~CFormCombo (); - - // The combo - CComboBox Combo; - - // Create the widget - void create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label); - - // From IFormWidget - void onOk (); - void updateData (bool update = true); - bool haveFocus (); - void setFocus (); - void getFromDocument (NLGEORGES::CForm &form); - void getValue (std::string &result); - bool getWindowRect (RECT &rect) const; - bool isWnd (const CWnd *wnd) const; - void resizeScan (RECT ¤tPos, uint &widgetCount, uint adjust, bool resize); -}; - -/** - * Widgets implementation for combo. - */ -class CFormBigEdit : public IFormWidget -{ -public: - - enum - { - CmdBrowse, - }; - - CFormBigEdit (CFormDialog *dialog, uint structId, const char *atomName, IFormWidget::TTypeSrc typeForm, uint slot); - virtual ~CFormBigEdit (); - - // The combo - CEdit Edit; - - // Create the widget - void create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label); - - // From IFormWidget - void onOk (); - void updateData (bool update = true); - bool haveFocus (); - void setFocus (); - void getFromDocument (NLGEORGES::CForm &form); - void getValue (std::string &result); - bool getWindowRect (RECT &rect) const; - bool isWnd (const CWnd *wnd) const; - void resizeScan (RECT ¤tPos, uint &widgetCount, uint adjust, bool resize); - bool extendableHeight () const; -}; - -/** - * Widgets implementation for color dialog. - */ -class CColorEdit : public IFormWidget -{ -public: - - enum - { - CmdBrowse, - }; - - CColorEdit (CFormDialog *dialog, uint structId, const char *atomName, IFormWidget::TTypeSrc typeForm, uint slot); - virtual ~CColorEdit (); - - // The combo - CColorWnd Color; - CButton Reset; - CEdit Edit; - bool Empty; - - // Create the widget - void create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label); - - // From IFormWidget - void onOk (); - void updateData (bool update = true); - bool haveFocus (); - void setFocus (); - void getFromDocument (NLGEORGES::CForm &form); - void getValue (std::string &result); - bool getWindowRect (RECT &rect) const; - bool isWnd (const CWnd *wnd) const; - void resizeScan (RECT ¤tPos, uint &widgetCount, uint adjust, bool resize); -}; - -/** - * Widgets implementation for list. - */ -class CListWidget : public IFormWidget -{ -public: - - CListWidget (CFormDialog *dialog, uint structId, const char *atomName, IFormWidget::TTypeSrc typeForm, uint slot); - virtual ~CListWidget (); - -private: - - // My list ctrl - class CMyEditListCtrl : public CEditListCtrl - { - friend CListWidget; - CEditListCtrl::TItemEdit getItemEditMode (uint item, uint subItem); - void getMemComboBoxProp (uint item, uint subItem, std::string ®Adr, bool &browse); - void getNewItemText (uint item, uint subItem, std::string &ret); - void getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::string &filter); - CListWidget *Ctrl; - }; - friend class CListWidget::CMyEditListCtrl; - - // The list - std::string RegAdr; - uint Divid; - CMyEditListCtrl ListCtrl; - CButton Button; - -public: - // Create the widget - void create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label, const char *reg, uint Divid=1); - - // Add column - void addColumn (const char *name); - - // From IFormWidget - void onOk (); - void updateData (bool update = true); - bool haveFocus (); - void setFocus (); - void getFromDocument (NLGEORGES::CForm &form); - void getValue (std::string &result, uint value); - bool getWindowRect (RECT &rect) const; - uint getNumValue (); - bool isWnd (const CWnd *wnd) const; - void resizeScan (RECT ¤tPos, uint &widgetCount, uint adjust, bool resize); - bool extendableHeight () const; - void onOpenSelected (); -}; - -/** - * Widgets implementation for color dialog. - */ -class CIconWidget : public IFormWidget -{ -public: - - CIconWidget (CFormDialog *dialog, uint structId, const char *atomName, IFormWidget::TTypeSrc typeForm, uint slot); - virtual ~CIconWidget (); - - // The combo - CIconWnd Icon; - - // Create the widget - void create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label); - - // From IFormWidget - void onOk (); - void updateData (bool update = true); - bool haveFocus (); - void setFocus (); - void getFromDocument (NLGEORGES::CForm &form); - void getValue (std::string &result); - bool getWindowRect (RECT &rect) const; - bool isWnd (const CWnd *wnd) const; - void resizeScan (RECT ¤tPos, uint &widgetCount, uint adjust, bool resize); -}; - - -/** - * The dialog object for FORM - */ -class CFormDialog : public CBaseDialog -{ -// Construction -public: - CFormDialog (); // standard constructor - ~CFormDialog (); // standard constructor - - enum - { - TypeCombo= 100, - }; - - enum - { - LtParents, - LtStruct, - }; - - enum - { - ParentHeight = 80, - DfnHeight = 230, - }; - - // Widget index count - uint WidgetIndexCount; - uint WidgetFocused; - - // Array of widget - std::vector Widgets; - - // From CDialog - virtual void OnOK (); - virtual void OnCancel (); - - // From CBaseDialog - void onOpenSelected (); - void onFirstFocus (); - void onLastFocus (); - - // Get from document, update rightview UI - void getFromDocument (); - - // Get the dfn name of the form - void getDfnName (std::string &result) const; - - // On sub focus changed - void onGetSubFocus (uint id); - -private: - // Sub update functions - void getVirtualDfnFromDocument (const NLGEORGES::CFormDfn *_dfn, const char *structName, uint slot); - void getDfnFromDocument (const NLGEORGES::CFormDfn &_dfn, const char *structName, uint slot); - void getArrayFromDocument (const char *arrayName, uint structId, uint slot); - void getTypeFromDocument (const NLGEORGES::CType &_type, const char *name, const char *typeFilename, const char *structName, uint slot); -public: - - // Set to document, update document with rightview UI - void setToDocument (uint widget); - - void resizeWidgets (); - - void updateLabels (); - - void updateValues (); - - // Clear the dialog - void clear (); - -private: - // Get the widget id in widgets array with a dialog Id. - int getWidget (uint dialogId) const; - - // Add a widget - CWnd* addTypeWidget (const NLGEORGES::CType &type, uint elmIndex, const char *title, const char *atomName, - const char *typeFilename, RECT ¤tPos, NLGEORGES::CForm &form, IFormWidget::TTypeSrc typeWidget, const char *filenameExt, uint slot); - - - CWnd* GetNextDlgTabItem( CWnd* pWndCtl, BOOL bPrevious = FALSE ) const; - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CFormDialog) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); - virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam); - virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CFormDialog) - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg BOOL OnInitDialog(); - afx_msg void OnLButtonDown(UINT nFlags, CPoint point); - afx_msg void OnSetFocus(CWnd* pNewWnd); - afx_msg void OnKillFocus(CWnd* pNewWnd); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(FORM_TYPE_H_INCLUDED) +// 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 . + +#if !defined(FORM_TYPE_H_INCLUDED) +#define FORM_TYPE_H_INCLUDED + +#include "base_dialog.h" +#include "edit_list_ctrl.h" +#include "color_wnd.h" +#include "icon_wnd.h" + +#include "nel/georges/u_form.h" +#include "nel/georges/u_form_elm.h" +#include "nel/georges/u_form_dfn.h" + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// form_dialog.h : header file +// + +class CGeorgesEditView; + +namespace NLGEORGES +{ +class CFormElmStruct; +class CFormElmVirtualStruct; +class CFormElmAtom; +class CFormElmArray; +class CFormElm; +}; + +class CFormDialog; + +/** + * Base class of form dialog widgets. + */ +class IFormWidget +{ +public: + + // Type of sub parameter to edit + enum TTypeSrc + { + TypeForm = 0, + TypeFormParent, + TypeArray, + TypeType, + TypeVirtualDfn, + }; + + // Constructor + IFormWidget (CFormDialog *dialog, uint structId, const char *formName, TTypeSrc typeSrc, uint slot); + + // Destructor + virtual ~IFormWidget () {} + + // Update the text of the base label + void updateLabel (); + + // Does this id is in this widget ? + bool isDialog (uint id) const; + + // Get the structure ID of this widget + uint getStructId () const; + + // Get the type edited with this widget + TTypeSrc getSrcType () const; + + // Get the form name of the widget + const std::string &getFormName () const; + + // Get the slot number for this widget + uint getSlot () const; + + // This widget is expendable in height (big edit for exemple) + virtual bool extendableHeight () const; + + // Ok / cancel hit + virtual void onOk () {} + virtual void onCancel () {} + + // Update widget date + virtual void updateData (bool update = true) = 0; + + // Does the widget has the focus + virtual bool haveFocus () = 0; + + // Give the focus + virtual void setFocus () = 0; + + // Does the window is in the widget + virtual bool isWnd (const CWnd *wnd) const=0; + + // Resize callback + virtual void resizeScan (RECT ¤tPos, uint &widgetCount, uint adjust, bool resize) = 0; + + // Get from document, update rightview UI + virtual void getFromDocument (NLGEORGES::CForm &form) = 0; + + // Get the widget value + virtual void getValue (std::string &result); + + // Get the widget array value count + virtual uint getNumValue (); + + // Get the widget array value + virtual void getValue (std::string &result, uint value); + + // Get the rect + virtual bool getWindowRect (RECT &rect) const; + + // Open the selected text + virtual void onOpenSelected (); + + // Get the sub object node using current sub object + bool getNode (const NLGEORGES::CFormDfn **parentDfn, uint &indexDfn, const NLGEORGES::CFormDfn **nodeDfn, + const NLGEORGES::CType **nodeType, NLGEORGES::CFormElm **node, NLGEORGES::UFormDfn::TEntryType &type, + bool &array) const; + + // Get the sub object as CFormElm + NLGEORGES::CFormElm *getFormElmNode () const; + + // Get the sub object as CFormElmStruct + NLGEORGES::CFormElmStruct *getFormElmStructNode () const; + + // Get the sub object as CFormElmVirtualStruct + NLGEORGES::CFormElmVirtualStruct *getFormElmVirtualStructNode () const; + + // Get the sub object as CFormElmArray + NLGEORGES::CFormElmArray *getFormElmArrayNode () const; + + // Get the sub object as CFormElmAtom + NLGEORGES::CFormElmAtom *getFormElmAtomNode () const; + +protected: + + // Dialog Id + uint FirstId; + + // Dialog Id + uint LastId; + + // Struct id of the element + uint StructId; + + // Slot id + uint Slot; + + // String atom name + std::string FormName; + + // The label + CStatic Label; + + // String atom name + std::string SavedLabel; + + // Source edit type + TTypeSrc SrcType; + + // Parent dialog + CFormDialog *Dialog; +}; + +/** + * Widgets implementation for memory combo. + */ +class CFormMemCombo : public IFormWidget +{ +public: + + enum + { + CmdBrowse = 0, + }; + + CFormMemCombo (CFormDialog *dialog, uint structId, const char *atomName, TTypeSrc typeSrc, uint slot); + virtual ~CFormMemCombo (); + + // The combo + CMemoryComboBox Combo; + + // The Spin + CSpinButtonCtrl Spin; + + // The Spin + CButton Browse; + + // Use the sipnner + bool UseSpinner; + + // Is a file browser + bool FileBrowser; + + // Create the widget + void create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label, const char *reg, bool spinner, bool fileBrowser, const char *filenameExt); + + // From IFormWidget + void onOk (); + void updateData (bool update = true); + bool haveFocus (); + void setFocus (); + void getFromDocument (NLGEORGES::CForm &form); + void getValue (std::string &result); + bool getWindowRect (RECT &rect) const; + bool isWnd (const CWnd *wnd) const; + void resizeScan (RECT ¤tPos, uint &widgetCount, uint adjust, bool resize); +}; + +/** + * Widgets implementation for combo. + */ +class CFormCombo : public IFormWidget +{ +public: + + enum + { + CmdBrowse, + }; + + CFormCombo (CFormDialog *dialog, uint structId, const char *atomName, IFormWidget::TTypeSrc typeForm, uint slot); + virtual ~CFormCombo (); + + // The combo + CComboBox Combo; + + // Create the widget + void create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label); + + // From IFormWidget + void onOk (); + void updateData (bool update = true); + bool haveFocus (); + void setFocus (); + void getFromDocument (NLGEORGES::CForm &form); + void getValue (std::string &result); + bool getWindowRect (RECT &rect) const; + bool isWnd (const CWnd *wnd) const; + void resizeScan (RECT ¤tPos, uint &widgetCount, uint adjust, bool resize); +}; + +/** + * Widgets implementation for combo. + */ +class CFormBigEdit : public IFormWidget +{ +public: + + enum + { + CmdBrowse, + }; + + CFormBigEdit (CFormDialog *dialog, uint structId, const char *atomName, IFormWidget::TTypeSrc typeForm, uint slot); + virtual ~CFormBigEdit (); + + // The combo + CEdit Edit; + + // Create the widget + void create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label); + + // From IFormWidget + void onOk (); + void updateData (bool update = true); + bool haveFocus (); + void setFocus (); + void getFromDocument (NLGEORGES::CForm &form); + void getValue (std::string &result); + bool getWindowRect (RECT &rect) const; + bool isWnd (const CWnd *wnd) const; + void resizeScan (RECT ¤tPos, uint &widgetCount, uint adjust, bool resize); + bool extendableHeight () const; +}; + +/** + * Widgets implementation for color dialog. + */ +class CColorEdit : public IFormWidget +{ +public: + + enum + { + CmdBrowse, + }; + + CColorEdit (CFormDialog *dialog, uint structId, const char *atomName, IFormWidget::TTypeSrc typeForm, uint slot); + virtual ~CColorEdit (); + + // The combo + CColorWnd Color; + CButton Reset; + CEdit Edit; + bool Empty; + + // Create the widget + void create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label); + + // From IFormWidget + void onOk (); + void updateData (bool update = true); + bool haveFocus (); + void setFocus (); + void getFromDocument (NLGEORGES::CForm &form); + void getValue (std::string &result); + bool getWindowRect (RECT &rect) const; + bool isWnd (const CWnd *wnd) const; + void resizeScan (RECT ¤tPos, uint &widgetCount, uint adjust, bool resize); +}; + +/** + * Widgets implementation for list. + */ +class CListWidget : public IFormWidget +{ +public: + + CListWidget (CFormDialog *dialog, uint structId, const char *atomName, IFormWidget::TTypeSrc typeForm, uint slot); + virtual ~CListWidget (); + +private: + + // My list ctrl + class CMyEditListCtrl : public CEditListCtrl + { + friend CListWidget; + CEditListCtrl::TItemEdit getItemEditMode (uint item, uint subItem); + void getMemComboBoxProp (uint item, uint subItem, std::string ®Adr, bool &browse); + void getNewItemText (uint item, uint subItem, std::string &ret); + void getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::string &filter); + CListWidget *Ctrl; + }; + friend class CListWidget::CMyEditListCtrl; + + // The list + std::string RegAdr; + uint Divid; + CMyEditListCtrl ListCtrl; + CButton Button; + +public: + // Create the widget + void create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label, const char *reg, uint Divid=1); + + // Add column + void addColumn (const char *name); + + // From IFormWidget + void onOk (); + void updateData (bool update = true); + bool haveFocus (); + void setFocus (); + void getFromDocument (NLGEORGES::CForm &form); + void getValue (std::string &result, uint value); + bool getWindowRect (RECT &rect) const; + uint getNumValue (); + bool isWnd (const CWnd *wnd) const; + void resizeScan (RECT ¤tPos, uint &widgetCount, uint adjust, bool resize); + bool extendableHeight () const; + void onOpenSelected (); +}; + +/** + * Widgets implementation for color dialog. + */ +class CIconWidget : public IFormWidget +{ +public: + + CIconWidget (CFormDialog *dialog, uint structId, const char *atomName, IFormWidget::TTypeSrc typeForm, uint slot); + virtual ~CIconWidget (); + + // The combo + CIconWnd Icon; + + // Create the widget + void create (DWORD wStyle, RECT ¤tPos, CFormDialog *parent, uint &dialog_index, const char *label); + + // From IFormWidget + void onOk (); + void updateData (bool update = true); + bool haveFocus (); + void setFocus (); + void getFromDocument (NLGEORGES::CForm &form); + void getValue (std::string &result); + bool getWindowRect (RECT &rect) const; + bool isWnd (const CWnd *wnd) const; + void resizeScan (RECT ¤tPos, uint &widgetCount, uint adjust, bool resize); +}; + + +/** + * The dialog object for FORM + */ +class CFormDialog : public CBaseDialog +{ +// Construction +public: + CFormDialog (); // standard constructor + ~CFormDialog (); // standard constructor + + enum + { + TypeCombo= 100, + }; + + enum + { + LtParents, + LtStruct, + }; + + enum + { + ParentHeight = 80, + DfnHeight = 230, + }; + + // Widget index count + uint WidgetIndexCount; + uint WidgetFocused; + + // Array of widget + std::vector Widgets; + + // From CDialog + virtual void OnOK (); + virtual void OnCancel (); + + // From CBaseDialog + void onOpenSelected (); + void onFirstFocus (); + void onLastFocus (); + + // Get from document, update rightview UI + void getFromDocument (); + + // Get the dfn name of the form + void getDfnName (std::string &result) const; + + // On sub focus changed + void onGetSubFocus (uint id); + +private: + // Sub update functions + void getVirtualDfnFromDocument (const NLGEORGES::CFormDfn *_dfn, const char *structName, uint slot); + void getDfnFromDocument (const NLGEORGES::CFormDfn &_dfn, const char *structName, uint slot); + void getArrayFromDocument (const char *arrayName, uint structId, uint slot); + void getTypeFromDocument (const NLGEORGES::CType &_type, const char *name, const char *typeFilename, const char *structName, uint slot); +public: + + // Set to document, update document with rightview UI + void setToDocument (uint widget); + + void resizeWidgets (); + + void updateLabels (); + + void updateValues (); + + // Clear the dialog + void clear (); + +private: + // Get the widget id in widgets array with a dialog Id. + int getWidget (uint dialogId) const; + + // Add a widget + CWnd* addTypeWidget (const NLGEORGES::CType &type, uint elmIndex, const char *title, const char *atomName, + const char *typeFilename, RECT ¤tPos, NLGEORGES::CForm &form, IFormWidget::TTypeSrc typeWidget, const char *filenameExt, uint slot); + + + CWnd* GetNextDlgTabItem( CWnd* pWndCtl, BOOL bPrevious = FALSE ) const; + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CFormDialog) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); + virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam); + virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CFormDialog) + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg BOOL OnInitDialog(); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg void OnSetFocus(CWnd* pNewWnd); + afx_msg void OnKillFocus(CWnd* pNewWnd); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(FORM_TYPE_H_INCLUDED) diff --git a/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp b/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp index 7b5fb4163..dd10a9bb6 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/georges_edit.cpp @@ -1,1631 +1,1631 @@ -// 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 "stdafx.h" - -#include "nel/misc/path.h" -#include "nel/misc/config_file.h" -#include "nel/misc/o_xml.h" -#include "nel/misc/i_xml.h" -#include "nel/misc/dynloadlib.h" - -#include "georges_edit.h" -#include "reg_shell_ext.h" - -#include "main_frm.h" -#include "child_frm.h" -#include "georges_edit_doc.h" -#include "left_view.h" - -#include "splash_screen.h" - -using namespace NLMISC; -using namespace NLGEORGES; -using namespace std; - - -const char* TypeFilter = "Type Files (*.typ)|*.typ|All Files (*.*)|*.*||"; -const char* DfnFilter = "Form Definition Files (*.dfn)|*.dfn|All Files (*.*)|*.*||"; -CSplashScreen* splashScreen=new CSplashScreen; -///////////////////////////////////////////////////////////////////////////// -// CGeorgesEditApp - -BEGIN_MESSAGE_MAP(CGeorgesEditApp, CWinApp) - //{{AFX_MSG_MAP(CGeorgesEditApp) - ON_COMMAND(ID_APP_ABOUT, OnAppAbout) - ON_COMMAND(ID_VIEW_REFRESH, OnViewRefresh) - ON_COMMAND(ID_FILE_SAVE_ALL, OnFileSaveAll) - ON_COMMAND(ID_FILE_CLOSE_ALL, OnFileCloseAll) - ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_ALL, OnUpdateFileSaveAll) - //}}AFX_MSG_MAP - // Standard file based document commands - ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) - ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CGeorgesEditApp construction - -CGeorgesEditApp::CGeorgesEditApp() : MemStream (false, false, 1024*1024) -{ - Superuser = true; - DefaultType = "default.typ"; - DefaultDfn = "default.dfn"; - - m_pMainWnd = NULL; - RememberListSize = 10; - MaxUndo = 20; - ResizeMain = true; - ExeStandalone = false; - StartExpanded = true; - Georges4CVS = true; - - FormClipBoardFormatStruct = RegisterClipboardFormat ("GeorgesFormStruct"); - FormClipBoardFormatVirtualStruct = RegisterClipboardFormat ("GeorgesFormVirtualStruct"); - FormClipBoardFormatArray = RegisterClipboardFormat ("GeorgesFormArray"); - FormClipBoardFormatType = RegisterClipboardFormat ("GeorgesFormType"); - nlassert (FormClipBoardFormatStruct); - nlassert (FormClipBoardFormatVirtualStruct); - nlassert (FormClipBoardFormatArray); - nlassert (FormClipBoardFormatType); - - _TemplateForm = NULL; - _TemplateType = NULL; - _TemplateDfn = NULL; -} - -CGeorgesEditApp::~CGeorgesEditApp () -{ -} - -///////////////////////////////////////////////////////////////////////////// -// The one and only CGeorgesEditApp object - -CGeorgesEditApp theApp; - -///////////////////////////////////////////////////////////////////////////// -// CGeorgesEditApp initialization - -BOOL CGeorgesEditApp::InitInstance() -{ - return TRUE; -} - -CMyMultiDocTemplate::CMyMultiDocTemplate (const char *ext, UINT nIDResource, CRuntimeClass* pDocClass, CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass) : - CMultiDocTemplate ( nIDResource, pDocClass, pFrameClass, pViewClass ) -{ - _Ext = ext; - _ExtMaj = _Ext; - _Ext = strlwr (_Ext); - _ExtMaj[0] = toupper (_ExtMaj[0]); -} - -void CMyMultiDocTemplate::getDfnName (string &dfnName) -{ - dfnName = _Ext + ".dfn"; -} - -BOOL CMyMultiDocTemplate::GetDocString(CString& rString, enum DocStringIndex index) const -{ - switch (index) - { - case fileNewName: - case windowTitle: - case docName: - rString = (_ExtMaj + " Form").c_str (); - return TRUE; - case filterName: - rString = (_ExtMaj + " Form Filename (*." + _Ext+ ")").c_str (); - return TRUE; - case filterExt: - rString = ("." + _Ext).c_str (); - return TRUE; - default: - return CMultiDocTemplate::GetDocString(rString, index); - } -} - -BOOL CGeorgesEditApp::initInstance (int nCmdShow, bool exeStandalone, int x, int y, int cx, int cy) -{ - // Some things have just to be done once per launch of the application that is - // completely different from an opening/closing of the main frame - static bool isInitialized = false; - ExeStandalone = exeStandalone; - - - splashScreen->Create(IDD_SPLASHSCREEN, theApp.GetMainWnd()); - splashScreen->ShowWindow(TRUE); - splashScreen->addLine(string("Georges Initialization")); - // Filter addSearchPath - splashScreen->addLine(string("Filter addSearchPath")); - NLMISC::createDebug(); - InfoLog->addNegativeFilter("adding the path"); - WarningLog->addNegativeFilter("Exception will be launched"); - - if (!isInitialized && exeStandalone) - { - m_nCmdShow = nCmdShow; - ExePath = GetCommandLine (); - if (ExePath.size()>0) - { - if (ExePath[0] == '\"') - { - uint end=ExePath.find ('\"', 1); - if (end != string::npos) - { - ExePath = ExePath.substr (1, end-1); - } - else - { - nlassert (0); // no! - } - } - else - { - uint end=ExePath.find (' ', 1); - ExePath = ExePath.substr (0, end); - } - } - - // Init CPath - loadCfg (); - initCfg (); - } - - if (!isInitialized) - { - // Fill the image list - splashScreen->addLine(string("Fill the image list")); - ImageList.create (16, 16); - ImageList.addResourceIcon (m_hInstance, IDR_ARRAY); - ImageList.addResourceIcon (m_hInstance, IDR_HEADER); - ImageList.addResourceIcon (m_hInstance, IDR_HOLD); - ImageList.addResourceIcon (m_hInstance, IDR_ROOT); - ImageList.addResourceIcon (m_hInstance, IDR_STRUCT); - ImageList.addResourceIcon (m_hInstance, IDR_VSTRUCT); - ImageList.addResourceIcon (m_hInstance, IDR_TYPEDFN); - ImageList.addResourceIcon (m_hInstance, IDR_TYPEFORM); - ImageList.addResourceIcon (m_hInstance, IDR_TYPETYPE); - - // Add icon - splashScreen->addLine(string("Add icon")); - std::vector result; - string iconPathName = RootSearchPath+TypeDfnSubDirectory; - if (!iconPathName.empty ()) - { - CPath::getPathContent (iconPathName, true, false, true, result); - uint i; - for (i=0; iaddLine(string("Standard initialization")); - if (!isInitialized) - { - -// const char *open = "Open(\"%1\")"; -// const char *copy = "Georges Copy(\"%1\")"; -// const char *derive = "Derive(\"%1\")"; -// const char *createForm = "CreateForm(\"%1\")"; -// const char *notepad = "notepad.exe \"%1\""; - - // *** Registry - - // MFC settings - splashScreen->addLine(string("MFC settings")); - SetRegistryKey(_T("Nevrax")); - LoadStdProfileSettings(16); // Load standard INI file options (including MRU) -// EnableShellOpen(); - - // Application path - string appPath = "\""; - appPath += ExePath; - appPath += "\""; - - bool okRegister = true; - if (ExeStandalone) - { - splashScreen->addLine(string("Associate Georges file extensions")); - okRegister &= RegisterApp ("Georges.Type", "Georges Type Files", appPath.c_str (), 3); - okRegister &= RegisterApp ("Georges.Dfn", "Georges Dfn Files", appPath.c_str (), 3); - okRegister &= RegisterApp ("Georges.Form", "Georges Form Files", appPath.c_str (), 3); - okRegister &= RegisterShellFileExt (".typ", "Georges.Type"); - okRegister &= RegisterShellFileExt (".dfn", "Georges.Dfn"); - - // Register Type and DFN for superuser -/* if (Superuser) - { - // Register the application - splashScreen->addLine(string("Register the application")); - okRegister &= RegisterApp ("Georges.Type", "Georges Type Files", appPath.c_str (), 1); - okRegister &= RegisterApp ("Georges.Dfn", "Georges Dfn Files", appPath.c_str (), 2); - okRegister &= RegisterApp ("Georges.Form", "Georges Form Files", appPath.c_str (), 3); - - // Register the command - splashScreen->addLine(string("Register the command")); - okRegister &= RegisterAppCommand ("Georges.Type", "Open", (appPath+" %1").c_str ()); - okRegister &= RegisterAppCommand ("Georges.Dfn", "Open", (appPath+" %1").c_str ()); - okRegister &= RegisterAppCommand ("Georges.Dfn", "Create Form", (appPath+" /dde").c_str ()); - - okRegister &= RegisterAppCommand ("Georges.Type", "Open With Notepad", notepad); - okRegister &= RegisterAppCommand ("Georges.Dfn", "Open With Notepad", notepad); - - // Register the DDE command (avoid strange Visual compile error..) - splashScreen->addLine(string("Register the DDE command")); - okRegister &= RegisterDDECommand ("Georges.Type", "Open", open, m_pszExeName); - okRegister &= RegisterDDECommand ("Georges.Dfn", "Open", open, m_pszExeName); - okRegister &= RegisterDDECommand ("Georges.Dfn", "Create Form", createForm, m_pszExeName); - - // Register the file extension - splashScreen->addLine(string("Register the file extension")); - okRegister &= RegisterShellFileExt (".typ", "Georges.Type"); - okRegister &= RegisterShellFileExt (".dfn", "Georges.Dfn"); - } - else - { - // Register the command - splashScreen->addLine(string("Register the command")); - UnregisterAppCommand ("Georges.Dfn", "Open"); - okRegister &= RegisterAppCommand ("Georges.Dfn", "Create Form", (appPath+" /dde").c_str ()); - UnregisterAppCommand ("Georges.Dfn", "Open With Notepad"); - - // Register the DDE command (avoid strange Visual compile error..) - splashScreen->addLine(string("Register the DDE command")); - okRegister &= RegisterDDECommand ("Georges.Dfn", "Create Form", createForm, m_pszExeName); - - // Register the file extension - splashScreen->addLine(string("Register the file extension")); - okRegister &= RegisterShellFileExt (".dfn", "Georges.Dfn"); - - // Unregister type and dfn - splashScreen->addLine(string("Unregister type and dfn")); - UnregisterApp ("Georges.Type"); - } - - // Register non super user commands - splashScreen->addLine(string("Register non super user commands")); - okRegister &= RegisterAppCommand ("Georges.Form", "Open", (appPath+" %1").c_str ()); - okRegister &= RegisterAppCommand ("Georges.Form", "Georges Copy", (appPath+" /dde").c_str ()); - okRegister &= RegisterAppCommand ("Georges.Form", "Derive", (appPath+" /dde").c_str ()); - okRegister &= RegisterAppCommand ("Georges.Form", "Open With Notepad", notepad); - - // Register dde commands - splashScreen->addLine(string("Register dde commands")); - okRegister &= RegisterDDECommand ("Georges.Form", "Open", open, m_pszExeName); - okRegister &= RegisterDDECommand ("Georges.Form", "Georges Copy", copy, m_pszExeName); - okRegister &= RegisterDDECommand ("Georges.Form", "Derive", derive, m_pszExeName); -*/ - } - - // Ok register ? - if (!okRegister) - nlwarning ("Register Georges: problem during Georges registration. Do you have administrator privileges ?"); - - // Register the application's document templates. Document templates - // serve as the connection between documents, frame windows and views. - - // Are we a superuser ? - if (Superuser) - { - // Form - _TemplateForm = new CMultiDocTemplate( - IDR_TYPEFORM, - RUNTIME_CLASS(CGeorgesEditDocForm), - RUNTIME_CLASS(CChildFrame), // custom MDI child frame - RUNTIME_CLASS(CLeftView)); - AddDocTemplate(_TemplateForm); - - // Type - _TemplateType = new CMultiDocTemplate( - IDR_TYPETYPE, - RUNTIME_CLASS(CGeorgesEditDocType), - RUNTIME_CLASS(CChildFrame), // custom MDI child frame - RUNTIME_CLASS(CLeftView)); - AddDocTemplate(_TemplateType); - - // Dfn - _TemplateDfn = new CMultiDocTemplate( - IDR_TYPEDFN, - RUNTIME_CLASS(CGeorgesEditDocDfn), - RUNTIME_CLASS(CChildFrame), // custom MDI child frame - RUNTIME_CLASS(CLeftView)); - AddDocTemplate(_TemplateDfn); - } - else - { - // For each form - uint i; - for (i=0; iaddLine(string("create main MDI Frame window")); - CMainFrame* pMainFrame = new CMainFrame; - nlassert (pMainFrame); - ((CMainFrame*)pMainFrame)->createX = x; - ((CMainFrame*)pMainFrame)->createY = y; - ((CMainFrame*)pMainFrame)->createCX = cx; - ((CMainFrame*)pMainFrame)->createCY = cy; - if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) - return FALSE; - m_pMainWnd = pMainFrame; - - // Enable drag/drop open - m_pMainWnd->DragAcceptFiles(); - - if (!isInitialized) - { - // Enable DDE Execute open -// EnableShellOpen(); -// RegisterShellFileTypes(TRUE); - isInitialized = true; - } - - // Parse command line for standard shell commands, DDE, file open - splashScreen->addLine(string("Parse command line")); - CCommandLineInfo cmdInfo; - ParseCommandLine(cmdInfo); - - // Dispatch commands specified on the command line - splashScreen->addLine(string("Dispatch commands specified")); - if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew) - cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing; - - /*if (!ProcessShellCommand(cmdInfo)) - return FALSE;*/ - - // Load and init plugins - splashScreen->addLine(string("Load and init plugins")); - loadPlugins (); - - // Init windows - ResizeMain = (x==-1); - loadState (); - - // The main window has been initialized, so show and update it. - pMainFrame->ShowWindow(SW_SHOW /*m_nCmdShow*/); - pMainFrame->UpdateWindow(); - - splashScreen->ShowWindow(false); - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CAboutDlg dialog used for App About - -class CAboutDlg : public CDialog -{ -public: - CAboutDlg(); - -// Dialog Data - //{{AFX_DATA(CAboutDlg) - enum { IDD = IDD_ABOUTBOX }; - //}}AFX_DATA - - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CAboutDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - //{{AFX_MSG(CAboutDlg) - // No message handlers - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) -{ - //{{AFX_DATA_INIT(CAboutDlg) - //}}AFX_DATA_INIT -} - -void CAboutDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CAboutDlg) - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) - //{{AFX_MSG_MAP(CAboutDlg) - // No message handlers - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// App command to run the dialog -void CGeorgesEditApp::OnAppAbout() -{ - CAboutDlg aboutDlg; - aboutDlg.DoModal(); -} - -void CGeorgesEditApp::outputError (const char* message) -{ - if (m_pMainWnd) - m_pMainWnd->MessageBox (message, "Georges Edit", MB_OK|MB_ICONEXCLAMATION); - else - MessageBox (NULL, message, "Georges Edit", MB_OK|MB_ICONEXCLAMATION); -} - -void CGeorgesEditApp::getConfigFilePath (std::string &output) -{ - // Get the config file path - char sDrive[MAX_PATH]; - char sDir[MAX_PATH]; - char sPath[MAX_PATH]; - _splitpath (theApp.ExePath.c_str (), sDrive, sDir, NULL, NULL); - _makepath (sPath, sDrive, sDir, "georges", ".cfg"); - output = sPath; -} - -bool CGeorgesEditApp::loadCfg () -{ - // Open the config file - std::string configPath; - getConfigFilePath (configPath); - CConfigFile &cf = ConfigFile;; - - - // Root search path - try - { - cf.load (configPath); - - CConfigFile::CVar *rootDirectory = cf.getVarPtr ("RootSearchDirectory"); - if (rootDirectory) - { - RootSearchPath = rootDirectory->asString (); - if (RootSearchPath.size ()) - { - char c = RootSearchPath[RootSearchPath.size ()-1]; - if ((c != '\\') && (c != '/')) - RootSearchPath += "\\"; - } - } - - // Type and Dfn sub directory - CConfigFile::CVar *typeDfnSubDirectory = cf.getVarPtr ("TypDfnSubFolder"); - if (typeDfnSubDirectory) - { - // Last char is good ? - string copy = typeDfnSubDirectory->asString (); - const char *ptr = copy.c_str (); - while ((*ptr == '/') || (*ptr == '\\')) - ptr++; - TypeDfnSubDirectory = ptr; - if (TypeDfnSubDirectory.size ()) - { - char c = TypeDfnSubDirectory[TypeDfnSubDirectory.size ()-1]; - if ((c != '\\') && (c != '/')) - TypeDfnSubDirectory += "\\"; - } - } - - // RememberListSize - CConfigFile::CVar *remember = cf.getVarPtr ("RememberListSize"); - if (remember) - RememberListSize = remember->asInt (); - - // StartExpanded - CConfigFile::CVar *start_expanded = cf.getVarPtr ("StartExpanded"); - if (start_expanded) - StartExpanded = start_expanded->asInt () != 0; - - // Georges4CVS - CConfigFile::CVar *georges_for_cvs = cf.getVarPtr ("GeorgesForCvs"); - if (georges_for_cvs) - Georges4CVS = georges_for_cvs->asInt () != 0; - - // MaxUndo - CConfigFile::CVar *max_undo = cf.getVarPtr ("MaxUndo"); - if (max_undo) - MaxUndo = max_undo->asInt (); - - // DefaultType - CConfigFile::CVar *defaultType = cf.getVarPtr ("DefaultType"); - if (defaultType) - DefaultType = defaultType->asString (); - - // DefaultDfn - CConfigFile::CVar *defaultDfn = cf.getVarPtr ("DefaultDfn"); - if (defaultDfn) - DefaultDfn = defaultDfn->asString (); - - // Plugins - CConfigFile::CVar *plugins = cf.getVarPtr ("Plugins"); - if (plugins) - { - PluginsNames.reserve (plugins->size()); - uint i; - for (i=0; i<(uint)plugins->size(); i++) - PluginsNames.push_back (plugins->asString (i)); - } - - // User types - CConfigFile::CVar *user_type = cf.getVarPtr ("UserType"); - if (user_type) - { - UserTypes.reserve (user_type->size()); - uint i; - for (i=0; i<(uint)user_type->size(); i++) - UserTypes.push_back (user_type->asString (i)); - } - - // Super user - CConfigFile::CVar *superuser = cf.getVarPtr ("SuperUser"); - if (superuser) - Superuser = superuser->asInt () != 0; - } - catch (Exception &) - { - char message[512]; - smprintf (message, 512, "Can't load georges.cfg config file."); - outputError (message); - } - - return true; -} - -bool CGeorgesEditApp::saveCfg () -{ - // Config path - std::string configPath; - getConfigFilePath (configPath); - CConfigFile &cf = ConfigFile; - - // Root search path - try - { - cf.load (configPath); - - CConfigFile::CVar *rootDirectory = cf.getVarPtr ("RootSearchDirectory"); - if (rootDirectory) - rootDirectory->setAsString (RootSearchPath.c_str ()); - - // Type and Dfn sub directory - CConfigFile::CVar *typeDfnSubDirectory = cf.getVarPtr ("TypDfnSubFolder"); - if (typeDfnSubDirectory) - typeDfnSubDirectory->setAsString (TypeDfnSubDirectory.c_str ()); - - // RememberListSize - CConfigFile::CVar *remember= cf.getVarPtr ("RememberListSize"); - if (remember) - remember->setAsInt (RememberListSize); - - // StartExpanded - CConfigFile::CVar *start_expanded= cf.getVarPtr ("StartExpanded"); - if (start_expanded) - start_expanded->setAsInt (StartExpanded); - - // Georges4CVS - CConfigFile::CVar *georges_for_cvs= cf.getVarPtr ("GeorgesForCvs"); - if (georges_for_cvs) - georges_for_cvs->setAsInt (Georges4CVS); - - // MaxUndo - CConfigFile::CVar *max_undo= cf.getVarPtr ("MaxUndo"); - if (max_undo) - max_undo->setAsInt (MaxUndo); - - // DefaultType - CConfigFile::CVar *defaultType = cf.getVarPtr ("DefaultType"); - if (defaultType) - defaultType->setAsString (DefaultType.c_str ()); - - // DefaultDfn - CConfigFile::CVar *defaultDfn = cf.getVarPtr ("DefaultDfn"); - if (defaultDfn) - defaultDfn->setAsString (DefaultDfn.c_str ()); - - // Save the list - try - { - cf.save (); - } - catch (Exception &) - { - char message[512]; - smprintf (message, 512, "Can't save georges.cfg config file."); - outputError (message); - } - } - catch (Exception &) - { - char message[512]; - smprintf (message, 512, "Can't load georges.cfg config file."); - outputError (message); - } - - return true; -} - -void CGeorgesEditApp::initCfg () -{ - // Clear the search path list - CPath::removeAllAlternativeSearchPath (); - - // Add search path - CPath::addSearchPath (RootSearchPath, true, true,(IProgressCallback*)splashScreen); -} - -bool CGeorgesEditApp::getColor (NLMISC::CRGBA &color) -{ - // Get custom colors - COLORREF arrayColor[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - HKEY hKey; - if (RegOpenKeyEx(HKEY_CURRENT_USER, GEORGES_EDIT_BASE_REG_KEY"\\Custom Colors", 0, KEY_READ, &hKey)==ERROR_SUCCESS) - { - DWORD len=sizeof(arrayColor); - DWORD type; - RegQueryValueEx (hKey, "", 0, &type, (LPBYTE)(arrayColor), &len); - RegCloseKey (hKey); - } - - // Reset the struct - CHOOSECOLOR cc; - memset (&cc, 0, sizeof(CHOOSECOLOR)); - - // Fill the struct - cc.lStructSize=sizeof(CHOOSECOLOR); - cc.rgbResult=RGB (color.R, color.G, color.B); - cc.lpCustColors=arrayColor; - cc.Flags=CC_RGBINIT|CC_ANYCOLOR|CC_FULLOPEN; - - // Open it - if (ChooseColor (&cc)) - { - color = CRGBA (GetRValue (cc.rgbResult), GetGValue (cc.rgbResult), GetBValue (cc.rgbResult)); - - // Save the custom colors - HKEY hKey; - if (RegCreateKey(HKEY_CURRENT_USER, GEORGES_EDIT_BASE_REG_KEY"\\Custom Colors", &hKey)==ERROR_SUCCESS) - { - RegSetValueEx (hKey, "", 0, REG_BINARY, (LPBYTE)(arrayColor), sizeof(arrayColor)); - RegCloseKey (hKey); - } - return true; - } - return false; -} - -bool CGeorgesEditApp::yesNo (const char* message) -{ - if (m_pMainWnd) - return m_pMainWnd->MessageBox (message, "Georges Edit", MB_YESNO|MB_ICONQUESTION) != IDNO; - else - return MessageBox (NULL, message, "Georges Edit", MB_YESNO|MB_ICONQUESTION) != IDNO; -} - -void CGeorgesEditApp::loadPlugins () -{ - uint i; - for (i=0; idialogInit (*m_pMainWnd); - - // Hide it - plugin->activate (false); - } - } - else - { - char message[512]; - smprintf (message, 512, "Bad interface in plugin \"%s\"", PluginsNames[i].c_str ()); - outputError (message); - } - } - else - { - char message[512]; - smprintf (message, 512, "Can't found plugin \"%s\"", PluginsNames[i].c_str ()); - outputError (message); - } - } -} - -void CGeorgesEditApp::releasePlugins () -{ - uint i; - for (i=0; iGetActiveDocument ()); - if (doc) - { - if (doc->isForm ()) - return doc; - else - return NULL; - } - else - return NULL; - } - else - return NULL; -} - -void CGeorgesEditApp::getSearchPath (std::string &searchPath) -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - - searchPath = RootSearchPath; -} - -NLGEORGES::IEditDocument *CGeorgesEditApp::createDocument (const char *dfnName, const char *pathName) -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - - // Get the form templaet - CMultiDocTemplate *docTemplate = getFormDocTemplate (dfnName); - - if (docTemplate) - { - // Create a new document - CGeorgesEditDocForm *doc = (CGeorgesEditDocForm*)docTemplate->CreateNewDocument(); - nlassert (doc); - nlassert (doc->isForm ()); - - // Create the frame - CFrameWnd* pFrame = docTemplate->CreateNewFrame(doc, NULL); - nlassert (pFrame); - - // Set default title - docTemplate->SetDefaultTitle (doc); - - // Init the document - if (doc->initDocument (dfnName, true)) - { - // Set the filename - if (strcmp (pathName, "") != 0) - { - doc->SetPathName ( pathName, FALSE ); - - // Create the file - doc->OnSaveDocument( pathName ); - } - - // Init the frame - docTemplate->InitialUpdateFrame (pFrame, doc, TRUE); - - doc->changeSubSelection ((CGeorgesEditDocSub *)NULL, NULL); - doc->UpdateAllViews (NULL); - return doc; - } - else - { - docTemplate->RemoveDocument( doc ); - doc = NULL; - } - } - return NULL; -} - -///////////////////////////////////////////////////////////////////////////// -// CGeorgesEditApp message handlers - - - -int CGeorgesEditApp::ExitInstance() -{ - // Save the app profile (because it is a DLL) - if (m_pCmdInfo == NULL || - m_pCmdInfo->m_nShellCommand != CCommandLineInfo::AppUnregister) - { - if (!afxContextIsDLL) - SaveStdProfileSettings(); - } - - return CWinApp::ExitInstance(); -} - -CGeorgesEditApp::CPlugin::CPlugin (HINSTANCE hModule, IEditPlugin *plugin) -{ - PluginModule = hModule; - PluginInterface = plugin; - Activated = false; -} - -void CGeorgesEditApp::onNewDocView (CGeorgesEditDoc *doc) -{ - if (doc->isForm ()) - { - uint i; - for (i=0; ionCreateDocument (doc); - } - - } -} - -bool CGeorgesEditApp::isPluginActivated (NLGEORGES::IEditPlugin *plugin) const -{ - uint i; - for (i=0; iFileBrowserDlg.refresh (); - } -} - -void CGeorgesEditApp::saveWindowState (const CWnd *wnd, const char *name, bool controlBar) -{ - HKEY hKey; - nlverify (RegCreateKey (HKEY_CURRENT_USER, GEORGES_EDIT_BASE_REG_KEY"\\Windows states", &hKey) == ERROR_SUCCESS); - - // Get the position - WINDOWPLACEMENT wndpl; - wnd->GetWindowPlacement( &wndpl ); - - // Set the registry - nlverify (RegSetValueEx (hKey, name, 0, REG_BINARY, (BYTE*)&wndpl, sizeof(WINDOWPLACEMENT)) == ERROR_SUCCESS); - - // Close the key - nlverify (RegCloseKey (hKey) == ERROR_SUCCESS); -} - -void CGeorgesEditApp::loadWindowState (CWnd *wnd, const char *name, bool mdiChildWnd, bool controlBar) -{ - HKEY hKey; - if (RegOpenKey (HKEY_CURRENT_USER, GEORGES_EDIT_BASE_REG_KEY"\\Windows states", &hKey) == ERROR_SUCCESS) - { - // Get the value - WINDOWPLACEMENT wndpl; - DWORD type; - DWORD len = sizeof (WINDOWPLACEMENT); - - // Get from the registry - if (RegQueryValueEx (hKey, name, 0, &type, (BYTE*)&wndpl, &len) == ERROR_SUCCESS) - { - // Length ok ? - if (len == sizeof (WINDOWPLACEMENT)) - { - // Set window placement - - // Other children - if (mdiChildWnd) - { - wndpl.showCmd = SW_SHOW; - wnd->SetWindowPos (NULL, 0, 0, wndpl.rcNormalPosition.right-wndpl.rcNormalPosition.left, - wndpl.rcNormalPosition.bottom-wndpl.rcNormalPosition.top, SWP_NOMOVE|SWP_NOZORDER|SWP_NOOWNERZORDER); - } - else - { - wnd->SetWindowPlacement( &wndpl ); - } - } - } - - nlverify (RegCloseKey (hKey) == ERROR_SUCCESS); - } -} - -void CGeorgesEditApp::saveState () -{ - // Save the main window state - nlassert (m_pMainWnd); - if (ResizeMain) - saveWindowState (m_pMainWnd, "main", false); - - saveWindowState (&((CMainFrame*)m_pMainWnd)->FileBrowser, "browser", true); - saveWindowState (&((CMainFrame*)m_pMainWnd)->OutputConsole, "output", true); -} - -void CGeorgesEditApp::loadState () -{ - nlassert (m_pMainWnd); - if (ResizeMain) - loadWindowState (m_pMainWnd, "main", false, false); - - loadWindowState (&((CMainFrame*)m_pMainWnd)->FileBrowser, "browser", false, true); - loadWindowState (&((CMainFrame*)m_pMainWnd)->OutputConsole, "output", false, true); -} - -void CGeorgesEditApp::OnFileSaveAll() -{ - SaveAllModified (); -} - -void CGeorgesEditApp::OnFileCloseAll() -{ - SaveAllModified (); - CloseAllDocuments (FALSE); -} - -void CGeorgesEditApp::OnUpdateFileSaveAll(CCmdUI* pCmdUI) -{ - pCmdUI->Enable (getActiveDocument () != NULL); -} - -bool CGeorgesEditApp::SerialIntoMemStream (const char *formName, CGeorgesEditDoc *doc, uint slot, bool copyToClipboard) -{ - // Ok, get the node - const CFormDfn *parentDfn; - uint lastElement; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - bool parentVDfnArray; - nlverify (((const CFormElm*)(doc->getRootNode (slot)))->getNodeByName ( formName, &parentDfn, lastElement, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND)); - - // Output mode - if (MemStream.isReading ()) - MemStream.invert (); - - // Init the stream - MemStream.clear (); - - // Create a serial - COXml serialOutput; - serialOutput.init (&MemStream); - - // Catch some prb - try - { - // Serial the string - string name; - if (parentDfn) - name = parentDfn->getEntry(lastElement).getFilename (); - else - { - // Get the string - CString str = doc->GetPathName (); - name = str; - uint pos = name.rfind ('.'); - if (pos != string::npos) - { - // Keep the extension - name = name.substr (pos+1); - name += ".dfn"; - } - } - MemStream.serial (name); - - // Data presents ? - bool presents = node != NULL; - - // Serial the flag - MemStream.serial (presents); - - if (presents) - { - // Serial the buffer - xmlNodePtr nodeXml = xmlNewDocNode (serialOutput.getDocument (), NULL, (const xmlChar*)"CLIPBOARD", NULL); - xmlDocSetRootElement (serialOutput.getDocument (), nodeXml); - - // Struct type ? - if (node) - { - if (array) - { - (safe_cast (node))->write (nodeXml, doc->getFormPtr(), NULL); - } - else - { - if (type == UFormDfn::EntryDfn) - { - (safe_cast (node))->write (nodeXml, doc->getFormPtr(), NULL); - } - else if (type == UFormDfn::EntryVirtualDfn) - { - (safe_cast (node))->write (nodeXml, doc->getFormPtr(), NULL); - } - else if (type == UFormDfn::EntryType) - { - (safe_cast (node))->write (nodeXml, doc->getFormPtr(), NULL); - } - } - } - else - { - (safe_cast (node))->write (nodeXml, doc->getFormPtr(), NULL); - } - } - - // Flush the XML stream - serialOutput.flush (); - - // Debug test - /* FILE *output = fopen ("c:\\toto.txt", "wb"); - fwrite ((void*)MemStream.buffer (), 1, MemStream.length (), output); - fclose (output); */ - - // Write to clipboard - if (copyToClipboard) - { - // Is an array ? - if (array) - { - ((CMainFrame*)m_pMainWnd)->dataToClipboard (FormClipBoardFormatArray, (void*)MemStream.buffer (), - MemStream.length ()); - } - else - { - // Dfn ? - if (type == UFormDfn::EntryDfn ) - { - ((CMainFrame*)m_pMainWnd)->dataToClipboard (FormClipBoardFormatStruct, (void*)MemStream.buffer (), - MemStream.length ()); - } - // Virtual Dfn ? - else if (parentDfn && type == UFormDfn::EntryVirtualDfn && !array) - { - ((CMainFrame*)m_pMainWnd)->dataToClipboard (FormClipBoardFormatVirtualStruct, (void*)MemStream.buffer (), - MemStream.length ()); - } - // Type ? - else // if (parentDfn && type == UFormDfn::EntryType && !array) - { - ((CMainFrame*)m_pMainWnd)->dataToClipboard (FormClipBoardFormatType, (void*)MemStream.buffer (), - MemStream.length ()); - } - } - } - - // Ok - return true; - } - catch (Exception &) - { - nlstop; - } - - // Not ok - return false; -} - -void CGeorgesEditApp::FillMemStreamWithBuffer (const uint8 *buffer, uint size) -{ - // Input mode - if (!theApp.MemStream.isReading ()) - theApp.MemStream.invert (); - - // Init the stream - theApp.MemStream.clear (); - - // Buffer to fill - uint8 *bufferPtr = theApp.MemStream.bufferToFill (size); - memcpy (bufferPtr, buffer, size); -} - -bool CGeorgesEditApp::FillMemStreamWithClipboard (const char *formName, CGeorgesEditDoc *doc, uint slot) -{ - // Input mode - if (!theApp.MemStream.isReading ()) - theApp.MemStream.invert (); - - // The form pointer - CForm *form = doc->getFormPtr (); - - // Ok, get the node - const CFormDfn *parentDfn; - uint lastElement; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - bool parentVDfnArray; - nlverify (((CFormElm*)doc->getRootNode(slot))->getNodeByName ( formName, &parentDfn, - lastElement, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND)); - - // Get the clipboard type - UINT clipboardType; - if (array) - clipboardType = theApp.FormClipBoardFormatArray; - else if (type == UFormDfn::EntryType) - clipboardType = theApp.FormClipBoardFormatType; - else if (type == UFormDfn::EntryDfn) - clipboardType = theApp.FormClipBoardFormatStruct; - else // if (type == UFormDfn::EntryVirtualDfn) - clipboardType = theApp.FormClipBoardFormatVirtualStruct; - - // Get the clipboard size - uint size; - - // Get the clipboard size - if (((CMainFrame*)theApp.m_pMainWnd)->clipboardSize (clipboardType, size)) - { - // Init the stream - theApp.MemStream.clear (); - - // Fill the input buffer - uint8 *bufferPtr = theApp.MemStream.bufferToFill (size); - nlverify (((CMainFrame*)theApp.m_pMainWnd)->dataFromClipboard (clipboardType, bufferPtr)); - return true; - } - else - return false; -} - -bool CGeorgesEditApp::SerialFromMemStream (const char *formName, CGeorgesEditDoc *doc, uint slot) -{ - // The form pointer - CForm *form = doc->getFormPtr (); - - // Ok, get the node - const CFormDfn *parentDfn; - uint lastElement; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - bool parentVDfnArray; - nlverify (((CFormElm*)(doc->getRootNode (slot)))->getNodeByName ( formName, &parentDfn, - lastElement, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND)); - - // Get the clipboard type - UINT clipboardType; - if (array) - clipboardType = theApp.FormClipBoardFormatArray; - else if (type == UFormDfn::EntryType) - clipboardType = theApp.FormClipBoardFormatType; - else if (type == UFormDfn::EntryDfn) - clipboardType = theApp.FormClipBoardFormatStruct; - else // if (type == UFormDfn::EntryVirtualDfn) - clipboardType = theApp.FormClipBoardFormatVirtualStruct; - - // Catch some prb - try - { - // Serial the string - string nameParent; - string name; - if (parentDfn) - nameParent = parentDfn->getEntry(lastElement).getFilename (); - else - { - // Get the string - CString str = doc->GetPathName (); - nameParent = str; - uint pos = nameParent.rfind ('.'); - if (pos != string::npos) - { - // Keep the extension - nameParent = nameParent.substr (pos+1); - nameParent += ".dfn"; - } - } - theApp.MemStream.serial (name); - - // Same DFN ? - if (name == nameParent) - { - // Is in the clipboard - bool present; - theApp.MemStream.serial (present); - - // Is present - if (present) - { - // Create the node - bool created; - nlverify (((CFormElm*)(doc->getRootNode (slot)))->createNodeByName ( formName, &parentDfn, - lastElement, &nodeDfn, &nodeType, &node, type, array, created)); - - // For struct - if (clipboardType == theApp.FormClipBoardFormatStruct) - { - // Struct pointer - CFormElmStruct *formStruct = safe_cast((CFormElm*)node); - - // Create a serial - CIXml serialInput; - serialInput.init (theApp.MemStream); - - // Clean the node - formStruct->clean (); - - // Serial it - - // Get first struct node - xmlNodePtr nodeXml = CIXml::getFirstChildNode (serialInput.getRootNode (), "STRUCT"); - if (nodeXml) - { - formStruct->read (nodeXml, doc->FormLoader, (CFormDfn*)nodeDfn, form); - } - } - // For array - else if (clipboardType == theApp.FormClipBoardFormatArray) - { - // Struct pointer - CFormElmArray *formArray = safe_cast((CFormElm*)node); - - // Create a serial - CIXml serialInput; - serialInput.init (theApp.MemStream); - - // Clean the node - formArray->clean (); - - // Serial it - - // Get first struct node - xmlNodePtr nodeXml = CIXml::getFirstChildNode (serialInput.getRootNode (), "ARRAY"); - if (nodeXml) - { - // Should be a type or a DFN - nlassert ((nodeType) || (nodeDfn)); - formArray->read (nodeXml, doc->FormLoader, form); - } - } - // For atom - else if (clipboardType == theApp.FormClipBoardFormatType) - { - // Struct pointer - CFormElmAtom *formAtom = safe_cast((CFormElm*)node); - - // Create a serial - CIXml serialInput; - serialInput.init (theApp.MemStream); - - // Serial it - - // Get first struct node - xmlNodePtr nodeXml = CIXml::getFirstChildNode (serialInput.getRootNode (), "ATOM"); - if (nodeXml) - { - // Should be a type - nlassert (nodeType); - formAtom->read (nodeXml, doc->FormLoader, (CType*)nodeType, form); - } - } - // For virtual struct - else if (clipboardType == theApp.FormClipBoardFormatVirtualStruct) - { - // Struct pointer - CFormElmVirtualStruct *vitualStruct = safe_cast((CFormElm*)node); - - // Create a serial - CIXml serialInput; - serialInput.init (theApp.MemStream); - - // Clean the node - vitualStruct->clean (); - - // Serial it - - // Get first struct node - xmlNodePtr nodeXml = CIXml::getFirstChildNode (serialInput.getRootNode (), "VSTRUCT"); - if (nodeXml) - { - vitualStruct->read (nodeXml, doc->FormLoader, form); - } - } - } // if (present) - else - { - // Does the node exist ? - // Ok, get the node - const CFormDfn *parentDfn; - uint lastElement; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - bool parentVDfnArray; - if (((CFormElm*)(doc->getRootNode (slot)))->getNodeByName ( formName, &parentDfn, - lastElement, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND)) - { - // Delete the node if it exist in this form - if (node && (node->getForm () == doc->getFormPtr ()) ) - { - nlverify (((CFormElm*)(doc->getRootNode (slot)))->deleteNodeByName ( formName, &parentDfn, - lastElement, &nodeDfn, &nodeType, &node, type, array)); - } - } - } - - // Not ok - return true; - } - } - catch (Exception &e) - { - nlwarning ("Error while paste: %s", e.what()); - } - - // Not ok - return false; -} - -BOOL CGeorgesEditApp::OnDDECommand(LPTSTR lpszCommand) -{ - if (strncmp (lpszCommand, "Open", 4) == 0) - { - string name = lpszCommand; - name = name.substr (6, name.size ()-8); - OpenDocumentFile (name.c_str ()); - } - else if (strncmp (lpszCommand, "Georges Copy", 4) == 0) - { - // Get ext name - string name = lpszCommand; - name = name.substr (6, name.size ()-8); - - // Get the extension - char ext[MAX_PATH]; - _splitpath (name.c_str (), NULL, NULL, NULL, ext); - string dfnName = string (ext+1) + ".dfn"; - - // Get the doc template - CMultiDocTemplate *docTemplate = getFormDocTemplate (dfnName.c_str ()); - - if (docTemplate) - { - // Create a new document - CGeorgesEditDocForm *doc = (CGeorgesEditDocForm*)docTemplate->CreateNewDocument(); - nlassert (doc); - nlassert (doc->isForm ()); - - // Create the frame - CFrameWnd* pFrame = docTemplate->CreateNewFrame(doc, NULL); - nlassert (pFrame); - if (doc->loadFormFile (name.c_str ())) - { - - doc->updateDocumentStructure (); - - // Init the frame - docTemplate->InitialUpdateFrame (pFrame, doc, TRUE); - - // Init the document - if (doc->initDocument (dfnName.c_str (), false)) - { - doc->changeSubSelection ((CGeorgesEditDocSub *)NULL, NULL); - doc->UpdateAllViews (NULL); - } - else - { - docTemplate->RemoveDocument( doc ); - doc = NULL; - char tmp[512]; - smprintf (tmp, 512, "Can't open document '%s'.", name.c_str ()); - outputError (tmp); - } - } - else - { - docTemplate->RemoveDocument( doc ); - doc = NULL; - char tmp[512]; - smprintf (tmp, 512, "Can't open document '%s'.", name.c_str ()); - outputError (tmp); - } - } - else - { - char tmp[512]; - smprintf (tmp, 512, "Can't open document '%s'.", name.c_str ()); - outputError (tmp); - } - } - else if (strncmp (lpszCommand, "Derive", 6) == 0) - { - // Get ext name - string name = lpszCommand; - name = name.substr (8, name.size ()-10); - - // Get the extension - char ext[MAX_PATH]; - _splitpath (name.c_str (), NULL, NULL, NULL, ext); - string dfnName = string (ext+1) + ".dfn"; - - // Create a document - CGeorgesEditDocForm *doc = (CGeorgesEditDocForm*)createDocument (dfnName.c_str (), ""); - if (doc) - { - char nameFile[MAX_PATH]; - char extFile[MAX_PATH]; - _splitpath (name.c_str (), NULL, NULL, nameFile, extFile); - doc->addParent ((string (nameFile) + extFile).c_str ()); - doc->updateDocumentStructure (); - doc->UpdateAllViews (NULL); - } - else - { - char tmp[512]; - smprintf (tmp, 512, "Can't derive from document '%s'.", name.c_str ()); - outputError (tmp); - } - } - else if (strncmp (lpszCommand, "CreateForm", 10) == 0) - { - // Get ext name - string name = lpszCommand; - name = name.substr (10, name.size ()-12); - - // Get the extension - char name2[MAX_PATH]; - char ext[MAX_PATH]; - _splitpath (name.c_str (), NULL, NULL, name2, ext); - string dfnName = name2; - dfnName += ext; - - // Create a document - CGeorgesEditDocForm *doc = (CGeorgesEditDocForm*)createDocument (dfnName.c_str (), ""); - if (doc) - { - doc->updateDocumentStructure (); - doc->UpdateAllViews (NULL); - } - else - { - char tmp[512]; - smprintf (tmp, 512, "Can't create a file from dfn '%s'.", name.c_str ()); - outputError (tmp); - } - } - return CWinApp::OnDDECommand(lpszCommand); -} - -CMultiDocTemplate *CGeorgesEditApp::getFormDocTemplate (const char *dfnName) -{ - if (Superuser) - { - return _TemplateForm; - } - else - { - POSITION pos = GetFirstDocTemplatePosition (); - while (pos) - { - // Get the template - CMyMultiDocTemplate *docTemp = safe_cast (GetNextDocTemplate(pos)); - - // Check its dfn name - std::string dfnNameTemplate; - docTemp->getDfnName (dfnNameTemplate); - if (dfnName == dfnNameTemplate) - return docTemp; - } - } - - // Not found - return NULL; +// 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 "stdafx.h" + +#include "nel/misc/path.h" +#include "nel/misc/config_file.h" +#include "nel/misc/o_xml.h" +#include "nel/misc/i_xml.h" +#include "nel/misc/dynloadlib.h" + +#include "georges_edit.h" +#include "reg_shell_ext.h" + +#include "main_frm.h" +#include "child_frm.h" +#include "georges_edit_doc.h" +#include "left_view.h" + +#include "splash_screen.h" + +using namespace NLMISC; +using namespace NLGEORGES; +using namespace std; + + +const char* TypeFilter = "Type Files (*.typ)|*.typ|All Files (*.*)|*.*||"; +const char* DfnFilter = "Form Definition Files (*.dfn)|*.dfn|All Files (*.*)|*.*||"; +CSplashScreen* splashScreen=new CSplashScreen; +///////////////////////////////////////////////////////////////////////////// +// CGeorgesEditApp + +BEGIN_MESSAGE_MAP(CGeorgesEditApp, CWinApp) + //{{AFX_MSG_MAP(CGeorgesEditApp) + ON_COMMAND(ID_APP_ABOUT, OnAppAbout) + ON_COMMAND(ID_VIEW_REFRESH, OnViewRefresh) + ON_COMMAND(ID_FILE_SAVE_ALL, OnFileSaveAll) + ON_COMMAND(ID_FILE_CLOSE_ALL, OnFileCloseAll) + ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_ALL, OnUpdateFileSaveAll) + //}}AFX_MSG_MAP + // Standard file based document commands + ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) + ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CGeorgesEditApp construction + +CGeorgesEditApp::CGeorgesEditApp() : MemStream (false, false, 1024*1024) +{ + Superuser = true; + DefaultType = "default.typ"; + DefaultDfn = "default.dfn"; + + m_pMainWnd = NULL; + RememberListSize = 10; + MaxUndo = 20; + ResizeMain = true; + ExeStandalone = false; + StartExpanded = true; + Georges4CVS = true; + + FormClipBoardFormatStruct = RegisterClipboardFormat ("GeorgesFormStruct"); + FormClipBoardFormatVirtualStruct = RegisterClipboardFormat ("GeorgesFormVirtualStruct"); + FormClipBoardFormatArray = RegisterClipboardFormat ("GeorgesFormArray"); + FormClipBoardFormatType = RegisterClipboardFormat ("GeorgesFormType"); + nlassert (FormClipBoardFormatStruct); + nlassert (FormClipBoardFormatVirtualStruct); + nlassert (FormClipBoardFormatArray); + nlassert (FormClipBoardFormatType); + + _TemplateForm = NULL; + _TemplateType = NULL; + _TemplateDfn = NULL; +} + +CGeorgesEditApp::~CGeorgesEditApp () +{ +} + +///////////////////////////////////////////////////////////////////////////// +// The one and only CGeorgesEditApp object + +CGeorgesEditApp theApp; + +///////////////////////////////////////////////////////////////////////////// +// CGeorgesEditApp initialization + +BOOL CGeorgesEditApp::InitInstance() +{ + return TRUE; +} + +CMyMultiDocTemplate::CMyMultiDocTemplate (const char *ext, UINT nIDResource, CRuntimeClass* pDocClass, CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass) : + CMultiDocTemplate ( nIDResource, pDocClass, pFrameClass, pViewClass ) +{ + _Ext = ext; + _ExtMaj = _Ext; + _Ext = strlwr (_Ext); + _ExtMaj[0] = toupper (_ExtMaj[0]); +} + +void CMyMultiDocTemplate::getDfnName (string &dfnName) +{ + dfnName = _Ext + ".dfn"; +} + +BOOL CMyMultiDocTemplate::GetDocString(CString& rString, enum DocStringIndex index) const +{ + switch (index) + { + case fileNewName: + case windowTitle: + case docName: + rString = (_ExtMaj + " Form").c_str (); + return TRUE; + case filterName: + rString = (_ExtMaj + " Form Filename (*." + _Ext+ ")").c_str (); + return TRUE; + case filterExt: + rString = ("." + _Ext).c_str (); + return TRUE; + default: + return CMultiDocTemplate::GetDocString(rString, index); + } +} + +BOOL CGeorgesEditApp::initInstance (int nCmdShow, bool exeStandalone, int x, int y, int cx, int cy) +{ + // Some things have just to be done once per launch of the application that is + // completely different from an opening/closing of the main frame + static bool isInitialized = false; + ExeStandalone = exeStandalone; + + + splashScreen->Create(IDD_SPLASHSCREEN, theApp.GetMainWnd()); + splashScreen->ShowWindow(TRUE); + splashScreen->addLine(string("Georges Initialization")); + // Filter addSearchPath + splashScreen->addLine(string("Filter addSearchPath")); + NLMISC::createDebug(); + InfoLog->addNegativeFilter("adding the path"); + WarningLog->addNegativeFilter("Exception will be launched"); + + if (!isInitialized && exeStandalone) + { + m_nCmdShow = nCmdShow; + ExePath = GetCommandLine (); + if (ExePath.size()>0) + { + if (ExePath[0] == '\"') + { + uint end=ExePath.find ('\"', 1); + if (end != string::npos) + { + ExePath = ExePath.substr (1, end-1); + } + else + { + nlassert (0); // no! + } + } + else + { + uint end=ExePath.find (' ', 1); + ExePath = ExePath.substr (0, end); + } + } + + // Init CPath + loadCfg (); + initCfg (); + } + + if (!isInitialized) + { + // Fill the image list + splashScreen->addLine(string("Fill the image list")); + ImageList.create (16, 16); + ImageList.addResourceIcon (m_hInstance, IDR_ARRAY); + ImageList.addResourceIcon (m_hInstance, IDR_HEADER); + ImageList.addResourceIcon (m_hInstance, IDR_HOLD); + ImageList.addResourceIcon (m_hInstance, IDR_ROOT); + ImageList.addResourceIcon (m_hInstance, IDR_STRUCT); + ImageList.addResourceIcon (m_hInstance, IDR_VSTRUCT); + ImageList.addResourceIcon (m_hInstance, IDR_TYPEDFN); + ImageList.addResourceIcon (m_hInstance, IDR_TYPEFORM); + ImageList.addResourceIcon (m_hInstance, IDR_TYPETYPE); + + // Add icon + splashScreen->addLine(string("Add icon")); + std::vector result; + string iconPathName = RootSearchPath+TypeDfnSubDirectory; + if (!iconPathName.empty ()) + { + CPath::getPathContent (iconPathName, true, false, true, result); + uint i; + for (i=0; iaddLine(string("Standard initialization")); + if (!isInitialized) + { + +// const char *open = "Open(\"%1\")"; +// const char *copy = "Georges Copy(\"%1\")"; +// const char *derive = "Derive(\"%1\")"; +// const char *createForm = "CreateForm(\"%1\")"; +// const char *notepad = "notepad.exe \"%1\""; + + // *** Registry + + // MFC settings + splashScreen->addLine(string("MFC settings")); + SetRegistryKey(_T("Nevrax")); + LoadStdProfileSettings(16); // Load standard INI file options (including MRU) +// EnableShellOpen(); + + // Application path + string appPath = "\""; + appPath += ExePath; + appPath += "\""; + + bool okRegister = true; + if (ExeStandalone) + { + splashScreen->addLine(string("Associate Georges file extensions")); + okRegister &= RegisterApp ("Georges.Type", "Georges Type Files", appPath.c_str (), 3); + okRegister &= RegisterApp ("Georges.Dfn", "Georges Dfn Files", appPath.c_str (), 3); + okRegister &= RegisterApp ("Georges.Form", "Georges Form Files", appPath.c_str (), 3); + okRegister &= RegisterShellFileExt (".typ", "Georges.Type"); + okRegister &= RegisterShellFileExt (".dfn", "Georges.Dfn"); + + // Register Type and DFN for superuser +/* if (Superuser) + { + // Register the application + splashScreen->addLine(string("Register the application")); + okRegister &= RegisterApp ("Georges.Type", "Georges Type Files", appPath.c_str (), 1); + okRegister &= RegisterApp ("Georges.Dfn", "Georges Dfn Files", appPath.c_str (), 2); + okRegister &= RegisterApp ("Georges.Form", "Georges Form Files", appPath.c_str (), 3); + + // Register the command + splashScreen->addLine(string("Register the command")); + okRegister &= RegisterAppCommand ("Georges.Type", "Open", (appPath+" %1").c_str ()); + okRegister &= RegisterAppCommand ("Georges.Dfn", "Open", (appPath+" %1").c_str ()); + okRegister &= RegisterAppCommand ("Georges.Dfn", "Create Form", (appPath+" /dde").c_str ()); + + okRegister &= RegisterAppCommand ("Georges.Type", "Open With Notepad", notepad); + okRegister &= RegisterAppCommand ("Georges.Dfn", "Open With Notepad", notepad); + + // Register the DDE command (avoid strange Visual compile error..) + splashScreen->addLine(string("Register the DDE command")); + okRegister &= RegisterDDECommand ("Georges.Type", "Open", open, m_pszExeName); + okRegister &= RegisterDDECommand ("Georges.Dfn", "Open", open, m_pszExeName); + okRegister &= RegisterDDECommand ("Georges.Dfn", "Create Form", createForm, m_pszExeName); + + // Register the file extension + splashScreen->addLine(string("Register the file extension")); + okRegister &= RegisterShellFileExt (".typ", "Georges.Type"); + okRegister &= RegisterShellFileExt (".dfn", "Georges.Dfn"); + } + else + { + // Register the command + splashScreen->addLine(string("Register the command")); + UnregisterAppCommand ("Georges.Dfn", "Open"); + okRegister &= RegisterAppCommand ("Georges.Dfn", "Create Form", (appPath+" /dde").c_str ()); + UnregisterAppCommand ("Georges.Dfn", "Open With Notepad"); + + // Register the DDE command (avoid strange Visual compile error..) + splashScreen->addLine(string("Register the DDE command")); + okRegister &= RegisterDDECommand ("Georges.Dfn", "Create Form", createForm, m_pszExeName); + + // Register the file extension + splashScreen->addLine(string("Register the file extension")); + okRegister &= RegisterShellFileExt (".dfn", "Georges.Dfn"); + + // Unregister type and dfn + splashScreen->addLine(string("Unregister type and dfn")); + UnregisterApp ("Georges.Type"); + } + + // Register non super user commands + splashScreen->addLine(string("Register non super user commands")); + okRegister &= RegisterAppCommand ("Georges.Form", "Open", (appPath+" %1").c_str ()); + okRegister &= RegisterAppCommand ("Georges.Form", "Georges Copy", (appPath+" /dde").c_str ()); + okRegister &= RegisterAppCommand ("Georges.Form", "Derive", (appPath+" /dde").c_str ()); + okRegister &= RegisterAppCommand ("Georges.Form", "Open With Notepad", notepad); + + // Register dde commands + splashScreen->addLine(string("Register dde commands")); + okRegister &= RegisterDDECommand ("Georges.Form", "Open", open, m_pszExeName); + okRegister &= RegisterDDECommand ("Georges.Form", "Georges Copy", copy, m_pszExeName); + okRegister &= RegisterDDECommand ("Georges.Form", "Derive", derive, m_pszExeName); +*/ + } + + // Ok register ? + if (!okRegister) + nlwarning ("Register Georges: problem during Georges registration. Do you have administrator privileges ?"); + + // Register the application's document templates. Document templates + // serve as the connection between documents, frame windows and views. + + // Are we a superuser ? + if (Superuser) + { + // Form + _TemplateForm = new CMultiDocTemplate( + IDR_TYPEFORM, + RUNTIME_CLASS(CGeorgesEditDocForm), + RUNTIME_CLASS(CChildFrame), // custom MDI child frame + RUNTIME_CLASS(CLeftView)); + AddDocTemplate(_TemplateForm); + + // Type + _TemplateType = new CMultiDocTemplate( + IDR_TYPETYPE, + RUNTIME_CLASS(CGeorgesEditDocType), + RUNTIME_CLASS(CChildFrame), // custom MDI child frame + RUNTIME_CLASS(CLeftView)); + AddDocTemplate(_TemplateType); + + // Dfn + _TemplateDfn = new CMultiDocTemplate( + IDR_TYPEDFN, + RUNTIME_CLASS(CGeorgesEditDocDfn), + RUNTIME_CLASS(CChildFrame), // custom MDI child frame + RUNTIME_CLASS(CLeftView)); + AddDocTemplate(_TemplateDfn); + } + else + { + // For each form + uint i; + for (i=0; iaddLine(string("create main MDI Frame window")); + CMainFrame* pMainFrame = new CMainFrame; + nlassert (pMainFrame); + ((CMainFrame*)pMainFrame)->createX = x; + ((CMainFrame*)pMainFrame)->createY = y; + ((CMainFrame*)pMainFrame)->createCX = cx; + ((CMainFrame*)pMainFrame)->createCY = cy; + if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) + return FALSE; + m_pMainWnd = pMainFrame; + + // Enable drag/drop open + m_pMainWnd->DragAcceptFiles(); + + if (!isInitialized) + { + // Enable DDE Execute open +// EnableShellOpen(); +// RegisterShellFileTypes(TRUE); + isInitialized = true; + } + + // Parse command line for standard shell commands, DDE, file open + splashScreen->addLine(string("Parse command line")); + CCommandLineInfo cmdInfo; + ParseCommandLine(cmdInfo); + + // Dispatch commands specified on the command line + splashScreen->addLine(string("Dispatch commands specified")); + if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew) + cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing; + + /*if (!ProcessShellCommand(cmdInfo)) + return FALSE;*/ + + // Load and init plugins + splashScreen->addLine(string("Load and init plugins")); + loadPlugins (); + + // Init windows + ResizeMain = (x==-1); + loadState (); + + // The main window has been initialized, so show and update it. + pMainFrame->ShowWindow(SW_SHOW /*m_nCmdShow*/); + pMainFrame->UpdateWindow(); + + splashScreen->ShowWindow(false); + return TRUE; +} + +///////////////////////////////////////////////////////////////////////////// +// CAboutDlg dialog used for App About + +class CAboutDlg : public CDialog +{ +public: + CAboutDlg(); + +// Dialog Data + //{{AFX_DATA(CAboutDlg) + enum { IDD = IDD_ABOUTBOX }; + //}}AFX_DATA + + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CAboutDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + //{{AFX_MSG(CAboutDlg) + // No message handlers + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) +{ + //{{AFX_DATA_INIT(CAboutDlg) + //}}AFX_DATA_INIT +} + +void CAboutDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CAboutDlg) + //}}AFX_DATA_MAP +} + +BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) + //{{AFX_MSG_MAP(CAboutDlg) + // No message handlers + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +// App command to run the dialog +void CGeorgesEditApp::OnAppAbout() +{ + CAboutDlg aboutDlg; + aboutDlg.DoModal(); +} + +void CGeorgesEditApp::outputError (const char* message) +{ + if (m_pMainWnd) + m_pMainWnd->MessageBox (message, "Georges Edit", MB_OK|MB_ICONEXCLAMATION); + else + MessageBox (NULL, message, "Georges Edit", MB_OK|MB_ICONEXCLAMATION); +} + +void CGeorgesEditApp::getConfigFilePath (std::string &output) +{ + // Get the config file path + char sDrive[MAX_PATH]; + char sDir[MAX_PATH]; + char sPath[MAX_PATH]; + _splitpath (theApp.ExePath.c_str (), sDrive, sDir, NULL, NULL); + _makepath (sPath, sDrive, sDir, "georges", ".cfg"); + output = sPath; +} + +bool CGeorgesEditApp::loadCfg () +{ + // Open the config file + std::string configPath; + getConfigFilePath (configPath); + CConfigFile &cf = ConfigFile;; + + + // Root search path + try + { + cf.load (configPath); + + CConfigFile::CVar *rootDirectory = cf.getVarPtr ("RootSearchDirectory"); + if (rootDirectory) + { + RootSearchPath = rootDirectory->asString (); + if (RootSearchPath.size ()) + { + char c = RootSearchPath[RootSearchPath.size ()-1]; + if ((c != '\\') && (c != '/')) + RootSearchPath += "\\"; + } + } + + // Type and Dfn sub directory + CConfigFile::CVar *typeDfnSubDirectory = cf.getVarPtr ("TypDfnSubFolder"); + if (typeDfnSubDirectory) + { + // Last char is good ? + string copy = typeDfnSubDirectory->asString (); + const char *ptr = copy.c_str (); + while ((*ptr == '/') || (*ptr == '\\')) + ptr++; + TypeDfnSubDirectory = ptr; + if (TypeDfnSubDirectory.size ()) + { + char c = TypeDfnSubDirectory[TypeDfnSubDirectory.size ()-1]; + if ((c != '\\') && (c != '/')) + TypeDfnSubDirectory += "\\"; + } + } + + // RememberListSize + CConfigFile::CVar *remember = cf.getVarPtr ("RememberListSize"); + if (remember) + RememberListSize = remember->asInt (); + + // StartExpanded + CConfigFile::CVar *start_expanded = cf.getVarPtr ("StartExpanded"); + if (start_expanded) + StartExpanded = start_expanded->asInt () != 0; + + // Georges4CVS + CConfigFile::CVar *georges_for_cvs = cf.getVarPtr ("GeorgesForCvs"); + if (georges_for_cvs) + Georges4CVS = georges_for_cvs->asInt () != 0; + + // MaxUndo + CConfigFile::CVar *max_undo = cf.getVarPtr ("MaxUndo"); + if (max_undo) + MaxUndo = max_undo->asInt (); + + // DefaultType + CConfigFile::CVar *defaultType = cf.getVarPtr ("DefaultType"); + if (defaultType) + DefaultType = defaultType->asString (); + + // DefaultDfn + CConfigFile::CVar *defaultDfn = cf.getVarPtr ("DefaultDfn"); + if (defaultDfn) + DefaultDfn = defaultDfn->asString (); + + // Plugins + CConfigFile::CVar *plugins = cf.getVarPtr ("Plugins"); + if (plugins) + { + PluginsNames.reserve (plugins->size()); + uint i; + for (i=0; i<(uint)plugins->size(); i++) + PluginsNames.push_back (plugins->asString (i)); + } + + // User types + CConfigFile::CVar *user_type = cf.getVarPtr ("UserType"); + if (user_type) + { + UserTypes.reserve (user_type->size()); + uint i; + for (i=0; i<(uint)user_type->size(); i++) + UserTypes.push_back (user_type->asString (i)); + } + + // Super user + CConfigFile::CVar *superuser = cf.getVarPtr ("SuperUser"); + if (superuser) + Superuser = superuser->asInt () != 0; + } + catch (Exception &) + { + char message[512]; + smprintf (message, 512, "Can't load georges.cfg config file."); + outputError (message); + } + + return true; +} + +bool CGeorgesEditApp::saveCfg () +{ + // Config path + std::string configPath; + getConfigFilePath (configPath); + CConfigFile &cf = ConfigFile; + + // Root search path + try + { + cf.load (configPath); + + CConfigFile::CVar *rootDirectory = cf.getVarPtr ("RootSearchDirectory"); + if (rootDirectory) + rootDirectory->setAsString (RootSearchPath.c_str ()); + + // Type and Dfn sub directory + CConfigFile::CVar *typeDfnSubDirectory = cf.getVarPtr ("TypDfnSubFolder"); + if (typeDfnSubDirectory) + typeDfnSubDirectory->setAsString (TypeDfnSubDirectory.c_str ()); + + // RememberListSize + CConfigFile::CVar *remember= cf.getVarPtr ("RememberListSize"); + if (remember) + remember->setAsInt (RememberListSize); + + // StartExpanded + CConfigFile::CVar *start_expanded= cf.getVarPtr ("StartExpanded"); + if (start_expanded) + start_expanded->setAsInt (StartExpanded); + + // Georges4CVS + CConfigFile::CVar *georges_for_cvs= cf.getVarPtr ("GeorgesForCvs"); + if (georges_for_cvs) + georges_for_cvs->setAsInt (Georges4CVS); + + // MaxUndo + CConfigFile::CVar *max_undo= cf.getVarPtr ("MaxUndo"); + if (max_undo) + max_undo->setAsInt (MaxUndo); + + // DefaultType + CConfigFile::CVar *defaultType = cf.getVarPtr ("DefaultType"); + if (defaultType) + defaultType->setAsString (DefaultType.c_str ()); + + // DefaultDfn + CConfigFile::CVar *defaultDfn = cf.getVarPtr ("DefaultDfn"); + if (defaultDfn) + defaultDfn->setAsString (DefaultDfn.c_str ()); + + // Save the list + try + { + cf.save (); + } + catch (Exception &) + { + char message[512]; + smprintf (message, 512, "Can't save georges.cfg config file."); + outputError (message); + } + } + catch (Exception &) + { + char message[512]; + smprintf (message, 512, "Can't load georges.cfg config file."); + outputError (message); + } + + return true; +} + +void CGeorgesEditApp::initCfg () +{ + // Clear the search path list + CPath::removeAllAlternativeSearchPath (); + + // Add search path + CPath::addSearchPath (RootSearchPath, true, true,(IProgressCallback*)splashScreen); +} + +bool CGeorgesEditApp::getColor (NLMISC::CRGBA &color) +{ + // Get custom colors + COLORREF arrayColor[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + HKEY hKey; + if (RegOpenKeyEx(HKEY_CURRENT_USER, GEORGES_EDIT_BASE_REG_KEY"\\Custom Colors", 0, KEY_READ, &hKey)==ERROR_SUCCESS) + { + DWORD len=sizeof(arrayColor); + DWORD type; + RegQueryValueEx (hKey, "", 0, &type, (LPBYTE)(arrayColor), &len); + RegCloseKey (hKey); + } + + // Reset the struct + CHOOSECOLOR cc; + memset (&cc, 0, sizeof(CHOOSECOLOR)); + + // Fill the struct + cc.lStructSize=sizeof(CHOOSECOLOR); + cc.rgbResult=RGB (color.R, color.G, color.B); + cc.lpCustColors=arrayColor; + cc.Flags=CC_RGBINIT|CC_ANYCOLOR|CC_FULLOPEN; + + // Open it + if (ChooseColor (&cc)) + { + color = CRGBA (GetRValue (cc.rgbResult), GetGValue (cc.rgbResult), GetBValue (cc.rgbResult)); + + // Save the custom colors + HKEY hKey; + if (RegCreateKey(HKEY_CURRENT_USER, GEORGES_EDIT_BASE_REG_KEY"\\Custom Colors", &hKey)==ERROR_SUCCESS) + { + RegSetValueEx (hKey, "", 0, REG_BINARY, (LPBYTE)(arrayColor), sizeof(arrayColor)); + RegCloseKey (hKey); + } + return true; + } + return false; +} + +bool CGeorgesEditApp::yesNo (const char* message) +{ + if (m_pMainWnd) + return m_pMainWnd->MessageBox (message, "Georges Edit", MB_YESNO|MB_ICONQUESTION) != IDNO; + else + return MessageBox (NULL, message, "Georges Edit", MB_YESNO|MB_ICONQUESTION) != IDNO; +} + +void CGeorgesEditApp::loadPlugins () +{ + uint i; + for (i=0; idialogInit (*m_pMainWnd); + + // Hide it + plugin->activate (false); + } + } + else + { + char message[512]; + smprintf (message, 512, "Bad interface in plugin \"%s\"", PluginsNames[i].c_str ()); + outputError (message); + } + } + else + { + char message[512]; + smprintf (message, 512, "Can't found plugin \"%s\"", PluginsNames[i].c_str ()); + outputError (message); + } + } +} + +void CGeorgesEditApp::releasePlugins () +{ + uint i; + for (i=0; iGetActiveDocument ()); + if (doc) + { + if (doc->isForm ()) + return doc; + else + return NULL; + } + else + return NULL; + } + else + return NULL; +} + +void CGeorgesEditApp::getSearchPath (std::string &searchPath) +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + + searchPath = RootSearchPath; +} + +NLGEORGES::IEditDocument *CGeorgesEditApp::createDocument (const char *dfnName, const char *pathName) +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + + // Get the form templaet + CMultiDocTemplate *docTemplate = getFormDocTemplate (dfnName); + + if (docTemplate) + { + // Create a new document + CGeorgesEditDocForm *doc = (CGeorgesEditDocForm*)docTemplate->CreateNewDocument(); + nlassert (doc); + nlassert (doc->isForm ()); + + // Create the frame + CFrameWnd* pFrame = docTemplate->CreateNewFrame(doc, NULL); + nlassert (pFrame); + + // Set default title + docTemplate->SetDefaultTitle (doc); + + // Init the document + if (doc->initDocument (dfnName, true)) + { + // Set the filename + if (strcmp (pathName, "") != 0) + { + doc->SetPathName ( pathName, FALSE ); + + // Create the file + doc->OnSaveDocument( pathName ); + } + + // Init the frame + docTemplate->InitialUpdateFrame (pFrame, doc, TRUE); + + doc->changeSubSelection ((CGeorgesEditDocSub *)NULL, NULL); + doc->UpdateAllViews (NULL); + return doc; + } + else + { + docTemplate->RemoveDocument( doc ); + doc = NULL; + } + } + return NULL; +} + +///////////////////////////////////////////////////////////////////////////// +// CGeorgesEditApp message handlers + + + +int CGeorgesEditApp::ExitInstance() +{ + // Save the app profile (because it is a DLL) + if (m_pCmdInfo == NULL || + m_pCmdInfo->m_nShellCommand != CCommandLineInfo::AppUnregister) + { + if (!afxContextIsDLL) + SaveStdProfileSettings(); + } + + return CWinApp::ExitInstance(); +} + +CGeorgesEditApp::CPlugin::CPlugin (HINSTANCE hModule, IEditPlugin *plugin) +{ + PluginModule = hModule; + PluginInterface = plugin; + Activated = false; +} + +void CGeorgesEditApp::onNewDocView (CGeorgesEditDoc *doc) +{ + if (doc->isForm ()) + { + uint i; + for (i=0; ionCreateDocument (doc); + } + + } +} + +bool CGeorgesEditApp::isPluginActivated (NLGEORGES::IEditPlugin *plugin) const +{ + uint i; + for (i=0; iFileBrowserDlg.refresh (); + } +} + +void CGeorgesEditApp::saveWindowState (const CWnd *wnd, const char *name, bool controlBar) +{ + HKEY hKey; + nlverify (RegCreateKey (HKEY_CURRENT_USER, GEORGES_EDIT_BASE_REG_KEY"\\Windows states", &hKey) == ERROR_SUCCESS); + + // Get the position + WINDOWPLACEMENT wndpl; + wnd->GetWindowPlacement( &wndpl ); + + // Set the registry + nlverify (RegSetValueEx (hKey, name, 0, REG_BINARY, (BYTE*)&wndpl, sizeof(WINDOWPLACEMENT)) == ERROR_SUCCESS); + + // Close the key + nlverify (RegCloseKey (hKey) == ERROR_SUCCESS); +} + +void CGeorgesEditApp::loadWindowState (CWnd *wnd, const char *name, bool mdiChildWnd, bool controlBar) +{ + HKEY hKey; + if (RegOpenKey (HKEY_CURRENT_USER, GEORGES_EDIT_BASE_REG_KEY"\\Windows states", &hKey) == ERROR_SUCCESS) + { + // Get the value + WINDOWPLACEMENT wndpl; + DWORD type; + DWORD len = sizeof (WINDOWPLACEMENT); + + // Get from the registry + if (RegQueryValueEx (hKey, name, 0, &type, (BYTE*)&wndpl, &len) == ERROR_SUCCESS) + { + // Length ok ? + if (len == sizeof (WINDOWPLACEMENT)) + { + // Set window placement + + // Other children + if (mdiChildWnd) + { + wndpl.showCmd = SW_SHOW; + wnd->SetWindowPos (NULL, 0, 0, wndpl.rcNormalPosition.right-wndpl.rcNormalPosition.left, + wndpl.rcNormalPosition.bottom-wndpl.rcNormalPosition.top, SWP_NOMOVE|SWP_NOZORDER|SWP_NOOWNERZORDER); + } + else + { + wnd->SetWindowPlacement( &wndpl ); + } + } + } + + nlverify (RegCloseKey (hKey) == ERROR_SUCCESS); + } +} + +void CGeorgesEditApp::saveState () +{ + // Save the main window state + nlassert (m_pMainWnd); + if (ResizeMain) + saveWindowState (m_pMainWnd, "main", false); + + saveWindowState (&((CMainFrame*)m_pMainWnd)->FileBrowser, "browser", true); + saveWindowState (&((CMainFrame*)m_pMainWnd)->OutputConsole, "output", true); +} + +void CGeorgesEditApp::loadState () +{ + nlassert (m_pMainWnd); + if (ResizeMain) + loadWindowState (m_pMainWnd, "main", false, false); + + loadWindowState (&((CMainFrame*)m_pMainWnd)->FileBrowser, "browser", false, true); + loadWindowState (&((CMainFrame*)m_pMainWnd)->OutputConsole, "output", false, true); +} + +void CGeorgesEditApp::OnFileSaveAll() +{ + SaveAllModified (); +} + +void CGeorgesEditApp::OnFileCloseAll() +{ + SaveAllModified (); + CloseAllDocuments (FALSE); +} + +void CGeorgesEditApp::OnUpdateFileSaveAll(CCmdUI* pCmdUI) +{ + pCmdUI->Enable (getActiveDocument () != NULL); +} + +bool CGeorgesEditApp::SerialIntoMemStream (const char *formName, CGeorgesEditDoc *doc, uint slot, bool copyToClipboard) +{ + // Ok, get the node + const CFormDfn *parentDfn; + uint lastElement; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + bool parentVDfnArray; + nlverify (((const CFormElm*)(doc->getRootNode (slot)))->getNodeByName ( formName, &parentDfn, lastElement, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND)); + + // Output mode + if (MemStream.isReading ()) + MemStream.invert (); + + // Init the stream + MemStream.clear (); + + // Create a serial + COXml serialOutput; + serialOutput.init (&MemStream); + + // Catch some prb + try + { + // Serial the string + string name; + if (parentDfn) + name = parentDfn->getEntry(lastElement).getFilename (); + else + { + // Get the string + CString str = doc->GetPathName (); + name = str; + uint pos = name.rfind ('.'); + if (pos != string::npos) + { + // Keep the extension + name = name.substr (pos+1); + name += ".dfn"; + } + } + MemStream.serial (name); + + // Data presents ? + bool presents = node != NULL; + + // Serial the flag + MemStream.serial (presents); + + if (presents) + { + // Serial the buffer + xmlNodePtr nodeXml = xmlNewDocNode (serialOutput.getDocument (), NULL, (const xmlChar*)"CLIPBOARD", NULL); + xmlDocSetRootElement (serialOutput.getDocument (), nodeXml); + + // Struct type ? + if (node) + { + if (array) + { + (safe_cast (node))->write (nodeXml, doc->getFormPtr(), NULL); + } + else + { + if (type == UFormDfn::EntryDfn) + { + (safe_cast (node))->write (nodeXml, doc->getFormPtr(), NULL); + } + else if (type == UFormDfn::EntryVirtualDfn) + { + (safe_cast (node))->write (nodeXml, doc->getFormPtr(), NULL); + } + else if (type == UFormDfn::EntryType) + { + (safe_cast (node))->write (nodeXml, doc->getFormPtr(), NULL); + } + } + } + else + { + (safe_cast (node))->write (nodeXml, doc->getFormPtr(), NULL); + } + } + + // Flush the XML stream + serialOutput.flush (); + + // Debug test + /* FILE *output = fopen ("c:\\toto.txt", "wb"); + fwrite ((void*)MemStream.buffer (), 1, MemStream.length (), output); + fclose (output); */ + + // Write to clipboard + if (copyToClipboard) + { + // Is an array ? + if (array) + { + ((CMainFrame*)m_pMainWnd)->dataToClipboard (FormClipBoardFormatArray, (void*)MemStream.buffer (), + MemStream.length ()); + } + else + { + // Dfn ? + if (type == UFormDfn::EntryDfn ) + { + ((CMainFrame*)m_pMainWnd)->dataToClipboard (FormClipBoardFormatStruct, (void*)MemStream.buffer (), + MemStream.length ()); + } + // Virtual Dfn ? + else if (parentDfn && type == UFormDfn::EntryVirtualDfn && !array) + { + ((CMainFrame*)m_pMainWnd)->dataToClipboard (FormClipBoardFormatVirtualStruct, (void*)MemStream.buffer (), + MemStream.length ()); + } + // Type ? + else // if (parentDfn && type == UFormDfn::EntryType && !array) + { + ((CMainFrame*)m_pMainWnd)->dataToClipboard (FormClipBoardFormatType, (void*)MemStream.buffer (), + MemStream.length ()); + } + } + } + + // Ok + return true; + } + catch (Exception &) + { + nlstop; + } + + // Not ok + return false; +} + +void CGeorgesEditApp::FillMemStreamWithBuffer (const uint8 *buffer, uint size) +{ + // Input mode + if (!theApp.MemStream.isReading ()) + theApp.MemStream.invert (); + + // Init the stream + theApp.MemStream.clear (); + + // Buffer to fill + uint8 *bufferPtr = theApp.MemStream.bufferToFill (size); + memcpy (bufferPtr, buffer, size); +} + +bool CGeorgesEditApp::FillMemStreamWithClipboard (const char *formName, CGeorgesEditDoc *doc, uint slot) +{ + // Input mode + if (!theApp.MemStream.isReading ()) + theApp.MemStream.invert (); + + // The form pointer + CForm *form = doc->getFormPtr (); + + // Ok, get the node + const CFormDfn *parentDfn; + uint lastElement; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + bool parentVDfnArray; + nlverify (((CFormElm*)doc->getRootNode(slot))->getNodeByName ( formName, &parentDfn, + lastElement, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND)); + + // Get the clipboard type + UINT clipboardType; + if (array) + clipboardType = theApp.FormClipBoardFormatArray; + else if (type == UFormDfn::EntryType) + clipboardType = theApp.FormClipBoardFormatType; + else if (type == UFormDfn::EntryDfn) + clipboardType = theApp.FormClipBoardFormatStruct; + else // if (type == UFormDfn::EntryVirtualDfn) + clipboardType = theApp.FormClipBoardFormatVirtualStruct; + + // Get the clipboard size + uint size; + + // Get the clipboard size + if (((CMainFrame*)theApp.m_pMainWnd)->clipboardSize (clipboardType, size)) + { + // Init the stream + theApp.MemStream.clear (); + + // Fill the input buffer + uint8 *bufferPtr = theApp.MemStream.bufferToFill (size); + nlverify (((CMainFrame*)theApp.m_pMainWnd)->dataFromClipboard (clipboardType, bufferPtr)); + return true; + } + else + return false; +} + +bool CGeorgesEditApp::SerialFromMemStream (const char *formName, CGeorgesEditDoc *doc, uint slot) +{ + // The form pointer + CForm *form = doc->getFormPtr (); + + // Ok, get the node + const CFormDfn *parentDfn; + uint lastElement; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + bool parentVDfnArray; + nlverify (((CFormElm*)(doc->getRootNode (slot)))->getNodeByName ( formName, &parentDfn, + lastElement, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND)); + + // Get the clipboard type + UINT clipboardType; + if (array) + clipboardType = theApp.FormClipBoardFormatArray; + else if (type == UFormDfn::EntryType) + clipboardType = theApp.FormClipBoardFormatType; + else if (type == UFormDfn::EntryDfn) + clipboardType = theApp.FormClipBoardFormatStruct; + else // if (type == UFormDfn::EntryVirtualDfn) + clipboardType = theApp.FormClipBoardFormatVirtualStruct; + + // Catch some prb + try + { + // Serial the string + string nameParent; + string name; + if (parentDfn) + nameParent = parentDfn->getEntry(lastElement).getFilename (); + else + { + // Get the string + CString str = doc->GetPathName (); + nameParent = str; + uint pos = nameParent.rfind ('.'); + if (pos != string::npos) + { + // Keep the extension + nameParent = nameParent.substr (pos+1); + nameParent += ".dfn"; + } + } + theApp.MemStream.serial (name); + + // Same DFN ? + if (name == nameParent) + { + // Is in the clipboard + bool present; + theApp.MemStream.serial (present); + + // Is present + if (present) + { + // Create the node + bool created; + nlverify (((CFormElm*)(doc->getRootNode (slot)))->createNodeByName ( formName, &parentDfn, + lastElement, &nodeDfn, &nodeType, &node, type, array, created)); + + // For struct + if (clipboardType == theApp.FormClipBoardFormatStruct) + { + // Struct pointer + CFormElmStruct *formStruct = safe_cast((CFormElm*)node); + + // Create a serial + CIXml serialInput; + serialInput.init (theApp.MemStream); + + // Clean the node + formStruct->clean (); + + // Serial it + + // Get first struct node + xmlNodePtr nodeXml = CIXml::getFirstChildNode (serialInput.getRootNode (), "STRUCT"); + if (nodeXml) + { + formStruct->read (nodeXml, doc->FormLoader, (CFormDfn*)nodeDfn, form); + } + } + // For array + else if (clipboardType == theApp.FormClipBoardFormatArray) + { + // Struct pointer + CFormElmArray *formArray = safe_cast((CFormElm*)node); + + // Create a serial + CIXml serialInput; + serialInput.init (theApp.MemStream); + + // Clean the node + formArray->clean (); + + // Serial it + + // Get first struct node + xmlNodePtr nodeXml = CIXml::getFirstChildNode (serialInput.getRootNode (), "ARRAY"); + if (nodeXml) + { + // Should be a type or a DFN + nlassert ((nodeType) || (nodeDfn)); + formArray->read (nodeXml, doc->FormLoader, form); + } + } + // For atom + else if (clipboardType == theApp.FormClipBoardFormatType) + { + // Struct pointer + CFormElmAtom *formAtom = safe_cast((CFormElm*)node); + + // Create a serial + CIXml serialInput; + serialInput.init (theApp.MemStream); + + // Serial it + + // Get first struct node + xmlNodePtr nodeXml = CIXml::getFirstChildNode (serialInput.getRootNode (), "ATOM"); + if (nodeXml) + { + // Should be a type + nlassert (nodeType); + formAtom->read (nodeXml, doc->FormLoader, (CType*)nodeType, form); + } + } + // For virtual struct + else if (clipboardType == theApp.FormClipBoardFormatVirtualStruct) + { + // Struct pointer + CFormElmVirtualStruct *vitualStruct = safe_cast((CFormElm*)node); + + // Create a serial + CIXml serialInput; + serialInput.init (theApp.MemStream); + + // Clean the node + vitualStruct->clean (); + + // Serial it + + // Get first struct node + xmlNodePtr nodeXml = CIXml::getFirstChildNode (serialInput.getRootNode (), "VSTRUCT"); + if (nodeXml) + { + vitualStruct->read (nodeXml, doc->FormLoader, form); + } + } + } // if (present) + else + { + // Does the node exist ? + // Ok, get the node + const CFormDfn *parentDfn; + uint lastElement; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + bool parentVDfnArray; + if (((CFormElm*)(doc->getRootNode (slot)))->getNodeByName ( formName, &parentDfn, + lastElement, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND)) + { + // Delete the node if it exist in this form + if (node && (node->getForm () == doc->getFormPtr ()) ) + { + nlverify (((CFormElm*)(doc->getRootNode (slot)))->deleteNodeByName ( formName, &parentDfn, + lastElement, &nodeDfn, &nodeType, &node, type, array)); + } + } + } + + // Not ok + return true; + } + } + catch (Exception &e) + { + nlwarning ("Error while paste: %s", e.what()); + } + + // Not ok + return false; +} + +BOOL CGeorgesEditApp::OnDDECommand(LPTSTR lpszCommand) +{ + if (strncmp (lpszCommand, "Open", 4) == 0) + { + string name = lpszCommand; + name = name.substr (6, name.size ()-8); + OpenDocumentFile (name.c_str ()); + } + else if (strncmp (lpszCommand, "Georges Copy", 4) == 0) + { + // Get ext name + string name = lpszCommand; + name = name.substr (6, name.size ()-8); + + // Get the extension + char ext[MAX_PATH]; + _splitpath (name.c_str (), NULL, NULL, NULL, ext); + string dfnName = string (ext+1) + ".dfn"; + + // Get the doc template + CMultiDocTemplate *docTemplate = getFormDocTemplate (dfnName.c_str ()); + + if (docTemplate) + { + // Create a new document + CGeorgesEditDocForm *doc = (CGeorgesEditDocForm*)docTemplate->CreateNewDocument(); + nlassert (doc); + nlassert (doc->isForm ()); + + // Create the frame + CFrameWnd* pFrame = docTemplate->CreateNewFrame(doc, NULL); + nlassert (pFrame); + if (doc->loadFormFile (name.c_str ())) + { + + doc->updateDocumentStructure (); + + // Init the frame + docTemplate->InitialUpdateFrame (pFrame, doc, TRUE); + + // Init the document + if (doc->initDocument (dfnName.c_str (), false)) + { + doc->changeSubSelection ((CGeorgesEditDocSub *)NULL, NULL); + doc->UpdateAllViews (NULL); + } + else + { + docTemplate->RemoveDocument( doc ); + doc = NULL; + char tmp[512]; + smprintf (tmp, 512, "Can't open document '%s'.", name.c_str ()); + outputError (tmp); + } + } + else + { + docTemplate->RemoveDocument( doc ); + doc = NULL; + char tmp[512]; + smprintf (tmp, 512, "Can't open document '%s'.", name.c_str ()); + outputError (tmp); + } + } + else + { + char tmp[512]; + smprintf (tmp, 512, "Can't open document '%s'.", name.c_str ()); + outputError (tmp); + } + } + else if (strncmp (lpszCommand, "Derive", 6) == 0) + { + // Get ext name + string name = lpszCommand; + name = name.substr (8, name.size ()-10); + + // Get the extension + char ext[MAX_PATH]; + _splitpath (name.c_str (), NULL, NULL, NULL, ext); + string dfnName = string (ext+1) + ".dfn"; + + // Create a document + CGeorgesEditDocForm *doc = (CGeorgesEditDocForm*)createDocument (dfnName.c_str (), ""); + if (doc) + { + char nameFile[MAX_PATH]; + char extFile[MAX_PATH]; + _splitpath (name.c_str (), NULL, NULL, nameFile, extFile); + doc->addParent ((string (nameFile) + extFile).c_str ()); + doc->updateDocumentStructure (); + doc->UpdateAllViews (NULL); + } + else + { + char tmp[512]; + smprintf (tmp, 512, "Can't derive from document '%s'.", name.c_str ()); + outputError (tmp); + } + } + else if (strncmp (lpszCommand, "CreateForm", 10) == 0) + { + // Get ext name + string name = lpszCommand; + name = name.substr (10, name.size ()-12); + + // Get the extension + char name2[MAX_PATH]; + char ext[MAX_PATH]; + _splitpath (name.c_str (), NULL, NULL, name2, ext); + string dfnName = name2; + dfnName += ext; + + // Create a document + CGeorgesEditDocForm *doc = (CGeorgesEditDocForm*)createDocument (dfnName.c_str (), ""); + if (doc) + { + doc->updateDocumentStructure (); + doc->UpdateAllViews (NULL); + } + else + { + char tmp[512]; + smprintf (tmp, 512, "Can't create a file from dfn '%s'.", name.c_str ()); + outputError (tmp); + } + } + return CWinApp::OnDDECommand(lpszCommand); +} + +CMultiDocTemplate *CGeorgesEditApp::getFormDocTemplate (const char *dfnName) +{ + if (Superuser) + { + return _TemplateForm; + } + else + { + POSITION pos = GetFirstDocTemplatePosition (); + while (pos) + { + // Get the template + CMyMultiDocTemplate *docTemp = safe_cast (GetNextDocTemplate(pos)); + + // Check its dfn name + std::string dfnNameTemplate; + docTemp->getDfnName (dfnNameTemplate); + if (dfnName == dfnNameTemplate) + return docTemp; + } + } + + // Not found + return NULL; } \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_dll/georges_edit.h b/code/ryzom/tools/leveldesign/georges_dll/georges_edit.h index e9354cf57..ec70cf093 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/georges_edit.h +++ b/code/ryzom/tools/leveldesign/georges_dll/georges_edit.h @@ -1,229 +1,229 @@ -// 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 . - -#if !defined(AFX_GEORGES_EDIT_H__F5294DDC_52AF_4A4A_BF08_7EAD2A36B084__INCLUDED_) -#define AFX_GEORGES_EDIT_H__F5294DDC_52AF_4A4A_BF08_7EAD2A36B084__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#ifndef __AFXWIN_H__ - #error include 'stdafx.h' before including this file for PCH -#endif - -#include "nel/misc/rgba.h" -#include "nel/misc/mem_stream.h" -#include "nel/misc/config_file.h" -#include "plugin_interface.h" -#include "imagelist_ex.h" - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// CGeorgesEditApp: -// See georges_edit.cpp for the implementation of this class -// - -#define GEORGES_EDIT_BASE_REG_KEY "Software\\Nevrax\\Georges Edit" -#define GEORGES_EDIT_BROWSE_LABEL "--- Browse..." - -extern const char* TypeFilter; -extern const char* DfnFilter; - -class CGeorgesEditDoc; - -// Doc template used by Georges in User mode -class CMyMultiDocTemplate : public CMultiDocTemplate -{ -public: - - // Constructor - CMyMultiDocTemplate (const char *ext, UINT nIDResource, CRuntimeClass* pDocClass, CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass); - - // Get dfn name for this form - void getDfnName (std::string &dfnName); - -protected: - - // Get doc string - virtual BOOL GetDocString(CString& rString, enum DocStringIndex index) const; - - std::string _Ext; - std::string _ExtMaj; -}; - -class CGeorgesEditApp : public CWinApp, public NLGEORGES::IEdit -{ -public: - CGeorgesEditApp(); - ~CGeorgesEditApp(); - - // Is a super user ? - bool Superuser; - - // Path of georges_exe.exe - std::string ExePath; - - // Root of search path for the forms, dfn and types - std::string RootSearchPath; - - // Type and dfn sub directory relative to RootSearchPath - std::string TypeDfnSubDirectory; - - // Default type inserted in list - std::string DefaultType; - - // Default type inserted in list - std::string DefaultDfn; - - // Remember list size per widget - uint RememberListSize; - - // Max undo backup - uint MaxUndo; - - // If true, expand document's content node at loading - bool StartExpanded; - - // Georges for CVS - bool Georges4CVS; - - // Clipboards ID - UINT FormClipBoardFormatStruct; - UINT FormClipBoardFormatVirtualStruct; - UINT FormClipBoardFormatArray; - UINT FormClipBoardFormatType; - - // Plugins info - std::vector PluginsNames; - std::vector UserTypes; - - // Resize and save main window size - bool ResizeMain; - bool ExeStandalone; - - // The config file loaded. - NLMISC::CConfigFile ConfigFile; - -public: - // Memory stream - NLMISC::CMemStream MemStream; - bool FillMemStreamWithClipboard (const char *formName, CGeorgesEditDoc *doc, uint slot); - void FillMemStreamWithBuffer (const uint8 *buffer, uint size); - - bool SerialIntoMemStream (const char *formName, CGeorgesEditDoc *doc, uint slot, bool copyToClipboard); - bool SerialFromMemStream (const char *formName, CGeorgesEditDoc *doc, uint slot); - - // Init - BOOL initInstance (int nCmdShow, bool exeStandalone, int x, int y, int cx, int cy); - - // On new view updated - void onNewDocView (CGeorgesEditDoc *doc); - - // Is the plugin activated ? - bool isPluginActivated (NLGEORGES::IEditPlugin *plugin) const; - - // From IEdit - NLGEORGES::IEditDocument *getActiveDocument (); - NLGEORGES::IEditDocument *createDocument (const char *dfnName, const char *pathName); - virtual void getSearchPath (std::string &searchPath); - virtual NLMISC::CConfigFile &getConfigFile() { return ConfigFile; } - - // Save / restaure state - void saveState (); - void loadState (); - - // Save the doc templace - CMultiDocTemplate *_TemplateForm; - CMultiDocTemplate *_TemplateType; - CMultiDocTemplate *_TemplateDfn; - - // The image list - CImageListEx ImageList; - - // Get a template form - CMultiDocTemplate *getFormDocTemplate (const char *dfnName); - - void saveWindowState (const CWnd *wnd, const char *name, bool controlBar); - void loadWindowState (CWnd *wnd, const char *name, bool changeShowWindow, bool controlBar); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CGeorgesEditApp) - public: - virtual BOOL InitInstance(); - virtual int ExitInstance(); - virtual void WinHelp(DWORD dwData, UINT nCmd = HELP_CONTEXT); - virtual BOOL OnDDECommand(LPTSTR lpszCommand); - //}}AFX_VIRTUAL - - // Config functions - bool loadCfg (); - bool saveCfg (); - void initCfg (); - void loadPlugins (); - void releasePlugins (); - - // Dialog function - void outputError (const char* message); - bool yesNo (const char* message); - bool getColor (NLMISC::CRGBA &color); - - // Browse an URL - void gotoURL (LPCTSTR url); - - // Utility function - static void getConfigFilePath (std::string &output); - - // Plugin list - class CPlugin - { - public: - // Constructor - CPlugin (HINSTANCE hModule, NLGEORGES::IEditPlugin *plugin); - - // Activated ? - bool Activated; - - // Module of the plugin - HINSTANCE PluginModule; - - // Plugin interface - NLGEORGES::IEditPlugin *PluginInterface; - }; - std::vector PluginArray; - - -// Implementation - //{{AFX_MSG(CGeorgesEditApp) - afx_msg void OnAppAbout(); - afx_msg void OnViewRefresh(); - afx_msg void OnFileSaveAll(); - afx_msg void OnFileCloseAll(); - afx_msg void OnUpdateFileSaveAll(CCmdUI* pCmdUI); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -extern CGeorgesEditApp theApp; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_GEORGES_EDIT_H__F5294DDC_52AF_4A4A_BF08_7EAD2A36B084__INCLUDED_) +// 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 . + +#if !defined(AFX_GEORGES_EDIT_H__F5294DDC_52AF_4A4A_BF08_7EAD2A36B084__INCLUDED_) +#define AFX_GEORGES_EDIT_H__F5294DDC_52AF_4A4A_BF08_7EAD2A36B084__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#ifndef __AFXWIN_H__ + #error include 'stdafx.h' before including this file for PCH +#endif + +#include "nel/misc/rgba.h" +#include "nel/misc/mem_stream.h" +#include "nel/misc/config_file.h" +#include "plugin_interface.h" +#include "imagelist_ex.h" + +#include "resource.h" // main symbols + +///////////////////////////////////////////////////////////////////////////// +// CGeorgesEditApp: +// See georges_edit.cpp for the implementation of this class +// + +#define GEORGES_EDIT_BASE_REG_KEY "Software\\Nevrax\\Georges Edit" +#define GEORGES_EDIT_BROWSE_LABEL "--- Browse..." + +extern const char* TypeFilter; +extern const char* DfnFilter; + +class CGeorgesEditDoc; + +// Doc template used by Georges in User mode +class CMyMultiDocTemplate : public CMultiDocTemplate +{ +public: + + // Constructor + CMyMultiDocTemplate (const char *ext, UINT nIDResource, CRuntimeClass* pDocClass, CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass); + + // Get dfn name for this form + void getDfnName (std::string &dfnName); + +protected: + + // Get doc string + virtual BOOL GetDocString(CString& rString, enum DocStringIndex index) const; + + std::string _Ext; + std::string _ExtMaj; +}; + +class CGeorgesEditApp : public CWinApp, public NLGEORGES::IEdit +{ +public: + CGeorgesEditApp(); + ~CGeorgesEditApp(); + + // Is a super user ? + bool Superuser; + + // Path of georges_exe.exe + std::string ExePath; + + // Root of search path for the forms, dfn and types + std::string RootSearchPath; + + // Type and dfn sub directory relative to RootSearchPath + std::string TypeDfnSubDirectory; + + // Default type inserted in list + std::string DefaultType; + + // Default type inserted in list + std::string DefaultDfn; + + // Remember list size per widget + uint RememberListSize; + + // Max undo backup + uint MaxUndo; + + // If true, expand document's content node at loading + bool StartExpanded; + + // Georges for CVS + bool Georges4CVS; + + // Clipboards ID + UINT FormClipBoardFormatStruct; + UINT FormClipBoardFormatVirtualStruct; + UINT FormClipBoardFormatArray; + UINT FormClipBoardFormatType; + + // Plugins info + std::vector PluginsNames; + std::vector UserTypes; + + // Resize and save main window size + bool ResizeMain; + bool ExeStandalone; + + // The config file loaded. + NLMISC::CConfigFile ConfigFile; + +public: + // Memory stream + NLMISC::CMemStream MemStream; + bool FillMemStreamWithClipboard (const char *formName, CGeorgesEditDoc *doc, uint slot); + void FillMemStreamWithBuffer (const uint8 *buffer, uint size); + + bool SerialIntoMemStream (const char *formName, CGeorgesEditDoc *doc, uint slot, bool copyToClipboard); + bool SerialFromMemStream (const char *formName, CGeorgesEditDoc *doc, uint slot); + + // Init + BOOL initInstance (int nCmdShow, bool exeStandalone, int x, int y, int cx, int cy); + + // On new view updated + void onNewDocView (CGeorgesEditDoc *doc); + + // Is the plugin activated ? + bool isPluginActivated (NLGEORGES::IEditPlugin *plugin) const; + + // From IEdit + NLGEORGES::IEditDocument *getActiveDocument (); + NLGEORGES::IEditDocument *createDocument (const char *dfnName, const char *pathName); + virtual void getSearchPath (std::string &searchPath); + virtual NLMISC::CConfigFile &getConfigFile() { return ConfigFile; } + + // Save / restaure state + void saveState (); + void loadState (); + + // Save the doc templace + CMultiDocTemplate *_TemplateForm; + CMultiDocTemplate *_TemplateType; + CMultiDocTemplate *_TemplateDfn; + + // The image list + CImageListEx ImageList; + + // Get a template form + CMultiDocTemplate *getFormDocTemplate (const char *dfnName); + + void saveWindowState (const CWnd *wnd, const char *name, bool controlBar); + void loadWindowState (CWnd *wnd, const char *name, bool changeShowWindow, bool controlBar); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CGeorgesEditApp) + public: + virtual BOOL InitInstance(); + virtual int ExitInstance(); + virtual void WinHelp(DWORD dwData, UINT nCmd = HELP_CONTEXT); + virtual BOOL OnDDECommand(LPTSTR lpszCommand); + //}}AFX_VIRTUAL + + // Config functions + bool loadCfg (); + bool saveCfg (); + void initCfg (); + void loadPlugins (); + void releasePlugins (); + + // Dialog function + void outputError (const char* message); + bool yesNo (const char* message); + bool getColor (NLMISC::CRGBA &color); + + // Browse an URL + void gotoURL (LPCTSTR url); + + // Utility function + static void getConfigFilePath (std::string &output); + + // Plugin list + class CPlugin + { + public: + // Constructor + CPlugin (HINSTANCE hModule, NLGEORGES::IEditPlugin *plugin); + + // Activated ? + bool Activated; + + // Module of the plugin + HINSTANCE PluginModule; + + // Plugin interface + NLGEORGES::IEditPlugin *PluginInterface; + }; + std::vector PluginArray; + + +// Implementation + //{{AFX_MSG(CGeorgesEditApp) + afx_msg void OnAppAbout(); + afx_msg void OnViewRefresh(); + afx_msg void OnFileSaveAll(); + afx_msg void OnFileCloseAll(); + afx_msg void OnUpdateFileSaveAll(CCmdUI* pCmdUI); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +extern CGeorgesEditApp theApp; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_GEORGES_EDIT_H__F5294DDC_52AF_4A4A_BF08_7EAD2A36B084__INCLUDED_) diff --git a/code/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.cpp b/code/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.cpp index e637bb44e..4255273bf 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.cpp @@ -1,1681 +1,1681 @@ -// 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 "stdafx.h" -#include "georges_edit.h" -#include "georges_edit_doc.h" -#include "georges_edit_view.h" -#include "main_frm.h" -#include "left_view.h" -#include "child_frm.h" -#include "action.h" -#include "reg_shell_ext.h" - -#include "nel/misc/file.h" -#include "nel/misc/o_xml.h" -#include "nel/misc/path.h" - -#include "nel/georges/form.h" - -using namespace NLMISC; -using namespace NLGEORGES; - -using namespace std; -using namespace NLGEORGES; - - -// *************************************************************************** -// CGeorgesEditDoc -// *************************************************************************** - -IMPLEMENT_DYNCREATE(CGeorgesEditDocType, CDocument) -IMPLEMENT_DYNCREATE(CGeorgesEditDocDfn, CDocument) -IMPLEMENT_DYNCREATE(CGeorgesEditDocForm, CDocument) - -// *************************************************************************** - -BEGIN_MESSAGE_MAP(CGeorgesEditDoc, CDocument) - //{{AFX_MSG_MAP(CGeorgesEditDoc) - ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_ALL, OnUpdateFileSaveAll) - ON_COMMAND(ID_EDIT_UNDO, OnEditUndo) - ON_UPDATE_COMMAND_UI(ID_EDIT_UNDO, OnUpdateEditUndo) - ON_COMMAND(ID_EDIT_REDO, OnEditRedo) - ON_UPDATE_COMMAND_UI(ID_EDIT_REDO, OnUpdateEditRedo) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// *************************************************************************** - -BEGIN_MESSAGE_MAP(CGeorgesEditDocType, CDocument) - //{{AFX_MSG_MAP(CGeorgesEditDocType) - // NOTE - the ClassWizard will add and remove mapping macros here. - // DO NOT EDIT what you see in these blocks of generated code! - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// *************************************************************************** - -BEGIN_MESSAGE_MAP(CGeorgesEditDocDfn, CDocument) - //{{AFX_MSG_MAP(CGeorgesEditDocDfn) - // NOTE - the ClassWizard will add and remove mapping macros here. - // DO NOT EDIT what you see in these blocks of generated code! - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// *************************************************************************** - -BEGIN_MESSAGE_MAP(CGeorgesEditDocForm, CDocument) - //{{AFX_MSG_MAP(CGeorgesEditDocForm) - ON_COMMAND(ID_EDIT_FETCH1, OnEditFetch1) - ON_COMMAND(ID_EDIT_FETCH3, OnEditFetch3) - ON_COMMAND(ID_EDIT_FETCH4, OnEditFetch4) - ON_COMMAND(ID_EDIT_FETCH2, OnEditFetch2) - ON_COMMAND(ID_EDIT_HOLD1, OnEditHold1) - ON_COMMAND(ID_EDIT_HOLD2, OnEditHold2) - ON_COMMAND(ID_EDIT_HOLD3, OnEditHold3) - ON_COMMAND(ID_EDIT_HOLD4, OnEditHold4) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// *************************************************************************** -// CGeorgesEditDoc construction/destruction -// *************************************************************************** - -CGeorgesEditDoc::CGeorgesEditDoc() -{ - NoModification = false; - _UndoModify = 0; -} - -// *************************************************************************** - -CGeorgesEditDoc::~CGeorgesEditDoc() -{ - for (uint i=0; igetRootNode (); - } - else - { - nlassert (slot < CForm::HeldElementCount+1); - return ((CForm*)(UForm*)Form)->HeldElements[slot-1]; - } -} - -// *************************************************************************** - -bool CGeorgesEditDocForm::initDocument (const char *dfnName, bool newElement) -{ - // Load the DFN - CFormDfn *dfn = FormLoader.loadFormDfn (dfnName, false); - if (!dfn) - { - char msg[512]; - smprintf (msg, 512, "Can't load DFN '%s'", dfnName); - theApp.outputError (msg); - return false; - } - - // Set file name and title - char name[512]; - char ext[512]; - _splitpath (dfnName, NULL, NULL, name, ext); - string name2 = (const char*)(name); - name2 = strlwr (name2); - SetPathName ( ("*."+name2).c_str(), FALSE); - SetTitle ( ("New "+name2+" form").c_str() ); - - // TMp - if (newElement) - { - Form = new CForm; - - // Build the root element - ((CFormElmStruct*)getRootNode (0))->build (dfn); - - uint i; - for (i=0; ibuild (dfn); - } - - RootObject.create (CGeorgesEditDocSub::Null, "Form", 0xffffffff, "NULL", 0xffffffff); - RootObject.add (CGeorgesEditDocSub::Header, "Header", 0xffffffff, "NULL", 0xffffffff); - RootObject.add (CGeorgesEditDocSub::Form, "Content", 0xffffffff, "", 0); - uint i; - for (i=0; i (GetDocTemplate ()); - string dfnName; - docTemplate->getDfnName (dfnName); - if (initDocument (dfnName.c_str (), true)) - return TRUE; - } - - return FALSE; -} - -// *************************************************************************** -// CGeorgesEditDoc diagnostics -// *************************************************************************** - -#ifdef _DEBUG -void CGeorgesEditDoc::AssertValid() const -{ - CDocument::AssertValid(); -} - -// *************************************************************************** - -void CGeorgesEditDoc::Dump(CDumpContext& dc) const -{ - CDocument::Dump(dc); -} -#endif //_DEBUG - -// *************************************************************************** - -bool CGeorgesEditDoc::isType () const -{ - return false; -} - -// *************************************************************************** - -bool CGeorgesEditDoc::isDfn () const -{ - return false; -} - -// *************************************************************************** - -bool CGeorgesEditDoc::isForm () const -{ - return false; -} - -// *************************************************************************** - -bool CGeorgesEditDocType::isType () const -{ - return true; -} - -// *************************************************************************** - -bool CGeorgesEditDocDfn::isDfn () const -{ - return true; -} - -// *************************************************************************** - -bool CGeorgesEditDocForm::isForm () const -{ - return true; -} - -// *************************************************************************** - -CGeorgesEditDocSub *CGeorgesEditDoc::addStruct (CGeorgesEditDocSub *parent, CFormElmStruct *_struct, CFormDfn *parentDfn, - const char *name, uint structId, const char *formName, uint slot) -{ - // The form pointer - CForm *formPtr = (CForm*)(UForm*)Form; - - // Add the new node - CGeorgesEditDocSub *newNode = parent->add (CGeorgesEditDocSub::Form, name, structId, formName, slot); - - // Can be NULL in virtual DFN - if (parentDfn) - { - // Get the parents - std::vector arrayDfn; - arrayDfn.reserve (parentDfn->countParentDfn ()); - parentDfn->getParentDfn (arrayDfn); - - // For each child - uint elm=0; - for (uint dfn=0; dfngetNumEntry (); i++) - { - // Get the entry ref - CFormDfn::CEntry &entry = arrayDfn[dfn]->getEntry (i); - - // Form entry name - string entryName = (string (formName)+"."+entry.getName ()); - - // Is a struct ? - if ( (entry.getType () == UFormDfn::EntryDfn) || (entry.getType () == UFormDfn::EntryVirtualDfn) ) - { - // Is an array of struct ? - if (entry.getArrayFlag ()) - { - // Get it from the form - CFormElmArray *nextArray = NULL; - if (_struct && _struct->Elements[elm].Element) - nextArray = safe_cast (_struct->Elements[elm].Element); - - // Else, get it from the parent if we are not a virtual DFN (don't inheritate) - - // todo array of virtual struct - if (!nextArray && (entry.getType () != UFormDfn::EntryVirtualDfn) ) - { - // For each parent form - for (uint parent=0; parentgetParentCount (); parent++) - { - // Get the node by name - UFormElm *uNode; - if (formPtr->getParent (parent)->getRootNode ().getNodeByName (&uNode, entryName.c_str(), NULL, false) && uNode) - { - nextArray = safe_cast (uNode); - } - } - } - - // Add the new struct - addArray (newNode, nextArray, entry.getDfnPtr (), entry.getName().c_str(), elm, entryName.c_str (), slot); - } - else - { - // Add it - CFormElmStruct *nextForm = NULL; - - // Get it from the form - if (_struct && _struct->Elements[elm].Element) - nextForm = safe_cast (_struct->Elements[elm].Element); - - // Else, get it from the parent - if (!nextForm) - { - // For each parent form - for (uint parent=0; parentgetParentCount (); parent++) - { - // Get the node by name - UFormElm *uNode; - if (formPtr->getParent (parent)->getRootNode ().getNodeByName (&uNode, entryName.c_str(), NULL, false) && uNode) - { - nextForm = safe_cast (uNode); - } - } - } - - // Virtual Dfn pointer - CFormElmVirtualStruct *vStruct = ((entry.getType () == UFormDfn::EntryVirtualDfn) && nextForm) ? - safe_cast (nextForm) : NULL; - - // Add the new struct - addStruct (newNode, nextForm, vStruct ? vStruct->FormDfn : entry.getDfnPtr (), entry.getName().c_str(), elm, entryName.c_str(), slot); - } - } - // Array of type ? - else if ( entry.getArrayFlag () ) - { - CFormElmArray *nextArray = NULL; - - // Get it from the form - if (_struct && _struct->Elements[elm].Element) - nextArray = safe_cast (_struct->Elements[elm].Element); - - // Else, get it from the parent - if (!nextArray) - { - // For each parent form - for (uint parent=0; parentgetParentCount (); parent++) - { - // Get the node by name - UFormElm *uNode; - if (formPtr->getParent (parent)->getRootNode ().getNodeByName (&uNode, entryName.c_str(), NULL, false) && uNode) - { - nextArray = safe_cast (uNode); - } - } - } - - // Add the new array - addArray ( newNode, nextArray, NULL, entry.getName().c_str(), elm, entryName.c_str(), slot ); - } - - // Next element - elm++; - } - } - } - - return newNode; -} - -// *************************************************************************** - -CGeorgesEditDocSub *CGeorgesEditDoc::addArray (CGeorgesEditDocSub *parent, CFormElmArray *array, CFormDfn *rootDfn, - const char *name, uint structId, const char *formName, uint slot) -{ - // Add the new node - CGeorgesEditDocSub *newNode = parent->add (CGeorgesEditDocSub::Form, name, structId, formName, slot); - - // The array exist - if (array) - { - // For each array element - for (uint elm=0; elmElements.size(); elm++) - { - // The form name - char formArrayElmName[512]; - smprintf (formArrayElmName, 512, "%s[%d]", formName, elm); - - // The name - char formArrayName[512]; - if (array->Elements[elm].Name.empty ()) - { - smprintf (formArrayName, 512, "#%d", elm); - } - else - { - smprintf (formArrayName, 512, "%s", array->Elements[elm].Name.c_str()); - } - - // Is a struct - if (rootDfn) - { - // Get struct ptr - CFormElmStruct *elmPtr = array->Elements[elm].Element ? safe_cast(array->Elements[elm].Element) : NULL; - addStruct (newNode, elmPtr, rootDfn, formArrayName, elm, formArrayElmName, slot); - } - else - newNode->add (CGeorgesEditDocSub::Form, formArrayName, elm, formArrayElmName, slot); - } - } - - return newNode; -} - -// *************************************************************************** - -BOOL CGeorgesEditDoc::OnOpenDocument(LPCTSTR lpszPathName) -{ - if (!CDocument::OnOpenDocument(lpszPathName)) - return FALSE; - - // Read the file - if (isType()) - { - try - { - // Read the form with the loader - Type = FormLoader.loadType (lpszPathName); - if (!Type) - { - char msg[512]; - smprintf (msg, 512, "Error while loading Type file %s", lpszPathName); - theApp.outputError (msg); - return FALSE; - } - - updateDocumentStructure (); - - return TRUE; - } - catch (Exception &e) - { - char message[512]; - smprintf (message, 512, "Error while loading Type file: %s", e.what()); - theApp.outputError (message); - return FALSE; - } - } - else if (isDfn()) - { - try - { - // Read the form with the loader - Dfn = FormLoader.loadFormDfn (lpszPathName, true); - if (!Dfn) - { - char msg[512]; - smprintf (msg, 512, "Error while loading Dfn file %s", lpszPathName); - theApp.outputError (msg); - return FALSE; - } - - updateDocumentStructure (); - - return TRUE; - } - catch (Exception &e) - { - char message[512]; - smprintf (message, 512, "Error while loading Type file: %s", e.what()); - theApp.outputError (message); - return FALSE; - } - } - else - { - try - { - // Check form - char ext[MAX_PATH]; - _splitpath (lpszPathName, NULL, NULL, NULL, ext); - string extLower = strlwr (string (ext)); - if (!extLower.empty ()) - { - string dfnName = extLower.substr (1, string::npos) + ".dfn"; - - // Check if the file is handled - if (theApp.getFormDocTemplate (dfnName.c_str ()) == NULL) - { - char message[512]; - smprintf (message, 512, "Can't open the file '%s'.", lpszPathName); - theApp.outputError (message); - return FALSE; - } - - // Read the form with the loader - if (!loadFormFile (lpszPathName)) - return FALSE; - - if (theApp.ExeStandalone) - { - // Loaded ! Register type.. - - // Does have an icon ? -// string iconPath = CPath::lookup (extLower.substr (1, string::npos) + ".ico", false, false); -// string commandApp = "Georges.Form" + extLower; - - RegisterShellFileExt (extLower.c_str(), "Georges.Form"); - -/* - if (!iconPath.empty ()) - { - // Application path - string appPath = "\""; - appPath += theApp.ExePath; - appPath += "\""; - - const char *open = "Open(\"%1\")"; - const char *copy = "Copy(\"%1\")"; - const char *derive = "Derive(\"%1\")"; - - // Special type - RegisterApp (commandApp.c_str (), "Georges Form Files", iconPath.c_str (), 0); - RegisterAppCommand (commandApp.c_str (), "Open", (appPath+" /dde").c_str ()); - RegisterAppCommand (commandApp.c_str (), "Copy", (appPath+" /dde").c_str ()); - RegisterAppCommand (commandApp.c_str (), "Derive", (appPath+" /dde").c_str ()); - - const char *notepad = "notepad.exe \"%1\""; - RegisterAppCommand (commandApp.c_str (), "Open with notepad", notepad); - - RegisterDDECommand (commandApp.c_str (), "Open", open, theApp.m_pszExeName); - RegisterDDECommand (commandApp.c_str (), "Copy", copy, theApp.m_pszExeName); - RegisterDDECommand (commandApp.c_str (), "Derive", derive, theApp.m_pszExeName); - RegisterShellFileExt (extLower.c_str (), commandApp.c_str ()); - } - else - { - // Register with basic type - RegisterShellFileExt (extLower.c_str (), "Georges.Form"); - - // Unregister special type - UnregisterApp (commandApp.c_str ()); - } -*/ - } - - updateDocumentStructure (); - - return TRUE; - } - else - { - return FALSE; - } - } - catch (Exception &e) - { - char message[512]; - smprintf (message, 512, "Error while loading Type file: %s", e.what()); - theApp.outputError (message); - return FALSE; - } - } - - return FALSE; -} - -// *************************************************************************** - -bool CGeorgesEditDoc::loadFormFile (const char *filename) -{ - // Read the form with the loader - Form = FormLoader.loadForm (filename); - if (!Form) - { - char msg[512]; - smprintf (msg, 512, "Error while loading Form file %s", filename); - theApp.outputError (msg); - return false; - } - return true; -} - -// *************************************************************************** - -bool CGeorgesEditDoc::addParent (const char *filename) -{ - nlassert (isForm()); - UForm *parent = FormLoader.loadForm (filename); - if (!parent) - { - char msg[512]; - smprintf (msg, 512, "Can't load Form named '%s'", filename); - theApp.outputError (msg); - return false; - } - else - { - ((CForm*)(UForm*)Form)->insertParent (((CForm*)(UForm*)Form)->getParentCount (), filename, (CForm*)parent); - return true; - } -} - -// *************************************************************************** - -void CGeorgesEditDoc::updateDocumentStructure () -{ - RootObject.clean (); - - // Get left view - CLeftView *leftView = getLeftView (); - - // Backup current selection - uint selection = 0xffffffff; - if (IsWindow (*leftView)) - selection = leftView->getCurrentSelectionId (); - - // Read the file - if (isType()) - { - // Setup sub object tree - RootObject.create (CGeorgesEditDocSub::Null, "Type", 0xffffffff, "NULL", 0xffffffff); - RootObject.add (CGeorgesEditDocSub::Header, "Header", 0xffffffff, "NULL", 0xffffffff); - RootObject.add (CGeorgesEditDocSub::Type, "Content", 0xffffffff, "NULL", 0xffffffff); - } - else if (isDfn ()) - { - // Setup sub object tree - RootObject.create (CGeorgesEditDocSub::Null, "Dfn", 0xffffffff, "NULL", 0xffffffff); - RootObject.add (CGeorgesEditDocSub::Header, "Header", 0xffffffff, "NULL", 0xffffffff); - RootObject.add (CGeorgesEditDocSub::Dfn, "Content", 0xffffffff, "NULL", 0xffffffff); - } - else - { - // Setup sub object tree - RootObject.create (CGeorgesEditDocSub::Null, "Form", 0xffffffff, "NULL", 0xffffffff); - RootObject.add (CGeorgesEditDocSub::Header, "Header", 0xffffffff, "NULL", 0xffffffff); - - // Get the parents - CFormElmStruct *rootstruct = &((CForm*)(UForm*)Form)->Elements; - addStruct (&RootObject, rootstruct, rootstruct->FormDfn, "Content", 0xffffffff, "", 0); - - // Get held objects - - // Write held elements - uint i; - for (i=0; iHeldElements[i]; - addStruct (&RootObject, rootstruct, rootstruct->FormDfn, ("Hold " + toString (1+i)).c_str (), 0xffffffff, "", i+1); - } - } - - // Update left view structure - leftView->getFromDocument (); - - // Set the old selction flag - if (selection != 0xffffffff) - { - // Reselect backuped node - leftView->setCurrentSelectionId (selection); - } - else - { - // Select the content - leftView->setCurrentSelectionId (2); - } -} - -// *************************************************************************** - -BOOL CGeorgesEditDoc::OnSaveDocument(LPCTSTR lpszPathName) -{ - // Get focus - CWnd *focus = CWnd::GetFocus (); - ::SetFocus (NULL); - - // Open the filt - COFile file; - if (file.open (lpszPathName)) - { - try - { - // Xml stream - COXml xmlStream; - xmlStream.init (&file); - - if (isType()) - { - nlassert (Type != NULL); - - // Write the file - // Modified ? - if (IsModified ()) - { - Type->Header.MinorVersion++; - flushValueChange (); - } - Type->write (xmlStream.getDocument (), theApp.Georges4CVS); - modify (NULL, NULL, false); - flushValueChange (); - UpdateAllViews (NULL); - return TRUE; - } - else if (isDfn ()) - { - nlassert (Dfn != NULL); - - // Write the file - if (IsModified ()) - { - Dfn->Header.MinorVersion++; - flushValueChange (); - } - Dfn->write (xmlStream.getDocument (), lpszPathName, theApp.Georges4CVS); - modify (NULL, NULL, false); - UpdateAllViews (NULL); - return TRUE; - } - else - { - nlassert (Form != NULL); - - // Write the file - if (IsModified ()) - { - ((CForm*)(UForm*)Form)->Header.MinorVersion++; - flushValueChange (); - } - ((CForm*)(UForm*)Form)->write (xmlStream.getDocument (), lpszPathName, theApp.Georges4CVS); - if (strcmp (xmlStream.getErrorString (), "") != 0) - { - char message[512]; - smprintf (message, 512, "Error while saving file: %s", xmlStream.getErrorString ()); - theApp.outputError (message); - } - modify (NULL, NULL, false); - flushValueChange (); - UpdateAllViews (NULL); - - // Get the left view - CView* pView = getLeftView (); - - return TRUE; - } - - } - catch (Exception &e) - { - char message[512]; - smprintf (message, 512, "Error while loading file: %s", e.what()); - theApp.outputError (message); - return FALSE; - } - } - else - { - char message[512]; - smprintf (message, 512, "Can't open the file %s for writing.", lpszPathName); - theApp.outputError (message); - return FALSE; - } - - // Set focus - focus->SetFocus (); - - return FALSE; - //return CDocument::OnSaveDocument(lpszPathName); -} - -void CGeorgesEditDoc::SetPathName(LPCTSTR lpszPathName, BOOL bAddToMRU) -{ - CDocument::SetPathName(lpszPathName, bAddToMRU); - - // Notify the plugin - uint i; - for (i=0; iactivate(false); - PluginArray[i].PluginInterface->activate(true); - } - -} - - -// *************************************************************************** - -bool CGeorgesEditDoc::modify (class IAction *action, bool modified, bool setHeaderStateToModified) -{ - if (!NoModification) - { - if (modified) - { - // Do the modification - bool reallyModified; - if ((action == NULL) || action->doAction (*this, true, reallyModified, true)) - { - // Action has modified the docment ? - if (reallyModified) - { - // Is modified - setModifiedState (true); - - if (setHeaderStateToModified) - { - if (isType()) - Type->Header.State = CFileHeader::Modified; - if (isDfn ()) - Dfn->Header.State = CFileHeader::Modified; - if (isForm()) - ((CForm*)(UForm*)Form)->Header.State = CFileHeader::Modified; - } - - // Add the action - if (action) - { - _UndoBuffer.push_back (action); - _UndoModify++; - clearRedo (); - - if (_UndoModify == 0) - { - setModifiedState (false); - } - - // Resize the undo buffer - nlassert (theApp.MaxUndo > 0); - if (_UndoBuffer.size () > theApp.MaxUndo) - { - // Number of element to remove from undo list - uint toRemove = _UndoBuffer.size () - theApp.MaxUndo; - - // Delete each elements - uint i; - for (i=0; iMDIGetActive(); - - // Get the active view attached to the active MDI child window. - CView* pOldActiveView = pChild->GetActiveView(); - - pChild->RecalcLayout(); - pNewView->UpdateWindow(); - pChild->SetActiveView(pNewView); - - return pOldActiveView; -} - -// *************************************************************************** - -CGeorgesEditDocSub *CGeorgesEditDoc::getSelectedObject () -{ - CLeftView *leftView = getLeftView (); - return leftView->getSelectedObject (); -} - -// *************************************************************************** - -void CGeorgesEditDoc::changeSubSelection (CGeorgesEditDocSub *subSelection, CView *view) -{ - if (subSelection == NULL) - getLeftView ()->changeSubSelection (RootObject.getChild (1)); - else - getLeftView ()->changeSubSelection (subSelection); - - // Save modified state - NoModification = true; - - UpdateAllViews (view); - - // Save modified state - NoModification = false; - - // Notify the plugin - uint i; - for (i=0; ionNodeChanged (); - } -} - -// *************************************************************************** - -void CGeorgesEditDoc::changeSubSelection (uint subSelection, CView *view) -{ - getLeftView ()->changeSubSelection (subSelection); - - // Save modified state - NoModification = true; - - UpdateAllViews (view); - - // Save modified state - NoModification = false; - - // Notify the plugin - uint i; - for (i=0; ionNodeChanged (); - } -} - -// *************************************************************************** - -CLeftView *CGeorgesEditDoc::getLeftView () -{ - // Get the left view - POSITION pos = GetFirstViewPosition (); - if (pos) - { - CLeftView *pView = (CLeftView*)GetNextView(pos); - nlassert (pView); - return pView; - } - return NULL; -} - -// *************************************************************************** - -CGeorgesEditView *CGeorgesEditDoc::getRightView () -{ - // Get the left view - POSITION pos = GetFirstViewPosition (); - if (pos) - { - nlverify (GetNextView (pos)); - CGeorgesEditView *pView = (CGeorgesEditView*)GetNextView(pos); - nlassert (pView); - return pView; - } - return NULL; -} - -// *************************************************************************** - -CFileHeader *CGeorgesEditDoc::getHeaderPtr () -{ - if (isType ()) - return &(Type->Header); - if (isDfn ()) - return &(Dfn->Header); - if (isForm ()) - return &(((CForm*)(UForm*)Form)->Header); - nlstop; - return NULL; -} - -// *************************************************************************** - -CType *CGeorgesEditDoc::getTypePtr () -{ - return Type; -} - -// *************************************************************************** - -CFormDfn *CGeorgesEditDoc::getDfnPtr () -{ - return Dfn; -} - -// *************************************************************************** - -CForm *CGeorgesEditDoc::getFormPtr () -{ - return (CForm*)(UForm*)Form; -} - -// *************************************************************************** - -UForm* CGeorgesEditDoc::getForm () -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - - return Form; -} - -// *************************************************************************** - -void CGeorgesEditDoc::getDfnFilename (std::string &dfnName) -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - - // Get the DFN filename - CString str = GetPathName (); - char extension[512]; - _splitpath (str, NULL, NULL, NULL, extension); - dfnName = extension+1; - dfnName += ".dfn"; -} - -// *************************************************************************** - -bool CGeorgesEditDoc::getActiveNode (std::string &dfnName) -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - - CGeorgesEditDocSub *sub = getSelectedObject (); - if (sub && (sub->getFormName () != "NULL")) - { - dfnName = getSelectedObject ()->getFormName (); - return true; - } - else - { - return false; - } -} - -// *************************************************************************** - -void CGeorgesEditDoc::refreshView () -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - - getRightView ()->PostMessage (WM_UPDATE_ALL_VIEWS, 0, 0); -} - -// *************************************************************************** - -void CGeorgesEditDoc::getFilename (std::string &pathname) -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - - pathname = (const char*)GetPathName (); -} - -// *************************************************************************** - -void CGeorgesEditDoc::getTitle (std::string &title) -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - - title = (const char*)GetTitle (); -} - -// *************************************************************************** - -void CGeorgesEditDoc::bind (NLGEORGES::IEditPlugin *plugin, IEditDocumentPlugin *docInterface) -{ - // Add the plugin to the list - PluginArray.push_back (CPlugin (plugin, docInterface)); - - docInterface->dialogInit (*getLeftView ()); - docInterface->activate (theApp.isPluginActivated (plugin)); -} - -// *************************************************************************** - -void CGeorgesEditDoc::onActivateView (bool activate) -{ - uint i; - for (i=0; iactivate (activate && theApp.isPluginActivated (PluginArray[i].Plugin)); - } -} - -// *************************************************************************** - -void CGeorgesEditDoc::notifyPlugins (const char *valueName) -{ - uint i; - for (i=0; ionValueChanged (valueName); - } -} - -// *************************************************************************** - -void CGeorgesEditDoc::logValueChange (const char *valueName, const char *newValue, bool present) -{ - if (present) - { - _LastLogs[valueName] = newValue; - } - else - { - _LastLogs.erase (valueName); - } -} - -// *************************************************************************** - -void CGeorgesEditDoc::flushValueChange () -{ - CFileHeader *header = NULL; - if (isForm ()) - header = &((CForm*)(UForm*)Form)->Header; - else if (isType ()) - header = &(Type->Header); - else if (isDfn ()) - header = &(Dfn->Header); - nlassert (header); - - std::map::iterator ite = _LastLogs.begin (); - while (ite != _LastLogs.end ()) - { - header->addLog ((ite->first + " = " + ite->second).c_str ()); - ite++; - } - _LastLogs.clear (); -} - -// *************************************************************************** - -void CGeorgesEditDoc::clearUndo () -{ - uint i; - for (i=0; i<_UndoBuffer.size (); i++) - delete _UndoBuffer[i]; - _UndoBuffer.clear (); -} - -// *************************************************************************** - -void CGeorgesEditDoc::clearRedo () -{ - uint i; - for (i=0; i<_RedoBuffer.size (); i++) - delete _RedoBuffer[i]; - _RedoBuffer.clear (); -} - -// *************************************************************************** - -void CGeorgesEditDoc::OnUpdateFileSaveAll(CCmdUI* pCmdUI) -{ - pCmdUI->Enable (); -} - -// *************************************************************************** - -void CGeorgesEditDoc::OnEditUndo() -{ - if (!_UndoBuffer.empty ()) - { - // Get an action - IAction *action = _UndoBuffer.back (); - _UndoBuffer.pop_back (); - - // Undo it - bool modified; - action->doAction (*this, false, modified, false); - - // Put in the redo list - _RedoBuffer.push_back (action); - - CMDIFrameWnd* pMainWnd = (CMDIFrameWnd*)AfxGetMainWnd(); - - // Get the active MDI child window. - CMDIChildWnd* pChild = (CMDIChildWnd*)pMainWnd->MDIGetActive(); - pChild->RecalcLayout(); - pChild->UpdateWindow(); - - _UndoModify--; - if ( (_UndoModify == 0) && IsModified () ) - { - setModifiedState (false); - } - else if ( (_UndoModify != 0) && !IsModified () ) - { - setModifiedState (true); - } - } -} - -// *************************************************************************** - -void CGeorgesEditDoc::OnUpdateEditUndo(CCmdUI* pCmdUI) -{ - pCmdUI->Enable (!_UndoBuffer.empty ()); -} - -// *************************************************************************** - -void CGeorgesEditDoc::OnEditRedo() -{ - if (!_RedoBuffer.empty ()) - { - // Get an action - IAction *action = _RedoBuffer.back (); - _RedoBuffer.pop_back (); - - // Undo it - bool modified; - action->doAction (*this, true, modified, false); - - // Put in the redo list - _UndoBuffer.push_back (action); - - ((CMainFrame*)(theApp.m_pMainWnd))->RecalcLayout (); - - _UndoModify++; - if ( (_UndoModify == 0) && IsModified () ) - { - setModifiedState (false); - } - else if ( (_UndoModify != 0) && !IsModified () ) - { - setModifiedState (true); - } - } -} - -// *************************************************************************** - -void CGeorgesEditDoc::OnUpdateEditRedo (CCmdUI* pCmdUI) -{ - pCmdUI->Enable (!_RedoBuffer.empty ()); -} - -// *************************************************************************** - -void CGeorgesEditDoc::setModifiedState (bool modified) -{ - SetModifiedFlag (modified?TRUE:FALSE); - - if (modified) - { - CString title = GetTitle (); - if ( (title.GetLength()<2) || (title[title.GetLength()-1] != '*') || (title[title.GetLength()-2] != ' ') ) - SetTitle (title+" *"); - } - else - { - string title = (const char*)GetTitle (); - if ( (title.size ()>=2) && (title[title.size()-1] == '*') && (title[title.size()-2] == ' ') ) - { - title.resize (title.size () - 2); - SetTitle (title.c_str()); - } - } -} - -// *************************************************************************** - -void CGeorgesEditDoc::setValue (const char *value, const char *name, uint slot) -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - - // Document modified - modify (new CActionString (IAction::FormValue, value, *this, name, "", 0xffffffff, slot)); - - notifyPlugins (name); -} - -// *************************************************************************** -// CGeorgesEditDocSub -// *************************************************************************** - -CGeorgesEditDocSub::~CGeorgesEditDocSub () -{ - clean (); -} - -// *************************************************************************** - -void CGeorgesEditDocSub::clean () -{ - for (uint i=0; i<_Children.size(); i++) - delete _Children[i]; - _Children.clear (); -} - -// *************************************************************************** - -bool CGeorgesEditDocSub::isEditable () const -{ - switch (_Type) - { - case Header: - case Type: - case Dfn: - case Form: - return true; - } - return false; -} - -// *************************************************************************** - -CGeorgesEditDocSub::TSub CGeorgesEditDocSub::getType () const -{ - return _Type; -} - -// *************************************************************************** - -uint CGeorgesEditDocSub::getChildrenCount () -{ - return _Children.size (); -} - -// *************************************************************************** - -CGeorgesEditDocSub *CGeorgesEditDocSub::getChild (uint child) -{ - return _Children[child]; -} - -// *************************************************************************** - -void CGeorgesEditDocSub::create (TSub type, const char *name, uint structId, const char *formName, uint slot) -{ - _StructId = structId; - _Type = type; - _Name = name; - _FormName = formName; - _Slot = slot; -} - -// *************************************************************************** - -CGeorgesEditDocSub *CGeorgesEditDocSub::add (TSub type, const char *name, uint structId, const char *formName, uint slot) -{ - // Add at the end - uint index = _Children.size(); - _Children.push_back (new CGeorgesEditDocSub); - - _Children[index]->_Type = type; - _Children[index]->_Name = name; - _Children[index]->_Parent = this; - _Children[index]->_StructId = structId; - _Children[index]->_FormName = formName; - _Children[index]->_Slot = slot; - return _Children[index]; -} - -// *************************************************************************** - -CGeorgesEditDocSub::CGeorgesEditDocSub () -{ - _Parent = NULL; -} - -// *************************************************************************** - -const std::string& CGeorgesEditDocSub::getName () const -{ - return _Name; -} - -// *************************************************************************** - -// *************************************************************************** - -CGeorgesEditDocSub *CGeorgesEditDocSub::getParent () -{ - return _Parent; -} - -// *************************************************************************** - -uint CGeorgesEditDocSub::getIdInParent () const -{ - return _StructId; -} - -// *************************************************************************** - -const std::string& CGeorgesEditDocSub::getFormName () const -{ - return _FormName; -} - -// *************************************************************************** - -void CGeorgesEditDocSub::removeChildren (uint child) -{ - _Children.erase (_Children.begin()+child); -} - -// *************************************************************************** - -uint CGeorgesEditDocSub::getSlot () const -{ - return _Slot; -} - -// *************************************************************************** - -int CGeorgesEditDocSub::getItemImage (CGeorgesEditDoc *doc) const -{ - switch (_Type) - { - case Null: - nlassert (_Children.size ()>1); - if (_Children[1]->_Type == Type) - return theApp.ImageList.getImage (IDR_TYPETYPE); - if (_Children[1]->_Type == Dfn) - return theApp.ImageList.getImage (IDR_TYPEDFN); - if (_Children[1]->_Type == Form) - return theApp.ImageList.getImage (IDR_TYPEFORM); - case Header: - { - int image = theApp.ImageList.getImage ("header"); - if (image == -1) - return theApp.ImageList.getImage (IDR_HEADER); - return image; - } - case Type: - { - int image = theApp.ImageList.getImage ("type"); - if (image == -1) - return theApp.ImageList.getImage (IDR_TYPETYPE); - return image; - } - case Dfn: - { - int image = theApp.ImageList.getImage ("dfn"); - if (image == -1) - return theApp.ImageList.getImage (IDR_TYPEDFN); - return image; - } - case Form: - { - // Root ? - if ((_Parent->_Parent == NULL) && (_Parent->_Children[1] != this)) - { - int image = theApp.ImageList.getImage ("hold"); - if (image == -1) - return theApp.ImageList.getImage (IDR_HOLD); - return image; - } - - if ((_Parent->_Parent == NULL) && (_Parent->_Children[1] == this)) - { - int image = theApp.ImageList.getImage ("root"); - if (image == -1) - return theApp.ImageList.getImage (IDR_ROOT); - return image; - } - - // What kind of node ? - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - bool parentVDfnArray; - CForm *form=doc->getFormPtr (); - CFormElm *elm = doc->getRootNode (getSlot ()); - nlverify ( elm->getNodeByName (getFormName ().c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); - - if (array) - { - int image = theApp.ImageList.getImage ("array"); - if (image == -1) - return theApp.ImageList.getImage (IDR_ARRAY); - return image; - } - else - { - if (type == UFormDfn::EntryType) - { - if (parentDfn) - { - int image = theApp.ImageList.getImage (parentDfn->getEntry(indexDfn).getFilename ().c_str ()); - if (image != -1) - return image; - } - int image = theApp.ImageList.getImage ("typedoc"); - if (image == -1) - return theApp.ImageList.getImage (IDR_TYPETYPE); - return image; - } - else if (type == UFormDfn::EntryDfn) - { - if (parentDfn) - { - int image = theApp.ImageList.getImage (parentDfn->getEntry(indexDfn).getFilename ().c_str ()); - if (image != -1) - return image; - } - int image = theApp.ImageList.getImage ("struct"); - if (image == -1) - return theApp.ImageList.getImage (IDR_STRUCT); - return image; - } - else if (type == UFormDfn::EntryVirtualDfn) - { - if (node) - { - string dfnName; - safe_cast (node)->getDfnName (dfnName); - int image = theApp.ImageList.getImage (dfnName.c_str ()); - if (image != -1) - return image; - } - int image = theApp.ImageList.getImage ("vstruct"); - if (image == -1) - return theApp.ImageList.getImage (IDR_VSTRUCT); - return image; - } - } - } - default: - nlstop; - } - return 0; -} - -// *************************************************************************** -// CPlugin -// *************************************************************************** - -CGeorgesEditDoc::CPlugin::CPlugin (NLGEORGES::IEditPlugin *plugin, NLGEORGES::IEditDocumentPlugin *pluginInterface) -{ - Plugin = plugin; - PluginInterface = pluginInterface; -} - -void CGeorgesEditDocForm::OnEditFetch1() -{ - fetch (1); -} - -void CGeorgesEditDocForm::OnEditFetch3() -{ - fetch (3); -} - -void CGeorgesEditDocForm::OnEditFetch4() -{ - fetch (1); -} - -void CGeorgesEditDocForm::OnEditFetch2() -{ - fetch (2); -} - -void CGeorgesEditDocForm::OnEditHold1() -{ - hold (1); -} - -void CGeorgesEditDocForm::OnEditHold2() -{ - hold (2); -} - -void CGeorgesEditDocForm::OnEditHold3() -{ - hold (3); -} - -void CGeorgesEditDocForm::OnEditHold4() -{ - hold (4); -} - -void CGeorgesEditDocForm::fetch (uint buffer) -{ - if (theApp.yesNo (("Are you sure you want to get back hold buffer #" + toString (buffer) + " ?").c_str())) - { - theApp.SerialIntoMemStream ("", this, buffer, false); - modify (new CActionBuffer (IAction::FormPaste, theApp.MemStream.buffer (), theApp.MemStream.length(), - *this, "", "", 2, 0), NULL); - } -} - -void CGeorgesEditDocForm::hold (uint buffer) -{ - theApp.SerialIntoMemStream ("", this, 0, false); - modify (new CActionBuffer (IAction::FormPaste, theApp.MemStream.buffer (), theApp.MemStream.length(), - *this, "", "", 2, buffer), NULL); -} +// 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 "stdafx.h" +#include "georges_edit.h" +#include "georges_edit_doc.h" +#include "georges_edit_view.h" +#include "main_frm.h" +#include "left_view.h" +#include "child_frm.h" +#include "action.h" +#include "reg_shell_ext.h" + +#include "nel/misc/file.h" +#include "nel/misc/o_xml.h" +#include "nel/misc/path.h" + +#include "nel/georges/form.h" + +using namespace NLMISC; +using namespace NLGEORGES; + +using namespace std; +using namespace NLGEORGES; + + +// *************************************************************************** +// CGeorgesEditDoc +// *************************************************************************** + +IMPLEMENT_DYNCREATE(CGeorgesEditDocType, CDocument) +IMPLEMENT_DYNCREATE(CGeorgesEditDocDfn, CDocument) +IMPLEMENT_DYNCREATE(CGeorgesEditDocForm, CDocument) + +// *************************************************************************** + +BEGIN_MESSAGE_MAP(CGeorgesEditDoc, CDocument) + //{{AFX_MSG_MAP(CGeorgesEditDoc) + ON_UPDATE_COMMAND_UI(ID_FILE_SAVE_ALL, OnUpdateFileSaveAll) + ON_COMMAND(ID_EDIT_UNDO, OnEditUndo) + ON_UPDATE_COMMAND_UI(ID_EDIT_UNDO, OnUpdateEditUndo) + ON_COMMAND(ID_EDIT_REDO, OnEditRedo) + ON_UPDATE_COMMAND_UI(ID_EDIT_REDO, OnUpdateEditRedo) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +// *************************************************************************** + +BEGIN_MESSAGE_MAP(CGeorgesEditDocType, CDocument) + //{{AFX_MSG_MAP(CGeorgesEditDocType) + // NOTE - the ClassWizard will add and remove mapping macros here. + // DO NOT EDIT what you see in these blocks of generated code! + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +// *************************************************************************** + +BEGIN_MESSAGE_MAP(CGeorgesEditDocDfn, CDocument) + //{{AFX_MSG_MAP(CGeorgesEditDocDfn) + // NOTE - the ClassWizard will add and remove mapping macros here. + // DO NOT EDIT what you see in these blocks of generated code! + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +// *************************************************************************** + +BEGIN_MESSAGE_MAP(CGeorgesEditDocForm, CDocument) + //{{AFX_MSG_MAP(CGeorgesEditDocForm) + ON_COMMAND(ID_EDIT_FETCH1, OnEditFetch1) + ON_COMMAND(ID_EDIT_FETCH3, OnEditFetch3) + ON_COMMAND(ID_EDIT_FETCH4, OnEditFetch4) + ON_COMMAND(ID_EDIT_FETCH2, OnEditFetch2) + ON_COMMAND(ID_EDIT_HOLD1, OnEditHold1) + ON_COMMAND(ID_EDIT_HOLD2, OnEditHold2) + ON_COMMAND(ID_EDIT_HOLD3, OnEditHold3) + ON_COMMAND(ID_EDIT_HOLD4, OnEditHold4) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +// *************************************************************************** +// CGeorgesEditDoc construction/destruction +// *************************************************************************** + +CGeorgesEditDoc::CGeorgesEditDoc() +{ + NoModification = false; + _UndoModify = 0; +} + +// *************************************************************************** + +CGeorgesEditDoc::~CGeorgesEditDoc() +{ + for (uint i=0; igetRootNode (); + } + else + { + nlassert (slot < CForm::HeldElementCount+1); + return ((CForm*)(UForm*)Form)->HeldElements[slot-1]; + } +} + +// *************************************************************************** + +bool CGeorgesEditDocForm::initDocument (const char *dfnName, bool newElement) +{ + // Load the DFN + CFormDfn *dfn = FormLoader.loadFormDfn (dfnName, false); + if (!dfn) + { + char msg[512]; + smprintf (msg, 512, "Can't load DFN '%s'", dfnName); + theApp.outputError (msg); + return false; + } + + // Set file name and title + char name[512]; + char ext[512]; + _splitpath (dfnName, NULL, NULL, name, ext); + string name2 = (const char*)(name); + name2 = strlwr (name2); + SetPathName ( ("*."+name2).c_str(), FALSE); + SetTitle ( ("New "+name2+" form").c_str() ); + + // TMp + if (newElement) + { + Form = new CForm; + + // Build the root element + ((CFormElmStruct*)getRootNode (0))->build (dfn); + + uint i; + for (i=0; ibuild (dfn); + } + + RootObject.create (CGeorgesEditDocSub::Null, "Form", 0xffffffff, "NULL", 0xffffffff); + RootObject.add (CGeorgesEditDocSub::Header, "Header", 0xffffffff, "NULL", 0xffffffff); + RootObject.add (CGeorgesEditDocSub::Form, "Content", 0xffffffff, "", 0); + uint i; + for (i=0; i (GetDocTemplate ()); + string dfnName; + docTemplate->getDfnName (dfnName); + if (initDocument (dfnName.c_str (), true)) + return TRUE; + } + + return FALSE; +} + +// *************************************************************************** +// CGeorgesEditDoc diagnostics +// *************************************************************************** + +#ifdef _DEBUG +void CGeorgesEditDoc::AssertValid() const +{ + CDocument::AssertValid(); +} + +// *************************************************************************** + +void CGeorgesEditDoc::Dump(CDumpContext& dc) const +{ + CDocument::Dump(dc); +} +#endif //_DEBUG + +// *************************************************************************** + +bool CGeorgesEditDoc::isType () const +{ + return false; +} + +// *************************************************************************** + +bool CGeorgesEditDoc::isDfn () const +{ + return false; +} + +// *************************************************************************** + +bool CGeorgesEditDoc::isForm () const +{ + return false; +} + +// *************************************************************************** + +bool CGeorgesEditDocType::isType () const +{ + return true; +} + +// *************************************************************************** + +bool CGeorgesEditDocDfn::isDfn () const +{ + return true; +} + +// *************************************************************************** + +bool CGeorgesEditDocForm::isForm () const +{ + return true; +} + +// *************************************************************************** + +CGeorgesEditDocSub *CGeorgesEditDoc::addStruct (CGeorgesEditDocSub *parent, CFormElmStruct *_struct, CFormDfn *parentDfn, + const char *name, uint structId, const char *formName, uint slot) +{ + // The form pointer + CForm *formPtr = (CForm*)(UForm*)Form; + + // Add the new node + CGeorgesEditDocSub *newNode = parent->add (CGeorgesEditDocSub::Form, name, structId, formName, slot); + + // Can be NULL in virtual DFN + if (parentDfn) + { + // Get the parents + std::vector arrayDfn; + arrayDfn.reserve (parentDfn->countParentDfn ()); + parentDfn->getParentDfn (arrayDfn); + + // For each child + uint elm=0; + for (uint dfn=0; dfngetNumEntry (); i++) + { + // Get the entry ref + CFormDfn::CEntry &entry = arrayDfn[dfn]->getEntry (i); + + // Form entry name + string entryName = (string (formName)+"."+entry.getName ()); + + // Is a struct ? + if ( (entry.getType () == UFormDfn::EntryDfn) || (entry.getType () == UFormDfn::EntryVirtualDfn) ) + { + // Is an array of struct ? + if (entry.getArrayFlag ()) + { + // Get it from the form + CFormElmArray *nextArray = NULL; + if (_struct && _struct->Elements[elm].Element) + nextArray = safe_cast (_struct->Elements[elm].Element); + + // Else, get it from the parent if we are not a virtual DFN (don't inheritate) + + // todo array of virtual struct + if (!nextArray && (entry.getType () != UFormDfn::EntryVirtualDfn) ) + { + // For each parent form + for (uint parent=0; parentgetParentCount (); parent++) + { + // Get the node by name + UFormElm *uNode; + if (formPtr->getParent (parent)->getRootNode ().getNodeByName (&uNode, entryName.c_str(), NULL, false) && uNode) + { + nextArray = safe_cast (uNode); + } + } + } + + // Add the new struct + addArray (newNode, nextArray, entry.getDfnPtr (), entry.getName().c_str(), elm, entryName.c_str (), slot); + } + else + { + // Add it + CFormElmStruct *nextForm = NULL; + + // Get it from the form + if (_struct && _struct->Elements[elm].Element) + nextForm = safe_cast (_struct->Elements[elm].Element); + + // Else, get it from the parent + if (!nextForm) + { + // For each parent form + for (uint parent=0; parentgetParentCount (); parent++) + { + // Get the node by name + UFormElm *uNode; + if (formPtr->getParent (parent)->getRootNode ().getNodeByName (&uNode, entryName.c_str(), NULL, false) && uNode) + { + nextForm = safe_cast (uNode); + } + } + } + + // Virtual Dfn pointer + CFormElmVirtualStruct *vStruct = ((entry.getType () == UFormDfn::EntryVirtualDfn) && nextForm) ? + safe_cast (nextForm) : NULL; + + // Add the new struct + addStruct (newNode, nextForm, vStruct ? vStruct->FormDfn : entry.getDfnPtr (), entry.getName().c_str(), elm, entryName.c_str(), slot); + } + } + // Array of type ? + else if ( entry.getArrayFlag () ) + { + CFormElmArray *nextArray = NULL; + + // Get it from the form + if (_struct && _struct->Elements[elm].Element) + nextArray = safe_cast (_struct->Elements[elm].Element); + + // Else, get it from the parent + if (!nextArray) + { + // For each parent form + for (uint parent=0; parentgetParentCount (); parent++) + { + // Get the node by name + UFormElm *uNode; + if (formPtr->getParent (parent)->getRootNode ().getNodeByName (&uNode, entryName.c_str(), NULL, false) && uNode) + { + nextArray = safe_cast (uNode); + } + } + } + + // Add the new array + addArray ( newNode, nextArray, NULL, entry.getName().c_str(), elm, entryName.c_str(), slot ); + } + + // Next element + elm++; + } + } + } + + return newNode; +} + +// *************************************************************************** + +CGeorgesEditDocSub *CGeorgesEditDoc::addArray (CGeorgesEditDocSub *parent, CFormElmArray *array, CFormDfn *rootDfn, + const char *name, uint structId, const char *formName, uint slot) +{ + // Add the new node + CGeorgesEditDocSub *newNode = parent->add (CGeorgesEditDocSub::Form, name, structId, formName, slot); + + // The array exist + if (array) + { + // For each array element + for (uint elm=0; elmElements.size(); elm++) + { + // The form name + char formArrayElmName[512]; + smprintf (formArrayElmName, 512, "%s[%d]", formName, elm); + + // The name + char formArrayName[512]; + if (array->Elements[elm].Name.empty ()) + { + smprintf (formArrayName, 512, "#%d", elm); + } + else + { + smprintf (formArrayName, 512, "%s", array->Elements[elm].Name.c_str()); + } + + // Is a struct + if (rootDfn) + { + // Get struct ptr + CFormElmStruct *elmPtr = array->Elements[elm].Element ? safe_cast(array->Elements[elm].Element) : NULL; + addStruct (newNode, elmPtr, rootDfn, formArrayName, elm, formArrayElmName, slot); + } + else + newNode->add (CGeorgesEditDocSub::Form, formArrayName, elm, formArrayElmName, slot); + } + } + + return newNode; +} + +// *************************************************************************** + +BOOL CGeorgesEditDoc::OnOpenDocument(LPCTSTR lpszPathName) +{ + if (!CDocument::OnOpenDocument(lpszPathName)) + return FALSE; + + // Read the file + if (isType()) + { + try + { + // Read the form with the loader + Type = FormLoader.loadType (lpszPathName); + if (!Type) + { + char msg[512]; + smprintf (msg, 512, "Error while loading Type file %s", lpszPathName); + theApp.outputError (msg); + return FALSE; + } + + updateDocumentStructure (); + + return TRUE; + } + catch (Exception &e) + { + char message[512]; + smprintf (message, 512, "Error while loading Type file: %s", e.what()); + theApp.outputError (message); + return FALSE; + } + } + else if (isDfn()) + { + try + { + // Read the form with the loader + Dfn = FormLoader.loadFormDfn (lpszPathName, true); + if (!Dfn) + { + char msg[512]; + smprintf (msg, 512, "Error while loading Dfn file %s", lpszPathName); + theApp.outputError (msg); + return FALSE; + } + + updateDocumentStructure (); + + return TRUE; + } + catch (Exception &e) + { + char message[512]; + smprintf (message, 512, "Error while loading Type file: %s", e.what()); + theApp.outputError (message); + return FALSE; + } + } + else + { + try + { + // Check form + char ext[MAX_PATH]; + _splitpath (lpszPathName, NULL, NULL, NULL, ext); + string extLower = strlwr (string (ext)); + if (!extLower.empty ()) + { + string dfnName = extLower.substr (1, string::npos) + ".dfn"; + + // Check if the file is handled + if (theApp.getFormDocTemplate (dfnName.c_str ()) == NULL) + { + char message[512]; + smprintf (message, 512, "Can't open the file '%s'.", lpszPathName); + theApp.outputError (message); + return FALSE; + } + + // Read the form with the loader + if (!loadFormFile (lpszPathName)) + return FALSE; + + if (theApp.ExeStandalone) + { + // Loaded ! Register type.. + + // Does have an icon ? +// string iconPath = CPath::lookup (extLower.substr (1, string::npos) + ".ico", false, false); +// string commandApp = "Georges.Form" + extLower; + + RegisterShellFileExt (extLower.c_str(), "Georges.Form"); + +/* + if (!iconPath.empty ()) + { + // Application path + string appPath = "\""; + appPath += theApp.ExePath; + appPath += "\""; + + const char *open = "Open(\"%1\")"; + const char *copy = "Copy(\"%1\")"; + const char *derive = "Derive(\"%1\")"; + + // Special type + RegisterApp (commandApp.c_str (), "Georges Form Files", iconPath.c_str (), 0); + RegisterAppCommand (commandApp.c_str (), "Open", (appPath+" /dde").c_str ()); + RegisterAppCommand (commandApp.c_str (), "Copy", (appPath+" /dde").c_str ()); + RegisterAppCommand (commandApp.c_str (), "Derive", (appPath+" /dde").c_str ()); + + const char *notepad = "notepad.exe \"%1\""; + RegisterAppCommand (commandApp.c_str (), "Open with notepad", notepad); + + RegisterDDECommand (commandApp.c_str (), "Open", open, theApp.m_pszExeName); + RegisterDDECommand (commandApp.c_str (), "Copy", copy, theApp.m_pszExeName); + RegisterDDECommand (commandApp.c_str (), "Derive", derive, theApp.m_pszExeName); + RegisterShellFileExt (extLower.c_str (), commandApp.c_str ()); + } + else + { + // Register with basic type + RegisterShellFileExt (extLower.c_str (), "Georges.Form"); + + // Unregister special type + UnregisterApp (commandApp.c_str ()); + } +*/ + } + + updateDocumentStructure (); + + return TRUE; + } + else + { + return FALSE; + } + } + catch (Exception &e) + { + char message[512]; + smprintf (message, 512, "Error while loading Type file: %s", e.what()); + theApp.outputError (message); + return FALSE; + } + } + + return FALSE; +} + +// *************************************************************************** + +bool CGeorgesEditDoc::loadFormFile (const char *filename) +{ + // Read the form with the loader + Form = FormLoader.loadForm (filename); + if (!Form) + { + char msg[512]; + smprintf (msg, 512, "Error while loading Form file %s", filename); + theApp.outputError (msg); + return false; + } + return true; +} + +// *************************************************************************** + +bool CGeorgesEditDoc::addParent (const char *filename) +{ + nlassert (isForm()); + UForm *parent = FormLoader.loadForm (filename); + if (!parent) + { + char msg[512]; + smprintf (msg, 512, "Can't load Form named '%s'", filename); + theApp.outputError (msg); + return false; + } + else + { + ((CForm*)(UForm*)Form)->insertParent (((CForm*)(UForm*)Form)->getParentCount (), filename, (CForm*)parent); + return true; + } +} + +// *************************************************************************** + +void CGeorgesEditDoc::updateDocumentStructure () +{ + RootObject.clean (); + + // Get left view + CLeftView *leftView = getLeftView (); + + // Backup current selection + uint selection = 0xffffffff; + if (IsWindow (*leftView)) + selection = leftView->getCurrentSelectionId (); + + // Read the file + if (isType()) + { + // Setup sub object tree + RootObject.create (CGeorgesEditDocSub::Null, "Type", 0xffffffff, "NULL", 0xffffffff); + RootObject.add (CGeorgesEditDocSub::Header, "Header", 0xffffffff, "NULL", 0xffffffff); + RootObject.add (CGeorgesEditDocSub::Type, "Content", 0xffffffff, "NULL", 0xffffffff); + } + else if (isDfn ()) + { + // Setup sub object tree + RootObject.create (CGeorgesEditDocSub::Null, "Dfn", 0xffffffff, "NULL", 0xffffffff); + RootObject.add (CGeorgesEditDocSub::Header, "Header", 0xffffffff, "NULL", 0xffffffff); + RootObject.add (CGeorgesEditDocSub::Dfn, "Content", 0xffffffff, "NULL", 0xffffffff); + } + else + { + // Setup sub object tree + RootObject.create (CGeorgesEditDocSub::Null, "Form", 0xffffffff, "NULL", 0xffffffff); + RootObject.add (CGeorgesEditDocSub::Header, "Header", 0xffffffff, "NULL", 0xffffffff); + + // Get the parents + CFormElmStruct *rootstruct = &((CForm*)(UForm*)Form)->Elements; + addStruct (&RootObject, rootstruct, rootstruct->FormDfn, "Content", 0xffffffff, "", 0); + + // Get held objects + + // Write held elements + uint i; + for (i=0; iHeldElements[i]; + addStruct (&RootObject, rootstruct, rootstruct->FormDfn, ("Hold " + toString (1+i)).c_str (), 0xffffffff, "", i+1); + } + } + + // Update left view structure + leftView->getFromDocument (); + + // Set the old selction flag + if (selection != 0xffffffff) + { + // Reselect backuped node + leftView->setCurrentSelectionId (selection); + } + else + { + // Select the content + leftView->setCurrentSelectionId (2); + } +} + +// *************************************************************************** + +BOOL CGeorgesEditDoc::OnSaveDocument(LPCTSTR lpszPathName) +{ + // Get focus + CWnd *focus = CWnd::GetFocus (); + ::SetFocus (NULL); + + // Open the filt + COFile file; + if (file.open (lpszPathName)) + { + try + { + // Xml stream + COXml xmlStream; + xmlStream.init (&file); + + if (isType()) + { + nlassert (Type != NULL); + + // Write the file + // Modified ? + if (IsModified ()) + { + Type->Header.MinorVersion++; + flushValueChange (); + } + Type->write (xmlStream.getDocument (), theApp.Georges4CVS); + modify (NULL, NULL, false); + flushValueChange (); + UpdateAllViews (NULL); + return TRUE; + } + else if (isDfn ()) + { + nlassert (Dfn != NULL); + + // Write the file + if (IsModified ()) + { + Dfn->Header.MinorVersion++; + flushValueChange (); + } + Dfn->write (xmlStream.getDocument (), lpszPathName, theApp.Georges4CVS); + modify (NULL, NULL, false); + UpdateAllViews (NULL); + return TRUE; + } + else + { + nlassert (Form != NULL); + + // Write the file + if (IsModified ()) + { + ((CForm*)(UForm*)Form)->Header.MinorVersion++; + flushValueChange (); + } + ((CForm*)(UForm*)Form)->write (xmlStream.getDocument (), lpszPathName, theApp.Georges4CVS); + if (strcmp (xmlStream.getErrorString (), "") != 0) + { + char message[512]; + smprintf (message, 512, "Error while saving file: %s", xmlStream.getErrorString ()); + theApp.outputError (message); + } + modify (NULL, NULL, false); + flushValueChange (); + UpdateAllViews (NULL); + + // Get the left view + CView* pView = getLeftView (); + + return TRUE; + } + + } + catch (Exception &e) + { + char message[512]; + smprintf (message, 512, "Error while loading file: %s", e.what()); + theApp.outputError (message); + return FALSE; + } + } + else + { + char message[512]; + smprintf (message, 512, "Can't open the file %s for writing.", lpszPathName); + theApp.outputError (message); + return FALSE; + } + + // Set focus + focus->SetFocus (); + + return FALSE; + //return CDocument::OnSaveDocument(lpszPathName); +} + +void CGeorgesEditDoc::SetPathName(LPCTSTR lpszPathName, BOOL bAddToMRU) +{ + CDocument::SetPathName(lpszPathName, bAddToMRU); + + // Notify the plugin + uint i; + for (i=0; iactivate(false); + PluginArray[i].PluginInterface->activate(true); + } + +} + + +// *************************************************************************** + +bool CGeorgesEditDoc::modify (class IAction *action, bool modified, bool setHeaderStateToModified) +{ + if (!NoModification) + { + if (modified) + { + // Do the modification + bool reallyModified; + if ((action == NULL) || action->doAction (*this, true, reallyModified, true)) + { + // Action has modified the docment ? + if (reallyModified) + { + // Is modified + setModifiedState (true); + + if (setHeaderStateToModified) + { + if (isType()) + Type->Header.State = CFileHeader::Modified; + if (isDfn ()) + Dfn->Header.State = CFileHeader::Modified; + if (isForm()) + ((CForm*)(UForm*)Form)->Header.State = CFileHeader::Modified; + } + + // Add the action + if (action) + { + _UndoBuffer.push_back (action); + _UndoModify++; + clearRedo (); + + if (_UndoModify == 0) + { + setModifiedState (false); + } + + // Resize the undo buffer + nlassert (theApp.MaxUndo > 0); + if (_UndoBuffer.size () > theApp.MaxUndo) + { + // Number of element to remove from undo list + uint toRemove = _UndoBuffer.size () - theApp.MaxUndo; + + // Delete each elements + uint i; + for (i=0; iMDIGetActive(); + + // Get the active view attached to the active MDI child window. + CView* pOldActiveView = pChild->GetActiveView(); + + pChild->RecalcLayout(); + pNewView->UpdateWindow(); + pChild->SetActiveView(pNewView); + + return pOldActiveView; +} + +// *************************************************************************** + +CGeorgesEditDocSub *CGeorgesEditDoc::getSelectedObject () +{ + CLeftView *leftView = getLeftView (); + return leftView->getSelectedObject (); +} + +// *************************************************************************** + +void CGeorgesEditDoc::changeSubSelection (CGeorgesEditDocSub *subSelection, CView *view) +{ + if (subSelection == NULL) + getLeftView ()->changeSubSelection (RootObject.getChild (1)); + else + getLeftView ()->changeSubSelection (subSelection); + + // Save modified state + NoModification = true; + + UpdateAllViews (view); + + // Save modified state + NoModification = false; + + // Notify the plugin + uint i; + for (i=0; ionNodeChanged (); + } +} + +// *************************************************************************** + +void CGeorgesEditDoc::changeSubSelection (uint subSelection, CView *view) +{ + getLeftView ()->changeSubSelection (subSelection); + + // Save modified state + NoModification = true; + + UpdateAllViews (view); + + // Save modified state + NoModification = false; + + // Notify the plugin + uint i; + for (i=0; ionNodeChanged (); + } +} + +// *************************************************************************** + +CLeftView *CGeorgesEditDoc::getLeftView () +{ + // Get the left view + POSITION pos = GetFirstViewPosition (); + if (pos) + { + CLeftView *pView = (CLeftView*)GetNextView(pos); + nlassert (pView); + return pView; + } + return NULL; +} + +// *************************************************************************** + +CGeorgesEditView *CGeorgesEditDoc::getRightView () +{ + // Get the left view + POSITION pos = GetFirstViewPosition (); + if (pos) + { + nlverify (GetNextView (pos)); + CGeorgesEditView *pView = (CGeorgesEditView*)GetNextView(pos); + nlassert (pView); + return pView; + } + return NULL; +} + +// *************************************************************************** + +CFileHeader *CGeorgesEditDoc::getHeaderPtr () +{ + if (isType ()) + return &(Type->Header); + if (isDfn ()) + return &(Dfn->Header); + if (isForm ()) + return &(((CForm*)(UForm*)Form)->Header); + nlstop; + return NULL; +} + +// *************************************************************************** + +CType *CGeorgesEditDoc::getTypePtr () +{ + return Type; +} + +// *************************************************************************** + +CFormDfn *CGeorgesEditDoc::getDfnPtr () +{ + return Dfn; +} + +// *************************************************************************** + +CForm *CGeorgesEditDoc::getFormPtr () +{ + return (CForm*)(UForm*)Form; +} + +// *************************************************************************** + +UForm* CGeorgesEditDoc::getForm () +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + + return Form; +} + +// *************************************************************************** + +void CGeorgesEditDoc::getDfnFilename (std::string &dfnName) +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + + // Get the DFN filename + CString str = GetPathName (); + char extension[512]; + _splitpath (str, NULL, NULL, NULL, extension); + dfnName = extension+1; + dfnName += ".dfn"; +} + +// *************************************************************************** + +bool CGeorgesEditDoc::getActiveNode (std::string &dfnName) +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + + CGeorgesEditDocSub *sub = getSelectedObject (); + if (sub && (sub->getFormName () != "NULL")) + { + dfnName = getSelectedObject ()->getFormName (); + return true; + } + else + { + return false; + } +} + +// *************************************************************************** + +void CGeorgesEditDoc::refreshView () +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + + getRightView ()->PostMessage (WM_UPDATE_ALL_VIEWS, 0, 0); +} + +// *************************************************************************** + +void CGeorgesEditDoc::getFilename (std::string &pathname) +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + + pathname = (const char*)GetPathName (); +} + +// *************************************************************************** + +void CGeorgesEditDoc::getTitle (std::string &title) +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + + title = (const char*)GetTitle (); +} + +// *************************************************************************** + +void CGeorgesEditDoc::bind (NLGEORGES::IEditPlugin *plugin, IEditDocumentPlugin *docInterface) +{ + // Add the plugin to the list + PluginArray.push_back (CPlugin (plugin, docInterface)); + + docInterface->dialogInit (*getLeftView ()); + docInterface->activate (theApp.isPluginActivated (plugin)); +} + +// *************************************************************************** + +void CGeorgesEditDoc::onActivateView (bool activate) +{ + uint i; + for (i=0; iactivate (activate && theApp.isPluginActivated (PluginArray[i].Plugin)); + } +} + +// *************************************************************************** + +void CGeorgesEditDoc::notifyPlugins (const char *valueName) +{ + uint i; + for (i=0; ionValueChanged (valueName); + } +} + +// *************************************************************************** + +void CGeorgesEditDoc::logValueChange (const char *valueName, const char *newValue, bool present) +{ + if (present) + { + _LastLogs[valueName] = newValue; + } + else + { + _LastLogs.erase (valueName); + } +} + +// *************************************************************************** + +void CGeorgesEditDoc::flushValueChange () +{ + CFileHeader *header = NULL; + if (isForm ()) + header = &((CForm*)(UForm*)Form)->Header; + else if (isType ()) + header = &(Type->Header); + else if (isDfn ()) + header = &(Dfn->Header); + nlassert (header); + + std::map::iterator ite = _LastLogs.begin (); + while (ite != _LastLogs.end ()) + { + header->addLog ((ite->first + " = " + ite->second).c_str ()); + ite++; + } + _LastLogs.clear (); +} + +// *************************************************************************** + +void CGeorgesEditDoc::clearUndo () +{ + uint i; + for (i=0; i<_UndoBuffer.size (); i++) + delete _UndoBuffer[i]; + _UndoBuffer.clear (); +} + +// *************************************************************************** + +void CGeorgesEditDoc::clearRedo () +{ + uint i; + for (i=0; i<_RedoBuffer.size (); i++) + delete _RedoBuffer[i]; + _RedoBuffer.clear (); +} + +// *************************************************************************** + +void CGeorgesEditDoc::OnUpdateFileSaveAll(CCmdUI* pCmdUI) +{ + pCmdUI->Enable (); +} + +// *************************************************************************** + +void CGeorgesEditDoc::OnEditUndo() +{ + if (!_UndoBuffer.empty ()) + { + // Get an action + IAction *action = _UndoBuffer.back (); + _UndoBuffer.pop_back (); + + // Undo it + bool modified; + action->doAction (*this, false, modified, false); + + // Put in the redo list + _RedoBuffer.push_back (action); + + CMDIFrameWnd* pMainWnd = (CMDIFrameWnd*)AfxGetMainWnd(); + + // Get the active MDI child window. + CMDIChildWnd* pChild = (CMDIChildWnd*)pMainWnd->MDIGetActive(); + pChild->RecalcLayout(); + pChild->UpdateWindow(); + + _UndoModify--; + if ( (_UndoModify == 0) && IsModified () ) + { + setModifiedState (false); + } + else if ( (_UndoModify != 0) && !IsModified () ) + { + setModifiedState (true); + } + } +} + +// *************************************************************************** + +void CGeorgesEditDoc::OnUpdateEditUndo(CCmdUI* pCmdUI) +{ + pCmdUI->Enable (!_UndoBuffer.empty ()); +} + +// *************************************************************************** + +void CGeorgesEditDoc::OnEditRedo() +{ + if (!_RedoBuffer.empty ()) + { + // Get an action + IAction *action = _RedoBuffer.back (); + _RedoBuffer.pop_back (); + + // Undo it + bool modified; + action->doAction (*this, true, modified, false); + + // Put in the redo list + _UndoBuffer.push_back (action); + + ((CMainFrame*)(theApp.m_pMainWnd))->RecalcLayout (); + + _UndoModify++; + if ( (_UndoModify == 0) && IsModified () ) + { + setModifiedState (false); + } + else if ( (_UndoModify != 0) && !IsModified () ) + { + setModifiedState (true); + } + } +} + +// *************************************************************************** + +void CGeorgesEditDoc::OnUpdateEditRedo (CCmdUI* pCmdUI) +{ + pCmdUI->Enable (!_RedoBuffer.empty ()); +} + +// *************************************************************************** + +void CGeorgesEditDoc::setModifiedState (bool modified) +{ + SetModifiedFlag (modified?TRUE:FALSE); + + if (modified) + { + CString title = GetTitle (); + if ( (title.GetLength()<2) || (title[title.GetLength()-1] != '*') || (title[title.GetLength()-2] != ' ') ) + SetTitle (title+" *"); + } + else + { + string title = (const char*)GetTitle (); + if ( (title.size ()>=2) && (title[title.size()-1] == '*') && (title[title.size()-2] == ' ') ) + { + title.resize (title.size () - 2); + SetTitle (title.c_str()); + } + } +} + +// *************************************************************************** + +void CGeorgesEditDoc::setValue (const char *value, const char *name, uint slot) +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + + // Document modified + modify (new CActionString (IAction::FormValue, value, *this, name, "", 0xffffffff, slot)); + + notifyPlugins (name); +} + +// *************************************************************************** +// CGeorgesEditDocSub +// *************************************************************************** + +CGeorgesEditDocSub::~CGeorgesEditDocSub () +{ + clean (); +} + +// *************************************************************************** + +void CGeorgesEditDocSub::clean () +{ + for (uint i=0; i<_Children.size(); i++) + delete _Children[i]; + _Children.clear (); +} + +// *************************************************************************** + +bool CGeorgesEditDocSub::isEditable () const +{ + switch (_Type) + { + case Header: + case Type: + case Dfn: + case Form: + return true; + } + return false; +} + +// *************************************************************************** + +CGeorgesEditDocSub::TSub CGeorgesEditDocSub::getType () const +{ + return _Type; +} + +// *************************************************************************** + +uint CGeorgesEditDocSub::getChildrenCount () +{ + return _Children.size (); +} + +// *************************************************************************** + +CGeorgesEditDocSub *CGeorgesEditDocSub::getChild (uint child) +{ + return _Children[child]; +} + +// *************************************************************************** + +void CGeorgesEditDocSub::create (TSub type, const char *name, uint structId, const char *formName, uint slot) +{ + _StructId = structId; + _Type = type; + _Name = name; + _FormName = formName; + _Slot = slot; +} + +// *************************************************************************** + +CGeorgesEditDocSub *CGeorgesEditDocSub::add (TSub type, const char *name, uint structId, const char *formName, uint slot) +{ + // Add at the end + uint index = _Children.size(); + _Children.push_back (new CGeorgesEditDocSub); + + _Children[index]->_Type = type; + _Children[index]->_Name = name; + _Children[index]->_Parent = this; + _Children[index]->_StructId = structId; + _Children[index]->_FormName = formName; + _Children[index]->_Slot = slot; + return _Children[index]; +} + +// *************************************************************************** + +CGeorgesEditDocSub::CGeorgesEditDocSub () +{ + _Parent = NULL; +} + +// *************************************************************************** + +const std::string& CGeorgesEditDocSub::getName () const +{ + return _Name; +} + +// *************************************************************************** + +// *************************************************************************** + +CGeorgesEditDocSub *CGeorgesEditDocSub::getParent () +{ + return _Parent; +} + +// *************************************************************************** + +uint CGeorgesEditDocSub::getIdInParent () const +{ + return _StructId; +} + +// *************************************************************************** + +const std::string& CGeorgesEditDocSub::getFormName () const +{ + return _FormName; +} + +// *************************************************************************** + +void CGeorgesEditDocSub::removeChildren (uint child) +{ + _Children.erase (_Children.begin()+child); +} + +// *************************************************************************** + +uint CGeorgesEditDocSub::getSlot () const +{ + return _Slot; +} + +// *************************************************************************** + +int CGeorgesEditDocSub::getItemImage (CGeorgesEditDoc *doc) const +{ + switch (_Type) + { + case Null: + nlassert (_Children.size ()>1); + if (_Children[1]->_Type == Type) + return theApp.ImageList.getImage (IDR_TYPETYPE); + if (_Children[1]->_Type == Dfn) + return theApp.ImageList.getImage (IDR_TYPEDFN); + if (_Children[1]->_Type == Form) + return theApp.ImageList.getImage (IDR_TYPEFORM); + case Header: + { + int image = theApp.ImageList.getImage ("header"); + if (image == -1) + return theApp.ImageList.getImage (IDR_HEADER); + return image; + } + case Type: + { + int image = theApp.ImageList.getImage ("type"); + if (image == -1) + return theApp.ImageList.getImage (IDR_TYPETYPE); + return image; + } + case Dfn: + { + int image = theApp.ImageList.getImage ("dfn"); + if (image == -1) + return theApp.ImageList.getImage (IDR_TYPEDFN); + return image; + } + case Form: + { + // Root ? + if ((_Parent->_Parent == NULL) && (_Parent->_Children[1] != this)) + { + int image = theApp.ImageList.getImage ("hold"); + if (image == -1) + return theApp.ImageList.getImage (IDR_HOLD); + return image; + } + + if ((_Parent->_Parent == NULL) && (_Parent->_Children[1] == this)) + { + int image = theApp.ImageList.getImage ("root"); + if (image == -1) + return theApp.ImageList.getImage (IDR_ROOT); + return image; + } + + // What kind of node ? + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + bool parentVDfnArray; + CForm *form=doc->getFormPtr (); + CFormElm *elm = doc->getRootNode (getSlot ()); + nlverify ( elm->getNodeByName (getFormName ().c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); + + if (array) + { + int image = theApp.ImageList.getImage ("array"); + if (image == -1) + return theApp.ImageList.getImage (IDR_ARRAY); + return image; + } + else + { + if (type == UFormDfn::EntryType) + { + if (parentDfn) + { + int image = theApp.ImageList.getImage (parentDfn->getEntry(indexDfn).getFilename ().c_str ()); + if (image != -1) + return image; + } + int image = theApp.ImageList.getImage ("typedoc"); + if (image == -1) + return theApp.ImageList.getImage (IDR_TYPETYPE); + return image; + } + else if (type == UFormDfn::EntryDfn) + { + if (parentDfn) + { + int image = theApp.ImageList.getImage (parentDfn->getEntry(indexDfn).getFilename ().c_str ()); + if (image != -1) + return image; + } + int image = theApp.ImageList.getImage ("struct"); + if (image == -1) + return theApp.ImageList.getImage (IDR_STRUCT); + return image; + } + else if (type == UFormDfn::EntryVirtualDfn) + { + if (node) + { + string dfnName; + safe_cast (node)->getDfnName (dfnName); + int image = theApp.ImageList.getImage (dfnName.c_str ()); + if (image != -1) + return image; + } + int image = theApp.ImageList.getImage ("vstruct"); + if (image == -1) + return theApp.ImageList.getImage (IDR_VSTRUCT); + return image; + } + } + } + default: + nlstop; + } + return 0; +} + +// *************************************************************************** +// CPlugin +// *************************************************************************** + +CGeorgesEditDoc::CPlugin::CPlugin (NLGEORGES::IEditPlugin *plugin, NLGEORGES::IEditDocumentPlugin *pluginInterface) +{ + Plugin = plugin; + PluginInterface = pluginInterface; +} + +void CGeorgesEditDocForm::OnEditFetch1() +{ + fetch (1); +} + +void CGeorgesEditDocForm::OnEditFetch3() +{ + fetch (3); +} + +void CGeorgesEditDocForm::OnEditFetch4() +{ + fetch (1); +} + +void CGeorgesEditDocForm::OnEditFetch2() +{ + fetch (2); +} + +void CGeorgesEditDocForm::OnEditHold1() +{ + hold (1); +} + +void CGeorgesEditDocForm::OnEditHold2() +{ + hold (2); +} + +void CGeorgesEditDocForm::OnEditHold3() +{ + hold (3); +} + +void CGeorgesEditDocForm::OnEditHold4() +{ + hold (4); +} + +void CGeorgesEditDocForm::fetch (uint buffer) +{ + if (theApp.yesNo (("Are you sure you want to get back hold buffer #" + toString (buffer) + " ?").c_str())) + { + theApp.SerialIntoMemStream ("", this, buffer, false); + modify (new CActionBuffer (IAction::FormPaste, theApp.MemStream.buffer (), theApp.MemStream.length(), + *this, "", "", 2, 0), NULL); + } +} + +void CGeorgesEditDocForm::hold (uint buffer) +{ + theApp.SerialIntoMemStream ("", this, 0, false); + modify (new CActionBuffer (IAction::FormPaste, theApp.MemStream.buffer (), theApp.MemStream.length(), + *this, "", "", 2, buffer), NULL); +} diff --git a/code/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.h b/code/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.h index b6f9ef7f6..87b33779f 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.h +++ b/code/ryzom/tools/leveldesign/georges_dll/georges_edit_doc.h @@ -1,422 +1,422 @@ -// 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 . - -#if !defined(AFX_GEORGES_EDITDOC_H__266E6547_220E_4A6E_9285_5F91BCD53E5B__INCLUDED_) -#define AFX_GEORGES_EDITDOC_H__266E6547_220E_4A6E_9285_5F91BCD53E5B__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - - -#include "nel/misc/types_nl.h" - -#include "nel/georges/type.h" -#include "nel/georges/form.h" -#include "nel/georges/form_dfn.h" -#include "nel/georges/form_loader.h" - -#include "plugin_interface.h" - -class CLeftView; -class CGeorgesEditView; -class CGeorgesEditDoc; - -/** - * This class is the sub object in the leftview tree. - * - * The CGeorgesEditDocSub pointers are stored in the CTreeCtrl user data. The current CGeorgesEditDocSub edited in the right view - * is the current ledfview CTreeCtrl selection. - * - * To get the node or the DFN entry from a CGeorgesEditDocSub, use the form name stored in the CGeorgesEditDocSub and make a - * getNodeByName / getValueByName. - */ -class CGeorgesEditDocSub -{ -public: - // What is the sub object ? - enum TSub - { - Null, // Nothing in this node (root ?) - Header, // Header node - Type, // This node is a type - Dfn, // This node is a dfn - Form, // This node is a form - }; - - CGeorgesEditDocSub (); - - // Delete sub objects - ~CGeorgesEditDocSub (); - - // Get the type of the sub object - bool isEditable () const; - - // Is Subobject editable - TSub getType () const; - - // Get the my id in the parent children array - uint getIdInParent () const; - - // Get the sub object name - const std::string& getName () const; - - // Get the form name - const std::string& getFormName () const; - - // Get the sub object children - uint getChildrenCount (); - void removeChildren (uint child); - CGeorgesEditDocSub *getChild (uint child); - CGeorgesEditDocSub *getParent (); - - // Get the slot number - uint getSlot () const; - - // Create a sub object - void create (TSub type, const char *name, uint structId, const char *formName, uint slot); - - // Add a sub object - CGeorgesEditDocSub *add (TSub type, const char *name, uint structId, const char *formName, uint slot); - - // Clean the struct - void clean (); - - // Get item image - int getItemImage (CGeorgesEditDoc *doc) const; - -private: - - uint _StructId; - std::string _Name; - std::string _FormName; - TSub _Type; - std::vector _Children; - CGeorgesEditDocSub *_Parent; - uint _Slot; -}; - -/** - * To get the current sub object, use getSelectedObject. - * - * When the structure of the document changes (and the left tree too), CGeorgesEditDoc::updateDocumentStructure must be called. - * This method destroy and construct the CGeorgesEditDocSub tree and the leftView CTreeCtrl. - * - * To change of sub selection, call changeSubSelection. - * - * When the left / right view need update, (document changes, sub object selection change..), call the right view getXXXFromDocument() method. - * When the document need update from the left / right view, (right view widget edition), call the left / right view setXXXToDocument () method. - */ -class CGeorgesEditDoc : public CDocument, public NLGEORGES::IEditDocument -{ - friend class IAction; -protected: // create from serialization only - CGeorgesEditDoc(); - // DECLARE_DYNCREATE(CGeorgesEditDoc) - -public: - /** - * Call this method when the document have been modified (not the structure but the document values). - * - * After this call, any CGeorgesEditDocSub pointers in this document are invalid. - */ - bool modify (class IAction *action, bool modified = true, bool setHeaderStateToModified = true); - -protected: - // Set the modified state of the document - void setModifiedState (bool modified); - -// Attributes -public: - - // Return the root node for a slot - NLGEORGES::CFormElm *getRootNode (uint slot); - - // Trick, when this flag is true, no modification (made by modified()) can be made. - bool NoModification; - - - // A form loader - NLGEORGES::CFormLoader FormLoader; - - // The root sub object - CGeorgesEditDocSub RootObject; - - /** - * Return the current sub object - * - * Warning, it you call modify or any method that call updateDocumentStructure (), this pointer is not valid anymore. - */ - CGeorgesEditDocSub *getSelectedObject (); - - // Change the sub selection. If subSelection == NULL, select the content - void changeSubSelection (CGeorgesEditDocSub *subSelection, CView *view); - void changeSubSelection (uint subId, CView *view); - - // Switch focus to the given view - CView *switchToView(CView* pNewView); - - // Get the type pointer - NLGEORGES::CType *getTypePtr (); - - // Get the DFN pointer - NLGEORGES::CFormDfn *getDfnPtr (); - - // Get the form document pointer - NLGEORGES::CForm *getFormPtr (); - - // Get the header pointer - NLGEORGES::CFileHeader *getHeaderPtr (); - - // Get the left view - CLeftView *getLeftView (); - - // Get the right view - CGeorgesEditView *getRightView (); - - /** - * Update the document structure. Call this when the document structure have been modified. - * It erases the sub object structure, rebuild it and rebuild the leftview tree. - * - * After this call, any CGeorgesEditDocSub pointers in this document are invalid. - */ - void updateDocumentStructure (); - - /** - * Call when the view is actived / disactivated - */ - void onActivateView (bool activate); - - // Notify the plugins that this value has changed - void notifyPlugins (const char *valueName); - - // Load a form file - bool loadFormFile (const char *filename); - - // Add a parent form to the file - bool addParent (const char *filename); - - // Document is a type ? - virtual bool isType () const; - - // Document is a dfn ? - virtual bool isDfn () const; - - // Docuemnt is a form ? - virtual bool isForm () const; - - // overload setPathName to update plugin - void SetPathName(LPCTSTR lpszPathName, BOOL bAddToMRU); - -protected: - // Internal methods to construct the sub object structre - CGeorgesEditDocSub *addStruct (CGeorgesEditDocSub *parent, NLGEORGES::CFormElmStruct *_struct, NLGEORGES::CFormDfn *rootDfn, const char *name, uint structId, const char *formName, uint slot); - - // Internal methods to construct the sub object structre - CGeorgesEditDocSub *addArray (CGeorgesEditDocSub *parent, NLGEORGES::CFormElmArray *array, NLGEORGES::CFormDfn *rootDfn, const char *name, uint structId, const char *formName, uint slot); - -protected: - // Log system - void logValueChange (const char *valueName, const char *newValue, bool present); - void flushValueChange (); - std::map _LastLogs; - - // Undo / redo system - uint _UndoModify; - std::vector _UndoBuffer; - std::vector _RedoBuffer; - void clearUndo (); - void clearRedo (); - -protected: - - - // The value - NLMISC::CSmartPtr Type; - NLMISC::CSmartPtr Dfn; - NLMISC::CSmartPtr Form; - - // From IEditDocument - NLGEORGES::UForm *getForm (); - void getDfnFilename (std::string &dfnName); - void bind (NLGEORGES::IEditPlugin *plugin, NLGEORGES::IEditDocumentPlugin *document); - bool getActiveNode (std::string &dfnName); - void refreshView (); - void getFilename (std::string &pathname); - void getTitle (std::string &pathname); - void setValue (const char *valueName, const char *value, uint slot); - -// Operations -public: - - // Plugin informations - class CPlugin - { - public: - // Constructor - CPlugin (NLGEORGES::IEditPlugin *plugin, NLGEORGES::IEditDocumentPlugin *pluginInterface); - - // The plugin document interface - NLGEORGES::IEditDocumentPlugin *PluginInterface; - NLGEORGES::IEditPlugin *Plugin; - }; - - // Array of plugin informations - std::vector PluginArray; - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CGeorgesEditDoc) - public: - virtual BOOL OnOpenDocument(LPCTSTR lpszPathName); - virtual BOOL OnSaveDocument(LPCTSTR lpszPathName); - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CGeorgesEditDoc(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - -// Generated message map functions -protected: - //{{AFX_MSG(CGeorgesEditDoc) - afx_msg void OnUpdateFileSaveAll(CCmdUI* pCmdUI); -public: - afx_msg void OnEditUndo(); - afx_msg void OnUpdateEditUndo(CCmdUI* pCmdUI); - afx_msg void OnEditRedo(); - afx_msg void OnUpdateEditRedo(CCmdUI* pCmdUI); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -class CGeorgesEditDocType : public CGeorgesEditDoc -{ -protected: // create from serialization only - CGeorgesEditDocType() {} - DECLARE_DYNCREATE(CGeorgesEditDocType) - - // Document is a type ? - bool isType () const; - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CGeorgesEditDocType) - public: - virtual BOOL OnNewDocument(); - //}}AFX_VIRTUAL - -protected: - -// Generated message map functions -protected: - //{{AFX_MSG(CGeorgesEditDocType) - // NOTE - the ClassWizard will add and remove member functions here. - // DO NOT EDIT what you see in these blocks of generated code ! - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -class CGeorgesEditDocDfn : public CGeorgesEditDoc -{ -protected: // create from serialization only - CGeorgesEditDocDfn() {} - DECLARE_DYNCREATE(CGeorgesEditDocDfn) - - // Document is a dfn ? - bool isDfn () const; - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CGeorgesEditDocDfn) - public: - virtual BOOL OnNewDocument(); - //}}AFX_VIRTUAL - -protected: - -// Generated message map functions -protected: - //{{AFX_MSG(CGeorgesEditDocDfn) - // NOTE - the ClassWizard will add and remove member functions here. - // DO NOT EDIT what you see in these blocks of generated code ! - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -class CGeorgesEditDocForm : public CGeorgesEditDoc -{ -protected: // create from serialization only - CGeorgesEditDocForm() {} - DECLARE_DYNCREATE(CGeorgesEditDocForm) - - // Docuemnt is a form ? - bool isForm () const; - - // Init the document - bool initDocument (const char *dfnName, bool newElement); - - // Fetch a backup buffer - void fetch (uint buffer); - - // Fetch a backup buffer - void hold (uint buffer); - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CGeorgesEditDocForm) - public: - virtual BOOL OnNewDocument(); - //}}AFX_VIRTUAL - -protected: - -// Generated message map functions -protected: - //{{AFX_MSG(CGeorgesEditDocForm) -public: - afx_msg void OnEditFetch1(); - afx_msg void OnEditFetch3(); - afx_msg void OnEditFetch4(); - afx_msg void OnEditFetch2(); - afx_msg void OnEditHold1(); - afx_msg void OnEditHold2(); - afx_msg void OnEditHold3(); - afx_msg void OnEditHold4(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_GEORGES_EDITDOC_H__266E6547_220E_4A6E_9285_5F91BCD53E5B__INCLUDED_) +// 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 . + +#if !defined(AFX_GEORGES_EDITDOC_H__266E6547_220E_4A6E_9285_5F91BCD53E5B__INCLUDED_) +#define AFX_GEORGES_EDITDOC_H__266E6547_220E_4A6E_9285_5F91BCD53E5B__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + + +#include "nel/misc/types_nl.h" + +#include "nel/georges/type.h" +#include "nel/georges/form.h" +#include "nel/georges/form_dfn.h" +#include "nel/georges/form_loader.h" + +#include "plugin_interface.h" + +class CLeftView; +class CGeorgesEditView; +class CGeorgesEditDoc; + +/** + * This class is the sub object in the leftview tree. + * + * The CGeorgesEditDocSub pointers are stored in the CTreeCtrl user data. The current CGeorgesEditDocSub edited in the right view + * is the current ledfview CTreeCtrl selection. + * + * To get the node or the DFN entry from a CGeorgesEditDocSub, use the form name stored in the CGeorgesEditDocSub and make a + * getNodeByName / getValueByName. + */ +class CGeorgesEditDocSub +{ +public: + // What is the sub object ? + enum TSub + { + Null, // Nothing in this node (root ?) + Header, // Header node + Type, // This node is a type + Dfn, // This node is a dfn + Form, // This node is a form + }; + + CGeorgesEditDocSub (); + + // Delete sub objects + ~CGeorgesEditDocSub (); + + // Get the type of the sub object + bool isEditable () const; + + // Is Subobject editable + TSub getType () const; + + // Get the my id in the parent children array + uint getIdInParent () const; + + // Get the sub object name + const std::string& getName () const; + + // Get the form name + const std::string& getFormName () const; + + // Get the sub object children + uint getChildrenCount (); + void removeChildren (uint child); + CGeorgesEditDocSub *getChild (uint child); + CGeorgesEditDocSub *getParent (); + + // Get the slot number + uint getSlot () const; + + // Create a sub object + void create (TSub type, const char *name, uint structId, const char *formName, uint slot); + + // Add a sub object + CGeorgesEditDocSub *add (TSub type, const char *name, uint structId, const char *formName, uint slot); + + // Clean the struct + void clean (); + + // Get item image + int getItemImage (CGeorgesEditDoc *doc) const; + +private: + + uint _StructId; + std::string _Name; + std::string _FormName; + TSub _Type; + std::vector _Children; + CGeorgesEditDocSub *_Parent; + uint _Slot; +}; + +/** + * To get the current sub object, use getSelectedObject. + * + * When the structure of the document changes (and the left tree too), CGeorgesEditDoc::updateDocumentStructure must be called. + * This method destroy and construct the CGeorgesEditDocSub tree and the leftView CTreeCtrl. + * + * To change of sub selection, call changeSubSelection. + * + * When the left / right view need update, (document changes, sub object selection change..), call the right view getXXXFromDocument() method. + * When the document need update from the left / right view, (right view widget edition), call the left / right view setXXXToDocument () method. + */ +class CGeorgesEditDoc : public CDocument, public NLGEORGES::IEditDocument +{ + friend class IAction; +protected: // create from serialization only + CGeorgesEditDoc(); + // DECLARE_DYNCREATE(CGeorgesEditDoc) + +public: + /** + * Call this method when the document have been modified (not the structure but the document values). + * + * After this call, any CGeorgesEditDocSub pointers in this document are invalid. + */ + bool modify (class IAction *action, bool modified = true, bool setHeaderStateToModified = true); + +protected: + // Set the modified state of the document + void setModifiedState (bool modified); + +// Attributes +public: + + // Return the root node for a slot + NLGEORGES::CFormElm *getRootNode (uint slot); + + // Trick, when this flag is true, no modification (made by modified()) can be made. + bool NoModification; + + + // A form loader + NLGEORGES::CFormLoader FormLoader; + + // The root sub object + CGeorgesEditDocSub RootObject; + + /** + * Return the current sub object + * + * Warning, it you call modify or any method that call updateDocumentStructure (), this pointer is not valid anymore. + */ + CGeorgesEditDocSub *getSelectedObject (); + + // Change the sub selection. If subSelection == NULL, select the content + void changeSubSelection (CGeorgesEditDocSub *subSelection, CView *view); + void changeSubSelection (uint subId, CView *view); + + // Switch focus to the given view + CView *switchToView(CView* pNewView); + + // Get the type pointer + NLGEORGES::CType *getTypePtr (); + + // Get the DFN pointer + NLGEORGES::CFormDfn *getDfnPtr (); + + // Get the form document pointer + NLGEORGES::CForm *getFormPtr (); + + // Get the header pointer + NLGEORGES::CFileHeader *getHeaderPtr (); + + // Get the left view + CLeftView *getLeftView (); + + // Get the right view + CGeorgesEditView *getRightView (); + + /** + * Update the document structure. Call this when the document structure have been modified. + * It erases the sub object structure, rebuild it and rebuild the leftview tree. + * + * After this call, any CGeorgesEditDocSub pointers in this document are invalid. + */ + void updateDocumentStructure (); + + /** + * Call when the view is actived / disactivated + */ + void onActivateView (bool activate); + + // Notify the plugins that this value has changed + void notifyPlugins (const char *valueName); + + // Load a form file + bool loadFormFile (const char *filename); + + // Add a parent form to the file + bool addParent (const char *filename); + + // Document is a type ? + virtual bool isType () const; + + // Document is a dfn ? + virtual bool isDfn () const; + + // Docuemnt is a form ? + virtual bool isForm () const; + + // overload setPathName to update plugin + void SetPathName(LPCTSTR lpszPathName, BOOL bAddToMRU); + +protected: + // Internal methods to construct the sub object structre + CGeorgesEditDocSub *addStruct (CGeorgesEditDocSub *parent, NLGEORGES::CFormElmStruct *_struct, NLGEORGES::CFormDfn *rootDfn, const char *name, uint structId, const char *formName, uint slot); + + // Internal methods to construct the sub object structre + CGeorgesEditDocSub *addArray (CGeorgesEditDocSub *parent, NLGEORGES::CFormElmArray *array, NLGEORGES::CFormDfn *rootDfn, const char *name, uint structId, const char *formName, uint slot); + +protected: + // Log system + void logValueChange (const char *valueName, const char *newValue, bool present); + void flushValueChange (); + std::map _LastLogs; + + // Undo / redo system + uint _UndoModify; + std::vector _UndoBuffer; + std::vector _RedoBuffer; + void clearUndo (); + void clearRedo (); + +protected: + + + // The value + NLMISC::CSmartPtr Type; + NLMISC::CSmartPtr Dfn; + NLMISC::CSmartPtr Form; + + // From IEditDocument + NLGEORGES::UForm *getForm (); + void getDfnFilename (std::string &dfnName); + void bind (NLGEORGES::IEditPlugin *plugin, NLGEORGES::IEditDocumentPlugin *document); + bool getActiveNode (std::string &dfnName); + void refreshView (); + void getFilename (std::string &pathname); + void getTitle (std::string &pathname); + void setValue (const char *valueName, const char *value, uint slot); + +// Operations +public: + + // Plugin informations + class CPlugin + { + public: + // Constructor + CPlugin (NLGEORGES::IEditPlugin *plugin, NLGEORGES::IEditDocumentPlugin *pluginInterface); + + // The plugin document interface + NLGEORGES::IEditDocumentPlugin *PluginInterface; + NLGEORGES::IEditPlugin *Plugin; + }; + + // Array of plugin informations + std::vector PluginArray; + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CGeorgesEditDoc) + public: + virtual BOOL OnOpenDocument(LPCTSTR lpszPathName); + virtual BOOL OnSaveDocument(LPCTSTR lpszPathName); + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CGeorgesEditDoc(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + +// Generated message map functions +protected: + //{{AFX_MSG(CGeorgesEditDoc) + afx_msg void OnUpdateFileSaveAll(CCmdUI* pCmdUI); +public: + afx_msg void OnEditUndo(); + afx_msg void OnUpdateEditUndo(CCmdUI* pCmdUI); + afx_msg void OnEditRedo(); + afx_msg void OnUpdateEditRedo(CCmdUI* pCmdUI); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +class CGeorgesEditDocType : public CGeorgesEditDoc +{ +protected: // create from serialization only + CGeorgesEditDocType() {} + DECLARE_DYNCREATE(CGeorgesEditDocType) + + // Document is a type ? + bool isType () const; + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CGeorgesEditDocType) + public: + virtual BOOL OnNewDocument(); + //}}AFX_VIRTUAL + +protected: + +// Generated message map functions +protected: + //{{AFX_MSG(CGeorgesEditDocType) + // NOTE - the ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +class CGeorgesEditDocDfn : public CGeorgesEditDoc +{ +protected: // create from serialization only + CGeorgesEditDocDfn() {} + DECLARE_DYNCREATE(CGeorgesEditDocDfn) + + // Document is a dfn ? + bool isDfn () const; + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CGeorgesEditDocDfn) + public: + virtual BOOL OnNewDocument(); + //}}AFX_VIRTUAL + +protected: + +// Generated message map functions +protected: + //{{AFX_MSG(CGeorgesEditDocDfn) + // NOTE - the ClassWizard will add and remove member functions here. + // DO NOT EDIT what you see in these blocks of generated code ! + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +class CGeorgesEditDocForm : public CGeorgesEditDoc +{ +protected: // create from serialization only + CGeorgesEditDocForm() {} + DECLARE_DYNCREATE(CGeorgesEditDocForm) + + // Docuemnt is a form ? + bool isForm () const; + + // Init the document + bool initDocument (const char *dfnName, bool newElement); + + // Fetch a backup buffer + void fetch (uint buffer); + + // Fetch a backup buffer + void hold (uint buffer); + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CGeorgesEditDocForm) + public: + virtual BOOL OnNewDocument(); + //}}AFX_VIRTUAL + +protected: + +// Generated message map functions +protected: + //{{AFX_MSG(CGeorgesEditDocForm) +public: + afx_msg void OnEditFetch1(); + afx_msg void OnEditFetch3(); + afx_msg void OnEditFetch4(); + afx_msg void OnEditFetch2(); + afx_msg void OnEditHold1(); + afx_msg void OnEditHold2(); + afx_msg void OnEditHold3(); + afx_msg void OnEditHold4(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_GEORGES_EDITDOC_H__266E6547_220E_4A6E_9285_5F91BCD53E5B__INCLUDED_) diff --git a/code/ryzom/tools/leveldesign/georges_dll/georges_edit_view.cpp b/code/ryzom/tools/leveldesign/georges_dll/georges_edit_view.cpp index 929299b89..32717f367 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/georges_edit_view.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/georges_edit_view.cpp @@ -1,699 +1,699 @@ -// 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 "stdafx.h" -#include "georges_edit.h" - -#include "georges_edit_doc.h" -#include "georges_edit_view.h" -#include "left_view.h" - -using namespace NLGEORGES; - - -///////////////////////////////////////////////////////////////////////////// -// CGeorgesEditView - -IMPLEMENT_DYNCREATE(CGeorgesEditView, CScrollView) - -BEGIN_MESSAGE_MAP(CGeorgesEditView, CScrollView) - //{{AFX_MSG_MAP(CGeorgesEditView) - ON_WM_SIZE() - ON_WM_SETFOCUS() - ON_COMMAND(ID_OPEN_SELECTED, OnOpenSelected) - ON_COMMAND(ID_EDIT_COPY, OnEditCopy) - ON_COMMAND(ID_EDIT_CUT, OnEditCut) - ON_COMMAND(ID_EDIT_PASTE, OnEditPaste) - ON_WM_MOUSEWHEEL() - ON_WM_KEYDOWN() - ON_COMMAND(ID_EDIT_REDO, OnEditRedo) - ON_UPDATE_COMMAND_UI(ID_EDIT_REDO, OnUpdateEditRedo) - ON_COMMAND(ID_EDIT_UNDO, OnEditUndo) - ON_UPDATE_COMMAND_UI(ID_EDIT_UNDO, OnUpdateEditUndo) - ON_COMMAND(ID_EDIT_FETCH1, OnEditFetch1) - ON_COMMAND(ID_EDIT_FETCH2, OnEditFetch2) - ON_COMMAND(ID_EDIT_FETCH3, OnEditFetch3) - ON_COMMAND(ID_EDIT_FETCH4, OnEditFetch4) - ON_COMMAND(ID_EDIT_HOLD1, OnEditHold1) - ON_COMMAND(ID_EDIT_HOLD2, OnEditHold2) - ON_COMMAND(ID_EDIT_HOLD3, OnEditHold3) - ON_COMMAND(ID_EDIT_HOLD4, OnEditHold4) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CGeorgesEditView construction/destruction - -CGeorgesEditView::CGeorgesEditView() -{ - VirtualWidth = 100; - VirtualHeight = 100; -} - -CGeorgesEditView::~CGeorgesEditView() -{ -} - -BOOL CGeorgesEditView::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return CScrollView::PreCreateWindow(cs); -} - -///////////////////////////////////////////////////////////////////////////// -// CGeorgesEditView drawing - -void CGeorgesEditView::OnDraw(CDC* pDC) -{ - CGeorgesEditDoc* pDoc = GetDocument(); - ASSERT_VALID(pDoc); -} - -void CGeorgesEditView::OnInitialUpdate() -{ - CScrollView::OnInitialUpdate(); - - // its list control through a call to GetListCtrl(). - CGeorgesEditDoc* pDoc = GetDocument(); - - // Save modified state - pDoc->NoModification = true; - - SIZE size; - size.cx = VirtualWidth; - size.cy = VirtualHeight; - SetScrollSizes (MM_TEXT, size); - - RECT rect; - GetClientRect (&rect); - - // Create the tab - TabCtrl.Create (WS_VISIBLE, rect, this, 0); - TabCtrl.SetImageList (&(theApp.ImageList.ImageList)); - TabCtrl.SetWindowPos (NULL, 0, 0, std::max ((int)VirtualWidth, (int)(rect.right-rect.left)), std::max ((int)VirtualHeight, (int)(rect.bottom-rect.top)), SWP_NOZORDER|SWP_NOOWNERZORDER); - - // Update the tab - updateTab (); - - // Create the type dialog - RECT tabClient; - TabCtrl.GetClientRect (&tabClient); - TypeDialog.View = this; - TypeDialog.Create (CBaseDialog::IDD, &TabCtrl); - TypeDialog.SetWindowPos (NULL, WidgetLeftMargin, WidgetTopMargin, tabClient.right - tabClient.left - WidgetLeftMargin - WidgetRightMargin, tabClient.bottom - tabClient.top - WidgetTopMargin - WidgetBottomMargin, SWP_NOZORDER|SWP_NOOWNERZORDER); - - // Create the header dialog - HeaderDialog.View = this; - HeaderDialog.Create (CBaseDialog::IDD, &TabCtrl); - HeaderDialog.SetWindowPos (NULL, WidgetLeftMargin, WidgetTopMargin, tabClient.right - tabClient.left - WidgetLeftMargin - WidgetRightMargin, tabClient.bottom - tabClient.top - WidgetTopMargin - WidgetBottomMargin, SWP_NOZORDER|SWP_NOOWNERZORDER); - - // Create the dfn dialog - DfnDialog.View = this; - DfnDialog.Create (CBaseDialog::IDD, &TabCtrl); - DfnDialog.SetWindowPos (NULL, WidgetLeftMargin, WidgetTopMargin, tabClient.right - tabClient.left - WidgetLeftMargin - WidgetRightMargin, tabClient.bottom - tabClient.top - WidgetTopMargin - WidgetBottomMargin, SWP_NOZORDER|SWP_NOOWNERZORDER); - - // Create the dfn dialog - FormDialog.View = this; - FormDialog.Create (CBaseDialog::IDD, &TabCtrl); - FormDialog.SetWindowPos (NULL, WidgetLeftMargin, WidgetTopMargin, tabClient.right - tabClient.left - WidgetLeftMargin - WidgetRightMargin, tabClient.bottom - tabClient.top - WidgetTopMargin - WidgetBottomMargin, SWP_NOZORDER|SWP_NOOWNERZORDER); - - // Set tab font - CFont* font = TypeDialog.GetFont (); - TabCtrl.SetFont (font); - TabCtrl.ShowWindow (SW_SHOW); - - // Update document - updateDocument (); - - // Save modified state - pDoc->NoModification = false; - - // Is it a form ? - theApp.onNewDocView (pDoc); - - // Notify the doc plugin - uint i; - CGeorgesEditDocSub *selection = pDoc->getSelectedObject (); - for (i=0; iPluginArray.size (); i++) - { - // Activate / desactivate plugin - pDoc->PluginArray[i].PluginInterface->onNodeChanged (); - } -} - -///////////////////////////////////////////////////////////////////////////// -// CGeorgesEditView diagnostics - -#ifdef _DEBUG -void CGeorgesEditView::AssertValid() const -{ - CScrollView::AssertValid(); -} - -void CGeorgesEditView::Dump(CDumpContext& dc) const -{ - CScrollView::Dump(dc); -} - -CGeorgesEditDoc* CGeorgesEditView::GetDocument() // non-debug version is inline -{ - ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CGeorgesEditDocType)) || - m_pDocument->IsKindOf(RUNTIME_CLASS(CGeorgesEditDocDfn)) || - m_pDocument->IsKindOf(RUNTIME_CLASS(CGeorgesEditDocForm))); - return (CGeorgesEditDoc*)m_pDocument; -} -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CGeorgesEditView message handlers -void CGeorgesEditView::OnStyleChanged(int nStyleType, LPSTYLESTRUCT lpStyleStruct) -{ - //TODO: add code to react to the user changing the view style of your window -} - -void CGeorgesEditView::OnSize(UINT nType, int cx, int cy) -{ - CScrollView::OnSize(nType, cx, cy); - - UpdateData (); - - if (IsWindow (TabCtrl)) - { - CPoint currentPos = GetDeviceScrollPosition (); - - RECT rect; - GetClientRect (&rect); - - if (IsWindow (TypeDialog) && TypeDialog.IsWindowVisible ()) - { - TypeDialog.resizeWidgets (); - } - - // Resize header dialog - if (IsWindow (HeaderDialog) && HeaderDialog.IsWindowVisible ()) - { - HeaderDialog.resizeWidgets (); - } - - // Resize dfn dialog - if (IsWindow (DfnDialog) && DfnDialog.IsWindowVisible ()) - { - DfnDialog.resizeWidgets (); - } - - // Resize dfn dialog - if (IsWindow (FormDialog) && FormDialog.IsWindowVisible ()) - { - FormDialog.resizeWidgets (); - } - - // Create the tab - TabCtrl.SetWindowPos (NULL, -currentPos.x, -currentPos.y, std::max ((int)VirtualWidth, (int)(rect.right-rect.left)), std::max ((int)VirtualHeight, (int)(rect.bottom-rect.top)), SWP_NOZORDER|SWP_NOOWNERZORDER); - - // Resize type dialog - RECT tabClient; - TabCtrl.GetClientRect (&tabClient); - - // Resize type dialog - if (IsWindow (TypeDialog)) - { - TypeDialog.SetWindowPos (NULL, WidgetLeftMargin, WidgetTopMargin, tabClient.right - tabClient.left - WidgetLeftMargin - WidgetRightMargin, - tabClient.bottom - tabClient.top - WidgetTopMargin - WidgetBottomMargin, SWP_NOZORDER|SWP_NOOWNERZORDER); - } - - // Resize header dialog - if (IsWindow (HeaderDialog)) - { - HeaderDialog.SetWindowPos (NULL, WidgetLeftMargin, WidgetTopMargin, tabClient.right - tabClient.left - WidgetLeftMargin - WidgetRightMargin, - tabClient.bottom - tabClient.top - WidgetTopMargin - WidgetBottomMargin, SWP_NOZORDER|SWP_NOOWNERZORDER); - } - - // Resize dfn dialog - if (IsWindow (DfnDialog)) - DfnDialog.SetWindowPos (NULL, WidgetLeftMargin, WidgetTopMargin, tabClient.right - tabClient.left - WidgetLeftMargin - WidgetRightMargin, - tabClient.bottom - tabClient.top - WidgetTopMargin - WidgetBottomMargin, SWP_NOZORDER|SWP_NOOWNERZORDER); - - // Resize dfn dialog - if (IsWindow (FormDialog)) - FormDialog.SetWindowPos (NULL, WidgetLeftMargin, WidgetTopMargin, tabClient.right - tabClient.left - WidgetLeftMargin - WidgetRightMargin, - tabClient.bottom - tabClient.top - WidgetTopMargin - WidgetBottomMargin, SWP_NOZORDER|SWP_NOOWNERZORDER); - } - - UpdateData (FALSE); -} - -void CGeorgesEditView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) -{ - // Not me ? - if (pSender != this) - { - // Update - updateTab (); - updateDocument (); - } -} - -void CGeorgesEditView::updateTab () -{ - if (IsWindow (TabCtrl)) - { - // Clear the tab - TabCtrl.DeleteAllItems (); - - CGeorgesEditDoc *doc = GetDocument(); - if (doc) - { - // Current selection - CGeorgesEditDocSub *subObject = doc->getSelectedObject (); - if (subObject) - { - // Get parent - CGeorgesEditDocSub *parent = subObject->getParent (); - if (parent) - { - // For each subobject - int tabSelected = -1; - for (uint i=0; igetChildrenCount(); i++) - { - // Init the tab - CGeorgesEditDocSub *child = parent->getChild (i); - int image = child->getItemImage (doc); - TabCtrl.InsertItem (i, child->getName ().c_str(), image); - - // This is the selection ? - if (subObject == child) - tabSelected = i; - } - - // Should be found - nlassert (tabSelected!=-1); - TabCtrl.SetCurSel (tabSelected); - - UpdateData (FALSE); - } - } - } - } -} - -void CGeorgesEditView::updateDocument () -{ - if (IsWindow (TabCtrl) && IsWindow (DfnDialog) && IsWindow (TypeDialog) && IsWindow (FormDialog) && IsWindow (HeaderDialog) ) - { - CGeorgesEditDoc *doc = GetDocument(); - if (doc) - { - // Hide all the window - TypeDialog.ShowWindow (SW_HIDE); - HeaderDialog.ShowWindow (SW_HIDE); - DfnDialog.ShowWindow (SW_HIDE); - FormDialog.ShowWindow (SW_HIDE); - - // Current selection - CGeorgesEditDocSub *subObject = doc->getSelectedObject (); - if (subObject) - { - switch (subObject->getType ()) - { - case CGeorgesEditDocSub::Type: - { - // Get the document - TypeDialog.getFromDocument (*doc->getTypePtr ()); - - // Show the window - TypeDialog.resizeWidgets (); - TypeDialog.ShowWindow (SW_SHOW); - } - break; - case CGeorgesEditDocSub::Header: - { - // Get the document - HeaderDialog.getFromDocument (*doc->getHeaderPtr ()); - - // Show the window - HeaderDialog.resizeWidgets (); - HeaderDialog.ShowWindow (SW_SHOW); - } - break; - case CGeorgesEditDocSub::Dfn: - { - // Get the document - DfnDialog.getFromDocument (*doc->getDfnPtr ()); - - // Show the window - DfnDialog.resizeWidgets (); - DfnDialog.ShowWindow (SW_SHOW); - } - break; - case CGeorgesEditDocSub::Form: - { - // Get the document - FormDialog.getFromDocument (); - - // Show the window - FormDialog.resizeWidgets (); - FormDialog.ShowWindow (SW_SHOW); - } - break; - } - } - } - } -} - -BOOL CGeorgesEditView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) -{ - LPNMHDR pnmh = (LPNMHDR) lParam; - switch (pnmh->code) - { - case TCN_SELCHANGE: - { - UpdateData (); - - // Get the document - CGeorgesEditDoc *doc = GetDocument(); - if (doc) - { - // Current selection - CGeorgesEditDocSub *subObject = doc->getSelectedObject (); - if (subObject) - { - // Get parent - CGeorgesEditDocSub *parent = subObject->getParent (); - if (parent) - { - // Get the child - CGeorgesEditDocSub *child = parent->getChild (TabCtrl.GetCurSel ()); - - // Sub selection changed - CLeftView* pView = doc->getLeftView (); - doc->changeSubSelection (child, pView); - TabCtrl.SetFocus (); - } - } - } - } - break; - } - - return CScrollView::OnNotify(wParam, lParam, pResult); -} - -void CGeorgesEditView::OnSetFocus(CWnd* pOldWnd) -{ - CScrollView::OnSetFocus(pOldWnd); - - TabCtrl.UpdateData (); - if ( (TabCtrl.GetItemCount ()) && (pOldWnd != &TabCtrl) ) - { - TabCtrl.SetFocus (); - } - else - { - if (TypeDialog.IsWindowVisible ()) - TypeDialog.SetFocus (); - if (HeaderDialog.IsWindowVisible ()) - HeaderDialog.SetFocus (); - if (DfnDialog.IsWindowVisible ()) - DfnDialog.SetFocus (); - if (FormDialog.IsWindowVisible ()) - FormDialog.SetFocus (); - } -} - -BOOL CGeorgesEditView::PreTranslateMessage(MSG* pMsg) -{ - if (theApp.m_pMainWnd->PreTranslateMessage(pMsg)) - return TRUE; - - if ((pMsg->message == WM_KEYDOWN) && ((int) pMsg->wParam == VK_TAB) ) - { - // Shift ? - if (GetAsyncKeyState (VK_SHIFT) & (1<<15)) - setFocusLeftView (); - else - SetFocus (); - return TRUE; - } - - return CScrollView::PreTranslateMessage(pMsg); -} - -void CGeorgesEditView::OnOpenSelected() -{ - if (HeaderDialog.IsWindowVisible ()) - { - HeaderDialog.onOpenSelected (); - } - if (TypeDialog.IsWindowVisible ()) - { - TypeDialog.onOpenSelected (); - } - if (DfnDialog.IsWindowVisible ()) - { - DfnDialog.onOpenSelected (); - } - if (FormDialog.IsWindowVisible ()) - { - FormDialog.onOpenSelected (); - } -} - -void CGeorgesEditView::setFocusLastWidget () -{ - if (HeaderDialog.IsWindowVisible ()) - { - HeaderDialog.setFocusLastWidget (); - } - if (TypeDialog.IsWindowVisible ()) - { - TypeDialog.setFocusLastWidget (); - } - if (DfnDialog.IsWindowVisible ()) - { - DfnDialog.setFocusLastWidget (); - } - if (FormDialog.IsWindowVisible ()) - { - FormDialog.setFocusLastWidget (); - } -} - -bool CGeorgesEditView::isFocusable () const -{ - return (HeaderDialog.IsWindowVisible () || TypeDialog.IsWindowVisible () || DfnDialog.IsWindowVisible () || FormDialog.IsWindowVisible ()); -} - -void CGeorgesEditView::setFocusLeftView () -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - CLeftView* pView = doc->getLeftView (); - doc->switchToView (pView); - } -} - -LRESULT CGeorgesEditView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) -{ - // When this message arrive, update the view - if (message == WM_UPDATE_ALL_VIEWS) - GetDocument ()->UpdateAllViews (NULL); - - return CScrollView::WindowProc(message, wParam, lParam); -} - -void CGeorgesEditView::OnEditCopy() -{ - CWnd *focus = GetFocus (); - if (focus) - focus->SendMessage (WM_COPY); -} - -void CGeorgesEditView::OnEditCut() -{ - CWnd *focus = GetFocus (); - if (focus) - focus->SendMessage (WM_CUT); -} - -void CGeorgesEditView::OnEditPaste() -{ - CWnd *focus = GetFocus (); - if (focus) - focus->SendMessage (WM_PASTE); -} -/* -void CGeorgesEditView::OnEditUndo() -{ - CWnd *focus = GetFocus (); - if (focus) - focus->SendMessage (WM_UNDO); -} -*/ -void CGeorgesEditView::setViewSize (uint width, uint height) -{ - VirtualWidth = width; - VirtualHeight = height; - SIZE size; - size.cx = VirtualWidth; - size.cy = VirtualHeight; - SetScrollSizes (MM_TEXT, size); -} - -BOOL CGeorgesEditView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) -{ - int nMapMode; - SIZE sizeTotal; - SIZE sizePage; - SIZE sizeLine; - GetDeviceScrollSizes( nMapMode, sizeTotal, sizePage, sizeLine ); - - RECT rect; - GetClientRect (&rect); - if (rect.bottom < sizeTotal.cy) - { - CPoint currentPos = GetDeviceScrollPosition (); - currentPos.y -= zDelta; - ScrollToPosition( currentPos ); - } - - return CScrollView::OnMouseWheel(nFlags, zDelta, pt); -} - - -void CGeorgesEditView::OnEditRedo() -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - doc->OnEditRedo(); - } -} - -void CGeorgesEditView::OnUpdateEditRedo(CCmdUI* pCmdUI) -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - if (doc->isForm ()) - ((CGeorgesEditDocForm*)doc)->OnUpdateEditRedo(pCmdUI) ; - } -} - -void CGeorgesEditView::OnEditUndo() -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - if (doc->isForm ()) - ((CGeorgesEditDocForm*)doc)->OnEditUndo(); - } -} - -void CGeorgesEditView::OnUpdateEditUndo(CCmdUI* pCmdUI) -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - if (doc->isForm ()) - ((CGeorgesEditDocForm*)doc)->OnUpdateEditUndo(pCmdUI) ; - } -} - -void CGeorgesEditView::OnEditFetch1() -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - if (doc->isForm ()) - ((CGeorgesEditDocForm*)doc)->OnEditFetch1(); - } -} - -void CGeorgesEditView::OnEditFetch2() -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - if (doc->isForm ()) - ((CGeorgesEditDocForm*)doc)->OnEditFetch2(); - } -} - -void CGeorgesEditView::OnEditFetch3() -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - if (doc->isForm ()) - ((CGeorgesEditDocForm*)doc)->OnEditFetch3(); - } -} - -void CGeorgesEditView::OnEditFetch4() -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - if (doc->isForm ()) - ((CGeorgesEditDocForm*)doc)->OnEditFetch4(); - } -} - -void CGeorgesEditView::OnEditHold1() -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - if (doc->isForm ()) - ((CGeorgesEditDocForm*)doc)->OnEditHold1(); - } -} - -void CGeorgesEditView::OnEditHold2() -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - if (doc->isForm ()) - ((CGeorgesEditDocForm*)doc)->OnEditHold2(); - } -} - -void CGeorgesEditView::OnEditHold3() -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - if (doc->isForm ()) - ((CGeorgesEditDocForm*)doc)->OnEditHold3(); - } -} - -void CGeorgesEditView::OnEditHold4() -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - if (doc->isForm ()) - ((CGeorgesEditDocForm*)doc)->OnEditHold4(); - } -} +// 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 "stdafx.h" +#include "georges_edit.h" + +#include "georges_edit_doc.h" +#include "georges_edit_view.h" +#include "left_view.h" + +using namespace NLGEORGES; + + +///////////////////////////////////////////////////////////////////////////// +// CGeorgesEditView + +IMPLEMENT_DYNCREATE(CGeorgesEditView, CScrollView) + +BEGIN_MESSAGE_MAP(CGeorgesEditView, CScrollView) + //{{AFX_MSG_MAP(CGeorgesEditView) + ON_WM_SIZE() + ON_WM_SETFOCUS() + ON_COMMAND(ID_OPEN_SELECTED, OnOpenSelected) + ON_COMMAND(ID_EDIT_COPY, OnEditCopy) + ON_COMMAND(ID_EDIT_CUT, OnEditCut) + ON_COMMAND(ID_EDIT_PASTE, OnEditPaste) + ON_WM_MOUSEWHEEL() + ON_WM_KEYDOWN() + ON_COMMAND(ID_EDIT_REDO, OnEditRedo) + ON_UPDATE_COMMAND_UI(ID_EDIT_REDO, OnUpdateEditRedo) + ON_COMMAND(ID_EDIT_UNDO, OnEditUndo) + ON_UPDATE_COMMAND_UI(ID_EDIT_UNDO, OnUpdateEditUndo) + ON_COMMAND(ID_EDIT_FETCH1, OnEditFetch1) + ON_COMMAND(ID_EDIT_FETCH2, OnEditFetch2) + ON_COMMAND(ID_EDIT_FETCH3, OnEditFetch3) + ON_COMMAND(ID_EDIT_FETCH4, OnEditFetch4) + ON_COMMAND(ID_EDIT_HOLD1, OnEditHold1) + ON_COMMAND(ID_EDIT_HOLD2, OnEditHold2) + ON_COMMAND(ID_EDIT_HOLD3, OnEditHold3) + ON_COMMAND(ID_EDIT_HOLD4, OnEditHold4) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CGeorgesEditView construction/destruction + +CGeorgesEditView::CGeorgesEditView() +{ + VirtualWidth = 100; + VirtualHeight = 100; +} + +CGeorgesEditView::~CGeorgesEditView() +{ +} + +BOOL CGeorgesEditView::PreCreateWindow(CREATESTRUCT& cs) +{ + // TODO: Modify the Window class or styles here by modifying + // the CREATESTRUCT cs + + return CScrollView::PreCreateWindow(cs); +} + +///////////////////////////////////////////////////////////////////////////// +// CGeorgesEditView drawing + +void CGeorgesEditView::OnDraw(CDC* pDC) +{ + CGeorgesEditDoc* pDoc = GetDocument(); + ASSERT_VALID(pDoc); +} + +void CGeorgesEditView::OnInitialUpdate() +{ + CScrollView::OnInitialUpdate(); + + // its list control through a call to GetListCtrl(). + CGeorgesEditDoc* pDoc = GetDocument(); + + // Save modified state + pDoc->NoModification = true; + + SIZE size; + size.cx = VirtualWidth; + size.cy = VirtualHeight; + SetScrollSizes (MM_TEXT, size); + + RECT rect; + GetClientRect (&rect); + + // Create the tab + TabCtrl.Create (WS_VISIBLE, rect, this, 0); + TabCtrl.SetImageList (&(theApp.ImageList.ImageList)); + TabCtrl.SetWindowPos (NULL, 0, 0, std::max ((int)VirtualWidth, (int)(rect.right-rect.left)), std::max ((int)VirtualHeight, (int)(rect.bottom-rect.top)), SWP_NOZORDER|SWP_NOOWNERZORDER); + + // Update the tab + updateTab (); + + // Create the type dialog + RECT tabClient; + TabCtrl.GetClientRect (&tabClient); + TypeDialog.View = this; + TypeDialog.Create (CBaseDialog::IDD, &TabCtrl); + TypeDialog.SetWindowPos (NULL, WidgetLeftMargin, WidgetTopMargin, tabClient.right - tabClient.left - WidgetLeftMargin - WidgetRightMargin, tabClient.bottom - tabClient.top - WidgetTopMargin - WidgetBottomMargin, SWP_NOZORDER|SWP_NOOWNERZORDER); + + // Create the header dialog + HeaderDialog.View = this; + HeaderDialog.Create (CBaseDialog::IDD, &TabCtrl); + HeaderDialog.SetWindowPos (NULL, WidgetLeftMargin, WidgetTopMargin, tabClient.right - tabClient.left - WidgetLeftMargin - WidgetRightMargin, tabClient.bottom - tabClient.top - WidgetTopMargin - WidgetBottomMargin, SWP_NOZORDER|SWP_NOOWNERZORDER); + + // Create the dfn dialog + DfnDialog.View = this; + DfnDialog.Create (CBaseDialog::IDD, &TabCtrl); + DfnDialog.SetWindowPos (NULL, WidgetLeftMargin, WidgetTopMargin, tabClient.right - tabClient.left - WidgetLeftMargin - WidgetRightMargin, tabClient.bottom - tabClient.top - WidgetTopMargin - WidgetBottomMargin, SWP_NOZORDER|SWP_NOOWNERZORDER); + + // Create the dfn dialog + FormDialog.View = this; + FormDialog.Create (CBaseDialog::IDD, &TabCtrl); + FormDialog.SetWindowPos (NULL, WidgetLeftMargin, WidgetTopMargin, tabClient.right - tabClient.left - WidgetLeftMargin - WidgetRightMargin, tabClient.bottom - tabClient.top - WidgetTopMargin - WidgetBottomMargin, SWP_NOZORDER|SWP_NOOWNERZORDER); + + // Set tab font + CFont* font = TypeDialog.GetFont (); + TabCtrl.SetFont (font); + TabCtrl.ShowWindow (SW_SHOW); + + // Update document + updateDocument (); + + // Save modified state + pDoc->NoModification = false; + + // Is it a form ? + theApp.onNewDocView (pDoc); + + // Notify the doc plugin + uint i; + CGeorgesEditDocSub *selection = pDoc->getSelectedObject (); + for (i=0; iPluginArray.size (); i++) + { + // Activate / desactivate plugin + pDoc->PluginArray[i].PluginInterface->onNodeChanged (); + } +} + +///////////////////////////////////////////////////////////////////////////// +// CGeorgesEditView diagnostics + +#ifdef _DEBUG +void CGeorgesEditView::AssertValid() const +{ + CScrollView::AssertValid(); +} + +void CGeorgesEditView::Dump(CDumpContext& dc) const +{ + CScrollView::Dump(dc); +} + +CGeorgesEditDoc* CGeorgesEditView::GetDocument() // non-debug version is inline +{ + ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CGeorgesEditDocType)) || + m_pDocument->IsKindOf(RUNTIME_CLASS(CGeorgesEditDocDfn)) || + m_pDocument->IsKindOf(RUNTIME_CLASS(CGeorgesEditDocForm))); + return (CGeorgesEditDoc*)m_pDocument; +} +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CGeorgesEditView message handlers +void CGeorgesEditView::OnStyleChanged(int nStyleType, LPSTYLESTRUCT lpStyleStruct) +{ + //TODO: add code to react to the user changing the view style of your window +} + +void CGeorgesEditView::OnSize(UINT nType, int cx, int cy) +{ + CScrollView::OnSize(nType, cx, cy); + + UpdateData (); + + if (IsWindow (TabCtrl)) + { + CPoint currentPos = GetDeviceScrollPosition (); + + RECT rect; + GetClientRect (&rect); + + if (IsWindow (TypeDialog) && TypeDialog.IsWindowVisible ()) + { + TypeDialog.resizeWidgets (); + } + + // Resize header dialog + if (IsWindow (HeaderDialog) && HeaderDialog.IsWindowVisible ()) + { + HeaderDialog.resizeWidgets (); + } + + // Resize dfn dialog + if (IsWindow (DfnDialog) && DfnDialog.IsWindowVisible ()) + { + DfnDialog.resizeWidgets (); + } + + // Resize dfn dialog + if (IsWindow (FormDialog) && FormDialog.IsWindowVisible ()) + { + FormDialog.resizeWidgets (); + } + + // Create the tab + TabCtrl.SetWindowPos (NULL, -currentPos.x, -currentPos.y, std::max ((int)VirtualWidth, (int)(rect.right-rect.left)), std::max ((int)VirtualHeight, (int)(rect.bottom-rect.top)), SWP_NOZORDER|SWP_NOOWNERZORDER); + + // Resize type dialog + RECT tabClient; + TabCtrl.GetClientRect (&tabClient); + + // Resize type dialog + if (IsWindow (TypeDialog)) + { + TypeDialog.SetWindowPos (NULL, WidgetLeftMargin, WidgetTopMargin, tabClient.right - tabClient.left - WidgetLeftMargin - WidgetRightMargin, + tabClient.bottom - tabClient.top - WidgetTopMargin - WidgetBottomMargin, SWP_NOZORDER|SWP_NOOWNERZORDER); + } + + // Resize header dialog + if (IsWindow (HeaderDialog)) + { + HeaderDialog.SetWindowPos (NULL, WidgetLeftMargin, WidgetTopMargin, tabClient.right - tabClient.left - WidgetLeftMargin - WidgetRightMargin, + tabClient.bottom - tabClient.top - WidgetTopMargin - WidgetBottomMargin, SWP_NOZORDER|SWP_NOOWNERZORDER); + } + + // Resize dfn dialog + if (IsWindow (DfnDialog)) + DfnDialog.SetWindowPos (NULL, WidgetLeftMargin, WidgetTopMargin, tabClient.right - tabClient.left - WidgetLeftMargin - WidgetRightMargin, + tabClient.bottom - tabClient.top - WidgetTopMargin - WidgetBottomMargin, SWP_NOZORDER|SWP_NOOWNERZORDER); + + // Resize dfn dialog + if (IsWindow (FormDialog)) + FormDialog.SetWindowPos (NULL, WidgetLeftMargin, WidgetTopMargin, tabClient.right - tabClient.left - WidgetLeftMargin - WidgetRightMargin, + tabClient.bottom - tabClient.top - WidgetTopMargin - WidgetBottomMargin, SWP_NOZORDER|SWP_NOOWNERZORDER); + } + + UpdateData (FALSE); +} + +void CGeorgesEditView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) +{ + // Not me ? + if (pSender != this) + { + // Update + updateTab (); + updateDocument (); + } +} + +void CGeorgesEditView::updateTab () +{ + if (IsWindow (TabCtrl)) + { + // Clear the tab + TabCtrl.DeleteAllItems (); + + CGeorgesEditDoc *doc = GetDocument(); + if (doc) + { + // Current selection + CGeorgesEditDocSub *subObject = doc->getSelectedObject (); + if (subObject) + { + // Get parent + CGeorgesEditDocSub *parent = subObject->getParent (); + if (parent) + { + // For each subobject + int tabSelected = -1; + for (uint i=0; igetChildrenCount(); i++) + { + // Init the tab + CGeorgesEditDocSub *child = parent->getChild (i); + int image = child->getItemImage (doc); + TabCtrl.InsertItem (i, child->getName ().c_str(), image); + + // This is the selection ? + if (subObject == child) + tabSelected = i; + } + + // Should be found + nlassert (tabSelected!=-1); + TabCtrl.SetCurSel (tabSelected); + + UpdateData (FALSE); + } + } + } + } +} + +void CGeorgesEditView::updateDocument () +{ + if (IsWindow (TabCtrl) && IsWindow (DfnDialog) && IsWindow (TypeDialog) && IsWindow (FormDialog) && IsWindow (HeaderDialog) ) + { + CGeorgesEditDoc *doc = GetDocument(); + if (doc) + { + // Hide all the window + TypeDialog.ShowWindow (SW_HIDE); + HeaderDialog.ShowWindow (SW_HIDE); + DfnDialog.ShowWindow (SW_HIDE); + FormDialog.ShowWindow (SW_HIDE); + + // Current selection + CGeorgesEditDocSub *subObject = doc->getSelectedObject (); + if (subObject) + { + switch (subObject->getType ()) + { + case CGeorgesEditDocSub::Type: + { + // Get the document + TypeDialog.getFromDocument (*doc->getTypePtr ()); + + // Show the window + TypeDialog.resizeWidgets (); + TypeDialog.ShowWindow (SW_SHOW); + } + break; + case CGeorgesEditDocSub::Header: + { + // Get the document + HeaderDialog.getFromDocument (*doc->getHeaderPtr ()); + + // Show the window + HeaderDialog.resizeWidgets (); + HeaderDialog.ShowWindow (SW_SHOW); + } + break; + case CGeorgesEditDocSub::Dfn: + { + // Get the document + DfnDialog.getFromDocument (*doc->getDfnPtr ()); + + // Show the window + DfnDialog.resizeWidgets (); + DfnDialog.ShowWindow (SW_SHOW); + } + break; + case CGeorgesEditDocSub::Form: + { + // Get the document + FormDialog.getFromDocument (); + + // Show the window + FormDialog.resizeWidgets (); + FormDialog.ShowWindow (SW_SHOW); + } + break; + } + } + } + } +} + +BOOL CGeorgesEditView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) +{ + LPNMHDR pnmh = (LPNMHDR) lParam; + switch (pnmh->code) + { + case TCN_SELCHANGE: + { + UpdateData (); + + // Get the document + CGeorgesEditDoc *doc = GetDocument(); + if (doc) + { + // Current selection + CGeorgesEditDocSub *subObject = doc->getSelectedObject (); + if (subObject) + { + // Get parent + CGeorgesEditDocSub *parent = subObject->getParent (); + if (parent) + { + // Get the child + CGeorgesEditDocSub *child = parent->getChild (TabCtrl.GetCurSel ()); + + // Sub selection changed + CLeftView* pView = doc->getLeftView (); + doc->changeSubSelection (child, pView); + TabCtrl.SetFocus (); + } + } + } + } + break; + } + + return CScrollView::OnNotify(wParam, lParam, pResult); +} + +void CGeorgesEditView::OnSetFocus(CWnd* pOldWnd) +{ + CScrollView::OnSetFocus(pOldWnd); + + TabCtrl.UpdateData (); + if ( (TabCtrl.GetItemCount ()) && (pOldWnd != &TabCtrl) ) + { + TabCtrl.SetFocus (); + } + else + { + if (TypeDialog.IsWindowVisible ()) + TypeDialog.SetFocus (); + if (HeaderDialog.IsWindowVisible ()) + HeaderDialog.SetFocus (); + if (DfnDialog.IsWindowVisible ()) + DfnDialog.SetFocus (); + if (FormDialog.IsWindowVisible ()) + FormDialog.SetFocus (); + } +} + +BOOL CGeorgesEditView::PreTranslateMessage(MSG* pMsg) +{ + if (theApp.m_pMainWnd->PreTranslateMessage(pMsg)) + return TRUE; + + if ((pMsg->message == WM_KEYDOWN) && ((int) pMsg->wParam == VK_TAB) ) + { + // Shift ? + if (GetAsyncKeyState (VK_SHIFT) & (1<<15)) + setFocusLeftView (); + else + SetFocus (); + return TRUE; + } + + return CScrollView::PreTranslateMessage(pMsg); +} + +void CGeorgesEditView::OnOpenSelected() +{ + if (HeaderDialog.IsWindowVisible ()) + { + HeaderDialog.onOpenSelected (); + } + if (TypeDialog.IsWindowVisible ()) + { + TypeDialog.onOpenSelected (); + } + if (DfnDialog.IsWindowVisible ()) + { + DfnDialog.onOpenSelected (); + } + if (FormDialog.IsWindowVisible ()) + { + FormDialog.onOpenSelected (); + } +} + +void CGeorgesEditView::setFocusLastWidget () +{ + if (HeaderDialog.IsWindowVisible ()) + { + HeaderDialog.setFocusLastWidget (); + } + if (TypeDialog.IsWindowVisible ()) + { + TypeDialog.setFocusLastWidget (); + } + if (DfnDialog.IsWindowVisible ()) + { + DfnDialog.setFocusLastWidget (); + } + if (FormDialog.IsWindowVisible ()) + { + FormDialog.setFocusLastWidget (); + } +} + +bool CGeorgesEditView::isFocusable () const +{ + return (HeaderDialog.IsWindowVisible () || TypeDialog.IsWindowVisible () || DfnDialog.IsWindowVisible () || FormDialog.IsWindowVisible ()); +} + +void CGeorgesEditView::setFocusLeftView () +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + CLeftView* pView = doc->getLeftView (); + doc->switchToView (pView); + } +} + +LRESULT CGeorgesEditView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) +{ + // When this message arrive, update the view + if (message == WM_UPDATE_ALL_VIEWS) + GetDocument ()->UpdateAllViews (NULL); + + return CScrollView::WindowProc(message, wParam, lParam); +} + +void CGeorgesEditView::OnEditCopy() +{ + CWnd *focus = GetFocus (); + if (focus) + focus->SendMessage (WM_COPY); +} + +void CGeorgesEditView::OnEditCut() +{ + CWnd *focus = GetFocus (); + if (focus) + focus->SendMessage (WM_CUT); +} + +void CGeorgesEditView::OnEditPaste() +{ + CWnd *focus = GetFocus (); + if (focus) + focus->SendMessage (WM_PASTE); +} +/* +void CGeorgesEditView::OnEditUndo() +{ + CWnd *focus = GetFocus (); + if (focus) + focus->SendMessage (WM_UNDO); +} +*/ +void CGeorgesEditView::setViewSize (uint width, uint height) +{ + VirtualWidth = width; + VirtualHeight = height; + SIZE size; + size.cx = VirtualWidth; + size.cy = VirtualHeight; + SetScrollSizes (MM_TEXT, size); +} + +BOOL CGeorgesEditView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) +{ + int nMapMode; + SIZE sizeTotal; + SIZE sizePage; + SIZE sizeLine; + GetDeviceScrollSizes( nMapMode, sizeTotal, sizePage, sizeLine ); + + RECT rect; + GetClientRect (&rect); + if (rect.bottom < sizeTotal.cy) + { + CPoint currentPos = GetDeviceScrollPosition (); + currentPos.y -= zDelta; + ScrollToPosition( currentPos ); + } + + return CScrollView::OnMouseWheel(nFlags, zDelta, pt); +} + + +void CGeorgesEditView::OnEditRedo() +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + doc->OnEditRedo(); + } +} + +void CGeorgesEditView::OnUpdateEditRedo(CCmdUI* pCmdUI) +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + if (doc->isForm ()) + ((CGeorgesEditDocForm*)doc)->OnUpdateEditRedo(pCmdUI) ; + } +} + +void CGeorgesEditView::OnEditUndo() +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + if (doc->isForm ()) + ((CGeorgesEditDocForm*)doc)->OnEditUndo(); + } +} + +void CGeorgesEditView::OnUpdateEditUndo(CCmdUI* pCmdUI) +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + if (doc->isForm ()) + ((CGeorgesEditDocForm*)doc)->OnUpdateEditUndo(pCmdUI) ; + } +} + +void CGeorgesEditView::OnEditFetch1() +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + if (doc->isForm ()) + ((CGeorgesEditDocForm*)doc)->OnEditFetch1(); + } +} + +void CGeorgesEditView::OnEditFetch2() +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + if (doc->isForm ()) + ((CGeorgesEditDocForm*)doc)->OnEditFetch2(); + } +} + +void CGeorgesEditView::OnEditFetch3() +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + if (doc->isForm ()) + ((CGeorgesEditDocForm*)doc)->OnEditFetch3(); + } +} + +void CGeorgesEditView::OnEditFetch4() +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + if (doc->isForm ()) + ((CGeorgesEditDocForm*)doc)->OnEditFetch4(); + } +} + +void CGeorgesEditView::OnEditHold1() +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + if (doc->isForm ()) + ((CGeorgesEditDocForm*)doc)->OnEditHold1(); + } +} + +void CGeorgesEditView::OnEditHold2() +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + if (doc->isForm ()) + ((CGeorgesEditDocForm*)doc)->OnEditHold2(); + } +} + +void CGeorgesEditView::OnEditHold3() +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + if (doc->isForm ()) + ((CGeorgesEditDocForm*)doc)->OnEditHold3(); + } +} + +void CGeorgesEditView::OnEditHold4() +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + if (doc->isForm ()) + ((CGeorgesEditDocForm*)doc)->OnEditHold4(); + } +} diff --git a/code/ryzom/tools/leveldesign/georges_dll/georges_edit_view.h b/code/ryzom/tools/leveldesign/georges_dll/georges_edit_view.h index 1a923824f..21469bed8 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/georges_edit_view.h +++ b/code/ryzom/tools/leveldesign/georges_dll/georges_edit_view.h @@ -1,141 +1,141 @@ -// 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 . - -#if !defined(AFX_GEORGES_EDITVIEW_H__BA694E6B_7DC1_40A4_BD65_2A4272862E8A__INCLUDED_) -#define AFX_GEORGES_EDITVIEW_H__BA694E6B_7DC1_40A4_BD65_2A4272862E8A__INCLUDED_ - -#include "type_dialog.h" -#include "header_dialog.h" -#include "dfn_dialog.h" -#include "form_dialog.h" - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -class CGeorgesEditDoc; - -#define WM_UPDATE_ALL_VIEWS (WM_APP+0x20) - -class CGeorgesEditView : public CScrollView -{ -protected: // create from serialization only - CGeorgesEditView(); - DECLARE_DYNCREATE(CGeorgesEditView) - - enum - { - WidgetLeftMargin = 20, - WidgetTopMargin = 40, - WidgetRightMargin = 20, - WidgetBottomMargin = 20, - }; - -// Attributes -public: - CGeorgesEditDoc* GetDocument(); - - // The top tab control - CTabCtrl TabCtrl; - - // The header dialog - CHeaderDialog HeaderDialog; - - // The type dialog - CTypeDialog TypeDialog; - - // The dfn dialog - CDfnDialog DfnDialog; - - // The form dialog - CFormDialog FormDialog; - - // Set the virtual view size (call by rightview dialog is resizeWidget callback - void setViewSize (uint width, uint height); - - void updateTab (); - void updateDocument (); - bool isFocusable () const; - void setFocusLeftView (); - void setFocusLastWidget (); - - uint VirtualWidth, VirtualHeight; - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CGeorgesEditView) - public: - virtual void OnDraw(CDC* pDC); // overridden to draw this view - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - virtual BOOL PreTranslateMessage(MSG* pMsg); - protected: - virtual void OnInitialUpdate(); // called first time after construct - virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint); - virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); - virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CGeorgesEditView(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - -// Generated message map functions -protected: - //{{AFX_MSG(CGeorgesEditView) - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnSetFocus(CWnd* pOldWnd); - afx_msg void OnOpenSelected(); - afx_msg void OnEditCopy(); - afx_msg void OnEditCut(); - afx_msg void OnEditPaste(); - afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt); - afx_msg void OnEditRedo(); - afx_msg void OnUpdateEditRedo(CCmdUI* pCmdUI); - afx_msg void OnEditUndo(); - afx_msg void OnUpdateEditUndo(CCmdUI* pCmdUI); - afx_msg void OnEditFetch1(); - afx_msg void OnEditFetch2(); - afx_msg void OnEditFetch3(); - afx_msg void OnEditFetch4(); - afx_msg void OnEditHold1(); - afx_msg void OnEditHold2(); - afx_msg void OnEditHold3(); - afx_msg void OnEditHold4(); - //}}AFX_MSG - afx_msg void OnStyleChanged(int nStyleType, LPSTYLESTRUCT lpStyleStruct); - DECLARE_MESSAGE_MAP() -}; - -#ifndef _DEBUG // debug version in georges_editView.cpp -inline CGeorgesEditDoc* CGeorgesEditView::GetDocument() - { return (CGeorgesEditDoc*)m_pDocument; } -#endif - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_GEORGES_EDITVIEW_H__BA694E6B_7DC1_40A4_BD65_2A4272862E8A__INCLUDED_) +// 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 . + +#if !defined(AFX_GEORGES_EDITVIEW_H__BA694E6B_7DC1_40A4_BD65_2A4272862E8A__INCLUDED_) +#define AFX_GEORGES_EDITVIEW_H__BA694E6B_7DC1_40A4_BD65_2A4272862E8A__INCLUDED_ + +#include "type_dialog.h" +#include "header_dialog.h" +#include "dfn_dialog.h" +#include "form_dialog.h" + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +class CGeorgesEditDoc; + +#define WM_UPDATE_ALL_VIEWS (WM_APP+0x20) + +class CGeorgesEditView : public CScrollView +{ +protected: // create from serialization only + CGeorgesEditView(); + DECLARE_DYNCREATE(CGeorgesEditView) + + enum + { + WidgetLeftMargin = 20, + WidgetTopMargin = 40, + WidgetRightMargin = 20, + WidgetBottomMargin = 20, + }; + +// Attributes +public: + CGeorgesEditDoc* GetDocument(); + + // The top tab control + CTabCtrl TabCtrl; + + // The header dialog + CHeaderDialog HeaderDialog; + + // The type dialog + CTypeDialog TypeDialog; + + // The dfn dialog + CDfnDialog DfnDialog; + + // The form dialog + CFormDialog FormDialog; + + // Set the virtual view size (call by rightview dialog is resizeWidget callback + void setViewSize (uint width, uint height); + + void updateTab (); + void updateDocument (); + bool isFocusable () const; + void setFocusLeftView (); + void setFocusLastWidget (); + + uint VirtualWidth, VirtualHeight; + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CGeorgesEditView) + public: + virtual void OnDraw(CDC* pDC); // overridden to draw this view + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + virtual BOOL PreTranslateMessage(MSG* pMsg); + protected: + virtual void OnInitialUpdate(); // called first time after construct + virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint); + virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); + virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CGeorgesEditView(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + +// Generated message map functions +protected: + //{{AFX_MSG(CGeorgesEditView) + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnSetFocus(CWnd* pOldWnd); + afx_msg void OnOpenSelected(); + afx_msg void OnEditCopy(); + afx_msg void OnEditCut(); + afx_msg void OnEditPaste(); + afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt); + afx_msg void OnEditRedo(); + afx_msg void OnUpdateEditRedo(CCmdUI* pCmdUI); + afx_msg void OnEditUndo(); + afx_msg void OnUpdateEditUndo(CCmdUI* pCmdUI); + afx_msg void OnEditFetch1(); + afx_msg void OnEditFetch2(); + afx_msg void OnEditFetch3(); + afx_msg void OnEditFetch4(); + afx_msg void OnEditHold1(); + afx_msg void OnEditHold2(); + afx_msg void OnEditHold3(); + afx_msg void OnEditHold4(); + //}}AFX_MSG + afx_msg void OnStyleChanged(int nStyleType, LPSTYLESTRUCT lpStyleStruct); + DECLARE_MESSAGE_MAP() +}; + +#ifndef _DEBUG // debug version in georges_editView.cpp +inline CGeorgesEditDoc* CGeorgesEditView::GetDocument() + { return (CGeorgesEditDoc*)m_pDocument; } +#endif + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_GEORGES_EDITVIEW_H__BA694E6B_7DC1_40A4_BD65_2A4272862E8A__INCLUDED_) diff --git a/code/ryzom/tools/leveldesign/georges_dll/georges_implementation.cpp b/code/ryzom/tools/leveldesign/georges_dll/georges_implementation.cpp index 8301f76bc..b97c22dba 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/georges_implementation.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/georges_implementation.cpp @@ -1,689 +1,689 @@ -// 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 . - -// Interface Implementation - -#include "stdafx.h" - -#undef GEORGES_EXPORT -#define GEORGES_EXPORT __declspec( dllexport ) - -#include "georges_interface.h" -#include "georges_edit.h" -#include "main_frm.h" -#include "left_view.h" -#include "georges_edit_doc.h" -#include "georges_edit_view.h" -#include "child_frm.h" -#include "action.h" - -#include "nel/georges/form_elm.h" -#include "nel/georges/type.h" -#include "nel/georges/form.h" -#include "nel/georges/form_elm.h" - -#include "nel/misc/file.h" -#include "nel/misc/o_xml.h" - -#include - -using namespace NLGEORGES; -using namespace NLMISC; - -///////////////////////////////////////////////////////////////////////////// -// The one and only CGeorgesEditApp object - -// CGeorgesEditApp TheGlobalApp; - - -// The interface implemented through this class -class CGeorgesImpl : public IGeorges -{ - -public: - - CGeorgesImpl(); - - virtual ~CGeorgesImpl(); - - // Init the UI - virtual void initUI (int nCmdShow, bool exeStandalone, HWND parent=NULL); - - // Init the UI Light version - virtual void initUILight (int nCmdShow, int x, int y, int cx, int cy); - - // Go - virtual void go (); - - // Release the UI - virtual void releaseUI (); - - // Get the main frame - virtual void* getMainFrame (); - - // Get instance - static GEORGES_EXPORT IGeorges* getInterface (int version = GEORGES_VERSION); - - // Release instance - static GEORGES_EXPORT void releaseInterface (IGeorges* pGeorges); - - virtual void createInstanceFile (const std::string &_sxFullnameWithoutExt, const std::string &_dfnname); - -// virtual void NewDocument(); - - virtual void NewDocument( const std::string& _sxdfnname); - - virtual void LoadDocument( const std::string& _sxfullname ); - -/* virtual void SaveDocument( const std::string& _sxfullname ); - - virtual void CloseDocument(); -*/ - // Directories settings - virtual void SetDirDfnTyp (const std::string& _sxworkdirectory); - virtual void SetDirPrototype (const std::string& _sxrootdirectory); - virtual void SetDirLevel (const std::string& _sxrootdirectory); - - virtual std::string GetDirDfnTyp (); -/* virtual std::string GetDirPrototype (); - virtual std::string GetDirLevel ();*/ - - // Put a text in the right cell - virtual void PutGroupText (const std::vector& _vText, bool append); - virtual void PutText (const std::string& _sText); - virtual void LineUp (); - virtual void LineDown (); - - virtual BOOL PreTranslateMessage (MSG *pMsg); -/* - virtual void SaveAllDocument(); - - virtual void CloseAllDocument(); - - virtual void SetTypPredef( const std::string& _sxfilename, const std::vector< std::string >& _pvs ); - - virtual void MakeDfn( const std::string& _sxfullname, const std::vector< std::pair< std::string, std::string > >* const _pvdefine = 0 );*/ - - virtual void MakeTyp( const std::string& filename, TType type, TUI ui, const std::string& _min, const std::string& _max, const std::string& _default, const std::vector< std::pair< std::string, std::string > >* const _pvpredef ); -}; - -// --------------------------------------------------------------------------- -CGeorgesImpl::CGeorgesImpl() -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); -} - -// --------------------------------------------------------------------------- -CGeorgesImpl::~CGeorgesImpl() -{ -} - -// --------------------------------------------------------------------------- -void CGeorgesImpl::initUI( int nCmdShow, bool exeStandalone, HWND parent) -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - - theApp.initInstance(nCmdShow, exeStandalone, -1, -1, -1, -1); -} - -// --------------------------------------------------------------------------- -void CGeorgesImpl::initUILight (int nCmdShow, int x, int y, int cx, int cy) -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - - theApp.initInstance (nCmdShow, false, x, y, cx, cy); - ((CMainFrame*)(theApp.m_pMainWnd))->m_bDontClose = true; - theApp.OnViewRefresh(); -} - -// --------------------------------------------------------------------------- -void CGeorgesImpl::go() -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - - theApp.Run (); - // theApp.m_pMainWnd->ActivateFrame; - -/* - MSG msg; - while (GetMessage( &msg, *theApp.m_pMainWnd, 0, 0) == TRUE) - { - if (!theApp.m_pMainWnd->PreTranslateMessage(&msg)) - { - ::TranslateMessage(&msg); - ::DispatchMessage(&msg); - } - if (!IsWindow (*theApp.m_pMainWnd)) - break; - } */ -} - -// --------------------------------------------------------------------------- -void CGeorgesImpl::releaseUI() -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - - if (IsWindow (*theApp.m_pMainWnd)) - theApp.m_pMainWnd->DestroyWindow(); - theApp.m_pMainWnd = NULL; - theApp.releasePlugins (); -} - -// --------------------------------------------------------------------------- -void * CGeorgesImpl::getMainFrame () -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - - - return theApp.m_pMainWnd; -} - -// --------------------------------------------------------------------------- -void CGeorgesImpl::SetDirDfnTyp (const std::string& _sxDirectory) -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - CGeorgesEditApp* theApp = dynamic_cast(AfxGetApp()); - - //theApp.SetDirDfnTyp (_sxDirectory); -} - -// --------------------------------------------------------------------------- -void CGeorgesImpl::SetDirPrototype (const std::string& _sxDirectory) -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - - //theApp.SetDirPrototype (_sxDirectory); - theApp.RootSearchPath = _sxDirectory; - theApp.initCfg (); - theApp.OnViewRefresh (); -} - -// --------------------------------------------------------------------------- -void CGeorgesImpl::SetDirLevel (const std::string& _sxDirectory) -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - - //theApp.SetDirLevel (_sxDirectory); -} - -// --------------------------------------------------------------------------- -void CGeorgesImpl::PutGroupText (const std::vector& _vText, bool append) -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - CMainFrame *pWnd = dynamic_cast< CMainFrame* >( theApp.m_pMainWnd ); - CChildFrame *pChild = (CChildFrame*)pWnd->MDIGetActive (); - if (pChild == NULL) return; - // Get active document - CGeorgesEditDoc *doc = (CGeorgesEditDoc *)pChild->GetActiveDocument(); - if (doc) - { - // Get the left view - CLeftView* pView = doc->getLeftView (); - - // Check type - CGeorgesEditDocSub *subDoc = doc->getSelectedObject (); - if (subDoc) - { - // Get the node - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - bool parentVDfnArray; - CForm *form=doc->getFormPtr (); - CFormElm *elm = doc->getRootNode (subDoc->getSlot ()); - nlverify ( elm->getNodeByName (subDoc->getFormName ().c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); - - // Is a type entry ? - if ((type == UFormDfn::EntryType) && array) - { - std::string formName = subDoc->getFormName (); - uint slot = subDoc->getSlot (); - - // Current node size - uint size = 0; - if (node) - { - CFormElmArray *arrayPtr = safe_cast(node); - nlverify (arrayPtr->getArraySize (size)); - } - - // Modify the size of the array - char value[512]; - smprintf (value, 512, "%d", _vText.size () + ((append)?size:0)); - doc->modify (new CActionBuffer (IAction::FormArraySize, NULL, 0, *doc, formName.c_str (), - value, doc->getLeftView ()->getCurrentSelectionId (), slot)); - - uint i; - for (i=0; i<_vText.size (); i++) - { - uint index = i + ((append)?size:0); - std::string formNameAtom = formName + "[" + toString (index) + "]"; - doc->modify (new CActionString (IAction::FormTypeValue, _vText[i].c_str (), *doc, formNameAtom.c_str (), "", - doc->getLeftView ()->getCurrentSelectionId (), slot)); - doc->modify (new CActionString (IAction::FormArrayRename, _vText[i].c_str(), *doc, formNameAtom.c_str (), - toString (index).c_str (), doc->getLeftView ()->getCurrentSelectionId (), slot)); - } - } - } - } -} - -// --------------------------------------------------------------------------- -void CGeorgesImpl::PutText (const std::string& _sText) -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - CMainFrame *pWnd = dynamic_cast< CMainFrame* >( theApp.m_pMainWnd ); - CChildFrame *pChild = (CChildFrame*)pWnd->MDIGetActive (); - if (pChild == NULL) return; - // Get active document - CGeorgesEditDoc *doc = (CGeorgesEditDoc *)pChild->GetActiveDocument(); - if (doc) - { - // Get the left view - CLeftView* pView = doc->getLeftView (); - - // Check type - CGeorgesEditDocSub *subDoc = doc->getSelectedObject (); - if (subDoc) - { - // Get the node - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - bool parentVDfnArray; - CForm *form=doc->getFormPtr (); - CFormElm *elm = doc->getRootNode (subDoc->getSlot ()); - nlverify ( elm->getNodeByName (subDoc->getFormName ().c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); - - // It is an array ? - if (array&&(type == UFormDfn::EntryType)) - { - // Modify the node - doc->modify (new CActionString (IAction::FormTypeValue, _sText.c_str(), *doc, subDoc->getFormName ().c_str (), "", - doc->getLeftView ()->getCurrentSelectionId (), subDoc->getSlot ())); - doc->modify (new CActionString (IAction::FormArrayRename, _sText.c_str(), *doc, subDoc->getFormName ().c_str (), - toString (subDoc->getIdInParent ()).c_str (), doc->getLeftView ()->getCurrentSelectionId (), subDoc->getSlot ())); - doc->updateDocumentStructure (); - doc->UpdateAllViews (pView); - } - else if ((UFormDfn::EntryDfn)&&(!array)) - { - // Get the right view - CGeorgesEditView* view = doc->getRightView (); - if (view->FormDialog.WidgetFocused != 0xffffffff) - { - // Set the string - doc->modify (new CActionString (IAction::FormValue, _sText.c_str(), *doc, - view->FormDialog.Widgets[view->FormDialog.WidgetFocused]->getFormName ().c_str (), "", - doc->getLeftView ()->getCurrentSelectionId (), subDoc->getSlot ())); - doc->updateDocumentStructure (); - doc->UpdateAllViews (pView); - } - } - } - } -} - -// --------------------------------------------------------------------------- -void CGeorgesImpl::LineUp () -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - CMainFrame* pWnd = dynamic_cast< CMainFrame* >( theApp.m_pMainWnd ); - CMDIChildWnd *pChild = pWnd->MDIGetActive (); - if (pChild == NULL) return; - // Get active document - CGeorgesEditDoc *doc = (CGeorgesEditDoc *)pChild->GetActiveDocument (); - if (doc) - { - // Get the left view - CLeftView* pView = doc->getLeftView (); - - // Check type - CGeorgesEditDocSub *subDoc = doc->getSelectedObject (); - if (subDoc) - { - // Get the node - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - bool parentVDfnArray; - CForm *form=doc->getFormPtr (); - CFormElm *elm = doc->getRootNode (subDoc->getSlot ()); - nlverify ( elm->getNodeByName (subDoc->getFormName ().c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); - - // Is a type entry ? - if ( (type == UFormDfn::EntryType) && !array ) - { - // Select next - if ((subDoc->getIdInParent ()) > 0) - doc->changeSubSelection (subDoc->getParent ()->getChild (subDoc->getIdInParent ()-1), pView); - } - } - } -} - -// --------------------------------------------------------------------------- -void CGeorgesImpl::LineDown () -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - CMainFrame* pWnd = dynamic_cast< CMainFrame* >( theApp.m_pMainWnd ); - CMDIChildWnd *pChild = pWnd->MDIGetActive (); - if (pChild == NULL) return; - - // Get active document - CGeorgesEditDoc *doc = (CGeorgesEditDoc *)pChild->GetActiveDocument (); - if (doc) - { - // Get the left view - CLeftView* pView = doc->getLeftView (); - - // Check type - CGeorgesEditDocSub *subDoc = doc->getSelectedObject (); - if (subDoc) - { - // Get the node - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - bool parentVDfnArray; - CForm *form=doc->getFormPtr (); - CFormElm *elm = doc->getRootNode (subDoc->getSlot ()); - nlverify ( elm->getNodeByName (subDoc->getFormName ().c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); - - // Is a type entry ? - if ( (type == UFormDfn::EntryType) && !array ) - { - // Select next - if ((subDoc->getIdInParent ()+1) < subDoc->getParent ()->getChildrenCount ()) - doc->changeSubSelection (subDoc->getParent ()->getChild (subDoc->getIdInParent ()+1), pView); - } - } - } -} - -// --------------------------------------------------------------------------- -BOOL CGeorgesImpl::PreTranslateMessage (MSG *pMsg) -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - CMainFrame* pWnd = dynamic_cast< CMainFrame* >( theApp.m_pMainWnd ); - if (pWnd == NULL) - return FALSE; - return theApp.PreTranslateMessage (pMsg); -} - -// --------------------------------------------------------------------------- -/*void CGeorgesImpl::SetTypPredef( const std::string& _sxfilename, const std::vector< std::string >& _pvs ) -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - CGeorgesEditApp* pApp = dynamic_cast< CGeorgesEditApp* >( AfxGetApp() ); - CLoader* ploader = theApp.GetLoader(); - std::vector< CStringEx > vsx; - for( std::vector< std::string >::const_iterator it = _pvs.begin(); it != _pvs.end(); ++it ) - vsx.push_back( *it ); - - try - { - ploader->SetTypPredef( _sxfilename, vsx ); - } - catch (NLMISC::Exception &e) - { - std::string tmp = std::string(e.what()) + "(" + _sxfilename + ")"; - theApp.m_pMainWnd->MessageBox(tmp.c_str(), "Georges_Lib", MB_ICONERROR | MB_OK); - } -} - -// --------------------------------------------------------------------------- -void CGeorgesImpl::MakeDfn( const std::string& _sxfullname, const std::vector< std::pair< std::string, std::string > >* const _pvdefine ) -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - CGeorgesEditApp* papp = dynamic_cast< CGeorgesEditApp* >( AfxGetApp() ); - CLoader* ploader = theApp.GetLoader(); - std::vector< std::pair< CStringEx, CStringEx > >* vsx = 0; - if( _pvdefine ) - { - std::vector< std::pair< CStringEx, CStringEx > > v; - vsx = &v; - for( std::vector< std::pair< std::string, std::string > >::const_iterator it = _pvdefine->begin(); it != _pvdefine->end(); ++it ) - vsx->push_back( std::make_pair( it->first , it->second ) ); - } - ploader->MakeDfn( _sxfullname, vsx ); -} -*/ -// --------------------------------------------------------------------------- -void CGeorgesImpl::MakeTyp( const std::string& filename, TType type, TUI ui, const std::string& _min, const std::string& _max, const std::string& _default, const std::vector< std::pair< std::string, std::string > >* const _pvpredef ) -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - - // Create a type - CType t; - t.Type = (CType::TType)type; - t.UIType = (CType::TUI)ui; - t.Min= _min; - t.Max = _max; - t.Default = _default; - - if (_pvpredef) - { - t.Definitions.resize (_pvpredef->size ()); - uint i; - for (i=0; i<_pvpredef->size (); i++) - { - t.Definitions[i].Label = (*_pvpredef)[i].first; - t.Definitions[i].Value = (*_pvpredef)[i].second; - } - } - - // Save the type - COFile output; - if (output.open (filename)) - { - try - { - // XML stream - COXml outputXml; - outputXml.init (&output); - - // Write - t.write (outputXml.getDocument (), theApp.Georges4CVS); - } - catch (Exception &e) - { - nlwarning ("Error during writting file '%s' : ", filename.c_str (), e.what ()); - } - } - else - { - nlwarning ("Can't open the file %s for writing", filename.c_str ()); - } -} - -// --------------------------------------------------------------------------- -void CGeorgesImpl::createInstanceFile (const std::string &_sxFullnameWithoutExt, const std::string &_dfnname) -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - - CFormLoader formLoader; - CFormDfn *dfn = formLoader.loadFormDfn (_dfnname.c_str(), false); - if (!dfn) - { - char msg[512]; - smprintf (msg, 512, "Can't load DFN '%s'", _dfnname); - theApp.outputError (msg); - return; - } - - NLMISC::CSmartPtr Form = new CForm; - - std::string fullName; - fullName = _sxFullnameWithoutExt + "."; - - int i = 0; - if (_dfnname[i] == '.') ++i; - for (; i < (int)_dfnname.size(); ++i) - { - if (_dfnname[i] == '.') break; - fullName += _dfnname[i]; - } - - ((CFormElmStruct*)&Form->getRootNode ())->build (dfn); - COFile f; - COXml ox; - if (f.open (fullName)) - { - ox.init(&f); - ((NLGEORGES::CForm*)((UForm*)Form))->write (ox.getDocument(), _sxFullnameWithoutExt.c_str (), theApp.Georges4CVS); - ox.flush(); - f.close(); - } - else - { - char msg[512]; - smprintf (msg, 512, "Can't write '%s'", fullName); - theApp.outputError (msg); - return; - } -} - -// --------------------------------------------------------------------------- -void CGeorgesImpl::LoadDocument( const std::string& _sxfullname ) -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - try - { - theApp.OpenDocumentFile(_sxfullname.c_str()); - } - catch (NLMISC::Exception &e) - { - std::string tmp = std::string(e.what()) + "(" + _sxfullname + ")"; - theApp.m_pMainWnd->MessageBox(tmp.c_str(), "Georges_Lib", MB_ICONERROR | MB_OK); - } -} - -// --------------------------------------------------------------------------- -/*void CGeorgesImpl::SaveDocument( const std::string& _sxfullname ) -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - CGeorgesEditApp* pApp = dynamic_cast< CGeorgesEditApp* >( AfxGetApp() ); - CGeorgesDoc* pgdoc = dynamic_cast< CGeorgesDoc* >( ( (CMainFrame*)theApp.m_pMainWnd )->GetActiveDocument() ); - pgdoc->OnSaveDocument( _sxfullname.c_str() ); -} - -// --------------------------------------------------------------------------- -void CGeorgesImpl::SaveAllDocument() -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - CGeorgesEditApp* papp = dynamic_cast< CGeorgesEditApp* >( AfxGetApp() ); - theApp.SaveAllDocument(); -}*/ - -// --------------------------------------------------------------------------- -void CGeorgesImpl::NewDocument( const std::string& _sxdfnname) -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - /*CGeorgesDoc* pgdoc = dynamic_cast< CGeorgesDoc* >( ( (CMainFrame*)theApp.m_pMainWnd )->GetActiveDocument() ); - pgdoc->NewDocument( _sxdfnname );*/ -} - -// --------------------------------------------------------------------------- -/*void CGeorgesImpl::NewDocument() -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - CGeorgesEditApp* pApp = dynamic_cast< CGeorgesEditApp* >( AfxGetApp() ); - CGeorgesDoc* pgdoc = dynamic_cast< CGeorgesDoc* >( ( (CMainFrame*)theApp.m_pMainWnd )->GetActiveDocument() ); - pgdoc->OnNewDocument(); -}*/ - -// --------------------------------------------------------------------------- -/*void CGeorgesImpl::CloseDocument() -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - CGeorgesEditApp* pApp = dynamic_cast< CGeorgesEditApp* >( AfxGetApp() ); - CGeorgesDoc* pgdoc = dynamic_cast< CGeorgesDoc* >( ( (CMainFrame*)theApp.m_pMainWnd )->GetActiveDocument() ); - pgdoc->OnCloseDocument(); -} - -// --------------------------------------------------------------------------- -void CGeorgesImpl::CloseAllDocument() -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - CGeorgesEditApp* pApp = dynamic_cast< CGeorgesEditApp* >( AfxGetApp() ); - theApp.CloseAllDocument(); -}*/ - -// --------------------------------------------------------------------------- -std::string CGeorgesImpl::GetDirDfnTyp () -{ - return theApp.RootSearchPath; -} - -// ******* -// STATICS -// ******* - -// --------------------------------------------------------------------------- -void IGeorges::releaseInterface (IGeorges* pGeorges) -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - - delete pGeorges; - -} - -// --------------------------------------------------------------------------- -IGeorges* IGeorges::getInterface (int version) -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - - // Check version number - if (version != GEORGES_VERSION) - { - MessageBox (NULL, "Bad version of georges.dll.", "Georges", MB_ICONEXCLAMATION|MB_OK); - return NULL; - } - else - return new CGeorgesImpl; - -} - -// --------------------------------------------------------------------------- -IGeorges* IGeorgesGetInterface (int version) -{ - return IGeorges::getInterface (version); - -} - -// --------------------------------------------------------------------------- -void IGeorgesReleaseInterface (IGeorges* pGeorges) -{ - IGeorges::releaseInterface (pGeorges); - -} +// 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 . + +// Interface Implementation + +#include "stdafx.h" + +#undef GEORGES_EXPORT +#define GEORGES_EXPORT __declspec( dllexport ) + +#include "georges_interface.h" +#include "georges_edit.h" +#include "main_frm.h" +#include "left_view.h" +#include "georges_edit_doc.h" +#include "georges_edit_view.h" +#include "child_frm.h" +#include "action.h" + +#include "nel/georges/form_elm.h" +#include "nel/georges/type.h" +#include "nel/georges/form.h" +#include "nel/georges/form_elm.h" + +#include "nel/misc/file.h" +#include "nel/misc/o_xml.h" + +#include + +using namespace NLGEORGES; +using namespace NLMISC; + +///////////////////////////////////////////////////////////////////////////// +// The one and only CGeorgesEditApp object + +// CGeorgesEditApp TheGlobalApp; + + +// The interface implemented through this class +class CGeorgesImpl : public IGeorges +{ + +public: + + CGeorgesImpl(); + + virtual ~CGeorgesImpl(); + + // Init the UI + virtual void initUI (int nCmdShow, bool exeStandalone, HWND parent=NULL); + + // Init the UI Light version + virtual void initUILight (int nCmdShow, int x, int y, int cx, int cy); + + // Go + virtual void go (); + + // Release the UI + virtual void releaseUI (); + + // Get the main frame + virtual void* getMainFrame (); + + // Get instance + static GEORGES_EXPORT IGeorges* getInterface (int version = GEORGES_VERSION); + + // Release instance + static GEORGES_EXPORT void releaseInterface (IGeorges* pGeorges); + + virtual void createInstanceFile (const std::string &_sxFullnameWithoutExt, const std::string &_dfnname); + +// virtual void NewDocument(); + + virtual void NewDocument( const std::string& _sxdfnname); + + virtual void LoadDocument( const std::string& _sxfullname ); + +/* virtual void SaveDocument( const std::string& _sxfullname ); + + virtual void CloseDocument(); +*/ + // Directories settings + virtual void SetDirDfnTyp (const std::string& _sxworkdirectory); + virtual void SetDirPrototype (const std::string& _sxrootdirectory); + virtual void SetDirLevel (const std::string& _sxrootdirectory); + + virtual std::string GetDirDfnTyp (); +/* virtual std::string GetDirPrototype (); + virtual std::string GetDirLevel ();*/ + + // Put a text in the right cell + virtual void PutGroupText (const std::vector& _vText, bool append); + virtual void PutText (const std::string& _sText); + virtual void LineUp (); + virtual void LineDown (); + + virtual BOOL PreTranslateMessage (MSG *pMsg); +/* + virtual void SaveAllDocument(); + + virtual void CloseAllDocument(); + + virtual void SetTypPredef( const std::string& _sxfilename, const std::vector< std::string >& _pvs ); + + virtual void MakeDfn( const std::string& _sxfullname, const std::vector< std::pair< std::string, std::string > >* const _pvdefine = 0 );*/ + + virtual void MakeTyp( const std::string& filename, TType type, TUI ui, const std::string& _min, const std::string& _max, const std::string& _default, const std::vector< std::pair< std::string, std::string > >* const _pvpredef ); +}; + +// --------------------------------------------------------------------------- +CGeorgesImpl::CGeorgesImpl() +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); +} + +// --------------------------------------------------------------------------- +CGeorgesImpl::~CGeorgesImpl() +{ +} + +// --------------------------------------------------------------------------- +void CGeorgesImpl::initUI( int nCmdShow, bool exeStandalone, HWND parent) +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + + theApp.initInstance(nCmdShow, exeStandalone, -1, -1, -1, -1); +} + +// --------------------------------------------------------------------------- +void CGeorgesImpl::initUILight (int nCmdShow, int x, int y, int cx, int cy) +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + + theApp.initInstance (nCmdShow, false, x, y, cx, cy); + ((CMainFrame*)(theApp.m_pMainWnd))->m_bDontClose = true; + theApp.OnViewRefresh(); +} + +// --------------------------------------------------------------------------- +void CGeorgesImpl::go() +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + + theApp.Run (); + // theApp.m_pMainWnd->ActivateFrame; + +/* + MSG msg; + while (GetMessage( &msg, *theApp.m_pMainWnd, 0, 0) == TRUE) + { + if (!theApp.m_pMainWnd->PreTranslateMessage(&msg)) + { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + if (!IsWindow (*theApp.m_pMainWnd)) + break; + } */ +} + +// --------------------------------------------------------------------------- +void CGeorgesImpl::releaseUI() +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + + if (IsWindow (*theApp.m_pMainWnd)) + theApp.m_pMainWnd->DestroyWindow(); + theApp.m_pMainWnd = NULL; + theApp.releasePlugins (); +} + +// --------------------------------------------------------------------------- +void * CGeorgesImpl::getMainFrame () +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + + + return theApp.m_pMainWnd; +} + +// --------------------------------------------------------------------------- +void CGeorgesImpl::SetDirDfnTyp (const std::string& _sxDirectory) +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + CGeorgesEditApp* theApp = dynamic_cast(AfxGetApp()); + + //theApp.SetDirDfnTyp (_sxDirectory); +} + +// --------------------------------------------------------------------------- +void CGeorgesImpl::SetDirPrototype (const std::string& _sxDirectory) +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + + //theApp.SetDirPrototype (_sxDirectory); + theApp.RootSearchPath = _sxDirectory; + theApp.initCfg (); + theApp.OnViewRefresh (); +} + +// --------------------------------------------------------------------------- +void CGeorgesImpl::SetDirLevel (const std::string& _sxDirectory) +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + + //theApp.SetDirLevel (_sxDirectory); +} + +// --------------------------------------------------------------------------- +void CGeorgesImpl::PutGroupText (const std::vector& _vText, bool append) +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + CMainFrame *pWnd = dynamic_cast< CMainFrame* >( theApp.m_pMainWnd ); + CChildFrame *pChild = (CChildFrame*)pWnd->MDIGetActive (); + if (pChild == NULL) return; + // Get active document + CGeorgesEditDoc *doc = (CGeorgesEditDoc *)pChild->GetActiveDocument(); + if (doc) + { + // Get the left view + CLeftView* pView = doc->getLeftView (); + + // Check type + CGeorgesEditDocSub *subDoc = doc->getSelectedObject (); + if (subDoc) + { + // Get the node + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + bool parentVDfnArray; + CForm *form=doc->getFormPtr (); + CFormElm *elm = doc->getRootNode (subDoc->getSlot ()); + nlverify ( elm->getNodeByName (subDoc->getFormName ().c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); + + // Is a type entry ? + if ((type == UFormDfn::EntryType) && array) + { + std::string formName = subDoc->getFormName (); + uint slot = subDoc->getSlot (); + + // Current node size + uint size = 0; + if (node) + { + CFormElmArray *arrayPtr = safe_cast(node); + nlverify (arrayPtr->getArraySize (size)); + } + + // Modify the size of the array + char value[512]; + smprintf (value, 512, "%d", _vText.size () + ((append)?size:0)); + doc->modify (new CActionBuffer (IAction::FormArraySize, NULL, 0, *doc, formName.c_str (), + value, doc->getLeftView ()->getCurrentSelectionId (), slot)); + + uint i; + for (i=0; i<_vText.size (); i++) + { + uint index = i + ((append)?size:0); + std::string formNameAtom = formName + "[" + toString (index) + "]"; + doc->modify (new CActionString (IAction::FormTypeValue, _vText[i].c_str (), *doc, formNameAtom.c_str (), "", + doc->getLeftView ()->getCurrentSelectionId (), slot)); + doc->modify (new CActionString (IAction::FormArrayRename, _vText[i].c_str(), *doc, formNameAtom.c_str (), + toString (index).c_str (), doc->getLeftView ()->getCurrentSelectionId (), slot)); + } + } + } + } +} + +// --------------------------------------------------------------------------- +void CGeorgesImpl::PutText (const std::string& _sText) +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + CMainFrame *pWnd = dynamic_cast< CMainFrame* >( theApp.m_pMainWnd ); + CChildFrame *pChild = (CChildFrame*)pWnd->MDIGetActive (); + if (pChild == NULL) return; + // Get active document + CGeorgesEditDoc *doc = (CGeorgesEditDoc *)pChild->GetActiveDocument(); + if (doc) + { + // Get the left view + CLeftView* pView = doc->getLeftView (); + + // Check type + CGeorgesEditDocSub *subDoc = doc->getSelectedObject (); + if (subDoc) + { + // Get the node + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + bool parentVDfnArray; + CForm *form=doc->getFormPtr (); + CFormElm *elm = doc->getRootNode (subDoc->getSlot ()); + nlverify ( elm->getNodeByName (subDoc->getFormName ().c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); + + // It is an array ? + if (array&&(type == UFormDfn::EntryType)) + { + // Modify the node + doc->modify (new CActionString (IAction::FormTypeValue, _sText.c_str(), *doc, subDoc->getFormName ().c_str (), "", + doc->getLeftView ()->getCurrentSelectionId (), subDoc->getSlot ())); + doc->modify (new CActionString (IAction::FormArrayRename, _sText.c_str(), *doc, subDoc->getFormName ().c_str (), + toString (subDoc->getIdInParent ()).c_str (), doc->getLeftView ()->getCurrentSelectionId (), subDoc->getSlot ())); + doc->updateDocumentStructure (); + doc->UpdateAllViews (pView); + } + else if ((UFormDfn::EntryDfn)&&(!array)) + { + // Get the right view + CGeorgesEditView* view = doc->getRightView (); + if (view->FormDialog.WidgetFocused != 0xffffffff) + { + // Set the string + doc->modify (new CActionString (IAction::FormValue, _sText.c_str(), *doc, + view->FormDialog.Widgets[view->FormDialog.WidgetFocused]->getFormName ().c_str (), "", + doc->getLeftView ()->getCurrentSelectionId (), subDoc->getSlot ())); + doc->updateDocumentStructure (); + doc->UpdateAllViews (pView); + } + } + } + } +} + +// --------------------------------------------------------------------------- +void CGeorgesImpl::LineUp () +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + CMainFrame* pWnd = dynamic_cast< CMainFrame* >( theApp.m_pMainWnd ); + CMDIChildWnd *pChild = pWnd->MDIGetActive (); + if (pChild == NULL) return; + // Get active document + CGeorgesEditDoc *doc = (CGeorgesEditDoc *)pChild->GetActiveDocument (); + if (doc) + { + // Get the left view + CLeftView* pView = doc->getLeftView (); + + // Check type + CGeorgesEditDocSub *subDoc = doc->getSelectedObject (); + if (subDoc) + { + // Get the node + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + bool parentVDfnArray; + CForm *form=doc->getFormPtr (); + CFormElm *elm = doc->getRootNode (subDoc->getSlot ()); + nlverify ( elm->getNodeByName (subDoc->getFormName ().c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); + + // Is a type entry ? + if ( (type == UFormDfn::EntryType) && !array ) + { + // Select next + if ((subDoc->getIdInParent ()) > 0) + doc->changeSubSelection (subDoc->getParent ()->getChild (subDoc->getIdInParent ()-1), pView); + } + } + } +} + +// --------------------------------------------------------------------------- +void CGeorgesImpl::LineDown () +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + CMainFrame* pWnd = dynamic_cast< CMainFrame* >( theApp.m_pMainWnd ); + CMDIChildWnd *pChild = pWnd->MDIGetActive (); + if (pChild == NULL) return; + + // Get active document + CGeorgesEditDoc *doc = (CGeorgesEditDoc *)pChild->GetActiveDocument (); + if (doc) + { + // Get the left view + CLeftView* pView = doc->getLeftView (); + + // Check type + CGeorgesEditDocSub *subDoc = doc->getSelectedObject (); + if (subDoc) + { + // Get the node + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + bool parentVDfnArray; + CForm *form=doc->getFormPtr (); + CFormElm *elm = doc->getRootNode (subDoc->getSlot ()); + nlverify ( elm->getNodeByName (subDoc->getFormName ().c_str (), &parentDfn, indexDfn, &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); + + // Is a type entry ? + if ( (type == UFormDfn::EntryType) && !array ) + { + // Select next + if ((subDoc->getIdInParent ()+1) < subDoc->getParent ()->getChildrenCount ()) + doc->changeSubSelection (subDoc->getParent ()->getChild (subDoc->getIdInParent ()+1), pView); + } + } + } +} + +// --------------------------------------------------------------------------- +BOOL CGeorgesImpl::PreTranslateMessage (MSG *pMsg) +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + CMainFrame* pWnd = dynamic_cast< CMainFrame* >( theApp.m_pMainWnd ); + if (pWnd == NULL) + return FALSE; + return theApp.PreTranslateMessage (pMsg); +} + +// --------------------------------------------------------------------------- +/*void CGeorgesImpl::SetTypPredef( const std::string& _sxfilename, const std::vector< std::string >& _pvs ) +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + CGeorgesEditApp* pApp = dynamic_cast< CGeorgesEditApp* >( AfxGetApp() ); + CLoader* ploader = theApp.GetLoader(); + std::vector< CStringEx > vsx; + for( std::vector< std::string >::const_iterator it = _pvs.begin(); it != _pvs.end(); ++it ) + vsx.push_back( *it ); + + try + { + ploader->SetTypPredef( _sxfilename, vsx ); + } + catch (NLMISC::Exception &e) + { + std::string tmp = std::string(e.what()) + "(" + _sxfilename + ")"; + theApp.m_pMainWnd->MessageBox(tmp.c_str(), "Georges_Lib", MB_ICONERROR | MB_OK); + } +} + +// --------------------------------------------------------------------------- +void CGeorgesImpl::MakeDfn( const std::string& _sxfullname, const std::vector< std::pair< std::string, std::string > >* const _pvdefine ) +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + CGeorgesEditApp* papp = dynamic_cast< CGeorgesEditApp* >( AfxGetApp() ); + CLoader* ploader = theApp.GetLoader(); + std::vector< std::pair< CStringEx, CStringEx > >* vsx = 0; + if( _pvdefine ) + { + std::vector< std::pair< CStringEx, CStringEx > > v; + vsx = &v; + for( std::vector< std::pair< std::string, std::string > >::const_iterator it = _pvdefine->begin(); it != _pvdefine->end(); ++it ) + vsx->push_back( std::make_pair( it->first , it->second ) ); + } + ploader->MakeDfn( _sxfullname, vsx ); +} +*/ +// --------------------------------------------------------------------------- +void CGeorgesImpl::MakeTyp( const std::string& filename, TType type, TUI ui, const std::string& _min, const std::string& _max, const std::string& _default, const std::vector< std::pair< std::string, std::string > >* const _pvpredef ) +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + + // Create a type + CType t; + t.Type = (CType::TType)type; + t.UIType = (CType::TUI)ui; + t.Min= _min; + t.Max = _max; + t.Default = _default; + + if (_pvpredef) + { + t.Definitions.resize (_pvpredef->size ()); + uint i; + for (i=0; i<_pvpredef->size (); i++) + { + t.Definitions[i].Label = (*_pvpredef)[i].first; + t.Definitions[i].Value = (*_pvpredef)[i].second; + } + } + + // Save the type + COFile output; + if (output.open (filename)) + { + try + { + // XML stream + COXml outputXml; + outputXml.init (&output); + + // Write + t.write (outputXml.getDocument (), theApp.Georges4CVS); + } + catch (Exception &e) + { + nlwarning ("Error during writting file '%s' : ", filename.c_str (), e.what ()); + } + } + else + { + nlwarning ("Can't open the file %s for writing", filename.c_str ()); + } +} + +// --------------------------------------------------------------------------- +void CGeorgesImpl::createInstanceFile (const std::string &_sxFullnameWithoutExt, const std::string &_dfnname) +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + + CFormLoader formLoader; + CFormDfn *dfn = formLoader.loadFormDfn (_dfnname.c_str(), false); + if (!dfn) + { + char msg[512]; + smprintf (msg, 512, "Can't load DFN '%s'", _dfnname); + theApp.outputError (msg); + return; + } + + NLMISC::CSmartPtr Form = new CForm; + + std::string fullName; + fullName = _sxFullnameWithoutExt + "."; + + int i = 0; + if (_dfnname[i] == '.') ++i; + for (; i < (int)_dfnname.size(); ++i) + { + if (_dfnname[i] == '.') break; + fullName += _dfnname[i]; + } + + ((CFormElmStruct*)&Form->getRootNode ())->build (dfn); + COFile f; + COXml ox; + if (f.open (fullName)) + { + ox.init(&f); + ((NLGEORGES::CForm*)((UForm*)Form))->write (ox.getDocument(), _sxFullnameWithoutExt.c_str (), theApp.Georges4CVS); + ox.flush(); + f.close(); + } + else + { + char msg[512]; + smprintf (msg, 512, "Can't write '%s'", fullName); + theApp.outputError (msg); + return; + } +} + +// --------------------------------------------------------------------------- +void CGeorgesImpl::LoadDocument( const std::string& _sxfullname ) +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + try + { + theApp.OpenDocumentFile(_sxfullname.c_str()); + } + catch (NLMISC::Exception &e) + { + std::string tmp = std::string(e.what()) + "(" + _sxfullname + ")"; + theApp.m_pMainWnd->MessageBox(tmp.c_str(), "Georges_Lib", MB_ICONERROR | MB_OK); + } +} + +// --------------------------------------------------------------------------- +/*void CGeorgesImpl::SaveDocument( const std::string& _sxfullname ) +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + CGeorgesEditApp* pApp = dynamic_cast< CGeorgesEditApp* >( AfxGetApp() ); + CGeorgesDoc* pgdoc = dynamic_cast< CGeorgesDoc* >( ( (CMainFrame*)theApp.m_pMainWnd )->GetActiveDocument() ); + pgdoc->OnSaveDocument( _sxfullname.c_str() ); +} + +// --------------------------------------------------------------------------- +void CGeorgesImpl::SaveAllDocument() +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + CGeorgesEditApp* papp = dynamic_cast< CGeorgesEditApp* >( AfxGetApp() ); + theApp.SaveAllDocument(); +}*/ + +// --------------------------------------------------------------------------- +void CGeorgesImpl::NewDocument( const std::string& _sxdfnname) +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + /*CGeorgesDoc* pgdoc = dynamic_cast< CGeorgesDoc* >( ( (CMainFrame*)theApp.m_pMainWnd )->GetActiveDocument() ); + pgdoc->NewDocument( _sxdfnname );*/ +} + +// --------------------------------------------------------------------------- +/*void CGeorgesImpl::NewDocument() +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + CGeorgesEditApp* pApp = dynamic_cast< CGeorgesEditApp* >( AfxGetApp() ); + CGeorgesDoc* pgdoc = dynamic_cast< CGeorgesDoc* >( ( (CMainFrame*)theApp.m_pMainWnd )->GetActiveDocument() ); + pgdoc->OnNewDocument(); +}*/ + +// --------------------------------------------------------------------------- +/*void CGeorgesImpl::CloseDocument() +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + CGeorgesEditApp* pApp = dynamic_cast< CGeorgesEditApp* >( AfxGetApp() ); + CGeorgesDoc* pgdoc = dynamic_cast< CGeorgesDoc* >( ( (CMainFrame*)theApp.m_pMainWnd )->GetActiveDocument() ); + pgdoc->OnCloseDocument(); +} + +// --------------------------------------------------------------------------- +void CGeorgesImpl::CloseAllDocument() +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + CGeorgesEditApp* pApp = dynamic_cast< CGeorgesEditApp* >( AfxGetApp() ); + theApp.CloseAllDocument(); +}*/ + +// --------------------------------------------------------------------------- +std::string CGeorgesImpl::GetDirDfnTyp () +{ + return theApp.RootSearchPath; +} + +// ******* +// STATICS +// ******* + +// --------------------------------------------------------------------------- +void IGeorges::releaseInterface (IGeorges* pGeorges) +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + + delete pGeorges; + +} + +// --------------------------------------------------------------------------- +IGeorges* IGeorges::getInterface (int version) +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + + // Check version number + if (version != GEORGES_VERSION) + { + MessageBox (NULL, "Bad version of georges.dll.", "Georges", MB_ICONEXCLAMATION|MB_OK); + return NULL; + } + else + return new CGeorgesImpl; + +} + +// --------------------------------------------------------------------------- +IGeorges* IGeorgesGetInterface (int version) +{ + return IGeorges::getInterface (version); + +} + +// --------------------------------------------------------------------------- +void IGeorgesReleaseInterface (IGeorges* pGeorges) +{ + IGeorges::releaseInterface (pGeorges); + +} diff --git a/code/ryzom/tools/leveldesign/georges_dll/georges_interface.h b/code/ryzom/tools/leveldesign/georges_dll/georges_interface.h index fbac91024..df651adb7 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/georges_interface.h +++ b/code/ryzom/tools/leveldesign/georges_dll/georges_interface.h @@ -1,141 +1,141 @@ -// 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 GEORGES_INTERFACE -#define GEORGES_INTERFACE - -#ifndef GEORGES_EXPORT -#define GEORGES_EXPORT __declspec( dllimport ) -#endif // GEORGES_EXPORT - -// Increment this version number each time you distribute a new version of the dll. -#define GEORGES_VERSION 3 - -#include -#include - -// Should be the same than in NLGEORGES::CType -enum TType -{ - UnsignedInt=0, - SignedInt, - Double, - String, - Color, - TypeCount -}; - -// Should be the same than in NLGEORGES::CType -enum TUI -{ - Edit, // Default, for all types - EditSpin, // For number types - NonEditableCombo, // For all types - FileBrowser, // Browse file - BigEdit, // Edit a huge text - ColorEdit, // Edit a color - IconWidget, // Draw an icon - UITypeCount -}; - -/** - * IGeorges - * - * \author Matthieu "TrapII" Besson - * \author Nevrax France - * \date 2001 - */ -class IGeorges -{ -public: - virtual ~IGeorges() {} - - // Init the UI - virtual void initUI (int m_nCmdShow, bool exeStandalone, HWND parent=NULL)=0; - - // Init the UI Light version - virtual void initUILight (int m_nCmdShow, int x, int y, int cx, int cy)=0; - - // Go - virtual void go ()=0; - - // Release the UI - virtual void releaseUI ()=0; - - // Get the main frame - virtual void *getMainFrame ()=0; - - //virtual void SetDocumentWorkDirectory( const std::string& _sxworkdirectory ) = 0; - //virtual void SetDocumentRootDirectory( const std::string& _sxrootdirectory ) = 0; - -// virtual void NewDocument() = 0; - -// virtual void NewDocument (const std::string& _sxdfnname) = 0; - - virtual void LoadDocument (const std::string& _sxfullname) = 0; - -// virtual void SaveDocument (const std::string& _sxfullname) = 0; - -// virtual void CloseDocument() = 0; - - // Directories Management - virtual void SetDirDfnTyp (const std::string &_sxDirectory) = 0; - virtual void SetDirPrototype (const std::string &_sxDirectory) = 0; - virtual void SetDirLevel (const std::string &_sxDirectory) = 0; - - virtual std::string GetDirDfnTyp () = 0; -/* virtual std::string GetDirPrototype () = 0; - virtual std::string GetDirLevel () = 0;*/ - - // Put a text in the right cell - virtual void PutGroupText (const std::vector& _vText, bool append) = 0; - virtual void PutText (const std::string& _sText) = 0; - virtual void LineUp () = 0; - virtual void LineDown () = 0; - - virtual BOOL PreTranslateMessage (MSG *pMsg) = 0; - -/* virtual void SaveAllDocument() = 0; - virtual void CloseAllDocument() = 0; - - virtual void SetTypPredef( const std::string& _sxfilename, const std::vector< std::string >& _pvsx ) = 0; - - virtual void MakeDfn( const std::string& _sxfullname, const std::vector< std::pair< std::string, std::string > >* const _pvdefine = 0 ) = 0; -*/ - virtual void MakeTyp( const std::string& filename, TType type, TUI ui, const std::string& _min, const std::string& _max, const std::string& _default, const std::vector< std::pair< std::string, std::string > >* const _pvpredef ) = 0; - - virtual void createInstanceFile (const std::string &_sxFullnameWithoutExt, const std::string &_dfnname) = 0; - - // ----------------------------------------------------------------------- - - // Get interface (autoconstruct like a factory) - static GEORGES_EXPORT IGeorges *getInterface (int version = GEORGES_VERSION); - - // Release interface - static GEORGES_EXPORT void releaseInterface (IGeorges *pGeorges); -}; - - -// To export the names in a good format that can be human readable and not with the heavy style -// of the C++ we have to do it in 'old-school' mode (so in C). But this is just a bind to -// the static factory constructor/destructor -extern "C" -{ - GEORGES_EXPORT IGeorges *IGeorgesGetInterface (int version = GEORGES_VERSION); - GEORGES_EXPORT void IGeorgesReleaseInterface (IGeorges *pG); -} - -#endif LOGIC_EDITOR_INTERFACE +// 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 GEORGES_INTERFACE +#define GEORGES_INTERFACE + +#ifndef GEORGES_EXPORT +#define GEORGES_EXPORT __declspec( dllimport ) +#endif // GEORGES_EXPORT + +// Increment this version number each time you distribute a new version of the dll. +#define GEORGES_VERSION 3 + +#include +#include + +// Should be the same than in NLGEORGES::CType +enum TType +{ + UnsignedInt=0, + SignedInt, + Double, + String, + Color, + TypeCount +}; + +// Should be the same than in NLGEORGES::CType +enum TUI +{ + Edit, // Default, for all types + EditSpin, // For number types + NonEditableCombo, // For all types + FileBrowser, // Browse file + BigEdit, // Edit a huge text + ColorEdit, // Edit a color + IconWidget, // Draw an icon + UITypeCount +}; + +/** + * IGeorges + * + * \author Matthieu "TrapII" Besson + * \author Nevrax France + * \date 2001 + */ +class IGeorges +{ +public: + virtual ~IGeorges() {} + + // Init the UI + virtual void initUI (int m_nCmdShow, bool exeStandalone, HWND parent=NULL)=0; + + // Init the UI Light version + virtual void initUILight (int m_nCmdShow, int x, int y, int cx, int cy)=0; + + // Go + virtual void go ()=0; + + // Release the UI + virtual void releaseUI ()=0; + + // Get the main frame + virtual void *getMainFrame ()=0; + + //virtual void SetDocumentWorkDirectory( const std::string& _sxworkdirectory ) = 0; + //virtual void SetDocumentRootDirectory( const std::string& _sxrootdirectory ) = 0; + +// virtual void NewDocument() = 0; + +// virtual void NewDocument (const std::string& _sxdfnname) = 0; + + virtual void LoadDocument (const std::string& _sxfullname) = 0; + +// virtual void SaveDocument (const std::string& _sxfullname) = 0; + +// virtual void CloseDocument() = 0; + + // Directories Management + virtual void SetDirDfnTyp (const std::string &_sxDirectory) = 0; + virtual void SetDirPrototype (const std::string &_sxDirectory) = 0; + virtual void SetDirLevel (const std::string &_sxDirectory) = 0; + + virtual std::string GetDirDfnTyp () = 0; +/* virtual std::string GetDirPrototype () = 0; + virtual std::string GetDirLevel () = 0;*/ + + // Put a text in the right cell + virtual void PutGroupText (const std::vector& _vText, bool append) = 0; + virtual void PutText (const std::string& _sText) = 0; + virtual void LineUp () = 0; + virtual void LineDown () = 0; + + virtual BOOL PreTranslateMessage (MSG *pMsg) = 0; + +/* virtual void SaveAllDocument() = 0; + virtual void CloseAllDocument() = 0; + + virtual void SetTypPredef( const std::string& _sxfilename, const std::vector< std::string >& _pvsx ) = 0; + + virtual void MakeDfn( const std::string& _sxfullname, const std::vector< std::pair< std::string, std::string > >* const _pvdefine = 0 ) = 0; +*/ + virtual void MakeTyp( const std::string& filename, TType type, TUI ui, const std::string& _min, const std::string& _max, const std::string& _default, const std::vector< std::pair< std::string, std::string > >* const _pvpredef ) = 0; + + virtual void createInstanceFile (const std::string &_sxFullnameWithoutExt, const std::string &_dfnname) = 0; + + // ----------------------------------------------------------------------- + + // Get interface (autoconstruct like a factory) + static GEORGES_EXPORT IGeorges *getInterface (int version = GEORGES_VERSION); + + // Release interface + static GEORGES_EXPORT void releaseInterface (IGeorges *pGeorges); +}; + + +// To export the names in a good format that can be human readable and not with the heavy style +// of the C++ we have to do it in 'old-school' mode (so in C). But this is just a bind to +// the static factory constructor/destructor +extern "C" +{ + GEORGES_EXPORT IGeorges *IGeorgesGetInterface (int version = GEORGES_VERSION); + GEORGES_EXPORT void IGeorgesReleaseInterface (IGeorges *pG); +} + +#endif LOGIC_EDITOR_INTERFACE diff --git a/code/ryzom/tools/leveldesign/georges_dll/header_dialog.cpp b/code/ryzom/tools/leveldesign/georges_dll/header_dialog.cpp index 40de30011..a69d481f4 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/header_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/header_dialog.cpp @@ -1,401 +1,401 @@ -// 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 . - -// header_dialog.cpp : implementation file -// - -#include "stdafx.h" -#include "georges_edit.h" -#include "georges_edit_view.h" -#include "georges_edit_doc.h" -#include "header_dialog.h" -#include "action.h" -#include "left_view.h" - -#include "nel/georges/type.h" - -using namespace NLGEORGES; -using namespace NLMISC; - - -///////////////////////////////////////////////////////////////////////////// -// CHeaderDialog dialog - - -CHeaderDialog::CHeaderDialog () : CBaseDialog (IDR_MAINFRAME) -{ - //{{AFX_DATA_INIT(CHeaderDialog) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT - View = NULL; -} - - -void CHeaderDialog::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CHeaderDialog) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CHeaderDialog, CDialog) - //{{AFX_MSG_MAP(CHeaderDialog) - ON_WM_SIZE() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CHeaderDialog message handlers - -void CHeaderDialog::OnSize(UINT nType, int cx, int cy) -{ - CBaseDialog::OnSize(nType, cx, cy); - - // TODO: Add your message handler code here - -} - -BOOL CHeaderDialog::OnInitDialog() -{ - CBaseDialog::OnInitDialog(); - - // Refresh sizes - RECT viewRect; - View->GetClientRect (&viewRect); - uint virtualWidth = std::max ((uint)MinViewWidth, (uint)(viewRect.right-viewRect.left)); - CBaseDialog::resizeWidgets (virtualWidth, 0); - - // Get first item coordinate - RECT currentPos; - getFirstItemPos (currentPos); - - // Create the version - setStaticSize (currentPos); - char versionText[512]; - smprintf (versionText, 512, "Version %d.%d", 0, 0); - LabelVersion.Create (versionText, WS_VISIBLE, currentPos, this); - initWidget (LabelVersion); - getNextPosLabel (currentPos); - - setButtonSize (currentPos, SmallWidget); - IncrementVersion.Create ("Increment Version", WS_VISIBLE|WS_TABSTOP, currentPos, this, BtIncrement); - initWidget (IncrementVersion); - getNextPos (currentPos); - IncrementVersion.EnableWindow ( theApp.Georges4CVS ? FALSE : TRUE ); - - // Create the state combo - setStaticSize (currentPos); - LabelState.Create ("State:", WS_VISIBLE, currentPos, this); - initWidget (LabelState); - getNextPosLabel (currentPos); - - setComboSize (currentPos, SmallWidget); - RECT pos = currentPos; - adjusteComboSize (pos); - ComboState.Create (WS_VISIBLE|CBS_DROPDOWNLIST|WS_TABSTOP, pos, this, CbState); - uint item; - for (item=0; itemGetClientRect (&viewRect); - uint virtualWidth = std::max ((uint)MinViewWidth, (uint)(viewRect.right-viewRect.left)); - - // Refresh sizes - CBaseDialog::resizeWidgets (virtualWidth, 0); - - // Get first item coordinate - RECT currentPos; - getFirstItemPos (currentPos); - setStaticSize (currentPos); - getNextPosLabel (currentPos); - setButtonSize (currentPos, SmallWidget); - getNextPos (currentPos); - setStaticSize (currentPos); - getNextPosLabel (currentPos); - setComboSize (currentPos, SmallWidget); - getNextPos (currentPos); - setStaticSize (currentPos); - getNextPosLabel (currentPos); - setBigEditSize (currentPos, Width, BigEditHeight); - getNextPos (currentPos); - setStaticSize (currentPos); - getNextPosLabel (currentPos); - setBigEditSize (currentPos, Width, BigEditHeight); - getNextPos (currentPos); - - // Refresh sizes - CBaseDialog::resizeWidgets (virtualWidth, currentPos.bottom); - - // Get first item coordinate - currentPos; - getFirstItemPos (currentPos); - - uint adjust = AdjusteHeight / 2; - - // Resize - setStaticSize (currentPos); - LabelVersion.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - getNextPosLabel (currentPos); - - // Resize - setButtonSize (currentPos, SmallWidget); - IncrementVersion.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - getNextPos (currentPos); - - // Resize - setStaticSize (currentPos); - LabelState.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - getNextPosLabel (currentPos); - - // Resize - setComboSize (currentPos, SmallWidget); - RECT pos = currentPos; - adjusteComboSize (pos); - ComboState.SetWindowPos (NULL, pos.left, pos.top, pos.right - pos.left, - pos.bottom - pos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - getNextPos (currentPos); - - // Resize - setStaticSize (currentPos); - LabelComments.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - getNextPosLabel (currentPos); - - // Resize - setBigEditSize (currentPos, Width, BigEditHeight + adjust); - Comments.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - getNextPos (currentPos); - - // Resize - setStaticSize (currentPos); - LabelLog.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - getNextPosLabel (currentPos); - - // Resize - setBigEditSize (currentPos, Width, BigEditHeight + AdjusteHeight - adjust); - Log.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - getNextPos (currentPos); - - // Resize the current view - View->setViewSize ( - virtualWidth, - currentPos.bottom+CGeorgesEditView::WidgetTopMargin+CGeorgesEditView::WidgetBottomMargin); -} - -void CHeaderDialog::getFromDocument (const NLGEORGES::CFileHeader &header) -{ - if (View) - { - if (theApp.Georges4CVS) - { - // CVS revision number - IncrementVersion.EnableWindow ( theApp.Georges4CVS ? FALSE : TRUE ); - - // Performs some checks - bool ok = false; - const char *revision = header.Revision.c_str (); - char name[32]; - char name2[512]; - if (strncmp (revision, "$Revision: ", 11) == 0) - { - // String start - const char *start = revision + 11; - - // String end - const char *end = strchr (start, '$'); - if (end) - { - // Build a string - int length = std::min (31, end-start); - memcpy (name, start, length); - name[length] = 0; - - // Nice version - smprintf (name2, 512, "CVS Revision %s", name); - - // Set the label - LabelVersion.SetWindowText (name2); - - // Success - ok = true; - } - } - - // Revision not found ? - if (!ok) - { - LabelVersion.SetWindowText ("CVS Revision number not found"); - } - } - else - { - // Nel standard version number - ComboState.SetCurSel (header.State); - char name[512]; - smprintf (name, 512, "Version %d.%d", header.MajorVersion, header.MinorVersion); - LabelVersion.SetWindowText (name); - } - - // Set comments - setEditTextMultiLine (Comments, header.Comments.c_str()); - - // Set logs - setEditTextMultiLine (Log, header.Log.c_str()); - } -} - -void CHeaderDialog::setStateToDocument () -{ - CGeorgesEditDoc *doc = View->GetDocument (); - if (doc) - { - CGeorgesEditDocSub *current = doc->getSelectedObject (); - CFileHeader *header = doc->getHeaderPtr (); - doc->modify (new CActionString (IAction::HeaderState, toString ((int)(CFileHeader::TState)ComboState.GetCurSel ()).c_str (), - *doc, "", "", doc->getLeftView ()->getCurrentSelectionId (), 0), true, false); - } -} - -void CHeaderDialog::setVersionToDocument () -{ - CGeorgesEditDoc *doc = View->GetDocument (); - if (doc) - { - uint v0, v1; - CString str; - LabelVersion.GetWindowText (str); - if (sscanf ((const char*)str, "Version %d.%d", &v0, &v1)==2) - { - v0++; - v1=0; - char name[512]; - smprintf (name, 512, "Version %d.%d", v0, v1); - LabelVersion.SetWindowText (name); - - // Modify docuemnt - doc->modify (new CActionString (IAction::HeaderVersion, name, *doc, "", "", - doc->getLeftView ()->getCurrentSelectionId (), 0)); - } - } -} - -void CHeaderDialog::setCommentsToDocument () -{ - CGeorgesEditDoc *doc = View->GetDocument (); - if (doc) - { - CGeorgesEditDocSub *current = doc->getSelectedObject (); - CString str; - Comments.GetWindowText (str); - doc->modify (new CActionString (IAction::HeaderComments, str, *doc, "", "", - doc->getLeftView ()->getCurrentSelectionId (), 0)); - } -} - -BOOL CHeaderDialog::OnCommand(WPARAM wParam, LPARAM lParam) -{ - switch (HIWORD(wParam)) - { - case EN_CHANGE: - { - // identifier - switch (LOWORD(wParam)) - { - case EdComments: - setCommentsToDocument (); - break; - } - } - break; - case CBN_SELCHANGE: - { - // identifier - switch (LOWORD(wParam)) - { - case CbState: - setStateToDocument (); - break; - } - } - break; - case BN_CLICKED: - { - // identifier - switch (LOWORD(wParam)) - { - case BtIncrement: - setVersionToDocument (); - break; - } - } - } - - return CWnd::OnCommand(wParam, lParam); -} - -void CHeaderDialog::onFirstFocus () -{ - View->SetFocus (); -} - -void CHeaderDialog::onLastFocus () -{ - View->setFocusLeftView (); -} +// 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 . + +// header_dialog.cpp : implementation file +// + +#include "stdafx.h" +#include "georges_edit.h" +#include "georges_edit_view.h" +#include "georges_edit_doc.h" +#include "header_dialog.h" +#include "action.h" +#include "left_view.h" + +#include "nel/georges/type.h" + +using namespace NLGEORGES; +using namespace NLMISC; + + +///////////////////////////////////////////////////////////////////////////// +// CHeaderDialog dialog + + +CHeaderDialog::CHeaderDialog () : CBaseDialog (IDR_MAINFRAME) +{ + //{{AFX_DATA_INIT(CHeaderDialog) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + View = NULL; +} + + +void CHeaderDialog::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CHeaderDialog) + // NOTE: the ClassWizard will add DDX and DDV calls here + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CHeaderDialog, CDialog) + //{{AFX_MSG_MAP(CHeaderDialog) + ON_WM_SIZE() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CHeaderDialog message handlers + +void CHeaderDialog::OnSize(UINT nType, int cx, int cy) +{ + CBaseDialog::OnSize(nType, cx, cy); + + // TODO: Add your message handler code here + +} + +BOOL CHeaderDialog::OnInitDialog() +{ + CBaseDialog::OnInitDialog(); + + // Refresh sizes + RECT viewRect; + View->GetClientRect (&viewRect); + uint virtualWidth = std::max ((uint)MinViewWidth, (uint)(viewRect.right-viewRect.left)); + CBaseDialog::resizeWidgets (virtualWidth, 0); + + // Get first item coordinate + RECT currentPos; + getFirstItemPos (currentPos); + + // Create the version + setStaticSize (currentPos); + char versionText[512]; + smprintf (versionText, 512, "Version %d.%d", 0, 0); + LabelVersion.Create (versionText, WS_VISIBLE, currentPos, this); + initWidget (LabelVersion); + getNextPosLabel (currentPos); + + setButtonSize (currentPos, SmallWidget); + IncrementVersion.Create ("Increment Version", WS_VISIBLE|WS_TABSTOP, currentPos, this, BtIncrement); + initWidget (IncrementVersion); + getNextPos (currentPos); + IncrementVersion.EnableWindow ( theApp.Georges4CVS ? FALSE : TRUE ); + + // Create the state combo + setStaticSize (currentPos); + LabelState.Create ("State:", WS_VISIBLE, currentPos, this); + initWidget (LabelState); + getNextPosLabel (currentPos); + + setComboSize (currentPos, SmallWidget); + RECT pos = currentPos; + adjusteComboSize (pos); + ComboState.Create (WS_VISIBLE|CBS_DROPDOWNLIST|WS_TABSTOP, pos, this, CbState); + uint item; + for (item=0; itemGetClientRect (&viewRect); + uint virtualWidth = std::max ((uint)MinViewWidth, (uint)(viewRect.right-viewRect.left)); + + // Refresh sizes + CBaseDialog::resizeWidgets (virtualWidth, 0); + + // Get first item coordinate + RECT currentPos; + getFirstItemPos (currentPos); + setStaticSize (currentPos); + getNextPosLabel (currentPos); + setButtonSize (currentPos, SmallWidget); + getNextPos (currentPos); + setStaticSize (currentPos); + getNextPosLabel (currentPos); + setComboSize (currentPos, SmallWidget); + getNextPos (currentPos); + setStaticSize (currentPos); + getNextPosLabel (currentPos); + setBigEditSize (currentPos, Width, BigEditHeight); + getNextPos (currentPos); + setStaticSize (currentPos); + getNextPosLabel (currentPos); + setBigEditSize (currentPos, Width, BigEditHeight); + getNextPos (currentPos); + + // Refresh sizes + CBaseDialog::resizeWidgets (virtualWidth, currentPos.bottom); + + // Get first item coordinate + currentPos; + getFirstItemPos (currentPos); + + uint adjust = AdjusteHeight / 2; + + // Resize + setStaticSize (currentPos); + LabelVersion.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + getNextPosLabel (currentPos); + + // Resize + setButtonSize (currentPos, SmallWidget); + IncrementVersion.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + getNextPos (currentPos); + + // Resize + setStaticSize (currentPos); + LabelState.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + getNextPosLabel (currentPos); + + // Resize + setComboSize (currentPos, SmallWidget); + RECT pos = currentPos; + adjusteComboSize (pos); + ComboState.SetWindowPos (NULL, pos.left, pos.top, pos.right - pos.left, + pos.bottom - pos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + getNextPos (currentPos); + + // Resize + setStaticSize (currentPos); + LabelComments.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + getNextPosLabel (currentPos); + + // Resize + setBigEditSize (currentPos, Width, BigEditHeight + adjust); + Comments.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + getNextPos (currentPos); + + // Resize + setStaticSize (currentPos); + LabelLog.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + getNextPosLabel (currentPos); + + // Resize + setBigEditSize (currentPos, Width, BigEditHeight + AdjusteHeight - adjust); + Log.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + getNextPos (currentPos); + + // Resize the current view + View->setViewSize ( + virtualWidth, + currentPos.bottom+CGeorgesEditView::WidgetTopMargin+CGeorgesEditView::WidgetBottomMargin); +} + +void CHeaderDialog::getFromDocument (const NLGEORGES::CFileHeader &header) +{ + if (View) + { + if (theApp.Georges4CVS) + { + // CVS revision number + IncrementVersion.EnableWindow ( theApp.Georges4CVS ? FALSE : TRUE ); + + // Performs some checks + bool ok = false; + const char *revision = header.Revision.c_str (); + char name[32]; + char name2[512]; + if (strncmp (revision, "$Revision: ", 11) == 0) + { + // String start + const char *start = revision + 11; + + // String end + const char *end = strchr (start, '$'); + if (end) + { + // Build a string + int length = std::min (31, end-start); + memcpy (name, start, length); + name[length] = 0; + + // Nice version + smprintf (name2, 512, "CVS Revision %s", name); + + // Set the label + LabelVersion.SetWindowText (name2); + + // Success + ok = true; + } + } + + // Revision not found ? + if (!ok) + { + LabelVersion.SetWindowText ("CVS Revision number not found"); + } + } + else + { + // Nel standard version number + ComboState.SetCurSel (header.State); + char name[512]; + smprintf (name, 512, "Version %d.%d", header.MajorVersion, header.MinorVersion); + LabelVersion.SetWindowText (name); + } + + // Set comments + setEditTextMultiLine (Comments, header.Comments.c_str()); + + // Set logs + setEditTextMultiLine (Log, header.Log.c_str()); + } +} + +void CHeaderDialog::setStateToDocument () +{ + CGeorgesEditDoc *doc = View->GetDocument (); + if (doc) + { + CGeorgesEditDocSub *current = doc->getSelectedObject (); + CFileHeader *header = doc->getHeaderPtr (); + doc->modify (new CActionString (IAction::HeaderState, toString ((int)(CFileHeader::TState)ComboState.GetCurSel ()).c_str (), + *doc, "", "", doc->getLeftView ()->getCurrentSelectionId (), 0), true, false); + } +} + +void CHeaderDialog::setVersionToDocument () +{ + CGeorgesEditDoc *doc = View->GetDocument (); + if (doc) + { + uint v0, v1; + CString str; + LabelVersion.GetWindowText (str); + if (sscanf ((const char*)str, "Version %d.%d", &v0, &v1)==2) + { + v0++; + v1=0; + char name[512]; + smprintf (name, 512, "Version %d.%d", v0, v1); + LabelVersion.SetWindowText (name); + + // Modify docuemnt + doc->modify (new CActionString (IAction::HeaderVersion, name, *doc, "", "", + doc->getLeftView ()->getCurrentSelectionId (), 0)); + } + } +} + +void CHeaderDialog::setCommentsToDocument () +{ + CGeorgesEditDoc *doc = View->GetDocument (); + if (doc) + { + CGeorgesEditDocSub *current = doc->getSelectedObject (); + CString str; + Comments.GetWindowText (str); + doc->modify (new CActionString (IAction::HeaderComments, str, *doc, "", "", + doc->getLeftView ()->getCurrentSelectionId (), 0)); + } +} + +BOOL CHeaderDialog::OnCommand(WPARAM wParam, LPARAM lParam) +{ + switch (HIWORD(wParam)) + { + case EN_CHANGE: + { + // identifier + switch (LOWORD(wParam)) + { + case EdComments: + setCommentsToDocument (); + break; + } + } + break; + case CBN_SELCHANGE: + { + // identifier + switch (LOWORD(wParam)) + { + case CbState: + setStateToDocument (); + break; + } + } + break; + case BN_CLICKED: + { + // identifier + switch (LOWORD(wParam)) + { + case BtIncrement: + setVersionToDocument (); + break; + } + } + } + + return CWnd::OnCommand(wParam, lParam); +} + +void CHeaderDialog::onFirstFocus () +{ + View->SetFocus (); +} + +void CHeaderDialog::onLastFocus () +{ + View->setFocusLeftView (); +} diff --git a/code/ryzom/tools/leveldesign/georges_dll/header_dialog.h b/code/ryzom/tools/leveldesign/georges_dll/header_dialog.h index 1169594cb..dff405553 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/header_dialog.h +++ b/code/ryzom/tools/leveldesign/georges_dll/header_dialog.h @@ -1,105 +1,105 @@ -// 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 . - -#if !defined(HEADER_TYPE_H) -#define HEADER_TYPE_H - -#include "base_dialog.h" -#include "edit_list_ctrl.h" - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// type_dialog.h : header file -// - -namespace NLGEORGES -{ -class CFileHeader; -}; - -class CGeorgesEditView; - -///////////////////////////////////////////////////////////////////////////// -// CHeaderDialog dialog - -class CHeaderDialog : public CBaseDialog -{ -// Construction -public: - CHeaderDialog (); // standard constructor - - enum - { - TypeCombo= 100, - }; - - enum - { - CbState = 1, - BtIncrement, - EdComments, - EdLog, - }; - - // The widgets - CStatic LabelVersion; - CButton IncrementVersion; - CStatic LabelState; - CComboBox ComboState; - CStatic LabelComments; - CEdit Comments; - CStatic LabelLog; - CEdit Log; - - // From CBaseDialog - void onLastFocus (); - void onFirstFocus (); - - // Get from document, update rightview UI - void getFromDocument (const NLGEORGES::CFileHeader &header); - - // Set to document, update document with rightview UI - void setStateToDocument (); - void setVersionToDocument (); - void setCommentsToDocument (); - - // Resize widget callback - void resizeWidgets (); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CHeaderDialog) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam); - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CHeaderDialog) - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(HEADER_TYPE_H) +// 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 . + +#if !defined(HEADER_TYPE_H) +#define HEADER_TYPE_H + +#include "base_dialog.h" +#include "edit_list_ctrl.h" + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// type_dialog.h : header file +// + +namespace NLGEORGES +{ +class CFileHeader; +}; + +class CGeorgesEditView; + +///////////////////////////////////////////////////////////////////////////// +// CHeaderDialog dialog + +class CHeaderDialog : public CBaseDialog +{ +// Construction +public: + CHeaderDialog (); // standard constructor + + enum + { + TypeCombo= 100, + }; + + enum + { + CbState = 1, + BtIncrement, + EdComments, + EdLog, + }; + + // The widgets + CStatic LabelVersion; + CButton IncrementVersion; + CStatic LabelState; + CComboBox ComboState; + CStatic LabelComments; + CEdit Comments; + CStatic LabelLog; + CEdit Log; + + // From CBaseDialog + void onLastFocus (); + void onFirstFocus (); + + // Get from document, update rightview UI + void getFromDocument (const NLGEORGES::CFileHeader &header); + + // Set to document, update document with rightview UI + void setStateToDocument (); + void setVersionToDocument (); + void setCommentsToDocument (); + + // Resize widget callback + void resizeWidgets (); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CHeaderDialog) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam); + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CHeaderDialog) + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(HEADER_TYPE_H) diff --git a/code/ryzom/tools/leveldesign/georges_dll/icon_wnd.cpp b/code/ryzom/tools/leveldesign/georges_dll/icon_wnd.cpp index 040204449..de9dcaad7 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/icon_wnd.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/icon_wnd.cpp @@ -1,299 +1,299 @@ -// 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 . - -// icon_wnd.cpp: implementation of the CIconWnd class. -// - -#include "stdafx.h" -#include "georges_edit.h" -#include "icon_wnd.h" - -#include "nel/misc/path.h" -#include "nel/misc/file.h" -#include "nel/misc/bitmap.h" - -using namespace NLMISC; -using namespace std; - -string CIconWnd::IconPath = ""; - - -CIconWnd::CIconWnd() -{ - pWndIcon = NULL; - pWndIconColor = NULL; - pWndIconBack = NULL; - pWndIconBackColor = NULL; - pWndIconOver = NULL; - pWndIconOverColor = NULL; - pWndIconOver2 = NULL; - pWndIconOver2Color = NULL; -} - -CIconWnd::~CIconWnd() -{ - -} - -BEGIN_MESSAGE_MAP(CIconWnd, CWnd) - //{{AFX_MSG_MAP(CIconWnd) - ON_WM_PAINT() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - - -void CIconWnd::OnPaint() -{ - CPaintDC dc(this); - - // update data - if (updateStr()) - updateIcon(); - - // Get client dc - RECT client; - GetClientRect(&client); - dc.Rectangle(&client); - - for (uint y=0 ; yasString(); - for (uint i=0 ; isize() ; i++) - CPath::addSearchPath(var->asString(i), true, false, NULL); - } - else - { - nlinfo("!! IconPath missing in .cfg, Please complete the config file !!"); - IconPath = "\\\\amiga\\3d\\Database\\Interfaces\\"; - nlinfo("default to : IconPath = \"\\\\amiga\\3d\\Database\\Interfaces\\\""); - CPath::addSearchPath(IconPath, true, false, NULL); - } - } - - NLMISC::CBitmap icon; - NLMISC::CRGBA color; - - bitmap.reset(); - bitmap.convertToType(NLMISC::CBitmap::RGBA); - bitmap.resample(40, 40); - - // back icon - if (loadIcon(strIconBack, icon)) - { - // back icon color - if (getColorFromStr(strIconBackColor, color)) - modulateIcon(icon, color); - - bitmap = icon; - - // base icon - addIconLayer(bitmap, strIcon, strIconColor); - } - else - { - // base icon - loadIcon(strIcon, icon); - - // base icon color - if (getColorFromStr(strIconColor, color)) - modulateIcon(icon, color); - - bitmap = icon; - } - - // overlay icon - addIconLayer(bitmap, strIconOver, strIconOverColor); - - // overlay 2 icon - addIconLayer(bitmap, strIconOver2, strIconOver2Color); -} - -bool CIconWnd::loadIcon(const std::string &filename, NLMISC::CBitmap &bmp) -{ - // Try to get the file path - string filepath = CPath::lookup(filename, false, false); - if (filepath == "") - { - bmp.makeDummy(); - bmp.convertToType(NLMISC::CBitmap::RGBA); - bmp.resample(40, 40); - return false; - } - - // load icon - CIFile f; - f.open(filepath); - - bmp.load(f); - bmp.convertToType(NLMISC::CBitmap::RGBA); - bmp.resample(40, 40); - - f.close(); - - return true; -} - -bool CIconWnd::getColorFromStr(const std::string &s, NLMISC::CRGBA &c) -{ - // Convert string to color - - sint r, g, b; - if (sscanf (s.c_str(), "%d,%d,%d", &r, &g, &b) == 3) - { - clamp (r, 0, 255); - clamp (g, 0, 255); - clamp (b, 0, 255); - c = CRGBA(r, g, b); - return true; - } - - return false; -} - -void CIconWnd::blendIcons(NLMISC::CBitmap &dst, const NLMISC::CBitmap &src) -{ - // blend between two icons - - nlassert(dst.getWidth() == src.getWidth()); - nlassert(dst.getHeight() == src.getHeight()); - - CObjectVector &data = dst.getPixels(); - - for (uint y=0 ; y &data = dst.getPixels(); - - for (uint y=0 ; yGetWindowText(buffer, 512); - if (buffer != str) - { - str = buffer; - return true; - } - } - - return false; +// 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 . + +// icon_wnd.cpp: implementation of the CIconWnd class. +// + +#include "stdafx.h" +#include "georges_edit.h" +#include "icon_wnd.h" + +#include "nel/misc/path.h" +#include "nel/misc/file.h" +#include "nel/misc/bitmap.h" + +using namespace NLMISC; +using namespace std; + +string CIconWnd::IconPath = ""; + + +CIconWnd::CIconWnd() +{ + pWndIcon = NULL; + pWndIconColor = NULL; + pWndIconBack = NULL; + pWndIconBackColor = NULL; + pWndIconOver = NULL; + pWndIconOverColor = NULL; + pWndIconOver2 = NULL; + pWndIconOver2Color = NULL; +} + +CIconWnd::~CIconWnd() +{ + +} + +BEGIN_MESSAGE_MAP(CIconWnd, CWnd) + //{{AFX_MSG_MAP(CIconWnd) + ON_WM_PAINT() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + + +void CIconWnd::OnPaint() +{ + CPaintDC dc(this); + + // update data + if (updateStr()) + updateIcon(); + + // Get client dc + RECT client; + GetClientRect(&client); + dc.Rectangle(&client); + + for (uint y=0 ; yasString(); + for (uint i=0 ; isize() ; i++) + CPath::addSearchPath(var->asString(i), true, false, NULL); + } + else + { + nlinfo("!! IconPath missing in .cfg, Please complete the config file !!"); + IconPath = "\\\\amiga\\3d\\Database\\Interfaces\\"; + nlinfo("default to : IconPath = \"\\\\amiga\\3d\\Database\\Interfaces\\\""); + CPath::addSearchPath(IconPath, true, false, NULL); + } + } + + NLMISC::CBitmap icon; + NLMISC::CRGBA color; + + bitmap.reset(); + bitmap.convertToType(NLMISC::CBitmap::RGBA); + bitmap.resample(40, 40); + + // back icon + if (loadIcon(strIconBack, icon)) + { + // back icon color + if (getColorFromStr(strIconBackColor, color)) + modulateIcon(icon, color); + + bitmap = icon; + + // base icon + addIconLayer(bitmap, strIcon, strIconColor); + } + else + { + // base icon + loadIcon(strIcon, icon); + + // base icon color + if (getColorFromStr(strIconColor, color)) + modulateIcon(icon, color); + + bitmap = icon; + } + + // overlay icon + addIconLayer(bitmap, strIconOver, strIconOverColor); + + // overlay 2 icon + addIconLayer(bitmap, strIconOver2, strIconOver2Color); +} + +bool CIconWnd::loadIcon(const std::string &filename, NLMISC::CBitmap &bmp) +{ + // Try to get the file path + string filepath = CPath::lookup(filename, false, false); + if (filepath == "") + { + bmp.makeDummy(); + bmp.convertToType(NLMISC::CBitmap::RGBA); + bmp.resample(40, 40); + return false; + } + + // load icon + CIFile f; + f.open(filepath); + + bmp.load(f); + bmp.convertToType(NLMISC::CBitmap::RGBA); + bmp.resample(40, 40); + + f.close(); + + return true; +} + +bool CIconWnd::getColorFromStr(const std::string &s, NLMISC::CRGBA &c) +{ + // Convert string to color + + sint r, g, b; + if (sscanf (s.c_str(), "%d,%d,%d", &r, &g, &b) == 3) + { + clamp (r, 0, 255); + clamp (g, 0, 255); + clamp (b, 0, 255); + c = CRGBA(r, g, b); + return true; + } + + return false; +} + +void CIconWnd::blendIcons(NLMISC::CBitmap &dst, const NLMISC::CBitmap &src) +{ + // blend between two icons + + nlassert(dst.getWidth() == src.getWidth()); + nlassert(dst.getHeight() == src.getHeight()); + + CObjectVector &data = dst.getPixels(); + + for (uint y=0 ; y &data = dst.getPixels(); + + for (uint y=0 ; yGetWindowText(buffer, 512); + if (buffer != str) + { + str = buffer; + return true; + } + } + + return false; } \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_dll/icon_wnd.h b/code/ryzom/tools/leveldesign/georges_dll/icon_wnd.h index 3caefa886..681b9af6b 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/icon_wnd.h +++ b/code/ryzom/tools/leveldesign/georges_dll/icon_wnd.h @@ -1,93 +1,93 @@ -// 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 . - -// icon_wnd.h: interface for the CIconWnd class. -// -////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_ICON_WND_H__12893D3C_9A86_4A7A_A972_7965BDDBD2A2__INCLUDED_) -#define AFX_ICON_WND_H__12893D3C_9A86_4A7A_A972_7965BDDBD2A2__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include "nel/misc/bitmap.h" - -class CIconWnd : public CWnd -{ -// Operations -public: - CIconWnd(); - void create (DWORD wStyle, RECT &pos, CWnd *window, uint dialogIndex); - -private: - bool updateStr(); - void updateIcon(); - - void blendIcons(NLMISC::CBitmap &dst, const NLMISC::CBitmap &src); - void modulateIcon(NLMISC::CBitmap &dst, const NLMISC::CRGBA &col); - - bool loadIcon(const std::string &filename, NLMISC::CBitmap &bmp); - bool getColorFromStr(const std::string &s, NLMISC::CRGBA &c); - - void addIconLayer(NLMISC::CBitmap &dst, const std::string iconStr, const std::string iconCol); - bool updateWnd(CWnd *pWnd, std::string &str); - -// Attributes -public: - uint Id; - - // Pointer to control window - CWnd *pWndIcon; - CWnd *pWndIconColor; - CWnd *pWndIconBack; - CWnd *pWndIconBackColor; - CWnd *pWndIconOver; - CWnd *pWndIconOverColor; - CWnd *pWndIconOver2; - CWnd *pWndIconOver2Color; - -private: - // String containing window data - std::string strIcon; - std::string strIconColor; - std::string strIconBack; - std::string strIconBackColor; - std::string strIconOver; - std::string strIconOverColor; - std::string strIconOver2; - std::string strIconOver2Color; - - // Bitmap printed on window - NLMISC::CBitmap bitmap; - - // Directory of icons - static std::string IconPath; - -// Implementation -public: - virtual ~CIconWnd(); - - // Generated message map functions -protected: - //{{AFX_MSG(CIconWnd) - afx_msg void OnPaint(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -#endif // !defined(AFX_ICON_WND_H__12893D3C_9A86_4A7A_A972_7965BDDBD2A2__INCLUDED_) +// 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 . + +// icon_wnd.h: interface for the CIconWnd class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_ICON_WND_H__12893D3C_9A86_4A7A_A972_7965BDDBD2A2__INCLUDED_) +#define AFX_ICON_WND_H__12893D3C_9A86_4A7A_A972_7965BDDBD2A2__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "nel/misc/bitmap.h" + +class CIconWnd : public CWnd +{ +// Operations +public: + CIconWnd(); + void create (DWORD wStyle, RECT &pos, CWnd *window, uint dialogIndex); + +private: + bool updateStr(); + void updateIcon(); + + void blendIcons(NLMISC::CBitmap &dst, const NLMISC::CBitmap &src); + void modulateIcon(NLMISC::CBitmap &dst, const NLMISC::CRGBA &col); + + bool loadIcon(const std::string &filename, NLMISC::CBitmap &bmp); + bool getColorFromStr(const std::string &s, NLMISC::CRGBA &c); + + void addIconLayer(NLMISC::CBitmap &dst, const std::string iconStr, const std::string iconCol); + bool updateWnd(CWnd *pWnd, std::string &str); + +// Attributes +public: + uint Id; + + // Pointer to control window + CWnd *pWndIcon; + CWnd *pWndIconColor; + CWnd *pWndIconBack; + CWnd *pWndIconBackColor; + CWnd *pWndIconOver; + CWnd *pWndIconOverColor; + CWnd *pWndIconOver2; + CWnd *pWndIconOver2Color; + +private: + // String containing window data + std::string strIcon; + std::string strIconColor; + std::string strIconBack; + std::string strIconBackColor; + std::string strIconOver; + std::string strIconOverColor; + std::string strIconOver2; + std::string strIconOver2Color; + + // Bitmap printed on window + NLMISC::CBitmap bitmap; + + // Directory of icons + static std::string IconPath; + +// Implementation +public: + virtual ~CIconWnd(); + + // Generated message map functions +protected: + //{{AFX_MSG(CIconWnd) + afx_msg void OnPaint(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +#endif // !defined(AFX_ICON_WND_H__12893D3C_9A86_4A7A_A972_7965BDDBD2A2__INCLUDED_) diff --git a/code/ryzom/tools/leveldesign/georges_dll/imagelist_ex.cpp b/code/ryzom/tools/leveldesign/georges_dll/imagelist_ex.cpp index bc4b1518f..513abe109 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/imagelist_ex.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/imagelist_ex.cpp @@ -1,142 +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 "stdafx.h" -#include "nel/misc/types_nl.h" -#include "nel/misc/common.h" -#include "resource.h" -#include "imagelist_ex.h" - -#include "set" - -using namespace std; -using namespace NLMISC; - -#pragma warning (disable : 4786) - -BOOL CALLBACK EnumResLangProc(HINSTANCE hModule, LPCTSTR lpszType, LPCTSTR lpszName, WORD wIDLanguage, - LONG lParam) -{ - set *iconNames = (set*)lParam; - - HRSRC hResInfo = FindResourceEx(hModule, lpszType, lpszName, wIDLanguage); - - iconNames->insert (hResInfo); - - return FALSE; -} - -BOOL CALLBACK EnumResNameProc (HINSTANCE hModule, LPCTSTR lpszType, LPTSTR lpszName, LONG lParam) -{ - - EnumResourceLanguages (hModule, lpszType, lpszName, EnumResLangProc, lParam); - - return TRUE; -} - -void CImageListEx::addResourceIcon (HINSTANCE hinst, int resource) -{ - // Image index - int index = ImageList.GetImageCount (); - - // Resize the list - ImageList.SetImageCount (index+1); - - // Get the size - IMAGEINFO imageInfo; - if (ImageList.GetImageInfo( index, &imageInfo)) - { - // Size - int width = imageInfo.rcImage.right - imageInfo.rcImage.left; - int height = imageInfo.rcImage.bottom - imageInfo.rcImage.top; - - // Load the icon - HICON handle = (HICON) LoadImage (hinst, MAKEINTRESOURCE(resource), IMAGE_ICON, width, height, LR_COLOR); - if (handle) - { - // Copy the icon - index = ImageList.Replace( index, handle); - - // Add in the map - _IconMapInt.insert (std::map::value_type (resource, index)); - - // Release the icon - DestroyIcon (handle); - } - } -} - -void CImageListEx::addResourceIcon (const char *filename) -{ - // Image index - int index = ImageList.GetImageCount (); - - // Resize the list - ImageList.SetImageCount (index+1); - - // Get the size - IMAGEINFO imageInfo; - if (ImageList.GetImageInfo( index, &imageInfo)) - { - // Size - int width = imageInfo.rcImage.right - imageInfo.rcImage.left; - int height = imageInfo.rcImage.bottom - imageInfo.rcImage.top; - - // Load the icon - HICON handle = (HICON) LoadImage (NULL, filename, IMAGE_ICON, width, height, LR_COLOR|LR_LOADFROMFILE); - if (handle) - { - // Copy the icon - index = ImageList.Replace( index, handle); - - // Add in the map - char name[MAX_PATH]; - _splitpath (filename, NULL, NULL, name, NULL); - string llwr = strlwr (string (name)); - _IconMapString.insert (std::map::value_type (llwr, index)); - - // Release the icon - DestroyIcon (handle); - } - } -} - -void CImageListEx::create (int width, int height) -{ - ImageList.Create (16, 16, TRUE, 6, 10); - ImageList.SetBkColor( CLR_NONE ); -} - -int CImageListEx::getImage (int resource) const -{ - std::map::const_iterator ite = _IconMapInt.find (resource); - if (ite == _IconMapInt.end()) - return -1; - else - return ite->second; -} - -int CImageListEx::getImage (const char *filename) const -{ - char name[MAX_PATH]; - _splitpath (filename, NULL, NULL, name, NULL); - string llwr = strlwr (string (name)); - std::map::const_iterator ite = _IconMapString.find (llwr); - if (ite == _IconMapString.end()) - return -1; - else - return ite->second; -} +// 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 "stdafx.h" +#include "nel/misc/types_nl.h" +#include "nel/misc/common.h" +#include "resource.h" +#include "imagelist_ex.h" + +#include "set" + +using namespace std; +using namespace NLMISC; + +#pragma warning (disable : 4786) + +BOOL CALLBACK EnumResLangProc(HINSTANCE hModule, LPCTSTR lpszType, LPCTSTR lpszName, WORD wIDLanguage, + LONG lParam) +{ + set *iconNames = (set*)lParam; + + HRSRC hResInfo = FindResourceEx(hModule, lpszType, lpszName, wIDLanguage); + + iconNames->insert (hResInfo); + + return FALSE; +} + +BOOL CALLBACK EnumResNameProc (HINSTANCE hModule, LPCTSTR lpszType, LPTSTR lpszName, LONG lParam) +{ + + EnumResourceLanguages (hModule, lpszType, lpszName, EnumResLangProc, lParam); + + return TRUE; +} + +void CImageListEx::addResourceIcon (HINSTANCE hinst, int resource) +{ + // Image index + int index = ImageList.GetImageCount (); + + // Resize the list + ImageList.SetImageCount (index+1); + + // Get the size + IMAGEINFO imageInfo; + if (ImageList.GetImageInfo( index, &imageInfo)) + { + // Size + int width = imageInfo.rcImage.right - imageInfo.rcImage.left; + int height = imageInfo.rcImage.bottom - imageInfo.rcImage.top; + + // Load the icon + HICON handle = (HICON) LoadImage (hinst, MAKEINTRESOURCE(resource), IMAGE_ICON, width, height, LR_COLOR); + if (handle) + { + // Copy the icon + index = ImageList.Replace( index, handle); + + // Add in the map + _IconMapInt.insert (std::map::value_type (resource, index)); + + // Release the icon + DestroyIcon (handle); + } + } +} + +void CImageListEx::addResourceIcon (const char *filename) +{ + // Image index + int index = ImageList.GetImageCount (); + + // Resize the list + ImageList.SetImageCount (index+1); + + // Get the size + IMAGEINFO imageInfo; + if (ImageList.GetImageInfo( index, &imageInfo)) + { + // Size + int width = imageInfo.rcImage.right - imageInfo.rcImage.left; + int height = imageInfo.rcImage.bottom - imageInfo.rcImage.top; + + // Load the icon + HICON handle = (HICON) LoadImage (NULL, filename, IMAGE_ICON, width, height, LR_COLOR|LR_LOADFROMFILE); + if (handle) + { + // Copy the icon + index = ImageList.Replace( index, handle); + + // Add in the map + char name[MAX_PATH]; + _splitpath (filename, NULL, NULL, name, NULL); + string llwr = strlwr (string (name)); + _IconMapString.insert (std::map::value_type (llwr, index)); + + // Release the icon + DestroyIcon (handle); + } + } +} + +void CImageListEx::create (int width, int height) +{ + ImageList.Create (16, 16, TRUE, 6, 10); + ImageList.SetBkColor( CLR_NONE ); +} + +int CImageListEx::getImage (int resource) const +{ + std::map::const_iterator ite = _IconMapInt.find (resource); + if (ite == _IconMapInt.end()) + return -1; + else + return ite->second; +} + +int CImageListEx::getImage (const char *filename) const +{ + char name[MAX_PATH]; + _splitpath (filename, NULL, NULL, name, NULL); + string llwr = strlwr (string (name)); + std::map::const_iterator ite = _IconMapString.find (llwr); + if (ite == _IconMapString.end()) + return -1; + else + return ite->second; +} diff --git a/code/ryzom/tools/leveldesign/georges_dll/imagelist_ex.h b/code/ryzom/tools/leveldesign/georges_dll/imagelist_ex.h index de5c8ef4b..77edc0a69 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/imagelist_ex.h +++ b/code/ryzom/tools/leveldesign/georges_dll/imagelist_ex.h @@ -1,52 +1,52 @@ -// 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 IMAGELIST_H_INCLUDED -#define IMAGELIST_H_INCLUDED - -// Super Imagelist class -class CImageListEx -{ -public: - - // Interface - - // Create the image list - void create (int width, int height); - - // Add resource icon - void addResourceIcon (HINSTANCE hinst, int resource); - - // Add resource icon - void addResourceIcon (const char *filename); - - // Get an icon resource image by icon name - int getImage (int resource) const; - - // Get an icon resource image by icon name - int getImage (const char *name) const; - -public: - // The image list - CImageList ImageList; - -private: - // The second icon map - std::map _IconMapInt; - std::map _IconMapString; -}; - -#endif // IMAGELIST_H_INCLUDED +// 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 IMAGELIST_H_INCLUDED +#define IMAGELIST_H_INCLUDED + +// Super Imagelist class +class CImageListEx +{ +public: + + // Interface + + // Create the image list + void create (int width, int height); + + // Add resource icon + void addResourceIcon (HINSTANCE hinst, int resource); + + // Add resource icon + void addResourceIcon (const char *filename); + + // Get an icon resource image by icon name + int getImage (int resource) const; + + // Get an icon resource image by icon name + int getImage (const char *name) const; + +public: + // The image list + CImageList ImageList; + +private: + // The second icon map + std::map _IconMapInt; + std::map _IconMapString; +}; + +#endif // IMAGELIST_H_INCLUDED diff --git a/code/ryzom/tools/leveldesign/georges_dll/left_view.cpp b/code/ryzom/tools/leveldesign/georges_dll/left_view.cpp index ec392f67c..51ed32688 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/left_view.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/left_view.cpp @@ -1,1073 +1,1073 @@ -// 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 "stdafx.h" -#include "georges_edit.h" - -#include "main_frm.h" -#include "georges_edit_doc.h" -#include "georges_edit_view.h" -#include "left_view.h" -#include "action.h" - -using namespace std; -using namespace NLGEORGES; -using namespace NLMISC; - - - -// *************************************************************************** -// CLeftView -// *************************************************************************** - -IMPLEMENT_DYNCREATE(CLeftView, CView) - -// *************************************************************************** - -BEGIN_MESSAGE_MAP(CLeftView, CView) - //{{AFX_MSG_MAP(CLeftView) - ON_WM_SIZE() - ON_WM_SETFOCUS() - ON_COMMAND(ID_EDIT_COPY, OnEditCopy) - ON_COMMAND(ID_EDIT_PASTE, OnEditPaste) - ON_COMMAND(ID_EDIT_CUT, OnEditCut) - ON_COMMAND(ID_INSERT, OnInsert) - ON_COMMAND(ID_DELETE, OnDelete) - ON_COMMAND(ID_EDIT_REDO, OnEditRedo) - ON_UPDATE_COMMAND_UI(ID_EDIT_REDO, OnUpdateEditRedo) - ON_COMMAND(ID_EDIT_UNDO, OnEditUndo) - ON_UPDATE_COMMAND_UI(ID_EDIT_UNDO, OnUpdateEditUndo) - ON_COMMAND(ID_EDIT_RENAME, OnEditRename) - ON_COMMAND(ID_EDIT_FETCH1, OnEditFetch1) - ON_COMMAND(ID_EDIT_FETCH2, OnEditFetch2) - ON_COMMAND(ID_EDIT_FETCH3, OnEditFetch3) - ON_COMMAND(ID_EDIT_FETCH4, OnEditFetch4) - ON_COMMAND(ID_EDIT_HOLD1, OnEditHold1) - ON_COMMAND(ID_EDIT_HOLD2, OnEditHold2) - ON_COMMAND(ID_EDIT_HOLD3, OnEditHold3) - ON_COMMAND(ID_EDIT_HOLD4, OnEditHold4) - ON_WM_KEYDOWN() - ON_COMMAND(ID_EDIT_COLLAPSEALL, OnEditCollapseall) - ON_COMMAND(ID_EDIT_EXPANDALL, OnEditExpandall) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// *************************************************************************** -// CLeftView construction/destruction -// *************************************************************************** - -CLeftView::CLeftView() -{ -} - -// *************************************************************************** - -CLeftView::~CLeftView() -{ -} - -// *************************************************************************** - -BOOL CLeftView::PreCreateWindow(CREATESTRUCT& cs) -{ - // TODO: Modify the Window class or styles here by modifying - // the CREATESTRUCT cs - - return CView::PreCreateWindow(cs); -} - -// *************************************************************************** -// CLeftView drawing -// *************************************************************************** - -void CLeftView::OnDraw(CDC* pDC) -{ - CGeorgesEditDoc* pDoc = GetDocument(); - ASSERT_VALID(pDoc); - - // TODO: add draw code for native data here -} - -// *************************************************************************** - -void CLeftView::getSubObject (CGeorgesEditDocSub *subObject, HTREEITEM parent, HTREEITEM item) -{ - // Is this child exist ? - if (!item) - { - int itemImage = subObject->getItemImage (GetDocument()); - item = TreeCtrl.InsertItem (subObject->getName ().c_str(), itemImage, itemImage, parent); - } - - // Set name - TreeCtrl.SetItemText (item, subObject->getName ().c_str()); - - // Set item data - TreeCtrl.SetItemData (item, (DWORD)subObject); - - // For each children - HTREEITEM child = TreeCtrl.GetChildItem (item); - for (uint i=0; igetChildrenCount(); i++) - { - getSubObject (subObject->getChild (i), item, child); - if (child) - { - // Next child - child = TreeCtrl.GetNextSiblingItem (child); - } - } - - // Remove old children - while (child) - { - HTREEITEM toDelete = child; - child = TreeCtrl.GetNextSiblingItem (child); - nlverify (TreeCtrl.DeleteItem (toDelete)); - } -} - -// *************************************************************************** - -void CLeftView::expand () -{ - if (IsWindow (TreeCtrl)) - { - HTREEITEM item = TreeCtrl.GetRootItem (); - if (item != NULL) - { - item = TreeCtrl.GetChildItem (item); - if (item != NULL) - { - item = TreeCtrl.GetNextSiblingItem (item); - expand (item); - } - } - } -} - -// *************************************************************************** - -void CLeftView::expand (HTREEITEM item) -{ - TreeCtrl.Expand (item, TVE_EXPAND); - - HTREEITEM child = TreeCtrl.GetChildItem (item); - while (child) - { - expand (child); - child = TreeCtrl.GetNextSiblingItem (child); - } -} - -// *************************************************************************** - -void CLeftView::collapse (HTREEITEM item) -{ - TreeCtrl.Expand (item, TVE_COLLAPSE); - - HTREEITEM child = TreeCtrl.GetChildItem (item); - while (child) - { - collapse (child); - child = TreeCtrl.GetNextSiblingItem (child); - } -} - -// *************************************************************************** - -void CLeftView::OnInitialUpdate() -{ - CView::OnInitialUpdate(); - - // Create the tree - RECT rect; - GetClientRect (&rect); - TreeCtrl.Create (TVS_EDITLABELS|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS|WS_VISIBLE|WS_CHILD, rect, this, 0); - TreeCtrl.SetImageList( &(theApp.ImageList.ImageList), TVSIL_NORMAL); - - getFromDocument (); - if (theApp.StartExpanded) - expand (); - - HTREEITEM child = TreeCtrl.GetChildItem (TreeCtrl.GetRootItem ()); - if (child) - { - child = TreeCtrl.GetNextItem (child, TVGN_NEXT); - if (child) - { - if (TreeCtrl.GetSelectedItem ()) - TreeCtrl.SetItemState(TreeCtrl.GetSelectedItem (), 0, TVIS_BOLD); - TreeCtrl.Select (child, TVGN_CARET); - TreeCtrl.SetItemState(child, TVIS_BOLD, TVIS_BOLD); - } - } -} - -// *************************************************************************** -// CLeftView diagnostics -// *************************************************************************** - -#ifdef _DEBUG -void CLeftView::AssertValid() const -{ - CView::AssertValid(); -} - -// *************************************************************************** - -void CLeftView::Dump(CDumpContext& dc) const -{ - CView::Dump(dc); -} - -// *************************************************************************** - -CGeorgesEditDoc* CLeftView::GetDocument() // non-debug version is inline -{ - ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CGeorgesEditDocType)) || - m_pDocument->IsKindOf(RUNTIME_CLASS(CGeorgesEditDocDfn)) || - m_pDocument->IsKindOf(RUNTIME_CLASS(CGeorgesEditDocForm))); - return (CGeorgesEditDoc*)m_pDocument; -} -#endif //_DEBUG - -// *************************************************************************** -// CLeftView message handlers -// *************************************************************************** - -BOOL CLeftView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) -{ - // Selection change ? - NMHDR *pnmh = (LPNMHDR) lParam; - switch (pnmh->code) - { - case TVN_BEGINLABELEDIT: - { - // Get tree selection - LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO) lParam; - if (ptvdi->item.hItem) - { - // Get the sub object - CGeorgesEditDocSub *subObject = (CGeorgesEditDocSub*)TreeCtrl.GetItemData (ptvdi->item.hItem); - if (subObject) - { - // Editable ? - if (subObject->isEditable ()) - { - // Get some information about the current node - bool deleteInsert = false; - - // Is a form child ? - CGeorgesEditDocSub *parent = subObject->getParent (); - if (parent && parent->getType () == CGeorgesEditDocSub::Form) - { - // Does the node in the same form ? - CGeorgesEditDoc *doc = GetDocument (); - if (doc) - { - // Get the parent node - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *parentNode; - UFormDfn::TEntryType type; - bool array; - bool parentVDfnArray; - CForm *form=doc->getFormPtr (); - CFormElm *elm = (CFormElm *)doc->getRootNode (subObject->getSlot ()); - nlverify ( elm->getNodeByName (parent->getFormName ().c_str (), &parentDfn, indexDfn, - &nodeDfn, &nodeType, &parentNode, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); - - // Is a non empty array ? - if (array && parentNode) - { - // Edit the tree - *pResult = 0; - return TRUE; - } - } - } - } - } - } - *pResult = 1; - return TRUE; - } - break; - case TVN_ENDLABELEDIT: - { - // Get tree selection - LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO) lParam; - if (ptvdi->item.hItem) - { - // Get the sub object - CGeorgesEditDocSub *subObject = (CGeorgesEditDocSub*)TreeCtrl.GetItemData (ptvdi->item.hItem); - if (subObject) - { - // Editable ? - if (subObject->isEditable ()) - { - // Get some information about the current node - bool deleteInsert = false; - - // Is a form child ? - CGeorgesEditDocSub *parent = subObject->getParent (); - if (parent && parent->getType () == CGeorgesEditDocSub::Form) - { - // Does the node in the same form ? - CGeorgesEditDoc *doc = GetDocument (); - if (doc) - { - // Get the parent node - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *parentNode; - UFormDfn::TEntryType type; - bool array; - bool parentVDfnArray; - CForm *form=doc->getFormPtr (); - CFormElm *elm = (CFormElm *)doc->getRootNode (subObject->getSlot ()); - nlverify ( elm->getNodeByName (parent->getFormName ().c_str (), &parentDfn, indexDfn, - &nodeDfn, &nodeType, &parentNode, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); - - // Is a non empty array ? - if (array && parentNode && (ptvdi->item.mask & TVIF_TEXT)) - { - // Change the node name - TreeCtrl.SetItemText (ptvdi->item.hItem, ptvdi->item.pszText); - doc->modify (new CActionString (IAction::FormArrayRename, ptvdi->item.pszText, *doc, - subObject->getFormName ().c_str (), toString (subObject->getIdInParent ()).c_str(), - doc->getLeftView ()->getCurrentSelectionId (), subObject->getSlot ())); - return TRUE; - } - } - } - } - } - } - *pResult = 1; - return TRUE; - } - break; - case TVN_SELCHANGED: - { - LPNMTREEVIEW itemData = (LPNMTREEVIEW) lParam; - - // Unbold old item - if (itemData->itemOld.hItem) - TreeCtrl.SetItemState(itemData->itemOld.hItem, 0, TVIS_BOLD); - - CGeorgesEditDoc *doc = GetDocument(); - if (doc) - { - CGeorgesEditDocSub *data = (CGeorgesEditDocSub *)TreeCtrl.GetItemData (itemData->itemNew.hItem); - nlassert (data); - doc->changeSubSelection (data, this); - TreeCtrl.SetFocus (); - } - } - break; - case NM_RCLICK: - { - // Get item clicked - TVHITTESTINFO tvhti; - GetCursorPos(&tvhti.pt); - ::ScreenToClient(TreeCtrl, &tvhti.pt); - tvhti.flags = LVHT_NOWHERE; - TreeView_HitTest(TreeCtrl, &tvhti); - - // Item clicked ? - if(TVHT_ONITEM & tvhti.flags) - { - // Select the item - if (TreeCtrl.GetSelectedItem ()) - TreeCtrl.SetItemState(TreeCtrl.GetSelectedItem (), 0, TVIS_BOLD); - TreeCtrl.SelectItem (tvhti.hItem); - TreeCtrl.SetItemState(tvhti.hItem, TVIS_BOLD, TVIS_BOLD); - - // Get the sub object - CGeorgesEditDocSub *subObject = (CGeorgesEditDocSub*)TreeCtrl.GetItemData (tvhti.hItem); - if (subObject) - { - // Editable ? - if (subObject->isEditable ()) - { - // Get some information about the current node - bool deleteInsert = false; - - // Is a form child ? - CGeorgesEditDocSub *parent = subObject->getParent (); - if (parent && parent->getType () == CGeorgesEditDocSub::Form) - { - // Does the node in the same form ? - CGeorgesEditDoc *doc = GetDocument (); - if (doc) - { - // Get the node - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *node; - UFormDfn::TEntryType type; - bool array; - bool parentVDfnArray; - CForm *form=doc->getFormPtr (); - CFormElm *elm = (CFormElm *)doc->getRootNode (subObject->getSlot ()); - nlverify ( elm->getNodeByName (parent->getFormName ().c_str (), &parentDfn, indexDfn, - &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); - - // Is the parent array ? - deleteInsert = array; - } - } - - // Show right click menu - - // Create menu - CMenu mainMenu; - mainMenu.LoadMenu (IDR_LEFT_VIEW_CONTEXT); - CMenu *popup = mainMenu.GetSubMenu (0); - - // Enable disable items - popup->EnableMenuItem (4, MF_BYPOSITION|(deleteInsert?MF_ENABLED:MF_GRAYED)); - popup->EnableMenuItem (5, MF_BYPOSITION|(deleteInsert?MF_ENABLED:MF_GRAYED)); - popup->EnableMenuItem (6, MF_BYPOSITION|(deleteInsert?MF_ENABLED:MF_GRAYED)); - - ::ClientToScreen(TreeCtrl, &tvhti.pt); - popup->TrackPopupMenu (TPM_LEFTALIGN | TPM_RIGHTBUTTON, tvhti.pt.x, tvhti.pt.y, this, NULL); - } - } - } - } - break; - } - - return CView::OnNotify(wParam, lParam, pResult); -} - -// *************************************************************************** - -void CLeftView::getFromDocument () -{ - CGeorgesEditDoc *doc = GetDocument(); - if (doc && IsWindow (TreeCtrl)) - { - // Get the tree root - //TreeCtrl.Expand (TreeCtrl.GetRootItem (), TVE_EXPAND); - getSubObject (&doc->RootObject, NULL, TreeCtrl.GetRootItem ()); - } -} - -// *************************************************************************** - -void CLeftView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) -{ - if (IsWindow (TreeCtrl)) - { - getFromDocument (); - } -} - -// *************************************************************************** - -void CLeftView::OnSize(UINT nType, int cx, int cy) -{ - CView::OnSize(nType, cx, cy); - - if (IsWindow (TreeCtrl)) - { - RECT rect; - GetClientRect (&rect); - TreeCtrl.SetWindowPos (NULL, 0, 0, rect.right-rect.left, rect.bottom-rect.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - } -} - -// *************************************************************************** - -BOOL CLeftView::PreTranslateMessage(MSG* pMsg) -{ - if (theApp.m_pMainWnd->PreTranslateMessage(pMsg)) - return TRUE; - - // Key ? - if (pMsg->message == WM_KEYDOWN) - { - // Tabulation ? - if ((int) pMsg->wParam == VK_TAB) - { - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - // Right view ? - CGeorgesEditView* pView = doc->getRightView (); - if (pView->isFocusable ()) - { - doc->switchToView (pView); - - // Shift ? - if (GetAsyncKeyState (VK_SHIFT) & (1<<15)) - pView->setFocusLastWidget (); - } - } - return TRUE; - } - else if ((int) pMsg->wParam == VK_INSERT) - { - OnInsert (); - return TRUE; - } - else if ((int) pMsg->wParam == VK_DELETE) - { - OnDelete (); - return TRUE; - } - } - - return CView::PreTranslateMessage(pMsg); -} - -// *************************************************************************** - -void CLeftView::OnSetFocus(CWnd* pOldWnd) -{ - CView::OnSetFocus(pOldWnd); - - TreeCtrl.SetFocus (); -} - -// *************************************************************************** - -void CLeftView::OnEditCopy() -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - // What is selected ? - HTREEITEM item = TreeCtrl.GetSelectedItem (); - if (item != NULL) - { - // Edit the label ? - CEdit *edit = TreeCtrl.GetEditControl(); - if (edit) - { - edit->SendMessage (WM_COPY); - } - else - { - // Get the sub data - CGeorgesEditDocSub *subData = (CGeorgesEditDocSub*)TreeCtrl.GetItemData (item); - if (subData) - { - // Get thte node type - CGeorgesEditDocSub::TSub subType = subData->getType (); - - // Good type for copy ? - if (subType == CGeorgesEditDocSub::Form) - { - theApp.SerialIntoMemStream (subData->getFormName ().c_str(), doc, subData->getSlot (), true); - } - } - } - } - } -} - -// *************************************************************************** - -void CLeftView::OnEditPaste() -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - // What is selected ? - HTREEITEM item = TreeCtrl.GetSelectedItem (); - if (item != NULL) - { - // Edit the label ? - CEdit *edit = TreeCtrl.GetEditControl(); - if (edit) - { - edit->SendMessage (WM_PASTE); - } - else - { - // Get the sub data - CGeorgesEditDocSub *subData = (CGeorgesEditDocSub*)TreeCtrl.GetItemData (item); - if (subData) - { - // Get thte node type - CGeorgesEditDocSub::TSub subType = subData->getType (); - - // Good type for copy ? - if (subType == CGeorgesEditDocSub::Form) - { - // Document is modified by this view - if (theApp.FillMemStreamWithClipboard (subData->getFormName ().c_str(), doc, subData->getSlot ())) - { - doc->modify (new CActionBuffer (IAction::FormPaste, theApp.MemStream.buffer (), theApp.MemStream.length(), - *doc, subData->getFormName ().c_str(), "", doc->getLeftView ()->getCurrentSelectionId (), subData->getSlot ())); - } - } - } - } - } - } -} - -// *************************************************************************** - -CGeorgesEditDocSub *CLeftView::getSelectedObject () -{ - HTREEITEM item = TreeCtrl.GetSelectedItem (); - if (item != NULL) - { - return (CGeorgesEditDocSub *)TreeCtrl.GetItemData (item); - } - return NULL; -} - -// *************************************************************************** - -bool CLeftView::changeSubSelection (CGeorgesEditDocSub *sub, HTREEITEM item) -{ - // First time ? - if (item == NULL) - item = TreeCtrl.GetRootItem (); - - // Good one ? - if ( (CGeorgesEditDocSub *)TreeCtrl.GetItemData (item) == sub ) - { - // Select it. - if (TreeCtrl.GetSelectedItem ()) - TreeCtrl.SetItemState(TreeCtrl.GetSelectedItem (), 0, TVIS_BOLD); - nlverify (TreeCtrl.SelectItem (item)); - TreeCtrl.SetItemState(item, TVIS_BOLD, TVIS_BOLD); - return true; - } - - // Scan ohters - HTREEITEM child = TreeCtrl.GetChildItem (item); - while (child) - { - // Good one ? - if (changeSubSelection (sub, child)) - return true; - - // Get next item - child = TreeCtrl.GetNextSiblingItem (child); - } - - // Selection not found - return false; -} - -// *************************************************************************** - -bool CLeftView::changeSubSelection (uint &sub, HTREEITEM item) -{ - // First time ? - if (item == NULL) - item = TreeCtrl.GetRootItem (); - - // Good one ? - if ( sub == 0 ) - { - // Select it. - if (TreeCtrl.GetSelectedItem ()) - TreeCtrl.SetItemState(TreeCtrl.GetSelectedItem (), 0, TVIS_BOLD); - nlverify (TreeCtrl.SelectItem (item)); - TreeCtrl.SetItemState(item, TVIS_BOLD, TVIS_BOLD); - return true; - } - - // Scan ohters - HTREEITEM child = TreeCtrl.GetChildItem (item); - while (child) - { - // Good one ? - if (changeSubSelection (--sub, child)) - return true; - - // Get next item - child = TreeCtrl.GetNextSiblingItem (child); - } - - // Selection not found - return false; -} - -// *************************************************************************** - -uint CLeftView::getCurrentSelectionId (uint *count, HTREEITEM item) -{ - if (IsWindow (TreeCtrl)) - { - uint id = 0; - - // Root item - if (item == NULL) - item = TreeCtrl.GetRootItem (); - - // First id - if (count == NULL) - { - count = &id; - *count = 0; - } - - // Good node ? - if (TreeCtrl.GetSelectedItem () == item) - { - return *count; - } - - // Look in children - item = TreeCtrl.GetChildItem (item); - while (item) - { - // Increment id - (*count) ++; - - // Found ? - if (getCurrentSelectionId (count, item) != 0xffffffff) - return *count; - - // Next child - item = TreeCtrl.GetNextSiblingItem (item); - } - } - - // Not found - return 0xffffffff; -} - -// *************************************************************************** - -bool CLeftView::setCurrentSelectionId (uint id, HTREEITEM item) -{ - if (IsWindow (TreeCtrl)) - { - // Root item - if (item == NULL) - { - item = TreeCtrl.GetRootItem (); - } - - // Good node ? - if (id == 0) - { - // Select the node - if (TreeCtrl.GetSelectedItem ()) - TreeCtrl.SetItemState(TreeCtrl.GetSelectedItem (), 0, TVIS_BOLD); - TreeCtrl.Select (item, TVGN_CARET); - TreeCtrl.SetItemState(item, TVIS_BOLD, TVIS_BOLD); - return true; - } - - // Look in children - item = TreeCtrl.GetChildItem (item); - while (item) - { - // Increment id - id++; - - // Found ? - if (setCurrentSelectionId (id, item)) - return true; - - // Next child - item = TreeCtrl.GetNextSiblingItem (item); - } - } - - // Not found - return false; -} - -// *************************************************************************** - -void CLeftView::OnEditCut() -{ - // Copy - OnEditCopy (); - - // Delete - OnDelete (); -} - -// *************************************************************************** - -void CLeftView::OnInsert() -{ - // Get tree selection - HTREEITEM item = TreeCtrl.GetSelectedItem (); - if (item) - { - // Get the sub object - CGeorgesEditDocSub *subObject = (CGeorgesEditDocSub*)TreeCtrl.GetItemData (item); - if (subObject) - { - // Editable ? - if (subObject->isEditable ()) - { - // Get some information about the current node - bool deleteInsert = false; - - // Is a form child ? - CGeorgesEditDocSub *parent = subObject->getParent (); - if (parent && parent->getType () == CGeorgesEditDocSub::Form) - { - // Does the node in the same form ? - CGeorgesEditDoc *doc = GetDocument (); - if (doc) - { - // Get the parent node - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *parentNode; - UFormDfn::TEntryType type; - bool array; - bool parentVDfnArray; - CForm *form=doc->getFormPtr (); - CFormElm *elm = (CFormElm *)doc->getRootNode (subObject->getSlot ()); - nlverify ( elm->getNodeByName (parent->getFormName ().c_str (), &parentDfn, indexDfn, - &nodeDfn, &nodeType, &parentNode, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); - - // Is a non empty array ? - if (array && parentNode) - { - // Document modified - doc->modify (new CActionString (IAction::FormArrayInsert, toString (subObject->getIdInParent ()).c_str (), - *doc, subObject->getFormName ().c_str (), "", doc->getLeftView ()->getCurrentSelectionId (), subObject->getSlot ())); - } - } - } - } - } - } -} - -// *************************************************************************** - -void CLeftView::OnDelete() -{ - // Get tree selection - HTREEITEM item = TreeCtrl.GetSelectedItem (); - if (item) - { - // Edit the label ? - CEdit *edit = TreeCtrl.GetEditControl(); - if (edit) - { - edit->SetWindowText (""); - } - else - { - // Get the sub object - CGeorgesEditDocSub *subObject = (CGeorgesEditDocSub*)TreeCtrl.GetItemData (item); - if (subObject) - { - // Editable ? - if (subObject->isEditable ()) - { - // Get some information about the current node - bool deleteInsert = false; - - // Is a form child ? - CGeorgesEditDocSub *parent = subObject->getParent (); - if (parent && parent->getType () == CGeorgesEditDocSub::Form) - { - // Does the node in the same form ? - CGeorgesEditDoc *doc = GetDocument (); - if (doc) - { - // Get the parent node - const CFormDfn *parentDfn; - uint indexDfn; - const CFormDfn *nodeDfn; - const CType *nodeType; - CFormElm *parentNode; - UFormDfn::TEntryType type; - bool array; - bool parentVDfnArray; - CForm *form=doc->getFormPtr (); - CFormElm *elm = (CFormElm *)doc->getRootNode (subObject->getSlot ()); - nlverify ( elm->getNodeByName (parent->getFormName ().c_str (), &parentDfn, indexDfn, - &nodeDfn, &nodeType, &parentNode, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); - - // Is a non empty array ? - if (array && parentNode) - { - // Document modified - doc->modify (new CActionBuffer (IAction::FormArrayDelete, NULL, 0, *doc, subObject->getFormName ().c_str (), - toString (subObject->getIdInParent ()).c_str (), doc->getLeftView ()->getCurrentSelectionId (), subObject->getSlot ())); - } - } - } - } - } - } - } -} - -// *************************************************************************** - - -void CLeftView::OnEditRedo() -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - doc->OnEditRedo(); - } -} - -void CLeftView::OnUpdateEditRedo(CCmdUI* pCmdUI) -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - doc->OnUpdateEditRedo(pCmdUI) ; - } -} - -void CLeftView::OnEditUndo() -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - doc->OnEditUndo(); - } -} - -void CLeftView::OnUpdateEditUndo(CCmdUI* pCmdUI) -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - doc->OnUpdateEditUndo(pCmdUI) ; - } -} - -void CLeftView::OnEditRename() -{ - // Edit the tree - HTREEITEM item = TreeCtrl.GetSelectedItem (); - if (item) - TreeCtrl.EditLabel ( item ); -} - -void CLeftView::OnEditFetch1() -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - if (doc->isForm ()) - ((CGeorgesEditDocForm*)doc)->OnEditFetch1(); - } -} - -void CLeftView::OnEditFetch2() -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - if (doc->isForm ()) - ((CGeorgesEditDocForm*)doc)->OnEditFetch2(); - } -} - -void CLeftView::OnEditFetch3() -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - if (doc->isForm ()) - ((CGeorgesEditDocForm*)doc)->OnEditFetch3(); - } -} - -void CLeftView::OnEditFetch4() -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - if (doc->isForm ()) - ((CGeorgesEditDocForm*)doc)->OnEditFetch4(); - } -} - -void CLeftView::OnEditHold1() -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - if (doc->isForm ()) - ((CGeorgesEditDocForm*)doc)->OnEditHold1(); - } -} - -void CLeftView::OnEditHold2() -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - if (doc->isForm ()) - ((CGeorgesEditDocForm*)doc)->OnEditHold2(); - } -} - -void CLeftView::OnEditHold3() -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - if (doc->isForm ()) - ((CGeorgesEditDocForm*)doc)->OnEditHold3(); - } -} - -void CLeftView::OnEditHold4() -{ - CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); - if (doc) - { - if (doc->isForm ()) - ((CGeorgesEditDocForm*)doc)->OnEditHold4(); - } -} - -void CLeftView::OnEditCollapseall() -{ - // Edit the tree - HTREEITEM item = TreeCtrl.GetSelectedItem (); - if (item) - collapse (item); -} - -void CLeftView::OnEditExpandall() -{ - // Edit the tree - HTREEITEM item = TreeCtrl.GetSelectedItem (); - if (item) - expand (item); -} +// 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 "stdafx.h" +#include "georges_edit.h" + +#include "main_frm.h" +#include "georges_edit_doc.h" +#include "georges_edit_view.h" +#include "left_view.h" +#include "action.h" + +using namespace std; +using namespace NLGEORGES; +using namespace NLMISC; + + + +// *************************************************************************** +// CLeftView +// *************************************************************************** + +IMPLEMENT_DYNCREATE(CLeftView, CView) + +// *************************************************************************** + +BEGIN_MESSAGE_MAP(CLeftView, CView) + //{{AFX_MSG_MAP(CLeftView) + ON_WM_SIZE() + ON_WM_SETFOCUS() + ON_COMMAND(ID_EDIT_COPY, OnEditCopy) + ON_COMMAND(ID_EDIT_PASTE, OnEditPaste) + ON_COMMAND(ID_EDIT_CUT, OnEditCut) + ON_COMMAND(ID_INSERT, OnInsert) + ON_COMMAND(ID_DELETE, OnDelete) + ON_COMMAND(ID_EDIT_REDO, OnEditRedo) + ON_UPDATE_COMMAND_UI(ID_EDIT_REDO, OnUpdateEditRedo) + ON_COMMAND(ID_EDIT_UNDO, OnEditUndo) + ON_UPDATE_COMMAND_UI(ID_EDIT_UNDO, OnUpdateEditUndo) + ON_COMMAND(ID_EDIT_RENAME, OnEditRename) + ON_COMMAND(ID_EDIT_FETCH1, OnEditFetch1) + ON_COMMAND(ID_EDIT_FETCH2, OnEditFetch2) + ON_COMMAND(ID_EDIT_FETCH3, OnEditFetch3) + ON_COMMAND(ID_EDIT_FETCH4, OnEditFetch4) + ON_COMMAND(ID_EDIT_HOLD1, OnEditHold1) + ON_COMMAND(ID_EDIT_HOLD2, OnEditHold2) + ON_COMMAND(ID_EDIT_HOLD3, OnEditHold3) + ON_COMMAND(ID_EDIT_HOLD4, OnEditHold4) + ON_WM_KEYDOWN() + ON_COMMAND(ID_EDIT_COLLAPSEALL, OnEditCollapseall) + ON_COMMAND(ID_EDIT_EXPANDALL, OnEditExpandall) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +// *************************************************************************** +// CLeftView construction/destruction +// *************************************************************************** + +CLeftView::CLeftView() +{ +} + +// *************************************************************************** + +CLeftView::~CLeftView() +{ +} + +// *************************************************************************** + +BOOL CLeftView::PreCreateWindow(CREATESTRUCT& cs) +{ + // TODO: Modify the Window class or styles here by modifying + // the CREATESTRUCT cs + + return CView::PreCreateWindow(cs); +} + +// *************************************************************************** +// CLeftView drawing +// *************************************************************************** + +void CLeftView::OnDraw(CDC* pDC) +{ + CGeorgesEditDoc* pDoc = GetDocument(); + ASSERT_VALID(pDoc); + + // TODO: add draw code for native data here +} + +// *************************************************************************** + +void CLeftView::getSubObject (CGeorgesEditDocSub *subObject, HTREEITEM parent, HTREEITEM item) +{ + // Is this child exist ? + if (!item) + { + int itemImage = subObject->getItemImage (GetDocument()); + item = TreeCtrl.InsertItem (subObject->getName ().c_str(), itemImage, itemImage, parent); + } + + // Set name + TreeCtrl.SetItemText (item, subObject->getName ().c_str()); + + // Set item data + TreeCtrl.SetItemData (item, (DWORD)subObject); + + // For each children + HTREEITEM child = TreeCtrl.GetChildItem (item); + for (uint i=0; igetChildrenCount(); i++) + { + getSubObject (subObject->getChild (i), item, child); + if (child) + { + // Next child + child = TreeCtrl.GetNextSiblingItem (child); + } + } + + // Remove old children + while (child) + { + HTREEITEM toDelete = child; + child = TreeCtrl.GetNextSiblingItem (child); + nlverify (TreeCtrl.DeleteItem (toDelete)); + } +} + +// *************************************************************************** + +void CLeftView::expand () +{ + if (IsWindow (TreeCtrl)) + { + HTREEITEM item = TreeCtrl.GetRootItem (); + if (item != NULL) + { + item = TreeCtrl.GetChildItem (item); + if (item != NULL) + { + item = TreeCtrl.GetNextSiblingItem (item); + expand (item); + } + } + } +} + +// *************************************************************************** + +void CLeftView::expand (HTREEITEM item) +{ + TreeCtrl.Expand (item, TVE_EXPAND); + + HTREEITEM child = TreeCtrl.GetChildItem (item); + while (child) + { + expand (child); + child = TreeCtrl.GetNextSiblingItem (child); + } +} + +// *************************************************************************** + +void CLeftView::collapse (HTREEITEM item) +{ + TreeCtrl.Expand (item, TVE_COLLAPSE); + + HTREEITEM child = TreeCtrl.GetChildItem (item); + while (child) + { + collapse (child); + child = TreeCtrl.GetNextSiblingItem (child); + } +} + +// *************************************************************************** + +void CLeftView::OnInitialUpdate() +{ + CView::OnInitialUpdate(); + + // Create the tree + RECT rect; + GetClientRect (&rect); + TreeCtrl.Create (TVS_EDITLABELS|TVS_HASLINES|TVS_LINESATROOT|TVS_HASBUTTONS|WS_VISIBLE|WS_CHILD, rect, this, 0); + TreeCtrl.SetImageList( &(theApp.ImageList.ImageList), TVSIL_NORMAL); + + getFromDocument (); + if (theApp.StartExpanded) + expand (); + + HTREEITEM child = TreeCtrl.GetChildItem (TreeCtrl.GetRootItem ()); + if (child) + { + child = TreeCtrl.GetNextItem (child, TVGN_NEXT); + if (child) + { + if (TreeCtrl.GetSelectedItem ()) + TreeCtrl.SetItemState(TreeCtrl.GetSelectedItem (), 0, TVIS_BOLD); + TreeCtrl.Select (child, TVGN_CARET); + TreeCtrl.SetItemState(child, TVIS_BOLD, TVIS_BOLD); + } + } +} + +// *************************************************************************** +// CLeftView diagnostics +// *************************************************************************** + +#ifdef _DEBUG +void CLeftView::AssertValid() const +{ + CView::AssertValid(); +} + +// *************************************************************************** + +void CLeftView::Dump(CDumpContext& dc) const +{ + CView::Dump(dc); +} + +// *************************************************************************** + +CGeorgesEditDoc* CLeftView::GetDocument() // non-debug version is inline +{ + ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CGeorgesEditDocType)) || + m_pDocument->IsKindOf(RUNTIME_CLASS(CGeorgesEditDocDfn)) || + m_pDocument->IsKindOf(RUNTIME_CLASS(CGeorgesEditDocForm))); + return (CGeorgesEditDoc*)m_pDocument; +} +#endif //_DEBUG + +// *************************************************************************** +// CLeftView message handlers +// *************************************************************************** + +BOOL CLeftView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) +{ + // Selection change ? + NMHDR *pnmh = (LPNMHDR) lParam; + switch (pnmh->code) + { + case TVN_BEGINLABELEDIT: + { + // Get tree selection + LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO) lParam; + if (ptvdi->item.hItem) + { + // Get the sub object + CGeorgesEditDocSub *subObject = (CGeorgesEditDocSub*)TreeCtrl.GetItemData (ptvdi->item.hItem); + if (subObject) + { + // Editable ? + if (subObject->isEditable ()) + { + // Get some information about the current node + bool deleteInsert = false; + + // Is a form child ? + CGeorgesEditDocSub *parent = subObject->getParent (); + if (parent && parent->getType () == CGeorgesEditDocSub::Form) + { + // Does the node in the same form ? + CGeorgesEditDoc *doc = GetDocument (); + if (doc) + { + // Get the parent node + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *parentNode; + UFormDfn::TEntryType type; + bool array; + bool parentVDfnArray; + CForm *form=doc->getFormPtr (); + CFormElm *elm = (CFormElm *)doc->getRootNode (subObject->getSlot ()); + nlverify ( elm->getNodeByName (parent->getFormName ().c_str (), &parentDfn, indexDfn, + &nodeDfn, &nodeType, &parentNode, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); + + // Is a non empty array ? + if (array && parentNode) + { + // Edit the tree + *pResult = 0; + return TRUE; + } + } + } + } + } + } + *pResult = 1; + return TRUE; + } + break; + case TVN_ENDLABELEDIT: + { + // Get tree selection + LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO) lParam; + if (ptvdi->item.hItem) + { + // Get the sub object + CGeorgesEditDocSub *subObject = (CGeorgesEditDocSub*)TreeCtrl.GetItemData (ptvdi->item.hItem); + if (subObject) + { + // Editable ? + if (subObject->isEditable ()) + { + // Get some information about the current node + bool deleteInsert = false; + + // Is a form child ? + CGeorgesEditDocSub *parent = subObject->getParent (); + if (parent && parent->getType () == CGeorgesEditDocSub::Form) + { + // Does the node in the same form ? + CGeorgesEditDoc *doc = GetDocument (); + if (doc) + { + // Get the parent node + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *parentNode; + UFormDfn::TEntryType type; + bool array; + bool parentVDfnArray; + CForm *form=doc->getFormPtr (); + CFormElm *elm = (CFormElm *)doc->getRootNode (subObject->getSlot ()); + nlverify ( elm->getNodeByName (parent->getFormName ().c_str (), &parentDfn, indexDfn, + &nodeDfn, &nodeType, &parentNode, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); + + // Is a non empty array ? + if (array && parentNode && (ptvdi->item.mask & TVIF_TEXT)) + { + // Change the node name + TreeCtrl.SetItemText (ptvdi->item.hItem, ptvdi->item.pszText); + doc->modify (new CActionString (IAction::FormArrayRename, ptvdi->item.pszText, *doc, + subObject->getFormName ().c_str (), toString (subObject->getIdInParent ()).c_str(), + doc->getLeftView ()->getCurrentSelectionId (), subObject->getSlot ())); + return TRUE; + } + } + } + } + } + } + *pResult = 1; + return TRUE; + } + break; + case TVN_SELCHANGED: + { + LPNMTREEVIEW itemData = (LPNMTREEVIEW) lParam; + + // Unbold old item + if (itemData->itemOld.hItem) + TreeCtrl.SetItemState(itemData->itemOld.hItem, 0, TVIS_BOLD); + + CGeorgesEditDoc *doc = GetDocument(); + if (doc) + { + CGeorgesEditDocSub *data = (CGeorgesEditDocSub *)TreeCtrl.GetItemData (itemData->itemNew.hItem); + nlassert (data); + doc->changeSubSelection (data, this); + TreeCtrl.SetFocus (); + } + } + break; + case NM_RCLICK: + { + // Get item clicked + TVHITTESTINFO tvhti; + GetCursorPos(&tvhti.pt); + ::ScreenToClient(TreeCtrl, &tvhti.pt); + tvhti.flags = LVHT_NOWHERE; + TreeView_HitTest(TreeCtrl, &tvhti); + + // Item clicked ? + if(TVHT_ONITEM & tvhti.flags) + { + // Select the item + if (TreeCtrl.GetSelectedItem ()) + TreeCtrl.SetItemState(TreeCtrl.GetSelectedItem (), 0, TVIS_BOLD); + TreeCtrl.SelectItem (tvhti.hItem); + TreeCtrl.SetItemState(tvhti.hItem, TVIS_BOLD, TVIS_BOLD); + + // Get the sub object + CGeorgesEditDocSub *subObject = (CGeorgesEditDocSub*)TreeCtrl.GetItemData (tvhti.hItem); + if (subObject) + { + // Editable ? + if (subObject->isEditable ()) + { + // Get some information about the current node + bool deleteInsert = false; + + // Is a form child ? + CGeorgesEditDocSub *parent = subObject->getParent (); + if (parent && parent->getType () == CGeorgesEditDocSub::Form) + { + // Does the node in the same form ? + CGeorgesEditDoc *doc = GetDocument (); + if (doc) + { + // Get the node + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *node; + UFormDfn::TEntryType type; + bool array; + bool parentVDfnArray; + CForm *form=doc->getFormPtr (); + CFormElm *elm = (CFormElm *)doc->getRootNode (subObject->getSlot ()); + nlverify ( elm->getNodeByName (parent->getFormName ().c_str (), &parentDfn, indexDfn, + &nodeDfn, &nodeType, &node, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); + + // Is the parent array ? + deleteInsert = array; + } + } + + // Show right click menu + + // Create menu + CMenu mainMenu; + mainMenu.LoadMenu (IDR_LEFT_VIEW_CONTEXT); + CMenu *popup = mainMenu.GetSubMenu (0); + + // Enable disable items + popup->EnableMenuItem (4, MF_BYPOSITION|(deleteInsert?MF_ENABLED:MF_GRAYED)); + popup->EnableMenuItem (5, MF_BYPOSITION|(deleteInsert?MF_ENABLED:MF_GRAYED)); + popup->EnableMenuItem (6, MF_BYPOSITION|(deleteInsert?MF_ENABLED:MF_GRAYED)); + + ::ClientToScreen(TreeCtrl, &tvhti.pt); + popup->TrackPopupMenu (TPM_LEFTALIGN | TPM_RIGHTBUTTON, tvhti.pt.x, tvhti.pt.y, this, NULL); + } + } + } + } + break; + } + + return CView::OnNotify(wParam, lParam, pResult); +} + +// *************************************************************************** + +void CLeftView::getFromDocument () +{ + CGeorgesEditDoc *doc = GetDocument(); + if (doc && IsWindow (TreeCtrl)) + { + // Get the tree root + //TreeCtrl.Expand (TreeCtrl.GetRootItem (), TVE_EXPAND); + getSubObject (&doc->RootObject, NULL, TreeCtrl.GetRootItem ()); + } +} + +// *************************************************************************** + +void CLeftView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) +{ + if (IsWindow (TreeCtrl)) + { + getFromDocument (); + } +} + +// *************************************************************************** + +void CLeftView::OnSize(UINT nType, int cx, int cy) +{ + CView::OnSize(nType, cx, cy); + + if (IsWindow (TreeCtrl)) + { + RECT rect; + GetClientRect (&rect); + TreeCtrl.SetWindowPos (NULL, 0, 0, rect.right-rect.left, rect.bottom-rect.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + } +} + +// *************************************************************************** + +BOOL CLeftView::PreTranslateMessage(MSG* pMsg) +{ + if (theApp.m_pMainWnd->PreTranslateMessage(pMsg)) + return TRUE; + + // Key ? + if (pMsg->message == WM_KEYDOWN) + { + // Tabulation ? + if ((int) pMsg->wParam == VK_TAB) + { + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + // Right view ? + CGeorgesEditView* pView = doc->getRightView (); + if (pView->isFocusable ()) + { + doc->switchToView (pView); + + // Shift ? + if (GetAsyncKeyState (VK_SHIFT) & (1<<15)) + pView->setFocusLastWidget (); + } + } + return TRUE; + } + else if ((int) pMsg->wParam == VK_INSERT) + { + OnInsert (); + return TRUE; + } + else if ((int) pMsg->wParam == VK_DELETE) + { + OnDelete (); + return TRUE; + } + } + + return CView::PreTranslateMessage(pMsg); +} + +// *************************************************************************** + +void CLeftView::OnSetFocus(CWnd* pOldWnd) +{ + CView::OnSetFocus(pOldWnd); + + TreeCtrl.SetFocus (); +} + +// *************************************************************************** + +void CLeftView::OnEditCopy() +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + // What is selected ? + HTREEITEM item = TreeCtrl.GetSelectedItem (); + if (item != NULL) + { + // Edit the label ? + CEdit *edit = TreeCtrl.GetEditControl(); + if (edit) + { + edit->SendMessage (WM_COPY); + } + else + { + // Get the sub data + CGeorgesEditDocSub *subData = (CGeorgesEditDocSub*)TreeCtrl.GetItemData (item); + if (subData) + { + // Get thte node type + CGeorgesEditDocSub::TSub subType = subData->getType (); + + // Good type for copy ? + if (subType == CGeorgesEditDocSub::Form) + { + theApp.SerialIntoMemStream (subData->getFormName ().c_str(), doc, subData->getSlot (), true); + } + } + } + } + } +} + +// *************************************************************************** + +void CLeftView::OnEditPaste() +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + // What is selected ? + HTREEITEM item = TreeCtrl.GetSelectedItem (); + if (item != NULL) + { + // Edit the label ? + CEdit *edit = TreeCtrl.GetEditControl(); + if (edit) + { + edit->SendMessage (WM_PASTE); + } + else + { + // Get the sub data + CGeorgesEditDocSub *subData = (CGeorgesEditDocSub*)TreeCtrl.GetItemData (item); + if (subData) + { + // Get thte node type + CGeorgesEditDocSub::TSub subType = subData->getType (); + + // Good type for copy ? + if (subType == CGeorgesEditDocSub::Form) + { + // Document is modified by this view + if (theApp.FillMemStreamWithClipboard (subData->getFormName ().c_str(), doc, subData->getSlot ())) + { + doc->modify (new CActionBuffer (IAction::FormPaste, theApp.MemStream.buffer (), theApp.MemStream.length(), + *doc, subData->getFormName ().c_str(), "", doc->getLeftView ()->getCurrentSelectionId (), subData->getSlot ())); + } + } + } + } + } + } +} + +// *************************************************************************** + +CGeorgesEditDocSub *CLeftView::getSelectedObject () +{ + HTREEITEM item = TreeCtrl.GetSelectedItem (); + if (item != NULL) + { + return (CGeorgesEditDocSub *)TreeCtrl.GetItemData (item); + } + return NULL; +} + +// *************************************************************************** + +bool CLeftView::changeSubSelection (CGeorgesEditDocSub *sub, HTREEITEM item) +{ + // First time ? + if (item == NULL) + item = TreeCtrl.GetRootItem (); + + // Good one ? + if ( (CGeorgesEditDocSub *)TreeCtrl.GetItemData (item) == sub ) + { + // Select it. + if (TreeCtrl.GetSelectedItem ()) + TreeCtrl.SetItemState(TreeCtrl.GetSelectedItem (), 0, TVIS_BOLD); + nlverify (TreeCtrl.SelectItem (item)); + TreeCtrl.SetItemState(item, TVIS_BOLD, TVIS_BOLD); + return true; + } + + // Scan ohters + HTREEITEM child = TreeCtrl.GetChildItem (item); + while (child) + { + // Good one ? + if (changeSubSelection (sub, child)) + return true; + + // Get next item + child = TreeCtrl.GetNextSiblingItem (child); + } + + // Selection not found + return false; +} + +// *************************************************************************** + +bool CLeftView::changeSubSelection (uint &sub, HTREEITEM item) +{ + // First time ? + if (item == NULL) + item = TreeCtrl.GetRootItem (); + + // Good one ? + if ( sub == 0 ) + { + // Select it. + if (TreeCtrl.GetSelectedItem ()) + TreeCtrl.SetItemState(TreeCtrl.GetSelectedItem (), 0, TVIS_BOLD); + nlverify (TreeCtrl.SelectItem (item)); + TreeCtrl.SetItemState(item, TVIS_BOLD, TVIS_BOLD); + return true; + } + + // Scan ohters + HTREEITEM child = TreeCtrl.GetChildItem (item); + while (child) + { + // Good one ? + if (changeSubSelection (--sub, child)) + return true; + + // Get next item + child = TreeCtrl.GetNextSiblingItem (child); + } + + // Selection not found + return false; +} + +// *************************************************************************** + +uint CLeftView::getCurrentSelectionId (uint *count, HTREEITEM item) +{ + if (IsWindow (TreeCtrl)) + { + uint id = 0; + + // Root item + if (item == NULL) + item = TreeCtrl.GetRootItem (); + + // First id + if (count == NULL) + { + count = &id; + *count = 0; + } + + // Good node ? + if (TreeCtrl.GetSelectedItem () == item) + { + return *count; + } + + // Look in children + item = TreeCtrl.GetChildItem (item); + while (item) + { + // Increment id + (*count) ++; + + // Found ? + if (getCurrentSelectionId (count, item) != 0xffffffff) + return *count; + + // Next child + item = TreeCtrl.GetNextSiblingItem (item); + } + } + + // Not found + return 0xffffffff; +} + +// *************************************************************************** + +bool CLeftView::setCurrentSelectionId (uint id, HTREEITEM item) +{ + if (IsWindow (TreeCtrl)) + { + // Root item + if (item == NULL) + { + item = TreeCtrl.GetRootItem (); + } + + // Good node ? + if (id == 0) + { + // Select the node + if (TreeCtrl.GetSelectedItem ()) + TreeCtrl.SetItemState(TreeCtrl.GetSelectedItem (), 0, TVIS_BOLD); + TreeCtrl.Select (item, TVGN_CARET); + TreeCtrl.SetItemState(item, TVIS_BOLD, TVIS_BOLD); + return true; + } + + // Look in children + item = TreeCtrl.GetChildItem (item); + while (item) + { + // Increment id + id++; + + // Found ? + if (setCurrentSelectionId (id, item)) + return true; + + // Next child + item = TreeCtrl.GetNextSiblingItem (item); + } + } + + // Not found + return false; +} + +// *************************************************************************** + +void CLeftView::OnEditCut() +{ + // Copy + OnEditCopy (); + + // Delete + OnDelete (); +} + +// *************************************************************************** + +void CLeftView::OnInsert() +{ + // Get tree selection + HTREEITEM item = TreeCtrl.GetSelectedItem (); + if (item) + { + // Get the sub object + CGeorgesEditDocSub *subObject = (CGeorgesEditDocSub*)TreeCtrl.GetItemData (item); + if (subObject) + { + // Editable ? + if (subObject->isEditable ()) + { + // Get some information about the current node + bool deleteInsert = false; + + // Is a form child ? + CGeorgesEditDocSub *parent = subObject->getParent (); + if (parent && parent->getType () == CGeorgesEditDocSub::Form) + { + // Does the node in the same form ? + CGeorgesEditDoc *doc = GetDocument (); + if (doc) + { + // Get the parent node + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *parentNode; + UFormDfn::TEntryType type; + bool array; + bool parentVDfnArray; + CForm *form=doc->getFormPtr (); + CFormElm *elm = (CFormElm *)doc->getRootNode (subObject->getSlot ()); + nlverify ( elm->getNodeByName (parent->getFormName ().c_str (), &parentDfn, indexDfn, + &nodeDfn, &nodeType, &parentNode, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); + + // Is a non empty array ? + if (array && parentNode) + { + // Document modified + doc->modify (new CActionString (IAction::FormArrayInsert, toString (subObject->getIdInParent ()).c_str (), + *doc, subObject->getFormName ().c_str (), "", doc->getLeftView ()->getCurrentSelectionId (), subObject->getSlot ())); + } + } + } + } + } + } +} + +// *************************************************************************** + +void CLeftView::OnDelete() +{ + // Get tree selection + HTREEITEM item = TreeCtrl.GetSelectedItem (); + if (item) + { + // Edit the label ? + CEdit *edit = TreeCtrl.GetEditControl(); + if (edit) + { + edit->SetWindowText (""); + } + else + { + // Get the sub object + CGeorgesEditDocSub *subObject = (CGeorgesEditDocSub*)TreeCtrl.GetItemData (item); + if (subObject) + { + // Editable ? + if (subObject->isEditable ()) + { + // Get some information about the current node + bool deleteInsert = false; + + // Is a form child ? + CGeorgesEditDocSub *parent = subObject->getParent (); + if (parent && parent->getType () == CGeorgesEditDocSub::Form) + { + // Does the node in the same form ? + CGeorgesEditDoc *doc = GetDocument (); + if (doc) + { + // Get the parent node + const CFormDfn *parentDfn; + uint indexDfn; + const CFormDfn *nodeDfn; + const CType *nodeType; + CFormElm *parentNode; + UFormDfn::TEntryType type; + bool array; + bool parentVDfnArray; + CForm *form=doc->getFormPtr (); + CFormElm *elm = (CFormElm *)doc->getRootNode (subObject->getSlot ()); + nlverify ( elm->getNodeByName (parent->getFormName ().c_str (), &parentDfn, indexDfn, + &nodeDfn, &nodeType, &parentNode, type, array, parentVDfnArray, true, NLGEORGES_FIRST_ROUND) ); + + // Is a non empty array ? + if (array && parentNode) + { + // Document modified + doc->modify (new CActionBuffer (IAction::FormArrayDelete, NULL, 0, *doc, subObject->getFormName ().c_str (), + toString (subObject->getIdInParent ()).c_str (), doc->getLeftView ()->getCurrentSelectionId (), subObject->getSlot ())); + } + } + } + } + } + } + } +} + +// *************************************************************************** + + +void CLeftView::OnEditRedo() +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + doc->OnEditRedo(); + } +} + +void CLeftView::OnUpdateEditRedo(CCmdUI* pCmdUI) +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + doc->OnUpdateEditRedo(pCmdUI) ; + } +} + +void CLeftView::OnEditUndo() +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + doc->OnEditUndo(); + } +} + +void CLeftView::OnUpdateEditUndo(CCmdUI* pCmdUI) +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + doc->OnUpdateEditUndo(pCmdUI) ; + } +} + +void CLeftView::OnEditRename() +{ + // Edit the tree + HTREEITEM item = TreeCtrl.GetSelectedItem (); + if (item) + TreeCtrl.EditLabel ( item ); +} + +void CLeftView::OnEditFetch1() +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + if (doc->isForm ()) + ((CGeorgesEditDocForm*)doc)->OnEditFetch1(); + } +} + +void CLeftView::OnEditFetch2() +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + if (doc->isForm ()) + ((CGeorgesEditDocForm*)doc)->OnEditFetch2(); + } +} + +void CLeftView::OnEditFetch3() +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + if (doc->isForm ()) + ((CGeorgesEditDocForm*)doc)->OnEditFetch3(); + } +} + +void CLeftView::OnEditFetch4() +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + if (doc->isForm ()) + ((CGeorgesEditDocForm*)doc)->OnEditFetch4(); + } +} + +void CLeftView::OnEditHold1() +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + if (doc->isForm ()) + ((CGeorgesEditDocForm*)doc)->OnEditHold1(); + } +} + +void CLeftView::OnEditHold2() +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + if (doc->isForm ()) + ((CGeorgesEditDocForm*)doc)->OnEditHold2(); + } +} + +void CLeftView::OnEditHold3() +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + if (doc->isForm ()) + ((CGeorgesEditDocForm*)doc)->OnEditHold3(); + } +} + +void CLeftView::OnEditHold4() +{ + CGeorgesEditDoc *doc = (CGeorgesEditDoc*)GetDocument( ); + if (doc) + { + if (doc->isForm ()) + ((CGeorgesEditDocForm*)doc)->OnEditHold4(); + } +} + +void CLeftView::OnEditCollapseall() +{ + // Edit the tree + HTREEITEM item = TreeCtrl.GetSelectedItem (); + if (item) + collapse (item); +} + +void CLeftView::OnEditExpandall() +{ + // Edit the tree + HTREEITEM item = TreeCtrl.GetSelectedItem (); + if (item) + expand (item); +} diff --git a/code/ryzom/tools/leveldesign/georges_dll/left_view.h b/code/ryzom/tools/leveldesign/georges_dll/left_view.h index ac37e0589..a4c8b0b13 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/left_view.h +++ b/code/ryzom/tools/leveldesign/georges_dll/left_view.h @@ -1,133 +1,133 @@ -// 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 . - -#if !defined(AFX_LEFTVIEW_H__5D7BB0E1_ADB3_42FF_AD3D_4ACDF282BA21__INCLUDED_) -#define AFX_LEFTVIEW_H__5D7BB0E1_ADB3_42FF_AD3D_4ACDF282BA21__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -class CGeorgesEditDoc; -class CGeorgesEditView; -class CGeorgesEditDocSub; - -class CLeftView : public CView -{ -protected: // create from serialization only - CLeftView (); - DECLARE_DYNCREATE(CLeftView) - -// Attributes -public: - CGeorgesEditDoc* GetDocument(); - - // Update the tree structure - void getFromDocument (); - - // Get the current selection Id. If no selection, return 0xffffffff. - uint getCurrentSelectionId (uint *count=NULL, HTREEITEM item = NULL); - - // Set the current selection Id. Return true if the node has been found. - bool setCurrentSelectionId (uint id, HTREEITEM item = NULL); - - // Return the seledcted sub object. Called by CGeorgesEditDoc::getSelectedObject (). - CGeorgesEditDocSub *getSelectedObject (); - - // Change the sub seletion. Called by CGeorgesEditDoc::changeSubSelection (). - bool changeSubSelection (CGeorgesEditDocSub *sub, HTREEITEM item = NULL); - - // Change the sub seletion. Called by CGeorgesEditDoc::changeSubSelection (). - bool changeSubSelection (uint &sub, HTREEITEM item = NULL); - - // Expand // Collapse - void expand (); - void expand (HTREEITEM item); - void collapse (HTREEITEM item); - -private: - - // Recurse sub object tree called by getFromDocument - void getSubObject (CGeorgesEditDocSub *subObject, HTREEITEM parent, HTREEITEM item); - - CTreeCtrl TreeCtrl; - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CLeftView) - public: - virtual void OnDraw(CDC* pDC); // overridden to draw this view - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - virtual BOOL PreTranslateMessage(MSG* pMsg); - protected: - virtual void OnInitialUpdate(); // called first time after construct - virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); - virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint); - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CLeftView(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -protected: - -// Generated message map functions -protected: - //{{AFX_MSG(CLeftView) - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnSetFocus(CWnd* pOldWnd); - afx_msg void OnEditCopy(); - afx_msg void OnEditPaste(); - afx_msg void OnEditCut(); - afx_msg void OnInsert(); - afx_msg void OnDelete(); - afx_msg void OnEditRedo(); - afx_msg void OnUpdateEditRedo(CCmdUI* pCmdUI); - afx_msg void OnEditUndo(); - afx_msg void OnUpdateEditUndo(CCmdUI* pCmdUI); - afx_msg void OnEditRename(); - afx_msg void OnEditFetch1(); - afx_msg void OnEditFetch2(); - afx_msg void OnEditFetch3(); - afx_msg void OnEditFetch4(); - afx_msg void OnEditHold1(); - afx_msg void OnEditHold2(); - afx_msg void OnEditHold3(); - afx_msg void OnEditHold4(); - afx_msg void OnEditCollapseall(); - afx_msg void OnEditExpandall(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -#ifndef _DEBUG // debug version in LeftView.cpp -inline CGeorgesEditDoc* CLeftView::GetDocument() - { return (CGeorgesEditDoc*)m_pDocument; } -#endif - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_LEFTVIEW_H__5D7BB0E1_ADB3_42FF_AD3D_4ACDF282BA21__INCLUDED_) +// 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 . + +#if !defined(AFX_LEFTVIEW_H__5D7BB0E1_ADB3_42FF_AD3D_4ACDF282BA21__INCLUDED_) +#define AFX_LEFTVIEW_H__5D7BB0E1_ADB3_42FF_AD3D_4ACDF282BA21__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +class CGeorgesEditDoc; +class CGeorgesEditView; +class CGeorgesEditDocSub; + +class CLeftView : public CView +{ +protected: // create from serialization only + CLeftView (); + DECLARE_DYNCREATE(CLeftView) + +// Attributes +public: + CGeorgesEditDoc* GetDocument(); + + // Update the tree structure + void getFromDocument (); + + // Get the current selection Id. If no selection, return 0xffffffff. + uint getCurrentSelectionId (uint *count=NULL, HTREEITEM item = NULL); + + // Set the current selection Id. Return true if the node has been found. + bool setCurrentSelectionId (uint id, HTREEITEM item = NULL); + + // Return the seledcted sub object. Called by CGeorgesEditDoc::getSelectedObject (). + CGeorgesEditDocSub *getSelectedObject (); + + // Change the sub seletion. Called by CGeorgesEditDoc::changeSubSelection (). + bool changeSubSelection (CGeorgesEditDocSub *sub, HTREEITEM item = NULL); + + // Change the sub seletion. Called by CGeorgesEditDoc::changeSubSelection (). + bool changeSubSelection (uint &sub, HTREEITEM item = NULL); + + // Expand // Collapse + void expand (); + void expand (HTREEITEM item); + void collapse (HTREEITEM item); + +private: + + // Recurse sub object tree called by getFromDocument + void getSubObject (CGeorgesEditDocSub *subObject, HTREEITEM parent, HTREEITEM item); + + CTreeCtrl TreeCtrl; + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CLeftView) + public: + virtual void OnDraw(CDC* pDC); // overridden to draw this view + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + virtual BOOL PreTranslateMessage(MSG* pMsg); + protected: + virtual void OnInitialUpdate(); // called first time after construct + virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult); + virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint); + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CLeftView(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +protected: + +// Generated message map functions +protected: + //{{AFX_MSG(CLeftView) + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnSetFocus(CWnd* pOldWnd); + afx_msg void OnEditCopy(); + afx_msg void OnEditPaste(); + afx_msg void OnEditCut(); + afx_msg void OnInsert(); + afx_msg void OnDelete(); + afx_msg void OnEditRedo(); + afx_msg void OnUpdateEditRedo(CCmdUI* pCmdUI); + afx_msg void OnEditUndo(); + afx_msg void OnUpdateEditUndo(CCmdUI* pCmdUI); + afx_msg void OnEditRename(); + afx_msg void OnEditFetch1(); + afx_msg void OnEditFetch2(); + afx_msg void OnEditFetch3(); + afx_msg void OnEditFetch4(); + afx_msg void OnEditHold1(); + afx_msg void OnEditHold2(); + afx_msg void OnEditHold3(); + afx_msg void OnEditHold4(); + afx_msg void OnEditCollapseall(); + afx_msg void OnEditExpandall(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +#ifndef _DEBUG // debug version in LeftView.cpp +inline CGeorgesEditDoc* CLeftView::GetDocument() + { return (CGeorgesEditDoc*)m_pDocument; } +#endif + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_LEFTVIEW_H__5D7BB0E1_ADB3_42FF_AD3D_4ACDF282BA21__INCLUDED_) diff --git a/code/ryzom/tools/leveldesign/georges_dll/main_frm.cpp b/code/ryzom/tools/leveldesign/georges_dll/main_frm.cpp index 8faf7e792..02c06fdde 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/main_frm.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/main_frm.cpp @@ -1,549 +1,549 @@ -// 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 "stdafx.h" -#include "georges_edit.h" -#include "georges_edit_view.h" -#include "georges_edit_doc.h" -#include "settings_dialog.h" -#include "child_frm.h" - -#include "main_frm.h" - -#include "nel/misc/debug.h" - -using namespace NLMISC; -using namespace std; - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame - -IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd) - -BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) - //{{AFX_MSG_MAP(CMainFrame) - ON_WM_CREATE() - ON_COMMAND(ID_VIEW_SETTINGS, OnSettings) - ON_WM_CLOSE() - ON_COMMAND(ID_VIEW_DOCKINGDIALOGBAR, OnViewDockingdialogbar) - ON_UPDATE_COMMAND_UI(ID_VIEW_DOCKINGDIALOGBAR, OnUpdateViewDockingdialogbar) - ON_WM_SIZE() - ON_COMMAND(ID_VIEW_OUTPUT_CONSOLE, OnViewOutputConsole) - ON_UPDATE_COMMAND_UI(ID_VIEW_OUTPUT_CONSOLE, OnUpdateViewOutputConsole) - ON_COMMAND(ID_VIEW_GOTO_FILE_BROWSER, OnViewGotoFileBrowser) - ON_COMMAND(ID_VIEW_GOTO_OUTPUT_CONSOLE, OnViewGotoOutputConsole) - ON_COMMAND(ID_MODULES_0, OnModules0) - ON_UPDATE_COMMAND_UI(ID_MODULES_0, OnUpdateModules0) - ON_COMMAND(ID_MODULES_1, OnModules1) - ON_UPDATE_COMMAND_UI(ID_MODULES_1, OnUpdateModules1) - ON_COMMAND(ID_MODULES_2, OnModules2) - ON_UPDATE_COMMAND_UI(ID_MODULES_2, OnUpdateModules2) - ON_COMMAND(ID_MODULES_3, OnModules3) - ON_UPDATE_COMMAND_UI(ID_MODULES_3, OnUpdateModules3) - ON_UPDATE_COMMAND_UI(ID_VIEW_SETTINGS, OnUpdateViewSettings) - ON_COMMAND(ID_BROWSER_SORTED_BY_TYPE, OnBrowserSortedByType) - ON_WM_KEYDOWN() - ON_UPDATE_COMMAND_UI(ID_BROWSER_SORTED_BY_TYPE, OnUpdateBrowserSortedByType) - //}}AFX_MSG_MAP - // Global help commands - ON_COMMAND(ID_HELP_FINDER, CMDIFrameWnd::OnHelpFinder) - ON_COMMAND(ID_HELP, CMDIFrameWnd::OnHelp) - ON_COMMAND(ID_CONTEXT_HELP, CMDIFrameWnd::OnContextHelp) - ON_COMMAND(ID_DEFAULT_HELP, CMDIFrameWnd::OnHelpFinder) -END_MESSAGE_MAP() - -static UINT indicators[] = -{ - ID_SEPARATOR, // status line indicator - ID_INDICATOR_CAPS, - ID_INDICATOR_NUM, - ID_INDICATOR_SCRL, -}; - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame construction/destruction - -CMainFrame::CMainFrame() -{ - // m_bAutoMenuEnable = FALSE; - m_bDontClose = false; - BrowserSortedByType = false; -} - -CMainFrame::~CMainFrame() -{ - ErrorLog->removeDisplayer (&Displayer); - WarningLog->removeDisplayer (&Displayer); - InfoLog->removeDisplayer (&Displayer); - DebugLog->removeDisplayer (&Displayer); - AssertLog->removeDisplayer (&Displayer); -} - -int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) -{ - if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) - return -1; - - if (!m_wndToolBar.Create(this) || - !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) - { - TRACE0("Failed to create toolbar\n"); - return -1; // fail to create - } - - if (!m_wndStatusBar.Create(this) || - !m_wndStatusBar.SetIndicators(indicators, - sizeof(indicators)/sizeof(UINT))) - { - TRACE0("Failed to create status bar\n"); - return -1; // fail to create - } - - // Icon bar - m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | - CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); - - // Dockable - m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); - EnableDocking(CBRS_ALIGN_ANY); - DockControlBar(&m_wndToolBar); - - // Create the file browser - if (!FileBrowser.Create(this, &FileBrowserDlg, CString("File browser"), IDD_FILE_BROWSER)) - { - TRACE0("Failed to create dialogbar\n"); - return -1; // fail to create - } - - // Docking bar - ShowControlBar (&FileBrowser, TRUE, FALSE); - FileBrowser.SetBarStyle (FileBrowser.GetBarStyle()|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_DYNAMIC); - FileBrowser.EnableDocking (CBRS_ALIGN_ANY); - DockControlBar (&FileBrowser); - - // Menu file browser - CMenu *menu = GetMenu(); - menu->CheckMenuItem(ID_VIEW_DOCKINGDIALOGBAR, MF_CHECKED); - - // Create the output console - if (!OutputConsole.Create(this, &OutputConsoleDlg, CString("Output"), IDD_OUTPUT_CONSOLE)) - { - TRACE0("Failed to create dialogbar\n"); - return -1; // fail to create - } - - // Docking bar - ShowControlBar (&OutputConsole, TRUE, FALSE); - OutputConsole.SetBarStyle (OutputConsole.GetBarStyle()|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_DYNAMIC); - OutputConsole.EnableDocking (CBRS_ALIGN_ANY); - DockControlBar (&OutputConsole, AFX_IDW_DOCKBAR_BOTTOM); - - // Menu file browser - menu = GetMenu(); - menu->CheckMenuItem(ID_VIEW_OUTPUT_CONSOLE, MF_CHECKED); - - // Init displayer - ErrorLog->addDisplayer (&Displayer); - WarningLog->addDisplayer (&Displayer); - InfoLog->addDisplayer (&Displayer); - DebugLog->addDisplayer (&Displayer); - AssertLog->addDisplayer (&Displayer); - - // JC: added LoadBarState - LoadBarState("Georges"); - - return 0; -} - -BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) -{ - if( !CMDIFrameWnd::PreCreateWindow(cs) ) - return FALSE; - - if (createX != -1) - cs.x = createX; - if (createY != -1) - cs.y = createY; - if (createCX != -1) - cs.cx = createCX; - if (createCY != -1) - cs.cy = createCY; - - return TRUE; -} - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame diagnostics - -#ifdef _DEBUG -void CMainFrame::AssertValid() const -{ - CMDIFrameWnd::AssertValid(); -} - -void CMainFrame::Dump(CDumpContext& dc) const -{ - CMDIFrameWnd::Dump(dc); -} - -#endif //_DEBUG - -///////////////////////////////////////////////////////////////////////////// -// CMainFrame message handlers - - - -void CMainFrame::OnSettings() -{ - if (theApp.Superuser) - { - CSettingsDialog dialog (this); - dialog.DoModal (); - theApp.OnViewRefresh (); - } -} - -bool CMainFrame::dataToClipboard (UINT format, void *data, uint len) -{ - // Open the clipboard - if (OpenClipboard ()) - { - if (data) - { - // Alloc a global memory - HGLOBAL hData = GlobalAlloc (GMEM_MOVEABLE|GMEM_DDESHARE, len); - if (hData) - { - // Copy the string - LPVOID dataPtr = GlobalLock (hData); - nlverify (dataPtr); - memcpy (dataPtr, data, len); - - // Release the pointer - GlobalUnlock (hData); - - // Set the clipboard - nlverify (SetClipboardData (format, hData)); - - // Close the clipboard - CloseClipboard (); - - // Ok - return true; - } - } - else - { - // Empty the clipboard - nlverify (EmptyClipboard()); - } - - - // Close the clipboard - CloseClipboard (); - } - return false; -} - -bool CMainFrame::dataFromClipboard (UINT format, void *data) -{ - // Open the clipboard - if (OpenClipboard ()) - { - // Get the clipboard data - HANDLE hData = GetClipboardData (format); - if (hData) - { - DWORD len = GlobalSize (hData); - - // Get the string - LPVOID dataPtr = GlobalLock (hData); - nlverify (dataPtr); - - // Copy the string - memcpy (data, dataPtr, len); - - // Close the clipboard - CloseClipboard (); - - // Ok - return true; - } - - // Close the clipboard - CloseClipboard (); - } - return false; -} - -bool CMainFrame::clipboardSize (UINT format, uint &size) -{ - // Open the clipboard - if (OpenClipboard ()) - { - // Get the clipboard data - HANDLE hData = GetClipboardData (format); - if (hData) - { - size = GlobalSize (hData); - - // Close the clipboard - CloseClipboard (); - - // Ok - return true; - } - else - size = 0; - - // Close the clipboard - CloseClipboard (); - } - return false; -} - -void CMainFrame::OnClose() -{ - if (m_bDontClose) return; - - if (theApp.SaveAllModified()) - { - // JC: added save bar state - SaveBarState("Georges"); - // Save state - theApp.saveState (); - - theApp.CloseAllDocuments (TRUE); - - // Release plugins - theApp.releasePlugins (); - - PostQuitMessage(0); - } -} - -void CMainFrame::OnViewDockingdialogbar() -{ - CMenu *menu = GetMenu(); - if(menu->GetMenuState(ID_VIEW_DOCKINGDIALOGBAR, MF_BYCOMMAND) & MF_CHECKED) - { - ShowControlBar (&FileBrowser, FALSE, FALSE); - } - else - { - ShowControlBar (&FileBrowser, TRUE, FALSE); - } -} - -void CMainFrame::OnUpdateViewDockingdialogbar(CCmdUI* pCmdUI) -{ - if(FileBrowser.IsVisible()) - pCmdUI->SetCheck(TRUE); - else - pCmdUI->SetCheck(FALSE); -} - -void CMainFrame::OnSize(UINT nType, int cx, int cy) -{ - CMDIFrameWnd::OnSize(nType, cx, cy); - - RecalcLayout (); -} - -void CMainFrame::OnViewOutputConsole() -{ - CMenu *menu = GetMenu(); - if(menu->GetMenuState(ID_VIEW_OUTPUT_CONSOLE, MF_BYCOMMAND) & MF_CHECKED) - { - ShowControlBar (&OutputConsole, FALSE, FALSE); - } - else - { - ShowControlBar (&OutputConsole, TRUE, FALSE); - } -} - -void CMainFrame::OnUpdateViewOutputConsole(CCmdUI* pCmdUI) -{ - if(OutputConsole.IsVisible()) - pCmdUI->SetCheck(TRUE); - else - pCmdUI->SetCheck(FALSE); -} - -void CMainFrame::outputConsoleString (const char *message) -{ - OutputConsoleDlg.outputString (message); -} - -void CMainFrame::OnViewGotoFileBrowser() -{ - ShowControlBar (&FileBrowser, TRUE, FALSE); - FileBrowserDlg.SetFocus (); -} - -void CMainFrame::OnViewGotoOutputConsole() -{ - ShowControlBar (&OutputConsole, TRUE, FALSE); - OutputConsoleDlg.SetFocus (); -} - -void CMainFrame::showOutputConsole (bool show) -{ - ShowControlBar (&OutputConsole, show?TRUE:FALSE, FALSE); -} - -BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) -{ - // For each plugins - uint i; - for (i=0; ipretranslateMessage (pMsg)) - return TRUE; - - return CMDIFrameWnd::PreTranslateMessage(pMsg); -} - -void CMainFrame::OnModules0() -{ - theApp.PluginArray[0].Activated ^= true; - theApp.PluginArray[0].PluginInterface->activate (theApp.PluginArray[0].Activated); - CChildFrame *pChild = (CChildFrame*)MDIGetActive (); - if (pChild) - { - CGeorgesEditDoc *doc = (CGeorgesEditDoc *)pChild->GetActiveDocument(); - doc->onActivateView (true); - } -} - -void CMainFrame::OnUpdateModules0(CCmdUI* pCmdUI) -{ - if (theApp.PluginArray.size () > 0) - { - pCmdUI->Enable (); - string name; - theApp.PluginArray[0].PluginInterface->getPluginName (name); - pCmdUI->SetText (name.c_str ()); - pCmdUI->SetCheck (theApp.PluginArray[0].Activated); - } - else - { - pCmdUI->Enable (FALSE); - } -} - -void CMainFrame::OnModules1() -{ - theApp.PluginArray[1].Activated ^= true; - theApp.PluginArray[1].PluginInterface->activate (theApp.PluginArray[1].Activated); - CChildFrame *pChild = (CChildFrame*)MDIGetActive (); - if (pChild) - { - CGeorgesEditDoc *doc = (CGeorgesEditDoc *)pChild->GetActiveDocument(); - doc->onActivateView (true); - } -} - -void CMainFrame::OnUpdateModules1(CCmdUI* pCmdUI) -{ - if (theApp.PluginArray.size () > 1) - { - pCmdUI->Enable (); - string name; - theApp.PluginArray[1].PluginInterface->getPluginName (name); - pCmdUI->SetText (name.c_str ()); - pCmdUI->SetCheck (theApp.PluginArray[1].Activated); - } - else - { - pCmdUI->Enable (FALSE); - } -} - -void CMainFrame::OnModules2() -{ - theApp.PluginArray[2].Activated ^= true; - theApp.PluginArray[2].PluginInterface->activate (theApp.PluginArray[2].Activated); - CChildFrame *pChild = (CChildFrame*)MDIGetActive (); - if (pChild) - { - CGeorgesEditDoc *doc = (CGeorgesEditDoc *)pChild->GetActiveDocument(); - doc->onActivateView (true); - } -} - -void CMainFrame::OnUpdateModules2(CCmdUI* pCmdUI) -{ - if (theApp.PluginArray.size () > 2) - { - pCmdUI->Enable (); - string name; - theApp.PluginArray[2].PluginInterface->getPluginName (name); - pCmdUI->SetText (name.c_str ()); - pCmdUI->SetCheck (theApp.PluginArray[2].Activated); - } - else - { - pCmdUI->Enable (FALSE); - } -} - -void CMainFrame::OnModules3() -{ - theApp.PluginArray[3].Activated ^= true; - theApp.PluginArray[3].PluginInterface->activate (theApp.PluginArray[3].Activated); - CChildFrame *pChild = (CChildFrame*)MDIGetActive (); - if (pChild) - { - CGeorgesEditDoc *doc = (CGeorgesEditDoc *)pChild->GetActiveDocument(); - doc->onActivateView (true); - } -} - -void CMainFrame::OnUpdateModules3(CCmdUI* pCmdUI) -{ - if (theApp.PluginArray.size () > 3) - { - pCmdUI->Enable (); - string name; - theApp.PluginArray[3].PluginInterface->getPluginName (name); - pCmdUI->SetText (name.c_str ()); - pCmdUI->SetCheck (theApp.PluginArray[3].Activated); - } - else - { - pCmdUI->Enable (FALSE); - } -} - -void CMainFrame::OnUpdateViewSettings(CCmdUI* pCmdUI) -{ - pCmdUI->Enable (theApp.Superuser); -} - -void CMainFrame::OnBrowserSortedByType() -{ - BrowserSortedByType ^= true; - FileBrowserDlg.setSortedByType (BrowserSortedByType); -} - -void CMainFrame::OnUpdateBrowserSortedByType(CCmdUI* pCmdUI) -{ - if(BrowserSortedByType) - pCmdUI->SetCheck(TRUE); - else - pCmdUI->SetCheck(FALSE); -} +// 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 "stdafx.h" +#include "georges_edit.h" +#include "georges_edit_view.h" +#include "georges_edit_doc.h" +#include "settings_dialog.h" +#include "child_frm.h" + +#include "main_frm.h" + +#include "nel/misc/debug.h" + +using namespace NLMISC; +using namespace std; + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame + +IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd) + +BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) + //{{AFX_MSG_MAP(CMainFrame) + ON_WM_CREATE() + ON_COMMAND(ID_VIEW_SETTINGS, OnSettings) + ON_WM_CLOSE() + ON_COMMAND(ID_VIEW_DOCKINGDIALOGBAR, OnViewDockingdialogbar) + ON_UPDATE_COMMAND_UI(ID_VIEW_DOCKINGDIALOGBAR, OnUpdateViewDockingdialogbar) + ON_WM_SIZE() + ON_COMMAND(ID_VIEW_OUTPUT_CONSOLE, OnViewOutputConsole) + ON_UPDATE_COMMAND_UI(ID_VIEW_OUTPUT_CONSOLE, OnUpdateViewOutputConsole) + ON_COMMAND(ID_VIEW_GOTO_FILE_BROWSER, OnViewGotoFileBrowser) + ON_COMMAND(ID_VIEW_GOTO_OUTPUT_CONSOLE, OnViewGotoOutputConsole) + ON_COMMAND(ID_MODULES_0, OnModules0) + ON_UPDATE_COMMAND_UI(ID_MODULES_0, OnUpdateModules0) + ON_COMMAND(ID_MODULES_1, OnModules1) + ON_UPDATE_COMMAND_UI(ID_MODULES_1, OnUpdateModules1) + ON_COMMAND(ID_MODULES_2, OnModules2) + ON_UPDATE_COMMAND_UI(ID_MODULES_2, OnUpdateModules2) + ON_COMMAND(ID_MODULES_3, OnModules3) + ON_UPDATE_COMMAND_UI(ID_MODULES_3, OnUpdateModules3) + ON_UPDATE_COMMAND_UI(ID_VIEW_SETTINGS, OnUpdateViewSettings) + ON_COMMAND(ID_BROWSER_SORTED_BY_TYPE, OnBrowserSortedByType) + ON_WM_KEYDOWN() + ON_UPDATE_COMMAND_UI(ID_BROWSER_SORTED_BY_TYPE, OnUpdateBrowserSortedByType) + //}}AFX_MSG_MAP + // Global help commands + ON_COMMAND(ID_HELP_FINDER, CMDIFrameWnd::OnHelpFinder) + ON_COMMAND(ID_HELP, CMDIFrameWnd::OnHelp) + ON_COMMAND(ID_CONTEXT_HELP, CMDIFrameWnd::OnContextHelp) + ON_COMMAND(ID_DEFAULT_HELP, CMDIFrameWnd::OnHelpFinder) +END_MESSAGE_MAP() + +static UINT indicators[] = +{ + ID_SEPARATOR, // status line indicator + ID_INDICATOR_CAPS, + ID_INDICATOR_NUM, + ID_INDICATOR_SCRL, +}; + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame construction/destruction + +CMainFrame::CMainFrame() +{ + // m_bAutoMenuEnable = FALSE; + m_bDontClose = false; + BrowserSortedByType = false; +} + +CMainFrame::~CMainFrame() +{ + ErrorLog->removeDisplayer (&Displayer); + WarningLog->removeDisplayer (&Displayer); + InfoLog->removeDisplayer (&Displayer); + DebugLog->removeDisplayer (&Displayer); + AssertLog->removeDisplayer (&Displayer); +} + +int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) +{ + if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) + return -1; + + if (!m_wndToolBar.Create(this) || + !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) + { + TRACE0("Failed to create toolbar\n"); + return -1; // fail to create + } + + if (!m_wndStatusBar.Create(this) || + !m_wndStatusBar.SetIndicators(indicators, + sizeof(indicators)/sizeof(UINT))) + { + TRACE0("Failed to create status bar\n"); + return -1; // fail to create + } + + // Icon bar + m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | + CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); + + // Dockable + m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); + EnableDocking(CBRS_ALIGN_ANY); + DockControlBar(&m_wndToolBar); + + // Create the file browser + if (!FileBrowser.Create(this, &FileBrowserDlg, CString("File browser"), IDD_FILE_BROWSER)) + { + TRACE0("Failed to create dialogbar\n"); + return -1; // fail to create + } + + // Docking bar + ShowControlBar (&FileBrowser, TRUE, FALSE); + FileBrowser.SetBarStyle (FileBrowser.GetBarStyle()|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_DYNAMIC); + FileBrowser.EnableDocking (CBRS_ALIGN_ANY); + DockControlBar (&FileBrowser); + + // Menu file browser + CMenu *menu = GetMenu(); + menu->CheckMenuItem(ID_VIEW_DOCKINGDIALOGBAR, MF_CHECKED); + + // Create the output console + if (!OutputConsole.Create(this, &OutputConsoleDlg, CString("Output"), IDD_OUTPUT_CONSOLE)) + { + TRACE0("Failed to create dialogbar\n"); + return -1; // fail to create + } + + // Docking bar + ShowControlBar (&OutputConsole, TRUE, FALSE); + OutputConsole.SetBarStyle (OutputConsole.GetBarStyle()|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_SIZE_DYNAMIC); + OutputConsole.EnableDocking (CBRS_ALIGN_ANY); + DockControlBar (&OutputConsole, AFX_IDW_DOCKBAR_BOTTOM); + + // Menu file browser + menu = GetMenu(); + menu->CheckMenuItem(ID_VIEW_OUTPUT_CONSOLE, MF_CHECKED); + + // Init displayer + ErrorLog->addDisplayer (&Displayer); + WarningLog->addDisplayer (&Displayer); + InfoLog->addDisplayer (&Displayer); + DebugLog->addDisplayer (&Displayer); + AssertLog->addDisplayer (&Displayer); + + // JC: added LoadBarState + LoadBarState("Georges"); + + return 0; +} + +BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) +{ + if( !CMDIFrameWnd::PreCreateWindow(cs) ) + return FALSE; + + if (createX != -1) + cs.x = createX; + if (createY != -1) + cs.y = createY; + if (createCX != -1) + cs.cx = createCX; + if (createCY != -1) + cs.cy = createCY; + + return TRUE; +} + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame diagnostics + +#ifdef _DEBUG +void CMainFrame::AssertValid() const +{ + CMDIFrameWnd::AssertValid(); +} + +void CMainFrame::Dump(CDumpContext& dc) const +{ + CMDIFrameWnd::Dump(dc); +} + +#endif //_DEBUG + +///////////////////////////////////////////////////////////////////////////// +// CMainFrame message handlers + + + +void CMainFrame::OnSettings() +{ + if (theApp.Superuser) + { + CSettingsDialog dialog (this); + dialog.DoModal (); + theApp.OnViewRefresh (); + } +} + +bool CMainFrame::dataToClipboard (UINT format, void *data, uint len) +{ + // Open the clipboard + if (OpenClipboard ()) + { + if (data) + { + // Alloc a global memory + HGLOBAL hData = GlobalAlloc (GMEM_MOVEABLE|GMEM_DDESHARE, len); + if (hData) + { + // Copy the string + LPVOID dataPtr = GlobalLock (hData); + nlverify (dataPtr); + memcpy (dataPtr, data, len); + + // Release the pointer + GlobalUnlock (hData); + + // Set the clipboard + nlverify (SetClipboardData (format, hData)); + + // Close the clipboard + CloseClipboard (); + + // Ok + return true; + } + } + else + { + // Empty the clipboard + nlverify (EmptyClipboard()); + } + + + // Close the clipboard + CloseClipboard (); + } + return false; +} + +bool CMainFrame::dataFromClipboard (UINT format, void *data) +{ + // Open the clipboard + if (OpenClipboard ()) + { + // Get the clipboard data + HANDLE hData = GetClipboardData (format); + if (hData) + { + DWORD len = GlobalSize (hData); + + // Get the string + LPVOID dataPtr = GlobalLock (hData); + nlverify (dataPtr); + + // Copy the string + memcpy (data, dataPtr, len); + + // Close the clipboard + CloseClipboard (); + + // Ok + return true; + } + + // Close the clipboard + CloseClipboard (); + } + return false; +} + +bool CMainFrame::clipboardSize (UINT format, uint &size) +{ + // Open the clipboard + if (OpenClipboard ()) + { + // Get the clipboard data + HANDLE hData = GetClipboardData (format); + if (hData) + { + size = GlobalSize (hData); + + // Close the clipboard + CloseClipboard (); + + // Ok + return true; + } + else + size = 0; + + // Close the clipboard + CloseClipboard (); + } + return false; +} + +void CMainFrame::OnClose() +{ + if (m_bDontClose) return; + + if (theApp.SaveAllModified()) + { + // JC: added save bar state + SaveBarState("Georges"); + // Save state + theApp.saveState (); + + theApp.CloseAllDocuments (TRUE); + + // Release plugins + theApp.releasePlugins (); + + PostQuitMessage(0); + } +} + +void CMainFrame::OnViewDockingdialogbar() +{ + CMenu *menu = GetMenu(); + if(menu->GetMenuState(ID_VIEW_DOCKINGDIALOGBAR, MF_BYCOMMAND) & MF_CHECKED) + { + ShowControlBar (&FileBrowser, FALSE, FALSE); + } + else + { + ShowControlBar (&FileBrowser, TRUE, FALSE); + } +} + +void CMainFrame::OnUpdateViewDockingdialogbar(CCmdUI* pCmdUI) +{ + if(FileBrowser.IsVisible()) + pCmdUI->SetCheck(TRUE); + else + pCmdUI->SetCheck(FALSE); +} + +void CMainFrame::OnSize(UINT nType, int cx, int cy) +{ + CMDIFrameWnd::OnSize(nType, cx, cy); + + RecalcLayout (); +} + +void CMainFrame::OnViewOutputConsole() +{ + CMenu *menu = GetMenu(); + if(menu->GetMenuState(ID_VIEW_OUTPUT_CONSOLE, MF_BYCOMMAND) & MF_CHECKED) + { + ShowControlBar (&OutputConsole, FALSE, FALSE); + } + else + { + ShowControlBar (&OutputConsole, TRUE, FALSE); + } +} + +void CMainFrame::OnUpdateViewOutputConsole(CCmdUI* pCmdUI) +{ + if(OutputConsole.IsVisible()) + pCmdUI->SetCheck(TRUE); + else + pCmdUI->SetCheck(FALSE); +} + +void CMainFrame::outputConsoleString (const char *message) +{ + OutputConsoleDlg.outputString (message); +} + +void CMainFrame::OnViewGotoFileBrowser() +{ + ShowControlBar (&FileBrowser, TRUE, FALSE); + FileBrowserDlg.SetFocus (); +} + +void CMainFrame::OnViewGotoOutputConsole() +{ + ShowControlBar (&OutputConsole, TRUE, FALSE); + OutputConsoleDlg.SetFocus (); +} + +void CMainFrame::showOutputConsole (bool show) +{ + ShowControlBar (&OutputConsole, show?TRUE:FALSE, FALSE); +} + +BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) +{ + // For each plugins + uint i; + for (i=0; ipretranslateMessage (pMsg)) + return TRUE; + + return CMDIFrameWnd::PreTranslateMessage(pMsg); +} + +void CMainFrame::OnModules0() +{ + theApp.PluginArray[0].Activated ^= true; + theApp.PluginArray[0].PluginInterface->activate (theApp.PluginArray[0].Activated); + CChildFrame *pChild = (CChildFrame*)MDIGetActive (); + if (pChild) + { + CGeorgesEditDoc *doc = (CGeorgesEditDoc *)pChild->GetActiveDocument(); + doc->onActivateView (true); + } +} + +void CMainFrame::OnUpdateModules0(CCmdUI* pCmdUI) +{ + if (theApp.PluginArray.size () > 0) + { + pCmdUI->Enable (); + string name; + theApp.PluginArray[0].PluginInterface->getPluginName (name); + pCmdUI->SetText (name.c_str ()); + pCmdUI->SetCheck (theApp.PluginArray[0].Activated); + } + else + { + pCmdUI->Enable (FALSE); + } +} + +void CMainFrame::OnModules1() +{ + theApp.PluginArray[1].Activated ^= true; + theApp.PluginArray[1].PluginInterface->activate (theApp.PluginArray[1].Activated); + CChildFrame *pChild = (CChildFrame*)MDIGetActive (); + if (pChild) + { + CGeorgesEditDoc *doc = (CGeorgesEditDoc *)pChild->GetActiveDocument(); + doc->onActivateView (true); + } +} + +void CMainFrame::OnUpdateModules1(CCmdUI* pCmdUI) +{ + if (theApp.PluginArray.size () > 1) + { + pCmdUI->Enable (); + string name; + theApp.PluginArray[1].PluginInterface->getPluginName (name); + pCmdUI->SetText (name.c_str ()); + pCmdUI->SetCheck (theApp.PluginArray[1].Activated); + } + else + { + pCmdUI->Enable (FALSE); + } +} + +void CMainFrame::OnModules2() +{ + theApp.PluginArray[2].Activated ^= true; + theApp.PluginArray[2].PluginInterface->activate (theApp.PluginArray[2].Activated); + CChildFrame *pChild = (CChildFrame*)MDIGetActive (); + if (pChild) + { + CGeorgesEditDoc *doc = (CGeorgesEditDoc *)pChild->GetActiveDocument(); + doc->onActivateView (true); + } +} + +void CMainFrame::OnUpdateModules2(CCmdUI* pCmdUI) +{ + if (theApp.PluginArray.size () > 2) + { + pCmdUI->Enable (); + string name; + theApp.PluginArray[2].PluginInterface->getPluginName (name); + pCmdUI->SetText (name.c_str ()); + pCmdUI->SetCheck (theApp.PluginArray[2].Activated); + } + else + { + pCmdUI->Enable (FALSE); + } +} + +void CMainFrame::OnModules3() +{ + theApp.PluginArray[3].Activated ^= true; + theApp.PluginArray[3].PluginInterface->activate (theApp.PluginArray[3].Activated); + CChildFrame *pChild = (CChildFrame*)MDIGetActive (); + if (pChild) + { + CGeorgesEditDoc *doc = (CGeorgesEditDoc *)pChild->GetActiveDocument(); + doc->onActivateView (true); + } +} + +void CMainFrame::OnUpdateModules3(CCmdUI* pCmdUI) +{ + if (theApp.PluginArray.size () > 3) + { + pCmdUI->Enable (); + string name; + theApp.PluginArray[3].PluginInterface->getPluginName (name); + pCmdUI->SetText (name.c_str ()); + pCmdUI->SetCheck (theApp.PluginArray[3].Activated); + } + else + { + pCmdUI->Enable (FALSE); + } +} + +void CMainFrame::OnUpdateViewSettings(CCmdUI* pCmdUI) +{ + pCmdUI->Enable (theApp.Superuser); +} + +void CMainFrame::OnBrowserSortedByType() +{ + BrowserSortedByType ^= true; + FileBrowserDlg.setSortedByType (BrowserSortedByType); +} + +void CMainFrame::OnUpdateBrowserSortedByType(CCmdUI* pCmdUI) +{ + if(BrowserSortedByType) + pCmdUI->SetCheck(TRUE); + else + pCmdUI->SetCheck(FALSE); +} diff --git a/code/ryzom/tools/leveldesign/georges_dll/main_frm.h b/code/ryzom/tools/leveldesign/georges_dll/main_frm.h index d6da7b03d..73c04c936 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/main_frm.h +++ b/code/ryzom/tools/leveldesign/georges_dll/main_frm.h @@ -1,114 +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 . - -#if !defined(AFX_MAINFRM_H__EF1B6999_B132_462C_A105_98AFE714DB42__INCLUDED_) -#define AFX_MAINFRM_H__EF1B6999_B132_462C_A105_98AFE714DB42__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include "cool_dialog_bar.h" -#include "file_browser_dialog.h" -#include "output_console_dlg.h" -#include "displayer.h" - -class CMainFrame : public CMDIFrameWnd -{ - DECLARE_DYNAMIC(CMainFrame) -public: - CMainFrame(); - -// Attributes -public: - -// Operations -public: - bool dataToClipboard (UINT format, void *data, uint len); - bool dataFromClipboard (UINT format, void *data); - bool clipboardSize (UINT format, uint &size); - - sint createX, createY, createCX, createCY; - - void outputConsoleString (const char *message); - - void showOutputConsole (bool show = true); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CMainFrame) - public: - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); - virtual BOOL PreTranslateMessage(MSG* pMsg); - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CMainFrame(); -#ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; -#endif - -public: - // control bar embedded members - CStatusBar m_wndStatusBar; - CToolBar m_wndToolBar; - CReBar m_wndReBar; - CDialogBar m_wndDlgBar; - CCoolDialogBar FileBrowser; - CFileBrowserDialog FileBrowserDlg; - CCoolDialogBar OutputConsole; - COutputConsoleDlg OutputConsoleDlg; - CGeorgesDisplayer Displayer; -public: - bool m_bDontClose; - bool BrowserSortedByType; - -// Generated message map functions -protected: - //{{AFX_MSG(CMainFrame) - afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnSettings(); - afx_msg void OnClose(); - afx_msg void OnViewDockingdialogbar(); - afx_msg void OnUpdateViewDockingdialogbar(CCmdUI* pCmdUI); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnViewOutputConsole(); - afx_msg void OnUpdateViewOutputConsole(CCmdUI* pCmdUI); - afx_msg void OnViewGotoFileBrowser(); - afx_msg void OnViewGotoOutputConsole(); - afx_msg void OnModules0(); - afx_msg void OnUpdateModules0(CCmdUI* pCmdUI); - afx_msg void OnModules1(); - afx_msg void OnUpdateModules1(CCmdUI* pCmdUI); - afx_msg void OnModules2(); - afx_msg void OnUpdateModules2(CCmdUI* pCmdUI); - afx_msg void OnModules3(); - afx_msg void OnUpdateModules3(CCmdUI* pCmdUI); - afx_msg void OnUpdateViewSettings(CCmdUI* pCmdUI); - afx_msg void OnBrowserSortedByType(); - afx_msg void OnUpdateBrowserSortedByType(CCmdUI* pCmdUI); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_MAINFRM_H__EF1B6999_B132_462C_A105_98AFE714DB42__INCLUDED_) +// 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 . + +#if !defined(AFX_MAINFRM_H__EF1B6999_B132_462C_A105_98AFE714DB42__INCLUDED_) +#define AFX_MAINFRM_H__EF1B6999_B132_462C_A105_98AFE714DB42__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "cool_dialog_bar.h" +#include "file_browser_dialog.h" +#include "output_console_dlg.h" +#include "displayer.h" + +class CMainFrame : public CMDIFrameWnd +{ + DECLARE_DYNAMIC(CMainFrame) +public: + CMainFrame(); + +// Attributes +public: + +// Operations +public: + bool dataToClipboard (UINT format, void *data, uint len); + bool dataFromClipboard (UINT format, void *data); + bool clipboardSize (UINT format, uint &size); + + sint createX, createY, createCX, createCY; + + void outputConsoleString (const char *message); + + void showOutputConsole (bool show = true); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CMainFrame) + public: + virtual BOOL PreCreateWindow(CREATESTRUCT& cs); + virtual BOOL PreTranslateMessage(MSG* pMsg); + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CMainFrame(); +#ifdef _DEBUG + virtual void AssertValid() const; + virtual void Dump(CDumpContext& dc) const; +#endif + +public: + // control bar embedded members + CStatusBar m_wndStatusBar; + CToolBar m_wndToolBar; + CReBar m_wndReBar; + CDialogBar m_wndDlgBar; + CCoolDialogBar FileBrowser; + CFileBrowserDialog FileBrowserDlg; + CCoolDialogBar OutputConsole; + COutputConsoleDlg OutputConsoleDlg; + CGeorgesDisplayer Displayer; +public: + bool m_bDontClose; + bool BrowserSortedByType; + +// Generated message map functions +protected: + //{{AFX_MSG(CMainFrame) + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnSettings(); + afx_msg void OnClose(); + afx_msg void OnViewDockingdialogbar(); + afx_msg void OnUpdateViewDockingdialogbar(CCmdUI* pCmdUI); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnViewOutputConsole(); + afx_msg void OnUpdateViewOutputConsole(CCmdUI* pCmdUI); + afx_msg void OnViewGotoFileBrowser(); + afx_msg void OnViewGotoOutputConsole(); + afx_msg void OnModules0(); + afx_msg void OnUpdateModules0(CCmdUI* pCmdUI); + afx_msg void OnModules1(); + afx_msg void OnUpdateModules1(CCmdUI* pCmdUI); + afx_msg void OnModules2(); + afx_msg void OnUpdateModules2(CCmdUI* pCmdUI); + afx_msg void OnModules3(); + afx_msg void OnUpdateModules3(CCmdUI* pCmdUI); + afx_msg void OnUpdateViewSettings(CCmdUI* pCmdUI); + afx_msg void OnBrowserSortedByType(); + afx_msg void OnUpdateBrowserSortedByType(CCmdUI* pCmdUI); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_MAINFRM_H__EF1B6999_B132_462C_A105_98AFE714DB42__INCLUDED_) diff --git a/code/ryzom/tools/leveldesign/georges_dll/memory_combo_box.cpp b/code/ryzom/tools/leveldesign/georges_dll/memory_combo_box.cpp index 59137c66b..949c084d6 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/memory_combo_box.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/memory_combo_box.cpp @@ -1,726 +1,726 @@ -// 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 . - -// memory_combo_box.cpp : implementation file -// - -#include "stdafx.h" -#include "memory_combo_box.h" - -using namespace std; -using namespace NLMISC; - -// *************************************************************************** -// CMemoryComboBox -// *************************************************************************** - -CMemoryComboBox::CMemoryComboBox() -{ - _EditChanged = false; - _ComboOpen = false; - _ComboCurSel = -1; - _AutoCompleteExtension = false; -} - -// *************************************************************************** - -CMemoryComboBox::~CMemoryComboBox() -{ -} - -// *************************************************************************** - -void CMemoryComboBox::create (DWORD style, const RECT &rect, CWnd *parent, UINT nId, const char *registerAdress, int memoryCount) -{ - // Register a window - Id = nId; - RegisterAdress = registerAdress; - MemoryCount = memoryCount; - LPCTSTR clas = AfxRegisterWndClass (0); - if (clas) - { - if (Create (clas, "MemoryComboBox", style, rect, parent, nId)) - { - // Create the combo box - RECT comboRect; - comboRect.left = 0; - comboRect.top = 0; - comboRect.right = rect.right-rect.left; - comboRect.bottom = 200; //rect.bottom-rect.top; - _ComboBox.Create (WS_CHILD|WS_VSCROLL|WS_VISIBLE|CBS_DROPDOWN|CBS_HASSTRINGS|CBS_AUTOHSCROLL, comboRect, this, 0); - } - } -} - -// *************************************************************************** - -BEGIN_MESSAGE_MAP(CMemoryComboBox, CWnd) - //{{AFX_MSG_MAP(CMemoryComboBox) - ON_WM_SIZE() - ON_WM_SETFOCUS() - ON_WM_ENABLE() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -// *************************************************************************** - -void CMemoryComboBox::OnSize(UINT nType, int cx, int cy) -{ - CWnd::OnSize(nType, cx, cy); - - if (IsWindow (_ComboBox)) - { - uint pos = _ComboBox.GetEditSel (); - _ComboBox.SetWindowPos (NULL, 0, 0, cx, 200, SWP_NOZORDER); - _ComboBox.SetEditSel (pos&0xffff, pos>>16); - } -} - -// *************************************************************************** - -bool CMemoryComboBox::getMemory (int slot, std::string &ret) -{ - // Open the key - HKEY hKey; - if (RegOpenKey (HKEY_CURRENT_USER, RegisterAdress.c_str (), &hKey) == ERROR_SUCCESS) - { - // Get the value - char strSrc[512]; - smprintf (strSrc, 512, "%d", slot); - char str[512]; - long size = 512; - if (RegQueryValue (hKey, strSrc, str, &size) == ERROR_SUCCESS) - { - ret = str; - - // Close - RegCloseKey (hKey); - - return true; - } - - // Close - RegCloseKey (hKey); - } - return false; -} - -// *************************************************************************** - -void CMemoryComboBox::scrollDown (int start, int end) -{ - // Open the key - HKEY hKey; - if (RegCreateKey (HKEY_CURRENT_USER, RegisterAdress.c_str (), &hKey) == ERROR_SUCCESS) - { - // Scroll down the list - for (int i=end-1; i>start; i--) - { - // Get the old value - char strSrc[512]; - smprintf (strSrc, 512, "%d", i-1); - char str[512]; - long size = 512; - if (RegQueryValue (hKey, strSrc, str, &size) == ERROR_SUCCESS) - { - // Set the value - char strDst[512]; - smprintf (strDst, 512, "%d", i); - RegSetValue (hKey, strDst, REG_SZ, str, size); - } - } - - // Close - RegCloseKey (hKey); - } -} - -// *************************************************************************** - -void CMemoryComboBox::pushString (const std::string &str) -{ - // Open the key - HKEY hKey; - if (RegCreateKey (HKEY_CURRENT_USER, RegisterAdress.c_str (), &hKey) == ERROR_SUCCESS) - { - // Set the value - RegSetValue (hKey, "0", REG_SZ, str.c_str (), str.size ()); - - // Close - RegCloseKey (hKey); - } -} - -// *************************************************************************** - -BOOL CMemoryComboBox::OnCommand(WPARAM wParam, LPARAM lParam) -{ - // Branch the message - switch (HIWORD(wParam)) - { - case CBN_CLOSEUP: - { - // Closed - _ComboOpen = false; - if (_ComboCurSel != _ComboBox.GetCurSel ()) - { - notifyParent (); - } - - CString str; - _ComboBox.GetWindowText (str); - // nlinfo ("CBN_CLOSEUP: %s", str); - - if ((uint)_ComboBox.GetCurSel () < Commands.size()) - { - GetParent ()->SendMessage (MC_COMMAND, Commands[_ComboBox.GetCurSel ()].Id, Id); - } - } - break; - case CBN_SELCHANGE: - { - CString str; - _ComboBox.GetWindowText (str); - // nlinfo ("CBN_SELCHANGE: %s", str); - GetParent()->PostMessage (CBN_CHANGED, 0, 0); - - // Edit not changed since select a string - _EditChanged = false; - - // Open ? - if (!_ComboOpen) - { - // Notify parent for string change - notifyParent (); - } - } - break; - case CBN_DBLCLK: - { - CString str; - _ComboBox.GetWindowText (str); - // nlinfo ("CBN_DBLCLK: %s", str); - - if ((uint)_ComboBox.GetCurSel () < Commands.size()) - { - break; - } - } - break; - case CBN_EDITCHANGE: - { - _EditChanged = true; - CString str; - _ComboBox.GetWindowText (str); - // nlinfo ("CBN_EDITCHANGE: %s", str); - GetParent()->PostMessage (CBN_CHANGED, 0, 0); - - if ((uint)_ComboBox.GetCurSel () < Commands.size()) - { - break; - } - }; - break; - case CBN_EDITUPDATE: - { - CString str; - _ComboBox.GetWindowText (str); - // nlinfo ("CBN_EDITUPDATE: %s", str); - - if ((uint)_ComboBox.GetCurSel () < Commands.size()) - { - break; - } - }; - break; - case CBN_DROPDOWN: - { - // Edit change ? - if (_EditChanged) - { - notifyParent (); - } - - // Closed - _ComboOpen = true; - - // Get current text - CString strText; - _ComboBox.GetWindowText (strText); - - // Look for the string in the combo - uint i; - uint count = _ComboBox.GetCount (); - _ComboCurSel = -1; - for (i=0; iSendMessage (WM_NOTIFY, Id, (LPARAM)&strNotify); - } - break; - case CBN_SELENDCANCEL: - { - CString str; - _ComboBox.GetWindowText (str); - // nlinfo ("CBN_SELENDCANCEL: %s", str); - - if ((uint)_ComboBox.GetCurSel () < Commands.size()) - { - } - } - break; - case CBN_SELENDOK: - { - CString str; - _ComboBox.GetWindowText (str); - // nlinfo ("CBN_SELENDOK: %s", str); - - if ((uint)_ComboBox.GetCurSel () < Commands.size()) - { - break; - } - } - break; - case CBN_SETFOCUS: - { - _EditChanged = false; - CString str; - _ComboBox.GetWindowText (str); - refreshStrings (); - _ComboBox.SetWindowText (str); - // nlinfo ("CBN_SETFOCUS: %s", str); - - if ((uint)_ComboBox.GetCurSel () < Commands.size()) - { - break; - } - - // Send the notify message to the parent - NMHDR strNotify; - strNotify.hwndFrom = *this; - strNotify.idFrom = Id; - strNotify.code = NM_SETFOCUS; - GetParent ()->SendMessage (WM_NOTIFY, Id, (LPARAM)&strNotify); - } - break; - } - - return CWnd::OnCommand(wParam, lParam); -} - -// *************************************************************************** - -void CMemoryComboBox::pushString () -{ - CString str; - GetWindowText (str); - if (str != "") - { - // Look for an existing static - uint i; - for (i=0; i0) - { - _ComboBox.GetLBText( i, value); - if (value == (const char*)str) - break; - } - } - - // Something change ? - if (i == (int)(itemCount+Commands.size()+ StaticStrings.size())) - { - // Insert the sting - _ComboBox.InsertString (Commands.size()+ StaticStrings.size(), str); - } - } - } -} - -// *************************************************************************** - -void CMemoryComboBox::refreshStrings () -{ - _ComboBox.ResetContent (); - - uint i; - for (i=0; iSendMessage (WM_COMMAND, wParam, 0); -} - -// *************************************************************************** - -void CMemoryComboBox::onCancel () -{ - _ComboBox.SetEditSel (0, -1); - - // Send the message to the parent - DWORD wParam = (CBN_SELENDCANCEL<<16) + Id; - GetParent ()->SendMessage (WM_COMMAND, wParam, 0); -} - -// *************************************************************************** - -void CMemoryComboBox::clearStaticStrings () -{ - StaticStrings.clear (); -} - -// *************************************************************************** - -void CMemoryComboBox::addStaticStrings (const char* strings) -{ - StaticStrings.push_back (strings); -} - -// *************************************************************************** - -LRESULT CMemoryComboBox::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) -{ - // Get window text - switch (message) - { - case WM_GETTEXTLENGTH: - { - int curSel = _ComboBox.GetCurSel (); - if ((curSel == -1) || ((uint)curSelGetParent () : NULL; - return focus && - ( (focus->m_hWnd == this->m_hWnd) || (focus->m_hWnd == _ComboBox.m_hWnd ) || - ( parent && (parent->m_hWnd == this->m_hWnd) || (parent->m_hWnd == _ComboBox.m_hWnd ) ) ); -} - -// *************************************************************************** - -bool CMemoryComboBox::isWnd (const CWnd *wnd) const -{ - if (wnd) - { - return (this == wnd) || (&_ComboBox == wnd) || (&_ComboBox == (const CWnd*)wnd->GetParent ()); - } - return false; -} - -// *************************************************************************** - -void CMemoryComboBox::notifyParent () -{ - // nlinfo ("notify parent"); - - // Push the string - pushString (); - - // Edit not changed - _EditChanged = false; - - // Notify parent - CWnd *parent = GetParent (); - if (parent) - { - parent->SendMessage (MC_STRINGCHANGE, Id, 0); - } -} - -// *************************************************************************** - -BOOL CMemoryComboBox::PreTranslateMessage(MSG* pMsg) -{ - switch (pMsg->message) - { - case WM_KEYDOWN: - { - if (pMsg->wParam==VK_ESCAPE) - { - CWnd *parent = GetParent (); - if (parent) - { - parent->SendMessage (MC_ESCAPE, Id, 0); - } - } - if (pMsg->wParam==VK_RETURN) - { - if (!_ComboBox.GetDroppedState ()) - { - // Auto compelete ? - if (_AutoCompleteExtension) - { - CString str; - _ComboBox.GetWindowText (str); - string str2 = str; - if ((!str2.empty ()) && (str2.find ('.') == string::npos)) - { - str2 += "." + _Extension; - _ComboBox.SetWindowText (str2.c_str ()); - } - } - - // Select the text - _ComboBox.SetEditSel (0, -1); - - // Notify parent change - notifyParent (); - return TRUE; - } - } - } - break; - } - - return CWnd::PreTranslateMessage(pMsg); -} - -// *************************************************************************** - -void CMemoryComboBox::OnEnable(BOOL bEnable) -{ - CWnd::OnEnable(bEnable); - - _ComboBox.EnableWindow (bEnable); -} - -// *************************************************************************** - -void CMemoryComboBox::enableAutoCompleteExtension (bool enable, const char * ext) -{ - _AutoCompleteExtension = enable; - const char *point = ext; - while ((*point == '.') || (*point == '*')) - point++; - _Extension = point; -} - -// *************************************************************************** - - +// 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 . + +// memory_combo_box.cpp : implementation file +// + +#include "stdafx.h" +#include "memory_combo_box.h" + +using namespace std; +using namespace NLMISC; + +// *************************************************************************** +// CMemoryComboBox +// *************************************************************************** + +CMemoryComboBox::CMemoryComboBox() +{ + _EditChanged = false; + _ComboOpen = false; + _ComboCurSel = -1; + _AutoCompleteExtension = false; +} + +// *************************************************************************** + +CMemoryComboBox::~CMemoryComboBox() +{ +} + +// *************************************************************************** + +void CMemoryComboBox::create (DWORD style, const RECT &rect, CWnd *parent, UINT nId, const char *registerAdress, int memoryCount) +{ + // Register a window + Id = nId; + RegisterAdress = registerAdress; + MemoryCount = memoryCount; + LPCTSTR clas = AfxRegisterWndClass (0); + if (clas) + { + if (Create (clas, "MemoryComboBox", style, rect, parent, nId)) + { + // Create the combo box + RECT comboRect; + comboRect.left = 0; + comboRect.top = 0; + comboRect.right = rect.right-rect.left; + comboRect.bottom = 200; //rect.bottom-rect.top; + _ComboBox.Create (WS_CHILD|WS_VSCROLL|WS_VISIBLE|CBS_DROPDOWN|CBS_HASSTRINGS|CBS_AUTOHSCROLL, comboRect, this, 0); + } + } +} + +// *************************************************************************** + +BEGIN_MESSAGE_MAP(CMemoryComboBox, CWnd) + //{{AFX_MSG_MAP(CMemoryComboBox) + ON_WM_SIZE() + ON_WM_SETFOCUS() + ON_WM_ENABLE() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +// *************************************************************************** + +void CMemoryComboBox::OnSize(UINT nType, int cx, int cy) +{ + CWnd::OnSize(nType, cx, cy); + + if (IsWindow (_ComboBox)) + { + uint pos = _ComboBox.GetEditSel (); + _ComboBox.SetWindowPos (NULL, 0, 0, cx, 200, SWP_NOZORDER); + _ComboBox.SetEditSel (pos&0xffff, pos>>16); + } +} + +// *************************************************************************** + +bool CMemoryComboBox::getMemory (int slot, std::string &ret) +{ + // Open the key + HKEY hKey; + if (RegOpenKey (HKEY_CURRENT_USER, RegisterAdress.c_str (), &hKey) == ERROR_SUCCESS) + { + // Get the value + char strSrc[512]; + smprintf (strSrc, 512, "%d", slot); + char str[512]; + long size = 512; + if (RegQueryValue (hKey, strSrc, str, &size) == ERROR_SUCCESS) + { + ret = str; + + // Close + RegCloseKey (hKey); + + return true; + } + + // Close + RegCloseKey (hKey); + } + return false; +} + +// *************************************************************************** + +void CMemoryComboBox::scrollDown (int start, int end) +{ + // Open the key + HKEY hKey; + if (RegCreateKey (HKEY_CURRENT_USER, RegisterAdress.c_str (), &hKey) == ERROR_SUCCESS) + { + // Scroll down the list + for (int i=end-1; i>start; i--) + { + // Get the old value + char strSrc[512]; + smprintf (strSrc, 512, "%d", i-1); + char str[512]; + long size = 512; + if (RegQueryValue (hKey, strSrc, str, &size) == ERROR_SUCCESS) + { + // Set the value + char strDst[512]; + smprintf (strDst, 512, "%d", i); + RegSetValue (hKey, strDst, REG_SZ, str, size); + } + } + + // Close + RegCloseKey (hKey); + } +} + +// *************************************************************************** + +void CMemoryComboBox::pushString (const std::string &str) +{ + // Open the key + HKEY hKey; + if (RegCreateKey (HKEY_CURRENT_USER, RegisterAdress.c_str (), &hKey) == ERROR_SUCCESS) + { + // Set the value + RegSetValue (hKey, "0", REG_SZ, str.c_str (), str.size ()); + + // Close + RegCloseKey (hKey); + } +} + +// *************************************************************************** + +BOOL CMemoryComboBox::OnCommand(WPARAM wParam, LPARAM lParam) +{ + // Branch the message + switch (HIWORD(wParam)) + { + case CBN_CLOSEUP: + { + // Closed + _ComboOpen = false; + if (_ComboCurSel != _ComboBox.GetCurSel ()) + { + notifyParent (); + } + + CString str; + _ComboBox.GetWindowText (str); + // nlinfo ("CBN_CLOSEUP: %s", str); + + if ((uint)_ComboBox.GetCurSel () < Commands.size()) + { + GetParent ()->SendMessage (MC_COMMAND, Commands[_ComboBox.GetCurSel ()].Id, Id); + } + } + break; + case CBN_SELCHANGE: + { + CString str; + _ComboBox.GetWindowText (str); + // nlinfo ("CBN_SELCHANGE: %s", str); + GetParent()->PostMessage (CBN_CHANGED, 0, 0); + + // Edit not changed since select a string + _EditChanged = false; + + // Open ? + if (!_ComboOpen) + { + // Notify parent for string change + notifyParent (); + } + } + break; + case CBN_DBLCLK: + { + CString str; + _ComboBox.GetWindowText (str); + // nlinfo ("CBN_DBLCLK: %s", str); + + if ((uint)_ComboBox.GetCurSel () < Commands.size()) + { + break; + } + } + break; + case CBN_EDITCHANGE: + { + _EditChanged = true; + CString str; + _ComboBox.GetWindowText (str); + // nlinfo ("CBN_EDITCHANGE: %s", str); + GetParent()->PostMessage (CBN_CHANGED, 0, 0); + + if ((uint)_ComboBox.GetCurSel () < Commands.size()) + { + break; + } + }; + break; + case CBN_EDITUPDATE: + { + CString str; + _ComboBox.GetWindowText (str); + // nlinfo ("CBN_EDITUPDATE: %s", str); + + if ((uint)_ComboBox.GetCurSel () < Commands.size()) + { + break; + } + }; + break; + case CBN_DROPDOWN: + { + // Edit change ? + if (_EditChanged) + { + notifyParent (); + } + + // Closed + _ComboOpen = true; + + // Get current text + CString strText; + _ComboBox.GetWindowText (strText); + + // Look for the string in the combo + uint i; + uint count = _ComboBox.GetCount (); + _ComboCurSel = -1; + for (i=0; iSendMessage (WM_NOTIFY, Id, (LPARAM)&strNotify); + } + break; + case CBN_SELENDCANCEL: + { + CString str; + _ComboBox.GetWindowText (str); + // nlinfo ("CBN_SELENDCANCEL: %s", str); + + if ((uint)_ComboBox.GetCurSel () < Commands.size()) + { + } + } + break; + case CBN_SELENDOK: + { + CString str; + _ComboBox.GetWindowText (str); + // nlinfo ("CBN_SELENDOK: %s", str); + + if ((uint)_ComboBox.GetCurSel () < Commands.size()) + { + break; + } + } + break; + case CBN_SETFOCUS: + { + _EditChanged = false; + CString str; + _ComboBox.GetWindowText (str); + refreshStrings (); + _ComboBox.SetWindowText (str); + // nlinfo ("CBN_SETFOCUS: %s", str); + + if ((uint)_ComboBox.GetCurSel () < Commands.size()) + { + break; + } + + // Send the notify message to the parent + NMHDR strNotify; + strNotify.hwndFrom = *this; + strNotify.idFrom = Id; + strNotify.code = NM_SETFOCUS; + GetParent ()->SendMessage (WM_NOTIFY, Id, (LPARAM)&strNotify); + } + break; + } + + return CWnd::OnCommand(wParam, lParam); +} + +// *************************************************************************** + +void CMemoryComboBox::pushString () +{ + CString str; + GetWindowText (str); + if (str != "") + { + // Look for an existing static + uint i; + for (i=0; i0) + { + _ComboBox.GetLBText( i, value); + if (value == (const char*)str) + break; + } + } + + // Something change ? + if (i == (int)(itemCount+Commands.size()+ StaticStrings.size())) + { + // Insert the sting + _ComboBox.InsertString (Commands.size()+ StaticStrings.size(), str); + } + } + } +} + +// *************************************************************************** + +void CMemoryComboBox::refreshStrings () +{ + _ComboBox.ResetContent (); + + uint i; + for (i=0; iSendMessage (WM_COMMAND, wParam, 0); +} + +// *************************************************************************** + +void CMemoryComboBox::onCancel () +{ + _ComboBox.SetEditSel (0, -1); + + // Send the message to the parent + DWORD wParam = (CBN_SELENDCANCEL<<16) + Id; + GetParent ()->SendMessage (WM_COMMAND, wParam, 0); +} + +// *************************************************************************** + +void CMemoryComboBox::clearStaticStrings () +{ + StaticStrings.clear (); +} + +// *************************************************************************** + +void CMemoryComboBox::addStaticStrings (const char* strings) +{ + StaticStrings.push_back (strings); +} + +// *************************************************************************** + +LRESULT CMemoryComboBox::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) +{ + // Get window text + switch (message) + { + case WM_GETTEXTLENGTH: + { + int curSel = _ComboBox.GetCurSel (); + if ((curSel == -1) || ((uint)curSelGetParent () : NULL; + return focus && + ( (focus->m_hWnd == this->m_hWnd) || (focus->m_hWnd == _ComboBox.m_hWnd ) || + ( parent && (parent->m_hWnd == this->m_hWnd) || (parent->m_hWnd == _ComboBox.m_hWnd ) ) ); +} + +// *************************************************************************** + +bool CMemoryComboBox::isWnd (const CWnd *wnd) const +{ + if (wnd) + { + return (this == wnd) || (&_ComboBox == wnd) || (&_ComboBox == (const CWnd*)wnd->GetParent ()); + } + return false; +} + +// *************************************************************************** + +void CMemoryComboBox::notifyParent () +{ + // nlinfo ("notify parent"); + + // Push the string + pushString (); + + // Edit not changed + _EditChanged = false; + + // Notify parent + CWnd *parent = GetParent (); + if (parent) + { + parent->SendMessage (MC_STRINGCHANGE, Id, 0); + } +} + +// *************************************************************************** + +BOOL CMemoryComboBox::PreTranslateMessage(MSG* pMsg) +{ + switch (pMsg->message) + { + case WM_KEYDOWN: + { + if (pMsg->wParam==VK_ESCAPE) + { + CWnd *parent = GetParent (); + if (parent) + { + parent->SendMessage (MC_ESCAPE, Id, 0); + } + } + if (pMsg->wParam==VK_RETURN) + { + if (!_ComboBox.GetDroppedState ()) + { + // Auto compelete ? + if (_AutoCompleteExtension) + { + CString str; + _ComboBox.GetWindowText (str); + string str2 = str; + if ((!str2.empty ()) && (str2.find ('.') == string::npos)) + { + str2 += "." + _Extension; + _ComboBox.SetWindowText (str2.c_str ()); + } + } + + // Select the text + _ComboBox.SetEditSel (0, -1); + + // Notify parent change + notifyParent (); + return TRUE; + } + } + } + break; + } + + return CWnd::PreTranslateMessage(pMsg); +} + +// *************************************************************************** + +void CMemoryComboBox::OnEnable(BOOL bEnable) +{ + CWnd::OnEnable(bEnable); + + _ComboBox.EnableWindow (bEnable); +} + +// *************************************************************************** + +void CMemoryComboBox::enableAutoCompleteExtension (bool enable, const char * ext) +{ + _AutoCompleteExtension = enable; + const char *point = ext; + while ((*point == '.') || (*point == '*')) + point++; + _Extension = point; +} + +// *************************************************************************** + + diff --git a/code/ryzom/tools/leveldesign/georges_dll/memory_combo_box.h b/code/ryzom/tools/leveldesign/georges_dll/memory_combo_box.h index 0adc8ea22..be999d252 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/memory_combo_box.h +++ b/code/ryzom/tools/leveldesign/georges_dll/memory_combo_box.h @@ -1,142 +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 . - -#if !defined(AFX_MEMORY_COMBO_BOX_H__A0A59637_63E4_40A6_AA7D_B57B4707ABF2__INCLUDED_) -#define AFX_MEMORY_COMBO_BOX_H__A0A59637_63E4_40A6_AA7D_B57B4707ABF2__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// memory_combo_box.h : header file -// - -#define MC_COMMAND (WM_APP+0x29) -#define MC_STRINGCHANGE (WM_APP+0x30) -#define MC_ESCAPE (WM_APP+0x45) - -#include -#include "color_wnd.h" - -///////////////////////////////////////////////////////////////////////////// -// CMemoryComboBox window - -class CMemoryComboBox : public CWnd -{ -// Construction -public: - CMemoryComboBox(); - - enum - { - HeightMin = 100, - }; - - void onOK (); - void onCancel (); - void create (DWORD style, const RECT &rect, CWnd *parent, UINT nId, const char *registerAdress, int memoryCount); - void create (DWORD style, const RECT &rect, CWnd *parent, UINT nId); - void setRegisterAdress (const char *registerAdress); - void clearCommand (); - void addCommand (const char* commandLabel, uint commandId); - void clearStaticStrings (); - void addStaticStrings (const char* strings); - uint getCommandCount () const; - void showDropDown (); - bool haveFocus (); - bool isWnd (const CWnd *wnd) const; - void enableAutoCompleteExtension (bool enable, const char * ext); - - std::string RegisterAdress; - int MemoryCount; - UINT Id; - - class CCommand - { - public: - std::string Label; - uint Id; - }; - - std::vector StaticStrings; - std::vector Commands; - -private: - - // Auto complete extension - bool _AutoCompleteExtension; - std::string _Extension; - - // Send the string changed to the parent - void notifyParent (); - - // Add the current string in the registry - void pushString (); - - // Get strings from the registry - void refreshStrings (); - - // The internal combobox - CComboBox _ComboBox; - - // Edit changed - bool _EditChanged; - bool _ComboOpen; - int _ComboCurSel; - - // Use the memory - bool _Memory; - - void scrollDown (int start, int end); - bool getMemory (int slot, std::string &ret); - void pushString (const std::string &str); - void addLabelCommands (uint i); - -// Attributes -public: - -// Operations -public: - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CMemoryComboBox) - public: - virtual BOOL PreTranslateMessage(MSG* pMsg); - protected: - virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam); - virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); - //}}AFX_VIRTUAL - -// Implementation -public: - virtual ~CMemoryComboBox(); - - // Generated message map functions -protected: - //{{AFX_MSG(CMemoryComboBox) - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnSetFocus(CWnd* pOldWnd); - afx_msg void OnEnable(BOOL bEnable); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_MEMORY_COMBO_BOX_H__A0A59637_63E4_40A6_AA7D_B57B4707ABF2__INCLUDED_) +// 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 . + +#if !defined(AFX_MEMORY_COMBO_BOX_H__A0A59637_63E4_40A6_AA7D_B57B4707ABF2__INCLUDED_) +#define AFX_MEMORY_COMBO_BOX_H__A0A59637_63E4_40A6_AA7D_B57B4707ABF2__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// memory_combo_box.h : header file +// + +#define MC_COMMAND (WM_APP+0x29) +#define MC_STRINGCHANGE (WM_APP+0x30) +#define MC_ESCAPE (WM_APP+0x45) + +#include +#include "color_wnd.h" + +///////////////////////////////////////////////////////////////////////////// +// CMemoryComboBox window + +class CMemoryComboBox : public CWnd +{ +// Construction +public: + CMemoryComboBox(); + + enum + { + HeightMin = 100, + }; + + void onOK (); + void onCancel (); + void create (DWORD style, const RECT &rect, CWnd *parent, UINT nId, const char *registerAdress, int memoryCount); + void create (DWORD style, const RECT &rect, CWnd *parent, UINT nId); + void setRegisterAdress (const char *registerAdress); + void clearCommand (); + void addCommand (const char* commandLabel, uint commandId); + void clearStaticStrings (); + void addStaticStrings (const char* strings); + uint getCommandCount () const; + void showDropDown (); + bool haveFocus (); + bool isWnd (const CWnd *wnd) const; + void enableAutoCompleteExtension (bool enable, const char * ext); + + std::string RegisterAdress; + int MemoryCount; + UINT Id; + + class CCommand + { + public: + std::string Label; + uint Id; + }; + + std::vector StaticStrings; + std::vector Commands; + +private: + + // Auto complete extension + bool _AutoCompleteExtension; + std::string _Extension; + + // Send the string changed to the parent + void notifyParent (); + + // Add the current string in the registry + void pushString (); + + // Get strings from the registry + void refreshStrings (); + + // The internal combobox + CComboBox _ComboBox; + + // Edit changed + bool _EditChanged; + bool _ComboOpen; + int _ComboCurSel; + + // Use the memory + bool _Memory; + + void scrollDown (int start, int end); + bool getMemory (int slot, std::string &ret); + void pushString (const std::string &str); + void addLabelCommands (uint i); + +// Attributes +public: + +// Operations +public: + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CMemoryComboBox) + public: + virtual BOOL PreTranslateMessage(MSG* pMsg); + protected: + virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam); + virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); + //}}AFX_VIRTUAL + +// Implementation +public: + virtual ~CMemoryComboBox(); + + // Generated message map functions +protected: + //{{AFX_MSG(CMemoryComboBox) + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnSetFocus(CWnd* pOldWnd); + afx_msg void OnEnable(BOOL bEnable); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_MEMORY_COMBO_BOX_H__A0A59637_63E4_40A6_AA7D_B57B4707ABF2__INCLUDED_) diff --git a/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.cpp b/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.cpp index 47181a4ab..abb81b933 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.cpp @@ -1,114 +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 . - -// output_console_dlg.cpp : implementation file -// - -#include "stdafx.h" -#include "georges_edit.h" -#include "output_console_dlg.h" -#include "main_frm.h" - -///////////////////////////////////////////////////////////////////////////// -// COutputConsoleDlg dialog - - -COutputConsoleDlg::COutputConsoleDlg(CWnd* pParent /*=NULL*/) - : CDialog(COutputConsoleDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(COutputConsoleDlg) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - - -void COutputConsoleDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(COutputConsoleDlg) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(COutputConsoleDlg, CDialog) - //{{AFX_MSG_MAP(COutputConsoleDlg) - ON_WM_SIZE() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// COutputConsoleDlg message handlers - -void COutputConsoleDlg::OnSize(UINT nType, int cx, int cy) -{ - CDialog::OnSize(nType, cx, cy); - - if (IsWindow (*this)) - { - CRect sz; - sz.left = 0; - sz.top = 0; - sz.right = cx; - sz.bottom = cy; - - CEdit* edit = (CEdit*)GetDlgItem (IDC_OUTPUT_CONSOLE); - if (edit) - { - sz.top += 5; - sz.left += 5; - sz.right -= 5; - sz.bottom -= 5; - - edit->MoveWindow(sz); - } - } -} - -BOOL COutputConsoleDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - // Create a font - /*CFont font; - font.CreateFont (8, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, - FF_DONTCARE, "Ms Sans Sherif");*/ - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void COutputConsoleDlg::outputString (const char *message) -{ - CEdit* edit = (CEdit*)GetDlgItem (IDC_OUTPUT_CONSOLE); - if (edit) - { - int index = edit->LineIndex(edit->GetLineCount( )-1) + edit->LineLength(edit->GetLineCount( )-1); - edit->SetSel (index, index); - edit->ReplaceSel (message); - } -} - -void COutputConsoleDlg::OnCancel () -{ - // Select document - CMDIChildWnd *child = ((CMainFrame*)theApp.m_pMainWnd)->MDIGetActive(); - if (child) - { - child->SetFocus (); - } -} - +// 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 . + +// output_console_dlg.cpp : implementation file +// + +#include "stdafx.h" +#include "georges_edit.h" +#include "output_console_dlg.h" +#include "main_frm.h" + +///////////////////////////////////////////////////////////////////////////// +// COutputConsoleDlg dialog + + +COutputConsoleDlg::COutputConsoleDlg(CWnd* pParent /*=NULL*/) + : CDialog(COutputConsoleDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(COutputConsoleDlg) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT +} + + +void COutputConsoleDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(COutputConsoleDlg) + // NOTE: the ClassWizard will add DDX and DDV calls here + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(COutputConsoleDlg, CDialog) + //{{AFX_MSG_MAP(COutputConsoleDlg) + ON_WM_SIZE() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// COutputConsoleDlg message handlers + +void COutputConsoleDlg::OnSize(UINT nType, int cx, int cy) +{ + CDialog::OnSize(nType, cx, cy); + + if (IsWindow (*this)) + { + CRect sz; + sz.left = 0; + sz.top = 0; + sz.right = cx; + sz.bottom = cy; + + CEdit* edit = (CEdit*)GetDlgItem (IDC_OUTPUT_CONSOLE); + if (edit) + { + sz.top += 5; + sz.left += 5; + sz.right -= 5; + sz.bottom -= 5; + + edit->MoveWindow(sz); + } + } +} + +BOOL COutputConsoleDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // Create a font + /*CFont font; + font.CreateFont (8, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, + FF_DONTCARE, "Ms Sans Sherif");*/ + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void COutputConsoleDlg::outputString (const char *message) +{ + CEdit* edit = (CEdit*)GetDlgItem (IDC_OUTPUT_CONSOLE); + if (edit) + { + int index = edit->LineIndex(edit->GetLineCount( )-1) + edit->LineLength(edit->GetLineCount( )-1); + edit->SetSel (index, index); + edit->ReplaceSel (message); + } +} + +void COutputConsoleDlg::OnCancel () +{ + // Select document + CMDIChildWnd *child = ((CMainFrame*)theApp.m_pMainWnd)->MDIGetActive(); + if (child) + { + child->SetFocus (); + } +} + diff --git a/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.h b/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.h index 47d447c59..f3bc4a799 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.h +++ b/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.h @@ -1,70 +1,70 @@ -// 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 . - -#if !defined(AFX_OUTPUT_CONSOLE_DLG_H__CE12A786_6B9B_41E1_A87E_8E19E6C708AE__INCLUDED_) -#define AFX_OUTPUT_CONSOLE_DLG_H__CE12A786_6B9B_41E1_A87E_8E19E6C708AE__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// output_console_dlg.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// COutputConsoleDlg dialog - -class COutputConsoleDlg : public CDialog -{ -// Construction -public: - COutputConsoleDlg(CWnd* pParent = NULL); // standard constructor - - // Output string - void outputString (const char *message); - - // From CDialog - void OnOK () {} - void OnCancel () - -// Dialog Data - //{{AFX_DATA(COutputConsoleDlg) - enum { IDD = IDD_OUTPUT_CONSOLE }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(COutputConsoleDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(COutputConsoleDlg) - afx_msg void OnSize(UINT nType, int cx, int cy); - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_OUTPUT_CONSOLE_DLG_H__CE12A786_6B9B_41E1_A87E_8E19E6C708AE__INCLUDED_) +// 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 . + +#if !defined(AFX_OUTPUT_CONSOLE_DLG_H__CE12A786_6B9B_41E1_A87E_8E19E6C708AE__INCLUDED_) +#define AFX_OUTPUT_CONSOLE_DLG_H__CE12A786_6B9B_41E1_A87E_8E19E6C708AE__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// output_console_dlg.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// COutputConsoleDlg dialog + +class COutputConsoleDlg : public CDialog +{ +// Construction +public: + COutputConsoleDlg(CWnd* pParent = NULL); // standard constructor + + // Output string + void outputString (const char *message); + + // From CDialog + void OnOK () {} + void OnCancel () + +// Dialog Data + //{{AFX_DATA(COutputConsoleDlg) + enum { IDD = IDD_OUTPUT_CONSOLE }; + // NOTE: the ClassWizard will add data members here + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(COutputConsoleDlg) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(COutputConsoleDlg) + afx_msg void OnSize(UINT nType, int cx, int cy); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_OUTPUT_CONSOLE_DLG_H__CE12A786_6B9B_41E1_A87E_8E19E6C708AE__INCLUDED_) diff --git a/code/ryzom/tools/leveldesign/georges_dll/plugin_interface.h b/code/ryzom/tools/leveldesign/georges_dll/plugin_interface.h index 36ad36062..97b667824 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/plugin_interface.h +++ b/code/ryzom/tools/leveldesign/georges_dll/plugin_interface.h @@ -1,248 +1,248 @@ -// 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 NLGEORGES_PLUGIN_INTERFACE_H -#define NLGEORGES_PLUGIN_INTERFACE_H - -#include -#include "nel/misc/config_file.h" - -namespace NLGEORGES -{ - -/** - * Georges plug-ins are dlls. To be loaded, dll must be listed in the georges.cfg config file. - * The dll must export 1 function: - * - * IEditPlugin *IGeorgesEditGetInterface (int version, IEdit *globalInterface); - * - * This method must first compare the version number with NLGEORGES_PLUGIN_INTERFACE_VERSION defined in - * plugin_interface.h. If the version is not the same, the function must returns NULL (can show an error message). - * If the number is the same, the plugin must instanciate an interface and return its pointers. It should - * do only basic initialisation stuff. This method is called only one time by georges editor session. - * The IEditPlugin derived object must be allocated with new. It will be delete by the system. - * - * The globalInterface pointer is valid to the end of the session. - */ - -class IEdit; -class IEditPlugin; -class IEditDocument; -class IEditDocumentPlugin; - -// The get interface plugin DLL entry. -typedef IEditPlugin *(*IGeorgesEditGetInterface) (int version, IEdit *globalInterface, NLMISC::INelContext &nelContext); - -#define NLGEORGES_PLUGIN_INTERFACE_VERSION 0x1 - -/** - * Communication interface between the plugin and georges editor. - * - * This interface give access to global global events handling. - * - * If you use MFC, don't forget to call AFX_MANAGE_STATE(AfxGetStaticModuleState()); - * at the beginning of each callback of the interface. - * - * This interface is instancied by the plugin. - */ -class IEditPlugin -{ -public: - - /** - * Destructor must uninitialise the plugin interface - */ - virtual ~IEditPlugin () {} - - /// Window related - - /** - * This method is called at dialog initialisation. - * Typicaly, this method will create / show some global edition tools. (Not document edition related dialog). - * - * \param is the HWND of georges editor main frame. - */ - virtual void dialogInit (HWND mainFrm) = 0; - - /** - * This method is called to activate / disactivate the plugin UI. - * - * \param activate is true to activate the plugin UI, false to hide the plugin UI - */ - virtual void activate (bool activate) = 0; - - /** - * Get the plugin name. - */ - virtual void getPluginName (std::string &name) = 0; - - /** - * Pretranslate message hook. - * This method give a chance to the plugin to pretranslate a message before the main frame. - * Useful for shortcuts etc.. - * Default implementation returns "false"; - */ - virtual bool pretranslateMessage (MSG *pMsg) = 0; - - /// Events - - /** - * This method is called when a document has been created / opened. - */ - virtual void onCreateDocument (IEditDocument *document) = 0; -}; - -/** - * This interface give access to global functions. - * - * This interface is instancied by the system. - */ -class IEdit -{ -public: - /** - * Return the active document. Return NULL if no current document. - */ - virtual IEditDocument *getActiveDocument () = 0; - - /** - * Return the current search path. - */ - virtual void getSearchPath (std::string &searchPath) = 0; - - /** - * Create a form in the editor. - * - * \param dfnName is the name of the DFN. Can't be NULL. - * \param pathName is the file name of the created document. Can be NULL. - * \return the document pointer or NULL if a problem occured. - */ - virtual IEditDocument *createDocument (const char *dfnName, const char *pathName) = 0; - - /** - * Retreive the loaded config file. - * Usefull for plugins to read any configuration var. - */ - virtual NLMISC::CConfigFile &getConfigFile() =0; -}; - -/** - * Communication interface between the plugin and georges editor document. - * For the time, the interface can't modify document. It can only read it. - * The interface must be allocated with new. It will be released by the - * system when the document will be destroyed. - * - * If you use MFC, don't forget to call AFX_MANAGE_STATE(AfxGetStaticModuleState()); - * at the beginning of each callback of the interface. - * - * This interface is instancied by the plugin. - */ -class IEditDocumentPlugin -{ -public: - - /** - * Destructor must uninitialise the plugin interface - */ - virtual ~IEditDocumentPlugin () {} - - /// Event message - - /** - * This method is called to intialise dialog during IEditDocument::bind (). - * Typicaly, this method will create / show some document control tools. - * - * \param is the HWND of the document view. - */ - virtual void dialogInit (HWND documentView) = 0; - - /** - * Pretranslate message hook. - * This method give a chance to the plugin to pretranslate a message before the main frame. - * Useful for shortcuts etc.. - * Default implementation returns "false"; - */ - virtual bool pretranslateMessage (MSG *pMsg) = 0; - - /** - * This method is called when a document's view has been activated / unactivated. - * If activated == true, the view has been activated, else the view is unactivated. - */ - virtual void activate (bool activated) = 0; - - /** - * Called by the system when a georges value has been changed. - */ - virtual void onValueChanged (const char *formName) = 0; - - /** - * Called by the system when the current edition node has been changed. - * Call IEditDocument::getActiveNode () to get the active node form name. - */ - virtual void onNodeChanged () = 0; -}; - -/** - * Document access interface. - * By this interface, you can access some values of the document. - * - * This interface is instancied by the system. - */ -class IEditDocument -{ -public: - /// Get the georges form pointer - virtual UForm *getForm () = 0; - - /// Get document DFN filename - virtual void getDfnFilename (std::string &dfnName) = 0; - - /// Get the document active node form name. Can return false if the node is not a form node. - virtual bool getActiveNode (std::string &formName) = 0; - - /// Refresh the document view. - virtual void refreshView () = 0; - - /// Return document filename. - virtual void getFilename (std::string &pathname) = 0; - - /// Return document title. - virtual void getTitle (std::string &pathname) = 0; - - /** - * Attach a document interface to this document. - * - * \param plugin is the global plugin interface. - * \param docInterface is a document interface allocated with new. It will be released by the document. - */ - virtual void bind (NLGEORGES::IEditPlugin *plugin, NLGEORGES::IEditDocumentPlugin *docInterface) = 0; - - /// \name Modify the document - - /** - * Set a form value with its name. If the node doesn't exist, it is created. - * - * \param value is a reference on the value to set in the form. - * \param name is the form name of the value to set or create. - * \param slot is 0, 1, 2, 3. 0 is the current document, 1 is 1st snapshot, 2 the 2nd snapshot etc.. - */ - virtual void setValue (const char *value, const char *name, uint slot=0) = 0; -}; - -} // NLGEORGES - -#endif // NLGEORGES_PLUGIN_INTERFACE_H - +// 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 NLGEORGES_PLUGIN_INTERFACE_H +#define NLGEORGES_PLUGIN_INTERFACE_H + +#include +#include "nel/misc/config_file.h" + +namespace NLGEORGES +{ + +/** + * Georges plug-ins are dlls. To be loaded, dll must be listed in the georges.cfg config file. + * The dll must export 1 function: + * + * IEditPlugin *IGeorgesEditGetInterface (int version, IEdit *globalInterface); + * + * This method must first compare the version number with NLGEORGES_PLUGIN_INTERFACE_VERSION defined in + * plugin_interface.h. If the version is not the same, the function must returns NULL (can show an error message). + * If the number is the same, the plugin must instanciate an interface and return its pointers. It should + * do only basic initialisation stuff. This method is called only one time by georges editor session. + * The IEditPlugin derived object must be allocated with new. It will be delete by the system. + * + * The globalInterface pointer is valid to the end of the session. + */ + +class IEdit; +class IEditPlugin; +class IEditDocument; +class IEditDocumentPlugin; + +// The get interface plugin DLL entry. +typedef IEditPlugin *(*IGeorgesEditGetInterface) (int version, IEdit *globalInterface, NLMISC::INelContext &nelContext); + +#define NLGEORGES_PLUGIN_INTERFACE_VERSION 0x1 + +/** + * Communication interface between the plugin and georges editor. + * + * This interface give access to global global events handling. + * + * If you use MFC, don't forget to call AFX_MANAGE_STATE(AfxGetStaticModuleState()); + * at the beginning of each callback of the interface. + * + * This interface is instancied by the plugin. + */ +class IEditPlugin +{ +public: + + /** + * Destructor must uninitialise the plugin interface + */ + virtual ~IEditPlugin () {} + + /// Window related + + /** + * This method is called at dialog initialisation. + * Typicaly, this method will create / show some global edition tools. (Not document edition related dialog). + * + * \param is the HWND of georges editor main frame. + */ + virtual void dialogInit (HWND mainFrm) = 0; + + /** + * This method is called to activate / disactivate the plugin UI. + * + * \param activate is true to activate the plugin UI, false to hide the plugin UI + */ + virtual void activate (bool activate) = 0; + + /** + * Get the plugin name. + */ + virtual void getPluginName (std::string &name) = 0; + + /** + * Pretranslate message hook. + * This method give a chance to the plugin to pretranslate a message before the main frame. + * Useful for shortcuts etc.. + * Default implementation returns "false"; + */ + virtual bool pretranslateMessage (MSG *pMsg) = 0; + + /// Events + + /** + * This method is called when a document has been created / opened. + */ + virtual void onCreateDocument (IEditDocument *document) = 0; +}; + +/** + * This interface give access to global functions. + * + * This interface is instancied by the system. + */ +class IEdit +{ +public: + /** + * Return the active document. Return NULL if no current document. + */ + virtual IEditDocument *getActiveDocument () = 0; + + /** + * Return the current search path. + */ + virtual void getSearchPath (std::string &searchPath) = 0; + + /** + * Create a form in the editor. + * + * \param dfnName is the name of the DFN. Can't be NULL. + * \param pathName is the file name of the created document. Can be NULL. + * \return the document pointer or NULL if a problem occured. + */ + virtual IEditDocument *createDocument (const char *dfnName, const char *pathName) = 0; + + /** + * Retreive the loaded config file. + * Usefull for plugins to read any configuration var. + */ + virtual NLMISC::CConfigFile &getConfigFile() =0; +}; + +/** + * Communication interface between the plugin and georges editor document. + * For the time, the interface can't modify document. It can only read it. + * The interface must be allocated with new. It will be released by the + * system when the document will be destroyed. + * + * If you use MFC, don't forget to call AFX_MANAGE_STATE(AfxGetStaticModuleState()); + * at the beginning of each callback of the interface. + * + * This interface is instancied by the plugin. + */ +class IEditDocumentPlugin +{ +public: + + /** + * Destructor must uninitialise the plugin interface + */ + virtual ~IEditDocumentPlugin () {} + + /// Event message + + /** + * This method is called to intialise dialog during IEditDocument::bind (). + * Typicaly, this method will create / show some document control tools. + * + * \param is the HWND of the document view. + */ + virtual void dialogInit (HWND documentView) = 0; + + /** + * Pretranslate message hook. + * This method give a chance to the plugin to pretranslate a message before the main frame. + * Useful for shortcuts etc.. + * Default implementation returns "false"; + */ + virtual bool pretranslateMessage (MSG *pMsg) = 0; + + /** + * This method is called when a document's view has been activated / unactivated. + * If activated == true, the view has been activated, else the view is unactivated. + */ + virtual void activate (bool activated) = 0; + + /** + * Called by the system when a georges value has been changed. + */ + virtual void onValueChanged (const char *formName) = 0; + + /** + * Called by the system when the current edition node has been changed. + * Call IEditDocument::getActiveNode () to get the active node form name. + */ + virtual void onNodeChanged () = 0; +}; + +/** + * Document access interface. + * By this interface, you can access some values of the document. + * + * This interface is instancied by the system. + */ +class IEditDocument +{ +public: + /// Get the georges form pointer + virtual UForm *getForm () = 0; + + /// Get document DFN filename + virtual void getDfnFilename (std::string &dfnName) = 0; + + /// Get the document active node form name. Can return false if the node is not a form node. + virtual bool getActiveNode (std::string &formName) = 0; + + /// Refresh the document view. + virtual void refreshView () = 0; + + /// Return document filename. + virtual void getFilename (std::string &pathname) = 0; + + /// Return document title. + virtual void getTitle (std::string &pathname) = 0; + + /** + * Attach a document interface to this document. + * + * \param plugin is the global plugin interface. + * \param docInterface is a document interface allocated with new. It will be released by the document. + */ + virtual void bind (NLGEORGES::IEditPlugin *plugin, NLGEORGES::IEditDocumentPlugin *docInterface) = 0; + + /// \name Modify the document + + /** + * Set a form value with its name. If the node doesn't exist, it is created. + * + * \param value is a reference on the value to set in the form. + * \param name is the form name of the value to set or create. + * \param slot is 0, 1, 2, 3. 0 is the current document, 1 is 1st snapshot, 2 the 2nd snapshot etc.. + */ + virtual void setValue (const char *value, const char *name, uint slot=0) = 0; +}; + +} // NLGEORGES + +#endif // NLGEORGES_PLUGIN_INTERFACE_H + diff --git a/code/ryzom/tools/leveldesign/georges_dll/reg_shell_ext.cpp b/code/ryzom/tools/leveldesign/georges_dll/reg_shell_ext.cpp index aac4da631..c92f2be16 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/reg_shell_ext.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/reg_shell_ext.cpp @@ -1,192 +1,192 @@ -// 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 "stdafx.h" -#include "reg_shell_ext.h" -#include "nel/misc/common.h" - -using namespace std; -using namespace NLMISC; - -void deleteKey (HKEY hKey, const char *name) -{ - HKEY subKey; - if (RegOpenKey (hKey, name, &subKey) == ERROR_SUCCESS) - { - char subName[512]; - while (RegEnumKey (subKey, 0, subName, 512) == ERROR_SUCCESS) - { - deleteKey (subKey, subName); - } - nlverify (RegDeleteKey (hKey, name) == ERROR_SUCCESS); - } -} - -// Register an application -bool RegisterApp (const char *appName, const char *appDescription, const char *icon, int iconIndex) -{ - // Create the app key - HKEY hKey; - if (RegCreateKey (HKEY_CLASSES_ROOT, appName, &hKey) == ERROR_SUCCESS) - { - // Set the description - RegSetValue (hKey, "", REG_SZ, appDescription, strlen (appDescription)); - - // Create the icon - HKEY hKey2; - if (RegCreateKey (hKey, "DefaultIcon", &hKey2) == ERROR_SUCCESS) - { - // Set the description - char tmp[512]; - smprintf (tmp, 512, "%s,%d", icon, iconIndex); - RegSetValue (hKey2, "", REG_SZ, tmp, strlen (tmp)); - } - - // Create the shell/open/command - if (RegCreateKey (hKey, "shell", &hKey) == ERROR_SUCCESS) - { - if (RegCreateKey (hKey, "open", &hKey) == ERROR_SUCCESS) - { - if (RegCreateKey (hKey, "command", &hKey) == ERROR_SUCCESS) - { - // Set the description - string tmp = string(icon)+" \"%1\""; - RegSetValue (hKey, "", REG_SZ, tmp.c_str(), tmp.size()); - } - } - } - - return true; - } - return false; -} - -// Unregister an application -bool UnregisterApp (const char *appName) -{ - // Delete the app key - deleteKey (HKEY_CLASSES_ROOT, appName); - return true; -} - -// Unregister an application command -bool UnregisterAppCommand (const char *appName, const char *command) -{ - // Create the app key - HKEY hKey; - if (RegOpenKey (HKEY_CLASSES_ROOT, appName, &hKey) == ERROR_SUCCESS) - { - // Create the icon - char tmp[512]; - smprintf (tmp, 512, "shell\\%s", command); - deleteKey (hKey, tmp); - return true; - } - return false; -} - -// Register an application command -bool RegisterAppCommand (const char *appName, const char *command, const char *app) -{ - // Create the app key - HKEY hKey; - if (RegCreateKey (HKEY_CLASSES_ROOT, appName, &hKey) == ERROR_SUCCESS) - { - // Create the icon - char tmp[512]; - smprintf (tmp, 512, "shell\\%s\\command", command); - if (RegCreateKey (hKey, tmp, &hKey) == ERROR_SUCCESS) - { - // Set the description - RegSetValue (hKey, "", REG_SZ, app, strlen (app)); - } - return true; - } - return false; -} - -// Unregister an application DDE command -bool UnregisterDDECommand (const char *appName, const char *command) -{ - // Create the app key - HKEY hKey; - if (RegOpenKey (HKEY_CLASSES_ROOT, appName, &hKey) == ERROR_SUCCESS) - { - // Create the icon - char tmp[512]; - smprintf (tmp, 512, "shell\\%s\\ddeexec", command); - deleteKey (hKey, tmp); - } - return false; -} - -// Register an application DDE command -bool RegisterDDECommand (const char *appName, const char *command, const char *ddeCommand, const char *application) -{ - // Create the app key - HKEY hKey; - if (RegCreateKey (HKEY_CLASSES_ROOT, appName, &hKey) == ERROR_SUCCESS) - { - // Create the icon - char tmp[512]; - smprintf (tmp, 512, "shell\\%s\\ddeexec", command); - if (RegCreateKey (hKey, tmp, &hKey) == ERROR_SUCCESS) - { - // Set the description - RegSetValue (hKey, "", REG_SZ, ddeCommand, strlen (ddeCommand)); - HKEY hKey2; - if (RegCreateKey (hKey, "application", &hKey2) == ERROR_SUCCESS) - { - RegSetValue (hKey2, "", REG_SZ, application, strlen (application)); - if (RegCreateKey (hKey, "topic", &hKey2) == ERROR_SUCCESS) - { - RegSetValue (hKey2, "", REG_SZ, "system", strlen ("system")); - return true; - } - } - } - } - return false; -} - -// Register a file extension -bool RegisterShellFileExt (const char *ext, const char *appName) -{ - // Remove key in explorer registry if exist - HKEY hKey; - string key = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\"+string (ext); - deleteKey (HKEY_CURRENT_USER, key.c_str ()); - - // Create the app key - if (RegCreateKey (HKEY_CLASSES_ROOT, ext, &hKey) == ERROR_SUCCESS) - { - // Set the description - RegSetValue (hKey, "", REG_SZ, appName, strlen (appName)); - return true; - } - return false; -} - -// Register a file extension -bool UnregisterShellFileExt (const char *ext) -{ - // Delete the app key - if (RegDeleteKey (HKEY_CLASSES_ROOT, ext) == ERROR_SUCCESS) - { - return true; - } - return false; -} +// 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 "stdafx.h" +#include "reg_shell_ext.h" +#include "nel/misc/common.h" + +using namespace std; +using namespace NLMISC; + +void deleteKey (HKEY hKey, const char *name) +{ + HKEY subKey; + if (RegOpenKey (hKey, name, &subKey) == ERROR_SUCCESS) + { + char subName[512]; + while (RegEnumKey (subKey, 0, subName, 512) == ERROR_SUCCESS) + { + deleteKey (subKey, subName); + } + nlverify (RegDeleteKey (hKey, name) == ERROR_SUCCESS); + } +} + +// Register an application +bool RegisterApp (const char *appName, const char *appDescription, const char *icon, int iconIndex) +{ + // Create the app key + HKEY hKey; + if (RegCreateKey (HKEY_CLASSES_ROOT, appName, &hKey) == ERROR_SUCCESS) + { + // Set the description + RegSetValue (hKey, "", REG_SZ, appDescription, strlen (appDescription)); + + // Create the icon + HKEY hKey2; + if (RegCreateKey (hKey, "DefaultIcon", &hKey2) == ERROR_SUCCESS) + { + // Set the description + char tmp[512]; + smprintf (tmp, 512, "%s,%d", icon, iconIndex); + RegSetValue (hKey2, "", REG_SZ, tmp, strlen (tmp)); + } + + // Create the shell/open/command + if (RegCreateKey (hKey, "shell", &hKey) == ERROR_SUCCESS) + { + if (RegCreateKey (hKey, "open", &hKey) == ERROR_SUCCESS) + { + if (RegCreateKey (hKey, "command", &hKey) == ERROR_SUCCESS) + { + // Set the description + string tmp = string(icon)+" \"%1\""; + RegSetValue (hKey, "", REG_SZ, tmp.c_str(), tmp.size()); + } + } + } + + return true; + } + return false; +} + +// Unregister an application +bool UnregisterApp (const char *appName) +{ + // Delete the app key + deleteKey (HKEY_CLASSES_ROOT, appName); + return true; +} + +// Unregister an application command +bool UnregisterAppCommand (const char *appName, const char *command) +{ + // Create the app key + HKEY hKey; + if (RegOpenKey (HKEY_CLASSES_ROOT, appName, &hKey) == ERROR_SUCCESS) + { + // Create the icon + char tmp[512]; + smprintf (tmp, 512, "shell\\%s", command); + deleteKey (hKey, tmp); + return true; + } + return false; +} + +// Register an application command +bool RegisterAppCommand (const char *appName, const char *command, const char *app) +{ + // Create the app key + HKEY hKey; + if (RegCreateKey (HKEY_CLASSES_ROOT, appName, &hKey) == ERROR_SUCCESS) + { + // Create the icon + char tmp[512]; + smprintf (tmp, 512, "shell\\%s\\command", command); + if (RegCreateKey (hKey, tmp, &hKey) == ERROR_SUCCESS) + { + // Set the description + RegSetValue (hKey, "", REG_SZ, app, strlen (app)); + } + return true; + } + return false; +} + +// Unregister an application DDE command +bool UnregisterDDECommand (const char *appName, const char *command) +{ + // Create the app key + HKEY hKey; + if (RegOpenKey (HKEY_CLASSES_ROOT, appName, &hKey) == ERROR_SUCCESS) + { + // Create the icon + char tmp[512]; + smprintf (tmp, 512, "shell\\%s\\ddeexec", command); + deleteKey (hKey, tmp); + } + return false; +} + +// Register an application DDE command +bool RegisterDDECommand (const char *appName, const char *command, const char *ddeCommand, const char *application) +{ + // Create the app key + HKEY hKey; + if (RegCreateKey (HKEY_CLASSES_ROOT, appName, &hKey) == ERROR_SUCCESS) + { + // Create the icon + char tmp[512]; + smprintf (tmp, 512, "shell\\%s\\ddeexec", command); + if (RegCreateKey (hKey, tmp, &hKey) == ERROR_SUCCESS) + { + // Set the description + RegSetValue (hKey, "", REG_SZ, ddeCommand, strlen (ddeCommand)); + HKEY hKey2; + if (RegCreateKey (hKey, "application", &hKey2) == ERROR_SUCCESS) + { + RegSetValue (hKey2, "", REG_SZ, application, strlen (application)); + if (RegCreateKey (hKey, "topic", &hKey2) == ERROR_SUCCESS) + { + RegSetValue (hKey2, "", REG_SZ, "system", strlen ("system")); + return true; + } + } + } + } + return false; +} + +// Register a file extension +bool RegisterShellFileExt (const char *ext, const char *appName) +{ + // Remove key in explorer registry if exist + HKEY hKey; + string key = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\"+string (ext); + deleteKey (HKEY_CURRENT_USER, key.c_str ()); + + // Create the app key + if (RegCreateKey (HKEY_CLASSES_ROOT, ext, &hKey) == ERROR_SUCCESS) + { + // Set the description + RegSetValue (hKey, "", REG_SZ, appName, strlen (appName)); + return true; + } + return false; +} + +// Register a file extension +bool UnregisterShellFileExt (const char *ext) +{ + // Delete the app key + if (RegDeleteKey (HKEY_CLASSES_ROOT, ext) == ERROR_SUCCESS) + { + return true; + } + return false; +} diff --git a/code/ryzom/tools/leveldesign/georges_dll/reg_shell_ext.h b/code/ryzom/tools/leveldesign/georges_dll/reg_shell_ext.h index 6b06ea47e..13f5c30fc 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/reg_shell_ext.h +++ b/code/ryzom/tools/leveldesign/georges_dll/reg_shell_ext.h @@ -1,41 +1,41 @@ -// 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 REG_SHELL_EXT_H_INCLUDED -#define REG_SHELL_EXT_H_INCLUDED - -// Register an application -bool RegisterApp (const char *appName, const char *appDescription, const char *icon, int iconIndex); - -// Unregister an application -bool UnregisterApp (const char *appName); - -// Register an application command -bool RegisterAppCommand (const char *appName, const char *command, const char *app); - -// Unregister an application command -bool UnregisterAppCommand (const char *appName, const char *command); - -// Register an application DDE command -bool RegisterDDECommand (const char *appName, const char *command, const char *ddeCommand, const char *application); - -// Unregister an application DDE command -bool UnregisterDDECommand (const char *appName, const char *command); - -// Register a file extension -bool RegisterShellFileExt (const char *ext, const char *appName); - -#endif // REG_SHELL_EXT_H_INCLUDED +// 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 REG_SHELL_EXT_H_INCLUDED +#define REG_SHELL_EXT_H_INCLUDED + +// Register an application +bool RegisterApp (const char *appName, const char *appDescription, const char *icon, int iconIndex); + +// Unregister an application +bool UnregisterApp (const char *appName); + +// Register an application command +bool RegisterAppCommand (const char *appName, const char *command, const char *app); + +// Unregister an application command +bool UnregisterAppCommand (const char *appName, const char *command); + +// Register an application DDE command +bool RegisterDDECommand (const char *appName, const char *command, const char *ddeCommand, const char *application); + +// Unregister an application DDE command +bool UnregisterDDECommand (const char *appName, const char *command); + +// Register a file extension +bool RegisterShellFileExt (const char *ext, const char *appName); + +#endif // REG_SHELL_EXT_H_INCLUDED diff --git a/code/ryzom/tools/leveldesign/georges_dll/settings_dialog.cpp b/code/ryzom/tools/leveldesign/georges_dll/settings_dialog.cpp index 9d1a3bf6a..28f50e7e1 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/settings_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/settings_dialog.cpp @@ -1,161 +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 . - -// settings_dialog.cpp : implementation file -// - -#include "stdafx.h" - -#include "georges_edit.h" -#include "settings_dialog.h" - -using namespace NLMISC; - -///////////////////////////////////////////////////////////////////////////// -// CSettingsDialog dialog - - -CSettingsDialog::CSettingsDialog(CWnd* pParent /*=NULL*/) - : CDialog(CSettingsDialog::IDD, pParent) -{ - //{{AFX_DATA_INIT(CSettingsDialog) - RootSearchPath = _T(""); - RememberListSize = 0; - DefaultDfn = _T(""); - DefaultType = _T(""); - TypeDfnSubDirectory = _T(""); - MaxUndo = 0; - StartExpanded = TRUE; - Georges4CVS = TRUE; - //}}AFX_DATA_INIT -} - - -void CSettingsDialog::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CSettingsDialog) - DDX_Text(pDX, IDC_ROOT_SEARCH_PATH, RootSearchPath); - DDX_Text(pDX, IDC_REMEMBER_LIST_SIZE, RememberListSize); - DDX_Text(pDX, IDC_DEFAULT_DFN, DefaultDfn); - DDX_Text(pDX, IDC_DEFAULT_TYPE, DefaultType); - DDX_Text(pDX, IDC_TYP_DFN_PATH, TypeDfnSubDirectory); - DDX_Text(pDX, IDC_MAX_UNDO, MaxUndo); - DDX_Check(pDX, IDC_START_EXPANDED, StartExpanded); - DDX_Check(pDX, IDC_GEORGES_4_CVS, Georges4CVS); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CSettingsDialog, CDialog) - //{{AFX_MSG_MAP(CSettingsDialog) - ON_EN_CHANGE(IDC_ROOT_SEARCH_PATH, OnChangeRootSearchPath) - ON_BN_CLICKED(IDC_BROWSE, OnBrowse) - ON_EN_CHANGE(IDC_REMEMBER_LIST_SIZE, OnChangeRememberListSize) - ON_EN_CHANGE(IDC_DEFAULT_DFN, OnChangeDefaultDfn) - ON_EN_CHANGE(IDC_DEFAULT_TYPE, OnChangeDefaultType) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CSettingsDialog message handlers - -void CSettingsDialog::OnChangeRootSearchPath() -{ -} - -BOOL CSettingsDialog::OnInitDialog() -{ - CDialog::OnInitDialog(); - - // Reset flags - RootSearchPath = "\\"; - - // Get the config file path - theApp.loadCfg (); - RootSearchPath = theApp.RootSearchPath.c_str(); - TypeDfnSubDirectory = theApp.TypeDfnSubDirectory.c_str(); - RememberListSize = theApp.RememberListSize; - MaxUndo = theApp.MaxUndo; - DefaultDfn = theApp.DefaultDfn.c_str (); - DefaultType = theApp.DefaultType.c_str (); - StartExpanded = theApp.StartExpanded; - Georges4CVS = theApp.Georges4CVS; - - UpdateData (FALSE); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void CSettingsDialog::OnOK() -{ - UpdateData (); - - // Make a config file - theApp.RootSearchPath = RootSearchPath; - theApp.TypeDfnSubDirectory = TypeDfnSubDirectory; - theApp.RememberListSize = RememberListSize; - theApp.StartExpanded = StartExpanded ? TRUE : FALSE; - theApp.Georges4CVS = Georges4CVS ? TRUE : FALSE; - theApp.MaxUndo = MaxUndo; - theApp.DefaultDfn = DefaultDfn; - theApp.DefaultType = DefaultType; - theApp.saveCfg (); - theApp.initCfg (); - - CDialog::OnOK(); -} - -void CSettingsDialog::OnBrowse() -{ - UpdateData (); - - // Select a directory. - char path[MAX_PATH]; - - // Build the struct - BROWSEINFO info; - memset (&info, 0, sizeof (BROWSEINFO)); - info.lpszTitle="Select the root search directory"; - info.ulFlags=BIF_RETURNONLYFSDIRS; - - // Select the path - LPITEMIDLIST list; - if (list=SHBrowseForFolder (&info)) - { - // Convert item into path string - BOOL bRet=SHGetPathFromIDList(list, path); - if (bRet) - { - // Set the path - RootSearchPath = path; - } - } - UpdateData (FALSE); -} - -void CSettingsDialog::OnChangeRememberListSize() -{ -} - -void CSettingsDialog::OnChangeDefaultDfn() -{ -} - -void CSettingsDialog::OnChangeDefaultType() -{ -} +// 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 . + +// settings_dialog.cpp : implementation file +// + +#include "stdafx.h" + +#include "georges_edit.h" +#include "settings_dialog.h" + +using namespace NLMISC; + +///////////////////////////////////////////////////////////////////////////// +// CSettingsDialog dialog + + +CSettingsDialog::CSettingsDialog(CWnd* pParent /*=NULL*/) + : CDialog(CSettingsDialog::IDD, pParent) +{ + //{{AFX_DATA_INIT(CSettingsDialog) + RootSearchPath = _T(""); + RememberListSize = 0; + DefaultDfn = _T(""); + DefaultType = _T(""); + TypeDfnSubDirectory = _T(""); + MaxUndo = 0; + StartExpanded = TRUE; + Georges4CVS = TRUE; + //}}AFX_DATA_INIT +} + + +void CSettingsDialog::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CSettingsDialog) + DDX_Text(pDX, IDC_ROOT_SEARCH_PATH, RootSearchPath); + DDX_Text(pDX, IDC_REMEMBER_LIST_SIZE, RememberListSize); + DDX_Text(pDX, IDC_DEFAULT_DFN, DefaultDfn); + DDX_Text(pDX, IDC_DEFAULT_TYPE, DefaultType); + DDX_Text(pDX, IDC_TYP_DFN_PATH, TypeDfnSubDirectory); + DDX_Text(pDX, IDC_MAX_UNDO, MaxUndo); + DDX_Check(pDX, IDC_START_EXPANDED, StartExpanded); + DDX_Check(pDX, IDC_GEORGES_4_CVS, Georges4CVS); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CSettingsDialog, CDialog) + //{{AFX_MSG_MAP(CSettingsDialog) + ON_EN_CHANGE(IDC_ROOT_SEARCH_PATH, OnChangeRootSearchPath) + ON_BN_CLICKED(IDC_BROWSE, OnBrowse) + ON_EN_CHANGE(IDC_REMEMBER_LIST_SIZE, OnChangeRememberListSize) + ON_EN_CHANGE(IDC_DEFAULT_DFN, OnChangeDefaultDfn) + ON_EN_CHANGE(IDC_DEFAULT_TYPE, OnChangeDefaultType) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CSettingsDialog message handlers + +void CSettingsDialog::OnChangeRootSearchPath() +{ +} + +BOOL CSettingsDialog::OnInitDialog() +{ + CDialog::OnInitDialog(); + + // Reset flags + RootSearchPath = "\\"; + + // Get the config file path + theApp.loadCfg (); + RootSearchPath = theApp.RootSearchPath.c_str(); + TypeDfnSubDirectory = theApp.TypeDfnSubDirectory.c_str(); + RememberListSize = theApp.RememberListSize; + MaxUndo = theApp.MaxUndo; + DefaultDfn = theApp.DefaultDfn.c_str (); + DefaultType = theApp.DefaultType.c_str (); + StartExpanded = theApp.StartExpanded; + Georges4CVS = theApp.Georges4CVS; + + UpdateData (FALSE); + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void CSettingsDialog::OnOK() +{ + UpdateData (); + + // Make a config file + theApp.RootSearchPath = RootSearchPath; + theApp.TypeDfnSubDirectory = TypeDfnSubDirectory; + theApp.RememberListSize = RememberListSize; + theApp.StartExpanded = StartExpanded ? TRUE : FALSE; + theApp.Georges4CVS = Georges4CVS ? TRUE : FALSE; + theApp.MaxUndo = MaxUndo; + theApp.DefaultDfn = DefaultDfn; + theApp.DefaultType = DefaultType; + theApp.saveCfg (); + theApp.initCfg (); + + CDialog::OnOK(); +} + +void CSettingsDialog::OnBrowse() +{ + UpdateData (); + + // Select a directory. + char path[MAX_PATH]; + + // Build the struct + BROWSEINFO info; + memset (&info, 0, sizeof (BROWSEINFO)); + info.lpszTitle="Select the root search directory"; + info.ulFlags=BIF_RETURNONLYFSDIRS; + + // Select the path + LPITEMIDLIST list; + if (list=SHBrowseForFolder (&info)) + { + // Convert item into path string + BOOL bRet=SHGetPathFromIDList(list, path); + if (bRet) + { + // Set the path + RootSearchPath = path; + } + } + UpdateData (FALSE); +} + +void CSettingsDialog::OnChangeRememberListSize() +{ +} + +void CSettingsDialog::OnChangeDefaultDfn() +{ +} + +void CSettingsDialog::OnChangeDefaultType() +{ +} diff --git a/code/ryzom/tools/leveldesign/georges_dll/settings_dialog.h b/code/ryzom/tools/leveldesign/georges_dll/settings_dialog.h index a2fab2413..1bc3aaffe 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/settings_dialog.h +++ b/code/ryzom/tools/leveldesign/georges_dll/settings_dialog.h @@ -1,78 +1,78 @@ -// 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 . - -#if !defined(AFX_SETTINGS_DIALOG_H__585A784F_E3C3_4B1B_9DCA_929001C14056__INCLUDED_) -#define AFX_SETTINGS_DIALOG_H__585A784F_E3C3_4B1B_9DCA_929001C14056__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// settings_dialog.h : header file -// - -#include "nel/misc/config_file.h" - -///////////////////////////////////////////////////////////////////////////// -// CSettingsDialog dialog - -class CSettingsDialog : public CDialog -{ -// Construction -public: - CSettingsDialog(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CSettingsDialog) - enum { IDD = IDD_SETTINGS }; - CString RootSearchPath; - UINT RememberListSize; - CString DefaultDfn; - CString DefaultType; - CString TypeDfnSubDirectory; - UINT MaxUndo; - BOOL StartExpanded; - BOOL Georges4CVS; - //}}AFX_DATA - - NLMISC::CConfigFile ConfigFile; - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CSettingsDialog) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CSettingsDialog) - afx_msg void OnChangeRootSearchPath(); - virtual BOOL OnInitDialog(); - virtual void OnOK(); - afx_msg void OnBrowse(); - afx_msg void OnChangeRememberListSize(); - afx_msg void OnChangeDefaultDfn(); - afx_msg void OnChangeDefaultType(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_SETTINGS_DIALOG_H__585A784F_E3C3_4B1B_9DCA_929001C14056__INCLUDED_) +// 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 . + +#if !defined(AFX_SETTINGS_DIALOG_H__585A784F_E3C3_4B1B_9DCA_929001C14056__INCLUDED_) +#define AFX_SETTINGS_DIALOG_H__585A784F_E3C3_4B1B_9DCA_929001C14056__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// settings_dialog.h : header file +// + +#include "nel/misc/config_file.h" + +///////////////////////////////////////////////////////////////////////////// +// CSettingsDialog dialog + +class CSettingsDialog : public CDialog +{ +// Construction +public: + CSettingsDialog(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CSettingsDialog) + enum { IDD = IDD_SETTINGS }; + CString RootSearchPath; + UINT RememberListSize; + CString DefaultDfn; + CString DefaultType; + CString TypeDfnSubDirectory; + UINT MaxUndo; + BOOL StartExpanded; + BOOL Georges4CVS; + //}}AFX_DATA + + NLMISC::CConfigFile ConfigFile; + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CSettingsDialog) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CSettingsDialog) + afx_msg void OnChangeRootSearchPath(); + virtual BOOL OnInitDialog(); + virtual void OnOK(); + afx_msg void OnBrowse(); + afx_msg void OnChangeRememberListSize(); + afx_msg void OnChangeDefaultDfn(); + afx_msg void OnChangeDefaultType(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_SETTINGS_DIALOG_H__585A784F_E3C3_4B1B_9DCA_929001C14056__INCLUDED_) diff --git a/code/ryzom/tools/leveldesign/georges_dll/splash_screen.cpp b/code/ryzom/tools/leveldesign/georges_dll/splash_screen.cpp index a2f61996d..0f407024e 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/splash_screen.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/splash_screen.cpp @@ -1,77 +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 . - -// splash_screen.cpp : implementation file -// - -#include "stdafx.h" -#include "splash_screen.h" -#include - -using namespace std; - -///////////////////////////////////////////////////////////////////////////// -// CSplashScreen dialog - - -CSplashScreen::CSplashScreen(CWnd* pParent /*=NULL*/) - : CDialog(CSplashScreen::IDD, pParent) -{ - //{{AFX_DATA_INIT(CSplashScreen) - m_load_list = _T(""); - //}}AFX_DATA_INIT -} - - -void CSplashScreen::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CSplashScreen) - DDX_Text(pDX, IDC_LOAD_GEORGES, m_load_list); - //}}AFX_DATA_MAP -} - -void CSplashScreen::addLine(std::string newLine) -{ - m_load_list=m_load_list+"\n"+newLine.c_str(); - UpdateData(false); - ShowWindow(true); - RedrawWindow(); -} -void CSplashScreen::close() -{ - OnClose(); -} - -void CSplashScreen::progress (float progressValue) -{ - MSG msg; - while ( PeekMessage(&msg,NULL,0,0,PM_REMOVE) ) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - -} - -BEGIN_MESSAGE_MAP(CSplashScreen, CDialog) - //{{AFX_MSG_MAP(CSplashScreen) - // NOTE: the ClassWizard will add message map macros here - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CSplashScreen message handlers +// 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 . + +// splash_screen.cpp : implementation file +// + +#include "stdafx.h" +#include "splash_screen.h" +#include + +using namespace std; + +///////////////////////////////////////////////////////////////////////////// +// CSplashScreen dialog + + +CSplashScreen::CSplashScreen(CWnd* pParent /*=NULL*/) + : CDialog(CSplashScreen::IDD, pParent) +{ + //{{AFX_DATA_INIT(CSplashScreen) + m_load_list = _T(""); + //}}AFX_DATA_INIT +} + + +void CSplashScreen::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CSplashScreen) + DDX_Text(pDX, IDC_LOAD_GEORGES, m_load_list); + //}}AFX_DATA_MAP +} + +void CSplashScreen::addLine(std::string newLine) +{ + m_load_list=m_load_list+"\n"+newLine.c_str(); + UpdateData(false); + ShowWindow(true); + RedrawWindow(); +} +void CSplashScreen::close() +{ + OnClose(); +} + +void CSplashScreen::progress (float progressValue) +{ + MSG msg; + while ( PeekMessage(&msg,NULL,0,0,PM_REMOVE) ) + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + +} + +BEGIN_MESSAGE_MAP(CSplashScreen, CDialog) + //{{AFX_MSG_MAP(CSplashScreen) + // NOTE: the ClassWizard will add message map macros here + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CSplashScreen message handlers diff --git a/code/ryzom/tools/leveldesign/georges_dll/splash_screen.h b/code/ryzom/tools/leveldesign/georges_dll/splash_screen.h index 833dbee04..80e8dedea 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/splash_screen.h +++ b/code/ryzom/tools/leveldesign/georges_dll/splash_screen.h @@ -1,66 +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 . - -#if !defined(AFX_SPLASHSCREEN_H__9CC775DA_1173_415D_AC2C_D3CDF05265F6__INCLUDED_) -#define AFX_SPLASHSCREEN_H__9CC775DA_1173_415D_AC2C_D3CDF05265F6__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// splash_screen.h : header file -// -#include "resource.h" -#include "nel/misc/progress_callback.h" -///////////////////////////////////////////////////////////////////////////// -// CSplashScreen dialog - -class CSplashScreen : public CDialog, public NLMISC::IProgressCallback -{ -// Construction -public: - CSplashScreen(CWnd* pParent = NULL); // standard constructor - -// Dialog Data - //{{AFX_DATA(CSplashScreen) - enum { IDD = IDD_SPLASHSCREEN }; - CString m_load_list; - //}}AFX_DATA - - virtual void progress (float progressValue); - void addLine(std::string newLine); - void close(); -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CSplashScreen) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CSplashScreen) - // NOTE: the ClassWizard will add member functions here - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_SPLASHSCREEN_H__9CC775DA_1173_415D_AC2C_D3CDF05265F6__INCLUDED_) +// 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 . + +#if !defined(AFX_SPLASHSCREEN_H__9CC775DA_1173_415D_AC2C_D3CDF05265F6__INCLUDED_) +#define AFX_SPLASHSCREEN_H__9CC775DA_1173_415D_AC2C_D3CDF05265F6__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// splash_screen.h : header file +// +#include "resource.h" +#include "nel/misc/progress_callback.h" +///////////////////////////////////////////////////////////////////////////// +// CSplashScreen dialog + +class CSplashScreen : public CDialog, public NLMISC::IProgressCallback +{ +// Construction +public: + CSplashScreen(CWnd* pParent = NULL); // standard constructor + +// Dialog Data + //{{AFX_DATA(CSplashScreen) + enum { IDD = IDD_SPLASHSCREEN }; + CString m_load_list; + //}}AFX_DATA + + virtual void progress (float progressValue); + void addLine(std::string newLine); + void close(); +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CSplashScreen) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CSplashScreen) + // NOTE: the ClassWizard will add member functions here + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_SPLASHSCREEN_H__9CC775DA_1173_415D_AC2C_D3CDF05265F6__INCLUDED_) diff --git a/code/ryzom/tools/leveldesign/georges_dll/stdafx.cpp b/code/ryzom/tools/leveldesign/georges_dll/stdafx.cpp index 8b94d0f68..d4850a5aa 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/stdafx.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/stdafx.cpp @@ -1,24 +1,24 @@ -// 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 . - -// stdafx.cpp : source file that includes just the standard includes -// georges_edit.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - - -void foo_std_afx_to_remove_warning() {}; +// 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 . + +// stdafx.cpp : source file that includes just the standard includes +// georges_edit.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + + +void foo_std_afx_to_remove_warning() {}; diff --git a/code/ryzom/tools/leveldesign/georges_dll/stdafx.h b/code/ryzom/tools/leveldesign/georges_dll/stdafx.h index 2837a238f..b5d7d2705 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/stdafx.h +++ b/code/ryzom/tools/leveldesign/georges_dll/stdafx.h @@ -1,58 +1,58 @@ -// 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 . -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#if !defined(AFX_STDAFX_H__4D897A7F_434F_441C_BA18_AC9BC59734EE__INCLUDED_) -#define AFX_STDAFX_H__4D897A7F_434F_441C_BA18_AC9BC59734EE__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#define NOMINMAX -#define _WIN32_WINNT 0x0500 - -#include // MFC core and standard components -#include // MFC extensions -#include -#include // MFC support for Internet Explorer 4 Common Controls -#include -#include -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#include -#include -#include -#include -#include - -#include "nel/misc/types_nl.h" -#include "nel/misc/debug.h" -#include "nel/misc/common.h" - -// Include from libxml2 -#include - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__4D897A7F_434F_441C_BA18_AC9BC59734EE__INCLUDED_) +// 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 . +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__4D897A7F_434F_441C_BA18_AC9BC59734EE__INCLUDED_) +#define AFX_STDAFX_H__4D897A7F_434F_441C_BA18_AC9BC59734EE__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +#define NOMINMAX +#define _WIN32_WINNT 0x0500 + +#include // MFC core and standard components +#include // MFC extensions +#include +#include // MFC support for Internet Explorer 4 Common Controls +#include +#include +#ifndef _AFX_NO_AFXCMN_SUPPORT +#include // MFC support for Windows Common Controls +#endif // _AFX_NO_AFXCMN_SUPPORT + +#include +#include +#include +#include +#include + +#include "nel/misc/types_nl.h" +#include "nel/misc/debug.h" +#include "nel/misc/common.h" + +// Include from libxml2 +#include + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__4D897A7F_434F_441C_BA18_AC9BC59734EE__INCLUDED_) diff --git a/code/ryzom/tools/leveldesign/georges_dll/type_dialog.cpp b/code/ryzom/tools/leveldesign/georges_dll/type_dialog.cpp index 8aeb531aa..f03347654 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/type_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_dll/type_dialog.cpp @@ -1,607 +1,607 @@ -// 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 . - -// type_dialog.cpp : implementation file -// - -#include "stdafx.h" -#include "georges_edit.h" -#include "georges_edit_view.h" -#include "georges_edit_doc.h" -#include "type_dialog.h" -#include "action.h" -#include "left_view.h" - -#include "nel/georges/type.h" - -using namespace std; -using namespace NLMISC; -using namespace NLGEORGES; - -///////////////////////////////////////////////////////////////////////////// -// CTypeDialog dialog - - -CTypeDialog::CTypeDialog () : CBaseDialog (IDR_MAINFRAME) -{ - //{{AFX_DATA_INIT(CTypeDialog) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT - View = NULL; -} - - -void CTypeDialog::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CTypeDialog) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(CTypeDialog, CDialog) - //{{AFX_MSG_MAP(CTypeDialog) - ON_WM_SIZE() - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CTypeDialog message handlers - -void CTypeDialog::OnSize(UINT nType, int cx, int cy) -{ - CBaseDialog::OnSize(nType, cx, cy); - - // TODO: Add your message handler code here - -} - -BOOL CTypeDialog::OnInitDialog() -{ - CBaseDialog::OnInitDialog(); - - RECT viewRect; - View->GetClientRect (&viewRect); - uint virtualWidth = std::max ((uint)MinViewWidth, (uint)(viewRect.right-viewRect.left)); - - // Refresh sizes - CBaseDialog::resizeWidgets (virtualWidth, 0); - - // Get first item coordinate - RECT currentPos; - RECT pos; - getFirstItemPos (currentPos); - - // Create the type combo - setStaticSize (currentPos); - LabelType.Create ("Type:", WS_VISIBLE, currentPos, this); - initWidget (LabelType); - getNextPosLabel (currentPos); - - setComboSize (currentPos, SmallWidget); - pos = currentPos; - adjusteComboSize (pos); - ComboType.Create (WS_VISIBLE|CBS_DROPDOWNLIST|WS_TABSTOP, pos, this, CbType); - - // Insert type string - uint item; - ComboType.ResetContent (); - for (item=0; itemGetClientRect (&viewRect); - uint virtualWidth = std::max ((uint)MinViewWidth, (uint)(viewRect.right-viewRect.left)); - - // Refresh sizes - CBaseDialog::resizeWidgets (virtualWidth, 0); - - // Get first item coordinate - RECT currentPos; - getFirstItemPos (currentPos); - setStaticSize (currentPos); - getNextPosLabel (currentPos); - setComboSize (currentPos, SmallWidget); - getNextPos (currentPos); - setStaticSize (currentPos); - getNextPosLabel (currentPos); - setComboSize (currentPos, SmallWidget); - getNextPos (currentPos); - setStaticSize (currentPos); - getNextPosLabel (currentPos); - setComboSize (currentPos, SmallWidget); - getNextPos (currentPos); - setStaticSize (currentPos); - getNextPosLabel (currentPos); - setComboSize (currentPos, SmallWidget); - getNextPos (currentPos); - setStaticSize (currentPos); - getNextPosLabel (currentPos); - setComboSize (currentPos, SmallWidget); - getNextPos (currentPos); - setStaticSize (currentPos); - getNextPosLabel (currentPos); - setComboSize (currentPos, SmallWidget); - getNextPos (currentPos); - setStaticSize (currentPos); - getNextPosLabel (currentPos); - setComboSize (currentPos, SmallWidget); - - getNextColumn (currentPos); - setStaticSize (currentPos); - getNextPosLabel (currentPos); - setListSize (currentPos, SmallWidgetNotLimited, 250); - getNextPos (currentPos); - - // Refresh sizes - CBaseDialog::resizeWidgets (virtualWidth, currentPos.bottom); - - getFirstItemPos (currentPos); - - // Create the type combo - setStaticSize (currentPos); - LabelType.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - getNextPosLabel (currentPos); - - setComboSize (currentPos, SmallWidget); - RECT pos = currentPos; - adjusteComboSize (pos); - ComboType.SetWindowPos (NULL, pos.left, pos.top, pos.right - pos.left, - pos.bottom - pos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - getNextPos (currentPos); - - // Create the type combo - setStaticSize (currentPos); - LabelUIType.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - getNextPosLabel (currentPos); - - setComboSize (currentPos, SmallWidget); - pos = currentPos; - adjusteComboSize (pos); - ComboUIType.SetWindowPos (NULL, pos.left, pos.top, pos.right - pos.left, - pos.bottom - pos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - getNextPos (currentPos); - - // Default value - setStaticSize (currentPos); - LabelDefault.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - getNextPosLabel (currentPos); - - setComboSize (currentPos, SmallWidget); - Default.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - getNextPos (currentPos); - - // Min value - setStaticSize (currentPos); - LabelMin.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - getNextPosLabel (currentPos); - - setComboSize (currentPos, SmallWidget); - Min.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - getNextPos (currentPos); - - // Max value - setStaticSize (currentPos); - LabelMax.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - getNextPosLabel (currentPos); - - setComboSize (currentPos, SmallWidget); - Max.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - getNextPos (currentPos); - - // Increment value - setStaticSize (currentPos); - LabelIncrement.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - getNextPosLabel (currentPos); - - setComboSize (currentPos, SmallWidget); - Increment.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - getNextColumn (currentPos); - - // Predef list value - setStaticSize (currentPos); - LabelPreDef.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - getNextPosLabel (currentPos); - - setListSize (currentPos, SmallWidgetNotLimited, 250 + AdjusteHeight); - Predef.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, - currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); - Predef.recalcColumn (); - getNextPos (currentPos); - - // Resize the current view - View->setViewSize ( - virtualWidth, - currentPos.bottom+CGeorgesEditView::WidgetTopMargin+CGeorgesEditView::WidgetBottomMargin); -} - -void CTypeDialog::OnOK () -{ - Predef.onOK (); - if (Default.haveFocus ()) - Default.onOK (); - if (Min.haveFocus ()) - Min.onOK (); - if (Max.haveFocus ()) - Max.onOK (); - if (Increment.haveFocus ()) - Increment.onOK (); -} - -void CTypeDialog::OnCancel () -{ - Predef.onCancel (); -} - -void CTypeDialog::getFromDocument (const NLGEORGES::CType &type) -{ - if (View) - { - uint item; - - // Insert type string - ComboType.ResetContent (); - for (item=0; itemGetDocument (); - if (doc) - { - CGeorgesEditDocSub *current = doc->getSelectedObject (); - - doc->modify (new CActionString (IAction::TypeType, toString (ComboType.GetCurSel ()).c_str (), *doc, - "", "", doc->getLeftView ()->getCurrentSelectionId (), 0)); - } -} - -void CTypeDialog::setUIToDocument () -{ - CGeorgesEditDoc *doc = View->GetDocument (); - if (doc) - { - CGeorgesEditDocSub *current = doc->getSelectedObject (); - int curSel = ComboUIType.GetCurSel (); - if (curSel != CB_ERR) - { - curSel = (CType::TUI)ComboUIType.GetItemData (curSel); - } - else - { - curSel = CType::Edit; - } - - doc->modify (new CActionString (IAction::TypeUI, toString (curSel).c_str (), *doc, "", "", - doc->getLeftView ()->getCurrentSelectionId (), 0)); - } -} - -void CTypeDialog::setDefaultToDocument () -{ - CGeorgesEditDoc *doc = View->GetDocument (); - if (doc) - { - CGeorgesEditDocSub *current = doc->getSelectedObject (); - if (current) - { - CString str; - - Default.UpdateData (); - Default.GetWindowText (str); - - doc->modify (new CActionString (IAction::TypeDefault, str, *doc, "", "", - doc->getLeftView ()->getCurrentSelectionId (), 0)); - } - } -} - -void CTypeDialog::setMinToDocument () -{ - CGeorgesEditDoc *doc = View->GetDocument (); - if (doc) - { - CGeorgesEditDocSub *current = doc->getSelectedObject (); - if (current) - { - CString str; - - Min.UpdateData (); - Min.GetWindowText (str); - - doc->modify (new CActionString (IAction::TypeMin, str, *doc, "", "", - doc->getLeftView ()->getCurrentSelectionId (), 0)); - } - } -} - -void CTypeDialog::setMaxToDocument () -{ - CGeorgesEditDoc *doc = View->GetDocument (); - if (doc) - { - CGeorgesEditDocSub *current = doc->getSelectedObject (); - CString str; - - Max.UpdateData (); - Max.GetWindowText (str); - - doc->modify (new CActionString (IAction::TypeMax, str, *doc, "", "", - doc->getLeftView ()->getCurrentSelectionId (), 0)); - } -} - -void CTypeDialog::setIncrementToDocument () -{ - CGeorgesEditDoc *doc = View->GetDocument (); - if (doc) - { - CGeorgesEditDocSub *current = doc->getSelectedObject (); - CString str; - - Increment.UpdateData (); - Increment.GetWindowText (str); - - doc->modify (new CActionString (IAction::TypeIncrement, str, *doc, "", "", - doc->getLeftView ()->getCurrentSelectionId (), 0)); - } -} - -void CTypeDialog::setPredefToDocument () -{ - CGeorgesEditDoc *doc = View->GetDocument (); - if (doc) - { - CGeorgesEditDocSub *current = doc->getSelectedObject (); - CString str; - - // Add the predef - vector > stringVector; - stringVector.resize (Predef.ListCtrl.GetItemCount()); - uint predef; - for (predef=0; predef<(uint)Predef.ListCtrl.GetItemCount(); predef++) - { - stringVector[predef].resize (2); - - // Add the label and value - str = Predef.ListCtrl.GetItemText (predef, 0); - stringVector[predef][0] = (const char*)str; - str = Predef.ListCtrl.GetItemText (predef, 1); - stringVector[predef][1] = (const char*)str; - } - - doc->modify (new CActionStringVectorVector (IAction::TypePredef, stringVector, *doc, - doc->getLeftView ()->getCurrentSelectionId (), 0)); - } -} - -BOOL CTypeDialog::OnCommand(WPARAM wParam, LPARAM lParam) -{ - switch (HIWORD(wParam)) - { - case CBN_SELCHANGE: - { - // identifier - switch (LOWORD(wParam)) - { - case CbType: - setTypeToDocument (); - break; - case CbUI: - setUIToDocument (); - break; - } - } - break; - } - - return CWnd::OnCommand(wParam, lParam); -} - -LRESULT CTypeDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case LC_CHANGE: - setPredefToDocument (); - break; - case MC_STRINGCHANGE: - { - // identifier - switch (LOWORD(wParam)) - { - case EdDefault: - setDefaultToDocument (); - break; - case EdMin: - setMinToDocument (); - break; - case EdMax: - setMaxToDocument (); - break; - case EdIncrement: - setIncrementToDocument (); - break; - } - } - break; - } - - return CDialog::WindowProc(message, wParam, lParam); -} - -void CTypeDialog::onLastFocus () -{ - View->setFocusLeftView (); -} - -void CTypeDialog::onFirstFocus () -{ - View->SetFocus (); -} - -CEditListCtrl::TItemEdit CTypeParentEditListCtrl::getItemEditMode (uint item, uint subItem) -{ - return CEditListCtrl::EditMemCombo; -} - -void CTypeParentEditListCtrl::getMemComboBoxProp (uint item, uint subItem, std::string ®Adr, bool &browse) -{ - browse = false; - if (subItem == 0) - regAdr = GEORGES_EDIT_BASE_REG_KEY"\\Type Label MemCombo"; - else - regAdr = GEORGES_EDIT_BASE_REG_KEY"\\Type Name MemCombo"; -} +// 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 . + +// type_dialog.cpp : implementation file +// + +#include "stdafx.h" +#include "georges_edit.h" +#include "georges_edit_view.h" +#include "georges_edit_doc.h" +#include "type_dialog.h" +#include "action.h" +#include "left_view.h" + +#include "nel/georges/type.h" + +using namespace std; +using namespace NLMISC; +using namespace NLGEORGES; + +///////////////////////////////////////////////////////////////////////////// +// CTypeDialog dialog + + +CTypeDialog::CTypeDialog () : CBaseDialog (IDR_MAINFRAME) +{ + //{{AFX_DATA_INIT(CTypeDialog) + // NOTE: the ClassWizard will add member initialization here + //}}AFX_DATA_INIT + View = NULL; +} + + +void CTypeDialog::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CTypeDialog) + // NOTE: the ClassWizard will add DDX and DDV calls here + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CTypeDialog, CDialog) + //{{AFX_MSG_MAP(CTypeDialog) + ON_WM_SIZE() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CTypeDialog message handlers + +void CTypeDialog::OnSize(UINT nType, int cx, int cy) +{ + CBaseDialog::OnSize(nType, cx, cy); + + // TODO: Add your message handler code here + +} + +BOOL CTypeDialog::OnInitDialog() +{ + CBaseDialog::OnInitDialog(); + + RECT viewRect; + View->GetClientRect (&viewRect); + uint virtualWidth = std::max ((uint)MinViewWidth, (uint)(viewRect.right-viewRect.left)); + + // Refresh sizes + CBaseDialog::resizeWidgets (virtualWidth, 0); + + // Get first item coordinate + RECT currentPos; + RECT pos; + getFirstItemPos (currentPos); + + // Create the type combo + setStaticSize (currentPos); + LabelType.Create ("Type:", WS_VISIBLE, currentPos, this); + initWidget (LabelType); + getNextPosLabel (currentPos); + + setComboSize (currentPos, SmallWidget); + pos = currentPos; + adjusteComboSize (pos); + ComboType.Create (WS_VISIBLE|CBS_DROPDOWNLIST|WS_TABSTOP, pos, this, CbType); + + // Insert type string + uint item; + ComboType.ResetContent (); + for (item=0; itemGetClientRect (&viewRect); + uint virtualWidth = std::max ((uint)MinViewWidth, (uint)(viewRect.right-viewRect.left)); + + // Refresh sizes + CBaseDialog::resizeWidgets (virtualWidth, 0); + + // Get first item coordinate + RECT currentPos; + getFirstItemPos (currentPos); + setStaticSize (currentPos); + getNextPosLabel (currentPos); + setComboSize (currentPos, SmallWidget); + getNextPos (currentPos); + setStaticSize (currentPos); + getNextPosLabel (currentPos); + setComboSize (currentPos, SmallWidget); + getNextPos (currentPos); + setStaticSize (currentPos); + getNextPosLabel (currentPos); + setComboSize (currentPos, SmallWidget); + getNextPos (currentPos); + setStaticSize (currentPos); + getNextPosLabel (currentPos); + setComboSize (currentPos, SmallWidget); + getNextPos (currentPos); + setStaticSize (currentPos); + getNextPosLabel (currentPos); + setComboSize (currentPos, SmallWidget); + getNextPos (currentPos); + setStaticSize (currentPos); + getNextPosLabel (currentPos); + setComboSize (currentPos, SmallWidget); + getNextPos (currentPos); + setStaticSize (currentPos); + getNextPosLabel (currentPos); + setComboSize (currentPos, SmallWidget); + + getNextColumn (currentPos); + setStaticSize (currentPos); + getNextPosLabel (currentPos); + setListSize (currentPos, SmallWidgetNotLimited, 250); + getNextPos (currentPos); + + // Refresh sizes + CBaseDialog::resizeWidgets (virtualWidth, currentPos.bottom); + + getFirstItemPos (currentPos); + + // Create the type combo + setStaticSize (currentPos); + LabelType.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + getNextPosLabel (currentPos); + + setComboSize (currentPos, SmallWidget); + RECT pos = currentPos; + adjusteComboSize (pos); + ComboType.SetWindowPos (NULL, pos.left, pos.top, pos.right - pos.left, + pos.bottom - pos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + getNextPos (currentPos); + + // Create the type combo + setStaticSize (currentPos); + LabelUIType.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + getNextPosLabel (currentPos); + + setComboSize (currentPos, SmallWidget); + pos = currentPos; + adjusteComboSize (pos); + ComboUIType.SetWindowPos (NULL, pos.left, pos.top, pos.right - pos.left, + pos.bottom - pos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + getNextPos (currentPos); + + // Default value + setStaticSize (currentPos); + LabelDefault.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + getNextPosLabel (currentPos); + + setComboSize (currentPos, SmallWidget); + Default.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + getNextPos (currentPos); + + // Min value + setStaticSize (currentPos); + LabelMin.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + getNextPosLabel (currentPos); + + setComboSize (currentPos, SmallWidget); + Min.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + getNextPos (currentPos); + + // Max value + setStaticSize (currentPos); + LabelMax.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + getNextPosLabel (currentPos); + + setComboSize (currentPos, SmallWidget); + Max.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + getNextPos (currentPos); + + // Increment value + setStaticSize (currentPos); + LabelIncrement.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + getNextPosLabel (currentPos); + + setComboSize (currentPos, SmallWidget); + Increment.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + getNextColumn (currentPos); + + // Predef list value + setStaticSize (currentPos); + LabelPreDef.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + getNextPosLabel (currentPos); + + setListSize (currentPos, SmallWidgetNotLimited, 250 + AdjusteHeight); + Predef.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left, + currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER); + Predef.recalcColumn (); + getNextPos (currentPos); + + // Resize the current view + View->setViewSize ( + virtualWidth, + currentPos.bottom+CGeorgesEditView::WidgetTopMargin+CGeorgesEditView::WidgetBottomMargin); +} + +void CTypeDialog::OnOK () +{ + Predef.onOK (); + if (Default.haveFocus ()) + Default.onOK (); + if (Min.haveFocus ()) + Min.onOK (); + if (Max.haveFocus ()) + Max.onOK (); + if (Increment.haveFocus ()) + Increment.onOK (); +} + +void CTypeDialog::OnCancel () +{ + Predef.onCancel (); +} + +void CTypeDialog::getFromDocument (const NLGEORGES::CType &type) +{ + if (View) + { + uint item; + + // Insert type string + ComboType.ResetContent (); + for (item=0; itemGetDocument (); + if (doc) + { + CGeorgesEditDocSub *current = doc->getSelectedObject (); + + doc->modify (new CActionString (IAction::TypeType, toString (ComboType.GetCurSel ()).c_str (), *doc, + "", "", doc->getLeftView ()->getCurrentSelectionId (), 0)); + } +} + +void CTypeDialog::setUIToDocument () +{ + CGeorgesEditDoc *doc = View->GetDocument (); + if (doc) + { + CGeorgesEditDocSub *current = doc->getSelectedObject (); + int curSel = ComboUIType.GetCurSel (); + if (curSel != CB_ERR) + { + curSel = (CType::TUI)ComboUIType.GetItemData (curSel); + } + else + { + curSel = CType::Edit; + } + + doc->modify (new CActionString (IAction::TypeUI, toString (curSel).c_str (), *doc, "", "", + doc->getLeftView ()->getCurrentSelectionId (), 0)); + } +} + +void CTypeDialog::setDefaultToDocument () +{ + CGeorgesEditDoc *doc = View->GetDocument (); + if (doc) + { + CGeorgesEditDocSub *current = doc->getSelectedObject (); + if (current) + { + CString str; + + Default.UpdateData (); + Default.GetWindowText (str); + + doc->modify (new CActionString (IAction::TypeDefault, str, *doc, "", "", + doc->getLeftView ()->getCurrentSelectionId (), 0)); + } + } +} + +void CTypeDialog::setMinToDocument () +{ + CGeorgesEditDoc *doc = View->GetDocument (); + if (doc) + { + CGeorgesEditDocSub *current = doc->getSelectedObject (); + if (current) + { + CString str; + + Min.UpdateData (); + Min.GetWindowText (str); + + doc->modify (new CActionString (IAction::TypeMin, str, *doc, "", "", + doc->getLeftView ()->getCurrentSelectionId (), 0)); + } + } +} + +void CTypeDialog::setMaxToDocument () +{ + CGeorgesEditDoc *doc = View->GetDocument (); + if (doc) + { + CGeorgesEditDocSub *current = doc->getSelectedObject (); + CString str; + + Max.UpdateData (); + Max.GetWindowText (str); + + doc->modify (new CActionString (IAction::TypeMax, str, *doc, "", "", + doc->getLeftView ()->getCurrentSelectionId (), 0)); + } +} + +void CTypeDialog::setIncrementToDocument () +{ + CGeorgesEditDoc *doc = View->GetDocument (); + if (doc) + { + CGeorgesEditDocSub *current = doc->getSelectedObject (); + CString str; + + Increment.UpdateData (); + Increment.GetWindowText (str); + + doc->modify (new CActionString (IAction::TypeIncrement, str, *doc, "", "", + doc->getLeftView ()->getCurrentSelectionId (), 0)); + } +} + +void CTypeDialog::setPredefToDocument () +{ + CGeorgesEditDoc *doc = View->GetDocument (); + if (doc) + { + CGeorgesEditDocSub *current = doc->getSelectedObject (); + CString str; + + // Add the predef + vector > stringVector; + stringVector.resize (Predef.ListCtrl.GetItemCount()); + uint predef; + for (predef=0; predef<(uint)Predef.ListCtrl.GetItemCount(); predef++) + { + stringVector[predef].resize (2); + + // Add the label and value + str = Predef.ListCtrl.GetItemText (predef, 0); + stringVector[predef][0] = (const char*)str; + str = Predef.ListCtrl.GetItemText (predef, 1); + stringVector[predef][1] = (const char*)str; + } + + doc->modify (new CActionStringVectorVector (IAction::TypePredef, stringVector, *doc, + doc->getLeftView ()->getCurrentSelectionId (), 0)); + } +} + +BOOL CTypeDialog::OnCommand(WPARAM wParam, LPARAM lParam) +{ + switch (HIWORD(wParam)) + { + case CBN_SELCHANGE: + { + // identifier + switch (LOWORD(wParam)) + { + case CbType: + setTypeToDocument (); + break; + case CbUI: + setUIToDocument (); + break; + } + } + break; + } + + return CWnd::OnCommand(wParam, lParam); +} + +LRESULT CTypeDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) +{ + switch (message) + { + case LC_CHANGE: + setPredefToDocument (); + break; + case MC_STRINGCHANGE: + { + // identifier + switch (LOWORD(wParam)) + { + case EdDefault: + setDefaultToDocument (); + break; + case EdMin: + setMinToDocument (); + break; + case EdMax: + setMaxToDocument (); + break; + case EdIncrement: + setIncrementToDocument (); + break; + } + } + break; + } + + return CDialog::WindowProc(message, wParam, lParam); +} + +void CTypeDialog::onLastFocus () +{ + View->setFocusLeftView (); +} + +void CTypeDialog::onFirstFocus () +{ + View->SetFocus (); +} + +CEditListCtrl::TItemEdit CTypeParentEditListCtrl::getItemEditMode (uint item, uint subItem) +{ + return CEditListCtrl::EditMemCombo; +} + +void CTypeParentEditListCtrl::getMemComboBoxProp (uint item, uint subItem, std::string ®Adr, bool &browse) +{ + browse = false; + if (subItem == 0) + regAdr = GEORGES_EDIT_BASE_REG_KEY"\\Type Label MemCombo"; + else + regAdr = GEORGES_EDIT_BASE_REG_KEY"\\Type Name MemCombo"; +} diff --git a/code/ryzom/tools/leveldesign/georges_dll/type_dialog.h b/code/ryzom/tools/leveldesign/georges_dll/type_dialog.h index d5f14d3e3..7e860ed9b 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/type_dialog.h +++ b/code/ryzom/tools/leveldesign/georges_dll/type_dialog.h @@ -1,129 +1,129 @@ -// 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 . - -#if !defined(AFX_TYPE_DIALOG_H__435B6164_470D_4E08_B45C_BD23965563A9__INCLUDED_) -#define AFX_TYPE_DIALOG_H__435B6164_470D_4E08_B45C_BD23965563A9__INCLUDED_ - -#include "base_dialog.h" -#include "edit_list_ctrl.h" - -#include "nel/georges/type.h" - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// type_dialog.h : header file -// - -class CGeorgesEditView; - -class CTypeParentEditListCtrl : public CEditListCtrl -{ - CEditListCtrl::TItemEdit getItemEditMode (uint item, uint subItem); - void getMemComboBoxProp (uint item, uint subItem, std::string ®Adr, bool &browse); -public: - class CTypeDialog *Dialog; -}; - -///////////////////////////////////////////////////////////////////////////// -// CTypeDialog dialog - -class CTypeDialog : public CBaseDialog -{ -// Construction -public: - CTypeDialog (); // standard constructor - - enum - { - TypeCombo= 100, - }; - - enum - { - CbType = 1, - CbUI, - EdDefault, - EdMin, - EdMax, - EdIncrement, - LtPredef - }; - - // The widgets - CStatic LabelType; - CComboBox ComboType; - CStatic LabelUIType; - CComboBox ComboUIType; - CStatic LabelDefault; - CMemoryComboBox Default; - CStatic LabelMin; - CMemoryComboBox Min; - CStatic LabelMax; - CMemoryComboBox Max; - CStatic LabelIncrement; - CMemoryComboBox Increment; - CStatic LabelPreDef; - CTypeParentEditListCtrl Predef; - // CListCtrl Max; - - // From CBaseDialog - void onFirstFocus (); - void onLastFocus (); - - // From CDialog - virtual void OnOK (); - virtual void OnCancel (); - - // Get from document, update rightview UI - void getFromDocument (const NLGEORGES::CType &type); - - // Set to document, update document with rightview UI - void setTypeToDocument (); - void setUIToDocument (); - void setDefaultToDocument (); - void setMinToDocument (); - void setMaxToDocument (); - void setIncrementToDocument (); - void setPredefToDocument (); - - // Resize widget callback - void resizeWidgets (); - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CTypeDialog) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam); - virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(CTypeDialog) - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_TYPE_DIALOG_H__435B6164_470D_4E08_B45C_BD23965563A9__INCLUDED_) +// 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 . + +#if !defined(AFX_TYPE_DIALOG_H__435B6164_470D_4E08_B45C_BD23965563A9__INCLUDED_) +#define AFX_TYPE_DIALOG_H__435B6164_470D_4E08_B45C_BD23965563A9__INCLUDED_ + +#include "base_dialog.h" +#include "edit_list_ctrl.h" + +#include "nel/georges/type.h" + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// type_dialog.h : header file +// + +class CGeorgesEditView; + +class CTypeParentEditListCtrl : public CEditListCtrl +{ + CEditListCtrl::TItemEdit getItemEditMode (uint item, uint subItem); + void getMemComboBoxProp (uint item, uint subItem, std::string ®Adr, bool &browse); +public: + class CTypeDialog *Dialog; +}; + +///////////////////////////////////////////////////////////////////////////// +// CTypeDialog dialog + +class CTypeDialog : public CBaseDialog +{ +// Construction +public: + CTypeDialog (); // standard constructor + + enum + { + TypeCombo= 100, + }; + + enum + { + CbType = 1, + CbUI, + EdDefault, + EdMin, + EdMax, + EdIncrement, + LtPredef + }; + + // The widgets + CStatic LabelType; + CComboBox ComboType; + CStatic LabelUIType; + CComboBox ComboUIType; + CStatic LabelDefault; + CMemoryComboBox Default; + CStatic LabelMin; + CMemoryComboBox Min; + CStatic LabelMax; + CMemoryComboBox Max; + CStatic LabelIncrement; + CMemoryComboBox Increment; + CStatic LabelPreDef; + CTypeParentEditListCtrl Predef; + // CListCtrl Max; + + // From CBaseDialog + void onFirstFocus (); + void onLastFocus (); + + // From CDialog + virtual void OnOK (); + virtual void OnCancel (); + + // Get from document, update rightview UI + void getFromDocument (const NLGEORGES::CType &type); + + // Set to document, update document with rightview UI + void setTypeToDocument (); + void setUIToDocument (); + void setDefaultToDocument (); + void setMinToDocument (); + void setMaxToDocument (); + void setIncrementToDocument (); + void setPredefToDocument (); + + // Resize widget callback + void resizeWidgets (); + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CTypeDialog) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam); + virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(CTypeDialog) + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_TYPE_DIALOG_H__435B6164_470D_4E08_B45C_BD23965563A9__INCLUDED_) diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/CMakeLists.txt b/code/ryzom/tools/leveldesign/georges_editor_qt/CMakeLists.txt index 0354cbeeb..985b00cf9 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/CMakeLists.txt +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/CMakeLists.txt @@ -1,19 +1,19 @@ -#----------------------------------------------------------------------------- -# -# Georges Editor Qt -# Copyright (C) 2010 Adrian Jäkel -# -#----------------------------------------------------------------------------- - -# This tells the application(s) where to find the installed data. -ADD_DEFINITIONS(-DDATA_DIR="\\"${NL_SHARE_PREFIX}/georges_editor_qt/\\"") - -ADD_SUBDIRECTORY(src) - -INSTALL(DIRECTORY data/ - DESTINATION share/georges_editor_qt/data - COMPONENT data - PATTERN "CVS" EXCLUDE - PATTERN ".svn" EXCLUDE - PATTERN "Makefile*" EXCLUDE) - +#----------------------------------------------------------------------------- +# +# Georges Editor Qt +# Copyright (C) 2010 Adrian Jäkel +# +#----------------------------------------------------------------------------- + +# This tells the application(s) where to find the installed data. +ADD_DEFINITIONS(-DDATA_DIR="\\"${NL_SHARE_PREFIX}/georges_editor_qt/\\"") + +ADD_SUBDIRECTORY(src) + +INSTALL(DIRECTORY data/ + DESTINATION share/georges_editor_qt/data + COMPONENT data + PATTERN "CVS" EXCLUDE + PATTERN ".svn" EXCLUDE + PATTERN "Makefile*" EXCLUDE) + diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/completer_line_edit.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/completer_line_edit.cpp index abb7b09c7..0adb02268 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/completer_line_edit.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/completer_line_edit.cpp @@ -1,150 +1,150 @@ - - -#include "completer_line_edit.h" - -#include -#include -#include -#include -#include -#include - -CompleteLineEdit::CompleteLineEdit(QWidget *parent, QStringList words) - : QLineEdit(parent), _words(words) -{ - listView = new QListView(this); - model = new QStringListModel(this); - listView->setModel(model); - listView->setWindowFlags(Qt::ToolTip); - listView->setUniformItemSizes(true); - - connect(this, SIGNAL(textChanged(const QString &)), this, SLOT(setCompleter(const QString &))); - connect(listView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(completeText(const QModelIndex &))); -} - -void CompleteLineEdit::setStringList(QStringList list) -{ - _words = list; -} - -//void CompleteLineEdit::focusOutEvent(QFocusEvent *e) -//{ -// listView->hide(); -//} - -void CompleteLineEdit::keyPressEvent(QKeyEvent *e) -{ - if (!listView->isHidden()) - { - int key = e->key(); - int count = listView->model()->rowCount(); - QModelIndex currentIndex = listView->currentIndex(); - - if (Qt::Key_Down == key) - { - int row = currentIndex.row() + 1; - if (row >= count) - { - row = 0; - } - - QModelIndex index = listView->model()->index(row, 0); - listView->setCurrentIndex(index); - } - else if (Qt::Key_Up == key) - { - int row = currentIndex.row() - 1; - if (row < 0) - { - row = count - 1; - } - - QModelIndex index = listView->model()->index(row, 0); - listView->setCurrentIndex(index); - } - else if (Qt::Key_Escape == key) - { - listView->hide(); - } - else if (Qt::Key_Enter == key || Qt::Key_Return == key) - { - if (currentIndex.isValid()) - { - QString text = listView->currentIndex().data().toString(); - setText(text); - } - - listView->hide(); - } - else - { - //listView->hide(); - QLineEdit::keyPressEvent(e); - } - } - else - { - QLineEdit::keyPressEvent(e); - } -} - -void CompleteLineEdit::setCompleter(const QString &text) -{ - if (text.isEmpty()) - { - listView->hide(); - return; - } - - if ((text.length() > 1) && (!listView->isHidden())) - { - //return; - } - - QStringList sl; - Q_FOREACH(QString word, _words) - { - if (word.contains(text)) - { - sl << word; - } - } - - if (sl.isEmpty()) - { - if (_words.isEmpty()) - { - setText(tr("No files found")); - setEnabled(false); - return; - } - else - { - model->setStringList(_words); - } - } - else - { - model->setStringList(sl); - } - - // Position the text edit - listView->setMinimumWidth(width()); - listView->setMaximumWidth(width()); - //listView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - - QPoint p(0, height()); - int x = mapToGlobal(p).x(); - int y = mapToGlobal(p).y() + 1; - - listView->move(x, y); - if(!listView->isVisible()) - listView->show(); -} - -void CompleteLineEdit::completeText(const QModelIndex &index) -{ - QString text = index.data().toString(); - setText(text); - listView->hide(); + + +#include "completer_line_edit.h" + +#include +#include +#include +#include +#include +#include + +CompleteLineEdit::CompleteLineEdit(QWidget *parent, QStringList words) + : QLineEdit(parent), _words(words) +{ + listView = new QListView(this); + model = new QStringListModel(this); + listView->setModel(model); + listView->setWindowFlags(Qt::ToolTip); + listView->setUniformItemSizes(true); + + connect(this, SIGNAL(textChanged(const QString &)), this, SLOT(setCompleter(const QString &))); + connect(listView, SIGNAL(clicked(const QModelIndex &)), this, SLOT(completeText(const QModelIndex &))); +} + +void CompleteLineEdit::setStringList(QStringList list) +{ + _words = list; +} + +//void CompleteLineEdit::focusOutEvent(QFocusEvent *e) +//{ +// listView->hide(); +//} + +void CompleteLineEdit::keyPressEvent(QKeyEvent *e) +{ + if (!listView->isHidden()) + { + int key = e->key(); + int count = listView->model()->rowCount(); + QModelIndex currentIndex = listView->currentIndex(); + + if (Qt::Key_Down == key) + { + int row = currentIndex.row() + 1; + if (row >= count) + { + row = 0; + } + + QModelIndex index = listView->model()->index(row, 0); + listView->setCurrentIndex(index); + } + else if (Qt::Key_Up == key) + { + int row = currentIndex.row() - 1; + if (row < 0) + { + row = count - 1; + } + + QModelIndex index = listView->model()->index(row, 0); + listView->setCurrentIndex(index); + } + else if (Qt::Key_Escape == key) + { + listView->hide(); + } + else if (Qt::Key_Enter == key || Qt::Key_Return == key) + { + if (currentIndex.isValid()) + { + QString text = listView->currentIndex().data().toString(); + setText(text); + } + + listView->hide(); + } + else + { + //listView->hide(); + QLineEdit::keyPressEvent(e); + } + } + else + { + QLineEdit::keyPressEvent(e); + } +} + +void CompleteLineEdit::setCompleter(const QString &text) +{ + if (text.isEmpty()) + { + listView->hide(); + return; + } + + if ((text.length() > 1) && (!listView->isHidden())) + { + //return; + } + + QStringList sl; + Q_FOREACH(QString word, _words) + { + if (word.contains(text)) + { + sl << word; + } + } + + if (sl.isEmpty()) + { + if (_words.isEmpty()) + { + setText(tr("No files found")); + setEnabled(false); + return; + } + else + { + model->setStringList(_words); + } + } + else + { + model->setStringList(sl); + } + + // Position the text edit + listView->setMinimumWidth(width()); + listView->setMaximumWidth(width()); + //listView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + + QPoint p(0, height()); + int x = mapToGlobal(p).x(); + int y = mapToGlobal(p).y() + 1; + + listView->move(x, y); + if(!listView->isVisible()) + listView->show(); +} + +void CompleteLineEdit::completeText(const QModelIndex &index) +{ + QString text = index.data().toString(); + setText(text); + listView->hide(); } \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/completer_line_edit.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/completer_line_edit.h index 30876a78b..4782e6aa7 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/completer_line_edit.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/completer_line_edit.h @@ -1,39 +1,39 @@ -#ifndef COMPLETELINEEDIT_H -#define COMPLETELINEEDIT_H - - -// code from -// http://www.cppblog.com/biao/archive/2009/10/31/99873.html -// there was no license attached - -#include -#include - -class QListView; -class QStringListModel; -class QModelIndex; - -class CompleteLineEdit : public QLineEdit -{ - Q_OBJECT - -public: - CompleteLineEdit(QWidget *parent = 0, QStringList words = QStringList()); - - void setStringList(QStringList list); - -public Q_SLOTS: - void setCompleter(const QString &text); - void completeText(const QModelIndex &index); - -protected: - virtual void keyPressEvent(QKeyEvent *e); - //virtual void focusOutEvent(QFocusEvent *e); - -private: - QStringList _words; - QListView *listView; - QStringListModel *model; -}; - +#ifndef COMPLETELINEEDIT_H +#define COMPLETELINEEDIT_H + + +// code from +// http://www.cppblog.com/biao/archive/2009/10/31/99873.html +// there was no license attached + +#include +#include + +class QListView; +class QStringListModel; +class QModelIndex; + +class CompleteLineEdit : public QLineEdit +{ + Q_OBJECT + +public: + CompleteLineEdit(QWidget *parent = 0, QStringList words = QStringList()); + + void setStringList(QStringList list); + +public Q_SLOTS: + void setCompleter(const QString &text); + void completeText(const QModelIndex &index); + +protected: + virtual void keyPressEvent(QKeyEvent *e); + //virtual void focusOutEvent(QFocusEvent *e); + +private: + QStringList _words; + QListView *listView; + QStringListModel *model; +}; + #endif // COMPLETELINEEDIT_H \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/configuration.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/configuration.cpp index 233e0c939..5868220cd 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/configuration.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/configuration.cpp @@ -1,237 +1,237 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -*/ - -#include "configuration.h" - -// STL includes - -// Qt includes -#include - -// NeL includes -#include -#include -#include -#include - -// Project includes -#include "modules.h" -#include "progress_dialog.h" - -using namespace std; -using namespace NLMISC; - -namespace NLQT { - - CConfiguration::CConfiguration() : _progressCB(0) - { - - } - - CConfiguration::~CConfiguration() - { - - } - - void CConfiguration::init() - { - // load config - QFile file(NLQT_CONFIG_FILE); - if (!file.exists()) { - file.open( QIODevice::WriteOnly | QIODevice::Text ); - file.write("GraphicsDrivers = { \"OpenGL\", \"Direct3D\" };"); - file.write("\nSearchPaths = {\"\"};"); - file.write("\nRemapExtensions = { \"png\", \"tga\" };"); - file.write("\nBackgroundColor = { 0, 0, 0 };"); - //file.write("\nQtStyle = \"\";"); - //file.write("\nQtPalette = \"\";"); - file.close(); - } - - try { - ConfigFile.load(NLQT_CONFIG_FILE); - } catch(...) { - } - - addLeveldesignPath(); - addSearchPaths(); - configRemapExtensions(); - } - - void CConfiguration::release() - { - //Modules::config().dropCallback("SearchPaths"); - - // save and release the config file - if (ConfigFile.exists("SaveConfig") && ConfigFile.getVarPtr("SaveConfig")->asBool()) - { - ConfigFile.save(); - } - ConfigFile.clear(); - - // release the search paths etc - CPath::releaseInstance(); - } - - void CConfiguration::updateUtilities() - { - //H_AUTO2 - CConfigFile::checkConfigFiles(); - } - - void CConfiguration::addLeveldesignPath() - { - std::vector list; - list.push_back(Modules::config().getValue("LeveldesignPath", QString("").toStdString())); - addSearchPaths(&list); - } - - void CConfiguration::configRemapExtensions() - { - CConfigFile::CVar *var; - var = ConfigFile.getVarPtr("RemapExtensions"); - uint varsize = var->size(); - for (uint i = 0; i < varsize; i += 2) - CPath::remapExtension(var->asString(i), var->asString(i + 1), true); - } - - float CConfiguration::getValue(const string &varName, float defaultValue) - { - if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asFloat(); - CConfigFile::CVar varToCopy; - varToCopy.forceAsDouble((double)defaultValue); - ConfigFile.insertVar(varName, varToCopy); - return defaultValue; - } - - double CConfiguration::getValue(const string &varName, double defaultValue) - { - if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asDouble(); - CConfigFile::CVar varToCopy; - varToCopy.forceAsDouble(defaultValue); - ConfigFile.insertVar(varName, varToCopy); - return defaultValue; - } - - int CConfiguration::getValue(const string &varName, int defaultValue) - { - if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asInt(); - CConfigFile::CVar varToCopy; - varToCopy.forceAsInt(defaultValue); - ConfigFile.insertVar(varName, varToCopy); - return defaultValue; - } - - string CConfiguration::getValue(const string &varName, const string &defaultValue) - { - if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asString(); - CConfigFile::CVar varToCopy; - varToCopy.forceAsString(defaultValue); - ConfigFile.insertVar(varName, varToCopy); - return defaultValue; - } - - ucstring CConfiguration::getValue(const string &varName, const ucstring &defaultValue) - { - if (ConfigFile.exists(varName)) return ucstring::makeFromUtf8(ConfigFile.getVar(varName).asString()); - CConfigFile::CVar varToCopy; - varToCopy.forceAsString(defaultValue.toUtf8()); - ConfigFile.insertVar(varName, varToCopy); - return defaultValue; - } - - bool CConfiguration::getValue(const string &varName, bool defaultValue) - { - if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asBool(); - CConfigFile::CVar varToCopy; - varToCopy.forceAsInt(defaultValue ? 1 : 0); - ConfigFile.insertVar(varName, varToCopy); - return defaultValue; - } - - CRGBA CConfiguration::getValue(const string &varName, const CRGBA &defaultValue) - { - if (ConfigFile.exists(varName)) - { - return getValue(ConfigFile.getVar(varName), defaultValue); - } - else - { - // create a new value only if one doesn't exist - CConfigFile::CVar varToCopy; - varToCopy.forceAsInt(defaultValue.R); - varToCopy.setAsInt(defaultValue.G, 1); - varToCopy.setAsInt(defaultValue.B, 2); - varToCopy.setAsInt(defaultValue.A, 3); - ConfigFile.insertVar(varName, varToCopy); - } - return defaultValue; - } - - CRGBA CConfiguration::getValue(const CConfigFile::CVar &var, const CRGBA &defaultValue) - { - if (var.size() >= 3) - { - if (var.size() > 4) nlwarning("RGBA value in config value '%s' is too long, ignoring unused values"); - return CRGBA((uint8)var.asInt(0), (uint8)var.asInt(1), (uint8)var.asInt(2), var.size() >= 4 ? (uint8)var.asInt(3) : 255); - } - nlwarning("Invalid RGBA value in config value '%s', reverting to default { %i, %i, %i, %i }", var.Name.c_str(), (sint)defaultValue.R, (sint)defaultValue.G, (sint)defaultValue.B, (sint)defaultValue.A); - return defaultValue; - } - - void CConfiguration::addSearchPaths(std::vector* list) - { - //Modules::config().getConfigFile().getVar("SearchPaths"); - - std::vector *tmpList = list; - if (!tmpList) - { - NLMISC::CConfigFile::CVar v = getConfigFile().getVar("SearchPaths"); - tmpList = new std::vector(); - for (uint i = 0; i < v.size(); ++i) - { - tmpList->push_back(v.asString(i)); - } - } - - uint listsize = tmpList->size(); - for (uint i = 0; i < listsize; ++i) - { - if(_progressCB) { - _progressCB->DisplayString = tmpList->at(i); - CPath::addSearchPath(tmpList->at(i), true, false, _progressCB); - } - else - { - CProgressDialog pcb; - pcb.DisplayString = tmpList->at(i); - pcb.show(); - CPath::addSearchPath(tmpList->at(i), true, false, &pcb); - } - } - if (!list) - delete tmpList; - } - - void CConfiguration::setProgressCallback(NLMISC::IProgressCallback *cb) - { - _progressCB = cb; - } - +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +*/ + +#include "configuration.h" + +// STL includes + +// Qt includes +#include + +// NeL includes +#include +#include +#include +#include + +// Project includes +#include "modules.h" +#include "progress_dialog.h" + +using namespace std; +using namespace NLMISC; + +namespace NLQT { + + CConfiguration::CConfiguration() : _progressCB(0) + { + + } + + CConfiguration::~CConfiguration() + { + + } + + void CConfiguration::init() + { + // load config + QFile file(NLQT_CONFIG_FILE); + if (!file.exists()) { + file.open( QIODevice::WriteOnly | QIODevice::Text ); + file.write("GraphicsDrivers = { \"OpenGL\", \"Direct3D\" };"); + file.write("\nSearchPaths = {\"\"};"); + file.write("\nRemapExtensions = { \"png\", \"tga\" };"); + file.write("\nBackgroundColor = { 0, 0, 0 };"); + //file.write("\nQtStyle = \"\";"); + //file.write("\nQtPalette = \"\";"); + file.close(); + } + + try { + ConfigFile.load(NLQT_CONFIG_FILE); + } catch(...) { + } + + addLeveldesignPath(); + addSearchPaths(); + configRemapExtensions(); + } + + void CConfiguration::release() + { + //Modules::config().dropCallback("SearchPaths"); + + // save and release the config file + if (ConfigFile.exists("SaveConfig") && ConfigFile.getVarPtr("SaveConfig")->asBool()) + { + ConfigFile.save(); + } + ConfigFile.clear(); + + // release the search paths etc + CPath::releaseInstance(); + } + + void CConfiguration::updateUtilities() + { + //H_AUTO2 + CConfigFile::checkConfigFiles(); + } + + void CConfiguration::addLeveldesignPath() + { + std::vector list; + list.push_back(Modules::config().getValue("LeveldesignPath", QString("").toStdString())); + addSearchPaths(&list); + } + + void CConfiguration::configRemapExtensions() + { + CConfigFile::CVar *var; + var = ConfigFile.getVarPtr("RemapExtensions"); + uint varsize = var->size(); + for (uint i = 0; i < varsize; i += 2) + CPath::remapExtension(var->asString(i), var->asString(i + 1), true); + } + + float CConfiguration::getValue(const string &varName, float defaultValue) + { + if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asFloat(); + CConfigFile::CVar varToCopy; + varToCopy.forceAsDouble((double)defaultValue); + ConfigFile.insertVar(varName, varToCopy); + return defaultValue; + } + + double CConfiguration::getValue(const string &varName, double defaultValue) + { + if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asDouble(); + CConfigFile::CVar varToCopy; + varToCopy.forceAsDouble(defaultValue); + ConfigFile.insertVar(varName, varToCopy); + return defaultValue; + } + + int CConfiguration::getValue(const string &varName, int defaultValue) + { + if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asInt(); + CConfigFile::CVar varToCopy; + varToCopy.forceAsInt(defaultValue); + ConfigFile.insertVar(varName, varToCopy); + return defaultValue; + } + + string CConfiguration::getValue(const string &varName, const string &defaultValue) + { + if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asString(); + CConfigFile::CVar varToCopy; + varToCopy.forceAsString(defaultValue); + ConfigFile.insertVar(varName, varToCopy); + return defaultValue; + } + + ucstring CConfiguration::getValue(const string &varName, const ucstring &defaultValue) + { + if (ConfigFile.exists(varName)) return ucstring::makeFromUtf8(ConfigFile.getVar(varName).asString()); + CConfigFile::CVar varToCopy; + varToCopy.forceAsString(defaultValue.toUtf8()); + ConfigFile.insertVar(varName, varToCopy); + return defaultValue; + } + + bool CConfiguration::getValue(const string &varName, bool defaultValue) + { + if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asBool(); + CConfigFile::CVar varToCopy; + varToCopy.forceAsInt(defaultValue ? 1 : 0); + ConfigFile.insertVar(varName, varToCopy); + return defaultValue; + } + + CRGBA CConfiguration::getValue(const string &varName, const CRGBA &defaultValue) + { + if (ConfigFile.exists(varName)) + { + return getValue(ConfigFile.getVar(varName), defaultValue); + } + else + { + // create a new value only if one doesn't exist + CConfigFile::CVar varToCopy; + varToCopy.forceAsInt(defaultValue.R); + varToCopy.setAsInt(defaultValue.G, 1); + varToCopy.setAsInt(defaultValue.B, 2); + varToCopy.setAsInt(defaultValue.A, 3); + ConfigFile.insertVar(varName, varToCopy); + } + return defaultValue; + } + + CRGBA CConfiguration::getValue(const CConfigFile::CVar &var, const CRGBA &defaultValue) + { + if (var.size() >= 3) + { + if (var.size() > 4) nlwarning("RGBA value in config value '%s' is too long, ignoring unused values"); + return CRGBA((uint8)var.asInt(0), (uint8)var.asInt(1), (uint8)var.asInt(2), var.size() >= 4 ? (uint8)var.asInt(3) : 255); + } + nlwarning("Invalid RGBA value in config value '%s', reverting to default { %i, %i, %i, %i }", var.Name.c_str(), (sint)defaultValue.R, (sint)defaultValue.G, (sint)defaultValue.B, (sint)defaultValue.A); + return defaultValue; + } + + void CConfiguration::addSearchPaths(std::vector* list) + { + //Modules::config().getConfigFile().getVar("SearchPaths"); + + std::vector *tmpList = list; + if (!tmpList) + { + NLMISC::CConfigFile::CVar v = getConfigFile().getVar("SearchPaths"); + tmpList = new std::vector(); + for (uint i = 0; i < v.size(); ++i) + { + tmpList->push_back(v.asString(i)); + } + } + + uint listsize = tmpList->size(); + for (uint i = 0; i < listsize; ++i) + { + if(_progressCB) { + _progressCB->DisplayString = tmpList->at(i); + CPath::addSearchPath(tmpList->at(i), true, false, _progressCB); + } + else + { + CProgressDialog pcb; + pcb.DisplayString = tmpList->at(i); + pcb.show(); + CPath::addSearchPath(tmpList->at(i), true, false, &pcb); + } + } + if (!list) + delete tmpList; + } + + void CConfiguration::setProgressCallback(NLMISC::IProgressCallback *cb) + { + _progressCB = cb; + } + } /* namespace NLQT */ \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/configuration.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/configuration.h index f701cd9fb..94876b240 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/configuration.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/configuration.h @@ -1,88 +1,88 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -*/ - -#ifndef CONFIGURATION_H -#define CONFIGURATION_H - -#include - -// STL includes -#include - -// NeL includes -#include -#include -#include - -// Project includes - -#define NLQT_CONFIG_FILE "georges_editor.cfg" - -namespace NLMISC { - class IProgressCallback; -} - -namespace NLQT { - - /** - * CConfiguration - * \brief CConfiguration - * \date 2010-02-05 15:44GMT - * \author Jan Boon (Kaetemi) - */ - class CConfiguration - { - public: - CConfiguration(); - virtual ~CConfiguration(); - - void init(); - void release(); - - void updateUtilities(); - void configRemapExtensions(); - void addSearchPaths(std::vector* list = 0); - void addLeveldesignPath(); - - void setProgressCallback(NLMISC::IProgressCallback *_progressCB); - - float getValue(const std::string &varName, float defaultValue); - double getValue(const std::string &varName, double defaultValue); - int getValue(const std::string &varName, int defaultValue); - std::string getValue(const std::string &varName, const std::string &defaultValue); - ucstring getValue(const std::string &varName, const ucstring &defaultValue); - bool getValue(const std::string &varName, bool defaultValue); - NLMISC::CRGBA getValue(const std::string &varName, const NLMISC::CRGBA &defaultValue); - NLMISC::CRGBA getValue(const NLMISC::CConfigFile::CVar &var, const NLMISC::CRGBA &defaultValue); - - inline NLMISC::CConfigFile &getConfigFile() { return ConfigFile; } - - private: - CConfiguration(const CConfiguration &); - CConfiguration &operator=(const CConfiguration &); - - NLMISC::CConfigFile ConfigFile; - - NLMISC::IProgressCallback *_progressCB; - - };/* class CConfiguration */ - -} /* namespace NLQT */ - -#endif // CONFIGURATION_H +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +*/ + +#ifndef CONFIGURATION_H +#define CONFIGURATION_H + +#include + +// STL includes +#include + +// NeL includes +#include +#include +#include + +// Project includes + +#define NLQT_CONFIG_FILE "georges_editor.cfg" + +namespace NLMISC { + class IProgressCallback; +} + +namespace NLQT { + + /** + * CConfiguration + * \brief CConfiguration + * \date 2010-02-05 15:44GMT + * \author Jan Boon (Kaetemi) + */ + class CConfiguration + { + public: + CConfiguration(); + virtual ~CConfiguration(); + + void init(); + void release(); + + void updateUtilities(); + void configRemapExtensions(); + void addSearchPaths(std::vector* list = 0); + void addLeveldesignPath(); + + void setProgressCallback(NLMISC::IProgressCallback *_progressCB); + + float getValue(const std::string &varName, float defaultValue); + double getValue(const std::string &varName, double defaultValue); + int getValue(const std::string &varName, int defaultValue); + std::string getValue(const std::string &varName, const std::string &defaultValue); + ucstring getValue(const std::string &varName, const ucstring &defaultValue); + bool getValue(const std::string &varName, bool defaultValue); + NLMISC::CRGBA getValue(const std::string &varName, const NLMISC::CRGBA &defaultValue); + NLMISC::CRGBA getValue(const NLMISC::CConfigFile::CVar &var, const NLMISC::CRGBA &defaultValue); + + inline NLMISC::CConfigFile &getConfigFile() { return ConfigFile; } + + private: + CConfiguration(const CConfiguration &); + CConfiguration &operator=(const CConfiguration &); + + NLMISC::CConfigFile ConfigFile; + + NLMISC::IProgressCallback *_progressCB; + + };/* class CConfiguration */ + +} /* namespace NLQT */ + +#endif // CONFIGURATION_H diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/entity.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/entity.cpp index d23939fd0..c811f3ecc 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/entity.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/entity.cpp @@ -1,430 +1,430 @@ -/* - Object Viewer Qt - Copyright (C) 2010 Dzmitry Kamiahin - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -*/ - -#include "stdpch.h" -#include "entity.h" - -#include - -// NeL includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Project includes -#include "modules.h" - -using namespace NLMISC; -using namespace NL3D; - -namespace NLQT { - -CSlotInfo& CSlotInfo::operator=(const CSlotInfo & slotInfo) -{ - if ( this != &slotInfo) - { - Animation = slotInfo.Animation; - ClampMode = slotInfo.ClampMode; - Enable = slotInfo.Enable; - EndBlend = slotInfo.EndBlend; - EndTime = slotInfo.EndTime; - Offset = slotInfo.Offset; - Skeleton = slotInfo.Skeleton; - SkeletonInverted = slotInfo.SkeletonInverted; - Smoothness = slotInfo.Smoothness; - SpeedFactor = slotInfo.SpeedFactor; - StartBlend = slotInfo.StartBlend; - StartTime = slotInfo.StartTime; - } - return *this; -} - -CEntity::CEntity(void): - _Name(""), _FileNameShape(""), - _FileNameSkeleton(""), _inPlace(false), _incPos(false), - _Instance(NULL), _Skeleton(NULL), - _PlayList(NULL), _AnimationSet(NULL) -{ - _CharacterScalePos = 1; -} - -CEntity::~CEntity(void) -{ - if (_PlayList != NULL) - { - _PlayList->resetAllChannels(); - Modules::objViewInt()->getPlayListManager()->deletePlayList (_PlayList); - _PlayList = NULL; - } - if (_AnimationSet != NULL) - { - Modules::objViewInt()->getDriver()->deleteAnimationSet(_AnimationSet); - _AnimationSet = NULL; - } - if (!_Skeleton.empty()) - { - _Skeleton.detachSkeletonSon(_Instance); - Modules::objViewInt()->getScene()->deleteSkeleton(_Skeleton); - _Skeleton = NULL; - } - if (!_Instance.empty()) - { - Modules::objViewInt()->getScene()->deleteInstance(_Instance); - _Instance = NULL; - } -} - -void CEntity::loadAnimation(std::string &fileName) -{ - uint id = _AnimationSet->addAnimation(fileName.c_str(),CFile::getFilenameWithoutExtension(fileName).c_str()); - _AnimationList.push_back(_AnimationSet->getAnimationName(id)); - _AnimationSet->build(); - if (!_Skeleton.empty()) _PlayList->registerTransform(_Skeleton); - else _PlayList->registerTransform(_Instance); -} - -void CEntity::loadSWT(std::string &fileName) -{ - uint id = _AnimationSet->addSkeletonWeight(fileName.c_str(),CFile::getFilenameWithoutExtension(fileName).c_str()); - _SWTList.push_back(_AnimationSet->getSkeletonWeightName(id)); -} - -void CEntity::addAnimToPlayList(std::string &name) -{ - _PlayListAnimation.push_back(name); - - _AnimationStatus.EndAnim = this->getPlayListLength(); - - _Instance.start(); -} - -void CEntity::removeAnimToPlayList(uint row) -{ - if (row < _PlayListAnimation.size()) - _PlayListAnimation.erase(_PlayListAnimation.begin() + row); - - _AnimationStatus.EndAnim = this->getPlayListLength(); -} - -void CEntity::swapAnimToPlayList(uint row1, uint row2) -{ - if ((row1 < _PlayListAnimation.size()) && (row2 < _PlayListAnimation.size())) - std::swap(_PlayListAnimation[row1], _PlayListAnimation[row2]); -} - -void CEntity::playbackAnim(bool play) -{ - _AnimationStatus.PlayAnim = play; - - if (play) - _Instance.start(); - else - _Instance.freezeHRC(); -} - -void CEntity::reset() -{ - _PlayListAnimation.clear(); - _AnimationList.clear(); - _SWTList.clear(); - - _PlayList->resetAllChannels(); -} - -float CEntity::getPlayListLength() -{ - // Accumul all the time - float time = 0; - for(size_t i = 0; i < _PlayListAnimation.size(); ++i) - time += getAnimLength(_PlayListAnimation[i]); - return time; -} - -float CEntity::getAnimLength(std::string name) -{ - uint id = _AnimationSet->getAnimationIdByName(name.c_str()); - NL3D::UAnimation *anim = _AnimationSet->getAnimation(id); - return anim->getEndTime() - anim->getBeginTime(); -} - -void CEntity::update(NL3D::TAnimationTime time) -{ - this->resetChannel(); - switch (_AnimationStatus.Mode) - { - case Mode::PlayList: - animatePlayList(time); - break; - case Mode::Mixer: - animateChannelMixer(); - break; - } -} - - -void CEntity::resetChannel() -{ - for(uint i = 0; i < NL3D::CChannelMixer::NumAnimationSlot; i++) - _PlayList->setAnimation(i, UPlayList::empty); -} - -void CEntity::addTransformation (CMatrix ¤t, UAnimation *anim, float begin, float end, UTrack *posTrack, UTrack *rotquatTrack, - UTrack *nextPosTrack, UTrack *nextRotquatTrack, bool removeLast) -{ - // In place ? - if (_inPlace) - { - // Just identity - current.identity(); - } - else - { - // Remove the start of the animation - CQuat rotEnd (0,0,0,1); - CVector posEnd (0,0,0); - if (rotquatTrack) - { - // Interpolate the rotation - rotquatTrack->interpolate (end, rotEnd); - } - if (posTrack) - { - // Interpolate the position - posTrack->interpolate (end, posEnd); - } - - // Add the final rotation and position - CMatrix tmp; - tmp.identity (); - tmp.setRot (rotEnd); - tmp.setPos (posEnd); - - // Incremental ? - if (_incPos) - current *= tmp; - else - current = tmp; - - if (removeLast) - { - CQuat rotStart (0,0,0,1); - CVector posStart (0,0,0); - if (nextRotquatTrack) - { - // Interpolate the rotation - nextRotquatTrack->interpolate (begin, rotStart); - } - if (nextPosTrack) - { - // Interpolate the position - nextPosTrack->interpolate (begin, posStart); - } - // Remove the init rotation and position of the next animation - tmp.identity (); - tmp.setRot (rotStart); - tmp.setPos (posStart); - tmp.invert (); - current *= tmp; - - // Normalize the mt - CVector I = current.getI (); - CVector J = current.getJ (); - I.z = 0; - J.z = 0; - J.normalize (); - CVector K = I^J; - K.normalize (); - I = J^K; - I.normalize (); - tmp.setRot (I, J, K); - tmp.setPos (current.getPos ()); - current = tmp; - } - } -} - -void CEntity::animatePlayList(NL3D::TAnimationTime time) -{ - if (!_PlayListAnimation.empty()) - { - // Animation index - uint id = _AnimationSet->getAnimationIdByName(_PlayListAnimation[0].c_str()); - - // Try channel AnimationSet - NL3D::UAnimation *anim = _AnimationSet->getAnimation(id); - - bool there = false; - - UTrack *posTrack = NULL; - UTrack *rotQuatTrack = NULL; - - // Current matrix - CMatrix current; - current.identity(); - - // read an animation for init matrix - rotQuatTrack = anim->getTrackByName("rotquat"); - posTrack = anim->getTrackByName("pos"); - - there = posTrack || rotQuatTrack; - - // Accumul time - float startTime = 0; - float endTime = anim->getEndTime() - anim->getBeginTime(); - - uint index = 0; - while (time >= endTime) - { - index++; - if (index < _PlayListAnimation.size()) - { - id = _AnimationSet->getAnimationIdByName(_PlayListAnimation[index].c_str()); - NL3D::UAnimation *newAnim = _AnimationSet->getAnimation(id); - - UTrack *newPosTrack = newAnim->getTrackByName ("pos"); - UTrack *newRotquatTrack = newAnim->getTrackByName ("rotquat"); - - // Add the transformation - addTransformation (current, anim, newAnim->getBeginTime(), anim->getEndTime(), posTrack, rotQuatTrack, newPosTrack, newRotquatTrack, true); - - - anim = newAnim; - posTrack = newPosTrack; - rotQuatTrack = newRotquatTrack; - - // Add start time - startTime = endTime; - endTime = startTime + (anim->getEndTime() - anim->getBeginTime()); - } - else - { - // Add the transformation - addTransformation (current, anim, 0, anim->getEndTime(), posTrack, rotQuatTrack, NULL, NULL, false); - break; - } - } - - // Time cropped ? - if (index >= _PlayListAnimation.size()) - { - // Yes - index--; - id = _AnimationSet->getAnimationIdByName(_PlayListAnimation[index].c_str()); - anim = _AnimationSet->getAnimation(id); - - // End time for last anim - startTime = anim->getEndTime() - time; - } - else - { - // No - - // Add the transformation - addTransformation (current, anim, 0, anim->getBeginTime() + time - startTime, posTrack, rotQuatTrack, NULL, NULL, false); - - id = _AnimationSet->getAnimationIdByName(_PlayListAnimation[index].c_str()); - anim = _AnimationSet->getAnimation(id); - - // Final time - startTime -= anim->getBeginTime(); - } - - // Set the slot - _PlayList->setAnimation(0, id); - _PlayList->setTimeOrigin(0, startTime); - _PlayList->setSpeedFactor(0, 1.0f); - _PlayList->setWeightSmoothness(0, 1.0f); - _PlayList->setStartWeight(0, 1, 0); - _PlayList->setEndWeight(0, 1, 1); - _PlayList->setWrapMode(0, UPlayList::Clamp); - - // Setup the pos and rot for this shape - if (there) - { - CVector pos = current.getPos(); - - // If a skeleton model - if(!_Skeleton.empty()) - { - // scale animated pos value with the CFG scale - pos *= _CharacterScalePos; - _Skeleton.setPos(pos); - _Skeleton.setRotQuat(current.getRot()); - } - else - { - _Instance.setPos(pos); - _Instance.setRotQuat(current.getRot()); - } - } - } -} - -void CEntity::animateChannelMixer() -{ - for (uint i = 0; i < NL3D::CChannelMixer::NumAnimationSlot; i++) - { - if (_SlotInfo[i].Enable) - { - // Set the animation - uint animId = _AnimationSet->getAnimationIdByName(_SlotInfo[i].Animation); - if (animId == UAnimationSet::NotFound) - _PlayList->setAnimation(i, UPlayList::empty); - else - _PlayList->setAnimation(i, animId); - - // Set the skeleton weight - uint skelId = _AnimationSet->getSkeletonWeightIdByName(_SlotInfo[i].Skeleton); - if (skelId == UAnimationSet::NotFound) - _PlayList->setSkeletonWeight(i, UPlayList::empty, false); - else - _PlayList->setSkeletonWeight(i, skelId, _SlotInfo[i].SkeletonInverted); - - // Set others values - _PlayList->setTimeOrigin(i, _SlotInfo[i].Offset); - _PlayList->setSpeedFactor(i, _SlotInfo[i].SpeedFactor); - _PlayList->setStartWeight(i, _SlotInfo[i].StartBlend, _SlotInfo[i].StartTime); - _PlayList->setEndWeight(i, _SlotInfo[i].EndBlend, _SlotInfo[i].EndTime); - _PlayList->setWeightSmoothness(i, _SlotInfo[i].Smoothness); - - // Switch between wrap modes - switch (_SlotInfo[i].ClampMode) - { - case 0: - _PlayList->setWrapMode (i, UPlayList::Clamp); - break; - case 1: - _PlayList->setWrapMode (i, UPlayList::Repeat); - break; - case 2: - _PlayList->setWrapMode (i, UPlayList::Disable); - break; - } - } - } -} - -} /* namespace NLQT */ +/* + Object Viewer Qt + Copyright (C) 2010 Dzmitry Kamiahin + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +*/ + +#include "stdpch.h" +#include "entity.h" + +#include + +// NeL includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Project includes +#include "modules.h" + +using namespace NLMISC; +using namespace NL3D; + +namespace NLQT { + +CSlotInfo& CSlotInfo::operator=(const CSlotInfo & slotInfo) +{ + if ( this != &slotInfo) + { + Animation = slotInfo.Animation; + ClampMode = slotInfo.ClampMode; + Enable = slotInfo.Enable; + EndBlend = slotInfo.EndBlend; + EndTime = slotInfo.EndTime; + Offset = slotInfo.Offset; + Skeleton = slotInfo.Skeleton; + SkeletonInverted = slotInfo.SkeletonInverted; + Smoothness = slotInfo.Smoothness; + SpeedFactor = slotInfo.SpeedFactor; + StartBlend = slotInfo.StartBlend; + StartTime = slotInfo.StartTime; + } + return *this; +} + +CEntity::CEntity(void): + _Name(""), _FileNameShape(""), + _FileNameSkeleton(""), _inPlace(false), _incPos(false), + _Instance(NULL), _Skeleton(NULL), + _PlayList(NULL), _AnimationSet(NULL) +{ + _CharacterScalePos = 1; +} + +CEntity::~CEntity(void) +{ + if (_PlayList != NULL) + { + _PlayList->resetAllChannels(); + Modules::objViewInt()->getPlayListManager()->deletePlayList (_PlayList); + _PlayList = NULL; + } + if (_AnimationSet != NULL) + { + Modules::objViewInt()->getDriver()->deleteAnimationSet(_AnimationSet); + _AnimationSet = NULL; + } + if (!_Skeleton.empty()) + { + _Skeleton.detachSkeletonSon(_Instance); + Modules::objViewInt()->getScene()->deleteSkeleton(_Skeleton); + _Skeleton = NULL; + } + if (!_Instance.empty()) + { + Modules::objViewInt()->getScene()->deleteInstance(_Instance); + _Instance = NULL; + } +} + +void CEntity::loadAnimation(std::string &fileName) +{ + uint id = _AnimationSet->addAnimation(fileName.c_str(),CFile::getFilenameWithoutExtension(fileName).c_str()); + _AnimationList.push_back(_AnimationSet->getAnimationName(id)); + _AnimationSet->build(); + if (!_Skeleton.empty()) _PlayList->registerTransform(_Skeleton); + else _PlayList->registerTransform(_Instance); +} + +void CEntity::loadSWT(std::string &fileName) +{ + uint id = _AnimationSet->addSkeletonWeight(fileName.c_str(),CFile::getFilenameWithoutExtension(fileName).c_str()); + _SWTList.push_back(_AnimationSet->getSkeletonWeightName(id)); +} + +void CEntity::addAnimToPlayList(std::string &name) +{ + _PlayListAnimation.push_back(name); + + _AnimationStatus.EndAnim = this->getPlayListLength(); + + _Instance.start(); +} + +void CEntity::removeAnimToPlayList(uint row) +{ + if (row < _PlayListAnimation.size()) + _PlayListAnimation.erase(_PlayListAnimation.begin() + row); + + _AnimationStatus.EndAnim = this->getPlayListLength(); +} + +void CEntity::swapAnimToPlayList(uint row1, uint row2) +{ + if ((row1 < _PlayListAnimation.size()) && (row2 < _PlayListAnimation.size())) + std::swap(_PlayListAnimation[row1], _PlayListAnimation[row2]); +} + +void CEntity::playbackAnim(bool play) +{ + _AnimationStatus.PlayAnim = play; + + if (play) + _Instance.start(); + else + _Instance.freezeHRC(); +} + +void CEntity::reset() +{ + _PlayListAnimation.clear(); + _AnimationList.clear(); + _SWTList.clear(); + + _PlayList->resetAllChannels(); +} + +float CEntity::getPlayListLength() +{ + // Accumul all the time + float time = 0; + for(size_t i = 0; i < _PlayListAnimation.size(); ++i) + time += getAnimLength(_PlayListAnimation[i]); + return time; +} + +float CEntity::getAnimLength(std::string name) +{ + uint id = _AnimationSet->getAnimationIdByName(name.c_str()); + NL3D::UAnimation *anim = _AnimationSet->getAnimation(id); + return anim->getEndTime() - anim->getBeginTime(); +} + +void CEntity::update(NL3D::TAnimationTime time) +{ + this->resetChannel(); + switch (_AnimationStatus.Mode) + { + case Mode::PlayList: + animatePlayList(time); + break; + case Mode::Mixer: + animateChannelMixer(); + break; + } +} + + +void CEntity::resetChannel() +{ + for(uint i = 0; i < NL3D::CChannelMixer::NumAnimationSlot; i++) + _PlayList->setAnimation(i, UPlayList::empty); +} + +void CEntity::addTransformation (CMatrix ¤t, UAnimation *anim, float begin, float end, UTrack *posTrack, UTrack *rotquatTrack, + UTrack *nextPosTrack, UTrack *nextRotquatTrack, bool removeLast) +{ + // In place ? + if (_inPlace) + { + // Just identity + current.identity(); + } + else + { + // Remove the start of the animation + CQuat rotEnd (0,0,0,1); + CVector posEnd (0,0,0); + if (rotquatTrack) + { + // Interpolate the rotation + rotquatTrack->interpolate (end, rotEnd); + } + if (posTrack) + { + // Interpolate the position + posTrack->interpolate (end, posEnd); + } + + // Add the final rotation and position + CMatrix tmp; + tmp.identity (); + tmp.setRot (rotEnd); + tmp.setPos (posEnd); + + // Incremental ? + if (_incPos) + current *= tmp; + else + current = tmp; + + if (removeLast) + { + CQuat rotStart (0,0,0,1); + CVector posStart (0,0,0); + if (nextRotquatTrack) + { + // Interpolate the rotation + nextRotquatTrack->interpolate (begin, rotStart); + } + if (nextPosTrack) + { + // Interpolate the position + nextPosTrack->interpolate (begin, posStart); + } + // Remove the init rotation and position of the next animation + tmp.identity (); + tmp.setRot (rotStart); + tmp.setPos (posStart); + tmp.invert (); + current *= tmp; + + // Normalize the mt + CVector I = current.getI (); + CVector J = current.getJ (); + I.z = 0; + J.z = 0; + J.normalize (); + CVector K = I^J; + K.normalize (); + I = J^K; + I.normalize (); + tmp.setRot (I, J, K); + tmp.setPos (current.getPos ()); + current = tmp; + } + } +} + +void CEntity::animatePlayList(NL3D::TAnimationTime time) +{ + if (!_PlayListAnimation.empty()) + { + // Animation index + uint id = _AnimationSet->getAnimationIdByName(_PlayListAnimation[0].c_str()); + + // Try channel AnimationSet + NL3D::UAnimation *anim = _AnimationSet->getAnimation(id); + + bool there = false; + + UTrack *posTrack = NULL; + UTrack *rotQuatTrack = NULL; + + // Current matrix + CMatrix current; + current.identity(); + + // read an animation for init matrix + rotQuatTrack = anim->getTrackByName("rotquat"); + posTrack = anim->getTrackByName("pos"); + + there = posTrack || rotQuatTrack; + + // Accumul time + float startTime = 0; + float endTime = anim->getEndTime() - anim->getBeginTime(); + + uint index = 0; + while (time >= endTime) + { + index++; + if (index < _PlayListAnimation.size()) + { + id = _AnimationSet->getAnimationIdByName(_PlayListAnimation[index].c_str()); + NL3D::UAnimation *newAnim = _AnimationSet->getAnimation(id); + + UTrack *newPosTrack = newAnim->getTrackByName ("pos"); + UTrack *newRotquatTrack = newAnim->getTrackByName ("rotquat"); + + // Add the transformation + addTransformation (current, anim, newAnim->getBeginTime(), anim->getEndTime(), posTrack, rotQuatTrack, newPosTrack, newRotquatTrack, true); + + + anim = newAnim; + posTrack = newPosTrack; + rotQuatTrack = newRotquatTrack; + + // Add start time + startTime = endTime; + endTime = startTime + (anim->getEndTime() - anim->getBeginTime()); + } + else + { + // Add the transformation + addTransformation (current, anim, 0, anim->getEndTime(), posTrack, rotQuatTrack, NULL, NULL, false); + break; + } + } + + // Time cropped ? + if (index >= _PlayListAnimation.size()) + { + // Yes + index--; + id = _AnimationSet->getAnimationIdByName(_PlayListAnimation[index].c_str()); + anim = _AnimationSet->getAnimation(id); + + // End time for last anim + startTime = anim->getEndTime() - time; + } + else + { + // No + + // Add the transformation + addTransformation (current, anim, 0, anim->getBeginTime() + time - startTime, posTrack, rotQuatTrack, NULL, NULL, false); + + id = _AnimationSet->getAnimationIdByName(_PlayListAnimation[index].c_str()); + anim = _AnimationSet->getAnimation(id); + + // Final time + startTime -= anim->getBeginTime(); + } + + // Set the slot + _PlayList->setAnimation(0, id); + _PlayList->setTimeOrigin(0, startTime); + _PlayList->setSpeedFactor(0, 1.0f); + _PlayList->setWeightSmoothness(0, 1.0f); + _PlayList->setStartWeight(0, 1, 0); + _PlayList->setEndWeight(0, 1, 1); + _PlayList->setWrapMode(0, UPlayList::Clamp); + + // Setup the pos and rot for this shape + if (there) + { + CVector pos = current.getPos(); + + // If a skeleton model + if(!_Skeleton.empty()) + { + // scale animated pos value with the CFG scale + pos *= _CharacterScalePos; + _Skeleton.setPos(pos); + _Skeleton.setRotQuat(current.getRot()); + } + else + { + _Instance.setPos(pos); + _Instance.setRotQuat(current.getRot()); + } + } + } +} + +void CEntity::animateChannelMixer() +{ + for (uint i = 0; i < NL3D::CChannelMixer::NumAnimationSlot; i++) + { + if (_SlotInfo[i].Enable) + { + // Set the animation + uint animId = _AnimationSet->getAnimationIdByName(_SlotInfo[i].Animation); + if (animId == UAnimationSet::NotFound) + _PlayList->setAnimation(i, UPlayList::empty); + else + _PlayList->setAnimation(i, animId); + + // Set the skeleton weight + uint skelId = _AnimationSet->getSkeletonWeightIdByName(_SlotInfo[i].Skeleton); + if (skelId == UAnimationSet::NotFound) + _PlayList->setSkeletonWeight(i, UPlayList::empty, false); + else + _PlayList->setSkeletonWeight(i, skelId, _SlotInfo[i].SkeletonInverted); + + // Set others values + _PlayList->setTimeOrigin(i, _SlotInfo[i].Offset); + _PlayList->setSpeedFactor(i, _SlotInfo[i].SpeedFactor); + _PlayList->setStartWeight(i, _SlotInfo[i].StartBlend, _SlotInfo[i].StartTime); + _PlayList->setEndWeight(i, _SlotInfo[i].EndBlend, _SlotInfo[i].EndTime); + _PlayList->setWeightSmoothness(i, _SlotInfo[i].Smoothness); + + // Switch between wrap modes + switch (_SlotInfo[i].ClampMode) + { + case 0: + _PlayList->setWrapMode (i, UPlayList::Clamp); + break; + case 1: + _PlayList->setWrapMode (i, UPlayList::Repeat); + break; + case 2: + _PlayList->setWrapMode (i, UPlayList::Disable); + break; + } + } + } +} + +} /* namespace NLQT */ diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/entity.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/entity.h index fba0d46c8..e906e069e 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/entity.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/entity.h @@ -1,260 +1,260 @@ -/* - Object Viewer Qt - Copyright (C) 2010 Dzmitry Kamiahin - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -*/ - -#ifndef ENTITY_H -#define ENTITY_H - -#include - -// STL includes -#include -#include -#include - -// NeL includes -#include -#include -#include -#include -#include -#include -#include - -namespace NL3D { - class UPlayList; - class UAnimationSet; -} - -namespace NLQT { - -class CSlotInfo -{ -public: - CSlotInfo (): - Animation("empty"), Skeleton("empty"), - Offset(0), StartTime(0), EndTime(0), - StartBlend(1), EndBlend (1), Smoothness(1), - SpeedFactor(1), ClampMode(0), - SkeletonInverted(false), - Enable(true) {} ; - - std::string Animation; - std::string Skeleton; - float Offset; - float StartTime; - float EndTime; - - float StartBlend; - float EndBlend; - float Smoothness; - float SpeedFactor; - sint32 ClampMode; - bool SkeletonInverted; - bool Enable; - - CSlotInfo &operator=(const CSlotInfo &); -}; - - -/** -@class CEntity -@brief Class manage animated shape. -@details -Allows you to load animations for shape and skeleton weight. -Contains a built-in playlist. Has management and playback Playlists or Mixer. -*/ -class CEntity -{ -public: - struct Mode - { - enum List - { - PlayList = 1, - Mixer - }; - }; - - /// Will need for a single or multiple animation shape - struct SAnimationStatus - { - bool LoopAnim; - bool PlayAnim; - float CurrentTimeAnim; - float StartAnim; - float EndAnim; - float SpeedAnim; - int Mode; - - SAnimationStatus(): - LoopAnim(false), PlayAnim(false), - CurrentTimeAnim(0), StartAnim(0), - EndAnim(0), SpeedAnim(1), Mode(Mode::PlayList) {} - }; - - /// Destructor - ~CEntity(void); - - /// Loads a file animations - /// @param fileName - name animation file - void loadAnimation(std::string &fileName); - - /// Loads a file skeleton weight - void loadSWT(std::string &fileName); - - /// Adds an animation to a playlist - /// @param name - name loaded animations - void addAnimToPlayList(std::string &name); - - /// Removes the animation from a playlist - /// @param row - number of animations in the playlist - void removeAnimToPlayList(uint row); - - /// Swaps animations to a playlist - /// @param row1 - first number of animations in the playlist - /// @param row2 - second number of animations in the playlist - void swapAnimToPlayList(uint row1, uint row2); - - /// Playback animation - void playbackAnim(bool play); - - /// Reset playlist and animation - void reset(); - - /// Get the total time of animation playlist - /// @return total time of animation - float getPlayListLength(); - - /// get time length single animation - float getAnimLength(std::string name); - - /// Get slot infomation - void setSlotInfo(uint num, CSlotInfo& slotInfo) { _SlotInfo[num] = slotInfo; } - - /// Set use mode playlist or mixer - void setMode(int mode) { _AnimationStatus.Mode = mode; } - - /// Set in place mode animation - void setInPlace(bool enabled) { _inPlace = enabled; } - - /// Get in place mode - bool getInPlace() { return _inPlace; } - - /// Set inc position - void setIncPos(bool enabled) { _incPos = enabled; } - - /// Get inc position - bool getIncPos() { return _incPos; } - - /// Get information about the current status of playing a playlist - /// @return struct containing current information playback - SAnimationStatus getStatus() { return _AnimationStatus; } - - /// Get name entity - /// @return name entity - std::string getName() { return _Name; } - - /// Get file name shape - /// @return file name shape - std::string getFileNameShape() { return _FileNameShape; } - - /// Get file name skeleton - /// @return file name skeleton - std::string getFileNameSkeleton() { return _FileNameSkeleton; } - - /// Get slot information - CSlotInfo getSlotInfo(uint num) { return _SlotInfo[num]; } - - /// Get list loaded animations files - std::vector& getAnimationList() { return _AnimationList; } - - /// Get playlist animations - std::vector& getPlayListAnimation() { return _PlayListAnimation; } - - /// Get list loaded skeleton weight template files - std::vector& getSWTList() { return _SWTList; } - - /// Get game interface for manipulating Skeleton. - NL3D::USkeleton getSkeleton() const { return _Skeleton; } - -private: - /// Constructor - CEntity(void); - - /// Update the animate from the playlist or channel mixer - /// @param time - current time in second - void update(NL3D::TAnimationTime time); - - void resetChannel(); - - /// Update the animate from the playlist - void animatePlayList(NL3D::TAnimationTime time); - - /// Update the animate from the mixer - void animateChannelMixer(); - void addTransformation (NLMISC::CMatrix ¤t, NL3D::UAnimation *anim, - float begin, float end, - NL3D::UTrack *posTrack, NL3D::UTrack *rotquatTrack, - NL3D::UTrack *nextPosTrack, NL3D::UTrack *nextRotquatTrack, - bool removeLast); - - // The name of the entity - std::string _Name; - std::string _FileNameShape; - std::string _FileNameSkeleton; - - SAnimationStatus _AnimationStatus; - - bool _inPlace; - bool _incPos; - - float _CharacterScalePos; - - // The mesh instance associated to this entity - NL3D::UInstance _Instance; - - // The skeleton binded to the instance - NL3D::USkeleton _Skeleton; - - NL3D::UPlayList *_PlayList; - - NL3D::UAnimationSet *_AnimationSet; - - // Animation input file - std::vector _AnimationList; - - // Skeleton weight input file - std::vector _SWTList; - - // Play list animation - std::vector _PlayListAnimation; - - // Slot info for this object - CSlotInfo _SlotInfo[NL3D::CChannelMixer::NumAnimationSlot]; - - friend class CObjectViewer; - friend class CObjectViewerWidget; -}; /* class CEntity */ - -typedef std::map CEntities; -typedef CEntities::iterator EIT; - -} /* namespace NLQT */ - -#endif // ENTITY_H +/* + Object Viewer Qt + Copyright (C) 2010 Dzmitry Kamiahin + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +*/ + +#ifndef ENTITY_H +#define ENTITY_H + +#include + +// STL includes +#include +#include +#include + +// NeL includes +#include +#include +#include +#include +#include +#include +#include + +namespace NL3D { + class UPlayList; + class UAnimationSet; +} + +namespace NLQT { + +class CSlotInfo +{ +public: + CSlotInfo (): + Animation("empty"), Skeleton("empty"), + Offset(0), StartTime(0), EndTime(0), + StartBlend(1), EndBlend (1), Smoothness(1), + SpeedFactor(1), ClampMode(0), + SkeletonInverted(false), + Enable(true) {} ; + + std::string Animation; + std::string Skeleton; + float Offset; + float StartTime; + float EndTime; + + float StartBlend; + float EndBlend; + float Smoothness; + float SpeedFactor; + sint32 ClampMode; + bool SkeletonInverted; + bool Enable; + + CSlotInfo &operator=(const CSlotInfo &); +}; + + +/** +@class CEntity +@brief Class manage animated shape. +@details +Allows you to load animations for shape and skeleton weight. +Contains a built-in playlist. Has management and playback Playlists or Mixer. +*/ +class CEntity +{ +public: + struct Mode + { + enum List + { + PlayList = 1, + Mixer + }; + }; + + /// Will need for a single or multiple animation shape + struct SAnimationStatus + { + bool LoopAnim; + bool PlayAnim; + float CurrentTimeAnim; + float StartAnim; + float EndAnim; + float SpeedAnim; + int Mode; + + SAnimationStatus(): + LoopAnim(false), PlayAnim(false), + CurrentTimeAnim(0), StartAnim(0), + EndAnim(0), SpeedAnim(1), Mode(Mode::PlayList) {} + }; + + /// Destructor + ~CEntity(void); + + /// Loads a file animations + /// @param fileName - name animation file + void loadAnimation(std::string &fileName); + + /// Loads a file skeleton weight + void loadSWT(std::string &fileName); + + /// Adds an animation to a playlist + /// @param name - name loaded animations + void addAnimToPlayList(std::string &name); + + /// Removes the animation from a playlist + /// @param row - number of animations in the playlist + void removeAnimToPlayList(uint row); + + /// Swaps animations to a playlist + /// @param row1 - first number of animations in the playlist + /// @param row2 - second number of animations in the playlist + void swapAnimToPlayList(uint row1, uint row2); + + /// Playback animation + void playbackAnim(bool play); + + /// Reset playlist and animation + void reset(); + + /// Get the total time of animation playlist + /// @return total time of animation + float getPlayListLength(); + + /// get time length single animation + float getAnimLength(std::string name); + + /// Get slot infomation + void setSlotInfo(uint num, CSlotInfo& slotInfo) { _SlotInfo[num] = slotInfo; } + + /// Set use mode playlist or mixer + void setMode(int mode) { _AnimationStatus.Mode = mode; } + + /// Set in place mode animation + void setInPlace(bool enabled) { _inPlace = enabled; } + + /// Get in place mode + bool getInPlace() { return _inPlace; } + + /// Set inc position + void setIncPos(bool enabled) { _incPos = enabled; } + + /// Get inc position + bool getIncPos() { return _incPos; } + + /// Get information about the current status of playing a playlist + /// @return struct containing current information playback + SAnimationStatus getStatus() { return _AnimationStatus; } + + /// Get name entity + /// @return name entity + std::string getName() { return _Name; } + + /// Get file name shape + /// @return file name shape + std::string getFileNameShape() { return _FileNameShape; } + + /// Get file name skeleton + /// @return file name skeleton + std::string getFileNameSkeleton() { return _FileNameSkeleton; } + + /// Get slot information + CSlotInfo getSlotInfo(uint num) { return _SlotInfo[num]; } + + /// Get list loaded animations files + std::vector& getAnimationList() { return _AnimationList; } + + /// Get playlist animations + std::vector& getPlayListAnimation() { return _PlayListAnimation; } + + /// Get list loaded skeleton weight template files + std::vector& getSWTList() { return _SWTList; } + + /// Get game interface for manipulating Skeleton. + NL3D::USkeleton getSkeleton() const { return _Skeleton; } + +private: + /// Constructor + CEntity(void); + + /// Update the animate from the playlist or channel mixer + /// @param time - current time in second + void update(NL3D::TAnimationTime time); + + void resetChannel(); + + /// Update the animate from the playlist + void animatePlayList(NL3D::TAnimationTime time); + + /// Update the animate from the mixer + void animateChannelMixer(); + void addTransformation (NLMISC::CMatrix ¤t, NL3D::UAnimation *anim, + float begin, float end, + NL3D::UTrack *posTrack, NL3D::UTrack *rotquatTrack, + NL3D::UTrack *nextPosTrack, NL3D::UTrack *nextRotquatTrack, + bool removeLast); + + // The name of the entity + std::string _Name; + std::string _FileNameShape; + std::string _FileNameSkeleton; + + SAnimationStatus _AnimationStatus; + + bool _inPlace; + bool _incPos; + + float _CharacterScalePos; + + // The mesh instance associated to this entity + NL3D::UInstance _Instance; + + // The skeleton binded to the instance + NL3D::USkeleton _Skeleton; + + NL3D::UPlayList *_PlayList; + + NL3D::UAnimationSet *_AnimationSet; + + // Animation input file + std::vector _AnimationList; + + // Skeleton weight input file + std::vector _SWTList; + + // Play list animation + std::vector _PlayListAnimation; + + // Slot info for this object + CSlotInfo _SlotInfo[NL3D::CChannelMixer::NumAnimationSlot]; + + friend class CObjectViewer; + friend class CObjectViewerWidget; +}; /* class CEntity */ + +typedef std::map CEntities; +typedef CEntities::iterator EIT; + +} /* namespace NLQT */ + +#endif // ENTITY_H diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/filesystem_model.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/filesystem_model.cpp index fc0bd4669..879804917 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/filesystem_model.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/filesystem_model.cpp @@ -1,79 +1,79 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#include "filesystem_model.h" - -#include -#include - -namespace NLQT -{ - - CFileSystemModel::CFileSystemModel(QString ldPath, QObject *parent) - : QFileSystemModel(parent), - _ldPath(ldPath) - { - - } - CFileSystemModel::~CFileSystemModel() - { - - } - - QVariant CFileSystemModel::data(const QModelIndex& index, int role) const { - - if (role == Qt::DecorationRole) - { - if (_ldPath.isEmpty()) - return QVariant(); - if (isDir(index)) - return QApplication::style()->standardIcon(QStyle::SP_DirIcon); - } - if (_ldPath.isEmpty() && role == Qt::DisplayRole) - { - if (index.parent().isValid()) - return QVariant(); - return QString("Set a correct leveldesign path ..."); - } - return QFileSystemModel::data(index, role); - } - - int CFileSystemModel::columnCount(const QModelIndex &/*parent*/) const - { - return 1; - } - - int CFileSystemModel::rowCount(const QModelIndex &parent) const - { - if (_ldPath.isEmpty()) - { - if(parent.isValid()) - { - return 0; - } - else - { - return qMin(QFileSystemModel::rowCount(parent),1); - } - } - return QFileSystemModel::rowCount(parent); - } - -} /* namespace NLQT */ - -/* end of file */ +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "filesystem_model.h" + +#include +#include + +namespace NLQT +{ + + CFileSystemModel::CFileSystemModel(QString ldPath, QObject *parent) + : QFileSystemModel(parent), + _ldPath(ldPath) + { + + } + CFileSystemModel::~CFileSystemModel() + { + + } + + QVariant CFileSystemModel::data(const QModelIndex& index, int role) const { + + if (role == Qt::DecorationRole) + { + if (_ldPath.isEmpty()) + return QVariant(); + if (isDir(index)) + return QApplication::style()->standardIcon(QStyle::SP_DirIcon); + } + if (_ldPath.isEmpty() && role == Qt::DisplayRole) + { + if (index.parent().isValid()) + return QVariant(); + return QString("Set a correct leveldesign path ..."); + } + return QFileSystemModel::data(index, role); + } + + int CFileSystemModel::columnCount(const QModelIndex &/*parent*/) const + { + return 1; + } + + int CFileSystemModel::rowCount(const QModelIndex &parent) const + { + if (_ldPath.isEmpty()) + { + if(parent.isValid()) + { + return 0; + } + else + { + return qMin(QFileSystemModel::rowCount(parent),1); + } + } + return QFileSystemModel::rowCount(parent); + } + +} /* namespace NLQT */ + +/* end of file */ diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/filesystem_model.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/filesystem_model.h index 90b93b297..413c86596 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/filesystem_model.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/filesystem_model.h @@ -1,44 +1,44 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#ifndef FILESYSTEM_MODEL_H -#define FILESYSTEM_MODEL_H - -#include - -namespace NLQT -{ - - class CFileSystemModel : public QFileSystemModel - { - QString _ldPath; - - public: - CFileSystemModel(QString ldPath, QObject *parent = 0); - ~CFileSystemModel(); - - int columnCount(const QModelIndex &/*parent*/) const; - int rowCount(const QModelIndex &/*parent*/) const; - - QVariant data(const QModelIndex& index, int role) const ; - - };/* class CFileSystemModel */ - -} /* namespace NLQT */ - +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef FILESYSTEM_MODEL_H +#define FILESYSTEM_MODEL_H + +#include + +namespace NLQT +{ + + class CFileSystemModel : public QFileSystemModel + { + QString _ldPath; + + public: + CFileSystemModel(QString ldPath, QObject *parent = 0); + ~CFileSystemModel(); + + int columnCount(const QModelIndex &/*parent*/) const; + int rowCount(const QModelIndex &/*parent*/) const; + + QVariant data(const QModelIndex& index, int role) const ; + + };/* class CFileSystemModel */ + +} /* namespace NLQT */ + #endif // FILESYSTEM_MODEL_H \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/formdelegate.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/formdelegate.cpp index fc634d322..a1e3e1d13 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/formdelegate.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/formdelegate.cpp @@ -1,314 +1,314 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#include "formdelegate.h" - -// NeL includes -#include -#include -#include - -// Qt includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -// Project includes -#include "georgesform_model.h" -#include "georgesform_proxy_model.h" -#include "formitem.h" - -namespace NLQT -{ - - FormDelegate::FormDelegate(QObject *parent) - : QStyledItemDelegate(parent) - { - } - - QWidget *FormDelegate::createEditor(QWidget *parent, - const QStyleOptionViewItem & option , - const QModelIndex &index) const - { - const CGeorgesFormProxyModel * mp = dynamic_cast(index.model()); - const CGeorgesFormModel * m = dynamic_cast(mp->sourceModel()); - CFormItem *item = static_cast(mp->mapToSource(index).internalPointer()); - QString value = item->data(1).toString(); - - if (value.isEmpty() || !mp || !m) - return 0; - - CFormItem* curItem = m->getItem(mp->mapToSource(index)); - NLGEORGES::UFormElm *curElm = curItem->getFormElm(); - if (!curElm) { - // TODO: create new Element - return 0; - } - const NLGEORGES::UType *type = curElm->getType(); - if(type) - { - int numDefinitions = type->getNumDefinition(); - - if (numDefinitions) - { - std::string l, v; - QString label,value; - - QComboBox *editor = new QComboBox(parent); - for (int i = 0; i < numDefinitions; i++) - { - type->getDefinition(i,l,v); - label = l.c_str(); - value = v.c_str(); - editor->addItem(label); - } - return editor; - } - else - { - switch (type->getType()) - { - case NLGEORGES::UType::UnsignedInt: - case NLGEORGES::UType::SignedInt: - { - QSpinBox *editor = new QSpinBox(parent); - - //QString min = QString(type->getMin().c_str()); - //QString max = QString(type->getMax().c_str()); - //QString inc = QString(type->getIncrement().c_str()); - //nldebug(QString("min %1 max %2 inc %3").arg(min).arg(max).arg(inc).toStdString().c_str()); - - // TODO: use saved min/max values - editor->setMinimum(-99999); - editor->setMaximum(99999); - editor->setSingleStep(1); - return editor; - } - case NLGEORGES::UType::Double: - { - QDoubleSpinBox *editor = new QDoubleSpinBox(parent); - - //QString min = QString(type->getMin().c_str()); - //QString max = QString(type->getMax().c_str()); - //QString inc = QString(type->getIncrement().c_str()); - //nldebug(QString("min %1 max %2 inc %3").arg(min).arg(max).arg(inc).toStdString().c_str()); - - // TODO: use saved min/max values - editor->setMinimum(-99999); - editor->setMaximum(99999); - editor->setSingleStep(0.1); - editor->setDecimals(1); - return editor; - } - case NLGEORGES::UType::Color: - { - return new QColorDialog(); - } - default: // UType::String - { - QLineEdit *editor = new QLineEdit(parent); - return editor; - } - } - } - } - return 0; - } - - void FormDelegate::setEditorData(QWidget *editor, - const QModelIndex &index) const - { - const CGeorgesFormProxyModel * mp = dynamic_cast(index.model()); - const CGeorgesFormModel * m = dynamic_cast(mp->sourceModel()); - - const NLGEORGES::UType *type = m->getItem(mp->mapToSource(index))->getFormElm()->getType(); - int numDefinitions = type->getNumDefinition(); - QString value = index.model()->data(index, Qt::DisplayRole).toString(); - - if (numDefinitions) - { - QComboBox *cb = static_cast(editor); - cb->setCurrentIndex(cb->findText(value)); - //cb->setIconSize() - } - else - { - switch (type->getType()) - { - case NLGEORGES::UType::UnsignedInt: - case NLGEORGES::UType::SignedInt: - { - QSpinBox *spinBox = static_cast(editor); - spinBox->setValue((int)value.toDouble()); - break; - } - case NLGEORGES::UType::Double: - { - QDoubleSpinBox *spinBox = static_cast(editor); - spinBox->setValue(value.toDouble()); - break; - } - case NLGEORGES::UType::Color: - { - break; - } - default: - { - QLineEdit *textEdit = static_cast(editor); - textEdit->setText(value); - break; - } - } - } - } - - void FormDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index) const - { - const CGeorgesFormProxyModel * mp = dynamic_cast(index.model()); - const CGeorgesFormModel * m = dynamic_cast(mp->sourceModel()); - - const NLGEORGES::UType *type = m->getItem(mp->mapToSource(index))->getFormElm()->getType(); - int numDefinitions = type->getNumDefinition(); - - if (numDefinitions) - { - QComboBox *comboBox = static_cast(editor); - QString value = comboBox->currentText(); - QString oldValue = index.model()->data(index, Qt::DisplayRole).toString(); - if (value == oldValue) - { - // nothing's changed - } - else - { - nldebug(QString("setModelData from %1 to %2") - .arg(oldValue).arg(value).toStdString().c_str()); - model->setData(index, value, Qt::EditRole); - } - } - else - { - switch (type->getType()) - { - case NLGEORGES::UType::UnsignedInt: - case NLGEORGES::UType::SignedInt: - { - QSpinBox *spinBox = static_cast(editor); - int value = spinBox->value(); - QString oldValue = index.model()->data(index, Qt::DisplayRole).toString(); - if (QString("%1").arg(value) == oldValue) - { - // nothing's changed - } - else - { - nldebug(QString("setModelData from %1 to %2") - .arg(oldValue).arg(value).toStdString().c_str()); - model->setData(index, value, Qt::EditRole); - } - break; - } - case NLGEORGES::UType::Double: - { - QDoubleSpinBox *spinBox = static_cast(editor); - double value = spinBox->value(); - QString oldValue = index.model()->data(index, Qt::DisplayRole).toString(); - if (QString("%1").arg(value) == oldValue) - { - // nothing's changed - } - else - { - nldebug(QString("setModelData from %1 to %2") - .arg(oldValue).arg(value).toStdString().c_str()); - model->setData(index, value, Qt::EditRole); - } - break; - } - case NLGEORGES::UType::Color: - { - break; // TODO - } - default: // UType::String - { - QLineEdit *textEdit = static_cast(editor); - QString value = textEdit->text(); - QString oldValue = index.model()->data(index, Qt::DisplayRole).toString(); - if (value == oldValue) - { - // nothing's changed - } - else - { - nldebug(QString("setModelData from %1 to %2") - .arg(oldValue).arg(value).toStdString().c_str()); - model->setData(index, value, Qt::EditRole); - } - break; - } - } - } - } - - void FormDelegate::updateEditorGeometry(QWidget *editor, - const QStyleOptionViewItem &option, const QModelIndex &index) const - { - QRect r = option.rect; - editor->setGeometry(r); - //option.decorationAlignment = QStyleOptionViewItem::Right; - } - - //void FormDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const - //{ - // QStyleOptionViewItemV4 optionV4 = option; - // optionV4.decorationPosition = QStyleOptionViewItem::Right; - // //optionV4.decorationSize = QSize(32,32); - // initStyleOption(&optionV4, index); - - // QStyledItemDelegate::paint(painter,optionV4,index); - - // //QStyle *style = optionV4.widget? optionV4.widget->style() : QApplication::style(); - - // //QTextDocument doc; - // //doc.setHtml(optionV4.text); - - // ///// Painting item without text - // //optionV4.text = QString(); - // //style->drawControl(QStyle::CE_ItemViewItem, &optionV4, painter); - - // //QAbstractTextDocumentLayout::PaintContext ctx; - - // //// Highlighting text if item is selected - // //if (optionV4.state & QStyle::State_Selected) - // // ctx.palette.setColor(QPalette::Text, optionV4.palette.color(QPalette::Active, QPalette::HighlightedText)); - - // //QRect textRect = style->subElementRect(QStyle::SE_ItemViewItemText, &optionV4); - // //painter->save(); - // //painter->translate(textRect.topLeft()); - // //painter->setClipRect(textRect.translated(-textRect.topLeft())); - // //doc.documentLayout()->draw(painter, ctx); - // //painter->restore(); - //} - -} /* namespace NLQT */ +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "formdelegate.h" + +// NeL includes +#include +#include +#include + +// Qt includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +// Project includes +#include "georgesform_model.h" +#include "georgesform_proxy_model.h" +#include "formitem.h" + +namespace NLQT +{ + + FormDelegate::FormDelegate(QObject *parent) + : QStyledItemDelegate(parent) + { + } + + QWidget *FormDelegate::createEditor(QWidget *parent, + const QStyleOptionViewItem & option , + const QModelIndex &index) const + { + const CGeorgesFormProxyModel * mp = dynamic_cast(index.model()); + const CGeorgesFormModel * m = dynamic_cast(mp->sourceModel()); + CFormItem *item = static_cast(mp->mapToSource(index).internalPointer()); + QString value = item->data(1).toString(); + + if (value.isEmpty() || !mp || !m) + return 0; + + CFormItem* curItem = m->getItem(mp->mapToSource(index)); + NLGEORGES::UFormElm *curElm = curItem->getFormElm(); + if (!curElm) { + // TODO: create new Element + return 0; + } + const NLGEORGES::UType *type = curElm->getType(); + if(type) + { + int numDefinitions = type->getNumDefinition(); + + if (numDefinitions) + { + std::string l, v; + QString label,value; + + QComboBox *editor = new QComboBox(parent); + for (int i = 0; i < numDefinitions; i++) + { + type->getDefinition(i,l,v); + label = l.c_str(); + value = v.c_str(); + editor->addItem(label); + } + return editor; + } + else + { + switch (type->getType()) + { + case NLGEORGES::UType::UnsignedInt: + case NLGEORGES::UType::SignedInt: + { + QSpinBox *editor = new QSpinBox(parent); + + //QString min = QString(type->getMin().c_str()); + //QString max = QString(type->getMax().c_str()); + //QString inc = QString(type->getIncrement().c_str()); + //nldebug(QString("min %1 max %2 inc %3").arg(min).arg(max).arg(inc).toStdString().c_str()); + + // TODO: use saved min/max values + editor->setMinimum(-99999); + editor->setMaximum(99999); + editor->setSingleStep(1); + return editor; + } + case NLGEORGES::UType::Double: + { + QDoubleSpinBox *editor = new QDoubleSpinBox(parent); + + //QString min = QString(type->getMin().c_str()); + //QString max = QString(type->getMax().c_str()); + //QString inc = QString(type->getIncrement().c_str()); + //nldebug(QString("min %1 max %2 inc %3").arg(min).arg(max).arg(inc).toStdString().c_str()); + + // TODO: use saved min/max values + editor->setMinimum(-99999); + editor->setMaximum(99999); + editor->setSingleStep(0.1); + editor->setDecimals(1); + return editor; + } + case NLGEORGES::UType::Color: + { + return new QColorDialog(); + } + default: // UType::String + { + QLineEdit *editor = new QLineEdit(parent); + return editor; + } + } + } + } + return 0; + } + + void FormDelegate::setEditorData(QWidget *editor, + const QModelIndex &index) const + { + const CGeorgesFormProxyModel * mp = dynamic_cast(index.model()); + const CGeorgesFormModel * m = dynamic_cast(mp->sourceModel()); + + const NLGEORGES::UType *type = m->getItem(mp->mapToSource(index))->getFormElm()->getType(); + int numDefinitions = type->getNumDefinition(); + QString value = index.model()->data(index, Qt::DisplayRole).toString(); + + if (numDefinitions) + { + QComboBox *cb = static_cast(editor); + cb->setCurrentIndex(cb->findText(value)); + //cb->setIconSize() + } + else + { + switch (type->getType()) + { + case NLGEORGES::UType::UnsignedInt: + case NLGEORGES::UType::SignedInt: + { + QSpinBox *spinBox = static_cast(editor); + spinBox->setValue((int)value.toDouble()); + break; + } + case NLGEORGES::UType::Double: + { + QDoubleSpinBox *spinBox = static_cast(editor); + spinBox->setValue(value.toDouble()); + break; + } + case NLGEORGES::UType::Color: + { + break; + } + default: + { + QLineEdit *textEdit = static_cast(editor); + textEdit->setText(value); + break; + } + } + } + } + + void FormDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, + const QModelIndex &index) const + { + const CGeorgesFormProxyModel * mp = dynamic_cast(index.model()); + const CGeorgesFormModel * m = dynamic_cast(mp->sourceModel()); + + const NLGEORGES::UType *type = m->getItem(mp->mapToSource(index))->getFormElm()->getType(); + int numDefinitions = type->getNumDefinition(); + + if (numDefinitions) + { + QComboBox *comboBox = static_cast(editor); + QString value = comboBox->currentText(); + QString oldValue = index.model()->data(index, Qt::DisplayRole).toString(); + if (value == oldValue) + { + // nothing's changed + } + else + { + nldebug(QString("setModelData from %1 to %2") + .arg(oldValue).arg(value).toStdString().c_str()); + model->setData(index, value, Qt::EditRole); + } + } + else + { + switch (type->getType()) + { + case NLGEORGES::UType::UnsignedInt: + case NLGEORGES::UType::SignedInt: + { + QSpinBox *spinBox = static_cast(editor); + int value = spinBox->value(); + QString oldValue = index.model()->data(index, Qt::DisplayRole).toString(); + if (QString("%1").arg(value) == oldValue) + { + // nothing's changed + } + else + { + nldebug(QString("setModelData from %1 to %2") + .arg(oldValue).arg(value).toStdString().c_str()); + model->setData(index, value, Qt::EditRole); + } + break; + } + case NLGEORGES::UType::Double: + { + QDoubleSpinBox *spinBox = static_cast(editor); + double value = spinBox->value(); + QString oldValue = index.model()->data(index, Qt::DisplayRole).toString(); + if (QString("%1").arg(value) == oldValue) + { + // nothing's changed + } + else + { + nldebug(QString("setModelData from %1 to %2") + .arg(oldValue).arg(value).toStdString().c_str()); + model->setData(index, value, Qt::EditRole); + } + break; + } + case NLGEORGES::UType::Color: + { + break; // TODO + } + default: // UType::String + { + QLineEdit *textEdit = static_cast(editor); + QString value = textEdit->text(); + QString oldValue = index.model()->data(index, Qt::DisplayRole).toString(); + if (value == oldValue) + { + // nothing's changed + } + else + { + nldebug(QString("setModelData from %1 to %2") + .arg(oldValue).arg(value).toStdString().c_str()); + model->setData(index, value, Qt::EditRole); + } + break; + } + } + } + } + + void FormDelegate::updateEditorGeometry(QWidget *editor, + const QStyleOptionViewItem &option, const QModelIndex &index) const + { + QRect r = option.rect; + editor->setGeometry(r); + //option.decorationAlignment = QStyleOptionViewItem::Right; + } + + //void FormDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const + //{ + // QStyleOptionViewItemV4 optionV4 = option; + // optionV4.decorationPosition = QStyleOptionViewItem::Right; + // //optionV4.decorationSize = QSize(32,32); + // initStyleOption(&optionV4, index); + + // QStyledItemDelegate::paint(painter,optionV4,index); + + // //QStyle *style = optionV4.widget? optionV4.widget->style() : QApplication::style(); + + // //QTextDocument doc; + // //doc.setHtml(optionV4.text); + + // ///// Painting item without text + // //optionV4.text = QString(); + // //style->drawControl(QStyle::CE_ItemViewItem, &optionV4, painter); + + // //QAbstractTextDocumentLayout::PaintContext ctx; + + // //// Highlighting text if item is selected + // //if (optionV4.state & QStyle::State_Selected) + // // ctx.palette.setColor(QPalette::Text, optionV4.palette.color(QPalette::Active, QPalette::HighlightedText)); + + // //QRect textRect = style->subElementRect(QStyle::SE_ItemViewItemText, &optionV4); + // //painter->save(); + // //painter->translate(textRect.topLeft()); + // //painter->setClipRect(textRect.translated(-textRect.topLeft())); + // //doc.documentLayout()->draw(painter, ctx); + // //painter->restore(); + //} + +} /* namespace NLQT */ diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/formdelegate.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/formdelegate.h index 1263ab58d..eff09e706 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/formdelegate.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/formdelegate.h @@ -1,45 +1,45 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#ifndef FORMDELEGATE_H -#define FORMDELEGATE_H - -#include - -namespace NLQT -{ - - class FormDelegate : public QStyledItemDelegate - { - - public: - FormDelegate(QObject *parent = 0); - - QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, - const QModelIndex &index) const; - void setEditorData(QWidget *editor, const QModelIndex &index) const; - void setModelData(QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index) const; - void updateEditorGeometry(QWidget *editor, - const QStyleOptionViewItem &option, const QModelIndex &index) const; - //void paint ( QPainter * painter, const QStyleOptionViewItem & option, - // const QModelIndex & index ) const; - }; - -} -#endif // FORMDELEGATE_H +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef FORMDELEGATE_H +#define FORMDELEGATE_H + +#include + +namespace NLQT +{ + + class FormDelegate : public QStyledItemDelegate + { + + public: + FormDelegate(QObject *parent = 0); + + QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, + const QModelIndex &index) const; + void setEditorData(QWidget *editor, const QModelIndex &index) const; + void setModelData(QWidget *editor, QAbstractItemModel *model, + const QModelIndex &index) const; + void updateEditorGeometry(QWidget *editor, + const QStyleOptionViewItem &option, const QModelIndex &index) const; + //void paint ( QPainter * painter, const QStyleOptionViewItem & option, + // const QModelIndex & index ) const; + }; + +} +#endif // FORMDELEGATE_H diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/formitem.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/formitem.cpp index 55e34f95c..5dc0fe498 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/formitem.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/formitem.cpp @@ -1,164 +1,164 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#include "formitem.h" - -// Qt includes - - -// NeL includes -#include -#include -#include - -namespace NLQT -{ - - CFormItem::CFormItem(NLGEORGES::UFormElm* elm, const QList &data, CFormItem *parent, - NLGEORGES::UFormElm::TWhereIsValue wV, NLGEORGES::UFormElm::TWhereIsNode wN) - { - parentItem = parent; - itemData = data; - formElm = elm; - whereV = wV; - whereN = wN; - } - - CFormItem::~CFormItem() - { - qDeleteAll(childItems); - } - - void CFormItem::appendChild(CFormItem *item) - { - childItems.append(item); - } - - CFormItem *CFormItem::child(int row) - { - return childItems.value(row); - } - - int CFormItem::childCount() const - { - return childItems.count(); - } - - int CFormItem::columnCount() const - { - return itemData.count(); - } - - QVariant CFormItem::data(int column) const - { - return itemData.value(column); - } - - CFormItem *CFormItem::parent() - { - return parentItem; - } - - int CFormItem::row() const - { - if (parentItem) - return parentItem->childItems.indexOf(const_cast(this)); - - return 0; - } - - bool CFormItem::setData(int column, const QVariant &value) - { - if (column < 0 || column >= itemData.size()) - return false; - - // TODO: default values - if (!formElm) - return false; - - itemData[column] = value; - if (formElm->isAtom()) - { - const NLGEORGES::UType *type = formElm->getType(); - if (type) - { - switch (type->getType()) - { - case NLGEORGES::UType::UnsignedInt: - case NLGEORGES::UType::SignedInt: - case NLGEORGES::UType::Double: - case NLGEORGES::UType::String: - if (parentItem->formElm->isArray()) - { - //((NLGEORGES::CFormElm*)parentItem->formElm);//->arrayInsertNodeByName( - //if(parentItem->formElm->getArrayNode(elmName, num)) - //{ - //} - - bool ok; - // TODO: the node can be renamed from eg "#0" to "foobar" - int arrayIndex = itemData[0].toString().remove("#").toInt(&ok); - if(ok) - { - NLGEORGES::UFormElm *elmt = 0; - if(parentItem->formElm->getArrayNode(&elmt, arrayIndex) && elmt) - { - if (elmt->isAtom()) - { - ((NLGEORGES::CFormElmAtom*)elmt)->setValue(value.toString().toStdString().c_str()); - nldebug(QString("array element string %1 %2") - .arg(itemData[0].toString()).arg(value.toString()) - .toStdString().c_str()); - } - } - } - } - else - { - if(parentItem->formElm->setValueByName( - value.toString().toStdString().c_str(), - itemData[0].toString().toStdString().c_str())) - { - nldebug(QString("string %1 %2") - .arg(itemData[0].toString()).arg(value.toString()) - .toStdString().c_str()); - } - else - { - nldebug(QString("FAILED string %1 %2") - .arg(itemData[0].toString()).arg(value.toString()) - .toStdString().c_str()); - } - } - break; - case NLGEORGES::UType::Color: - nldebug("Color is TODO"); - break; - default: - break; - } - } - } - else - { - nldebug("setting sth other than Atom"); - } - //formElm->setValueByName(); - return true; - } -} +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "formitem.h" + +// Qt includes + + +// NeL includes +#include +#include +#include + +namespace NLQT +{ + + CFormItem::CFormItem(NLGEORGES::UFormElm* elm, const QList &data, CFormItem *parent, + NLGEORGES::UFormElm::TWhereIsValue wV, NLGEORGES::UFormElm::TWhereIsNode wN) + { + parentItem = parent; + itemData = data; + formElm = elm; + whereV = wV; + whereN = wN; + } + + CFormItem::~CFormItem() + { + qDeleteAll(childItems); + } + + void CFormItem::appendChild(CFormItem *item) + { + childItems.append(item); + } + + CFormItem *CFormItem::child(int row) + { + return childItems.value(row); + } + + int CFormItem::childCount() const + { + return childItems.count(); + } + + int CFormItem::columnCount() const + { + return itemData.count(); + } + + QVariant CFormItem::data(int column) const + { + return itemData.value(column); + } + + CFormItem *CFormItem::parent() + { + return parentItem; + } + + int CFormItem::row() const + { + if (parentItem) + return parentItem->childItems.indexOf(const_cast(this)); + + return 0; + } + + bool CFormItem::setData(int column, const QVariant &value) + { + if (column < 0 || column >= itemData.size()) + return false; + + // TODO: default values + if (!formElm) + return false; + + itemData[column] = value; + if (formElm->isAtom()) + { + const NLGEORGES::UType *type = formElm->getType(); + if (type) + { + switch (type->getType()) + { + case NLGEORGES::UType::UnsignedInt: + case NLGEORGES::UType::SignedInt: + case NLGEORGES::UType::Double: + case NLGEORGES::UType::String: + if (parentItem->formElm->isArray()) + { + //((NLGEORGES::CFormElm*)parentItem->formElm);//->arrayInsertNodeByName( + //if(parentItem->formElm->getArrayNode(elmName, num)) + //{ + //} + + bool ok; + // TODO: the node can be renamed from eg "#0" to "foobar" + int arrayIndex = itemData[0].toString().remove("#").toInt(&ok); + if(ok) + { + NLGEORGES::UFormElm *elmt = 0; + if(parentItem->formElm->getArrayNode(&elmt, arrayIndex) && elmt) + { + if (elmt->isAtom()) + { + ((NLGEORGES::CFormElmAtom*)elmt)->setValue(value.toString().toStdString().c_str()); + nldebug(QString("array element string %1 %2") + .arg(itemData[0].toString()).arg(value.toString()) + .toStdString().c_str()); + } + } + } + } + else + { + if(parentItem->formElm->setValueByName( + value.toString().toStdString().c_str(), + itemData[0].toString().toStdString().c_str())) + { + nldebug(QString("string %1 %2") + .arg(itemData[0].toString()).arg(value.toString()) + .toStdString().c_str()); + } + else + { + nldebug(QString("FAILED string %1 %2") + .arg(itemData[0].toString()).arg(value.toString()) + .toStdString().c_str()); + } + } + break; + case NLGEORGES::UType::Color: + nldebug("Color is TODO"); + break; + default: + break; + } + } + } + else + { + nldebug("setting sth other than Atom"); + } + //formElm->setValueByName(); + return true; + } +} diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges.cpp index 369c62d90..ceeb8e6ac 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges.cpp @@ -1,66 +1,66 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#include "georges.h" -#include "nel/misc/o_xml.h" - -// STL includes - -// NeL includes -#include -#include -#include - -// Project includes - -using namespace NLGEORGES; - -namespace NLQT -{ - - CGeorges::CGeorges(): FormLoader(0) - { - FormLoader = UFormLoader::createLoader(); - } - - CGeorges::~CGeorges() - { - } - - UForm *CGeorges::loadForm(std::string formName) - { - UForm *form = FormLoader->loadForm(formName.c_str()); - - return form; - } - - UFormDfn *CGeorges::loadFormDfn(std::string formName) - { - UFormDfn *formdfn = FormLoader->loadFormDfn(formName.c_str()); - - return formdfn; - } - - UType *CGeorges::loadFormType(std::string formName) - { - UType *type = FormLoader->loadFormType(formName.c_str()); - - return type; - } - -} /* namespace NLQT */ +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "georges.h" +#include "nel/misc/o_xml.h" + +// STL includes + +// NeL includes +#include +#include +#include + +// Project includes + +using namespace NLGEORGES; + +namespace NLQT +{ + + CGeorges::CGeorges(): FormLoader(0) + { + FormLoader = UFormLoader::createLoader(); + } + + CGeorges::~CGeorges() + { + } + + UForm *CGeorges::loadForm(std::string formName) + { + UForm *form = FormLoader->loadForm(formName.c_str()); + + return form; + } + + UFormDfn *CGeorges::loadFormDfn(std::string formName) + { + UFormDfn *formdfn = FormLoader->loadFormDfn(formName.c_str()); + + return formdfn; + } + + UType *CGeorges::loadFormType(std::string formName) + { + UType *type = FormLoader->loadFormType(formName.c_str()); + + return type; + } + +} /* namespace NLQT */ diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges.h index 64dd61679..e103c7132 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges.h @@ -1,71 +1,71 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#ifndef GEORGES_H -#define GEORGES_H - -// Misc - -// STL includes -#include - -// NeL includes - -// Qt includes - -// Project includes - -namespace NLGEORGES -{ - class UType; - class UForm; - class UFormDfn; - class UFormLoader; -} - -using namespace NLGEORGES; - -namespace NLQT -{ - - /** - @class CGeorges - A CGeorges class loading and viewing sheets. - */ - class CGeorges - { - public: - /// Default constructor. - CGeorges(); - virtual ~CGeorges(); - - // Load the given form root - UForm* loadForm(std::string formName); - // Load a dfn - UFormDfn* loadFormDfn(std::string formName); - // Load a type - UType *loadFormType (std::string formName); - - // A form loader - UFormLoader *FormLoader; - - };/* class CGeorges */ - -} /* namespace NLQT */ - -#endif // GEORGES_H +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef GEORGES_H +#define GEORGES_H + +// Misc + +// STL includes +#include + +// NeL includes + +// Qt includes + +// Project includes + +namespace NLGEORGES +{ + class UType; + class UForm; + class UFormDfn; + class UFormLoader; +} + +using namespace NLGEORGES; + +namespace NLQT +{ + + /** + @class CGeorges + A CGeorges class loading and viewing sheets. + */ + class CGeorges + { + public: + /// Default constructor. + CGeorges(); + virtual ~CGeorges(); + + // Load the given form root + UForm* loadForm(std::string formName); + // Load a dfn + UFormDfn* loadFormDfn(std::string formName); + // Load a type + UType *loadFormType (std::string formName); + + // A form loader + UFormLoader *FormLoader; + + };/* class CGeorges */ + +} /* namespace NLQT */ + +#endif // GEORGES_H diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_dirtree_dialog.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_dirtree_dialog.cpp index 6d1c999f6..728c0c1d7 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_dirtree_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_dirtree_dialog.cpp @@ -1,142 +1,142 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -*/ - -#include "georges_dirtree_dialog.h" - -// Qt includes -#include -#include - -// NeL includes - -// Project includes -#include "modules.h" - -using namespace NLMISC; - -namespace NLQT -{ - - CGeorgesDirTreeDialog::CGeorgesDirTreeDialog(QString ldPath, QWidget *parent) - :QDockWidget(parent), _ldPath(ldPath) - { - - _ui.setupUi(this); - - //QStyleOptionViewItem myButtonOption; - // const QStyleOptionViewItem *buttonOption = - // qstyleoption_cast(_ui.dirTree->style()); - - /*setStyleSheet(" \ - QTreeView { \ - alternate-background-color: yellow; \ - } \ - QTreeView::item { \ - border: 1px solid #d9d9d9; \ - border-top-color: transparent; \ - border-bottom-color: transparent; \ - } \ - QTreeView::item:hover { \ - background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e7effd, stop: 1 #cbdaf1);\ - border: 1px solid #bfcde4; \ - } \ - QTreeView::item:selected { \ - border: 1px solid #567dbc; \ - } \ - QTreeView::item:selected:active{ \ - background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6ea1f1, stop: 1 #567dbc);\ - } \ - QTreeView::item:selected:!active { \ - background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6b9be8, stop: 1 #577fbf);\ - }\ - ");*/ - //QString leveldata = Modules::config().getConfigFile().getVar("SearchPaths").asString().c_str(); - - _dirModel = new CFileSystemModel(_ldPath); - _ui.dirTree->setModel(_dirModel); - - QFileInfo info(_ldPath); - - if (!_ldPath.isEmpty() && info.isDir()) - { - _dirModel->setRootPath(_ldPath); - _ui.dirTree->setRootIndex(_dirModel->index(_ldPath)); - } - else - { - _dirModel->setRootPath(QDir::currentPath()); - } - - _ui.dirTree->setAnimated(false); - _ui.dirTree->setIndentation(20); - //_ui.dirTree->setSortingEnabled(true); - - /*connect(_ui.dirTree, SIGNAL(clicked(QModelIndex)), - this, SLOT(fileSelected(QModelIndex)));*/ - connect(_ui.dirTree, SIGNAL(activated(QModelIndex)), - this, SLOT(fileSelected(QModelIndex))); - } - - CGeorgesDirTreeDialog::~CGeorgesDirTreeDialog() - { - delete _dirModel; - } - - void CGeorgesDirTreeDialog::fileSelected(QModelIndex index) - { - QString name; - if (index.isValid() && !_dirModel->isDir(index)) - { - Q_EMIT selectedForm(_dirModel->fileName(index)); - } - } - - void CGeorgesDirTreeDialog::changeFile(QString file) - { - QModelIndex index = _dirModel->index(file); - //_dirModel->; - _ui.dirTree->selectionModel()->select(index,QItemSelectionModel::ClearAndSelect); - _ui.dirTree->scrollTo(index,QAbstractItemView::PositionAtCenter); - fileSelected(index); - } - - void CGeorgesDirTreeDialog::ldPathChanged(QString path) - { - _ldPath = path; - QFileInfo info(_ldPath); - - delete _dirModel; - - if (!_ldPath.isEmpty() && info.isDir()) - { - _dirModel = new CFileSystemModel(_ldPath); - _ui.dirTree->setModel(_dirModel); - _dirModel->setRootPath(_ldPath); - _ui.dirTree->setRootIndex(_dirModel->index(_ldPath)); - } - else - { - _dirModel = new CFileSystemModel(""); - _ui.dirTree->setModel(_dirModel); - _dirModel->setRootPath(QDir::currentPath()); - _ldPath = ""; - } - } - +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +*/ + +#include "georges_dirtree_dialog.h" + +// Qt includes +#include +#include + +// NeL includes + +// Project includes +#include "modules.h" + +using namespace NLMISC; + +namespace NLQT +{ + + CGeorgesDirTreeDialog::CGeorgesDirTreeDialog(QString ldPath, QWidget *parent) + :QDockWidget(parent), _ldPath(ldPath) + { + + _ui.setupUi(this); + + //QStyleOptionViewItem myButtonOption; + // const QStyleOptionViewItem *buttonOption = + // qstyleoption_cast(_ui.dirTree->style()); + + /*setStyleSheet(" \ + QTreeView { \ + alternate-background-color: yellow; \ + } \ + QTreeView::item { \ + border: 1px solid #d9d9d9; \ + border-top-color: transparent; \ + border-bottom-color: transparent; \ + } \ + QTreeView::item:hover { \ + background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #e7effd, stop: 1 #cbdaf1);\ + border: 1px solid #bfcde4; \ + } \ + QTreeView::item:selected { \ + border: 1px solid #567dbc; \ + } \ + QTreeView::item:selected:active{ \ + background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6ea1f1, stop: 1 #567dbc);\ + } \ + QTreeView::item:selected:!active { \ + background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #6b9be8, stop: 1 #577fbf);\ + }\ + ");*/ + //QString leveldata = Modules::config().getConfigFile().getVar("SearchPaths").asString().c_str(); + + _dirModel = new CFileSystemModel(_ldPath); + _ui.dirTree->setModel(_dirModel); + + QFileInfo info(_ldPath); + + if (!_ldPath.isEmpty() && info.isDir()) + { + _dirModel->setRootPath(_ldPath); + _ui.dirTree->setRootIndex(_dirModel->index(_ldPath)); + } + else + { + _dirModel->setRootPath(QDir::currentPath()); + } + + _ui.dirTree->setAnimated(false); + _ui.dirTree->setIndentation(20); + //_ui.dirTree->setSortingEnabled(true); + + /*connect(_ui.dirTree, SIGNAL(clicked(QModelIndex)), + this, SLOT(fileSelected(QModelIndex)));*/ + connect(_ui.dirTree, SIGNAL(activated(QModelIndex)), + this, SLOT(fileSelected(QModelIndex))); + } + + CGeorgesDirTreeDialog::~CGeorgesDirTreeDialog() + { + delete _dirModel; + } + + void CGeorgesDirTreeDialog::fileSelected(QModelIndex index) + { + QString name; + if (index.isValid() && !_dirModel->isDir(index)) + { + Q_EMIT selectedForm(_dirModel->fileName(index)); + } + } + + void CGeorgesDirTreeDialog::changeFile(QString file) + { + QModelIndex index = _dirModel->index(file); + //_dirModel->; + _ui.dirTree->selectionModel()->select(index,QItemSelectionModel::ClearAndSelect); + _ui.dirTree->scrollTo(index,QAbstractItemView::PositionAtCenter); + fileSelected(index); + } + + void CGeorgesDirTreeDialog::ldPathChanged(QString path) + { + _ldPath = path; + QFileInfo info(_ldPath); + + delete _dirModel; + + if (!_ldPath.isEmpty() && info.isDir()) + { + _dirModel = new CFileSystemModel(_ldPath); + _ui.dirTree->setModel(_dirModel); + _dirModel->setRootPath(_ldPath); + _ui.dirTree->setRootIndex(_dirModel->index(_ldPath)); + } + else + { + _dirModel = new CFileSystemModel(""); + _ui.dirTree->setModel(_dirModel); + _dirModel->setRootPath(QDir::currentPath()); + _ldPath = ""; + } + } + } /* namespace NLQT */ \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_dirtree_dialog.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_dirtree_dialog.h index 1c476350a..9f110e991 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_dirtree_dialog.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_dirtree_dialog.h @@ -1,65 +1,65 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#ifndef GEORGES_DIRTREE_DIALOG_H -#define GEORGES_DIRTREE_DIALOG_H - -// Qt includes -#include - -// STL includes - -// NeL includes - -// Project includes -#include "ui_georges_dirtree_form.h" -#include "filesystem_model.h" - -namespace NLQT -{ - - class CGeorgesDirTreeDialog: public QDockWidget - { - Q_OBJECT - - public: - CGeorgesDirTreeDialog(QString ldPath, QWidget *parent = 0); - ~CGeorgesDirTreeDialog(); - - private: - Ui::CGeorgesDirTreeDialog _ui; - - CFileSystemModel *_dirModel; - QString _ldPath; - - Q_SIGNALS: - void selectedForm(const QString); - - public Q_SLOTS: - void ldPathChanged(QString path); - - private Q_SLOTS: - void fileSelected(QModelIndex index); - void changeFile(QString file); - - friend class CMainWindow; - }; /* CGEorgesDirTreeDialog */ - -} /* namespace NLQT */ - -#endif // GEORGES_DIRTREE_DIALOG_H +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef GEORGES_DIRTREE_DIALOG_H +#define GEORGES_DIRTREE_DIALOG_H + +// Qt includes +#include + +// STL includes + +// NeL includes + +// Project includes +#include "ui_georges_dirtree_form.h" +#include "filesystem_model.h" + +namespace NLQT +{ + + class CGeorgesDirTreeDialog: public QDockWidget + { + Q_OBJECT + + public: + CGeorgesDirTreeDialog(QString ldPath, QWidget *parent = 0); + ~CGeorgesDirTreeDialog(); + + private: + Ui::CGeorgesDirTreeDialog _ui; + + CFileSystemModel *_dirModel; + QString _ldPath; + + Q_SIGNALS: + void selectedForm(const QString); + + public Q_SLOTS: + void ldPathChanged(QString path); + + private Q_SLOTS: + void fileSelected(QModelIndex index); + void changeFile(QString file); + + friend class CMainWindow; + }; /* CGEorgesDirTreeDialog */ + +} /* namespace NLQT */ + +#endif // GEORGES_DIRTREE_DIALOG_H diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_splash.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_splash.cpp index b28dfc3d8..8bc921472 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_splash.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_splash.cpp @@ -1,73 +1,73 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -*/ - -#include "georges_splash.h" - -// Qt includes -#include -#include -#include - -// NeL includes - -// Project includes - -namespace NLMISC { - class IProgressCallback; -} - -namespace NLQT -{ - - CGeorgesSplash::CGeorgesSplash(QWidget *parent) - : QWidget(parent) - { - _ui.setupUi(this); - - setWindowFlags(Qt::SplashScreen); - _ui.imageLabel->setPixmap( - QPixmap(":/images/georges_logo.png"). - scaledToHeight(_ui.imageLabel->height(),Qt::SmoothTransformation)); - //setWindowIcon(QIcon(":/images/georges_logo.png")); - } - - CGeorgesSplash::~CGeorgesSplash() - { - - } - - void CGeorgesSplash::progress (float progressValue) - { - QString display = DisplayString.c_str(); - - // UNCOMMENT if shorter strings are needed - //QFileInfo info(display); - //display = info.filePath(); - //QString sec = display.section("/",-2,-1, - // QString::SectionSkipEmpty | - // QString::SectionIncludeTrailingSep | - // QString::SectionIncludeLeadingSep); - //if(display != sec) - // display = sec.prepend("..."); - - _ui.splashLabel->setText(QString(tr("Adding Folder:\n%1")).arg(display)); - _ui.progressBar->setValue(getCropedValue(progressValue) * 100); - QApplication::processEvents(); - } +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +*/ + +#include "georges_splash.h" + +// Qt includes +#include +#include +#include + +// NeL includes + +// Project includes + +namespace NLMISC { + class IProgressCallback; +} + +namespace NLQT +{ + + CGeorgesSplash::CGeorgesSplash(QWidget *parent) + : QWidget(parent) + { + _ui.setupUi(this); + + setWindowFlags(Qt::SplashScreen); + _ui.imageLabel->setPixmap( + QPixmap(":/images/georges_logo.png"). + scaledToHeight(_ui.imageLabel->height(),Qt::SmoothTransformation)); + //setWindowIcon(QIcon(":/images/georges_logo.png")); + } + + CGeorgesSplash::~CGeorgesSplash() + { + + } + + void CGeorgesSplash::progress (float progressValue) + { + QString display = DisplayString.c_str(); + + // UNCOMMENT if shorter strings are needed + //QFileInfo info(display); + //display = info.filePath(); + //QString sec = display.section("/",-2,-1, + // QString::SectionSkipEmpty | + // QString::SectionIncludeTrailingSep | + // QString::SectionIncludeLeadingSep); + //if(display != sec) + // display = sec.prepend("..."); + + _ui.splashLabel->setText(QString(tr("Adding Folder:\n%1")).arg(display)); + _ui.progressBar->setValue(getCropedValue(progressValue) * 100); + QApplication::processEvents(); + } } /* namespace NLQT */ \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_splash.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_splash.h index 336dab431..769e35190 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_splash.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_splash.h @@ -1,56 +1,56 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#ifndef GEORGES_SPLASH_H -#define GEORGES_SPLASH_H - -// Qt includes -#include - -// STL includes - -// NeL includes - -// NeL includes -#include - -// Project includes -#include "ui_splash.h" - -namespace NLMISC { - class IProgressCallback; -} - -namespace NLQT -{ - class CGeorgesSplash: public QWidget, public NLMISC::IProgressCallback - { - Q_OBJECT - - Ui::CGeorgesSplash _ui; - - void progress (float progressValue); - - public: - CGeorgesSplash(QWidget *parent = 0); - ~CGeorgesSplash(); - }; /* CGeorgesSplash */ - -} /* namespace NLQT */ - -#endif // GEORGES_SPLASH_H +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef GEORGES_SPLASH_H +#define GEORGES_SPLASH_H + +// Qt includes +#include + +// STL includes + +// NeL includes + +// NeL includes +#include + +// Project includes +#include "ui_splash.h" + +namespace NLMISC { + class IProgressCallback; +} + +namespace NLQT +{ + class CGeorgesSplash: public QWidget, public NLMISC::IProgressCallback + { + Q_OBJECT + + Ui::CGeorgesSplash _ui; + + void progress (float progressValue); + + public: + CGeorgesSplash(QWidget *parent = 0); + ~CGeorgesSplash(); + }; /* CGeorgesSplash */ + +} /* namespace NLQT */ + +#endif // GEORGES_SPLASH_H diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_treeview_dialog.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_treeview_dialog.cpp index b2c3d5a64..cae202aa8 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_treeview_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_treeview_dialog.cpp @@ -1,423 +1,423 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -*/ - -#include "georges_treeview_dialog.h" - -// Qt includes -#include -#include -#include - -// NeL includes -#include -#include -#include -#include - -// Project includes -#include "modules.h" -#include "georges.h" -#include "georgesform_model.h" -#include "georgesform_proxy_model.h" -#include "formitem.h" -#include "formdelegate.h" - -using namespace NLMISC; -using namespace NLGEORGES; - -namespace NLQT -{ - - CGeorgesTreeViewDialog::CGeorgesTreeViewDialog(QWidget *parent /*= 0*/, bool emptyView /*= false*/) - : QDockWidget(parent) - { - _georges = new NLQT::CGeorges; - - loadedForm = ""; - _modified = false; - - _ui.setupUi(this); - _ui.treeViewTabWidget->setTabEnabled (2,false); - - if (emptyView) - { - _ui.treeViewTabWidget->clear(); - setWindowTitle("Form Area"); - } - - _ui.checkBoxParent->setStyleSheet("background-color: rgba(0,255,0,30)"); - _ui.checkBoxDefaults->setStyleSheet("background-color: rgba(255,0,0,30)"); - _form = 0; - - FormDelegate *formdelegate = new FormDelegate(this); - _ui.treeView->setItemDelegateForColumn(1, formdelegate); - - - connect(_ui.treeView, SIGNAL(doubleClicked (QModelIndex)), - this, SLOT(doubleClicked (QModelIndex))); - connect(_ui.checkBoxParent, SIGNAL(toggled(bool)), - this, SLOT(filterRows())); - connect(_ui.checkBoxDefaults, SIGNAL(toggled(bool)), - this, SLOT(filterRows())); - } - - CGeorgesTreeViewDialog::~CGeorgesTreeViewDialog() - { - delete _ui.treeView->itemDelegateForColumn(1); - delete _form; - deleteLater(); - //QSettings settings("RyzomCore", "GeorgesQt"); - //settings.setValue("dirViewGeometry", saveGeometry()); - } - - void CGeorgesTreeViewDialog::setForm(const CForm *form) - { - _form = (UForm*)form; - } - - CForm* CGeorgesTreeViewDialog::getFormByName(const QString formName) - { - if(NLMISC::CPath::exists(formName.toStdString())) - { - return (CForm*)_georges->loadForm(formName.toStdString()); - } - else - { - CForm *form = 0; - // Load the DFN - std::string extStr = NLMISC::CFile::getExtension( formName.toStdString() ); - QString dfnName = QString("%1.dfn").arg(extStr.c_str()); - UFormDfn *formdfn; - if (NLMISC::CPath::exists(dfnName.toStdString())) - { - formdfn = _georges->loadFormDfn (dfnName.toStdString()); - if (!formdfn) - { - nlwarning("Failed to load dfn: %s", dfnName.toStdString().c_str()); - return 0; - } - } - else - { - nlwarning("Cannot find dfn: %s", dfnName.toStdString().c_str()); - return 0; - } - - form = new CForm; - - // Build the root element - ((CFormElmStruct*)&form->getRootNode())->build((CFormDfn*)formdfn); - - uint i; - for (i=0; iHeldElements[i]))->build ((CFormDfn*)formdfn); - } - return form; - } - return 0; - } - - void CGeorgesTreeViewDialog::loadFormIntoDialog(CForm *form) - { - - if(form) - _form = form; - - if (_form) - { - UFormElm *root = 0; - root = &_form->getRootNode(); - - QStringList parents; - for (uint i = 0; i < _form->getNumParent(); i++) - { - UForm *u = _form->getParentForm(i); - parents << u->getFilename().c_str(); - } - - QString comments; - comments = _form->getComment().c_str(); - - if (!comments.isEmpty()) - { - _ui.treeViewTabWidget->setTabEnabled (1,true); - _ui.commentEdit->setPlainText(comments); - } - - QStringList strList; - std::set dependencies; - _form->getDependencies(dependencies); - - QMap< QString, QStringList> deps; - Q_FOREACH(std::string str, dependencies) - { - QString file = str.c_str(); - if (str == _form->getFilename()) continue; - deps[file.remove(0,file.indexOf(".")+1)] << str.c_str(); - } - nlinfo("typ's %d",deps["typ"].count()); - nlinfo("dfn's %d",deps["dfn"].count()); - - //nlwarning(strList.join(";").toStdString().c_str()); - if (root) - { - loadedForm = _form->getFilename().c_str(); - - CGeorgesFormModel *model = new CGeorgesFormModel(root,deps,comments,parents); - CGeorgesFormProxyModel *proxyModel = new CGeorgesFormProxyModel(); - proxyModel->setSourceModel(model); - _ui.treeView->setModel(proxyModel); - _ui.treeView->expandAll(); - _ui.treeView->resizeColumnToContents(0); - _ui.treeView->resizeColumnToContents(1); - _ui.treeView->resizeColumnToContents(2); - //_ui.treeView->hideColumn(3); - - filterRows(); - - //_ui.treeView->setRowHidden(0,QModelIndex(),true); - connect(model, SIGNAL(dataChanged(const QModelIndex, const QModelIndex)), - this, SLOT(modifiedFile())); - - Modules::mainWin().setWindowTitle("Qt Georges Editor - " + loadedForm); - //Modules::mainWin().getTabBar(); - } - } - } - - void CGeorgesTreeViewDialog::addParentForm(CForm *form) - { - ((CForm*)_form)->insertParent(((CForm*)_form)->getParentCount(), form->getFilename().c_str(), form); - } - - void CGeorgesTreeViewDialog::modifiedFile( ) - { - if (!_modified) - { - _modified = true; - setWindowTitle(windowTitle()+"*"); - Modules::mainWin().setWindowTitle(Modules::mainWin().windowTitle()+"*"); - Q_EMIT modified(_modified); - } - } - - void CGeorgesTreeViewDialog::write( ) - { - - COFile file; - std::string s = CPath::lookup(loadedForm.toStdString(), false); - if (file.open (s)) - { - try - { - if (loadedForm.contains(".typ")) - { - //nlassert (Type != NULL); - - //// Write the file - //// Modified ? - //if (IsModified ()) - //{ - // Type->Header.MinorVersion++; - // flushValueChange (); - //} - //Type->write (xmlStream.getDocument (), theApp.Georges4CVS); - //modify (NULL, NULL, false); - //flushValueChange (); - //UpdateAllViews (NULL); - //return TRUE; - } - else if (loadedForm.contains(".dfn")) - { - //nlassert (Dfn != NULL); - - //// Write the file - //if (IsModified ()) - //{ - // Dfn->Header.MinorVersion++; - // flushValueChange (); - //} - //Dfn->write (xmlStream.getDocument (), lpszPathName, theApp.Georges4CVS); - //modify (NULL, NULL, false); - //UpdateAllViews (NULL); - //return TRUE; - } - else - { - nlassert (_form != NULL); - - // Write the file - /*if (IsModified ()) - { - ((CForm*)(UForm*)Form)->Header.MinorVersion++; - }*/ - //((CForm*)(UForm*)Form)->write (xmlStream.getDocument (), lpszPathName, theApp.Georges4CVS); - _form->write(file, false); - setWindowTitle(windowTitle().remove("*")); - _modified = false; - //if (strcmp (xmlStream.getErrorString (), "") != 0) - //{ - // char message[512]; - // smprintf (message, 512, "Error while saving file: %s", xmlStream.getErrorString ()); - //theApp.outputError (message); - //} - //modify (NULL, NULL, false); - //flushValueChange (); - //UpdateAllViews (NULL); - - // Get the left view - //CView* pView = getLeftView (); - } - } - catch (Exception &e) - { - nlerror("Error while loading file: %s", e.what()); - } - } - else - { //if (!file.open()) - nlerror("Can't open the file %s for writing.", s.c_str()); - } - } - - void CGeorgesTreeViewDialog::doubleClicked ( const QModelIndex & index ) - { - // TODO: this is messy :( perhaps this can be done better - CGeorgesFormProxyModel * mp = - dynamic_cast(_ui.treeView->model()); - CGeorgesFormModel *m = - dynamic_cast(mp->sourceModel()); - QModelIndex in = mp->mapToSource(index); - - // col containing additional stuff like icons - if (index.column() == 2) - { - QModelIndex in2 = m->index(in.row(),in.column()-1,in.parent()); - CFormItem *item = m->getItem(in2); - QString value = item->data(1).toString(); - - QString path = CPath::lookup(value.toStdString(),false).c_str(); - - if(value.contains(".tga") || value.contains(".png")) - { - QString file = QFileDialog::getOpenFileName( - this, - "Select a new image", - path, - "Images (*.png *.tga)" - ); - if (file.isNull()) - return; - QFileInfo info = QFileInfo(file); - - // TODO? - // right way would be another delegate but im too lazy :) - // so for now i just call it directly - m->setData(in2, info.fileName()); - return; - } - else - { - if (path.contains(".shape") || path.contains(".ps")) - { - if (Modules::objViewInt()) - { - Modules::objViewInt()->resetScene(); - //Modules::config().configRemapExtensions(); - Modules::objViewInt()->loadMesh(path.toStdString(),""); - } - return; - } - } - - // open eg parent files - if (!path.isEmpty()) - Q_EMIT changeFile(path); - - } - } - - void CGeorgesTreeViewDialog::closeEvent(QCloseEvent *event) - { - if (Modules::mainWin().getEmptyView() == this) - { - event->ignore(); - } - else - { - if(Modules::mainWin().getTreeViewList().size() == 1) - { - Modules::mainWin().createEmptyView( - Modules::mainWin().getTreeViewList().takeFirst()); - } - Modules::mainWin().getTreeViewList().removeOne(this); - deleteLater(); - } - } - - void CGeorgesTreeViewDialog::filterRows() - { - nlinfo("CGeorgesTreeViewDialog::filterRows"); - CGeorgesFormProxyModel * mp = dynamic_cast(_ui.treeView->model()); - CGeorgesFormModel *m = dynamic_cast(mp->sourceModel()); - if (m) { - m->setShowParents(_ui.checkBoxParent->isChecked()); - m->setShowDefaults(_ui.checkBoxDefaults->isChecked()); - } - - //CGeorgesFormProxyModel * mp = dynamic_cast(_ui.treeView->model()); - //CGeorgesFormModel *m = dynamic_cast(mp->sourceModel()); - - //for (int i = 0; i < m->rowCount(); i++) - //{ - // const QModelIndex in = m->index(i,0); - // if (m->getItem(in)->nodeFrom() == UFormElm::NodeParentForm) - // { - // if (newState == Qt::Checked) - // { - // _ui.treeView->setRowHidden(in.row(),in.parent(),false); - // } - // else - // { - // _ui.treeView->setRowHidden(in.row(),in.parent(),true); - // } - // } - // else - // { // search childs // recursive? - // for (int j = 0; j < m->rowCount(in); j++) - // { - // const QModelIndex in2 = m->index(j,0,in); - // if (m->getItem(in2)->nodeFrom() == UFormElm::NodeParentForm) - // { - // if (newState == Qt::Checked) - // { - // _ui.treeView->setRowHidden(in2.row(),in,false); - // } - // else - // { - // _ui.treeView->setRowHidden(in2.row(),in,true); - // } - // } - // } - // } // end of search childs - //} - } - -} /* namespace NLQT */ +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +*/ + +#include "georges_treeview_dialog.h" + +// Qt includes +#include +#include +#include + +// NeL includes +#include +#include +#include +#include + +// Project includes +#include "modules.h" +#include "georges.h" +#include "georgesform_model.h" +#include "georgesform_proxy_model.h" +#include "formitem.h" +#include "formdelegate.h" + +using namespace NLMISC; +using namespace NLGEORGES; + +namespace NLQT +{ + + CGeorgesTreeViewDialog::CGeorgesTreeViewDialog(QWidget *parent /*= 0*/, bool emptyView /*= false*/) + : QDockWidget(parent) + { + _georges = new NLQT::CGeorges; + + loadedForm = ""; + _modified = false; + + _ui.setupUi(this); + _ui.treeViewTabWidget->setTabEnabled (2,false); + + if (emptyView) + { + _ui.treeViewTabWidget->clear(); + setWindowTitle("Form Area"); + } + + _ui.checkBoxParent->setStyleSheet("background-color: rgba(0,255,0,30)"); + _ui.checkBoxDefaults->setStyleSheet("background-color: rgba(255,0,0,30)"); + _form = 0; + + FormDelegate *formdelegate = new FormDelegate(this); + _ui.treeView->setItemDelegateForColumn(1, formdelegate); + + + connect(_ui.treeView, SIGNAL(doubleClicked (QModelIndex)), + this, SLOT(doubleClicked (QModelIndex))); + connect(_ui.checkBoxParent, SIGNAL(toggled(bool)), + this, SLOT(filterRows())); + connect(_ui.checkBoxDefaults, SIGNAL(toggled(bool)), + this, SLOT(filterRows())); + } + + CGeorgesTreeViewDialog::~CGeorgesTreeViewDialog() + { + delete _ui.treeView->itemDelegateForColumn(1); + delete _form; + deleteLater(); + //QSettings settings("RyzomCore", "GeorgesQt"); + //settings.setValue("dirViewGeometry", saveGeometry()); + } + + void CGeorgesTreeViewDialog::setForm(const CForm *form) + { + _form = (UForm*)form; + } + + CForm* CGeorgesTreeViewDialog::getFormByName(const QString formName) + { + if(NLMISC::CPath::exists(formName.toStdString())) + { + return (CForm*)_georges->loadForm(formName.toStdString()); + } + else + { + CForm *form = 0; + // Load the DFN + std::string extStr = NLMISC::CFile::getExtension( formName.toStdString() ); + QString dfnName = QString("%1.dfn").arg(extStr.c_str()); + UFormDfn *formdfn; + if (NLMISC::CPath::exists(dfnName.toStdString())) + { + formdfn = _georges->loadFormDfn (dfnName.toStdString()); + if (!formdfn) + { + nlwarning("Failed to load dfn: %s", dfnName.toStdString().c_str()); + return 0; + } + } + else + { + nlwarning("Cannot find dfn: %s", dfnName.toStdString().c_str()); + return 0; + } + + form = new CForm; + + // Build the root element + ((CFormElmStruct*)&form->getRootNode())->build((CFormDfn*)formdfn); + + uint i; + for (i=0; iHeldElements[i]))->build ((CFormDfn*)formdfn); + } + return form; + } + return 0; + } + + void CGeorgesTreeViewDialog::loadFormIntoDialog(CForm *form) + { + + if(form) + _form = form; + + if (_form) + { + UFormElm *root = 0; + root = &_form->getRootNode(); + + QStringList parents; + for (uint i = 0; i < _form->getNumParent(); i++) + { + UForm *u = _form->getParentForm(i); + parents << u->getFilename().c_str(); + } + + QString comments; + comments = _form->getComment().c_str(); + + if (!comments.isEmpty()) + { + _ui.treeViewTabWidget->setTabEnabled (1,true); + _ui.commentEdit->setPlainText(comments); + } + + QStringList strList; + std::set dependencies; + _form->getDependencies(dependencies); + + QMap< QString, QStringList> deps; + Q_FOREACH(std::string str, dependencies) + { + QString file = str.c_str(); + if (str == _form->getFilename()) continue; + deps[file.remove(0,file.indexOf(".")+1)] << str.c_str(); + } + nlinfo("typ's %d",deps["typ"].count()); + nlinfo("dfn's %d",deps["dfn"].count()); + + //nlwarning(strList.join(";").toStdString().c_str()); + if (root) + { + loadedForm = _form->getFilename().c_str(); + + CGeorgesFormModel *model = new CGeorgesFormModel(root,deps,comments,parents); + CGeorgesFormProxyModel *proxyModel = new CGeorgesFormProxyModel(); + proxyModel->setSourceModel(model); + _ui.treeView->setModel(proxyModel); + _ui.treeView->expandAll(); + _ui.treeView->resizeColumnToContents(0); + _ui.treeView->resizeColumnToContents(1); + _ui.treeView->resizeColumnToContents(2); + //_ui.treeView->hideColumn(3); + + filterRows(); + + //_ui.treeView->setRowHidden(0,QModelIndex(),true); + connect(model, SIGNAL(dataChanged(const QModelIndex, const QModelIndex)), + this, SLOT(modifiedFile())); + + Modules::mainWin().setWindowTitle("Qt Georges Editor - " + loadedForm); + //Modules::mainWin().getTabBar(); + } + } + } + + void CGeorgesTreeViewDialog::addParentForm(CForm *form) + { + ((CForm*)_form)->insertParent(((CForm*)_form)->getParentCount(), form->getFilename().c_str(), form); + } + + void CGeorgesTreeViewDialog::modifiedFile( ) + { + if (!_modified) + { + _modified = true; + setWindowTitle(windowTitle()+"*"); + Modules::mainWin().setWindowTitle(Modules::mainWin().windowTitle()+"*"); + Q_EMIT modified(_modified); + } + } + + void CGeorgesTreeViewDialog::write( ) + { + + COFile file; + std::string s = CPath::lookup(loadedForm.toStdString(), false); + if (file.open (s)) + { + try + { + if (loadedForm.contains(".typ")) + { + //nlassert (Type != NULL); + + //// Write the file + //// Modified ? + //if (IsModified ()) + //{ + // Type->Header.MinorVersion++; + // flushValueChange (); + //} + //Type->write (xmlStream.getDocument (), theApp.Georges4CVS); + //modify (NULL, NULL, false); + //flushValueChange (); + //UpdateAllViews (NULL); + //return TRUE; + } + else if (loadedForm.contains(".dfn")) + { + //nlassert (Dfn != NULL); + + //// Write the file + //if (IsModified ()) + //{ + // Dfn->Header.MinorVersion++; + // flushValueChange (); + //} + //Dfn->write (xmlStream.getDocument (), lpszPathName, theApp.Georges4CVS); + //modify (NULL, NULL, false); + //UpdateAllViews (NULL); + //return TRUE; + } + else + { + nlassert (_form != NULL); + + // Write the file + /*if (IsModified ()) + { + ((CForm*)(UForm*)Form)->Header.MinorVersion++; + }*/ + //((CForm*)(UForm*)Form)->write (xmlStream.getDocument (), lpszPathName, theApp.Georges4CVS); + _form->write(file, false); + setWindowTitle(windowTitle().remove("*")); + _modified = false; + //if (strcmp (xmlStream.getErrorString (), "") != 0) + //{ + // char message[512]; + // smprintf (message, 512, "Error while saving file: %s", xmlStream.getErrorString ()); + //theApp.outputError (message); + //} + //modify (NULL, NULL, false); + //flushValueChange (); + //UpdateAllViews (NULL); + + // Get the left view + //CView* pView = getLeftView (); + } + } + catch (Exception &e) + { + nlerror("Error while loading file: %s", e.what()); + } + } + else + { //if (!file.open()) + nlerror("Can't open the file %s for writing.", s.c_str()); + } + } + + void CGeorgesTreeViewDialog::doubleClicked ( const QModelIndex & index ) + { + // TODO: this is messy :( perhaps this can be done better + CGeorgesFormProxyModel * mp = + dynamic_cast(_ui.treeView->model()); + CGeorgesFormModel *m = + dynamic_cast(mp->sourceModel()); + QModelIndex in = mp->mapToSource(index); + + // col containing additional stuff like icons + if (index.column() == 2) + { + QModelIndex in2 = m->index(in.row(),in.column()-1,in.parent()); + CFormItem *item = m->getItem(in2); + QString value = item->data(1).toString(); + + QString path = CPath::lookup(value.toStdString(),false).c_str(); + + if(value.contains(".tga") || value.contains(".png")) + { + QString file = QFileDialog::getOpenFileName( + this, + "Select a new image", + path, + "Images (*.png *.tga)" + ); + if (file.isNull()) + return; + QFileInfo info = QFileInfo(file); + + // TODO? + // right way would be another delegate but im too lazy :) + // so for now i just call it directly + m->setData(in2, info.fileName()); + return; + } + else + { + if (path.contains(".shape") || path.contains(".ps")) + { + if (Modules::objViewInt()) + { + Modules::objViewInt()->resetScene(); + //Modules::config().configRemapExtensions(); + Modules::objViewInt()->loadMesh(path.toStdString(),""); + } + return; + } + } + + // open eg parent files + if (!path.isEmpty()) + Q_EMIT changeFile(path); + + } + } + + void CGeorgesTreeViewDialog::closeEvent(QCloseEvent *event) + { + if (Modules::mainWin().getEmptyView() == this) + { + event->ignore(); + } + else + { + if(Modules::mainWin().getTreeViewList().size() == 1) + { + Modules::mainWin().createEmptyView( + Modules::mainWin().getTreeViewList().takeFirst()); + } + Modules::mainWin().getTreeViewList().removeOne(this); + deleteLater(); + } + } + + void CGeorgesTreeViewDialog::filterRows() + { + nlinfo("CGeorgesTreeViewDialog::filterRows"); + CGeorgesFormProxyModel * mp = dynamic_cast(_ui.treeView->model()); + CGeorgesFormModel *m = dynamic_cast(mp->sourceModel()); + if (m) { + m->setShowParents(_ui.checkBoxParent->isChecked()); + m->setShowDefaults(_ui.checkBoxDefaults->isChecked()); + } + + //CGeorgesFormProxyModel * mp = dynamic_cast(_ui.treeView->model()); + //CGeorgesFormModel *m = dynamic_cast(mp->sourceModel()); + + //for (int i = 0; i < m->rowCount(); i++) + //{ + // const QModelIndex in = m->index(i,0); + // if (m->getItem(in)->nodeFrom() == UFormElm::NodeParentForm) + // { + // if (newState == Qt::Checked) + // { + // _ui.treeView->setRowHidden(in.row(),in.parent(),false); + // } + // else + // { + // _ui.treeView->setRowHidden(in.row(),in.parent(),true); + // } + // } + // else + // { // search childs // recursive? + // for (int j = 0; j < m->rowCount(in); j++) + // { + // const QModelIndex in2 = m->index(j,0,in); + // if (m->getItem(in2)->nodeFrom() == UFormElm::NodeParentForm) + // { + // if (newState == Qt::Checked) + // { + // _ui.treeView->setRowHidden(in2.row(),in,false); + // } + // else + // { + // _ui.treeView->setRowHidden(in2.row(),in,true); + // } + // } + // } + // } // end of search childs + //} + } + +} /* namespace NLQT */ diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_treeview_dialog.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_treeview_dialog.h index af17ba1df..ffd9cb275 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_treeview_dialog.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georges_treeview_dialog.h @@ -1,89 +1,89 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#ifndef GEORGES_TREEVIEWER_DIALOG_H -#define GEORGES_TREEVIEWER_DIALOG_H - -#include "ui_georges_treeview_form.h" - -// Qt includes -#include - -// STL includes - -// NeL includes - -// Project includes - -namespace NLGEORGES -{ - class UForm; - class CForm; -} - -using namespace NLGEORGES; - -namespace NLQT -{ - - class CGeorges; - - class CGeorgesTreeViewDialog: public QDockWidget - { - Q_OBJECT - - public: - CGeorgesTreeViewDialog(QWidget *parent = 0, bool empty = false); - ~CGeorgesTreeViewDialog(); - - bool modified() {return _modified;} - void setModified(bool m) {_modified = m;} - - CForm* getFormByName(const QString); - void addParentForm(CForm *form); - - void write ( ); - - QString loadedForm; - - protected: - void closeEvent(QCloseEvent *event); - - Q_SIGNALS: - void changeFile(QString); - void modified(bool); - public Q_SLOTS: - void setForm(const CForm*); - void loadFormIntoDialog(CForm *form = 0); - void modifiedFile( ); - private Q_SLOTS: - void doubleClicked ( const QModelIndex & index ); - void filterRows(); - - private: - Ui::CGeorgesTreeViewDialog _ui; - UForm *_form; - NLQT::CGeorges *_georges; - - bool _modified; - - }; /* CGeorgesTreeViewDialog */ - -} /* namespace NLQT */ - -#endif // GEORGES_TREEVIEWER_DIALOG_H +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef GEORGES_TREEVIEWER_DIALOG_H +#define GEORGES_TREEVIEWER_DIALOG_H + +#include "ui_georges_treeview_form.h" + +// Qt includes +#include + +// STL includes + +// NeL includes + +// Project includes + +namespace NLGEORGES +{ + class UForm; + class CForm; +} + +using namespace NLGEORGES; + +namespace NLQT +{ + + class CGeorges; + + class CGeorgesTreeViewDialog: public QDockWidget + { + Q_OBJECT + + public: + CGeorgesTreeViewDialog(QWidget *parent = 0, bool empty = false); + ~CGeorgesTreeViewDialog(); + + bool modified() {return _modified;} + void setModified(bool m) {_modified = m;} + + CForm* getFormByName(const QString); + void addParentForm(CForm *form); + + void write ( ); + + QString loadedForm; + + protected: + void closeEvent(QCloseEvent *event); + + Q_SIGNALS: + void changeFile(QString); + void modified(bool); + public Q_SLOTS: + void setForm(const CForm*); + void loadFormIntoDialog(CForm *form = 0); + void modifiedFile( ); + private Q_SLOTS: + void doubleClicked ( const QModelIndex & index ); + void filterRows(); + + private: + Ui::CGeorgesTreeViewDialog _ui; + UForm *_form; + NLQT::CGeorges *_georges; + + bool _modified; + + }; /* CGeorgesTreeViewDialog */ + +} /* namespace NLQT */ + +#endif // GEORGES_TREEVIEWER_DIALOG_H diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georgesform_model.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georgesform_model.cpp index 956380851..21c1e25ef 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georgesform_model.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georgesform_model.cpp @@ -1,642 +1,642 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#include "georgesform_model.h" - -// NeL includes -#include -#include -#include -#include -#include -#include - -// Qt includes -#include -#include -#include -#include -#include - -// project includes -#include "formitem.h" -#include "modules.h" - -using namespace NLGEORGES; - -namespace NLQT -{ - - CGeorgesFormModel::CGeorgesFormModel(UFormElm *rootElm, QMap< QString, QStringList> deps, - QString comment, QStringList parents, QObject *parent) : QAbstractItemModel(parent) - { - QList rootData; - rootData << "Value" << "Data" << "Extra";// << "Type"; - _rootElm = rootElm; - _rootItem = new CFormItem(_rootElm, rootData); - _dependencies = deps; - _comments = comment; - _parents = parents; - _parentRows = new QList; - - setupModelData(); - } - - CGeorgesFormModel::~CGeorgesFormModel() - { - delete _rootItem; - } - - /******************************************************************************/ - - QVariant CGeorgesFormModel::data(const QModelIndex &p_index, int p_role) const - { - if (!p_index.isValid()) - return QVariant(); - - switch (p_role) - { - case Qt::DisplayRole: - { - return getItem(p_index)->data(p_index.column()); - } - case Qt::BackgroundRole: - { - QBrush defaultBrush = QBrush(QColor(255,0,0,30)); - QBrush parentBrush = QBrush(QColor(0,255,0,30)); - - // if elm not existing it must be some kind of default or type value - if(!getItem(p_index)->getFormElm()) - { - return defaultBrush; - } - - // else it might be some parent elm - switch (getItem(p_index)->nodeFrom()) - { - case NLGEORGES::UFormElm::NodeParentForm: - { - return parentBrush; - } - case NLGEORGES::UFormElm::NodeForm: - { - switch (getItem(p_index)->valueFrom()) - { - case NLGEORGES::UFormElm::ValueParentForm: - { - return parentBrush; - } - default: - { - // parent status test kindof ugly, testing only 2 steps deep - // only needed for colorization as treeview default hides childs - // when parent is hidden - CFormItem *parent = getItem(p_index)->parent(); - if (parent) - { - if (parent->nodeFrom() == NLGEORGES::UFormElm::NodeParentForm) - { - return parentBrush; - } - - CFormItem *parentParent = parent->parent(); - if (parentParent) - { - if (parentParent->nodeFrom() == NLGEORGES::UFormElm::NodeParentForm) - { - return parentBrush; - } - } // endif parentParent - } // endif parent - } // end default - } // end switch valueFrom - } // end case nodeForm - } // end switch nodeFrom - return QVariant(); - } - case Qt::DecorationRole: - { - if (p_index.column() == 2) - { - //p_index. - QModelIndex in = index(p_index.row(),p_index.column()-1,p_index.parent()); - CFormItem *item = getItem(in); - - QString value = item->data(1).toString(); - //QString path = NLMISC::CPath::lookup(value.toStdString(),false).c_str(); - - if (value.contains(".shape")) - { - if (Modules::objViewInt()) - { - QIcon *icon = Modules::objViewInt()->saveOneImage(value.toStdString()); - if (icon) - { - if(icon->isNull()) - return QIcon(":/images/pqrticles.png"); - else - return QIcon(*icon); - } - else - { - return QIcon(); - } - } - } - else if(value.contains(".tga") || value.contains(".png")) - { - QString path = NLMISC::CPath::lookup(value.toStdString(),false).c_str(); - if(path.isEmpty()) - { - path = ":/images/pqrticles.png"; - } - return QIcon(path); - } - } - return QVariant(); - break; - } - case Qt::ToolTipRole: - { - if (p_index.column() == 2) - { - QModelIndex in = index(p_index.row(),p_index.column()-1,p_index.parent()); - CFormItem *item = getItem(in); - QString value = item->data(1).toString(); - - if (value.contains(".shape")) - { - if (Modules::objViewInt()) - { - QIcon *icon = Modules::objViewInt()->saveOneImage(value.toStdString()); - if (icon) - { - if(icon->isNull()) - return QIcon(":/images/pqrticles.png"); - else - return QIcon(*icon); - } - else - { - return QIcon(); - } - } - } - else if(value.contains(".tga") || value.contains(".png")) - { - QString path = NLMISC::CPath::lookup(value.toStdString(),false).c_str(); - if(path.isEmpty()) - { - path = ":/images/pqrticles.png"; - } - - QString imageTooltip = QString("").arg(path); - - return imageTooltip; - } - } - return QVariant(); - break; - } - default: - return QVariant(); - } - } - - /******************************************************************************/ - - CFormItem *CGeorgesFormModel::getItem(const QModelIndex &index) const - { - if (index.isValid()) - { - CFormItem *item = static_cast(index.internalPointer()); - if (item) - return item; - } - return _rootItem; - } - - /******************************************************************************/ - - bool CGeorgesFormModel::setData(const QModelIndex &index, const QVariant &value, - int role) - { - - if (role != Qt::EditRole) - return false; - - CFormItem *item = getItem(index); - bool result = item->setData(index.column(), value); - - // TODO: ugly hack for updating icon too - if (result) - Q_EMIT dataChanged(index, this->index(index.row(),index.column()+1,index.parent())); - - setupModelData(); - return result; - } - - /******************************************************************************/ - - Qt::ItemFlags CGeorgesFormModel::flags(const QModelIndex& index) const { - - if (!index.isValid()) - return 0; - - Qt::ItemFlags returnValue = Qt::ItemIsSelectable | Qt::ItemIsEnabled; - - if(index.column() == 1) - returnValue |= Qt::ItemIsEditable; - // TODO? - // col 2 should go here too but i dont want to do another delegate - // so for now i just connected the dblClick in the dialog - - return returnValue; - - } - - /******************************************************************************/ - - QVariant CGeorgesFormModel::headerData(int section, - Qt::Orientation orientation, int role) const - { - if (orientation == Qt::Horizontal && role == Qt::DisplayRole) - return _rootItem->data(section); - - return QVariant(); - - } - - /******************************************************************************/ - - QModelIndex CGeorgesFormModel::index(int row, int column, const QModelIndex &parent) - const - { - if (!hasIndex(row, column, parent)) - return QModelIndex(); - - CFormItem *parentItem; - - if (!parent.isValid()) - parentItem = _rootItem; - else - parentItem = static_cast(parent.internalPointer()); - - CFormItem *childItem = parentItem->child(row); - if (childItem) - return createIndex(row, column, childItem); - else - return QModelIndex(); - } - - /******************************************************************************/ - - QModelIndex CGeorgesFormModel::parent(const QModelIndex &index) const - { - if (!index.isValid()) - return QModelIndex(); - - CFormItem *childItem = static_cast(index.internalPointer()); - CFormItem *parentItem = childItem->parent(); - - if (parentItem == _rootItem) - return QModelIndex(); - - return createIndex(parentItem->row(), 0, parentItem); - } - - /******************************************************************************/ - - int CGeorgesFormModel::rowCount(const QModelIndex &parent) const { - - CFormItem *parentItem; - if (parent.column() > 0) - return 0; - - if (!parent.isValid()) - parentItem = _rootItem; - else - parentItem = static_cast(parent.internalPointer()); - - return parentItem->childCount(); - - } - - /******************************************************************************/ - - int CGeorgesFormModel::columnCount(const QModelIndex &parent) const { - - if (parent.isValid()) - return static_cast(parent.internalPointer())->columnCount(); - else - return _rootItem->columnCount(); - - } - - /******************************************************************************/ - - void CGeorgesFormModel::loadFormData(UFormElm *root, CFormItem *parent) { - - if (!root) - return; - - uint num = 0; - - - if (root->isStruct()) - { - //((CFormElm*)root)->getForm()->getComment(); - uint structSize = 0; - root->getStructSize(structSize); - while (num < structSize) - { - UFormElm::TWhereIsNode *whereN = new UFormElm::TWhereIsNode; - UFormElm::TWhereIsValue *whereV = new UFormElm::TWhereIsValue; - // Append a new item to the current parent's list of children. - std::string elmName; - if(root->getStructNodeName(num, elmName)) - { - QList columnData; - //QVariant value; - std::string value; - //NLMISC::CRGBA value_color; - //uint value_uint; - //sint value_sint; - //double value_double; - QString elmtType = ""; - UFormElm *elmt = 0; - if(root->getNodeByName(&elmt, elmName.c_str(), whereN, true)) - { - if (elmt) - { - if (elmt->isArray()) - elmtType = "Array"; - if (elmt->isStruct()) - elmtType = "Struct"; - if (elmt->isAtom()) { - elmtType = "Atom"; - uint numDefinitions = 0; - const UType *type = elmt->getType(); - if (type) - { - numDefinitions = type->getNumDefinition(); - root->getValueByName(value, elmName.c_str(),UFormElm::Eval,whereV); - switch (type->getType()) - { - case UType::UnsignedInt: - value = QString("%1").arg(QString("%1").arg(value.c_str()).toDouble()).toStdString(); - elmtType.append("_uint");break; - case UType::SignedInt: - value = QString("%1").arg(QString("%1").arg(value.c_str()).toDouble()).toStdString(); - elmtType.append("_sint");break; - case UType::Double: - value = QString("%1").arg(QString("%1").arg(value.c_str()).toDouble(),0,'f',1).toStdString(); - elmtType.append("_double");break; - case UType::String: - elmtType.append("_string");break; - case UType::Color: - elmtType.append("_color");break; - default: - elmtType.append("_unknownType"); - } - } - else - { - elmtType.append("_noType"); - } - - if (numDefinitions) - { - std::string l, v; - QString tmpLabel, tmpValue; - for (uint i = 0; i < numDefinitions; i++) - { - type->getDefinition(i,l,v); - tmpLabel = l.c_str(); - tmpValue = v.c_str(); - if (type->getType() == UType::SignedInt) - { - if (QString("%1").arg(value.c_str()).toDouble() == tmpValue.toDouble()) { - value = l; - break; - } - } - if (type->getType() == UType::String) - { - if (QString(value.c_str()) == tmpValue) - { - value = l; - break; - } - } - } - } - } - if (elmt->isVirtualStruct()) - { - root->getValueByName(value, elmName.c_str(),UFormElm::Eval,whereV); - elmtType = "VirtualStruct"; - } - switch (*whereN) - { - case UFormElm::NodeForm: - elmtType.append("_fromForm"); break; - case UFormElm::NodeParentForm: - elmtType.append("_fromParentForm"); break; - case UFormElm::NodeDfn: - elmtType.append("_isDFN"); break; - case UFormElm::NodeType: - elmtType.append("_isType"); break; - default: - elmtType.append("_noNode"); - } - switch (*whereV) - { - case UFormElm::ValueForm: - elmtType.append("_formValue"); break; - case UFormElm::ValueParentForm: - elmtType.append("_parentValue"); break; - case UFormElm::ValueDefaultDfn: - elmtType.append("_dfnValue"); break; - case UFormElm::ValueDefaultType: - elmtType.append("_typeValue"); break; - default: - elmtType.append("_noValue"); - } - columnData << QString(elmName.c_str()) << QString(value.c_str()) << "" << elmtType; - parent->appendChild(new CFormItem(elmt, columnData, parent, *whereV, *whereN)); - //if (parents.last()->childCount() > 0) { - // parents << parents.last()->child(parents.last()->childCount()-1); - //} - loadFormData(elmt, parent->child(parent->childCount()-1)); - } - else - { - // add Defaults - // TODO: spams warnings for non ATOM values but i dont get type of non existing nodes - bool success = root->getValueByName(value, elmName.c_str(),UFormElm::Eval,whereV); - switch (*whereN) - { - case UFormElm::NodeForm: - elmtType.append("_fromForm"); break; - case UFormElm::NodeParentForm: - elmtType.append("_fromParentForm"); break; - case UFormElm::NodeDfn: - elmtType.append("_isDFN"); break; - case UFormElm::NodeType: - elmtType.append("_isType"); break; - default: - elmtType.append("_noNode"); - } - switch (*whereV) - { - case UFormElm::ValueForm: - elmtType.append("_formValue"); break; - case UFormElm::ValueParentForm: - elmtType.append("_parentValue"); break; - case UFormElm::ValueDefaultDfn: - elmtType.append("_dfnValue"); break; - case UFormElm::ValueDefaultType: - elmtType.append("_typeValue"); break; - default: - elmtType.append("_noValue"); - } - - columnData << QString(elmName.c_str()) << QString(value.c_str()) << "" << elmtType; - parent->appendChild(new CFormItem(elmt, columnData, parent, *whereV, *whereN)); - } - } - else - { - nlinfo("getNodeByName returned false"); - } - } - num++; - } - } - if (root->isArray()) - { - uint arraySize = 0; - root->getArraySize(arraySize); - while (num < arraySize) - { - std::string elmName; - if(root->getArrayNodeName(elmName, num)) - { - QList columnData; - std::string value; - QString elmtType = ""; - - UFormElm *elmt = 0; - if(root->getArrayNode(&elmt,0) && elmt) - { - if (elmt->isArray()) - elmtType = "Array"; - if (elmt->isStruct()) { - elmtType = "Struct"; - } - if (elmt->isAtom()) - { - elmt->getValue(value); - elmtType = "Atom"; - } - if (elmt->isVirtualStruct()) - elmtType = "VirtualStruct"; - - elmtType.append("_arrayValue"); - columnData << QString(elmName.c_str()) << QString(value.c_str()) << "" << elmtType; - parent->appendChild(new CFormItem(elmt, columnData, parent)); - loadFormData(elmt, parent->child(parent->childCount()-1)); - } - } - num++; - } - } - } - - /******************************************************************************/ - - void CGeorgesFormModel::loadFormHeader() - { - - CFormItem *fi_pars = new CFormItem(_rootElm, QList() << "parents", _rootItem); - _rootItem->appendChild(fi_pars); - - Q_FOREACH(QString str, _parents) - { - fi_pars->appendChild(new CFormItem(_rootElm, QList() << str, fi_pars)); - } - - /*QStringList dfns = _dependencies["dfn"]; - QStringList typs = _dependencies["typ"]; - - _dependencies.remove("dfn"); - _dependencies.remove("typ"); - - CFormItem *fi_dep = new CFormItem(_rootElm, QList() << "dependencies", _rootItem); - _rootItem->appendChild(fi_dep); - - if (!dfns.isEmpty()) { - CFormItem *fi_dfn = new CFormItem(_rootElm, QList() << "dfn", fi_dep); - fi_dep->appendChild(fi_dfn); - foreach(QString str, dfns) { - fi_dfn->appendChild(new CFormItem(_rootElm, QList() << str, fi_dfn)); - } - } - if (!typs.isEmpty()) { - CFormItem *fi_typ = new CFormItem(_rootElm, QList() << "typ", fi_dep); - fi_dep->appendChild(fi_typ); - foreach(QString str, typs) { - fi_typ->appendChild(new CFormItem(_rootElm, QList() << str, fi_typ)); - } - } - if (!_dependencies.isEmpty()) { - CFormItem *fi_other = new CFormItem(_rootElm, QList() << "other", fi_dep); - fi_dep->appendChild(fi_other); - foreach(QStringList list, _dependencies) { - foreach(QString str, list) { - fi_other->appendChild(new CFormItem(_rootElm, QList() << str, fi_other)); - } - } - }*/ - } - - /******************************************************************************/ - - void CGeorgesFormModel::setupModelData() - { - loadFormHeader(); - loadFormData(_rootElm, _rootItem); - } - - /******************************************************************************/ - - void CGeorgesFormModel::setShowParents( bool show ) { - _showParents = show; - Q_EMIT layoutAboutToBeChanged(); - Q_EMIT layoutChanged(); - } - void CGeorgesFormModel::setShowDefaults( bool show ) - { - _showDefaults = show; - Q_EMIT layoutAboutToBeChanged(); - Q_EMIT layoutChanged(); - } -} /* namespace NLQT */ - -/* end of file */ +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "georgesform_model.h" + +// NeL includes +#include +#include +#include +#include +#include +#include + +// Qt includes +#include +#include +#include +#include +#include + +// project includes +#include "formitem.h" +#include "modules.h" + +using namespace NLGEORGES; + +namespace NLQT +{ + + CGeorgesFormModel::CGeorgesFormModel(UFormElm *rootElm, QMap< QString, QStringList> deps, + QString comment, QStringList parents, QObject *parent) : QAbstractItemModel(parent) + { + QList rootData; + rootData << "Value" << "Data" << "Extra";// << "Type"; + _rootElm = rootElm; + _rootItem = new CFormItem(_rootElm, rootData); + _dependencies = deps; + _comments = comment; + _parents = parents; + _parentRows = new QList; + + setupModelData(); + } + + CGeorgesFormModel::~CGeorgesFormModel() + { + delete _rootItem; + } + + /******************************************************************************/ + + QVariant CGeorgesFormModel::data(const QModelIndex &p_index, int p_role) const + { + if (!p_index.isValid()) + return QVariant(); + + switch (p_role) + { + case Qt::DisplayRole: + { + return getItem(p_index)->data(p_index.column()); + } + case Qt::BackgroundRole: + { + QBrush defaultBrush = QBrush(QColor(255,0,0,30)); + QBrush parentBrush = QBrush(QColor(0,255,0,30)); + + // if elm not existing it must be some kind of default or type value + if(!getItem(p_index)->getFormElm()) + { + return defaultBrush; + } + + // else it might be some parent elm + switch (getItem(p_index)->nodeFrom()) + { + case NLGEORGES::UFormElm::NodeParentForm: + { + return parentBrush; + } + case NLGEORGES::UFormElm::NodeForm: + { + switch (getItem(p_index)->valueFrom()) + { + case NLGEORGES::UFormElm::ValueParentForm: + { + return parentBrush; + } + default: + { + // parent status test kindof ugly, testing only 2 steps deep + // only needed for colorization as treeview default hides childs + // when parent is hidden + CFormItem *parent = getItem(p_index)->parent(); + if (parent) + { + if (parent->nodeFrom() == NLGEORGES::UFormElm::NodeParentForm) + { + return parentBrush; + } + + CFormItem *parentParent = parent->parent(); + if (parentParent) + { + if (parentParent->nodeFrom() == NLGEORGES::UFormElm::NodeParentForm) + { + return parentBrush; + } + } // endif parentParent + } // endif parent + } // end default + } // end switch valueFrom + } // end case nodeForm + } // end switch nodeFrom + return QVariant(); + } + case Qt::DecorationRole: + { + if (p_index.column() == 2) + { + //p_index. + QModelIndex in = index(p_index.row(),p_index.column()-1,p_index.parent()); + CFormItem *item = getItem(in); + + QString value = item->data(1).toString(); + //QString path = NLMISC::CPath::lookup(value.toStdString(),false).c_str(); + + if (value.contains(".shape")) + { + if (Modules::objViewInt()) + { + QIcon *icon = Modules::objViewInt()->saveOneImage(value.toStdString()); + if (icon) + { + if(icon->isNull()) + return QIcon(":/images/pqrticles.png"); + else + return QIcon(*icon); + } + else + { + return QIcon(); + } + } + } + else if(value.contains(".tga") || value.contains(".png")) + { + QString path = NLMISC::CPath::lookup(value.toStdString(),false).c_str(); + if(path.isEmpty()) + { + path = ":/images/pqrticles.png"; + } + return QIcon(path); + } + } + return QVariant(); + break; + } + case Qt::ToolTipRole: + { + if (p_index.column() == 2) + { + QModelIndex in = index(p_index.row(),p_index.column()-1,p_index.parent()); + CFormItem *item = getItem(in); + QString value = item->data(1).toString(); + + if (value.contains(".shape")) + { + if (Modules::objViewInt()) + { + QIcon *icon = Modules::objViewInt()->saveOneImage(value.toStdString()); + if (icon) + { + if(icon->isNull()) + return QIcon(":/images/pqrticles.png"); + else + return QIcon(*icon); + } + else + { + return QIcon(); + } + } + } + else if(value.contains(".tga") || value.contains(".png")) + { + QString path = NLMISC::CPath::lookup(value.toStdString(),false).c_str(); + if(path.isEmpty()) + { + path = ":/images/pqrticles.png"; + } + + QString imageTooltip = QString("").arg(path); + + return imageTooltip; + } + } + return QVariant(); + break; + } + default: + return QVariant(); + } + } + + /******************************************************************************/ + + CFormItem *CGeorgesFormModel::getItem(const QModelIndex &index) const + { + if (index.isValid()) + { + CFormItem *item = static_cast(index.internalPointer()); + if (item) + return item; + } + return _rootItem; + } + + /******************************************************************************/ + + bool CGeorgesFormModel::setData(const QModelIndex &index, const QVariant &value, + int role) + { + + if (role != Qt::EditRole) + return false; + + CFormItem *item = getItem(index); + bool result = item->setData(index.column(), value); + + // TODO: ugly hack for updating icon too + if (result) + Q_EMIT dataChanged(index, this->index(index.row(),index.column()+1,index.parent())); + + setupModelData(); + return result; + } + + /******************************************************************************/ + + Qt::ItemFlags CGeorgesFormModel::flags(const QModelIndex& index) const { + + if (!index.isValid()) + return 0; + + Qt::ItemFlags returnValue = Qt::ItemIsSelectable | Qt::ItemIsEnabled; + + if(index.column() == 1) + returnValue |= Qt::ItemIsEditable; + // TODO? + // col 2 should go here too but i dont want to do another delegate + // so for now i just connected the dblClick in the dialog + + return returnValue; + + } + + /******************************************************************************/ + + QVariant CGeorgesFormModel::headerData(int section, + Qt::Orientation orientation, int role) const + { + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) + return _rootItem->data(section); + + return QVariant(); + + } + + /******************************************************************************/ + + QModelIndex CGeorgesFormModel::index(int row, int column, const QModelIndex &parent) + const + { + if (!hasIndex(row, column, parent)) + return QModelIndex(); + + CFormItem *parentItem; + + if (!parent.isValid()) + parentItem = _rootItem; + else + parentItem = static_cast(parent.internalPointer()); + + CFormItem *childItem = parentItem->child(row); + if (childItem) + return createIndex(row, column, childItem); + else + return QModelIndex(); + } + + /******************************************************************************/ + + QModelIndex CGeorgesFormModel::parent(const QModelIndex &index) const + { + if (!index.isValid()) + return QModelIndex(); + + CFormItem *childItem = static_cast(index.internalPointer()); + CFormItem *parentItem = childItem->parent(); + + if (parentItem == _rootItem) + return QModelIndex(); + + return createIndex(parentItem->row(), 0, parentItem); + } + + /******************************************************************************/ + + int CGeorgesFormModel::rowCount(const QModelIndex &parent) const { + + CFormItem *parentItem; + if (parent.column() > 0) + return 0; + + if (!parent.isValid()) + parentItem = _rootItem; + else + parentItem = static_cast(parent.internalPointer()); + + return parentItem->childCount(); + + } + + /******************************************************************************/ + + int CGeorgesFormModel::columnCount(const QModelIndex &parent) const { + + if (parent.isValid()) + return static_cast(parent.internalPointer())->columnCount(); + else + return _rootItem->columnCount(); + + } + + /******************************************************************************/ + + void CGeorgesFormModel::loadFormData(UFormElm *root, CFormItem *parent) { + + if (!root) + return; + + uint num = 0; + + + if (root->isStruct()) + { + //((CFormElm*)root)->getForm()->getComment(); + uint structSize = 0; + root->getStructSize(structSize); + while (num < structSize) + { + UFormElm::TWhereIsNode *whereN = new UFormElm::TWhereIsNode; + UFormElm::TWhereIsValue *whereV = new UFormElm::TWhereIsValue; + // Append a new item to the current parent's list of children. + std::string elmName; + if(root->getStructNodeName(num, elmName)) + { + QList columnData; + //QVariant value; + std::string value; + //NLMISC::CRGBA value_color; + //uint value_uint; + //sint value_sint; + //double value_double; + QString elmtType = ""; + UFormElm *elmt = 0; + if(root->getNodeByName(&elmt, elmName.c_str(), whereN, true)) + { + if (elmt) + { + if (elmt->isArray()) + elmtType = "Array"; + if (elmt->isStruct()) + elmtType = "Struct"; + if (elmt->isAtom()) { + elmtType = "Atom"; + uint numDefinitions = 0; + const UType *type = elmt->getType(); + if (type) + { + numDefinitions = type->getNumDefinition(); + root->getValueByName(value, elmName.c_str(),UFormElm::Eval,whereV); + switch (type->getType()) + { + case UType::UnsignedInt: + value = QString("%1").arg(QString("%1").arg(value.c_str()).toDouble()).toStdString(); + elmtType.append("_uint");break; + case UType::SignedInt: + value = QString("%1").arg(QString("%1").arg(value.c_str()).toDouble()).toStdString(); + elmtType.append("_sint");break; + case UType::Double: + value = QString("%1").arg(QString("%1").arg(value.c_str()).toDouble(),0,'f',1).toStdString(); + elmtType.append("_double");break; + case UType::String: + elmtType.append("_string");break; + case UType::Color: + elmtType.append("_color");break; + default: + elmtType.append("_unknownType"); + } + } + else + { + elmtType.append("_noType"); + } + + if (numDefinitions) + { + std::string l, v; + QString tmpLabel, tmpValue; + for (uint i = 0; i < numDefinitions; i++) + { + type->getDefinition(i,l,v); + tmpLabel = l.c_str(); + tmpValue = v.c_str(); + if (type->getType() == UType::SignedInt) + { + if (QString("%1").arg(value.c_str()).toDouble() == tmpValue.toDouble()) { + value = l; + break; + } + } + if (type->getType() == UType::String) + { + if (QString(value.c_str()) == tmpValue) + { + value = l; + break; + } + } + } + } + } + if (elmt->isVirtualStruct()) + { + root->getValueByName(value, elmName.c_str(),UFormElm::Eval,whereV); + elmtType = "VirtualStruct"; + } + switch (*whereN) + { + case UFormElm::NodeForm: + elmtType.append("_fromForm"); break; + case UFormElm::NodeParentForm: + elmtType.append("_fromParentForm"); break; + case UFormElm::NodeDfn: + elmtType.append("_isDFN"); break; + case UFormElm::NodeType: + elmtType.append("_isType"); break; + default: + elmtType.append("_noNode"); + } + switch (*whereV) + { + case UFormElm::ValueForm: + elmtType.append("_formValue"); break; + case UFormElm::ValueParentForm: + elmtType.append("_parentValue"); break; + case UFormElm::ValueDefaultDfn: + elmtType.append("_dfnValue"); break; + case UFormElm::ValueDefaultType: + elmtType.append("_typeValue"); break; + default: + elmtType.append("_noValue"); + } + columnData << QString(elmName.c_str()) << QString(value.c_str()) << "" << elmtType; + parent->appendChild(new CFormItem(elmt, columnData, parent, *whereV, *whereN)); + //if (parents.last()->childCount() > 0) { + // parents << parents.last()->child(parents.last()->childCount()-1); + //} + loadFormData(elmt, parent->child(parent->childCount()-1)); + } + else + { + // add Defaults + // TODO: spams warnings for non ATOM values but i dont get type of non existing nodes + bool success = root->getValueByName(value, elmName.c_str(),UFormElm::Eval,whereV); + switch (*whereN) + { + case UFormElm::NodeForm: + elmtType.append("_fromForm"); break; + case UFormElm::NodeParentForm: + elmtType.append("_fromParentForm"); break; + case UFormElm::NodeDfn: + elmtType.append("_isDFN"); break; + case UFormElm::NodeType: + elmtType.append("_isType"); break; + default: + elmtType.append("_noNode"); + } + switch (*whereV) + { + case UFormElm::ValueForm: + elmtType.append("_formValue"); break; + case UFormElm::ValueParentForm: + elmtType.append("_parentValue"); break; + case UFormElm::ValueDefaultDfn: + elmtType.append("_dfnValue"); break; + case UFormElm::ValueDefaultType: + elmtType.append("_typeValue"); break; + default: + elmtType.append("_noValue"); + } + + columnData << QString(elmName.c_str()) << QString(value.c_str()) << "" << elmtType; + parent->appendChild(new CFormItem(elmt, columnData, parent, *whereV, *whereN)); + } + } + else + { + nlinfo("getNodeByName returned false"); + } + } + num++; + } + } + if (root->isArray()) + { + uint arraySize = 0; + root->getArraySize(arraySize); + while (num < arraySize) + { + std::string elmName; + if(root->getArrayNodeName(elmName, num)) + { + QList columnData; + std::string value; + QString elmtType = ""; + + UFormElm *elmt = 0; + if(root->getArrayNode(&elmt,0) && elmt) + { + if (elmt->isArray()) + elmtType = "Array"; + if (elmt->isStruct()) { + elmtType = "Struct"; + } + if (elmt->isAtom()) + { + elmt->getValue(value); + elmtType = "Atom"; + } + if (elmt->isVirtualStruct()) + elmtType = "VirtualStruct"; + + elmtType.append("_arrayValue"); + columnData << QString(elmName.c_str()) << QString(value.c_str()) << "" << elmtType; + parent->appendChild(new CFormItem(elmt, columnData, parent)); + loadFormData(elmt, parent->child(parent->childCount()-1)); + } + } + num++; + } + } + } + + /******************************************************************************/ + + void CGeorgesFormModel::loadFormHeader() + { + + CFormItem *fi_pars = new CFormItem(_rootElm, QList() << "parents", _rootItem); + _rootItem->appendChild(fi_pars); + + Q_FOREACH(QString str, _parents) + { + fi_pars->appendChild(new CFormItem(_rootElm, QList() << str, fi_pars)); + } + + /*QStringList dfns = _dependencies["dfn"]; + QStringList typs = _dependencies["typ"]; + + _dependencies.remove("dfn"); + _dependencies.remove("typ"); + + CFormItem *fi_dep = new CFormItem(_rootElm, QList() << "dependencies", _rootItem); + _rootItem->appendChild(fi_dep); + + if (!dfns.isEmpty()) { + CFormItem *fi_dfn = new CFormItem(_rootElm, QList() << "dfn", fi_dep); + fi_dep->appendChild(fi_dfn); + foreach(QString str, dfns) { + fi_dfn->appendChild(new CFormItem(_rootElm, QList() << str, fi_dfn)); + } + } + if (!typs.isEmpty()) { + CFormItem *fi_typ = new CFormItem(_rootElm, QList() << "typ", fi_dep); + fi_dep->appendChild(fi_typ); + foreach(QString str, typs) { + fi_typ->appendChild(new CFormItem(_rootElm, QList() << str, fi_typ)); + } + } + if (!_dependencies.isEmpty()) { + CFormItem *fi_other = new CFormItem(_rootElm, QList() << "other", fi_dep); + fi_dep->appendChild(fi_other); + foreach(QStringList list, _dependencies) { + foreach(QString str, list) { + fi_other->appendChild(new CFormItem(_rootElm, QList() << str, fi_other)); + } + } + }*/ + } + + /******************************************************************************/ + + void CGeorgesFormModel::setupModelData() + { + loadFormHeader(); + loadFormData(_rootElm, _rootItem); + } + + /******************************************************************************/ + + void CGeorgesFormModel::setShowParents( bool show ) { + _showParents = show; + Q_EMIT layoutAboutToBeChanged(); + Q_EMIT layoutChanged(); + } + void CGeorgesFormModel::setShowDefaults( bool show ) + { + _showDefaults = show; + Q_EMIT layoutAboutToBeChanged(); + Q_EMIT layoutChanged(); + } +} /* namespace NLQT */ + +/* end of file */ diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georgesform_model.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georgesform_model.h index d7665c271..2eb1a608c 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georgesform_model.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georgesform_model.h @@ -1,82 +1,82 @@ -/* -Georges Viewer Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -*/ - -#ifndef GEORGESFORM_MODEL_H -#define GEORGESFORM_MODEL_H - -// Qt includes -#include -#include -#include -#include - -// project includes - -namespace NLGEORGES { - class UFormElm; -} - -namespace NLQT -{ - - class CFormItem; - - class CGeorgesFormModel : public QAbstractItemModel - { - - public: - CGeorgesFormModel(NLGEORGES::UFormElm *root, QMap< QString, QStringList> deps, - QString comment, QStringList parents, QObject *parent = 0); - ~CGeorgesFormModel(); - - QVariant data(const QModelIndex &index, int role) const; - bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); - Qt::ItemFlags flags(const QModelIndex &index) const; - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; - QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &index) const; - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - CFormItem *getItem(const QModelIndex &index) const; - CGeorgesFormModel *model() { return this; } - bool showParents() { return _showParents;} - bool showDefaults() { return _showDefaults;} - void setShowParents( bool show ); - void setShowDefaults( bool show ); - - private: - void setupModelData(); - void loadFormData(NLGEORGES::UFormElm *rootElm, CFormItem *parent); - void loadFormHeader(); - - CFormItem* _rootItem; - NLGEORGES::UFormElm* _rootElm; - QMap< QString, QStringList> _dependencies; - QString _comments; - QStringList _parents; - QList* _parentRows; - - bool _showParents; - bool _showDefaults; - - };/* class CGeorgesFormModel */ - -} /* namespace NLQT */ - -#endif // GEORGESFORM_MODEL_H +/* +Georges Viewer Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +*/ + +#ifndef GEORGESFORM_MODEL_H +#define GEORGESFORM_MODEL_H + +// Qt includes +#include +#include +#include +#include + +// project includes + +namespace NLGEORGES { + class UFormElm; +} + +namespace NLQT +{ + + class CFormItem; + + class CGeorgesFormModel : public QAbstractItemModel + { + + public: + CGeorgesFormModel(NLGEORGES::UFormElm *root, QMap< QString, QStringList> deps, + QString comment, QStringList parents, QObject *parent = 0); + ~CGeorgesFormModel(); + + QVariant data(const QModelIndex &index, int role) const; + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); + Qt::ItemFlags flags(const QModelIndex &index) const; + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; + QModelIndex parent(const QModelIndex &index) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; + CFormItem *getItem(const QModelIndex &index) const; + CGeorgesFormModel *model() { return this; } + bool showParents() { return _showParents;} + bool showDefaults() { return _showDefaults;} + void setShowParents( bool show ); + void setShowDefaults( bool show ); + + private: + void setupModelData(); + void loadFormData(NLGEORGES::UFormElm *rootElm, CFormItem *parent); + void loadFormHeader(); + + CFormItem* _rootItem; + NLGEORGES::UFormElm* _rootElm; + QMap< QString, QStringList> _dependencies; + QString _comments; + QStringList _parents; + QList* _parentRows; + + bool _showParents; + bool _showDefaults; + + };/* class CGeorgesFormModel */ + +} /* namespace NLQT */ + +#endif // GEORGESFORM_MODEL_H diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georgesform_proxy_model.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georgesform_proxy_model.cpp index 47b238dd2..68b990b30 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georgesform_proxy_model.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georgesform_proxy_model.cpp @@ -1,96 +1,96 @@ -/* - Georges Editor Qt - Copyright (C) 2010 Adrian Jaekel - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "georgesform_proxy_model.h" -#include "georgesform_model.h" - -// NeL includes -#include -#include - -// project includes -#include "formitem.h" - -#include - -namespace NLQT -{ - - bool CGeorgesFormProxyModel::filterAcceptsRow(int sourceRow, - const QModelIndex &sourceParent) const - { - //nlinfo("CGeorgesFormProxyModel::filterAcceptsRow"); - - // column doesnt matter for item - CGeorgesFormModel *smodel = dynamic_cast(sourceModel()); - QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); - CFormItem *item = smodel->getItem(index); - - //qDebug() << smodel->showParents() << (item->valueFrom() == NLGEORGES::UFormElm::NodeParentForm); - //nlinfo("%s %d %d %d %d", item->data(index.column()).toString().toStdString().c_str(), - // item->valueFrom(), - // item->nodeFrom(), - // smodel->showParents(), - // (item->valueFrom() == NLGEORGES::UFormElm::NodeParentForm)); - - // if elm not existing it must be some kind of default or type value - if(!item->getFormElm()) - { - return smodel->showDefaults(); - } - - // else it might be some parent elm - switch (item->nodeFrom()) - { - case NLGEORGES::UFormElm::NodeParentForm: - { - return smodel->showParents(); - } - case NLGEORGES::UFormElm::NodeForm: - { - switch (item->valueFrom()) - { - case NLGEORGES::UFormElm::ValueParentForm: - { - return smodel->showParents(); - } - default: - { - CFormItem *parent = item->parent(); - if (parent && (parent->nodeFrom() == NLGEORGES::UFormElm::NodeParentForm)) - { - return smodel->showParents(); - } - } - } - } - } - return true; - } - -/******************************************************************************/ - - bool CGeorgesFormProxyModel::filterAcceptsColumn(int sourceRow, - const QModelIndex &sourceParent) const - { - //nlinfo("CGeorgesFormProxyModel::filterAcceptsColumn"); - return QSortFilterProxyModel::filterAcceptsColumn(sourceRow, sourceParent); - } -} /* namespace NLQT */ - -/* end of file */ +/* + Georges Editor Qt + Copyright (C) 2010 Adrian Jaekel + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "georgesform_proxy_model.h" +#include "georgesform_model.h" + +// NeL includes +#include +#include + +// project includes +#include "formitem.h" + +#include + +namespace NLQT +{ + + bool CGeorgesFormProxyModel::filterAcceptsRow(int sourceRow, + const QModelIndex &sourceParent) const + { + //nlinfo("CGeorgesFormProxyModel::filterAcceptsRow"); + + // column doesnt matter for item + CGeorgesFormModel *smodel = dynamic_cast(sourceModel()); + QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); + CFormItem *item = smodel->getItem(index); + + //qDebug() << smodel->showParents() << (item->valueFrom() == NLGEORGES::UFormElm::NodeParentForm); + //nlinfo("%s %d %d %d %d", item->data(index.column()).toString().toStdString().c_str(), + // item->valueFrom(), + // item->nodeFrom(), + // smodel->showParents(), + // (item->valueFrom() == NLGEORGES::UFormElm::NodeParentForm)); + + // if elm not existing it must be some kind of default or type value + if(!item->getFormElm()) + { + return smodel->showDefaults(); + } + + // else it might be some parent elm + switch (item->nodeFrom()) + { + case NLGEORGES::UFormElm::NodeParentForm: + { + return smodel->showParents(); + } + case NLGEORGES::UFormElm::NodeForm: + { + switch (item->valueFrom()) + { + case NLGEORGES::UFormElm::ValueParentForm: + { + return smodel->showParents(); + } + default: + { + CFormItem *parent = item->parent(); + if (parent && (parent->nodeFrom() == NLGEORGES::UFormElm::NodeParentForm)) + { + return smodel->showParents(); + } + } + } + } + } + return true; + } + +/******************************************************************************/ + + bool CGeorgesFormProxyModel::filterAcceptsColumn(int sourceRow, + const QModelIndex &sourceParent) const + { + //nlinfo("CGeorgesFormProxyModel::filterAcceptsColumn"); + return QSortFilterProxyModel::filterAcceptsColumn(sourceRow, sourceParent); + } +} /* namespace NLQT */ + +/* end of file */ diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georgesform_proxy_model.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georgesform_proxy_model.h index faff7f553..20ed8bff5 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/georgesform_proxy_model.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/georgesform_proxy_model.h @@ -1,48 +1,48 @@ -/* -Georges Viewer Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -*/ - -#ifndef GEORGESFORM_PROXY_MODEL_H -#define GEORGESFORM_PROXY_MODEL_H - -// Qt includes -#include - -namespace NLQT -{ - - class CGeorgesFormProxyModel : public QSortFilterProxyModel - { - - public: - CGeorgesFormProxyModel(QObject *parent = 0): QSortFilterProxyModel(parent) - { - } - ~CGeorgesFormProxyModel() - { - } - - protected: - virtual bool filterAcceptsColumn ( int source_column, const QModelIndex & source_parent ) const ; - virtual bool filterAcceptsRow ( int source_row, const QModelIndex & source_parent ) const ; - - };/* class CGeorgesFormProxyModel */ - -} /* namespace NLQT */ - -#endif // GEORGESFORM_PROXY_MODEL_H +/* +Georges Viewer Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +*/ + +#ifndef GEORGESFORM_PROXY_MODEL_H +#define GEORGESFORM_PROXY_MODEL_H + +// Qt includes +#include + +namespace NLQT +{ + + class CGeorgesFormProxyModel : public QSortFilterProxyModel + { + + public: + CGeorgesFormProxyModel(QObject *parent = 0): QSortFilterProxyModel(parent) + { + } + ~CGeorgesFormProxyModel() + { + } + + protected: + virtual bool filterAcceptsColumn ( int source_column, const QModelIndex & source_parent ) const ; + virtual bool filterAcceptsRow ( int source_row, const QModelIndex & source_parent ) const ; + + };/* class CGeorgesFormProxyModel */ + +} /* namespace NLQT */ + +#endif // GEORGESFORM_PROXY_MODEL_H diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/log_dialog.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/log_dialog.cpp index be2b7a340..255ae5fde 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/log_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/log_dialog.cpp @@ -1,61 +1,61 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -*/ - -#include "log_dialog.h" - -// Qt includes -#include -#include -#include -#include - -// NeL includes - -// Project includes -#include "qt_displayer.h" - -namespace NLQT -{ - - CGeorgesLogDialog::CGeorgesLogDialog(QWidget *parent): - QDockWidget(parent) - { - - _ui.setupUi(this); - - _displayer = new CQtDisplayer(_ui.plainTextEdit); - NLMISC::ErrorLog->addDisplayer(_displayer); - NLMISC::WarningLog->addDisplayer(_displayer); - NLMISC::DebugLog->addDisplayer(_displayer); - NLMISC::AssertLog->addDisplayer(_displayer); - NLMISC::InfoLog->addDisplayer(_displayer); - -} - -CGeorgesLogDialog::~CGeorgesLogDialog() -{ - NLMISC::ErrorLog->removeDisplayer(_displayer); - NLMISC::WarningLog->removeDisplayer(_displayer); - NLMISC::DebugLog->removeDisplayer(_displayer); - NLMISC::AssertLog->removeDisplayer(_displayer); - NLMISC::InfoLog->removeDisplayer(_displayer); - delete _displayer; -} - +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +*/ + +#include "log_dialog.h" + +// Qt includes +#include +#include +#include +#include + +// NeL includes + +// Project includes +#include "qt_displayer.h" + +namespace NLQT +{ + + CGeorgesLogDialog::CGeorgesLogDialog(QWidget *parent): + QDockWidget(parent) + { + + _ui.setupUi(this); + + _displayer = new CQtDisplayer(_ui.plainTextEdit); + NLMISC::ErrorLog->addDisplayer(_displayer); + NLMISC::WarningLog->addDisplayer(_displayer); + NLMISC::DebugLog->addDisplayer(_displayer); + NLMISC::AssertLog->addDisplayer(_displayer); + NLMISC::InfoLog->addDisplayer(_displayer); + +} + +CGeorgesLogDialog::~CGeorgesLogDialog() +{ + NLMISC::ErrorLog->removeDisplayer(_displayer); + NLMISC::WarningLog->removeDisplayer(_displayer); + NLMISC::DebugLog->removeDisplayer(_displayer); + NLMISC::AssertLog->removeDisplayer(_displayer); + NLMISC::InfoLog->removeDisplayer(_displayer); + delete _displayer; +} + } /* namespace NLQT */ \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/log_dialog.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/log_dialog.h index 107629412..6f358222a 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/log_dialog.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/log_dialog.h @@ -1,54 +1,54 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#ifndef LOG_DIALOG_H -#define LOG_DIALOG_H - -// Qt includes -#include - -// STL includes - -// NeL includes -#include - -// Project includes -#include "ui_log_form.h" - -namespace NLQT -{ - class CQtDisplayer; - - class CGeorgesLogDialog: public QDockWidget - { - - public: - CGeorgesLogDialog(QWidget *parent = 0); - ~CGeorgesLogDialog(); - - private: - Ui::CGeorgesLogDialog _ui; - - CQtDisplayer *_displayer; - - friend class CMainWindow; - }; /* CGeorgesLogDialog */ - -} /* namespace NLQT */ - -#endif // LOG_DIALOG_H +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef LOG_DIALOG_H +#define LOG_DIALOG_H + +// Qt includes +#include + +// STL includes + +// NeL includes +#include + +// Project includes +#include "ui_log_form.h" + +namespace NLQT +{ + class CQtDisplayer; + + class CGeorgesLogDialog: public QDockWidget + { + + public: + CGeorgesLogDialog(QWidget *parent = 0); + ~CGeorgesLogDialog(); + + private: + Ui::CGeorgesLogDialog _ui; + + CQtDisplayer *_displayer; + + friend class CMainWindow; + }; /* CGeorgesLogDialog */ + +} /* namespace NLQT */ + +#endif // LOG_DIALOG_H diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/main.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/main.cpp index d877de075..ef8fadec0 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/main.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/main.cpp @@ -1,137 +1,137 @@ -#include -#include - -// Qt includes -#include -#include -#include -#include -#include -#include - -// NeL includes -#include -#include -#include -#include -#include -#include - -// Project includes -#include "modules.h" -#include "georges_splash.h" - -// nel_qt log file name -#define NLQT_LOG_FILE "nel_qt.log" - -// clear nel_qt log before use -#define NLQT_ERASE_LOG true - -#if !defined (NLQT_USE_LOG_LOG) -# define NLQT_USE_LOG_LOG true -#endif -#if !defined (NLQT_USE_LOG) -# define NLQT_USE_LOG 1 -#endif - -using namespace std; -using namespace NLMISC; - -namespace NLQT -{ - - namespace - { - - CFileDisplayer *s_FileDisplayer = NULL; - - } /* anonymous namespace */ - -} /* namespace NLQT */ - -void messageHandler(QtMsgType p_type, const char* p_msg) -{ - - fprintf(stderr, "%s\n", p_msg); - - QFile file("qt.log"); - file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text); - - QChar code; - switch (p_type) - { - case QtDebugMsg: code = 'D'; break; - case QtWarningMsg: code = 'W'; break; - case QtCriticalMsg: code = 'C'; break; - case QtFatalMsg: code = 'F'; break; - } - QString dt = QDateTime::currentDateTime().toString("yyyyMMdd hh:mm:ss"); - - QTextStream(&file) << QString("%1 [%2] %3\n").arg(dt).arg(code).arg(QString(p_msg)); -} - -#ifndef DATA_DIR -# define DATA_DIR "." -#endif - - -#ifdef NL_OS_WINDOWS -# ifdef _UNICODE -# define tstring wstring -# else -# define tstring string -# endif -#endif - -sint main(int argc, char **argv) -{ - QApplication app(argc, argv); - QPixmap pixmap(":/images/georges_logo.png"); - NLQT::CGeorgesSplash splash; - splash.show(); - app.processEvents(); - - NLMISC::CApplicationContext myApplicationContext; - -#if defined(NL_OS_MAC) - QDir::setCurrent(qApp->applicationDirPath() + QString("/../Resources")); - CLibrary::addLibPath( - (qApp->applicationDirPath() + QString("/../PlugIns/nel")).toStdString()); -#endif - - // go nel! - { - // use log.log if NEL_LOG_IN_FILE and NLQT_USE_LOG_LOG defined as 1 - createDebug(NULL, NLQT_USE_LOG_LOG, false); - if (QFile::exists("qt.log")) - QFile::remove("qt.log"); - - qInstallMsgHandler(messageHandler); -#if NLQT_USE_LOG - // create toverhex_client.log - // filedisplayer only deletes the 001 etc - if (NLQT_ERASE_LOG && CFile::isExists(NLQT_LOG_FILE)) - CFile::deleteFile(NLQT_LOG_FILE); - // initialize the log file - NLQT::s_FileDisplayer = new CFileDisplayer(); - NLQT::s_FileDisplayer->setParam(NLQT_LOG_FILE, NLQT_ERASE_LOG); - DebugLog->addDisplayer(NLQT::s_FileDisplayer); - InfoLog->addDisplayer(NLQT::s_FileDisplayer); - WarningLog->addDisplayer(NLQT::s_FileDisplayer); - AssertLog->addDisplayer(NLQT::s_FileDisplayer); - ErrorLog->addDisplayer(NLQT::s_FileDisplayer); -#endif - - nlinfo("Welcome to NeL!"); - - NLMISC::CPath::remapExtension("tga", "png", true); - } - - Modules::init(&splash); - //Modules::mainWin().resize(800,600); - Modules::mainWin().show(); - splash.close(); - int result = app.exec(); - Modules::release(); - return result; -} +#include +#include + +// Qt includes +#include +#include +#include +#include +#include +#include + +// NeL includes +#include +#include +#include +#include +#include +#include + +// Project includes +#include "modules.h" +#include "georges_splash.h" + +// nel_qt log file name +#define NLQT_LOG_FILE "nel_qt.log" + +// clear nel_qt log before use +#define NLQT_ERASE_LOG true + +#if !defined (NLQT_USE_LOG_LOG) +# define NLQT_USE_LOG_LOG true +#endif +#if !defined (NLQT_USE_LOG) +# define NLQT_USE_LOG 1 +#endif + +using namespace std; +using namespace NLMISC; + +namespace NLQT +{ + + namespace + { + + CFileDisplayer *s_FileDisplayer = NULL; + + } /* anonymous namespace */ + +} /* namespace NLQT */ + +void messageHandler(QtMsgType p_type, const char* p_msg) +{ + + fprintf(stderr, "%s\n", p_msg); + + QFile file("qt.log"); + file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text); + + QChar code; + switch (p_type) + { + case QtDebugMsg: code = 'D'; break; + case QtWarningMsg: code = 'W'; break; + case QtCriticalMsg: code = 'C'; break; + case QtFatalMsg: code = 'F'; break; + } + QString dt = QDateTime::currentDateTime().toString("yyyyMMdd hh:mm:ss"); + + QTextStream(&file) << QString("%1 [%2] %3\n").arg(dt).arg(code).arg(QString(p_msg)); +} + +#ifndef DATA_DIR +# define DATA_DIR "." +#endif + + +#ifdef NL_OS_WINDOWS +# ifdef _UNICODE +# define tstring wstring +# else +# define tstring string +# endif +#endif + +sint main(int argc, char **argv) +{ + QApplication app(argc, argv); + QPixmap pixmap(":/images/georges_logo.png"); + NLQT::CGeorgesSplash splash; + splash.show(); + app.processEvents(); + + NLMISC::CApplicationContext myApplicationContext; + +#if defined(NL_OS_MAC) + QDir::setCurrent(qApp->applicationDirPath() + QString("/../Resources")); + CLibrary::addLibPath( + (qApp->applicationDirPath() + QString("/../PlugIns/nel")).toStdString()); +#endif + + // go nel! + { + // use log.log if NEL_LOG_IN_FILE and NLQT_USE_LOG_LOG defined as 1 + createDebug(NULL, NLQT_USE_LOG_LOG, false); + if (QFile::exists("qt.log")) + QFile::remove("qt.log"); + + qInstallMsgHandler(messageHandler); +#if NLQT_USE_LOG + // create toverhex_client.log + // filedisplayer only deletes the 001 etc + if (NLQT_ERASE_LOG && CFile::isExists(NLQT_LOG_FILE)) + CFile::deleteFile(NLQT_LOG_FILE); + // initialize the log file + NLQT::s_FileDisplayer = new CFileDisplayer(); + NLQT::s_FileDisplayer->setParam(NLQT_LOG_FILE, NLQT_ERASE_LOG); + DebugLog->addDisplayer(NLQT::s_FileDisplayer); + InfoLog->addDisplayer(NLQT::s_FileDisplayer); + WarningLog->addDisplayer(NLQT::s_FileDisplayer); + AssertLog->addDisplayer(NLQT::s_FileDisplayer); + ErrorLog->addDisplayer(NLQT::s_FileDisplayer); +#endif + + nlinfo("Welcome to NeL!"); + + NLMISC::CPath::remapExtension("tga", "png", true); + } + + Modules::init(&splash); + //Modules::mainWin().resize(800,600); + Modules::mainWin().show(); + splash.close(); + int result = app.exec(); + Modules::release(); + return result; +} diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/main_window.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/main_window.cpp index b9c105615..1e5959973 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/main_window.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/main_window.cpp @@ -1,541 +1,541 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#include "main_window.h" - -// STL includes - -// Qt includes -#include - -// NeL includes -#include - -// Project includes -#include "modules.h" -#include "settings_dialog.h" -#include "log_dialog.h" -#include "new_dialog.h" -#include "objectviewer_dialog.h" -#include "georges_dirtree_dialog.h" -#include "georges_treeview_dialog.h" -#include "progress_dialog.h" - -using namespace std; -using namespace NLMISC; - -namespace NLQT -{ - - CMainWindow::CMainWindow(QWidget *parent) - : QMainWindow(parent), _GeorgesLogDialog(0), _ObjectViewerDialog(0), - _GeorgesDirTreeDialog(0),_emptyView(0) - { - setWindowTitle("Georges Editor Qt"); - - setDockNestingEnabled(true); - setCentralWidget(0); - setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); - setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); - - // create log dock widget - _GeorgesLogDialog = new CGeorgesLogDialog(this); - addDockWidget(Qt::RightDockWidgetArea, _GeorgesLogDialog); - - // empty form view as placeholder - createEmptyView(); - _currentView = 0; - - // load and set leveldesign path from config - _leveldesignPath = Modules::config(). - getValue("LeveldesignPath", QString("").toStdString()).c_str(); - QFileInfo info(_leveldesignPath); - if (!info.isDir()) - _leveldesignPath = ""; - - // create georges dir dock widget - _GeorgesDirTreeDialog = new CGeorgesDirTreeDialog(_leveldesignPath, this); - addDockWidget(Qt::LeftDockWidgetArea, _GeorgesDirTreeDialog); - if (_leveldesignPath == "") - { - if (QMessageBox::information(this, tr("Missing leveldesign path"), - tr("Your leveldesign path seems to be empty or incorrect.\nDo you want to set it now?"), - QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) - { - settings(); - } - } - - // create NeL viewport dock widget - _ObjectViewerDialog = new CObjectViewerDialog(this); - addDockWidget(Qt::LeftDockWidgetArea, _ObjectViewerDialog); - - createActions(); - createMenus(); - createToolBars(); - createStatusBar(); - - //_ObjectViewerDialog->toggleViewAction()->trigger(); - QSettings settings("georges_editor_qt.ini", QSettings::IniFormat); - settings.beginGroup("WindowSettings"); - restoreState(settings.value("QtWindowState").toByteArray()); - restoreGeometry(settings.value("QtWindowGeometry").toByteArray()); - settings.endGroup(); - - setWindowIcon(QIcon(":/images/georges_logo.png")); - - _statusBarTimer = new QTimer(this); - connect(_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar())); - _statusBarTimer->start(5000); - - connect(_GeorgesDirTreeDialog, SIGNAL(selectedForm(const QString)), - this, SLOT(loadFile(const QString))); - } - - CMainWindow::~CMainWindow() - { - // save state & geometry of window and widgets - - - _statusBarTimer->stop(); - - delete _ObjectViewerDialog; - delete _GeorgesDirTreeDialog; - delete _GeorgesLogDialog; - //delete _emptyView; - } - - void CMainWindow::closeEvent(QCloseEvent *event) - { - // TODO: dirty hack to have qt recognize possible state/geometry changes - // of new emptyView - CGeorgesTreeViewDialog *bla = new CGeorgesTreeViewDialog(this, true); - tabifyDockWidget(_emptyView, bla); - removeDockWidget(bla); - bla->deleteLater(); - - QSettings settings("georges_editor_qt.ini", QSettings::IniFormat); - settings.beginGroup("WindowSettings"); - settings.setValue("QtWindowState", saveState()); - settings.setValue("QtWindowGeometry", saveGeometry()); - settings.endGroup(); - event->accept(); - } - - CGeorgesTreeViewDialog * CMainWindow::createTreeView(QString file) - { - // create or/and raise tree view dock widget for current file - - //setCurrentFile(file); - - CGeorgesTreeViewDialog *newView = 0; - - Q_FOREACH(CGeorgesTreeViewDialog* dlg, _treeViewList) - { - if (dlg->loadedForm == file) - newView = dlg; - } - if (!newView) - { - newView = new CGeorgesTreeViewDialog(this); - newView->setWindowTitle(file); - - if (_treeViewList.isEmpty()) - { - tabifyDockWidget(_emptyView, newView); - _emptyView->deleteLater(); - } - else - { - tabifyDockWidget(_currentView,newView); - QTabBar* tb = Modules::mainWin().getTabBar(); - if (tb) - { - disconnect(tb, SIGNAL(currentChanged ( int ) ), - this,SLOT(tabChanged(int))); - connect(tb, SIGNAL(currentChanged ( int ) ), - this,SLOT(tabChanged(int))); - } - } - - _treeViewList.append(newView); - - //newView->selectedForm(file); - - _currentView = newView; - - connect(newView, SIGNAL(changeFile(QString)), - _GeorgesDirTreeDialog, SLOT(changeFile(QString))); - connect(newView, SIGNAL(modified(bool)), - _saveAction, SLOT(setEnabled(bool))); - } - QApplication::processEvents(); - newView->raise(); - - return newView; - } - - void CMainWindow::settings() - { - CSettingsDialog _settingsDialog(this); - - connect(&_settingsDialog,SIGNAL(ldPathChanged(QString)), - _GeorgesDirTreeDialog,SLOT(ldPathChanged(QString))); - - //_settingsDialog.show(); - _settingsDialog.exec(); - } - - void CMainWindow::about() - { - QMessageBox::about(this, tr("About Georges Viewer Qt"), - tr("

Georges Viewer Qt

" - "Author: aquiles
Credits:Thx to dnk-88 for parts of his code")); - } - - void CMainWindow::updateStatusBar() - { - //if (_isGraphicsInitialized) - // statusBar()->showMessage(QString(Modules::objView().getDriver()->getVideocardInformation())); - } - - void CMainWindow::open() - { - // TODO: FileDialog & loadFile(); - QString fileName = QFileDialog::getOpenFileName(); - loadFile(fileName); - } - - void CMainWindow::save() - { - if(!_currentView) - return; - - setCursor(Qt::WaitCursor); - - //TODO: if not exists open FileDialog SaveAs... - if(!CPath::exists(_currentView->loadedForm.toStdString())) - { - QString fileName = QFileDialog::getSaveFileName( - this, - QString(), - _currentView->loadedForm - ); - QFile file(fileName); - file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text); - file.close(); - CPath::addSearchFile(fileName.toStdString()); - //QFileInfo info = QFileInfo(file); - //m->setData(in2, info.fileName()); - } - _currentView->write(); - setWindowTitle(windowTitle().remove("*")); - _saveAction->setEnabled(false); - - setCursor(Qt::ArrowCursor); - } - - void CMainWindow::create() - { - QStringList lst; - CGeorgesNewDialog dlg(lst); - dlg.exec(); - qDebug() << lst; - if (!lst.isEmpty() && !lst.at(0).isEmpty()) - { - QString formName = lst.takeFirst(); - CGeorgesTreeViewDialog * newView = 0; - newView = createTreeView(formName); - CForm* form = newView->getFormByName(formName); - newView->setForm(form); - - Q_FOREACH(QString dep, lst) - { - newView->addParentForm(newView->getFormByName(dep)); - } - newView->loadFormIntoDialog(); - //TODO: look into setFilename for new Form object - if(newView->loadedForm.isEmpty()) - { - newView->loadedForm = formName; - setWindowTitle("Qt Georges Editor - " + formName); - } - newView->modifiedFile(); - } - } - - void CMainWindow::createEmptyView(QDockWidget* w) - { - _emptyView = new CGeorgesTreeViewDialog(this, true); - - if(w) - { - addDockWidget(Qt::TopDockWidgetArea, _emptyView); - tabifyDockWidget(w, _emptyView); - } - else - { - addDockWidget(Qt::TopDockWidgetArea, _emptyView); - } - } - - void CMainWindow::createActions() - { - _openAction = new QAction(tr("&Open..."), this); - _openAction->setIcon(QApplication::style()->standardIcon(QStyle::SP_DialogOpenButton)); - _openAction->setShortcut(QKeySequence::Open); - _openAction->setStatusTip(tr("Open an existing file")); - connect(_openAction, SIGNAL(triggered()), this, SLOT(open())); - - _createAction = new QAction(tr("&New..."), this); - _createAction->setIcon(QApplication::style()->standardIcon(QStyle::SP_FileDialogNewFolder)); - _createAction->setShortcut(QKeySequence::New); - _createAction->setStatusTip(tr("Create a new file")); - connect(_createAction, SIGNAL(triggered()), this, SLOT(create())); - - _saveAction = new QAction(tr("&Save..."), this); - _saveAction->setIcon(QApplication::style()->standardIcon(QStyle::SP_DialogSaveButton)); - _saveAction->setShortcut(QKeySequence::Save); - _saveAction->setStatusTip(tr("Saves the current file")); - _saveAction->setDisabled(true); - connect(_saveAction, SIGNAL(triggered()), this, SLOT(save())); - - _exitAction = new QAction(tr("E&xit"), this); - _exitAction->setShortcut(QKeySequence::Close); - _exitAction->setIcon(QApplication::style()->standardIcon(QStyle::SP_DialogCloseButton)); - _exitAction->setStatusTip(tr("Exit the application")); - connect(_exitAction, SIGNAL(triggered()), this, SLOT(close())); - - _setBackColorAction = _ObjectViewerDialog->createSetBackgroundColor(this); - _setBackColorAction->setText(tr("Set &background color")); - _setBackColorAction->setStatusTip(tr("Set background color")); - - _settingsAction = new QAction(tr("&Settings"), this); - _settingsAction->setIcon(QIcon(":/images/preferences.png")); - _settingsAction->setStatusTip(tr("Settings")); - connect(_settingsAction, SIGNAL(triggered()), this, SLOT(settings())); - - _aboutAction = new QAction(tr("&About"), this); - _aboutAction->setStatusTip(tr("Show the application's About box")); - connect(_aboutAction, SIGNAL(triggered()), this, SLOT(about())); - - _aboutQtAction = new QAction(tr("About &Qt"), this); - _aboutQtAction->setStatusTip(tr("Show the Qt library's About box")); - connect(_aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); - - for (int i = 0; i < MaxRecentFiles; ++i) { - recentFileActs[i] = new QAction(this); - recentFileActs[i]->setVisible(false); - connect(recentFileActs[i], SIGNAL(triggered()), - this, SLOT(openRecentFile())); - } - } - - void CMainWindow::createMenus() - { - _fileMenu = menuBar()->addMenu(tr("&File")); - _fileMenu->addAction(_createAction); - _fileMenu->addAction(_openAction); - _fileMenu->addAction(_saveAction); - _separatorAction = _fileMenu->addSeparator(); - for (int i = 0; i < MaxRecentFiles; ++i) - _fileMenu->addAction(recentFileActs[i]); - _fileMenu->addSeparator(); - _fileMenu->addAction(_exitAction); - updateRecentFileActions(); - - _viewMenu = menuBar()->addMenu(tr("&View")); - _viewMenu->addAction(_setBackColorAction); - if (_GeorgesDirTreeDialog) - _viewMenu->addAction(_GeorgesDirTreeDialog->toggleViewAction()); - - _toolsMenu = menuBar()->addMenu(tr("&Tools")); - if (_ObjectViewerDialog) - { - _toolsMenu->addAction(_ObjectViewerDialog->toggleViewAction()); - _ObjectViewerDialog->toggleViewAction()->setIcon(QIcon(":/images/pqrticles.png")); - } - _toolsMenu->addSeparator(); - _toolsMenu->addAction(_settingsAction); - - menuBar()->addSeparator(); - - _helpMenu = menuBar()->addMenu(tr("&Help")); - _helpMenu->addAction(_aboutAction); - _helpMenu->addAction(_aboutQtAction); - } - - void CMainWindow::createToolBars() - { - _fileToolBar = addToolBar(tr("&File")); - _fileToolBar->addAction(_createAction); - _fileToolBar->addAction(_openAction); - _fileToolBar->addAction(_saveAction); - - _toolsBar = addToolBar(tr("&Tools")); - if (_ObjectViewerDialog) - _toolsBar->addAction(_ObjectViewerDialog->toggleViewAction()); - } - - void CMainWindow::createStatusBar() - { - statusBar()->showMessage(tr("StatusReady")); - } - - void CMainWindow::cfcbQtStyle(NLMISC::CConfigFile::CVar &var) - { - QApplication::setStyle(QStyleFactory::create(var.asString().c_str())); - } - - void CMainWindow::cfcbQtPalette(NLMISC::CConfigFile::CVar &var) - { - if (var.asBool()) - QApplication::setPalette(QApplication::style()->standardPalette()); - else - QApplication::setPalette(_originalPalette); - } - - QTabBar* CMainWindow::getTabBar() - { - // get the QTabBar - QList tabList = findChildren(); - //tabList = _mainWindow->findChildren(); - //nlinfo(QString("%1 %2").arg(QString::number((int)this,16)). - // arg(QString::number((int)_mainWindow,16)). - // toStdString().c_str()); - QTabBar *tb = 0; - Q_FOREACH(QTabBar *tabBar, tabList) - { - if (tabBar->parent() != this) - continue; - //nlinfo(QString("%1 %2 %3 %4").arg(tabBar->objectName()). - // arg(QString::number((int)tabBar,16)). - // arg(QString::number((int)tabBar->parentWidget(),16)). - // arg(QString::number((int)tabBar->parent(),16)). - // toStdString().c_str()); - for (int i = 0; i < tabBar->count(); i++) - { - QString currentTab = tabBar->tabText(i); - //nlinfo(currentTab.toStdString().c_str()); - } - tb = tabBar; - } - return tb; - } - - void CMainWindow::tabChanged(int index) - { - nlinfo(QString("%1").arg(index).toStdString().c_str()); - if (index == -1) - { - setWindowTitle("Qt Georges Editor"); - return; - } - - QTabBar *tb = getTabBar(); - //nlinfo(QString("%1").arg(index).toStdString().c_str()); - - Q_FOREACH(CGeorgesTreeViewDialog* dlg, _treeViewList) - { - if (dlg->windowTitle() == tb->tabText(index)) - { - //nlinfo(QString("%1 modified %2").arg(tb->tabText(index)). - // arg(dlg->modified()). - // toStdString().c_str()); - _currentView = dlg; - setWindowTitle("Qt Georges Editor - " + tb->tabText(index)); - _saveAction->setEnabled(dlg->modified()); - } - } - } - - void CMainWindow::loadFile(QString fileName){ - QFileInfo info(fileName); - fileName = info.fileName(); - // TODO: make georges static and stuff - CGeorgesTreeViewDialog *newView = new CGeorgesTreeViewDialog; - CForm *form = newView->getFormByName(fileName); - if (form) - { - delete newView; - newView = createTreeView(fileName); - newView->setForm(form); - newView->loadFormIntoDialog(form); - setCurrentFile(fileName); - return; - } - delete newView; - } - - void CMainWindow::openRecentFile() - { - QAction *action = qobject_cast(sender()); - if (action) - loadFile(action->data().toString()); - } - - void CMainWindow::setCurrentFile(const QString &fileName) - { - //curFile = fileName; - //setWindowFilePath(curFile); - - QSettings settings("georges_editor_qt.ini", QSettings::IniFormat); - settings.beginGroup("RecentFileList"); - QStringList files = settings.value("List").toStringList(); - settings.endGroup(); - - files.removeAll(fileName); - files.prepend(fileName); - while (files.size() > MaxRecentFiles) - files.removeLast(); - - settings.beginGroup("RecentFileList"); - settings.setValue("List",files); - settings.endGroup(); - - Q_FOREACH (QWidget *widget, QApplication::topLevelWidgets()) - { - CMainWindow *mainWin = qobject_cast(widget); - if (mainWin) - mainWin->updateRecentFileActions(); - } - } - - void CMainWindow::updateRecentFileActions() - { - QSettings settings("georges_editor_qt.ini", QSettings::IniFormat); - settings.beginGroup("RecentFileList"); - QStringList files = settings.value("List").toStringList(); - settings.endGroup(); - int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles); - - for (int i = 0; i < numRecentFiles; ++i) - { - QString text = tr("&%1 %2").arg(i + 1).arg(QFileInfo(files[i]).fileName()); - recentFileActs[i]->setText(text); - recentFileActs[i]->setData(files[i]); - recentFileActs[i]->setVisible(true); - } - for (int j = numRecentFiles; j < MaxRecentFiles; ++j) - recentFileActs[j]->setVisible(false); - - _separatorAction->setVisible(numRecentFiles > 0); - } -} /* namespace NLQT */ - -/* end of file */ +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "main_window.h" + +// STL includes + +// Qt includes +#include + +// NeL includes +#include + +// Project includes +#include "modules.h" +#include "settings_dialog.h" +#include "log_dialog.h" +#include "new_dialog.h" +#include "objectviewer_dialog.h" +#include "georges_dirtree_dialog.h" +#include "georges_treeview_dialog.h" +#include "progress_dialog.h" + +using namespace std; +using namespace NLMISC; + +namespace NLQT +{ + + CMainWindow::CMainWindow(QWidget *parent) + : QMainWindow(parent), _GeorgesLogDialog(0), _ObjectViewerDialog(0), + _GeorgesDirTreeDialog(0),_emptyView(0) + { + setWindowTitle("Georges Editor Qt"); + + setDockNestingEnabled(true); + setCentralWidget(0); + setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); + setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); + + // create log dock widget + _GeorgesLogDialog = new CGeorgesLogDialog(this); + addDockWidget(Qt::RightDockWidgetArea, _GeorgesLogDialog); + + // empty form view as placeholder + createEmptyView(); + _currentView = 0; + + // load and set leveldesign path from config + _leveldesignPath = Modules::config(). + getValue("LeveldesignPath", QString("").toStdString()).c_str(); + QFileInfo info(_leveldesignPath); + if (!info.isDir()) + _leveldesignPath = ""; + + // create georges dir dock widget + _GeorgesDirTreeDialog = new CGeorgesDirTreeDialog(_leveldesignPath, this); + addDockWidget(Qt::LeftDockWidgetArea, _GeorgesDirTreeDialog); + if (_leveldesignPath == "") + { + if (QMessageBox::information(this, tr("Missing leveldesign path"), + tr("Your leveldesign path seems to be empty or incorrect.\nDo you want to set it now?"), + QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) + { + settings(); + } + } + + // create NeL viewport dock widget + _ObjectViewerDialog = new CObjectViewerDialog(this); + addDockWidget(Qt::LeftDockWidgetArea, _ObjectViewerDialog); + + createActions(); + createMenus(); + createToolBars(); + createStatusBar(); + + //_ObjectViewerDialog->toggleViewAction()->trigger(); + QSettings settings("georges_editor_qt.ini", QSettings::IniFormat); + settings.beginGroup("WindowSettings"); + restoreState(settings.value("QtWindowState").toByteArray()); + restoreGeometry(settings.value("QtWindowGeometry").toByteArray()); + settings.endGroup(); + + setWindowIcon(QIcon(":/images/georges_logo.png")); + + _statusBarTimer = new QTimer(this); + connect(_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar())); + _statusBarTimer->start(5000); + + connect(_GeorgesDirTreeDialog, SIGNAL(selectedForm(const QString)), + this, SLOT(loadFile(const QString))); + } + + CMainWindow::~CMainWindow() + { + // save state & geometry of window and widgets + + + _statusBarTimer->stop(); + + delete _ObjectViewerDialog; + delete _GeorgesDirTreeDialog; + delete _GeorgesLogDialog; + //delete _emptyView; + } + + void CMainWindow::closeEvent(QCloseEvent *event) + { + // TODO: dirty hack to have qt recognize possible state/geometry changes + // of new emptyView + CGeorgesTreeViewDialog *bla = new CGeorgesTreeViewDialog(this, true); + tabifyDockWidget(_emptyView, bla); + removeDockWidget(bla); + bla->deleteLater(); + + QSettings settings("georges_editor_qt.ini", QSettings::IniFormat); + settings.beginGroup("WindowSettings"); + settings.setValue("QtWindowState", saveState()); + settings.setValue("QtWindowGeometry", saveGeometry()); + settings.endGroup(); + event->accept(); + } + + CGeorgesTreeViewDialog * CMainWindow::createTreeView(QString file) + { + // create or/and raise tree view dock widget for current file + + //setCurrentFile(file); + + CGeorgesTreeViewDialog *newView = 0; + + Q_FOREACH(CGeorgesTreeViewDialog* dlg, _treeViewList) + { + if (dlg->loadedForm == file) + newView = dlg; + } + if (!newView) + { + newView = new CGeorgesTreeViewDialog(this); + newView->setWindowTitle(file); + + if (_treeViewList.isEmpty()) + { + tabifyDockWidget(_emptyView, newView); + _emptyView->deleteLater(); + } + else + { + tabifyDockWidget(_currentView,newView); + QTabBar* tb = Modules::mainWin().getTabBar(); + if (tb) + { + disconnect(tb, SIGNAL(currentChanged ( int ) ), + this,SLOT(tabChanged(int))); + connect(tb, SIGNAL(currentChanged ( int ) ), + this,SLOT(tabChanged(int))); + } + } + + _treeViewList.append(newView); + + //newView->selectedForm(file); + + _currentView = newView; + + connect(newView, SIGNAL(changeFile(QString)), + _GeorgesDirTreeDialog, SLOT(changeFile(QString))); + connect(newView, SIGNAL(modified(bool)), + _saveAction, SLOT(setEnabled(bool))); + } + QApplication::processEvents(); + newView->raise(); + + return newView; + } + + void CMainWindow::settings() + { + CSettingsDialog _settingsDialog(this); + + connect(&_settingsDialog,SIGNAL(ldPathChanged(QString)), + _GeorgesDirTreeDialog,SLOT(ldPathChanged(QString))); + + //_settingsDialog.show(); + _settingsDialog.exec(); + } + + void CMainWindow::about() + { + QMessageBox::about(this, tr("About Georges Viewer Qt"), + tr("

Georges Viewer Qt

" + "Author: aquiles
Credits:Thx to dnk-88 for parts of his code")); + } + + void CMainWindow::updateStatusBar() + { + //if (_isGraphicsInitialized) + // statusBar()->showMessage(QString(Modules::objView().getDriver()->getVideocardInformation())); + } + + void CMainWindow::open() + { + // TODO: FileDialog & loadFile(); + QString fileName = QFileDialog::getOpenFileName(); + loadFile(fileName); + } + + void CMainWindow::save() + { + if(!_currentView) + return; + + setCursor(Qt::WaitCursor); + + //TODO: if not exists open FileDialog SaveAs... + if(!CPath::exists(_currentView->loadedForm.toStdString())) + { + QString fileName = QFileDialog::getSaveFileName( + this, + QString(), + _currentView->loadedForm + ); + QFile file(fileName); + file.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text); + file.close(); + CPath::addSearchFile(fileName.toStdString()); + //QFileInfo info = QFileInfo(file); + //m->setData(in2, info.fileName()); + } + _currentView->write(); + setWindowTitle(windowTitle().remove("*")); + _saveAction->setEnabled(false); + + setCursor(Qt::ArrowCursor); + } + + void CMainWindow::create() + { + QStringList lst; + CGeorgesNewDialog dlg(lst); + dlg.exec(); + qDebug() << lst; + if (!lst.isEmpty() && !lst.at(0).isEmpty()) + { + QString formName = lst.takeFirst(); + CGeorgesTreeViewDialog * newView = 0; + newView = createTreeView(formName); + CForm* form = newView->getFormByName(formName); + newView->setForm(form); + + Q_FOREACH(QString dep, lst) + { + newView->addParentForm(newView->getFormByName(dep)); + } + newView->loadFormIntoDialog(); + //TODO: look into setFilename for new Form object + if(newView->loadedForm.isEmpty()) + { + newView->loadedForm = formName; + setWindowTitle("Qt Georges Editor - " + formName); + } + newView->modifiedFile(); + } + } + + void CMainWindow::createEmptyView(QDockWidget* w) + { + _emptyView = new CGeorgesTreeViewDialog(this, true); + + if(w) + { + addDockWidget(Qt::TopDockWidgetArea, _emptyView); + tabifyDockWidget(w, _emptyView); + } + else + { + addDockWidget(Qt::TopDockWidgetArea, _emptyView); + } + } + + void CMainWindow::createActions() + { + _openAction = new QAction(tr("&Open..."), this); + _openAction->setIcon(QApplication::style()->standardIcon(QStyle::SP_DialogOpenButton)); + _openAction->setShortcut(QKeySequence::Open); + _openAction->setStatusTip(tr("Open an existing file")); + connect(_openAction, SIGNAL(triggered()), this, SLOT(open())); + + _createAction = new QAction(tr("&New..."), this); + _createAction->setIcon(QApplication::style()->standardIcon(QStyle::SP_FileDialogNewFolder)); + _createAction->setShortcut(QKeySequence::New); + _createAction->setStatusTip(tr("Create a new file")); + connect(_createAction, SIGNAL(triggered()), this, SLOT(create())); + + _saveAction = new QAction(tr("&Save..."), this); + _saveAction->setIcon(QApplication::style()->standardIcon(QStyle::SP_DialogSaveButton)); + _saveAction->setShortcut(QKeySequence::Save); + _saveAction->setStatusTip(tr("Saves the current file")); + _saveAction->setDisabled(true); + connect(_saveAction, SIGNAL(triggered()), this, SLOT(save())); + + _exitAction = new QAction(tr("E&xit"), this); + _exitAction->setShortcut(QKeySequence::Close); + _exitAction->setIcon(QApplication::style()->standardIcon(QStyle::SP_DialogCloseButton)); + _exitAction->setStatusTip(tr("Exit the application")); + connect(_exitAction, SIGNAL(triggered()), this, SLOT(close())); + + _setBackColorAction = _ObjectViewerDialog->createSetBackgroundColor(this); + _setBackColorAction->setText(tr("Set &background color")); + _setBackColorAction->setStatusTip(tr("Set background color")); + + _settingsAction = new QAction(tr("&Settings"), this); + _settingsAction->setIcon(QIcon(":/images/preferences.png")); + _settingsAction->setStatusTip(tr("Settings")); + connect(_settingsAction, SIGNAL(triggered()), this, SLOT(settings())); + + _aboutAction = new QAction(tr("&About"), this); + _aboutAction->setStatusTip(tr("Show the application's About box")); + connect(_aboutAction, SIGNAL(triggered()), this, SLOT(about())); + + _aboutQtAction = new QAction(tr("About &Qt"), this); + _aboutQtAction->setStatusTip(tr("Show the Qt library's About box")); + connect(_aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); + + for (int i = 0; i < MaxRecentFiles; ++i) { + recentFileActs[i] = new QAction(this); + recentFileActs[i]->setVisible(false); + connect(recentFileActs[i], SIGNAL(triggered()), + this, SLOT(openRecentFile())); + } + } + + void CMainWindow::createMenus() + { + _fileMenu = menuBar()->addMenu(tr("&File")); + _fileMenu->addAction(_createAction); + _fileMenu->addAction(_openAction); + _fileMenu->addAction(_saveAction); + _separatorAction = _fileMenu->addSeparator(); + for (int i = 0; i < MaxRecentFiles; ++i) + _fileMenu->addAction(recentFileActs[i]); + _fileMenu->addSeparator(); + _fileMenu->addAction(_exitAction); + updateRecentFileActions(); + + _viewMenu = menuBar()->addMenu(tr("&View")); + _viewMenu->addAction(_setBackColorAction); + if (_GeorgesDirTreeDialog) + _viewMenu->addAction(_GeorgesDirTreeDialog->toggleViewAction()); + + _toolsMenu = menuBar()->addMenu(tr("&Tools")); + if (_ObjectViewerDialog) + { + _toolsMenu->addAction(_ObjectViewerDialog->toggleViewAction()); + _ObjectViewerDialog->toggleViewAction()->setIcon(QIcon(":/images/pqrticles.png")); + } + _toolsMenu->addSeparator(); + _toolsMenu->addAction(_settingsAction); + + menuBar()->addSeparator(); + + _helpMenu = menuBar()->addMenu(tr("&Help")); + _helpMenu->addAction(_aboutAction); + _helpMenu->addAction(_aboutQtAction); + } + + void CMainWindow::createToolBars() + { + _fileToolBar = addToolBar(tr("&File")); + _fileToolBar->addAction(_createAction); + _fileToolBar->addAction(_openAction); + _fileToolBar->addAction(_saveAction); + + _toolsBar = addToolBar(tr("&Tools")); + if (_ObjectViewerDialog) + _toolsBar->addAction(_ObjectViewerDialog->toggleViewAction()); + } + + void CMainWindow::createStatusBar() + { + statusBar()->showMessage(tr("StatusReady")); + } + + void CMainWindow::cfcbQtStyle(NLMISC::CConfigFile::CVar &var) + { + QApplication::setStyle(QStyleFactory::create(var.asString().c_str())); + } + + void CMainWindow::cfcbQtPalette(NLMISC::CConfigFile::CVar &var) + { + if (var.asBool()) + QApplication::setPalette(QApplication::style()->standardPalette()); + else + QApplication::setPalette(_originalPalette); + } + + QTabBar* CMainWindow::getTabBar() + { + // get the QTabBar + QList tabList = findChildren(); + //tabList = _mainWindow->findChildren(); + //nlinfo(QString("%1 %2").arg(QString::number((int)this,16)). + // arg(QString::number((int)_mainWindow,16)). + // toStdString().c_str()); + QTabBar *tb = 0; + Q_FOREACH(QTabBar *tabBar, tabList) + { + if (tabBar->parent() != this) + continue; + //nlinfo(QString("%1 %2 %3 %4").arg(tabBar->objectName()). + // arg(QString::number((int)tabBar,16)). + // arg(QString::number((int)tabBar->parentWidget(),16)). + // arg(QString::number((int)tabBar->parent(),16)). + // toStdString().c_str()); + for (int i = 0; i < tabBar->count(); i++) + { + QString currentTab = tabBar->tabText(i); + //nlinfo(currentTab.toStdString().c_str()); + } + tb = tabBar; + } + return tb; + } + + void CMainWindow::tabChanged(int index) + { + nlinfo(QString("%1").arg(index).toStdString().c_str()); + if (index == -1) + { + setWindowTitle("Qt Georges Editor"); + return; + } + + QTabBar *tb = getTabBar(); + //nlinfo(QString("%1").arg(index).toStdString().c_str()); + + Q_FOREACH(CGeorgesTreeViewDialog* dlg, _treeViewList) + { + if (dlg->windowTitle() == tb->tabText(index)) + { + //nlinfo(QString("%1 modified %2").arg(tb->tabText(index)). + // arg(dlg->modified()). + // toStdString().c_str()); + _currentView = dlg; + setWindowTitle("Qt Georges Editor - " + tb->tabText(index)); + _saveAction->setEnabled(dlg->modified()); + } + } + } + + void CMainWindow::loadFile(QString fileName){ + QFileInfo info(fileName); + fileName = info.fileName(); + // TODO: make georges static and stuff + CGeorgesTreeViewDialog *newView = new CGeorgesTreeViewDialog; + CForm *form = newView->getFormByName(fileName); + if (form) + { + delete newView; + newView = createTreeView(fileName); + newView->setForm(form); + newView->loadFormIntoDialog(form); + setCurrentFile(fileName); + return; + } + delete newView; + } + + void CMainWindow::openRecentFile() + { + QAction *action = qobject_cast(sender()); + if (action) + loadFile(action->data().toString()); + } + + void CMainWindow::setCurrentFile(const QString &fileName) + { + //curFile = fileName; + //setWindowFilePath(curFile); + + QSettings settings("georges_editor_qt.ini", QSettings::IniFormat); + settings.beginGroup("RecentFileList"); + QStringList files = settings.value("List").toStringList(); + settings.endGroup(); + + files.removeAll(fileName); + files.prepend(fileName); + while (files.size() > MaxRecentFiles) + files.removeLast(); + + settings.beginGroup("RecentFileList"); + settings.setValue("List",files); + settings.endGroup(); + + Q_FOREACH (QWidget *widget, QApplication::topLevelWidgets()) + { + CMainWindow *mainWin = qobject_cast(widget); + if (mainWin) + mainWin->updateRecentFileActions(); + } + } + + void CMainWindow::updateRecentFileActions() + { + QSettings settings("georges_editor_qt.ini", QSettings::IniFormat); + settings.beginGroup("RecentFileList"); + QStringList files = settings.value("List").toStringList(); + settings.endGroup(); + int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles); + + for (int i = 0; i < numRecentFiles; ++i) + { + QString text = tr("&%1 %2").arg(i + 1).arg(QFileInfo(files[i]).fileName()); + recentFileActs[i]->setText(text); + recentFileActs[i]->setData(files[i]); + recentFileActs[i]->setVisible(true); + } + for (int j = numRecentFiles; j < MaxRecentFiles; ++j) + recentFileActs[j]->setVisible(false); + + _separatorAction->setVisible(numRecentFiles > 0); + } +} /* namespace NLQT */ + +/* end of file */ diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/main_window.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/main_window.h index 05fdb928a..9740d6dcb 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/main_window.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/main_window.h @@ -1,127 +1,127 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -*/ - -#ifndef MAIN_WINDOW_H -#define MAIN_WINDOW_H -#include - -// STL includes - -// Qt includes - -#include -#include - -// NeL includes -#include - -// Project includes - -namespace NLMISC -{ - class CConfigFile; -} - -namespace NLQT -{ - - class CGeorgesLogDialog; - class CObjectViewerDialog; - class CGeorgesDirTreeDialog; - class CGeorgesTreeViewDialog; - - class CMainWindow : public QMainWindow - { - Q_OBJECT - - public: - CMainWindow(QWidget *parent = 0); - ~CMainWindow(); - - CGeorgesTreeViewDialog* getEmptyView() { return _emptyView;} - QList& getTreeViewList() { return _treeViewList; } - QTabBar* getTabBar(); - void createEmptyView(QDockWidget* w = 0); - void closeEvent(QCloseEvent *event); - - QString leveldesignPath() { return _leveldesignPath; } - - private Q_SLOTS: - void open(); - void create(); - void save(); - void settings(); - void about(); - void updateStatusBar(); - CGeorgesTreeViewDialog * createTreeView(QString); - void tabChanged(int); - void openRecentFile(); - void loadFile(QString fileName); - - private: - void createActions(); - void createMenus(); - void createToolBars(); - void createStatusBar(); - void createDialogs(); - - void updateRecentFileActions(); - void setCurrentFile(const QString &fileName); - - void cfcbQtStyle(NLMISC::CConfigFile::CVar &var); - void cfcbQtPalette(NLMISC::CConfigFile::CVar &var); - - CGeorgesLogDialog *_GeorgesLogDialog; - CObjectViewerDialog *_ObjectViewerDialog; - CGeorgesDirTreeDialog *_GeorgesDirTreeDialog; - QList _treeViewList; - CGeorgesTreeViewDialog *_emptyView; - CGeorgesTreeViewDialog *_currentView; - - QPalette _originalPalette; - - QTimer *_statusBarTimer; - - QMenu *_fileMenu; - QMenu *_viewMenu; - QMenu *_toolsMenu; - QMenu *_helpMenu; - QToolBar *_fileToolBar; - QToolBar *_editToolBar; - QToolBar *_toolsBar; - QAction *_openAction; - QAction *_createAction; - QAction *_saveAction; - QAction *_exitAction; - QAction *_setBackColorAction; - QAction *_settingsAction; - QAction *_aboutAction; - QAction *_aboutQtAction; - QAction *_separatorAction; - - QString _leveldesignPath; - - enum { MaxRecentFiles = 5 }; - QAction *recentFileActs[MaxRecentFiles]; - - };/* class CMainWindow */ - -} /* namespace NLQT */ - -#endif // MAIN_WINDOW_H +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +*/ + +#ifndef MAIN_WINDOW_H +#define MAIN_WINDOW_H +#include + +// STL includes + +// Qt includes + +#include +#include + +// NeL includes +#include + +// Project includes + +namespace NLMISC +{ + class CConfigFile; +} + +namespace NLQT +{ + + class CGeorgesLogDialog; + class CObjectViewerDialog; + class CGeorgesDirTreeDialog; + class CGeorgesTreeViewDialog; + + class CMainWindow : public QMainWindow + { + Q_OBJECT + + public: + CMainWindow(QWidget *parent = 0); + ~CMainWindow(); + + CGeorgesTreeViewDialog* getEmptyView() { return _emptyView;} + QList& getTreeViewList() { return _treeViewList; } + QTabBar* getTabBar(); + void createEmptyView(QDockWidget* w = 0); + void closeEvent(QCloseEvent *event); + + QString leveldesignPath() { return _leveldesignPath; } + + private Q_SLOTS: + void open(); + void create(); + void save(); + void settings(); + void about(); + void updateStatusBar(); + CGeorgesTreeViewDialog * createTreeView(QString); + void tabChanged(int); + void openRecentFile(); + void loadFile(QString fileName); + + private: + void createActions(); + void createMenus(); + void createToolBars(); + void createStatusBar(); + void createDialogs(); + + void updateRecentFileActions(); + void setCurrentFile(const QString &fileName); + + void cfcbQtStyle(NLMISC::CConfigFile::CVar &var); + void cfcbQtPalette(NLMISC::CConfigFile::CVar &var); + + CGeorgesLogDialog *_GeorgesLogDialog; + CObjectViewerDialog *_ObjectViewerDialog; + CGeorgesDirTreeDialog *_GeorgesDirTreeDialog; + QList _treeViewList; + CGeorgesTreeViewDialog *_emptyView; + CGeorgesTreeViewDialog *_currentView; + + QPalette _originalPalette; + + QTimer *_statusBarTimer; + + QMenu *_fileMenu; + QMenu *_viewMenu; + QMenu *_toolsMenu; + QMenu *_helpMenu; + QToolBar *_fileToolBar; + QToolBar *_editToolBar; + QToolBar *_toolsBar; + QAction *_openAction; + QAction *_createAction; + QAction *_saveAction; + QAction *_exitAction; + QAction *_setBackColorAction; + QAction *_settingsAction; + QAction *_aboutAction; + QAction *_aboutQtAction; + QAction *_separatorAction; + + QString _leveldesignPath; + + enum { MaxRecentFiles = 5 }; + QAction *recentFileActs[MaxRecentFiles]; + + };/* class CMainWindow */ + +} /* namespace NLQT */ + +#endif // MAIN_WINDOW_H diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/modules.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/modules.h index 3718d6733..24acf3cfe 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/modules.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/modules.h @@ -1,47 +1,47 @@ -/* - Georges Editor Qt - Copyright (C) 2010 Adrian Jaekel - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef MODULES_H -#define MODULES_H - -#include "configuration.h" -#include "main_window.h" -#include "interfaces.h" - -namespace NLMISC { - class IProgressCallback; -} - -class Modules -{ -public: - static void init(NLMISC::IProgressCallback *cb); - static void release(); - - static NLQT::CConfiguration &config() { return *_configuration; } - static NLQT::IObjectViewer* objViewInt() { return _objViewerInterface; } - static NLQT::CMainWindow &mainWin() { return *_mainWindow; } -private: - static bool loadPlugin(); - - static NLQT::IObjectViewer *_objViewerInterface; - static NLQT::CConfiguration *_configuration; - static NLQT::CMainWindow *_mainWindow; -}; - -#endif // MODULES_H +/* + Georges Editor Qt + Copyright (C) 2010 Adrian Jaekel + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef MODULES_H +#define MODULES_H + +#include "configuration.h" +#include "main_window.h" +#include "interfaces.h" + +namespace NLMISC { + class IProgressCallback; +} + +class Modules +{ +public: + static void init(NLMISC::IProgressCallback *cb); + static void release(); + + static NLQT::CConfiguration &config() { return *_configuration; } + static NLQT::IObjectViewer* objViewInt() { return _objViewerInterface; } + static NLQT::CMainWindow &mainWin() { return *_mainWindow; } +private: + static bool loadPlugin(); + + static NLQT::IObjectViewer *_objViewerInterface; + static NLQT::CConfiguration *_configuration; + static NLQT::CMainWindow *_mainWindow; +}; + +#endif // MODULES_H diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/new_dialog.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/new_dialog.cpp index 156e17ec0..e3cbda962 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/new_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/new_dialog.cpp @@ -1,341 +1,341 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -*/ - -#include "new_dialog.h" - -// Qt includes -#include -#include -#include -#include -#include - -#include - -// NeL includes -#include - -// Project includes -#include "modules.h" -#include "completer_line_edit.h" - -namespace NLQT -{ - - CGeorgesNewDialog::CGeorgesNewDialog(QStringList& result, QWidget *parent) - : QDialog(parent), - _result(result), - _descriptionTemplate(QString()) - { - _ui.setupUi(this); - - setWindowIcon(QIcon(":/images/georges_logo.png")); - - _ui.parentLineEdit->setEnabled(false); - _ui.addParentButton->setEnabled(true); - - // wizard page - connect(_ui.wizardBtn, SIGNAL(clicked(bool)), - this, SLOT(wizardBtnClicked(bool))); - connect(_ui.wizardList, SIGNAL(itemClicked(QListWidgetItem*)), - this, SLOT(wizardItemActivated(QListWidgetItem *))); - - // form page - connect(_ui.formBtn, SIGNAL(clicked(bool)), - this, SLOT(formBtnClicked(bool))); - connect(_ui.addParentButton, SIGNAL(clicked()), - this, SLOT(addParentClicked())); - connect(_ui.deleteParentButton, SIGNAL(clicked()), - this, SLOT(deleteParentClicked())); - connect(_ui.formList, SIGNAL(itemActivated(QListWidgetItem*)), - this, SLOT(formItemActivated(QListWidgetItem *))); - connect(_ui.formList, SIGNAL(itemClicked(QListWidgetItem*)), - this, SLOT(formItemActivated(QListWidgetItem *))); - connect(_ui.parentLineEdit, SIGNAL(editingFinished()), - this, SLOT(validateParentCombo())); - - // dfn page - connect(_ui.dfnTypeBtn, SIGNAL(clicked(bool)), - this, SLOT(dfnTypeClicked(bool))); - - connect(_ui.buttonBox, SIGNAL(accepted()), - this, SLOT(buttonBoxAccepted())); - connect(_ui.buttonBox, SIGNAL(rejected()), - this, SLOT(buttonBoxRejected())); - - // wizard list - QListWidgetItem *mpWiz = new QListWidgetItem(QIcon(":/images/mp_generic.png"),tr("Raw Material Generator")); - _ui.wizardList->addItem(mpWiz); - - // form list - QString path = Modules::mainWin().leveldesignPath(); - QStringList typelist; - //nlinfo ("Searching files in directory '%s'...", dir.c_str()); - NLMISC::CPath::getPathContent(path.toStdString(),true,false,true,_files); - - getTypes( /* path.toStdString() // incompatible parameter type */ ); - //nlinfo ("%d supported file types :",FileTypeToId.size()); - for ( std::map::iterator it = FileTypeToId.begin(); it != FileTypeToId.end(); ++it ) - { - typelist.append(QString((*it).first.c_str())); - //nlinfo("%s",(*it).first.c_str()); - } - _ui.formList->addItems(typelist); - - for(uint i = 0; i < _files.size(); i++) - { - std::string extStr = NLMISC::CFile::getExtension( _files[i] ); - - // filter files without existing dfn - if (!NLMISC::CPath::exists(QString("%1.dfn").arg(extStr.c_str()).toStdString()) && - !NLMISC::CPath::exists(QString("%1.typ").arg(extStr.c_str()).toStdString())) - { - continue; - } - _filelist.append(QString(NLMISC::CFile::getFilename(_files[i]).c_str())); - } - - _ui.parentFrame->hide(); - - // replace "Heading" and "Descriptive Text" with your string - _descriptionTemplate = - "" - "\n" - "" - "" - "\n

" - "Heading

" - "\n

" - "Descriptive Text

"; - } - - CGeorgesNewDialog::~CGeorgesNewDialog() - { - - } - - void CGeorgesNewDialog::wizardBtnClicked(bool p_checked) - { - if(p_checked) - _ui.stackedWidget->setCurrentWidget(_ui.wizardPage); - else - _ui.wizardBtn->setChecked(true); - } - - void CGeorgesNewDialog::formBtnClicked(bool p_checked) - { - if(p_checked) - _ui.stackedWidget->setCurrentWidget(_ui.formPage); - else - _ui.formBtn->setChecked(true); - } - - void CGeorgesNewDialog::dfnTypeClicked(bool p_checked) - { - if(p_checked) - _ui.stackedWidget->setCurrentWidget(_ui.dfnTypePage); - else - _ui.dfnTypeBtn->setChecked(true); - } - - void CGeorgesNewDialog::addParentClicked() - { - if (!_filelist.contains(_ui.parentLineEdit->text())) - { - _ui.parentLineEdit->clear(); - return; - } - - _ui.parentFrame->show(); - - QList itemList = _ui.parentList-> - findItems(_ui.parentLineEdit->text(), Qt::MatchFixedString); - if ((itemList.count() == 0) && (!_ui.parentLineEdit->text().isEmpty())) - { - _ui.parentList->insertItem(_ui.parentList->count(), _ui.parentLineEdit->text()); - } - _ui.parentLineEdit->clear(); - } - - void CGeorgesNewDialog::deleteParentClicked() - { - _ui.parentList->takeItem(_ui.parentList->currentRow()); - - if (_ui.parentList->count() == 0) - { - _ui.parentFrame->hide(); - } - } - - void CGeorgesNewDialog::buttonBoxAccepted() - { - if (_ui.stackedWidget->currentWidget() == _ui.formPage) - { - _result << _ui.formFileNameEdit->text(); - for (int i = 0; i < _ui.parentList->count(); i++) - { - _result << _ui.parentList->item(i)->text(); - } - } - else - { - QMessageBox::information(this,"Information","Not yet included.\nSoon to come! :)"); - } - } - - void CGeorgesNewDialog::buttonBoxRejected() - { - // TODO - } - - void CGeorgesNewDialog::formItemActivated(QListWidgetItem *item) - { - _ui.formFileNameEdit->setText(QString(tr("newfile.%1").arg(item->text()))); - _ui.parentLineEdit->setEnabled(true); - _ui.parentLineEdit->setText(""); - //_ui.addParentButton->setEnabled(false); - - QStringList list = _filelist.filter(item->text()); - _ui.parentLineEdit->setStringList(list); - _ui.formFileNameEdit->setFocus(); - _ui.formFileNameEdit->setSelection(0, tr("newfile").size()); - } - - void CGeorgesNewDialog::wizardItemActivated(QListWidgetItem *item) - { - QString myDescription = _descriptionTemplate; - myDescription = myDescription.replace("Heading", item->text()); - - if (item->text() == tr("Raw Material Generator")) - { - myDescription = myDescription.replace("Descriptive Text", - tr("Automatically creates MP (resources) for every creature in the assets.")); - } - - _ui.wizDescLabel->setText(myDescription); - } - - void CGeorgesNewDialog::getTypes( /* std::string& dir // not needed anymore? */ ) - { - //nlinfo ("Found %d files in directory '%s'", files.size(), dir.c_str()); - for(uint i = 0; i < _files.size(); i++) - { - addType(NLMISC::CFile::getFilename(_files[i])); - QApplication::processEvents(); - } - } - - void CGeorgesNewDialog::addType( std::string fileName ) - { - if(fileName.empty() || fileName=="." || fileName==".." || fileName[0]=='_' || fileName.find(".#")==0) - { - //nlinfo("Discarding file '%s'", fileName.c_str()); - return; - } - else - { - std::string extStr = NLMISC::CFile::getExtension( fileName ); - - if (!NLMISC::CPath::exists(QString("%1.dfn").arg(extStr.c_str()).toStdString())) - { - return; - } - } - - // if the file is new - std::map::iterator itFI = FormToId.find( fileName ); - if( itFI == FormToId.end() ) - { - // double check : if file not found we check with lower case version of filename - std::map::iterator itFILwr = FormToId.find( NLMISC::toLower(fileName) ); - if( itFILwr != FormToId.end() ) - { - nlwarning("Trying to add %s but the file %s is already known ! be careful with lower case and upper case.", fileName.c_str(), NLMISC::toLower(fileName).c_str()); - return; - } - - std::string fileType; - if( getFileType( fileName, fileType ) ) - { - std::map::iterator itFTI = FileTypeToId.find( fileType ); - TFormId fid; - memset( &fid, 0, sizeof(TFormId) ); - - // if the type of this file is a new type - if( itFTI == FileTypeToId.end() ) - { - sint16 firstFreeFileTypeId = getFirstFreeFileTypeId(); - if( firstFreeFileTypeId == -1 ) - { - nlwarning("MORE THAN 256 FILE TYPES!!!!"); - } - else - { - FileTypeToId.insert( std::make_pair(fileType,(uint8)firstFreeFileTypeId) ); - IdToFileType.insert( std::make_pair((uint8)firstFreeFileTypeId,fileType) ); - - fid.FormIDInfos.Type = (uint8)firstFreeFileTypeId; - fid.FormIDInfos.Id = 0; - - //nlinfo("Adding file type '%s' with id %d", fileType.c_str(), firstFreeFileTypeId); - } - } - else - { - return; - } - FormToId.insert( make_pair(fileName,fid) ); - //nlinfo("Adding file '%s' id %d with type '%s' id %d", fileName.c_str(), fid.FormIDInfos.Id, fileType.c_str(), fid.FormIDInfos.Type); - } - else - { - nlinfo("Unknown file type for the file : '%s' --> not added",fileName.c_str()); - } - } - else - { - nlinfo("Skipping file '%s', already in the file", fileName.c_str()); - } - } - - bool CGeorgesNewDialog::getFileType( std::string& fileName, std::string& fileType ) - { - fileType = NLMISC::CFile::getExtension(NLMISC::CFile::getFilename(fileName)); - return !fileType.empty(); - } - - sint16 CGeorgesNewDialog::getFirstFreeFileTypeId() - { - for( sint16 id=0; id<256; ++id ) - { - if( IdToFileType.find((uint8)id) == IdToFileType.end() ) - { - return id; - } - } - return -1; - } - - void CGeorgesNewDialog::validateParentCombo() { - // TODO: clear if no valid text - //if (!_filelist.contains(_ui.parentLineEdit->text())) - // _ui.parentLineEdit->clear(); - } +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +*/ + +#include "new_dialog.h" + +// Qt includes +#include +#include +#include +#include +#include + +#include + +// NeL includes +#include + +// Project includes +#include "modules.h" +#include "completer_line_edit.h" + +namespace NLQT +{ + + CGeorgesNewDialog::CGeorgesNewDialog(QStringList& result, QWidget *parent) + : QDialog(parent), + _result(result), + _descriptionTemplate(QString()) + { + _ui.setupUi(this); + + setWindowIcon(QIcon(":/images/georges_logo.png")); + + _ui.parentLineEdit->setEnabled(false); + _ui.addParentButton->setEnabled(true); + + // wizard page + connect(_ui.wizardBtn, SIGNAL(clicked(bool)), + this, SLOT(wizardBtnClicked(bool))); + connect(_ui.wizardList, SIGNAL(itemClicked(QListWidgetItem*)), + this, SLOT(wizardItemActivated(QListWidgetItem *))); + + // form page + connect(_ui.formBtn, SIGNAL(clicked(bool)), + this, SLOT(formBtnClicked(bool))); + connect(_ui.addParentButton, SIGNAL(clicked()), + this, SLOT(addParentClicked())); + connect(_ui.deleteParentButton, SIGNAL(clicked()), + this, SLOT(deleteParentClicked())); + connect(_ui.formList, SIGNAL(itemActivated(QListWidgetItem*)), + this, SLOT(formItemActivated(QListWidgetItem *))); + connect(_ui.formList, SIGNAL(itemClicked(QListWidgetItem*)), + this, SLOT(formItemActivated(QListWidgetItem *))); + connect(_ui.parentLineEdit, SIGNAL(editingFinished()), + this, SLOT(validateParentCombo())); + + // dfn page + connect(_ui.dfnTypeBtn, SIGNAL(clicked(bool)), + this, SLOT(dfnTypeClicked(bool))); + + connect(_ui.buttonBox, SIGNAL(accepted()), + this, SLOT(buttonBoxAccepted())); + connect(_ui.buttonBox, SIGNAL(rejected()), + this, SLOT(buttonBoxRejected())); + + // wizard list + QListWidgetItem *mpWiz = new QListWidgetItem(QIcon(":/images/mp_generic.png"),tr("Raw Material Generator")); + _ui.wizardList->addItem(mpWiz); + + // form list + QString path = Modules::mainWin().leveldesignPath(); + QStringList typelist; + //nlinfo ("Searching files in directory '%s'...", dir.c_str()); + NLMISC::CPath::getPathContent(path.toStdString(),true,false,true,_files); + + getTypes( /* path.toStdString() // incompatible parameter type */ ); + //nlinfo ("%d supported file types :",FileTypeToId.size()); + for ( std::map::iterator it = FileTypeToId.begin(); it != FileTypeToId.end(); ++it ) + { + typelist.append(QString((*it).first.c_str())); + //nlinfo("%s",(*it).first.c_str()); + } + _ui.formList->addItems(typelist); + + for(uint i = 0; i < _files.size(); i++) + { + std::string extStr = NLMISC::CFile::getExtension( _files[i] ); + + // filter files without existing dfn + if (!NLMISC::CPath::exists(QString("%1.dfn").arg(extStr.c_str()).toStdString()) && + !NLMISC::CPath::exists(QString("%1.typ").arg(extStr.c_str()).toStdString())) + { + continue; + } + _filelist.append(QString(NLMISC::CFile::getFilename(_files[i]).c_str())); + } + + _ui.parentFrame->hide(); + + // replace "Heading" and "Descriptive Text" with your string + _descriptionTemplate = + "" + "\n" + "" + "" + "\n

" + "Heading

" + "\n

" + "Descriptive Text

"; + } + + CGeorgesNewDialog::~CGeorgesNewDialog() + { + + } + + void CGeorgesNewDialog::wizardBtnClicked(bool p_checked) + { + if(p_checked) + _ui.stackedWidget->setCurrentWidget(_ui.wizardPage); + else + _ui.wizardBtn->setChecked(true); + } + + void CGeorgesNewDialog::formBtnClicked(bool p_checked) + { + if(p_checked) + _ui.stackedWidget->setCurrentWidget(_ui.formPage); + else + _ui.formBtn->setChecked(true); + } + + void CGeorgesNewDialog::dfnTypeClicked(bool p_checked) + { + if(p_checked) + _ui.stackedWidget->setCurrentWidget(_ui.dfnTypePage); + else + _ui.dfnTypeBtn->setChecked(true); + } + + void CGeorgesNewDialog::addParentClicked() + { + if (!_filelist.contains(_ui.parentLineEdit->text())) + { + _ui.parentLineEdit->clear(); + return; + } + + _ui.parentFrame->show(); + + QList itemList = _ui.parentList-> + findItems(_ui.parentLineEdit->text(), Qt::MatchFixedString); + if ((itemList.count() == 0) && (!_ui.parentLineEdit->text().isEmpty())) + { + _ui.parentList->insertItem(_ui.parentList->count(), _ui.parentLineEdit->text()); + } + _ui.parentLineEdit->clear(); + } + + void CGeorgesNewDialog::deleteParentClicked() + { + _ui.parentList->takeItem(_ui.parentList->currentRow()); + + if (_ui.parentList->count() == 0) + { + _ui.parentFrame->hide(); + } + } + + void CGeorgesNewDialog::buttonBoxAccepted() + { + if (_ui.stackedWidget->currentWidget() == _ui.formPage) + { + _result << _ui.formFileNameEdit->text(); + for (int i = 0; i < _ui.parentList->count(); i++) + { + _result << _ui.parentList->item(i)->text(); + } + } + else + { + QMessageBox::information(this,"Information","Not yet included.\nSoon to come! :)"); + } + } + + void CGeorgesNewDialog::buttonBoxRejected() + { + // TODO + } + + void CGeorgesNewDialog::formItemActivated(QListWidgetItem *item) + { + _ui.formFileNameEdit->setText(QString(tr("newfile.%1").arg(item->text()))); + _ui.parentLineEdit->setEnabled(true); + _ui.parentLineEdit->setText(""); + //_ui.addParentButton->setEnabled(false); + + QStringList list = _filelist.filter(item->text()); + _ui.parentLineEdit->setStringList(list); + _ui.formFileNameEdit->setFocus(); + _ui.formFileNameEdit->setSelection(0, tr("newfile").size()); + } + + void CGeorgesNewDialog::wizardItemActivated(QListWidgetItem *item) + { + QString myDescription = _descriptionTemplate; + myDescription = myDescription.replace("Heading", item->text()); + + if (item->text() == tr("Raw Material Generator")) + { + myDescription = myDescription.replace("Descriptive Text", + tr("Automatically creates MP (resources) for every creature in the assets.")); + } + + _ui.wizDescLabel->setText(myDescription); + } + + void CGeorgesNewDialog::getTypes( /* std::string& dir // not needed anymore? */ ) + { + //nlinfo ("Found %d files in directory '%s'", files.size(), dir.c_str()); + for(uint i = 0; i < _files.size(); i++) + { + addType(NLMISC::CFile::getFilename(_files[i])); + QApplication::processEvents(); + } + } + + void CGeorgesNewDialog::addType( std::string fileName ) + { + if(fileName.empty() || fileName=="." || fileName==".." || fileName[0]=='_' || fileName.find(".#")==0) + { + //nlinfo("Discarding file '%s'", fileName.c_str()); + return; + } + else + { + std::string extStr = NLMISC::CFile::getExtension( fileName ); + + if (!NLMISC::CPath::exists(QString("%1.dfn").arg(extStr.c_str()).toStdString())) + { + return; + } + } + + // if the file is new + std::map::iterator itFI = FormToId.find( fileName ); + if( itFI == FormToId.end() ) + { + // double check : if file not found we check with lower case version of filename + std::map::iterator itFILwr = FormToId.find( NLMISC::toLower(fileName) ); + if( itFILwr != FormToId.end() ) + { + nlwarning("Trying to add %s but the file %s is already known ! be careful with lower case and upper case.", fileName.c_str(), NLMISC::toLower(fileName).c_str()); + return; + } + + std::string fileType; + if( getFileType( fileName, fileType ) ) + { + std::map::iterator itFTI = FileTypeToId.find( fileType ); + TFormId fid; + memset( &fid, 0, sizeof(TFormId) ); + + // if the type of this file is a new type + if( itFTI == FileTypeToId.end() ) + { + sint16 firstFreeFileTypeId = getFirstFreeFileTypeId(); + if( firstFreeFileTypeId == -1 ) + { + nlwarning("MORE THAN 256 FILE TYPES!!!!"); + } + else + { + FileTypeToId.insert( std::make_pair(fileType,(uint8)firstFreeFileTypeId) ); + IdToFileType.insert( std::make_pair((uint8)firstFreeFileTypeId,fileType) ); + + fid.FormIDInfos.Type = (uint8)firstFreeFileTypeId; + fid.FormIDInfos.Id = 0; + + //nlinfo("Adding file type '%s' with id %d", fileType.c_str(), firstFreeFileTypeId); + } + } + else + { + return; + } + FormToId.insert( make_pair(fileName,fid) ); + //nlinfo("Adding file '%s' id %d with type '%s' id %d", fileName.c_str(), fid.FormIDInfos.Id, fileType.c_str(), fid.FormIDInfos.Type); + } + else + { + nlinfo("Unknown file type for the file : '%s' --> not added",fileName.c_str()); + } + } + else + { + nlinfo("Skipping file '%s', already in the file", fileName.c_str()); + } + } + + bool CGeorgesNewDialog::getFileType( std::string& fileName, std::string& fileType ) + { + fileType = NLMISC::CFile::getExtension(NLMISC::CFile::getFilename(fileName)); + return !fileType.empty(); + } + + sint16 CGeorgesNewDialog::getFirstFreeFileTypeId() + { + for( sint16 id=0; id<256; ++id ) + { + if( IdToFileType.find((uint8)id) == IdToFileType.end() ) + { + return id; + } + } + return -1; + } + + void CGeorgesNewDialog::validateParentCombo() { + // TODO: clear if no valid text + //if (!_filelist.contains(_ui.parentLineEdit->text())) + // _ui.parentLineEdit->clear(); + } } /* namespace NLQT */ \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/new_dialog.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/new_dialog.h index 04cf2a6b0..b15459515 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/new_dialog.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/new_dialog.h @@ -1,88 +1,88 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#ifndef NEW_DIALOG_H -#define NEW_DIALOG_H - -// Qt includes -#include - -// STL includes - -// NeL includes -#include -#include - -// Project includes -#include "ui_new_form.h" - -namespace NLQT -{ - class CGeorgesNewDialog: public QDialog - { - Q_OBJECT - - union TFormId - { - uint32 Id; - struct - { - uint32 Type : 8; - uint32 Id : 24; - } FormIDInfos; - void serial(NLMISC::IStream &f) { f.serial(Id); }; - }; - - Ui::CGeorgesNewDialog _ui; - QStringList _filelist; - QStringList &_result; - QString _descriptionTemplate; - - std::map FormToId; - std::map FileTypeToId; - std::map IdToFileType; - - std::vector _files; - - void getTypes( /* std::string& dir // not needed anymore? */ ); - void addType( std::string fileName ); - bool getFileType( std::string& fileName, std::string& fileType ); - sint16 getFirstFreeFileTypeId(); - - public: - CGeorgesNewDialog(QStringList& result, QWidget *parent = 0); - ~CGeorgesNewDialog(); - - private Q_SLOTS: - void wizardBtnClicked(bool checked); - void formBtnClicked (bool checked); - void dfnTypeClicked (bool p_checked); - void addParentClicked(); - void deleteParentClicked(); - void formItemActivated(QListWidgetItem *); - void wizardItemActivated(QListWidgetItem *); - void validateParentCombo(); - void buttonBoxAccepted(); - void buttonBoxRejected(); - - friend class CMainWindow; - }; /* CGeorgesNewDialog */ - -} /* namespace NLQT */ - -#endif // NEW_DIALOG_H +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef NEW_DIALOG_H +#define NEW_DIALOG_H + +// Qt includes +#include + +// STL includes + +// NeL includes +#include +#include + +// Project includes +#include "ui_new_form.h" + +namespace NLQT +{ + class CGeorgesNewDialog: public QDialog + { + Q_OBJECT + + union TFormId + { + uint32 Id; + struct + { + uint32 Type : 8; + uint32 Id : 24; + } FormIDInfos; + void serial(NLMISC::IStream &f) { f.serial(Id); }; + }; + + Ui::CGeorgesNewDialog _ui; + QStringList _filelist; + QStringList &_result; + QString _descriptionTemplate; + + std::map FormToId; + std::map FileTypeToId; + std::map IdToFileType; + + std::vector _files; + + void getTypes( /* std::string& dir // not needed anymore? */ ); + void addType( std::string fileName ); + bool getFileType( std::string& fileName, std::string& fileType ); + sint16 getFirstFreeFileTypeId(); + + public: + CGeorgesNewDialog(QStringList& result, QWidget *parent = 0); + ~CGeorgesNewDialog(); + + private Q_SLOTS: + void wizardBtnClicked(bool checked); + void formBtnClicked (bool checked); + void dfnTypeClicked (bool p_checked); + void addParentClicked(); + void deleteParentClicked(); + void formItemActivated(QListWidgetItem *); + void wizardItemActivated(QListWidgetItem *); + void validateParentCombo(); + void buttonBoxAccepted(); + void buttonBoxRejected(); + + friend class CMainWindow; + }; /* CGeorgesNewDialog */ + +} /* namespace NLQT */ + +#endif // NEW_DIALOG_H diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/objectviewer_dialog.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/objectviewer_dialog.cpp index ebe725b24..a47395cf6 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/objectviewer_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/objectviewer_dialog.cpp @@ -1,114 +1,114 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#include "objectviewer_dialog.h" - -// Qt includes -#include -#include -#include -#include -#include - -// NeL includes -#include -#include - -#include -#include - -// Project includes -#include "modules.h" - -using namespace std; -using namespace NL3D; - -namespace NLQT -{ - - CObjectViewerDialog::CObjectViewerDialog(QWidget *parent) :QDockWidget(parent), - _nlw(0) - { - _ui.setupUi(this); - - if (Modules::objViewInt()) - { - _nlw = dynamic_cast(Modules::objViewInt()->getWidget()); - //_nlw->setObjectName(QString::fromUtf8("nlwidget")); - _ui.gridLayout->addWidget(_nlw, 0, 0); - } - } - - CObjectViewerDialog::~CObjectViewerDialog() - { - } - - void CObjectViewerDialog::setVisible(bool visible) - { - // called by show() - // code assuming visible window needed to init the 3d driver - nldebug("%d", visible); - if (visible) - { - QDockWidget::setVisible(true); - //_mainTimer->start(25); - //updateInitialization(true); - //_nlw->show(); - } - else - { - //updateInitialization(false); - QDockWidget::setVisible(false); - } - } - - void CObjectViewerDialog::topLevelChanged ( bool topLevel ) { - //nldebug("topLevel:%d",topLevel); - //_georges->init(); - } - - QAction *CObjectViewerDialog::createSaveScreenshotAction(QObject *parent) - { - QAction *action = new QAction(parent); - connect(action, SIGNAL(triggered()), _nlw, SLOT(saveScreenshot())); - return action; - } - - QAction *CObjectViewerDialog::createSetBackgroundColor(QObject *parent) - { - QAction *action = new QAction(parent); - connect(action, SIGNAL(triggered()), _nlw, SLOT(setBackgroundColor())); - return action; - } - - void CObjectViewerDialog::resizeEvent(QResizeEvent *resizeEvent) - { - //nldebug("%d %d",_nlw->width(), _nlw->height()); - QDockWidget::resizeEvent(resizeEvent); - if (Modules::objViewInt()) { - if (Modules::objViewInt()->getDriver()) - Modules::objViewInt()->setSizeViewport(resizeEvent->size().width(), resizeEvent->size().height()); - } - // The OpenGL driver does not resize automatically. - // The Direct3D driver breaks the window mode to include window borders when calling setMode windowed. - - // Resizing the window after switching drivers a few times becomes slow. - // There is probably something inside the drivers not being released properly. - } - -} /* namespace NLQT */ +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "objectviewer_dialog.h" + +// Qt includes +#include +#include +#include +#include +#include + +// NeL includes +#include +#include + +#include +#include + +// Project includes +#include "modules.h" + +using namespace std; +using namespace NL3D; + +namespace NLQT +{ + + CObjectViewerDialog::CObjectViewerDialog(QWidget *parent) :QDockWidget(parent), + _nlw(0) + { + _ui.setupUi(this); + + if (Modules::objViewInt()) + { + _nlw = dynamic_cast(Modules::objViewInt()->getWidget()); + //_nlw->setObjectName(QString::fromUtf8("nlwidget")); + _ui.gridLayout->addWidget(_nlw, 0, 0); + } + } + + CObjectViewerDialog::~CObjectViewerDialog() + { + } + + void CObjectViewerDialog::setVisible(bool visible) + { + // called by show() + // code assuming visible window needed to init the 3d driver + nldebug("%d", visible); + if (visible) + { + QDockWidget::setVisible(true); + //_mainTimer->start(25); + //updateInitialization(true); + //_nlw->show(); + } + else + { + //updateInitialization(false); + QDockWidget::setVisible(false); + } + } + + void CObjectViewerDialog::topLevelChanged ( bool topLevel ) { + //nldebug("topLevel:%d",topLevel); + //_georges->init(); + } + + QAction *CObjectViewerDialog::createSaveScreenshotAction(QObject *parent) + { + QAction *action = new QAction(parent); + connect(action, SIGNAL(triggered()), _nlw, SLOT(saveScreenshot())); + return action; + } + + QAction *CObjectViewerDialog::createSetBackgroundColor(QObject *parent) + { + QAction *action = new QAction(parent); + connect(action, SIGNAL(triggered()), _nlw, SLOT(setBackgroundColor())); + return action; + } + + void CObjectViewerDialog::resizeEvent(QResizeEvent *resizeEvent) + { + //nldebug("%d %d",_nlw->width(), _nlw->height()); + QDockWidget::resizeEvent(resizeEvent); + if (Modules::objViewInt()) { + if (Modules::objViewInt()->getDriver()) + Modules::objViewInt()->setSizeViewport(resizeEvent->size().width(), resizeEvent->size().height()); + } + // The OpenGL driver does not resize automatically. + // The Direct3D driver breaks the window mode to include window borders when calling setMode windowed. + + // Resizing the window after switching drivers a few times becomes slow. + // There is probably something inside the drivers not being released properly. + } + +} /* namespace NLQT */ diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/objectviewer_dialog.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/objectviewer_dialog.h index f890eaca2..5bb699f5a 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/objectviewer_dialog.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/objectviewer_dialog.h @@ -1,84 +1,84 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#ifndef OBJECTVIEWER_DIALOG_H -#define OBJECTVIEWER_DIALOG_H - -#include -#include - -#include "ui_objectviewer_form.h" - -// Qt includes -#include -#include -#include - -// STL includes - -// NeL includes -#include - -// Project includes - -#ifdef NL_OS_WINDOWS -//typedef QDockWidget QNLWidget; -typedef QWidget QNLWidget; -#elif defined(NL_OS_MAC) -typedef QWidget QNLWidget; -#else // NL_OS_UNIX -typedef QGLWidget QNLWidget; -#endif // NL_OS_UNIX - -class QAction; - -namespace NLQT -{ - - class CObjectViewerDialog: public QDockWidget - { - Q_OBJECT - - public: - CObjectViewerDialog(QWidget *parent = 0); - ~CObjectViewerDialog(); - - virtual void setVisible(bool visible); - - QAction *createSaveScreenshotAction(QObject *parent); - QAction *createSetBackgroundColor(QObject *parent); - - private Q_SLOTS: - void topLevelChanged(bool topLevel); - - protected: - virtual void resizeEvent(QResizeEvent *resizeEvent); - - private: - CObjectViewerDialog(const CObjectViewerDialog &); - CObjectViewerDialog &operator=(const CObjectViewerDialog &); - - Ui::CObjectViewerDialog _ui; - QNLWidget * _nlw; - - friend class CMainWindow; - }; /* CObjectViewerDialog */ - -} /* namespace NLQT */ - -#endif // OBJECTVIEWER_DIALOG_H +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef OBJECTVIEWER_DIALOG_H +#define OBJECTVIEWER_DIALOG_H + +#include +#include + +#include "ui_objectviewer_form.h" + +// Qt includes +#include +#include +#include + +// STL includes + +// NeL includes +#include + +// Project includes + +#ifdef NL_OS_WINDOWS +//typedef QDockWidget QNLWidget; +typedef QWidget QNLWidget; +#elif defined(NL_OS_MAC) +typedef QWidget QNLWidget; +#else // NL_OS_UNIX +typedef QGLWidget QNLWidget; +#endif // NL_OS_UNIX + +class QAction; + +namespace NLQT +{ + + class CObjectViewerDialog: public QDockWidget + { + Q_OBJECT + + public: + CObjectViewerDialog(QWidget *parent = 0); + ~CObjectViewerDialog(); + + virtual void setVisible(bool visible); + + QAction *createSaveScreenshotAction(QObject *parent); + QAction *createSetBackgroundColor(QObject *parent); + + private Q_SLOTS: + void topLevelChanged(bool topLevel); + + protected: + virtual void resizeEvent(QResizeEvent *resizeEvent); + + private: + CObjectViewerDialog(const CObjectViewerDialog &); + CObjectViewerDialog &operator=(const CObjectViewerDialog &); + + Ui::CObjectViewerDialog _ui; + QNLWidget * _nlw; + + friend class CMainWindow; + }; /* CObjectViewerDialog */ + +} /* namespace NLQT */ + +#endif // OBJECTVIEWER_DIALOG_H diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/progress_dialog.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/progress_dialog.cpp index 6d98b9d97..026b4b79f 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/progress_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/progress_dialog.cpp @@ -1,66 +1,66 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -*/ - -#include "progress_dialog.h" - -// Qt includes -#include -#include -#include -#include -#include -// STL includes - -// NeL includes -#include -#include - -// Project includes - -namespace NLQT -{ - - CProgressDialog::CProgressDialog(QDialog *parent): QDialog(parent) - { - setWindowTitle(tr("Loading Data")); - QGridLayout* gridLayout = new QGridLayout(this); - gridLayout->setObjectName(QString::fromUtf8("gridLayout")); - _infoLabel = new QLabel("test",this); - _progressBar = new QProgressBar(this); - gridLayout->addWidget(_progressBar, 0, 0); - gridLayout->addWidget(_infoLabel, 1, 0); - resize(250, 100); - _progressBar->setMinimum(0); - _progressBar->setMaximum(100); - setWindowIcon(QIcon(":/images/georges_logo.png")); - } - - CProgressDialog::~CProgressDialog() - { - } - - void CProgressDialog::progress (float progressValue) - { - _infoLabel->setText(QString(tr("Adding Folder:\n%1")).arg(DisplayString.c_str())); - _progressBar->setValue(getCropedValue(progressValue) * 100); - QApplication::processEvents(); - } - -} /* namespace NLQT */ - +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +*/ + +#include "progress_dialog.h" + +// Qt includes +#include +#include +#include +#include +#include +// STL includes + +// NeL includes +#include +#include + +// Project includes + +namespace NLQT +{ + + CProgressDialog::CProgressDialog(QDialog *parent): QDialog(parent) + { + setWindowTitle(tr("Loading Data")); + QGridLayout* gridLayout = new QGridLayout(this); + gridLayout->setObjectName(QString::fromUtf8("gridLayout")); + _infoLabel = new QLabel("test",this); + _progressBar = new QProgressBar(this); + gridLayout->addWidget(_progressBar, 0, 0); + gridLayout->addWidget(_infoLabel, 1, 0); + resize(250, 100); + _progressBar->setMinimum(0); + _progressBar->setMaximum(100); + setWindowIcon(QIcon(":/images/georges_logo.png")); + } + + CProgressDialog::~CProgressDialog() + { + } + + void CProgressDialog::progress (float progressValue) + { + _infoLabel->setText(QString(tr("Adding Folder:\n%1")).arg(DisplayString.c_str())); + _progressBar->setValue(getCropedValue(progressValue) * 100); + QApplication::processEvents(); + } + +} /* namespace NLQT */ + diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/progress_dialog.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/progress_dialog.h index 83471f46c..0d3edeb2d 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/progress_dialog.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/progress_dialog.h @@ -1,59 +1,59 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -*/ - -#ifndef NLQT_PROGRESS_WIDGET_H -#define NLQT_PROGRESS_WIDGET_H - -// Qt includes -#include - -// STL includes - -// NeL includes -#include - -// Project includes - -namespace NLMISC { - class IProgressCallback; -} - -class QProgressBar; -class QLabel; - -namespace NLQT -{ - class CProgressDialog : public QDialog, public NLMISC::IProgressCallback - { - Q_OBJECT - - public: - CProgressDialog(QDialog *parent = 0); - ~CProgressDialog(); - - private: - void progress (float progressValue); - - QProgressBar* _progressBar; - QLabel* _infoLabel; - }; - -} /* namespace NLQT */ - +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +*/ + +#ifndef NLQT_PROGRESS_WIDGET_H +#define NLQT_PROGRESS_WIDGET_H + +// Qt includes +#include + +// STL includes + +// NeL includes +#include + +// Project includes + +namespace NLMISC { + class IProgressCallback; +} + +class QProgressBar; +class QLabel; + +namespace NLQT +{ + class CProgressDialog : public QDialog, public NLMISC::IProgressCallback + { + Q_OBJECT + + public: + CProgressDialog(QDialog *parent = 0); + ~CProgressDialog(); + + private: + void progress (float progressValue); + + QProgressBar* _progressBar; + QLabel* _infoLabel; + }; + +} /* namespace NLQT */ + #endif // NLQT_PROGRESS_WIDGET_H \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/qt_displayer.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/qt_displayer.cpp index 74b9a3805..07b338009 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/qt_displayer.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/qt_displayer.cpp @@ -1,127 +1,127 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -*/ - -// Nel includes - -#include "qt_displayer.h" -#include -#include -#include - -namespace NLQT -{ - - CQtDisplayer::CQtDisplayer(QPlainTextEdit *dlgDebug, bool eraseLastLog, const char *displayerName, bool raw) - : NLMISC::IDisplayer (displayerName), _NeedHeader(true), _LastLogSizeChecked(0), _Raw(raw) - { - setParam(dlgDebug,eraseLastLog); - } - - CQtDisplayer::CQtDisplayer() - : IDisplayer (""), _NeedHeader(true), _LastLogSizeChecked(0), _Raw(false) - { - ; - } - - CQtDisplayer::~CQtDisplayer() { - ; - } - - void CQtDisplayer::setParam (QPlainTextEdit *dlgDebug, bool eraseLastLog) - { - m_DlgDebug=dlgDebug; - //dlgDebug->dlgDbgText->WriteText("test"); - } - - void CQtDisplayer::doDisplay ( const NLMISC::CLog::TDisplayInfo& args, const char *message ) - { - bool needSpace = false; - std::string str; - - if(m_DlgDebug==NULL) - return; - - QTextCharFormat format; - - if (args.Date != 0 && !_Raw) { - str += dateToHumanString(args.Date); - needSpace = true; - } - - if (args.LogType != NLMISC::CLog::LOG_NO && !_Raw) - { - if (needSpace) { str += " "; needSpace = false; } - str += logTypeToString(args.LogType); - if (args.LogType == NLMISC::CLog::LOG_WARNING) - format.setForeground(QBrush(QColor("red"))); - else - format.setForeground(QBrush(QColor("black"))); - needSpace = true; - } - - // Write thread identifier - /*if ( args.ThreadId != 0 && !_Raw) { - if (needSpace) { str += " "; needSpace = false; } - str += NLMISC::toString(args.ThreadId); - needSpace = true; - }*/ - /*if (!args.ProcessName.empty() && !_Raw) { - if (needSpace) { str += " "; needSpace = false; } - str += args.ProcessName; - needSpace = true; - }*/ - - //if (args.FileName != NULL && !_Raw) { - // if (needSpace) { str += " "; needSpace = false; } - // str += NLMISC::CFile::getFilename(args.FileName); - // needSpace = true; - //} - - /*if (args.Line != -1 && !_Raw) { - if (needSpace) { str += " "; needSpace = false; } - str += NLMISC::toString(args.Line); - needSpace = true; - }*/ - - if (args.FuncName != NULL && !_Raw) - { - if (needSpace) - { - str += " "; needSpace = false; - } - str += args.FuncName; - needSpace = true; - } - - if (needSpace) - { - str += " : "; needSpace = false; - } - str += message; - - - - m_DlgDebug->textCursor().insertText(str.c_str(), format); - //m_DlgDebug->setCenterOnScroll(true); - m_DlgDebug->centerCursor(); - //m_DlgDebug->ensureCursorVisible(); - - } - +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +*/ + +// Nel includes + +#include "qt_displayer.h" +#include +#include +#include + +namespace NLQT +{ + + CQtDisplayer::CQtDisplayer(QPlainTextEdit *dlgDebug, bool eraseLastLog, const char *displayerName, bool raw) + : NLMISC::IDisplayer (displayerName), _NeedHeader(true), _LastLogSizeChecked(0), _Raw(raw) + { + setParam(dlgDebug,eraseLastLog); + } + + CQtDisplayer::CQtDisplayer() + : IDisplayer (""), _NeedHeader(true), _LastLogSizeChecked(0), _Raw(false) + { + ; + } + + CQtDisplayer::~CQtDisplayer() { + ; + } + + void CQtDisplayer::setParam (QPlainTextEdit *dlgDebug, bool eraseLastLog) + { + m_DlgDebug=dlgDebug; + //dlgDebug->dlgDbgText->WriteText("test"); + } + + void CQtDisplayer::doDisplay ( const NLMISC::CLog::TDisplayInfo& args, const char *message ) + { + bool needSpace = false; + std::string str; + + if(m_DlgDebug==NULL) + return; + + QTextCharFormat format; + + if (args.Date != 0 && !_Raw) { + str += dateToHumanString(args.Date); + needSpace = true; + } + + if (args.LogType != NLMISC::CLog::LOG_NO && !_Raw) + { + if (needSpace) { str += " "; needSpace = false; } + str += logTypeToString(args.LogType); + if (args.LogType == NLMISC::CLog::LOG_WARNING) + format.setForeground(QBrush(QColor("red"))); + else + format.setForeground(QBrush(QColor("black"))); + needSpace = true; + } + + // Write thread identifier + /*if ( args.ThreadId != 0 && !_Raw) { + if (needSpace) { str += " "; needSpace = false; } + str += NLMISC::toString(args.ThreadId); + needSpace = true; + }*/ + /*if (!args.ProcessName.empty() && !_Raw) { + if (needSpace) { str += " "; needSpace = false; } + str += args.ProcessName; + needSpace = true; + }*/ + + //if (args.FileName != NULL && !_Raw) { + // if (needSpace) { str += " "; needSpace = false; } + // str += NLMISC::CFile::getFilename(args.FileName); + // needSpace = true; + //} + + /*if (args.Line != -1 && !_Raw) { + if (needSpace) { str += " "; needSpace = false; } + str += NLMISC::toString(args.Line); + needSpace = true; + }*/ + + if (args.FuncName != NULL && !_Raw) + { + if (needSpace) + { + str += " "; needSpace = false; + } + str += args.FuncName; + needSpace = true; + } + + if (needSpace) + { + str += " : "; needSpace = false; + } + str += message; + + + + m_DlgDebug->textCursor().insertText(str.c_str(), format); + //m_DlgDebug->setCenterOnScroll(true); + m_DlgDebug->centerCursor(); + //m_DlgDebug->ensureCursorVisible(); + + } + } \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/qt_displayer.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/qt_displayer.h index 8aea6d22d..ec6cfcba2 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/qt_displayer.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/qt_displayer.h @@ -1,55 +1,55 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . - -*/ - - -#ifndef QTDISPLAYER_H -#define QTDISPLAYER_H - -// NeL includes -#include "modules.h" -#include - -// Qt includes -#include - -namespace NLQT -{ - - class CQtDisplayer : virtual public NLMISC::IDisplayer - { - - public: - CQtDisplayer(QPlainTextEdit *dlgDebug, bool eraseLastLog = false, const char *displayerName = "", bool raw = false); - CQtDisplayer(); - ~CQtDisplayer (); - void setParam (QPlainTextEdit *dlgDebug, bool eraseLastLog = false); - - protected: - virtual void doDisplay ( const NLMISC::CLog::TDisplayInfo& args, const char *message ); - - private: - QPlainTextEdit *m_DlgDebug; - bool _NeedHeader; - uint _LastLogSizeChecked; - bool _Raw; - };/* class CQtDisplayer */ - -} /* namespace NLQT */ - +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +*/ + + +#ifndef QTDISPLAYER_H +#define QTDISPLAYER_H + +// NeL includes +#include "modules.h" +#include + +// Qt includes +#include + +namespace NLQT +{ + + class CQtDisplayer : virtual public NLMISC::IDisplayer + { + + public: + CQtDisplayer(QPlainTextEdit *dlgDebug, bool eraseLastLog = false, const char *displayerName = "", bool raw = false); + CQtDisplayer(); + ~CQtDisplayer (); + void setParam (QPlainTextEdit *dlgDebug, bool eraseLastLog = false); + + protected: + virtual void doDisplay ( const NLMISC::CLog::TDisplayInfo& args, const char *message ); + + private: + QPlainTextEdit *m_DlgDebug; + bool _NeedHeader; + uint _LastLogSizeChecked; + bool _Raw; + };/* class CQtDisplayer */ + +} /* namespace NLQT */ + #endif //QTDISPLAYER_H \ No newline at end of file diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/settings_dialog.cpp b/code/ryzom/tools/leveldesign/georges_editor_qt/src/settings_dialog.cpp index a21629203..a005fdf5d 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/settings_dialog.cpp +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/settings_dialog.cpp @@ -1,208 +1,208 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#include "settings_dialog.h" - -// Qt includes -#include -#include -#include - -// NeL includes -#include - -// Project includes -#include "modules.h" - -using namespace NLMISC; - -namespace NLQT -{ - - CSettingsDialog::CSettingsDialog(QWidget *parent) - : QDialog(parent) - { - ui.setupUi(this); - - while (ui.driverGraphComboBox->count()) - ui.driverGraphComboBox->removeItem(0); - - // load types graphics driver from the config file - NLMISC::CConfigFile::CVar v = Modules::config().getConfigFile().getVar("GraphicsDrivers"); - for (uint i = 0; i < v.size(); ++i) - ui.driverGraphComboBox->addItem(v.asString(i).c_str()); - - // set graphics driver from the config file - QString value = Modules::config().getValue("GraphicsDriver",std::string("OpenGL")).c_str(); - QString dn = value.toLower(); - for (sint i = 0; i < ui.driverGraphComboBox->count(); ++i) - { - if (dn == ui.driverGraphComboBox->itemText(i).toLower()) - { - ui.driverGraphComboBox->setCurrentIndex(i); - } - } - - // load leveldesign path from the config file - NLMISC::CConfigFile::CVar v2 = Modules::config().getConfigFile().getVar("LeveldesignPath"); - ui.leveldesignPath->setText(v2.asString().c_str()); - - // load search paths from the config file - NLMISC::CConfigFile::CVar v3 = Modules::config().getConfigFile().getVar("SearchPaths"); - ui.pathsListWidget->clear(); - - for (uint i = 0; i < v3.size(); ++i) - { - ui.pathsListWidget->addItem(v3.asString(i).c_str()); - ui.pathsListWidget->item(i)->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); - } - - connect(ui.addToolButton, SIGNAL(clicked()), this, SLOT(addPath())); - connect(ui.removeToolButton, SIGNAL(clicked()), this, SLOT(removePath())); - connect(ui.upToolButton, SIGNAL(clicked()), this, SLOT(upPath())); - connect(ui.downToolButton, SIGNAL(clicked()), this, SLOT(downPath())); - connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(applyPressed())); - - connect(ui.browseLdPath, SIGNAL(clicked()), this, SLOT(browseLeveldesignPath())); - -#ifdef NL_OS_UNIX - ui.driverGraphComboBox->setEnabled(false); -#endif - - } - - CSettingsDialog::~CSettingsDialog() - { - } - - void CSettingsDialog::addPath() - { - QListWidgetItem *newItem = new QListWidgetItem; - QFileDialog dialog(this); - dialog.setOption(QFileDialog::ShowDirsOnly, true); - dialog.setFileMode(QFileDialog::Directory); - if (dialog.exec()) - { - QString newPath = dialog.selectedFiles().first(); - if (!newPath.isEmpty()) - { - newItem->setText(newPath); - newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); - ui.pathsListWidget->addItem(newItem); - } - } - } - - void CSettingsDialog::removePath() - { - QListWidgetItem *removeItem = ui.pathsListWidget->takeItem(ui.pathsListWidget->currentRow()); - if (!removeItem) delete removeItem; - } - - void CSettingsDialog::upPath() - { - sint currentRow = ui.pathsListWidget->currentRow(); - if (!(currentRow == 0)) - { - QListWidgetItem *item = ui.pathsListWidget->takeItem(currentRow); - ui.pathsListWidget->insertItem(--currentRow, item); - ui.pathsListWidget->setCurrentRow(currentRow); - } - } - - void CSettingsDialog::downPath() - { - sint currentRow = ui.pathsListWidget->currentRow(); - if (!(currentRow == ui.pathsListWidget->count()-1)) - { - QListWidgetItem *item = ui.pathsListWidget->takeItem(currentRow); - ui.pathsListWidget->insertItem(++currentRow, item); - ui.pathsListWidget->setCurrentRow(currentRow); - } - } - - void CSettingsDialog::applyPressed() - { - - // settings take after restart the program - /*QMessageBox::warning(this, tr("Settings"), - tr("Graphics and sound settings " - "take after restart the program"), - QMessageBox::Ok);*/ - - // save graphics settings to config file - Modules::config().getConfigFile().getVar("GraphicsDriver").setAsString(ui.driverGraphComboBox->currentText().toStdString()); - - // save leveldesign path to config file - QString oldLdPath = Modules::config().getValue("LeveldesignPath", std::string("")).c_str(); - if (oldLdPath != ui.leveldesignPath->text()) - { - std::string ldPath = ui.leveldesignPath->text().toStdString(); - Modules::config().getConfigFile().getVar("LeveldesignPath").forceAsString(ldPath); - Q_EMIT ldPathChanged(ldPath.c_str()); - // TODO: remove old Path from CPath - Modules::config().addLeveldesignPath(); - } - - // save search paths to config file - NLMISC::CConfigFile::CVar v = Modules::config().getConfigFile().getVar("SearchPaths"); - QStringList sl; - for (uint i = 0; i < v.size(); ++i) - { - sl.append(v.asString(i).c_str()); - } - - std::vector list; - std::vector addList; - for (sint i = 0; i < ui.pathsListWidget->count(); ++i) - { - std::string str = ui.pathsListWidget->item(i)->text().toStdString(); - if (str != "") - { - list.push_back(str); - if (!sl.contains(str.c_str())) - { - addList.push_back(str); - } - } - } - - if (list.empty()) - { - Modules::config().getConfigFile().getVar("SearchPaths").forceAsString(""); - } - else - { - Modules::config().getConfigFile().getVar("SearchPaths").forceAsString(""); - Modules::config().getConfigFile().getVar("SearchPaths").setAsString(list); - } - - // save config file - Modules::config().getConfigFile().save(); - - // reload search paths - Modules::config().addSearchPaths(&addList); - } - - void CSettingsDialog::browseLeveldesignPath() - { - ui.leveldesignPath->setText(QFileDialog::getExistingDirectory(this, tr("Open Directory"), - QDir::currentPath(), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks)); - } - -} /* namespace NLQT */ +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "settings_dialog.h" + +// Qt includes +#include +#include +#include + +// NeL includes +#include + +// Project includes +#include "modules.h" + +using namespace NLMISC; + +namespace NLQT +{ + + CSettingsDialog::CSettingsDialog(QWidget *parent) + : QDialog(parent) + { + ui.setupUi(this); + + while (ui.driverGraphComboBox->count()) + ui.driverGraphComboBox->removeItem(0); + + // load types graphics driver from the config file + NLMISC::CConfigFile::CVar v = Modules::config().getConfigFile().getVar("GraphicsDrivers"); + for (uint i = 0; i < v.size(); ++i) + ui.driverGraphComboBox->addItem(v.asString(i).c_str()); + + // set graphics driver from the config file + QString value = Modules::config().getValue("GraphicsDriver",std::string("OpenGL")).c_str(); + QString dn = value.toLower(); + for (sint i = 0; i < ui.driverGraphComboBox->count(); ++i) + { + if (dn == ui.driverGraphComboBox->itemText(i).toLower()) + { + ui.driverGraphComboBox->setCurrentIndex(i); + } + } + + // load leveldesign path from the config file + NLMISC::CConfigFile::CVar v2 = Modules::config().getConfigFile().getVar("LeveldesignPath"); + ui.leveldesignPath->setText(v2.asString().c_str()); + + // load search paths from the config file + NLMISC::CConfigFile::CVar v3 = Modules::config().getConfigFile().getVar("SearchPaths"); + ui.pathsListWidget->clear(); + + for (uint i = 0; i < v3.size(); ++i) + { + ui.pathsListWidget->addItem(v3.asString(i).c_str()); + ui.pathsListWidget->item(i)->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); + } + + connect(ui.addToolButton, SIGNAL(clicked()), this, SLOT(addPath())); + connect(ui.removeToolButton, SIGNAL(clicked()), this, SLOT(removePath())); + connect(ui.upToolButton, SIGNAL(clicked()), this, SLOT(upPath())); + connect(ui.downToolButton, SIGNAL(clicked()), this, SLOT(downPath())); + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(applyPressed())); + + connect(ui.browseLdPath, SIGNAL(clicked()), this, SLOT(browseLeveldesignPath())); + +#ifdef NL_OS_UNIX + ui.driverGraphComboBox->setEnabled(false); +#endif + + } + + CSettingsDialog::~CSettingsDialog() + { + } + + void CSettingsDialog::addPath() + { + QListWidgetItem *newItem = new QListWidgetItem; + QFileDialog dialog(this); + dialog.setOption(QFileDialog::ShowDirsOnly, true); + dialog.setFileMode(QFileDialog::Directory); + if (dialog.exec()) + { + QString newPath = dialog.selectedFiles().first(); + if (!newPath.isEmpty()) + { + newItem->setText(newPath); + newItem->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable); + ui.pathsListWidget->addItem(newItem); + } + } + } + + void CSettingsDialog::removePath() + { + QListWidgetItem *removeItem = ui.pathsListWidget->takeItem(ui.pathsListWidget->currentRow()); + if (!removeItem) delete removeItem; + } + + void CSettingsDialog::upPath() + { + sint currentRow = ui.pathsListWidget->currentRow(); + if (!(currentRow == 0)) + { + QListWidgetItem *item = ui.pathsListWidget->takeItem(currentRow); + ui.pathsListWidget->insertItem(--currentRow, item); + ui.pathsListWidget->setCurrentRow(currentRow); + } + } + + void CSettingsDialog::downPath() + { + sint currentRow = ui.pathsListWidget->currentRow(); + if (!(currentRow == ui.pathsListWidget->count()-1)) + { + QListWidgetItem *item = ui.pathsListWidget->takeItem(currentRow); + ui.pathsListWidget->insertItem(++currentRow, item); + ui.pathsListWidget->setCurrentRow(currentRow); + } + } + + void CSettingsDialog::applyPressed() + { + + // settings take after restart the program + /*QMessageBox::warning(this, tr("Settings"), + tr("Graphics and sound settings " + "take after restart the program"), + QMessageBox::Ok);*/ + + // save graphics settings to config file + Modules::config().getConfigFile().getVar("GraphicsDriver").setAsString(ui.driverGraphComboBox->currentText().toStdString()); + + // save leveldesign path to config file + QString oldLdPath = Modules::config().getValue("LeveldesignPath", std::string("")).c_str(); + if (oldLdPath != ui.leveldesignPath->text()) + { + std::string ldPath = ui.leveldesignPath->text().toStdString(); + Modules::config().getConfigFile().getVar("LeveldesignPath").forceAsString(ldPath); + Q_EMIT ldPathChanged(ldPath.c_str()); + // TODO: remove old Path from CPath + Modules::config().addLeveldesignPath(); + } + + // save search paths to config file + NLMISC::CConfigFile::CVar v = Modules::config().getConfigFile().getVar("SearchPaths"); + QStringList sl; + for (uint i = 0; i < v.size(); ++i) + { + sl.append(v.asString(i).c_str()); + } + + std::vector list; + std::vector addList; + for (sint i = 0; i < ui.pathsListWidget->count(); ++i) + { + std::string str = ui.pathsListWidget->item(i)->text().toStdString(); + if (str != "") + { + list.push_back(str); + if (!sl.contains(str.c_str())) + { + addList.push_back(str); + } + } + } + + if (list.empty()) + { + Modules::config().getConfigFile().getVar("SearchPaths").forceAsString(""); + } + else + { + Modules::config().getConfigFile().getVar("SearchPaths").forceAsString(""); + Modules::config().getConfigFile().getVar("SearchPaths").setAsString(list); + } + + // save config file + Modules::config().getConfigFile().save(); + + // reload search paths + Modules::config().addSearchPaths(&addList); + } + + void CSettingsDialog::browseLeveldesignPath() + { + ui.leveldesignPath->setText(QFileDialog::getExistingDirectory(this, tr("Open Directory"), + QDir::currentPath(), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks)); + } + +} /* namespace NLQT */ diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/settings_dialog.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/settings_dialog.h index f0fba77b2..2e2124b0f 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/settings_dialog.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/settings_dialog.h @@ -1,62 +1,62 @@ -/* -Georges Editor Qt -Copyright (C) 2010 Adrian Jaekel - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#ifndef SETTINGS_DIALOG_H -#define SETTINGS_DIALOG_H - -#include -#include "ui_settings_form.h" - -// STL includes - -// NeL includes -#include - -// Project includes - -namespace NLQT -{ - - class CSettingsDialog: public QDialog - { - Q_OBJECT - - public: - CSettingsDialog(QWidget *parent = 0); - ~CSettingsDialog(); - - Q_SIGNALS: - void ldPathChanged(QString); - - private Q_SLOTS: - void addPath(); - void removePath(); - void upPath(); - void downPath(); - void applyPressed(); - void browseLeveldesignPath(); - - private: - - Ui::CSettingsDialog ui; - - }; /* class CSettingsDialog */ - -} /* namespace NLQT */ - -#endif // SETTINGS_DIALOG_H +/* +Georges Editor Qt +Copyright (C) 2010 Adrian Jaekel + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#ifndef SETTINGS_DIALOG_H +#define SETTINGS_DIALOG_H + +#include +#include "ui_settings_form.h" + +// STL includes + +// NeL includes +#include + +// Project includes + +namespace NLQT +{ + + class CSettingsDialog: public QDialog + { + Q_OBJECT + + public: + CSettingsDialog(QWidget *parent = 0); + ~CSettingsDialog(); + + Q_SIGNALS: + void ldPathChanged(QString); + + private Q_SLOTS: + void addPath(); + void removePath(); + void upPath(); + void downPath(); + void applyPressed(); + void browseLeveldesignPath(); + + private: + + Ui::CSettingsDialog ui; + + }; /* class CSettingsDialog */ + +} /* namespace NLQT */ + +#endif // SETTINGS_DIALOG_H diff --git a/code/ryzom/tools/leveldesign/georges_editor_qt/src/stdpch.h b/code/ryzom/tools/leveldesign/georges_editor_qt/src/stdpch.h index 0ef614792..d9dcf4d58 100644 --- a/code/ryzom/tools/leveldesign/georges_editor_qt/src/stdpch.h +++ b/code/ryzom/tools/leveldesign/georges_editor_qt/src/stdpch.h @@ -1,33 +1,33 @@ -/* - Object Viewer Qt - Copyright (C) 2010 Dzmitry Kamiahin - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU 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 General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -*/ - -#ifndef NL_STDPCH_H -#define NL_STDPCH_H - -#include - -#include -#include -#include -#include -#include - -#include - -#endif +/* + Object Viewer Qt + Copyright (C) 2010 Dzmitry Kamiahin + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +*/ + +#ifndef NL_STDPCH_H +#define NL_STDPCH_H + +#include + +#include +#include +#include +#include +#include + +#include + +#endif diff --git a/code/ryzom/tools/leveldesign/georges_exe/georges_exe.cpp b/code/ryzom/tools/leveldesign/georges_exe/georges_exe.cpp index 6a1738939..864a74bd7 100644 --- a/code/ryzom/tools/leveldesign/georges_exe/georges_exe.cpp +++ b/code/ryzom/tools/leveldesign/georges_exe/georges_exe.cpp @@ -1,69 +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 . - -// georges_exe.cpp : Defines the entry point for the application. -// -#include - -#ifdef min -#undef min -#endif - -#ifdef max -#undef max -#endif - -#include "nel/misc/debug.h" -#include "../georges_dll/georges_interface.h" - -using namespace std; - - -int APIENTRY WinMain(HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPSTR lpCmdLine, - int nCmdShow) -{ - // Init the NeL application context - NLMISC::CApplicationContext context; - - // Create a logic editor - IGeorges* pGeorges = IGeorges::getInterface(); - - if (pGeorges) - { - // Init ui - pGeorges->initUI(nCmdShow, true); - - string cmd = lpCmdLine; - if(!cmd.empty()) - { - nlinfo("Using command line '%s'", cmd.c_str()); - pGeorges->LoadDocument(cmd.c_str()); - } - - // Go - pGeorges->go(); - - // Release ui - // pGeorges->releaseUI (); - - // Delete the pointer - IGeorges::releaseInterface (pGeorges); - } - - return 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 . + +// georges_exe.cpp : Defines the entry point for the application. +// +#include + +#ifdef min +#undef min +#endif + +#ifdef max +#undef max +#endif + +#include "nel/misc/debug.h" +#include "../georges_dll/georges_interface.h" + +using namespace std; + + +int APIENTRY WinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpCmdLine, + int nCmdShow) +{ + // Init the NeL application context + NLMISC::CApplicationContext context; + + // Create a logic editor + IGeorges* pGeorges = IGeorges::getInterface(); + + if (pGeorges) + { + // Init ui + pGeorges->initUI(nCmdShow, true); + + string cmd = lpCmdLine; + if(!cmd.empty()) + { + nlinfo("Using command line '%s'", cmd.c_str()); + pGeorges->LoadDocument(cmd.c_str()); + } + + // Go + pGeorges->go(); + + // Release ui + // pGeorges->releaseUI (); + + // Delete the pointer + IGeorges::releaseInterface (pGeorges); + } + + return 0; +} diff --git a/code/ryzom/tools/leveldesign/georges_exe/resource.h b/code/ryzom/tools/leveldesign/georges_exe/resource.h index d71ba78da..183fb92e7 100644 --- a/code/ryzom/tools/leveldesign/georges_exe/resource.h +++ b/code/ryzom/tools/leveldesign/georges_exe/resource.h @@ -1,38 +1,38 @@ -// 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 . - -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by georges_exe.rc -// -#define IDI_ICON1 101 -#define IDC_CURSOR1 102 -#define IDD_DIALOG1 103 -#define IDR_MAINFRAME 128 -#define IDR_TYPETYPE 129 -#define IDR_TYPEDFN 132 -#define IDR_TYPEFORM 133 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 105 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif +// 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 . + +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by georges_exe.rc +// +#define IDI_ICON1 101 +#define IDC_CURSOR1 102 +#define IDD_DIALOG1 103 +#define IDR_MAINFRAME 128 +#define IDR_TYPETYPE 129 +#define IDR_TYPEDFN 132 +#define IDR_TYPEFORM 133 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 105 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBase.cpp b/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBase.cpp index 4762bab84..40b3a9bc2 100644 --- a/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBase.cpp +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBase.cpp @@ -1,40 +1,40 @@ -// 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 "std_sound_plugin.h" -#include "PageBase.h" - - - -#undef new -IMPLEMENT_DYNCREATE(CPageBase, CPropertyPage) -#define new NL_NEW - - -std::set CPageBase::_AllPages; - - -void CPageBase::docChanged() -{ - AFX_MANAGE_STATE(AfxGetStaticModuleState()); - std::set::iterator first(_AllPages.begin()), last(_AllPages.end()); - for(; first != last; ++first) - { - CPageBase *page = (*first); - if (page->m_hWnd != NULL) - (*first)->onDocChanged(); - } -} +// 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 "std_sound_plugin.h" +#include "PageBase.h" + + + +#undef new +IMPLEMENT_DYNCREATE(CPageBase, CPropertyPage) +#define new NL_NEW + + +std::set CPageBase::_AllPages; + + +void CPageBase::docChanged() +{ + AFX_MANAGE_STATE(AfxGetStaticModuleState()); + std::set::iterator first(_AllPages.begin()), last(_AllPages.end()); + for(; first != last; ++first) + { + CPageBase *page = (*first); + if (page->m_hWnd != NULL) + (*first)->onDocChanged(); + } +} diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBase.h b/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBase.h index 6af4bc18c..04ec0b9cc 100644 --- a/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBase.h +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/PageBase.h @@ -1,69 +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 . - -#ifndef BAGE_PAGE_H -#define BAGE_PAGE_H - -#include -#include - -namespace NLGEORGES -{ - class CSoundDialog; -} - -/** Base class for all property page -*/ -class CPageBase : public CPropertyPage -{ - DECLARE_DYNCREATE(CPageBase) - - static std::set _AllPages; - -protected: - CPageBase(NLGEORGES::CSoundDialog *soundDialog, UINT nIDTemplate, UINT nIDCaption = 0) - : CPropertyPage(nIDTemplate, nIDCaption), - SoundDialog(soundDialog) - { - _AllPages.insert(this); - } - - CPageBase() - : SoundDialog(0) - { - _AllPages.insert(this); - } - - ~CPageBase() - { - _AllPages.erase(this); - } - - /// The dialog pane call this method when the content of the doc has changed -// void docChanged(); - - - NLGEORGES::CSoundDialog *SoundDialog; - -public: - /// The master dialog call this method when the document is changed/updated - static void docChanged(); - /// The docChanged static method call this method on each page. - virtual void onDocChanged() {} -}; - - +// 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 BAGE_PAGE_H +#define BAGE_PAGE_H + +#include +#include + +namespace NLGEORGES +{ + class CSoundDialog; +} + +/** Base class for all property page +*/ +class CPageBase : public CPropertyPage +{ + DECLARE_DYNCREATE(CPageBase) + + static std::set _AllPages; + +protected: + CPageBase(NLGEORGES::CSoundDialog *soundDialog, UINT nIDTemplate, UINT nIDCaption = 0) + : CPropertyPage(nIDTemplate, nIDCaption), + SoundDialog(soundDialog) + { + _AllPages.insert(this); + } + + CPageBase() + : SoundDialog(0) + { + _AllPages.insert(this); + } + + ~CPageBase() + { + _AllPages.erase(this); + } + + /// The dialog pane call this method when the content of the doc has changed +// void docChanged(); + + + NLGEORGES::CSoundDialog *SoundDialog; + +public: + /// The master dialog call this method when the document is changed/updated + static void docChanged(); + /// The docChanged static method call this method on each page. + virtual void onDocChanged() {} +}; + + #endif \ No newline at end of file