georges.patch
b/code/ryzom/tools/leveldesign/CMakeLists.txt Sun Oct 31 20:26:05 2010 +0100 | ||
---|---|---|
9 | 9 |
ADD_SUBDIRECTORY(world_editor) |
10 | 10 |
ENDIF(WIN32) |
11 | 11 | |
12 |
IF(WITH_QT) |
|
13 |
ADD_SUBDIRECTORY(georges_editor_qt) |
|
14 |
ENDIF(WITH_QT) |
|
15 | ||
12 | 16 |
# folders not handled yet. |
13 | 17 |
#georges_convert |
14 | 18 |
#georges_dll |
b/code/ryzom/tools/leveldesign/georges_editor_qt/CMakeLists.txt Sun Oct 31 20:26:05 2010 +0100 | ||
---|---|---|
1 |
#----------------------------------------------------------------------------- |
|
2 |
# |
|
3 |
# Georges Editor Qt |
|
4 |
# Copyright (C) 2010 Adrian J?kel <aj at elane2k dot com> |
|
5 |
# |
|
6 |
#----------------------------------------------------------------------------- |
|
7 |
|
|
8 |
# This tells the application(s) where to find the installed data. |
|
9 |
ADD_DEFINITIONS(-DDATA_DIR="\\"${NL_SHARE_PREFIX}/georges_editor_qt/\\"") |
|
10 |
|
|
11 |
ADD_SUBDIRECTORY(src) |
|
12 |
|
|
13 |
INSTALL(DIRECTORY data/ |
|
14 |
DESTINATION share/georges_editor_qt/data |
|
15 |
COMPONENT data |
|
16 |
PATTERN "CVS" EXCLUDE |
|
17 |
PATTERN ".svn" EXCLUDE |
|
18 |
PATTERN "Makefile*" EXCLUDE) |
|
19 |
|
b/code/ryzom/tools/leveldesign/georges_editor_qt/data/georges_editor.cfg Sun Oct 31 20:26:05 2010 +0100 | ||
---|---|---|
1 |
RootConfigFilename = "georges_editor_default.cfg"; |
|
2 |
SearchPaths = { |
|
3 |
"G:/ryzom_assets/ryzom_assets/Stuff/Matis", "G:/ryzom_assets/bnps/characters_shapes" |
|
4 |
}; |
|
5 |
GraphicsDriver = "OpenGL"; |
|
6 |
BackgroundColor = { |
|
7 |
173, 205, 234 |
|
8 |
}; |
|
9 |
LeveldesignPath = "D:/Dev/Ryzom/code/ryzom/common/data_leveldesign/leveldesign"; |
|
10 |
QtWindowState = "%00%00%00%FF%00%00%00%00%FD%00%00%00%03%00%00%00%00%00%00%02%A6%00%00%00%E9%FC%02%00%00%00%01%FB%00%00%00%2A%00C%00G%00e%00o%00r%00g%00e%00s%00D%00i%00r%00T%00r%00e%00e%00D%00i%00a%00l%00o%00g%01%00%00%00%3B%00%00%00%E9%00%00%00t%00%FF%FF%FF%00%00%00%02%00%00%00%00%00%00%00%00%FC%01%00%00%00%01%FB%00%00%00%26%00C%00O%00b%00j%00e%00c%00t%00V%00i%00e%00w%00e%00r%00D%00i%00a%00l%00o%00g%00%00%00%00%00%FF%FF%FF%FF%00%00%00N%00%FF%FF%FF%00%00%00%03%00%00%02%A6%00%00%01c%FC%01%00%00%00%01%FB%00%00%00%22%00C%00G%00e%00o%00r%00g%00e%00s%00L%00o%00g%00D%00i%00a%00l%00o%00g%01%00%00%00%00%00%00%02%A6%00%00%00%5D%00%FF%FF%FF%00%00%00%00%00%00%00%E9%00%00%00%04%00%00%00%04%00%00%00%08%00%00%00%08%FC%00%00%00%01%00%00%00%02%00%00%00%01%FF%FF%FF%FF%01%00%00%00%00%FF%FF%FF%FF%00%00%00%00%00%00%00%00"; |
|
11 |
QtWindowGeometry = "%01%D9%D0%CB%00%01%00%00%00%00%00%D6%00%00%00%C0%00%00%03%83%00%00%03%82%00%00%00%DA%00%00%00%DE%00%00%03%7F%00%00%03~%00%00%00%00%00%00"; |
b/code/ryzom/tools/leveldesign/georges_editor_qt/data/georges_editor_default.cfg Sun Oct 31 20:26:05 2010 +0100 | ||
---|---|---|
1 |
////////////////////////////////////////////////////////////////////////////// |
|
2 |
// Config file for Georges Editor Qt //////////////////////////////////////////////////// |
|
3 |
////////////////////////////////////////////////////////////////////////////// |
|
4 | ||
5 |
// |
|
6 |
// This file is used to setup the georges editor tool. |
|
7 |
// |
|
8 | ||
9 | ||
10 |
////////////////////////////////////////////////////////////////////////////// |
|
11 |
// NeL Qt //////////////////////////////////////////////////////////////////// |
|
12 |
////////////////////////////////////////////////////////////////////////////// |
|
13 | ||
14 |
// Root directory where we can find the client datas (zones, tiles, maps, ...) |
|
15 |
// You must uncomment this line on GNU/Linux and comment the next one |
|
16 |
//SearchPaths = { "/usr/local/share/games/nel_qt/" }; |
|
17 |
SearchPaths = { "data" }; |
|
18 |
LeveldesignPath = ""; |
|
19 | ||
20 |
// Which extensions to remap to what if needed (pairs of 2) |
|
21 |
RemapExtensions = { "png", "tga" }; |
|
22 | ||
23 |
// The language code of the client |
|
24 |
LanguageCode = "en"; |
|
25 | ||
26 |
// If changes to the config should be saved on exit |
|
27 |
SaveConfig = 1; |
|
28 | ||
29 | ||
30 |
////////////////////////////////////////////////////////////////////////////// |
|
31 |
// Qt //////////////////////////////////////////////////////////////////////// |
|
32 |
////////////////////////////////////////////////////////////////////////////// |
|
33 | ||
34 |
QtStyle = "Cleanlooks"; |
|
35 |
QtPalette = 0; |
|
36 |
QtWindowState = ""; |
|
37 |
QtWindowGeometry = ""; |
|
38 | ||
39 |
////////////////////////////////////////////////////////////////////////////// |
|
40 |
// Graphics ////////////////////////////////////////////////////////////////// |
|
41 |
////////////////////////////////////////////////////////////////////////////// |
|
42 | ||
43 |
// Use OpenGL or Direct3D (Windows) |
|
44 |
GraphicsEnabled = 1; |
|
45 |
GraphicsDrivers = { "OpenGL", "Direct3D" }; |
|
46 |
GraphicsDriver = "OpenGL"; |
|
47 | ||
48 |
// Font name used for all text in the client (it can be a .ttf, .fon, .pfb) |
|
49 |
FontName = "andbasr.ttf"; |
|
50 |
FontShadow = 1; |
|
51 | ||
52 |
// Background color |
|
53 |
BackgroundColor = { 151, 156, 182 }; |
|
54 | ||
55 |
SunDirection = { -2.935, +0.107, -1.22 }; |
|
56 |
SunAmbient = { 190, 170, 150 }; |
|
57 |
SunDiffuse = { 255, 248, 255 }; |
|
58 |
SunSpecular = { 255, 255, 255}; |
|
59 | ||
60 |
////////////////////////////////////////////////////////////////////////////// |
|
61 |
// Time ////////////////////////////////////////////////////////////////////// |
|
62 |
////////////////////////////////////////////////////////////////////////////// |
|
63 | ||
64 |
FpsSmoothing = 64; |
|
65 | ||
66 |
////////////////////////////////////////////////////////////////////////////// |
|
67 |
// Interface ///////////////////////////////////////////////////////////////// |
|
68 |
////////////////////////////////////////////////////////////////////////////// |
|
69 | ||
70 |
// This setting is used to bind keys to actions. |
|
71 |
// "key_handler", "args", "***", "Key1|Key2", |
|
72 |
// *** -> CTRL, SHIFT, ALT don't matter |
|
73 |
// --- -> CTRL, SHIFT, ALT must all be disabled |
|
74 |
// -+- -> only SHIFT must be down |
|
75 |
KeySettings = { |
|
76 |
"screenshot", "", "***", "KeyF5", |
|
77 |
"command", "set_state Exit", "-+-", "KeyESCAPE", |
|
78 |
"command", "set_state Login", "+--", "KeyESCAPE", |
|
79 |
"command", "set_state Unload", "***", "KeyF8", |
|
80 |
"command", "set_state Demo", "***", "KeyF7", |
|
81 |
"move_forward", "", "***", "KeyUP|KeyZ|KeyW", |
|
82 |
"move_backward", "", "***", "KeyDOWN|KeyS", |
|
83 |
"move_left", "", "***", "KeyLEFT|KeyQ|KeyA", |
|
84 |
"move_right", "", "***", "KeyRIGHT|KeyD", |
|
85 |
"move_forward", "", "***", "KeyZ|KeyW", |
|
86 |
"move_backward", "", "***", "KeyS", |
|
87 |
"move_left", "", "***", "KeyQ|KeyA", |
|
88 |
"move_right", "", "***", "KeyD", |
|
89 |
"chat_begin", "", "***", "KeyT", |
|
90 |
"chat_send", "", "***", "KeyENTER", |
|
91 |
"chat_leave", "", "***", "KeyESCAPE", |
|
92 |
"display_test", "", "***", "KeyTAB", |
|
93 |
"send_action", "0", "---", "Key1", |
|
94 |
"send_action", "1", "---", "Key2", |
|
95 |
"send_action", "2", "---", "Key3", |
|
96 |
"send_action", "3", "---", "Key4", |
|
97 |
"send_action", "4", "---", "Key5", |
|
98 |
"send_action", "5", "---", "Key6", |
|
99 |
"send_action", "6", "---", "Key7", |
|
100 |
"send_action", "7", "---", "Key8", |
|
101 |
"send_action", "8", "---", "Key9", |
|
102 |
"send_action", "9", "---", "Key0", |
|
103 |
"demo_crystal_spawn", "", "---", "KeyO", |
|
104 |
"demo_crystal_explode", "", "---", "KeyP", |
|
105 |
"free_camera_forward", "", "---", "KeyNUMPAD8", |
|
106 |
"free_camera_backward", "", "---", "KeyNUMPAD2", |
|
107 |
"free_camera_left", "", "---", "KeyNUMPAD4", |
|
108 |
"free_camera_right", "", "---", "KeyNUMPAD6", |
|
109 |
"switch_camera", "", "---", "KeyF4", |
|
110 |
"switch_ui_visible" ,"", "---", "KeyF6", |
|
111 |
}; |
|
112 | ||
113 |
// end of file |
b/code/ryzom/tools/leveldesign/georges_editor_qt/src/CMakeLists.txt Sun Oct 31 20:26:05 2010 +0100 | ||
---|---|---|
1 |
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${LIBXML2_INCLUDE_DIR} ${NEL_INCLUDE_DIR} ${QT_INCLUDES}) |
|
2 |
INCLUDE( ${QT_USE_FILE} ) |
|
3 | ||
4 |
FILE(GLOB GEORGES_EDITOR_SRC *.cpp) |
|
5 |
SET(GEORGES_EDITOR_HDR georges_dirtree_dialog.h georges_treeview_dialog.h georgesform_model.h main_window.h |
|
6 |
log_dialog.h objectviewer_dialog.h settings_dialog.h) |
|
7 |
SET(GEORGES_EDITOR_UIS settings_form.ui objectviewer_form.ui log_form.ui georges_treeview_form.ui georges_dirtree_form.ui) |
|
8 |
SET(GEORGES_EDITOR_RCS georges_editor_qt.qrc) |
|
9 | ||
10 |
SET(QT_USE_QTGUI TRUE) |
|
11 |
SET(QT_USE_QTOPENGL TRUE) |
|
12 | ||
13 |
QT4_ADD_RESOURCES( GEORGES_EDITOR_RC_SRCS ${GEORGES_EDITOR_RCS} ) |
|
14 |
QT4_WRAP_CPP( GEORGES_EDITOR_MOC_SRCS ${GEORGES_EDITOR_HDR} ) |
|
15 |
QT4_WRAP_UI( GEORGES_EDITOR_UI_HDRS ${GEORGES_EDITOR_UIS} ) |
|
16 | ||
17 |
ADD_EXECUTABLE(georges_editor_qt WIN32 ${GEORGES_EDITOR_SRC} ${GEORGES_EDITOR_MOC_SRCS} ${GEORGES_EDITOR_RC_SRCS} ${GEORGES_EDITOR_UI_HDRS}) |
|
18 | ||
19 |
TARGET_LINK_LIBRARIES(georges_editor_qt |
|
20 |
nelmisc |
|
21 |
nel3d |
|
22 |
nelgeorges |
|
23 |
${QT_LIBRARIES} |
|
24 |
${QT_QTOPENGL_LIBRARY} |
|
25 |
${QT_QTMAIN_LIBRARY}) |
|
26 | ||
27 |
ADD_DEFINITIONS(-DQT_NO_KEYWORDS ${LIBXML2_DEFINITIONS} ${QT_DEFINITIONS}) |
|
28 |
NL_DEFAULT_PROPS(georges_editor_qt "Ryzom, Tools, World: Georges Editor Qt") |
|
29 |
NL_ADD_RUNTIME_FLAGS(georges_editor_qt) |
|
30 | ||
31 |
IF(WITH_PCH) |
|
32 |
ADD_NATIVE_PRECOMPILED_HEADER(georges_editor_qt ${CMAKE_CURRENT_SOURCE_DIR}/stdpch.h ${CMAKE_CURRENT_SOURCE_DIR}/stdpch.cpp) |
|
33 |
ENDIF(WITH_PCH) |
|
34 | ||
35 |
INSTALL(TARGETS georges_editor_qt RUNTIME DESTINATION bin COMPONENT runtime) |
b/code/ryzom/tools/leveldesign/georges_editor_qt/src/callback.cpp Sun Oct 31 20:26:05 2010 +0100 | ||
---|---|---|
1 |
/* |
|
2 |
* Copyright (C) 2010 by authors |
|
3 |
* |
|
4 |
* This file is part of NEL QT. |
|
5 |
* NEL QT is free software: you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation, either version 2 of the License, or |
|
8 |
* (at your option) any later version. |
|
9 |
* |
|
10 |
* NEL QT is distributed in the hope that it will be useful, but |
|
11 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 |
* General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with NEL QT; see the file COPYING. If not, see |
|
17 |
* <http://www.gnu.org/licenses/>. |
|
18 |
*/ |
|
19 | ||
20 |
#include <nel/misc/types_nl.h> |
|
21 |
#include "callback.h" |
|
22 | ||
23 |
namespace NLQT { |
|
24 | ||
25 |
} /* namespace NLQT */ |
|
26 | ||
27 |
/* end of file */ |
b/code/ryzom/tools/leveldesign/georges_editor_qt/src/callback.h Sun Oct 31 20:26:05 2010 +0100 | ||
---|---|---|
1 |
/* |
|
2 |
* Copyright (C) 2010 by authors |
|
3 |
* |
|
4 |
* This file is part of NEL QT. |
|
5 |
* NEL QT is free software: you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation, either version 2 of the License, or |
|
8 |
* (at your option) any later version. |
|
9 |
* |
|
10 |
* NEL QT is distributed in the hope that it will be useful, but |
|
11 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 |
* General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with NEL QT; see the file COPYING. If not, see |
|
17 |
* <http://www.gnu.org/licenses/>. |
|
18 |
*/ |
|
19 | ||
20 |
#ifndef NLQT_CALLBACK_H |
|
21 |
#define NLQT_CALLBACK_H |
|
22 |
#include <nel/misc/types_nl.h> |
|
23 | ||
24 |
// STL includes |
|
25 | ||
26 |
// NeL includes |
|
27 |
#include <nel/misc/debug.h> |
|
28 | ||
29 |
// Project includes |
|
30 | ||
31 |
namespace NLQT { |
|
32 | ||
33 |
#define NLQT_CALLBACK_TEMPLATE \ |
|
34 |
/** \ |
|
35 |
* \brief NLQT_CALLBACK_ARGS_CLASS \ |
|
36 |
* \date 2009-03-03 18:09GMT \ |
|
37 |
* \author Jan Boon (Kaetemi) \ |
|
38 |
* Awesome callback template \ |
|
39 |
*/ \ |
|
40 |
template<typename TReturn NLQT_CALLBACK_ARGS_TYPENAME> \ |
|
41 |
class NLQT_CALLBACK_ARGS_CLASS \ |
|
42 |
{ \ |
|
43 |
/* Very simple reference counting callback base */ \ |
|
44 |
class CCallbackBase \ |
|
45 |
{ \ |
|
46 |
public: \ |
|
47 |
CCallbackBase() : m_RefCount(0) \ |
|
48 |
{ \ |
|
49 |
\ |
|
50 |
} \ |
|
51 |
\ |
|
52 |
virtual ~CCallbackBase() \ |
|
53 |
{ \ |
|
54 |
nlassert(!m_RefCount); \ |
|
55 |
} \ |
|
56 |
\ |
|
57 |
void refAdd() \ |
|
58 |
{ \ |
|
59 |
++m_RefCount; \ |
|
60 |
} \ |
|
61 |
\ |
|
62 |
void refRemove() \ |
|
63 |
{ \ |
|
64 |
--m_RefCount; \ |
|
65 |
if (!m_RefCount) \ |
|
66 |
delete this; \ |
|
67 |
} \ |
|
68 |
\ |
|
69 |
virtual TReturn callback(NLQT_CALLBACK_ARGS_DECL) = 0; \ |
|
70 |
\ |
|
71 |
virtual bool equals(const CCallbackBase *callbackBase) = 0; \ |
|
72 |
\ |
|
73 |
/* disable copy */ \ |
|
74 |
CCallbackBase(const CCallbackBase &); \ |
|
75 |
CCallbackBase &operator=(const CCallbackBase &); \ |
|
76 |
\ |
|
77 |
private: \ |
|
78 |
uint m_RefCount; \ |
|
79 |
}; \ |
|
80 |
\ |
|
81 |
typedef TReturn TCallbackFunction(NLQT_CALLBACK_ARGS_DECL); \ |
|
82 |
class CCallbackFunction : public CCallbackBase \ |
|
83 |
{ \ |
|
84 |
public: \ |
|
85 |
CCallbackFunction(TCallbackFunction *callbackFunction) : m_CallbackFunction(callbackFunction) \ |
|
86 |
{ \ |
|
87 |
nlassert(m_CallbackFunction); \ |
|
88 |
} \ |
|
89 |
\ |
|
90 |
virtual ~CCallbackFunction() \ |
|
91 |
{ \ |
|
92 |
m_CallbackFunction = NULL; \ |
|
93 |
} \ |
|
94 |
\ |
|
95 |
virtual TReturn callback(NLQT_CALLBACK_ARGS_DECL) \ |
|
96 |
{ \ |
|
97 |
return m_CallbackFunction(NLQT_CALLBACK_ARGS_IMPL); \ |
|
98 |
} \ |
|
99 |
\ |
|
100 |
virtual bool equals(const CCallbackBase *callbackBase) \ |
|
101 |
{ \ |
|
102 |
const CCallbackFunction *callbackFunction = \ |
|
103 |
dynamic_cast<const CCallbackFunction *>(callbackBase); \ |
|
104 |
if (!callbackFunction) return false; \ |
|
105 |
return m_CallbackFunction == callbackFunction->m_CallbackFunction; \ |
|
106 |
} \ |
|
107 |
\ |
|
108 |
private: \ |
|
109 |
TCallbackFunction *m_CallbackFunction; \ |
|
110 |
}; \ |
|
111 |
\ |
|
112 |
template<typename TClass> \ |
|
113 |
class CCallbackMethod : public CCallbackBase \ |
|
114 |
{ \ |
|
115 |
typedef TReturn (TClass::*TCallbackMethod)(NLQT_CALLBACK_ARGS_DECL); \ |
|
116 |
public: \ |
|
117 |
CCallbackMethod(TClass *callbackObject, TCallbackMethod callbackMethod) : m_CallbackObject(callbackObject), m_CallbackMethod(callbackMethod) \ |
|
118 |
{ \ |
|
119 |
nlassert(m_CallbackObject); \ |
|
120 |
nlassert(m_CallbackMethod); \ |
|
121 |
} \ |
|
122 |
\ |
|
123 |
virtual ~CCallbackMethod() \ |
|
124 |
{ \ |
|
125 |
m_CallbackObject = NULL; \ |
|
126 |
m_CallbackMethod = NULL; \ |
|
127 |
} \ |
|
128 |
\ |
|
129 |
virtual TReturn callback(NLQT_CALLBACK_ARGS_DECL) \ |
|
130 |
{ \ |
|
131 |
return (m_CallbackObject->*m_CallbackMethod)(NLQT_CALLBACK_ARGS_IMPL); \ |
|
132 |
} \ |
|
133 |
\ |
|
134 |
virtual bool equals(const CCallbackBase *callbackBase) \ |
|
135 |
{ \ |
|
136 |
const CCallbackMethod *callbackMethod = \ |
|
137 |
dynamic_cast<const CCallbackMethod *>(callbackBase); \ |
|
138 |
if (!callbackMethod) return false; \ |
|
139 |
return m_CallbackObject == callbackMethod->m_CallbackObject \ |
|
140 |
&& m_CallbackMethod == callbackMethod->m_CallbackMethod; \ |
|
141 |
} \ |
|
142 |
\ |
|
143 |
private: \ |
|
144 |
TClass *m_CallbackObject; \ |
|
145 |
TCallbackMethod m_CallbackMethod; \ |
|
146 |
}; \ |
|
147 |
\ |
|
148 |
public: \ |
|
149 |
CCallback() : m_CallbackBase(NULL) \ |
|
150 |
{ \ |
|
151 |
\ |
|
152 |
} \ |
|
153 |
\ |
|
154 |
CCallback(TCallbackFunction *callbackFunction) : m_CallbackBase(new CCallbackFunction(callbackFunction)) \ |
|
155 |
{ \ |
|
156 |
nlassert(m_CallbackBase); \ |
|
157 |
m_CallbackBase->refAdd(); \ |
|
158 |
} \ |
|
159 |
\ |
|
160 |
template<typename TClass> \ |
|
161 |
CCallback(TClass *callbackObject, TReturn (TClass::*callbackMethod)(NLQT_CALLBACK_ARGS_DECL)) : m_CallbackBase(new CCallbackMethod<TClass>(callbackObject, callbackMethod)) \ |
|
162 |
{ \ |
|
163 |
nlassert(m_CallbackBase); \ |
|
164 |
m_CallbackBase->refAdd(); \ |
|
165 |
} \ |
|
166 |
\ |
|
167 |
CCallback(const CCallback &callback) \ |
|
168 |
{ \ |
|
169 |
m_CallbackBase = callback.m_CallbackBase; \ |
|
170 |
if (m_CallbackBase) \ |
|
171 |
m_CallbackBase->refAdd(); \ |
|
172 |
} \ |
|
173 |
\ |
|
174 |
CCallback &operator=(const CCallback &callback) \ |
|
175 |
{ \ |
|
176 |
if (m_CallbackBase != callback.m_CallbackBase) \ |
|
177 |
{ \ |
|
178 |
if (m_CallbackBase) \ |
|
179 |
m_CallbackBase->refRemove(); \ |
|
180 |
m_CallbackBase = callback.m_CallbackBase; \ |
|
181 |
if (m_CallbackBase) \ |
|
182 |
m_CallbackBase->refAdd(); \ |
|
183 |
} \ |
|
184 |
return *this; \ |
|
185 |
} \ |
|
186 |
\ |
|
187 |
~CCallback() \ |
|
188 |
{ \ |
|
189 |
if (m_CallbackBase) \ |
|
190 |
{ \ |
|
191 |
m_CallbackBase->refRemove(); \ |
|
192 |
m_CallbackBase = NULL; \ |
|
193 |
} \ |
|
194 |
} \ |
|
195 |
\ |
|
196 |
TReturn callback(NLQT_CALLBACK_ARGS_DECL) \ |
|
197 |
{ \ |
|
198 |
nlassert(m_CallbackBase); \ |
|
199 |
return m_CallbackBase->callback(NLQT_CALLBACK_ARGS_IMPL); \ |
|
200 |
} \ |
|
201 |
\ |
|
202 |
TReturn operator()(NLQT_CALLBACK_ARGS_DECL) \ |
|
203 |
{ \ |
|
204 |
nlassert(m_CallbackBase); \ |
|
205 |
return m_CallbackBase->callback(NLQT_CALLBACK_ARGS_IMPL); \ |
|
206 |
} \ |
|
207 |
\ |
|
208 |
bool valid() const \ |
|
209 |
{ \ |
|
210 |
return m_CallbackBase != NULL; \ |
|
211 |
} \ |
|
212 |
\ |
|
213 |
operator bool() const \ |
|
214 |
{ \ |
|
215 |
return m_CallbackBase != NULL; \ |
|
216 |
} \ |
|
217 |
\ |
|
218 |
bool operator==(const CCallback &callback) \ |
|
219 |
{ \ |
|
220 |
return m_CallbackBase->equals(callback.m_CallbackBase); \ |
|
221 |
} \ |
|
222 |
\ |
|
223 |
private: \ |
|
224 |
CCallbackBase *m_CallbackBase; \ |
|
225 |
\ |
|
226 |
}; /* class CCallback */ \ |
|
227 | ||
228 |
template<typename TReturn, typename TArgsA = void, typename TArgsB = void, typename TArgsC = void, typename TArgsD = void, typename TArgsE = void, typename TArgsF = void, typename TArgsG = void, typename TDummy = void> |
|
229 |
class CCallback; |
|
230 | ||
231 |
#define NLQT_CALLBACK_ARGS_CLASS CCallback<TReturn, void, void, void, void, void, void, void, void> |
|
232 |
#define NLQT_CALLBACK_ARGS_TYPENAME |
|
233 |
#define NLQT_CALLBACK_ARGS_DECL |
|
234 |
#define NLQT_CALLBACK_ARGS_IMPL |
|
235 |
NLQT_CALLBACK_TEMPLATE |
|
236 |
#undef NLQT_CALLBACK_ARGS_CLASS |
|
237 |
#undef NLQT_CALLBACK_ARGS_TYPENAME |
|
238 |
#undef NLQT_CALLBACK_ARGS_DECL |
|
239 |
#undef NLQT_CALLBACK_ARGS_IMPL |
|
240 | ||
241 |
#define NLQT_CALLBACK_ARGS_CLASS CCallback<TReturn, TArgsA, void, void, void, void, void, void, void> |
|
242 |
#define NLQT_CALLBACK_ARGS_TYPENAME , typename TArgsA |
|
243 |
#define NLQT_CALLBACK_ARGS_DECL TArgsA argsA |
|
244 |
#define NLQT_CALLBACK_ARGS_IMPL argsA |
|
245 |
NLQT_CALLBACK_TEMPLATE |
|
246 |
#undef NLQT_CALLBACK_ARGS_CLASS |
|
247 |
#undef NLQT_CALLBACK_ARGS_TYPENAME |
|
248 |
#undef NLQT_CALLBACK_ARGS_DECL |
|
249 |
#undef NLQT_CALLBACK_ARGS_IMPL |
|
250 | ||
251 |
#define NLQT_CALLBACK_ARGS_CLASS CCallback<TReturn, TArgsA, TArgsB, void, void, void, void, void, void> |
|
252 |
#define NLQT_CALLBACK_ARGS_TYPENAME , typename TArgsA, typename TArgsB |
|
253 |
#define NLQT_CALLBACK_ARGS_DECL TArgsA argsA, TArgsB argsB |
|
254 |
#define NLQT_CALLBACK_ARGS_IMPL argsA, argsB |
|
255 |
NLQT_CALLBACK_TEMPLATE |
|
256 |
#undef NLQT_CALLBACK_ARGS_CLASS |
|
257 |
#undef NLQT_CALLBACK_ARGS_TYPENAME |
|
258 |
#undef NLQT_CALLBACK_ARGS_DECL |
|
259 |
#undef NLQT_CALLBACK_ARGS_IMPL |
|
260 | ||
261 |
#define NLQT_CALLBACK_ARGS_CLASS CCallback<TReturn, TArgsA, TArgsB, TArgsC, void, void, void, void, void> |
|
262 |
#define NLQT_CALLBACK_ARGS_TYPENAME , typename TArgsA, typename TArgsB, typename TArgsC |
|
263 |
#define NLQT_CALLBACK_ARGS_DECL TArgsA argsA, TArgsB argsB, TArgsC argsC |
|
264 |
#define NLQT_CALLBACK_ARGS_IMPL argsA, argsB, argsC |
|
265 |
NLQT_CALLBACK_TEMPLATE |
|
266 |
#undef NLQT_CALLBACK_ARGS_CLASS |
|
267 |
#undef NLQT_CALLBACK_ARGS_TYPENAME |
|
268 |
#undef NLQT_CALLBACK_ARGS_DECL |
|
269 |
#undef NLQT_CALLBACK_ARGS_IMPL |
|
270 | ||
271 |
#define NLQT_CALLBACK_ARGS_CLASS CCallback<TReturn, TArgsA, TArgsB, TArgsC, TArgsD, void, void, void, void> |
|
272 |
#define NLQT_CALLBACK_ARGS_TYPENAME , typename TArgsA, typename TArgsB, typename TArgsC, typename TArgsD |
|
273 |
#define NLQT_CALLBACK_ARGS_DECL TArgsA argsA, TArgsB argsB, TArgsC argsC, TArgsD argsD |
|
274 |
#define NLQT_CALLBACK_ARGS_IMPL argsA, argsB, argsC, argsD |
|
275 |
NLQT_CALLBACK_TEMPLATE |
|
276 |
#undef NLQT_CALLBACK_ARGS_CLASS |
|
277 |
#undef NLQT_CALLBACK_ARGS_TYPENAME |
|
278 |
#undef NLQT_CALLBACK_ARGS_DECL |
|
279 |
#undef NLQT_CALLBACK_ARGS_IMPL |
|
280 | ||
281 |
#define NLQT_CALLBACK_ARGS_CLASS CCallback<TReturn, TArgsA, TArgsB, TArgsC, TArgsD, TArgsE, void, void, void> |
|
282 |
#define NLQT_CALLBACK_ARGS_TYPENAME , typename TArgsA, typename TArgsB, typename TArgsC, typename TArgsD, typename TArgsE |
|
283 |
#define NLQT_CALLBACK_ARGS_DECL TArgsA argsA, TArgsB argsB, TArgsC argsC, TArgsD argsD, TArgsE argsE |
|
284 |
#define NLQT_CALLBACK_ARGS_IMPL argsA, argsB, argsC, argsD, argsE |
|
285 |
NLQT_CALLBACK_TEMPLATE |
|
286 |
#undef NLQT_CALLBACK_ARGS_CLASS |
|
287 |
#undef NLQT_CALLBACK_ARGS_TYPENAME |
|
288 |
#undef NLQT_CALLBACK_ARGS_DECL |
|
289 |
#undef NLQT_CALLBACK_ARGS_IMPL |
|
290 | ||
291 |
#define NLQT_CALLBACK_ARGS_CLASS CCallback<TReturn, TArgsA, TArgsB, TArgsC, TArgsD, TArgsE, TArgsF, void, void> |
|
292 |
#define NLQT_CALLBACK_ARGS_TYPENAME , typename TArgsA, typename TArgsB, typename TArgsC, typename TArgsD, typename TArgsE, typename TArgsF |
|
293 |
#define NLQT_CALLBACK_ARGS_DECL TArgsA argsA, TArgsB argsB, TArgsC argsC, TArgsD argsD, TArgsE argsE, TArgsF argsF |
|
294 |
#define NLQT_CALLBACK_ARGS_IMPL argsA, argsB, argsC, argsD, argsE, argsF |
|
295 |
NLQT_CALLBACK_TEMPLATE |
|
296 |
#undef NLQT_CALLBACK_ARGS_CLASS |
|
297 |
#undef NLQT_CALLBACK_ARGS_TYPENAME |
|
298 |
#undef NLQT_CALLBACK_ARGS_DECL |
|
299 |
#undef NLQT_CALLBACK_ARGS_IMPL |
|
300 | ||
301 |
#define NLQT_CALLBACK_ARGS_CLASS CCallback<TReturn, TArgsA, TArgsB, TArgsC, TArgsD, TArgsE, TArgsF, TArgsG, void> |
|
302 |
#define NLQT_CALLBACK_ARGS_TYPENAME , typename TArgsA, typename TArgsB, typename TArgsC, typename TArgsD, typename TArgsE, typename TArgsF, typename TArgsG |
|
303 |
#define NLQT_CALLBACK_ARGS_DECL TArgsA argsA, TArgsB argsB, TArgsC argsC, TArgsD argsD, TArgsE argsE, TArgsF argsF, TArgsG argsG |
|
304 |
#define NLQT_CALLBACK_ARGS_IMPL argsA, argsB, argsC, argsD, argsE, argsF, argsG |
|
305 |
NLQT_CALLBACK_TEMPLATE |
|
306 |
#undef NLQT_CALLBACK_ARGS_CLASS |
|
307 |
#undef NLQT_CALLBACK_ARGS_TYPENAME |
|
308 |
#undef NLQT_CALLBACK_ARGS_DECL |
|
309 |
#undef NLQT_CALLBACK_ARGS_IMPL |
|
310 |
#undef NLQT_CALLBACK_ARGS_CLASSNAME |
|
311 | ||
312 |
#undef NLQT_CALLBACK_TEMPLATE |
|
313 | ||
314 |
typedef CCallback<void> CEmptyCallback; |
|
315 | ||
316 |
} /* namespace NLQT */ |
|
317 | ||
318 |
#endif /* #ifndef NLQT_CALLBACK_H */ |
|
319 | ||
320 |
/* end of file */ |
b/code/ryzom/tools/leveldesign/georges_editor_qt/src/configuration.cpp Sun Oct 31 20:26:05 2010 +0100 | ||
---|---|---|
1 |
/* |
|
2 |
Georges Editor Qt |
|
3 |
Copyright (C) 2010 Adrian Jaekel <aj at elane2k dot com> |
|
4 |
|
|
5 |
This program is free software: you can redistribute it and/or modify |
|
6 |
it under the terms of the GNU General Public License as published by |
|
7 |
the Free Software Foundation, either version 3 of the License, or |
|
8 |
(at your option) any later version. |
|
9 |
|
|
10 |
This program is distributed in the hope that it will be useful, |
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
GNU General Public License for more details. |
|
14 |
|
|
15 |
You should have received a copy of the GNU General Public License |
|
16 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
17 |
|
|
18 |
*/ |
|
19 |
|
|
20 |
#include "configuration.h" |
|
21 |
|
|
22 |
// STL includes |
|
23 |
|
|
24 |
// Qt includes |
|
25 |
#include <QFile> |
|
26 |
|
|
27 |
// NeL includes |
|
28 |
#include <nel/misc/debug.h> |
|
29 |
#include <nel/misc/hierarchical_timer.h> |
|
30 |
#include <nel/misc/config_file.h> |
|
31 |
#include <nel/misc/path.h> |
|
32 |
|
|
33 |
#include "modules.h" |
|
34 |
|
|
35 |
#include <QFile> |
|
36 |
|
|
37 |
using namespace std; |
|
38 |
using namespace NLMISC; |
|
39 |
|
|
40 |
namespace NLQT { |
|
41 |
|
|
42 |
CConfiguration::CConfiguration() |
|
43 |
{ |
|
44 |
|
|
45 |
} |
|
46 |
|
|
47 |
CConfiguration::~CConfiguration() |
|
48 |
{ |
|
49 |
|
|
50 |
} |
|
51 |
|
|
52 |
void CConfiguration::init() |
|
53 |
{ |
|
54 |
// verify data |
|
55 |
nlassert(!ConfigCallbacks.size()); |
|
56 |
|
|
57 |
// load config |
|
58 |
QFile file(NLQT_CONFIG_FILE); |
|
59 |
if (!file.exists()) { |
|
60 |
file.open( QIODevice::WriteOnly | QIODevice::Text ); |
|
61 |
file.write("GraphicsDrivers = { \"OpenGL\", \"Direct3D\" };"); |
|
62 |
file.write("\nSearchPaths = {\"\"};"); |
|
63 |
file.write("\nRemapExtensions = { \"png\", \"tga\" };"); |
|
64 |
file.write("\nBackgroundColor = { 0, 0, 0 };"); |
|
65 |
file.write("\nQtStyle = \"\";"); |
|
66 |
file.write("\nQtPalette = \"\";"); |
|
67 |
file.close(); |
|
68 |
} |
|
69 |
|
|
70 |
try { |
|
71 |
ConfigFile.load(NLQT_CONFIG_FILE); |
|
72 |
} catch(...) { |
|
73 |
} |
|
74 |
|
|
75 |
// setup config file callback |
|
76 |
Modules::config().setCallback("SearchPaths", CConfigCallback(this, &CConfiguration::cfcbSearchPaths)); |
|
77 |
|
|
78 |
} |
|
79 |
|
|
80 |
void CConfiguration::release() |
|
81 |
{ |
|
82 |
Modules::config().dropCallback("SearchPaths"); |
|
83 |
|
|
84 |
// save and release the config file |
|
85 |
if (ConfigFile.exists("SaveConfig") && ConfigFile.getVarPtr("SaveConfig")->asBool()) |
|
86 |
{ |
|
87 |
ConfigFile.save(); |
|
88 |
} |
|
89 |
ConfigFile.clear(); |
|
90 |
|
|
91 |
// release the search paths etc |
|
92 |
CPath::releaseInstance(); |
|
93 |
|
|
94 |
// verify data |
|
95 |
nlassert(!ConfigCallbacks.size()); |
|
96 |
} |
|
97 |
|
|
98 |
void CConfiguration::updateUtilities() |
|
99 |
{ |
|
100 |
//H_AUTO2 |
|
101 |
CConfigFile::checkConfigFiles(); |
|
102 |
} |
|
103 |
|
|
104 |
void CConfiguration::configSearchPaths() |
|
105 |
{ |
|
106 |
cfcbSearchPaths(Modules::config().getConfigFile().getVar("SearchPaths")); |
|
107 |
} |
|
108 |
|
|
109 |
std::string CConfiguration::configLeveldesignPath() |
|
110 |
{ |
|
111 |
std::string path = Modules::config().getValue("LeveldesignPath", QString("").toStdString()); |
|
112 |
cfcbSearchPaths(Modules::config().getConfigFile().getVar("LeveldesignPath")); |
|
113 |
|
|
114 |
return path; |
|
115 |
} |
|
116 |
|
|
117 |
void CConfiguration::configRemapExtensions() |
|
118 |
{ |
|
119 |
CConfigFile::CVar *var; |
|
120 |
var = ConfigFile.getVarPtr("RemapExtensions"); |
|
121 |
uint varsize = var->size(); |
|
122 |
for (uint i = 0; i < varsize; i += 2) |
|
123 |
CPath::remapExtension(var->asString(i), var->asString(i + 1), true); |
|
124 |
} |
|
125 |
|
|
126 |
void CConfiguration::setAndCallback(const std::string &varName, CConfigCallback configCallback) |
|
127 |
{ |
|
128 |
ConfigCallbacks[varName] = configCallback; |
|
129 |
ConfigFile.setCallback(varName, cbConfigCallback); |
|
130 |
configCallback(*ConfigFile.getVarPtr(varName)); |
|
131 |
} |
|
132 |
|
|
133 |
void CConfiguration::setCallback(const std::string &varName, CConfigCallback configCallback) |
|
134 |
{ |
|
135 |
ConfigCallbacks[varName] = configCallback; |
|
136 |
ConfigFile.setCallback(varName, cbConfigCallback); |
|
137 |
} |
|
138 |
|
|
139 |
void CConfiguration::dropCallback(const std::string &varName) |
|
140 |
{ |
|
141 |
ConfigFile.setCallback(varName, NULL); |
|
142 |
ConfigCallbacks.erase(varName); |
|
143 |
} |
|
144 |
|
|
145 |
float CConfiguration::getValue(const string &varName, float defaultValue) |
|
146 |
{ |
|
147 |
if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asFloat(); |
|
148 |
CConfigFile::CVar varToCopy; |
|
149 |
varToCopy.forceAsDouble((double)defaultValue); |
|
150 |
ConfigFile.insertVar(varName, varToCopy); |
|
151 |
return defaultValue; |
|
152 |
} |
|
153 |
|
|
154 |
double CConfiguration::getValue(const string &varName, double defaultValue) |
|
155 |
{ |
|
156 |
if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asDouble(); |
|
157 |
CConfigFile::CVar varToCopy; |
|
158 |
varToCopy.forceAsDouble(defaultValue); |
|
159 |
ConfigFile.insertVar(varName, varToCopy); |
|
160 |
return defaultValue; |
|
161 |
} |
|
162 |
|
|
163 |
int CConfiguration::getValue(const string &varName, int defaultValue) |
|
164 |
{ |
|
165 |
if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asInt(); |
|
166 |
CConfigFile::CVar varToCopy; |
|
167 |
varToCopy.forceAsInt(defaultValue); |
|
168 |
ConfigFile.insertVar(varName, varToCopy); |
|
169 |
return defaultValue; |
|
170 |
} |
|
171 |
|
|
172 |
string CConfiguration::getValue(const string &varName, const string &defaultValue) |
|
173 |
{ |
|
174 |
if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asString(); |
|
175 |
CConfigFile::CVar varToCopy; |
|
176 |
varToCopy.forceAsString(defaultValue); |
|
177 |
ConfigFile.insertVar(varName, varToCopy); |
|
178 |
return defaultValue; |
|
179 |
} |
|
180 |
|
|
181 |
ucstring CConfiguration::getValue(const string &varName, const ucstring &defaultValue) |
|
182 |
{ |
|
183 |
if (ConfigFile.exists(varName)) return ucstring::makeFromUtf8(ConfigFile.getVar(varName).asString()); |
|
184 |
CConfigFile::CVar varToCopy; |
|
185 |
varToCopy.forceAsString(defaultValue.toUtf8()); |
|
186 |
ConfigFile.insertVar(varName, varToCopy); |
|
187 |
return defaultValue; |
|
188 |
} |
|
189 |
|
|
190 |
bool CConfiguration::getValue(const string &varName, bool defaultValue) |
|
191 |
{ |
|
192 |
if (ConfigFile.exists(varName)) return ConfigFile.getVar(varName).asBool(); |
|
193 |
CConfigFile::CVar varToCopy; |
|
194 |
varToCopy.forceAsInt(defaultValue ? 1 : 0); |
|
195 |
ConfigFile.insertVar(varName, varToCopy); |
|
196 |
return defaultValue; |
|
197 |
} |
|
198 |
|
|
199 |
CRGBA CConfiguration::getValue(const string &varName, const CRGBA &defaultValue) |
|
200 |
{ |
|
201 |
if (ConfigFile.exists(varName)) |
|
202 |
{ |
|
203 |
return getValue(ConfigFile.getVar(varName), defaultValue); |
|
204 |
} |
|
205 |
else |
|
206 |
{ |
|
207 |
// create a new value only if one doesn't exist |
|
208 |
CConfigFile::CVar varToCopy; |
|
209 |
varToCopy.forceAsInt(defaultValue.R); |
|
210 |
varToCopy.setAsInt(defaultValue.G, 1); |
|
211 |
varToCopy.setAsInt(defaultValue.B, 2); |
|
212 |
varToCopy.setAsInt(defaultValue.A, 3); |
|
213 |
ConfigFile.insertVar(varName, varToCopy); |
|
214 |
} |
|
215 |
return defaultValue; |
|
216 |
} |
|
217 |
|
|
218 |
CRGBA CConfiguration::getValue(const CConfigFile::CVar &var, const CRGBA &defaultValue) |
|
219 |
{ |
|
220 |
if (var.size() >= 3) |
|
221 |
{ |
|
222 |
if (var.size() > 4) nlwarning("RGBA value in config value '%s' is too long, ignoring unused values"); |
|
223 |
return CRGBA((uint8)var.asInt(0), (uint8)var.asInt(1), (uint8)var.asInt(2), var.size() >= 4 ? (uint8)var.asInt(3) : 255); |
|
224 |
} |
|
225 |
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); |
|
226 |
return defaultValue; |
|
227 |
} |
|
228 |
|
|
229 |
void CConfiguration::cbConfigCallback(NLMISC::CConfigFile::CVar &var) |
|
230 |
{ |
|
231 |
Modules::config().ConfigCallbacks[var.Name](var); |
|
232 |
} |
|
233 |
|
|
234 |
void CConfiguration::cfcbSearchPaths(NLMISC::CConfigFile::CVar &var) |
|
235 |
{ |
|
236 |
uint varsize = var.size(); |
|
237 |
//CPath::clearMap(); |
|
238 |
for (uint i = 0; i < varsize; ++i) |
|
239 |
CPath::addSearchPath(var.asString(i), true, false); |
|
240 |
} |
|
241 |
|
|
242 |
} /* namespace NLQT */ |
b/code/ryzom/tools/leveldesign/georges_editor_qt/src/configuration.h Sun Oct 31 20:26:05 2010 +0100 | ||
---|---|---|
1 |
/* |
|
2 |
Georges Editor Qt |
|
3 |
Copyright (C) 2010 Adrian Jaekel <aj at elane2k dot com> |
|
4 |
|
|
5 |
This program is free software: you can redistribute it and/or modify |
|
6 |
it under the terms of the GNU General Public License as published by |
|
7 |
the Free Software Foundation, either version 3 of the License, or |
|
8 |
(at your option) any later version. |
|
9 |
|
|
10 |
This program is distributed in the hope that it will be useful, |
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
GNU General Public License for more details. |
|
14 |
|
|
15 |
You should have received a copy of the GNU General Public License |
|
16 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
17 |
|
|
18 |
*/ |
|
19 |
|
|
20 |
#ifndef CONFIGURATION_H |
|
21 |
#define CONFIGURATION_H |
|
22 |
|
|
23 |
#include <nel/misc/types_nl.h> |
|
24 |
|
|
25 |
// STL includes |
|
26 |
#include <map> |
|
27 |
|
|
28 |
// NeL includes |
|
29 |
#include <nel/misc/config_file.h> |
|
30 |
#include <nel/misc/rgba.h> |
|
31 |
#include <nel/misc/ucstring.h> |
|
32 |
|
|
33 |
// Project includes |
|
34 |
#include "callback.h" |
|
35 |
|
|
36 |
#define NLQT_CONFIG_FILE "georges_editor.cfg" |
|
37 |
|
|
38 |
namespace NLQT { |
|
39 |
|
|
40 |
typedef CCallback<void, NLMISC::CConfigFile::CVar &> CConfigCallback; |
|
41 |
|
|
42 |
/** |
|
43 |
* CConfiguration |
|
44 |
* \brief CConfiguration |
|
45 |
* \date 2010-02-05 15:44GMT |
|
46 |
* \author Jan Boon (Kaetemi) |
|
47 |
*/ |
|
48 |
class CConfiguration |
|
49 |
{ |
|
50 |
public: |
|
51 |
CConfiguration(); |
|
52 |
virtual ~CConfiguration(); |
|
53 |
|
|
54 |
void init(); |
|
55 |
void release(); |
|
56 |
|
|
57 |
void updateUtilities(); |
|
58 |
void configSearchPaths(); |
|
59 |
std::string configLeveldesignPath(); |
|
60 |
void configRemapExtensions(); |
|
61 |
|
|
62 |
void setAndCallback(const std::string &varName, CConfigCallback configCallback); |
|
63 |
void setCallback(const std::string &varName, CConfigCallback configCallback); |
|
64 |
void dropCallback(const std::string &varName); |
|
65 |
|
|
66 |
float getValue(const std::string &varName, float defaultValue); |
|
67 |
double getValue(const std::string &varName, double defaultValue); |
|
68 |
int getValue(const std::string &varName, int defaultValue); |
|
69 |
std::string getValue(const std::string &varName, const std::string &defaultValue); |
|
70 |
ucstring getValue(const std::string &varName, const ucstring &defaultValue); |
|
71 |
bool getValue(const std::string &varName, bool defaultValue); |
|
72 |
NLMISC::CRGBA getValue(const std::string &varName, const NLMISC::CRGBA &defaultValue); |
|
73 |
NLMISC::CRGBA getValue(const NLMISC::CConfigFile::CVar &var, const NLMISC::CRGBA &defaultValue); |
|
74 |
|
|
75 |
inline NLMISC::CConfigFile &getConfigFile() { return ConfigFile; } |
|
76 |
|
|
77 |
private: |
|
78 |
static void cbConfigCallback(NLMISC::CConfigFile::CVar &var); |
|
79 |
|
|
80 |
void cfcbSearchPaths(NLMISC::CConfigFile::CVar &var); |
|
81 |
|
|
82 |
CConfiguration(const CConfiguration &); |
|
83 |
CConfiguration &operator=(const CConfiguration &); |
|
84 |
|
|
85 |
NLMISC::CConfigFile ConfigFile; |
|
86 |
std::map<std::string, CConfigCallback> ConfigCallbacks; |
|
87 |
|
|
88 |
};/* class CConfiguration */ |
|
89 |
|
|
90 |
} /* namespace NLQT */ |
|
91 |
|
|
92 |
#endif // CONFIGURATION_H |
b/code/ryzom/tools/leveldesign/georges_editor_qt/src/entity.cpp Sun Oct 31 20:26:05 2010 +0100 | ||
---|---|---|
1 |
/* |
|
2 |
Georges Editor Qt |
|
3 |
Copyright (C) 2010 Adrian Jaekel <aj at elane2k dot com> |
|
4 | ||
5 |
This program is free software: you can redistribute it and/or modify |
|
6 |
it under the terms of the GNU General Public License as published by |
|
7 |
the Free Software Foundation, either version 3 of the License, or |
|
8 |
(at your option) any later version. |
|
9 | ||
10 |
This program is distributed in the hope that it will be useful, |
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
GNU General Public License for more details. |
|
14 | ||
15 |
You should have received a copy of the GNU General Public License |
|
16 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
17 |
*/ |
|
18 |
|
|
19 |
#include "entity.h" |
|
20 |
|
|
21 |
// NeL includes |
|
22 |
#include <nel/misc/path.h> |
|
23 |
#include <nel/3d/u_camera.h> |
|
24 |
#include <nel/3d/u_driver.h> |
|
25 |
#include <nel/3d/u_text_context.h> |
|
26 |
#include <nel/3d/u_instance.h> |
|
27 |
#include <nel/3d/u_scene.h> |
|
28 |
#include <nel/3d/u_material.h> |
|
29 |
#include <nel/3d/u_landscape.h> |
|
30 |
#include <nel/3d/u_skeleton.h> |
|
31 |
#include <nel/3d/u_animation_set.h> |
|
32 |
#include <nel/3d/u_animation.h> |
|
33 |
#include <nel/3d/u_play_list_manager.h> |
|
34 |
#include <nel/3d/u_play_list.h> |
|
35 |
#include <nel/3d/u_track.h> |
|
36 |
|
|
37 |
// Project includes |
|
38 |
#include "modules.h" |
|
39 |
|
|
40 |
using namespace NLMISC; |
|
41 |
using namespace NL3D; |
|
42 |
|
|
43 |
namespace NLQT { |
|
44 |
|
|
45 |
CSlotInfo& CSlotInfo::operator=(const CSlotInfo & slotInfo) |
|
46 |
{ |
|
47 |
if ( this != &slotInfo) |
|
48 |
{ |
|
49 |
Animation = slotInfo.Animation; |
|
50 |
ClampMode = slotInfo.ClampMode; |
|
51 |
Enable = slotInfo.Enable; |
|
52 |
EndBlend = slotInfo.EndBlend; |
|
53 |
EndTime = slotInfo.EndTime; |
|
54 |
Offset = slotInfo.Offset; |
|
55 |
Skeleton = slotInfo.Skeleton; |
|
56 |
SkeletonInverted = slotInfo.SkeletonInverted; |
|
57 |
Smoothness = slotInfo.Smoothness; |
|
58 |
SpeedFactor = slotInfo.SpeedFactor; |
|
59 |
StartBlend = slotInfo.StartBlend; |
|
60 |
StartTime = slotInfo.StartTime; |
|
61 |
} |
|
62 |
return *this; |
|
63 |
} |
|
64 |
|
|
65 |
CEntity::CEntity(void): |
|
66 |
_Name("<Unknown>"), |
|
67 |
_Instance(NULL), _Skeleton(NULL), |
|
68 |
_PlayList(NULL), _AnimationSet(NULL) |
|
69 |
{ |
|
70 |
} |
|
71 |
|
|
72 |
CEntity::~CEntity(void) |
|
73 |
{ |
|
74 |
} |
|
75 |
|
|
76 |
void CEntity::loadAnimation(std::string &fileName) |
|
77 |
{ |
|
78 |
uint id = _AnimationSet->addAnimation(fileName.c_str(),CFile::getFilenameWithoutExtension(fileName).c_str()); |
|
79 |
_AnimationList.push_back(_AnimationSet->getAnimationName(id)); |
|
80 |
_AnimationSet->build(); |
|
81 |
if (!_Skeleton.empty()) _PlayList->registerTransform(_Skeleton); |
|
82 |
else _PlayList->registerTransform(_Instance); |
|
83 |
} |
|
84 |
|
|
85 |
void CEntity::loadSWT(std::string &fileName) |
|
86 |
{ |
|
87 |
uint id = _AnimationSet->addSkeletonWeight(fileName.c_str(),CFile::getFilenameWithoutExtension(fileName).c_str()); |
|
88 |
_SWTList.push_back(_AnimationSet->getSkeletonWeightName(id)); |
|
89 |
} |
|
90 |
|
|
91 |
void CEntity::addAnimToPlayList(std::string &name) |
|
92 |
{ |
|
93 |
_PlayListAnimation.push_back(name); |
|
94 |
|
|
95 |
_AnimationStatus.EndAnim = this->getPlayListLength(); |
|
96 |
} |
|
97 |
|
|
98 |
void CEntity::removeAnimToPlayList(uint row) |
|
99 |
{ |
|
100 |
if (row < _PlayListAnimation.size()) |
|
101 |
_PlayListAnimation.erase(_PlayListAnimation.begin() + row); |
|
102 |
|
|
103 |
_AnimationStatus.EndAnim = this->getPlayListLength(); |
|
104 |
} |
|
105 |
|
|
106 |
void CEntity::swapAnimToPlayList(uint row1, uint row2) |
|
107 |
{ |
|
108 |
if ((row1 < _PlayListAnimation.size()) && (row2 < _PlayListAnimation.size())) |
|
109 |
std::swap(_PlayListAnimation[row1], _PlayListAnimation[row2]); |
|
110 |
} |
|
111 |
|
|
112 |
void CEntity::playbackAnim(bool play) |
|
113 |
{ |
|
114 |
_AnimationStatus.PlayAnim = play; |
|
115 |
} |
|
116 |
|
|
117 |
void CEntity::reset() |
|
118 |
{ |
|
119 |
_PlayListAnimation.clear(); |
|
120 |
_AnimationList.clear(); |
|
121 |
_SWTList.clear(); |
|
122 |
|
|
123 |
_PlayList->resetAllChannels(); |
|
124 |
} |
|
125 |
|
|
126 |
float CEntity::getPlayListLength() |
|
127 |
{ |
|
128 |
// Accumul all the time |
|
129 |
float time = 0; |
|
130 |
for(size_t i = 0; i < _PlayListAnimation.size(); ++i) |
|
131 |
time += getAnimLength(_PlayListAnimation[i]); |
|
132 |
return time; |
|
133 |
} |
|
134 |
|
|
135 |
float CEntity::getAnimLength(std::string name) |
|
136 |
{ |
|
137 |
uint id = _AnimationSet->getAnimationIdByName(name.c_str()); |
|
138 |
NL3D::UAnimation *anim = _AnimationSet->getAnimation(id); |
|
139 |
return anim->getEndTime() - anim->getBeginTime(); |
|
140 |
} |
|
141 |
|
|
142 |
void CEntity::update(NL3D::TAnimationTime time) |
|
143 |
{ |
|
144 |
this->resetChannel(); |
|
145 |
switch (_AnimationStatus.Mode) |
|
146 |
{ |
|
147 |
case Mode::PlayList: |
|
148 |
animatePlayList(time); |
|
149 |
break; |
|
150 |
case Mode::Mixer: |
|
151 |
animateChannelMixer(); |
|
152 |
break; |
|
153 |
} |
|
154 |
} |
|
155 |
|
|
156 |
|
|
157 |
void CEntity::resetChannel() |
|
158 |
{ |
|
159 |
for(size_t i = 0; i < NL3D::CChannelMixer::NumAnimationSlot; i++) |
|
160 |
_PlayList->setAnimation(i, UPlayList::empty); |
|
161 |
} |
|
162 |
|
|
163 |
void CEntity::animatePlayList(NL3D::TAnimationTime time) |
|
164 |
{ |
|
165 |
if (!_PlayListAnimation.empty()) |
|
166 |
{ |
|
167 |
// Animation index |
|
168 |
uint id = _AnimationSet->getAnimationIdByName(_PlayListAnimation[0].c_str()); |
|
169 |
|
|
170 |
// Try channel AnimationSet |
|
171 |
NL3D::UAnimation *anim = _AnimationSet->getAnimation(id); |
|
172 |
|
|
173 |
// Accumul time |
|
174 |
float startTime = 0; |
|
175 |
float endTime = anim->getEndTime() - anim->getBeginTime(); |
|
176 |
|
|
177 |
uint index = 0; |
|
178 |
while (time >= endTime) |
|
179 |
{ |
|
180 |
index++; |
|
181 |
if (index < _PlayListAnimation.size()) |
|
182 |
{ |
|
183 |
id = _AnimationSet->getAnimationIdByName(_PlayListAnimation[index].c_str()); |
|
184 |
anim = _AnimationSet->getAnimation(id); |
|
185 |
|
|
186 |
// Add start time |
|
187 |
startTime = endTime; |
|
188 |
endTime = startTime + (anim->getEndTime() - anim->getBeginTime()); |
|
189 |
} |
|
190 |
else |
|
191 |
break; |
|
192 |
} |
|
193 |
|
|
194 |
// Time cropped ? |
|
195 |
if (index >= _PlayListAnimation.size()) |
|
196 |
{ |
|
197 |
// Yes |
|
198 |
index--; |
|
199 |
id = _AnimationSet->getAnimationIdByName(_PlayListAnimation[index].c_str()); |
|
200 |
anim = _AnimationSet->getAnimation(id); |
|
201 |
|
|
202 |
// End time for last anim |
|
203 |
startTime = anim->getEndTime() - time; |
|
204 |
} |
|
205 |
else |
|
206 |
{ |
|
207 |
// No |
|
208 |
id = _AnimationSet->getAnimationIdByName(_PlayListAnimation[index].c_str()); |
|
209 |
anim = _AnimationSet->getAnimation(id); |
|
210 |
|
|
211 |
// Final time |
|
212 |
startTime -= anim->getBeginTime(); |
|
213 |
} |
|
214 |
|
|
215 |
// Set the slot |
|
216 |
_PlayList->setAnimation(0, id); |
|
217 |
_PlayList->setTimeOrigin(0, startTime); |
|
218 |
_PlayList->setWeightSmoothness(0, 1.0f); |
|
219 |
_PlayList->setStartWeight(0, 1, 0); |
|
220 |
_PlayList->setEndWeight(0, 1, 1); |
|
221 |
_PlayList->setWrapMode(0, UPlayList::Clamp); |
|
222 |
} |
|
223 |
} |
|
224 |
|
|
225 |
void CEntity::animateChannelMixer() |
|
226 |
{ |
|
227 |
for (uint i = 0; i < NL3D::CChannelMixer::NumAnimationSlot; i++) |
|
228 |
{ |
|
229 |
if (_SlotInfo[i].Enable) |
|
230 |
{ |
|
231 |
// Set the animation |
|
232 |
uint animId = _AnimationSet->getAnimationIdByName(_SlotInfo[i].Animation); |
|
233 |
if (animId == UAnimationSet::NotFound) |
|
234 |
_PlayList->setAnimation(i, UPlayList::empty); |
|
235 |
else |
|
236 |
_PlayList->setAnimation(i, animId); |
|
237 |
|
|
238 |
// Set the skeleton weight |
|
239 |
uint skelId = _AnimationSet->getSkeletonWeightIdByName(_SlotInfo[i].Skeleton); |
|
240 |
if (skelId == UAnimationSet::NotFound) |
|
241 |
_PlayList->setSkeletonWeight(i, UPlayList::empty, false); |
|
242 |
else |
|
243 |
_PlayList->setSkeletonWeight(i, skelId, _SlotInfo[i].SkeletonInverted); |
|
244 |
|
|
245 |
// Set others values |
|
246 |
_PlayList->setTimeOrigin(i, _SlotInfo[i].Offset); |
|
247 |
_PlayList->setSpeedFactor(i, _SlotInfo[i].SpeedFactor); |
|
248 |
_PlayList->setStartWeight(i, _SlotInfo[i].StartBlend, _SlotInfo[i].StartTime); |
|
249 |
_PlayList->setEndWeight(i, _SlotInfo[i].EndBlend, _SlotInfo[i].EndTime); |
|
250 |
_PlayList->setWeightSmoothness(i, _SlotInfo[i].Smoothness); |
|
251 |
|
|
252 |
// Switch between wrap modes |
|
253 |
switch (_SlotInfo[i].ClampMode) |
|
254 |
{ |
|
255 |
case 0: |
|
256 |
_PlayList->setWrapMode (i, UPlayList::Clamp); |
|
257 |
break; |
|
258 |
case 1: |
|
259 |
_PlayList->setWrapMode (i, UPlayList::Repeat); |
|
260 |
break; |
|
261 |
case 2: |
|
262 |
_PlayList->setWrapMode (i, UPlayList::Disable); |
|
263 |
break; |
|
264 |
} |
|
265 |
} |
|
266 |
} |
|
267 |
} |
|
268 |
|
|
269 |
} /* namespace NLQT */ |
b/code/ryzom/tools/leveldesign/georges_editor_qt/src/entity.h Sun Oct 31 20:26:05 2010 +0100 | ||
---|---|---|
1 |
/* |
|
2 |
Georges Editor Qt |
|
3 |
Copyright (C) 2010 Adrian Jaekel <aj at elane2k dot com> |
|
4 |
|
|
5 |
This program is free software: you can redistribute it and/or modify |
|
6 |
it under the terms of the GNU General Public License as published by |
|
7 |
the Free Software Foundation, either version 3 of the License, or |
|
8 |
(at your option) any later version. |
|
9 |
|
|
10 |
This program is distributed in the hope that it will be useful, |
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
GNU General Public License for more details. |
|
14 |
|
|
15 |
You should have received a copy of the GNU General Public License |
|
16 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
17 |
*/ |
|
18 |
|
|
19 |
#ifndef ENTITY_H |
|
20 |
#define ENTITY_H |
|
21 |
|
|
22 |
// STL includes |
|
23 |
#include <map> |
|
24 |
#include <string> |
|
25 |
#include <vector> |
|
26 |
|
|
27 |
// NeL includes |
|
28 |
#include "nel/3d/animation_time.h" |
|
29 |
#include <nel/3d/u_instance.h> |
|
30 |
#include <nel/3d/u_skeleton.h> |
|
31 |
#include "nel/3d/channel_mixer.h" |
|
32 |
|
|
33 |
namespace NL3D { |
|
34 |
class UPlayList; |
|
35 |
class UAnimationSet; |
|
36 |
} |
|
37 |
|
|
38 |
namespace NLQT { |
|
39 |
|
|
40 |
class CSlotInfo |
|
41 |
{ |
|
42 |
public: |
|
43 |
CSlotInfo (): |
|
44 |
Animation("empty"), Skeleton("empty"), |
|
45 |
Offset(0), StartTime(0), EndTime(0), |
|
46 |
StartBlend(1), EndBlend (1), Smoothness(1), |
|
47 |
SpeedFactor(1), ClampMode(0), |
|
48 |
SkeletonInverted(false), |
|
49 |
Enable(true) {} ; |
|
50 |
|
|
51 |
std::string Animation; |
|
52 |
std::string Skeleton; |
|
53 |
float Offset; |
|
54 |
float StartTime; |
|
55 |
float EndTime; |
|
56 |
|
|
57 |
float StartBlend; |
|
58 |
float EndBlend; |
|
59 |
float Smoothness; |
|
60 |
float SpeedFactor; |
|
61 |
sint32 ClampMode; |
|
62 |
bool SkeletonInverted; |
|
63 |
bool Enable; |
|
64 |
|
|
65 |
CSlotInfo &operator=(const CSlotInfo &); |
|
66 |
}; |
|
67 |
|
|
68 |
|
|
69 |
/** |
|
70 |
@class CEntity |
|
71 |
Animated object. Allows you to upload animations for the shape. |
|
72 |
Contains a built-in playlist. Has management and playback Playlists or Mixer. |
|
73 |
*/ |
|
74 |
class CEntity |
|
75 |
{ |
|
76 |
public: |
|
77 |
struct Mode |
|
78 |
{ |
|
79 |
enum List |
|
80 |
{ |
|
81 |
PlayList = 1, |
|
82 |
Mixer |
|
83 |
}; |
|
84 |
}; |
|
85 |
|
|
86 |
// will need for a single or multiple reproduction |
|
87 |
struct SAnimationStatus |
|
88 |
{ |
|
89 |
bool LoopAnim; |
|
90 |
bool PlayAnim; |
|
91 |
float CurrentTimeAnim; |
|
92 |
float StartAnim; |
|
93 |
float EndAnim; |
|
94 |
float SpeedAnim; |
|
95 |
int Mode; |
|
96 |
|
|
97 |
SAnimationStatus(): |
|
98 |
LoopAnim(false), PlayAnim(false), |
|
99 |
CurrentTimeAnim(0), StartAnim(0), |
|
100 |
EndAnim(0), SpeedAnim(1), Mode(Mode::PlayList) {} |
|
101 |
}; |
|
102 |
|
|
103 |
/// Constructor |
|
104 |
CEntity(void); |
|
105 |
|
|
106 |
/// Destructor |
|
107 |
~CEntity(void); |
|
108 |
|
|
109 |
/// Loads a file animations |
|
110 |
/// @param fileName - name animation file |
|
111 |
void loadAnimation(std::string &fileName); |
|
112 |
|
|
113 |
/// Loads a file skeleton weight |
|
114 |
void loadSWT(std::string &fileName); |
|
115 |
|
|
116 |
/// Adds an animation to a playlist |
|
117 |
/// @param name - name loaded animations |
|
118 |
void addAnimToPlayList(std::string &name); |
|
119 |
|
|
120 |
/// Removes the animation from a playlist |
|
121 |
/// @param row - number of animations in the playlist |
|
122 |
void removeAnimToPlayList(uint row); |
|
123 |
|
|
124 |
/// Swaps animations to a playlist |
|
125 |
/// @param row1 - first number of animations in the playlist |
|
126 |
/// @param row2 - second number of animations in the playlist |
|
127 |
void swapAnimToPlayList(uint row1, uint row2); |
|
128 |
|
|
129 |
/// Playback animation |
|
130 |
void playbackAnim(bool play); |
|
131 |
|
|
132 |
/// Reset playlist and animation |
|
133 |
void reset(); |
|
134 |
|
|
135 |
/// Get the total time of animation playlist |
|
136 |
/// @return total time of animation |
|
137 |
float getPlayListLength(); |
|
138 |
|
|
139 |
/// get time length single animation |
|
140 |
float getAnimLength(std::string name); |
|
141 |
|
|
142 |
/// Get slot infomation |
|
143 |
void setSlotInfo(uint num, CSlotInfo& slotInfo) { _SlotInfo[num] = slotInfo; } |
|
144 |
|
|
145 |
/// Set use mode playlist or mixer |
|
146 |
void setMode(int mode) { _AnimationStatus.Mode = mode; } |
|
147 |
|
|
148 |
/// Get information about the current status of playing a playlist |
|
149 |
/// @return struct containing current information playback |
|
150 |
SAnimationStatus& getStatus() { return _AnimationStatus; } |
|
151 |
|
|
152 |
/// Get name entity |
|
153 |
/// @return name entity |
|
154 |
std::string &getName() { return _Name; } |
|
155 |
|
|
156 |
/// Get slot information |
|
157 |
CSlotInfo& getSlotInfo(uint num) { return _SlotInfo[num]; } |
|
158 |
|
|
159 |
/// Get list loaded animations files |
|
160 |
std::vector<std::string>& getAnimationList() { return _AnimationList; } |
|
161 |
|
|
162 |
/// Get playlist animations |
|
163 |
std::vector<std::string>& getPlayListAnimation() { return _PlayListAnimation; } |
|
164 |
|
|
165 |
/// Get list loaded skeleton weight template files |
|
166 |
std::vector<std::string>& getSWTList() { return _SWTList; } |
|
167 |
|
|
168 |
private: |
|
169 |
|
|
170 |
/// Update the animate from the playlist or channel mixer |
|
171 |
/// @param time - current time in second |
|
172 |
void update(NL3D::TAnimationTime time); |
|
173 |
|
|
174 |
void resetChannel(); |
|
175 |
|
|
176 |
/// Update the animate from the playlist |
|
177 |
void animatePlayList(NL3D::TAnimationTime time); |
|
178 |
|
|
179 |
/// Update the animate from the mixer |
|
180 |
void animateChannelMixer(); |
|
181 |
|
|
182 |
// The name of the entity |
|
183 |
std::string _Name; |
|
184 |
|
|
185 |
SAnimationStatus _AnimationStatus; |
|
186 |
|
|
187 |
// The mesh instance associated to this entity |
|
188 |
NL3D::UInstance _Instance; |
|
189 |
|
|
190 |
// The skeleton binded to the instance |
|
191 |
NL3D::USkeleton _Skeleton; |
|
192 |
|
|
193 |
NL3D::UPlayList *_PlayList; |
|
194 |
|
|
195 |
NL3D::UAnimationSet *_AnimationSet; |
|
196 |
|
|
197 |
// Animation input file |
|
198 |
std::vector<std::string> _AnimationList; |
|
199 |
|
|
200 |
// Skeleton weight input file |
|
201 |
std::vector<std::string> _SWTList; |
|
202 |
|
|
203 |
// Play list animation |
|
204 |
std::vector<std::string > _PlayListAnimation; |
|
205 |
|
|
206 |
// Slot info for this object |
|
207 |
CSlotInfo _SlotInfo[NL3D::CChannelMixer::NumAnimationSlot]; |
|
208 |
|
|
209 |
friend class CObjectViewer; |
|
210 |
}; /* class CEntity */ |
|
211 |
|
|
212 |
typedef std::map<std::string, CEntity> CEntities; |
|
213 |
typedef CEntities::iterator EIT; |
|
214 |
|
|
215 |
} /* namespace NLQT */ |
|
216 |
|
|
217 |
#endif // ENTITY_H |
b/code/ryzom/tools/leveldesign/georges_editor_qt/src/filesystem_model.cpp Sun Oct 31 20:26:05 2010 +0100 | ||
---|---|---|
1 |
/* |
|
2 |
Georges Editor Qt |
|
3 |
Copyright (C) 2010 Adrian Jaekel <aj at elane2k dot com> |
|
4 |
|
|
5 |
This program is free software: you can redistribute it and/or modify |
|
6 |
it under the terms of the GNU General Public License as published by |
|
7 |
the Free Software Foundation, either version 3 of the License, or |
|
8 |
(at your option) any later version. |
|
9 |
|
|
10 |
This program is distributed in the hope that it will be useful, |
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
GNU General Public License for more details. |
|
14 |
|
|
15 |
You should have received a copy of the GNU General Public License |
|
16 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
17 |
*/ |
|
18 |
|
|
19 |
#include "filesystem_model.h" |
|
20 |
|
|
21 |
#include <QtGui/QApplication> |
|
22 |
#include <QtGui/QStyle> |
|
23 |
|
|
24 |
namespace NLQT { |
|
25 |
|
|
26 |
CFileSystemModel::CFileSystemModel(QString ldPath, QObject *parent) |
|
27 |
: QFileSystemModel(parent), |
|
28 |
_ldPath(ldPath){ |
|
29 |
|
|
30 |
} |
|
31 |
CFileSystemModel::~CFileSystemModel() { |
|
32 |
|
|
33 |
} |
|
34 |
|
|
35 |
QVariant CFileSystemModel::data(const QModelIndex& index, int role) const { |
|
36 |
|
|
37 |
if (role == Qt::DecorationRole) { |
|
38 |
if (_ldPath.isEmpty()) |
|
39 |
return QVariant(); |
|
40 |
if (isDir(index)) |
|
41 |
return QApplication::style()->standardIcon(QStyle::SP_DirIcon); |
|
42 |
} |
|
43 |
if (_ldPath.isEmpty() && role == Qt::DisplayRole) { |
|
44 |
if (index.parent().isValid()) |
|
45 |
return QVariant(); |
|
46 |
return QString("Set a correct leveldesign path ..."); |
|
47 |
} |
|
48 |
return QFileSystemModel::data(index, role); |
|
49 |
} |
|
50 |
|
|
51 |
int CFileSystemModel::columnCount(const QModelIndex &/*parent*/) const |
|
52 |
{ |
|
53 |
return 1; |
|
54 |
} |
|
55 |
|
|
56 |
int CFileSystemModel::rowCount(const QModelIndex &parent) const |
|
57 |
{ |
|
58 |
if (_ldPath.isEmpty()) { |
|
59 |
if(parent.isValid()) { |
|
60 |
return 0; |
|
61 |
} else { |
|
62 |
return qMin(QFileSystemModel::rowCount(parent),1); |
|
63 |
} |
|
64 |
} |
|
65 |
return QFileSystemModel::rowCount(parent); |
|
66 |
} |
|
67 |
|
|
68 |
} /* namespace NLQT */ |
|
69 |
|
|
70 |
/* end of file */ |
b/code/ryzom/tools/leveldesign/georges_editor_qt/src/filesystem_model.h Sun Oct 31 20:26:05 2010 +0100 | ||
---|---|---|
1 |
/* |
|
2 |
Georges Editor Qt |
|
3 |
Copyright (C) 2010 Adrian Jaekel <aj at elane2k dot com> |
|
4 |
|
|
5 |
This program is free software: you can redistribute it and/or modify |
|
6 |
it under the terms of the GNU General Public License as published by |
|
7 |
the Free Software Foundation, either version 3 of the License, or |
|
8 |
(at your option) any later version. |
|
9 |
|
|
10 |
This program is distributed in the hope that it will be useful, |
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
GNU General Public License for more details. |
|
14 |
|
|
15 |
You should have received a copy of the GNU General Public License |
|
16 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |