Linux multi-monitor fullscreen support
[ryzomcore.git] / tool / visual_studio_macros / nevrax_macros_98.dsm
blob624eef69132da147cb3464484855c58a12b35900
1 ' nevrax_macros_98.dsm\r
2 '\r
3 ' Copyright (C) 2000-2005 Nevrax. All rights reserved.\r
4 '\r
5 ' The redistribution, use and modification in source or binary forms of\r
6 ' this software is subject to the conditions set forth in the copyright\r
7 ' document ("Copyright") included with this distribution.\r
8 '\r
9 '------------------------------------------------------------------------------\r
10 ' FILE DESCRIPTION: Nevrax Visual Studio macro file\r
11 ' when Scripting.FileSystemObject cannot be instanciated\r
12 ' $Id: nevrax_macros_98.dsm,v 1.21 2005/01/03 14:46:02 cado Exp $\r
13 '------------------------------------------------------------------------------\r
16 ' *** NevraxNewClass ***\r
19 ' NevraxInsertFileHeader\r
20 ' Utility Sub for NevraxNewClass()\r
21 ' Author : Olivier Cado\r
22 Sub NevraxInsertFileHeader( filename, productname )\r
23         ActiveDocument.Selection.StartOfDocument\r
24         ActiveDocument.Selection = _\r
25                 "/** \file " + filename + vbLf + _\r
26                 " * <File description>" + vbLf + _\r
27                 " *" + vbLf + _\r
28                 " */" + vbLf + vbLf\r
29 End Sub\r
32 Function IsUpCase( str )\r
33         IsUpcase = ( str = Ucase(str) )\r
34 End Function\r
37 ' NevraxClassNameToFileName\r
38 ' Utility Function for NevraxNewClass()\r
39 ' 1/08/2000 : now analyses the first character\r
40 ' Author : Olivier Cado\r
41 Function NevraxClassNameToFileName( classname )\r
42         beginningpos = 1\r
43         first = left(classname,1)\r
44         if ((first="C") or (first="E") or (first="I")) then\r
45                 if len(classname)>1 then\r
46                         if IsUpCase( mid(classname,2,1) ) then\r
47                                 beginningpos = 2\r
48                         end if\r
49                 end if\r
50         end if\r
51         filename = lcase(mid(classname,beginningpos,1))\r
52         for i = beginningpos+1 to len( classname )\r
53                 charact = mid(classname,i,1 )\r
54                 if IsUpCase( charact ) then\r
55                         if i+1 <= len( classname ) then\r
56                                 if not IsUpCase( mid(classname,i+1,1) ) then\r
57                                         filename = filename + "_"\r
58                                 end if\r
59                         else\r
60                                 filename = filename + "_"\r
61                         end if\r
62                 end if\r
63                 filename = filename + lcase(charact)\r
64         next\r
65         NevraxClassNameToFileName = filename\r
66 End Function\r
69 ' NevraxProjectOpen\r
70 ' Utility Function for NevraxNewClass()\r
71 ' Author : Olivier Cado\r
72 Function NevraxProjectOpen( projname )\r
73         found = 0\r
74         dim proj\r
75         for i = 1 to Projects.Count\r
76                 if Projects(i).Name = projname then\r
77                         found = i\r
78                         exit for\r
79                 end if\r
80         next\r
81         NevraxProjectOpen = found\r
82 End Function\r
85 ' Global variable\r
86 Dim CurrentDirectoryName\r
87 Dim CurrentProgrammerName\r
90 ' NevraxNewClass\r
91 ' DESCRIPTION: Wizard for new class creation\r
92 ' 1/08/2000 : added input boxes for directories\r
93 ' 7/09/2000 : added programmer's name dialog and test for file existence (dirs & files)\r
94 ' 18/09/2000 : namespace, programmer's name saved in a file, file added to the right project\r
95 ' 12/10/2000 : modified output\r
96 ' Weird things :\r
97 ' - CreateObject( Scripting.FileSystemObject ) doesn't work on Win 98, but on 2000\r
98 ' - Projects.Item( string ) doesn't work. Using number instead\r
99 ' Author : Olivier Cado\r
100 Sub NevraxNewClass()\r
102         ' ** Input class name and file name\r
103         ClassName = InputBox( "Bienvenue dans l'assistant de création de classe." + vbLf + vbLf + _\r
104                 "Nom de la nouvelle classe :", "Nouvelle classe (1)" )\r
105         if ClassName = "" then\r
106                 Exit Sub\r
107         end if\r
108         Filename = NevraxClassNameToFileName( ClassName )\r
109         ' Warning: do not enter an existing filename, or MsDev will crash when attempting to save\r
110         Filename = InputBox( "Nom de fichier sans l'extension:", "Nouvelle classe (2)", Filename )\r
111         if Filename = "" then\r
112                 Exit Sub\r
113         end if\r
114         UniqueName = "NL_" + UCase( Filename ) + "_H"\r
115         HFilename = Filename + ".h"\r
116         CppFilename = Filename + ".cpp"\r
118         ' ** Directories (NB: input boxes cannot be canceled in this part)\r
119         SrcDirectory = "R:\code\nel\src"\r
120         SrcDirectory = InputBox( "Répertoire racine (existant) des sources (.cpp)" + vbLf + "(entrer . pour un projet hors-NeL) :","Nouvelle classe (3)", SrcDirectory )\r
121         if SrcDirectory <> "" then\r
122                 if right(SrcDirectory,1)<>"\" then\r
123                         SrcDirectory = SrcDirectory + "\"\r
124                 end if\r
125         else\r
126                 IncDirectory = ""\r
127         end if\r
128         IncDirectory = "R:\code\nel\include\nel"\r
129         IncDirectory = InputBox( "Répertoire racine (existant) des include (.h)" + vbLf + "(ex: R:\code\nel\include\nel pour NeL ; chaîne vide pour le même répertoire que les fichiers source ) :","Nouvelle classe (4)", IncDirectory )\r
130         if IncDirectory = "" then\r
131                 IncDirectory = SrcDirectory\r
132         else\r
133                 if (right(IncDirectory,1)<>"\") then\r
134                         IncDirectory = IncDirectory + "\"\r
135                 end if\r
136         end if\r
137         CurrentDirectoryName = InputBox( "Nom du répertoire de travail (ex: misc)" + vbLf + "(existant dans " + SrcDirectory + _\r
138                 " et dans " + IncDirectory + ")" + vbLf + "Ce nom restera mémorisé" + vbLf + "(chaîne vide pour pour un projet hors-NeL).", "Nouvelle classe (5)", CurrentDirectoryName )\r
139         if CurrentDirectoryName<>"" then\r
140                 CurrentDirectoryDir = CurrentDirectoryName + "\"\r
141                 Namesp = "NL" + ucase(CurrentDirectoryName)\r
142         end if\r
143         If InStr( IncDirectory, "nel" ) then\r
144                 ProdName = "NEL"\r
145                 ShortIncDir = "nel/" + CurrentDirectoryName + "/"\r
146         else\r
147                 ProdName = "NeL Network Services" ' not Distributed Toolkit Components System anymore\r
148         end if\r
150         FinalCPPdir = SrcDirectory + CurrentDirectoryDir\r
151         FinalHdir = IncDirectory + CurrentDirectoryDir\r
152         FinalCPPfilename = FinalCPPdir + CppFilename\r
153         FinalHfilename = FinalHdir + HFilename\r
155         ' ** Check for open project\r
156         if CurrentDirectoryName=""      then\r
157                 AddToProject = 0\r
158         else\r
159                 AddToProject = NevraxProjectOpen( CurrentDirectoryName )\r
160         end if\r
162         ' ** Programmer's name\r
163         ConfigFileName = "R:\code\tool\visual_studio_macros\nevrax_new_class.cfg"\r
164         if CurrentProgrammerName = "" then\r
165                 CurrentProgrammerName = "Fox Mulder"\r
166         end if\r
167         CurrentProgrammerName = InputBox( "Votre prénom et votre nom (qui restera mémorisé dans un fichier) :", "Nouvelle classe (6)", CurrentProgrammerName )\r
168         if CurrentProgrammerName = "" then\r
169                 Exit Sub\r
170         end if\r
172         ' ** Input ancestor class name and file name\r
173         NoAncestor = "NO BASE CLASS"\r
174         AncClassName = InputBox( "Nom de la classe de base :", "Nouvelle classe (7)", NoAncestor )\r
175         if AncClassName = "" then\r
176                 Exit Sub\r
177         else\r
178                 if AncClassName = NoAncestor then\r
179                         AncClassName = ""\r
180                 else\r
181                         AncFilename = InputBox( "Nom de fichier (avec chemin) sans l'extension (ex: nel/misc/toto) :", "Nouvelle classe (8)" )\r
182                         if AncFileName = "" then\r
183                                 Exit Sub\r
184                         end if\r
185                         AncHFilename = AncFilename + ".h"\r
186                 end if\r
187         end if\r
189         ' ** Now write .cpp\r
190         Documents.Add( "Text" )\r
191         NevraxInsertFileHeader CppFilename, ProdName\r
192         ActiveDocument.Selection = vbLf + "#include """ + ShortIncDir + HFilename + """" + vbLf + vbLf + vbLf\r
193         if ( CurrentDirectoryName<>"" ) then\r
194                 ActiveDocument.Selection = "namespace " + Namesp + " {" + vbLf + vbLf + vbLf\r
195         end if\r
196         ActiveDocument.Selection = "/*" + vbLf + _\r
197                 " * Constructor" + vbLf + _\r
198                 " */" + vbLf + _\r
199                 ClassName + "::" + ClassName + "()" + vbLf + _\r
200                 "{" + vbLf + _\r
201                 "}" + vbLf + vbLf + vbLf\r
202         if ( CurrentDirectoryName<>"" ) then\r
203                 ActiveDocument.Selection = "} // " + Namesp + vbLf\r
204         end if\r
205         ' Warning: ActiveDocument.Save raises an "Unknown error" if the directory does not exist"\r
206         ActiveDocument.Save( FinalCPPfilename )\r
207         if AddToProject=0 then\r
208                 ActiveProject.AddFile( FinalCPPfilename )\r
209         else\r
210                 Projects(AddToProject).AddFile( FinalCPPfilename )\r
211         end if\r
213         ' ** Now write .h\r
214         Documents.Add( "Text" )\r
215         NevraxInsertFileHeader HFilename, ProdName\r
216         ActiveDocument.Selection = vbLf + "#ifndef " + UniqueName + vbLf + _\r
217                 "#define " + UniqueName + vbLf + vbLf\r
218         ActiveDocument.Selection = "#include ""nel/misc/types_nl.h""" + vbLf\r
219         if AncClassName <> "" then\r
220                 ActiveDocument.Selection = "#include """ + AncHFilename + """" + vbLf\r
221         end if\r
222         if ( CurrentDirectoryName<>"" ) then\r
223                 ActiveDocument.Selection = vbLf + vbLf + "namespace " + Namesp + " {" + vbLf\r
224         end if\r
225         ActiveDocument.Selection = vbLf + vbLf + _\r
226                 "/**" + vbLf + _\r
227                 " * <Class description>" + vbLf + _\r
228                 " * \author " + CurrentProgrammerName + vbLf + _\r
229                 " * \author Nevrax France" + vbLf + _\r
230                 " * \date 2005" + vbLf + _\r
231                 " */" + vbLf + _\r
232                 "class " + ClassName\r
233         if AncClassName <> "" then\r
234                 ActiveDocument.Selection = " : public " + AncClassName\r
235         end if\r
236         ActiveDocument.Selection = vbLf + _\r
237                 "{" + vbLf + _\r
238                 "public:" + vbLf + vbLf + _\r
239                 "       /// Constructor" + vbLf + _\r
240                 "       " + ClassName + "();" + vbLf + vbLf + _\r
241                 "};" + vbLf + vbLf\r
242         if ( CurrentDirectoryName<>"" ) then\r
243                 ActiveDocument.Selection = vbLf + "} // " + Namesp + vbLf + vbLf\r
244         end if\r
245         ActiveDocument.Selection = vbLf + "#endif // " + UniqueName + vbLf\r
246         ActiveDocument.Selection = vbLf + "/* End of " + HFilename + " */" + vbLf\r
247         ' Warning: ActiveDocument.Save raises an "Unknown error" if the directory does not exist"\r
248         ActiveDocument.Save( FinalHfilename )\r
249         if AddToProject=0 then\r
250                 ActiveProject.AddFile( FinalHfilename )\r
251         else\r
252                 Projects(AddToProject).AddFile( FinalHfilename )\r
253         end if\r
255 End Sub\r
257 ' *** End of NevraxNewClass ***\r
260 ' ** NevraxToggleHCPP\r
262 ' NevraxToggleHCPP\r
263 ' DESCRIPTION: Opens the .cpp or .h file (toggles) for the current document.\r
264 ' NOTE: Can be used in conjunction with NevraxNewClass (NevraxToggleHCPP uses the CurrentDirectoryName global variable)\r
265 ' TIP: Bind this macro to Ctrl+<\r
266 ' Author : Olivier Cado\r
267 Sub NevraxToggleHCPP()\r
269         ' ** Get filename extension and ensure it is .h or .cpp\r
270         ActFilename = ActiveDocument.FullName\r
271         pos = InstrRev( ActFilename, "." )\r
272         if ( pos <> 0 ) then\r
273                 Ext = mid(ActFilename,pos)              \r
274                 if (Ext<>".h" and Ext<>".cpp") then\r
275                         msgbox( "Error : Active document is not a .cpp or .h file" )\r
276                         exit sub\r
277                 end if\r
278         else\r
279                 exit sub\r
280         end if\r
281         \r
282         ' ** Build the alternative filename\r
283         NewFilename = ""\r
284         if (InStr(ActFilename,"nel\src\")<>0) or (InStr(ActFilename,"nel\include\")<>0) then\r
285                 if Ext = ".h" then\r
286                         NewFilename = "R:\code\nel\src\"\r
287                 else\r
288                         NewFilename = "R:\code\nel\include\nel\"\r
289                 end if\r
290                 ' Take the module name (the word between the two last backslashes)\r
291                 DirectoryName = left( ActFilename, InstrRev(ActFilename,"\")-1 )\r
292                 DirectoryName = mid( DirectoryName, InstrRev(DirectoryName, "\")+1 )\r
293                 ' Add the rest of the path\r
294                 NewFilename = NewFilename + DirectoryName + "\" \r
295                 ShortFilenameDot = mid( ActFilename, InstrRev(ActFilename,"\")+1 )\r
296         else\r
297                 ShortFilenameDot = ActFilename\r
298         end if\r
299         ShortFilenameDot = left( ShortFilenameDot, Instr(ShortFilenameDot,".") )\r
300         if Ext=".h" then\r
301                 Ext = "cpp"\r
302         else\r
303                 Ext = "h"\r
304         end if\r
305         NewFilename = NewFilename + ShortFilenameDot + Ext\r
306  \r
307         ' ** Open the alternative file\r
308         Documents.Open( NewFilename )\r
309 End Sub\r