Fix css style order when using external css files
[ryzomcore.git] / ryzom / client / src / interface_v3 / action_handler_debug.cpp
blob1670bdc777a4611f18863bd864b3dfd243d8952b
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
6 // Copyright (C) 2014 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
7 //
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU Affero General Public License as
10 // published by the Free Software Foundation, either version 3 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU Affero General Public License for more details.
18 // You should have received a copy of the GNU Affero General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "stdpch.h"
23 using namespace std;
24 using namespace NLMISC;
25 using namespace NL3D;
27 #include "nel/gui/action_handler.h"
28 #include "../misc.h"
29 #include "../prim_file.h"
30 #include "../graph.h"
31 #include "../motion/user_controls.h"
32 #include "../ig_callback.h"
33 #include "../movie_shooter.h"
34 #include "../weather.h"
35 #include "../weather_manager_client.h"
36 #include "../continent_manager.h"
37 #include "../user_entity.h"
38 #include "../connection.h"
40 using namespace NLGUI;
42 ////////////
43 // GLOBAL //
44 ////////////
45 extern bool Render;
46 extern bool WantProfiling; // Do we want a CPU profile?
47 extern bool WantProfilingVBLock; // Do we want a VBLock profile?
48 extern bool PACSBorders;
49 extern bool ARKPACSBorders;
50 extern bool DebugClusters;
51 extern bool SoundBox;
52 extern uint8 ShowInfos;
53 extern UDriver *Driver;
54 extern CUserControls UserControls;
55 extern CIGCallback *IGCallbacks;
56 extern CLandscapeIGManager LandscapeIGManager;
57 extern bool MovieShooterSaving;
58 extern bool Filter3D[RYZOM_MAX_FILTER_3D];
59 extern ULandscape *Landscape;
60 extern EGSPD::CSeason::TSeason ManualSeasonValue;
61 extern CContinentManager ContinentMngr;
62 extern NL3D::UScene *Scene;
63 extern UCamera MainCam;
64 extern bool ForceTrueWeatherValue;
65 extern bool InitCloudScape;
66 extern bool DisplayWeatherFunction;
67 extern bool FreezeGraph;
68 extern bool MovieShooterReplay;
69 extern bool MovieShooterSave;
71 void endMovieShooting();
74 // ***************************************************************************
75 class CAHDisplayInfos : public IActionHandler
77 void execute(CCtrlBase * /* pCaller */, const std::string &/* params */)
79 // can only be used by devs and CSR or in local mode
80 #if FINAL_VERSION
81 if( ClientCfg.Local || hasPrivilegeDEV() || hasPrivilegeSGM() || hasPrivilegeGM() || hasPrivilegeSG() || hasPrivilegeEM() || hasPrivilegeVG() )
82 #endif
84 ShowInfos = (ShowInfos+1)%6;
86 CGraph::Display = (ShowInfos != 0);
90 // ***************************************************************************
91 REGISTER_ACTION_HANDLER (CAHDisplayInfos, "display_infos");
94 /**********************************************************************************************************
95 * *
96 * move player handlers actions *
97 * *
98 ***********************************************************************************************************/
100 // ------------------------------------------------------------------------------------------------
101 class CAHToggleARKPACSBorders : public IActionHandler
103 virtual void execute (CCtrlBase * /* pCaller */, const string &Params)
105 if (!getParam(Params, "on").empty())
106 ARKPACSBorders = true;
107 else if (!getParam(Params, "off").empty())
108 ARKPACSBorders = false;
109 else ARKPACSBorders = !ARKPACSBorders;
113 REGISTER_ACTION_HANDLER (CAHToggleARKPACSBorders, "ark_pacs_borders");
115 #if !FINAL_VERSION
116 // ------------------------------------------------------------------------------------------------
117 class CAHProfile : public IActionHandler
119 virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
121 WantProfiling= true;
124 REGISTER_ACTION_HANDLER (CAHProfile, "profile");
126 // ------------------------------------------------------------------------------------------------
127 class CAHProfileVBLock : public IActionHandler
129 virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
131 WantProfilingVBLock= true;
134 REGISTER_ACTION_HANDLER (CAHProfileVBLock, "profile_vblock");
136 // ------------------------------------------------------------------------------------------------
137 class CAHProfileFillRate : public IActionHandler
139 virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
141 static bool minimized= false;
142 minimized= !minimized;
143 if(minimized)
145 CViewport vp;
146 vp.init(0, 0, 0.1f, 0.1f);
147 Scene->setViewport(vp);
149 else
151 CViewport vp;
152 vp.initFullScreen();
153 Scene->setViewport(vp);
157 REGISTER_ACTION_HANDLER (CAHProfileFillRate, "profile_fillrate");
159 // ------------------------------------------------------------------------------------------------
160 class CAHProfileTexture : public IActionHandler
162 virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
164 if(Driver)
166 vector<string> res;
167 Driver->profileTextureUsage(res);
169 // Display and save profile to a File.
170 CLog log;
171 CFileDisplayer fileDisplayer(NLMISC::CFile::findNewFile(getLogDirectory() + "texture.log"));
172 CStdDisplayer stdDisplayer;
173 log.addDisplayer(&fileDisplayer);
174 log.addDisplayer(&stdDisplayer);
176 log.displayRawNL("********* TEXTURE PROFILE **********");
177 for(uint i=0;i<res.size();i++)
179 log.displayRawNL(res[i].c_str());
181 log.displayRawNL("************************************");
185 REGISTER_ACTION_HANDLER (CAHProfileTexture, "profile_texture");
188 // ------------------------------------------------------------------------------------------------
189 class CAHTogglePACSBorders : public IActionHandler
191 virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
193 PACSBorders = !PACSBorders;
196 REGISTER_ACTION_HANDLER (CAHTogglePACSBorders, "pacs_borders");
198 // ------------------------------------------------------------------------------------------------
199 class CAHToggleDebugClusters : public IActionHandler
201 virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
203 DebugClusters = !DebugClusters;
206 REGISTER_ACTION_HANDLER (CAHToggleDebugClusters, "debug_clusters");
208 /*// ------------------------------------------------------------------------------------------------
209 class CAHToggleSoundBox : public IActionHandler
211 virtual void execute (CCtrlBase *pCaller, const string &Params)
213 SoundBox = !SoundBox;
216 REGISTER_ACTION_HANDLER (CAHToggleSoundBox, "sound_box");
218 // ***************************************************************************
219 class CAHTest : public IActionHandler
221 void execute(CCtrlBase * /* pCaller */, const std::string &/* params */)
223 // For test
226 // ***************************************************************************
227 REGISTER_ACTION_HANDLER (CAHTest, "test");
229 // ***************************************************************************
230 class CAHRenderMode : public IActionHandler
232 void execute(CCtrlBase * /* pCaller */, const std::string &/* params */)
234 switch(Driver->getPolygonMode())
236 case UDriver::Filled:
237 Driver->setPolygonMode(UDriver::Line);
238 break;
239 case UDriver::Line:
240 Driver->setPolygonMode(UDriver::Point);
241 break;
242 case UDriver::Point:
243 Driver->setPolygonMode(UDriver::Filled);
244 break;
248 // ***************************************************************************
249 REGISTER_ACTION_HANDLER (CAHRenderMode, "render_mode");
251 // ***************************************************************************
252 class CAHToggleRender : public IActionHandler
254 virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
256 Render = !Render;
259 // ***************************************************************************
260 REGISTER_ACTION_HANDLER (CAHToggleRender, "toggle_render");
262 // ***************************************************************************
263 class CAHSwitchConsoleDisplay : public IActionHandler
265 virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
267 // ChatOutput.switchDisplay();
270 // ***************************************************************************
271 REGISTER_ACTION_HANDLER (CAHSwitchConsoleDisplay, "switch_console_display");
273 // ***************************************************************************
274 class CAHToggleFly : public IActionHandler
276 virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
278 // Change to AI Mode.
279 if(UserControls.mode() != CUserControls::AIMode)
280 UserControls.mode(CUserControls::AIMode);
281 // Leave the AI Mode.
282 else
283 UserEntity->viewMode(UserEntity->viewMode());
286 // ***************************************************************************
287 REGISTER_ACTION_HANDLER (CAHToggleFly, "toggle_fly");
289 // ***************************************************************************
290 class CAHReloadLandscapeIg : public IActionHandler
292 virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
294 if (Landscape)
296 if (IGCallbacks) IGCallbacks->deleteIGs();
297 LandscapeIGManager.reloadAllIgs ();
298 nlassert(IGCallbacks);
299 std::vector<UInstanceGroup *> igs;
300 LandscapeIGManager.getAllIG(igs);
301 if (IGCallbacks) IGCallbacks->addIGs(igs);
305 // ***************************************************************************
306 REGISTER_ACTION_HANDLER (CAHReloadLandscapeIg, "reload_landscape_ig");
308 // ***************************************************************************
309 class CAHMemoryReport : public IActionHandler
311 virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
313 #ifndef NL_USE_DEFAULT_MEMORY_MANAGER
314 #ifndef NL_HEAP_ALLOCATION_NDEBUG
315 // NLMEMORY::StatisticsReport ("memory_stat.csv", false);
316 #endif // NL_HEAP_ALLOCATION_NDEBUG
317 #endif // NL_USE_DEFAULT_MEMORY_MANAGER
320 // ***************************************************************************
321 REGISTER_ACTION_HANDLER (CAHMemoryReport, "memory_report");
323 // ***************************************************************************
324 class CAHTogglePrimitive: public IActionHandler
326 virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
328 PrimFiles.toggleShowHide ();
331 // ***************************************************************************
332 REGISTER_ACTION_HANDLER (CAHTogglePrimitive, "toggle_primitive");
334 // ***************************************************************************
335 class CAHPrimBrowseUp : public IActionHandler
337 virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
339 PrimFiles.loadNext ();
342 // ***************************************************************************
343 REGISTER_ACTION_HANDLER (CAHPrimBrowseUp, "primitive_up");
345 // ***************************************************************************
346 class CAHPrimBrowseDown : public IActionHandler
348 virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
350 PrimFiles.loadPrevious ();
353 // ***************************************************************************
354 REGISTER_ACTION_HANDLER (CAHPrimBrowseDown, "primitive_down");
356 // ***************************************************************************
357 class CAHToggleMovieRecorder : public IActionHandler
359 virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
361 #ifdef _MOVIE_SHOOTER_ON_
362 if (!MovieShooterSave && !MovieShooterReplay)
364 if(!MovieShooter.enabled())
366 Driver->systemMessageBox("MovieShooter not enabled", "MovieShooter");
368 else
370 if( !MovieShooterSaving )
372 // reset the movie, and start a new one
373 MovieShooter.resetMovie();
374 // state
375 MovieShooterSaving= true;
377 else
379 // save the movie
380 endMovieShooting();
384 #endif // _MOVIE_SHOOTER_ON_
387 // ***************************************************************************
388 REGISTER_ACTION_HANDLER (CAHToggleMovieRecorder, "toggle_movie_recorder");
390 // ***************************************************************************
391 class CAHReplayMovie : public IActionHandler
393 virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
395 if (!MovieShooterSave && !MovieShooterSaving)
396 MovieShooterReplay = true;
399 // ***************************************************************************
400 REGISTER_ACTION_HANDLER (CAHReplayMovie, "replay_movie");
402 // ***************************************************************************
403 class CAHSaveMovie : public IActionHandler
405 virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
407 if (!MovieShooterReplay && !MovieShooterSaving)
408 MovieShooterSave = true;
411 // ***************************************************************************
412 REGISTER_ACTION_HANDLER (CAHSaveMovie, "save_movie");
414 // ***************************************************************************
415 class CAHToggleFilter3D : public IActionHandler
417 virtual void execute (CCtrlBase * /* pCaller */, const string &Params)
419 #ifdef _PROFILE_ON_
421 uint32 filter;
422 fromString(Params, filter);
424 if (filter <= RYZOM_MAX_FILTER_3D)
426 Filter3D[filter] = !Filter3D[filter];
427 if (filter == FilterVegetable)
429 if (Landscape) Landscape->enableVegetable(Filter3D[FilterVegetable]);
432 #endif // _PROFILE_ON_
435 // ***************************************************************************
436 REGISTER_ACTION_HANDLER (CAHToggleFilter3D, "toggle_3d_filter");
438 // ***************************************************************************
439 class CAHToggleSeason: public IActionHandler
441 virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
443 if (ClientCfg.ManualWeatherSetup)
445 ManualSeasonValue = (EGSPD::CSeason::TSeason) (ManualSeasonValue + 1);
446 if (ManualSeasonValue == EGSPD::CSeason::Invalid) ManualSeasonValue = EGSPD::CSeason::Spring;
447 class CDummyProgress : public NLMISC::IProgressCallback
449 void progress (float /* value */) {}
451 CDummyProgress progress;
452 ContinentMngr.select(UserEntity->pos(), progress);
456 // ***************************************************************************
457 REGISTER_ACTION_HANDLER (CAHToggleSeason, "toggle_season");
459 // ***************************************************************************
460 class CAHReloadSeason: public IActionHandler
462 virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
464 // reload all parameters for weather
465 loadWorldLightCycle();
466 loadWeatherFunctionParams();
467 WeatherManager.init();
468 ContinentMngr.reloadWeather();
471 // ***************************************************************************
472 REGISTER_ACTION_HANDLER (CAHReloadSeason, "reload_season");
475 // ***************************************************************************
476 class CAHWindTest : public IActionHandler
478 virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
480 NL3D::UInstance inst = Scene->createInstance("wind.ps");
481 if (!inst.empty())
483 inst.setPos(MainCam.getPos());
487 // ***************************************************************************
488 REGISTER_ACTION_HANDLER (CAHWindTest, "wind_test");
491 // ***************************************************************************
492 class CAHReelWeather : public IActionHandler
494 virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
496 ForceTrueWeatherValue = !ForceTrueWeatherValue;
499 // ***************************************************************************
500 REGISTER_ACTION_HANDLER (CAHReelWeather, "real_weather");
503 // ***************************************************************************
504 class CAHUpdateClouds: public IActionHandler
506 virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
508 InitCloudScape = true;
511 // ***************************************************************************
512 REGISTER_ACTION_HANDLER (CAHUpdateClouds, "update_clouds");
515 // ***************************************************************************
516 class CAHToggleWeatherFunction: public IActionHandler
518 virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
520 DisplayWeatherFunction = !DisplayWeatherFunction;
523 // ***************************************************************************
524 REGISTER_ACTION_HANDLER (CAHToggleWeatherFunction, "toggle_weather_function");
527 // ***************************************************************************
528 class CAHToggleFreezeGraph: public IActionHandler
530 virtual void execute (CCtrlBase * /* pCaller */, const string &/* Params */)
532 FreezeGraph = !FreezeGraph;
535 // ***************************************************************************
536 REGISTER_ACTION_HANDLER (CAHToggleFreezeGraph, "toggle_freeze_graph");
537 #endif // !FINAL_VERSION