Linux multi-monitor fullscreen support
[ryzomcore.git] / nel / tools / misc / disp_sheet_id / main.cpp
blobc7fe6f78261634d8c08659c32c3d31fec15b934c
1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "nel/misc/types_nl.h"
18 #ifdef NL_OS_WINDOWS
19 #include <conio.h>
20 #else
21 #include <stdio.h>
22 #include <termios.h>
23 #include <unistd.h>
25 /// This is our Unix-variant to the Windows _getch function.
26 int _getch()
28 struct termios oldt, newt;
29 int ch;
30 tcgetattr(STDIN_FILENO, &oldt);
31 newt=oldt;
32 newt.c_lflag &= ~(ICANON | ECHO);
33 tcsetattr(STDIN_FILENO, TCSANOW, &newt);
34 ch = getchar();
35 tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
36 return ch;
39 #endif
41 #include "nel/misc/path.h"
42 #include "nel/misc/sheet_id.h"
43 #include "nel/misc/common.h"
44 #include <vector>
47 using namespace std;
48 using namespace NLMISC;
52 // ***************************************************************************
53 class CPred
55 public:
56 bool operator()(const CSheetId &a, const CSheetId &b)
58 return a.toString()<b.toString();
62 // ***************************************************************************
63 /// Dispaly info cmd line
64 int main(int argc, const char *argv[])
66 if(argc<2)
68 puts("Usage: disp_sheet_id path");
69 puts(" display a raw list of file names sorted by name with their sheet_id associated");
70 puts(" output in sheetid.txt");
71 puts("Press any key");
72 _getch();
73 return -1;
76 NLMISC::CApplicationContext appContext;
78 CPath::addSearchPath(argv[1]);
80 CSheetId::init(false);
82 std::vector<CSheetId> sheets;
83 CSheetId::buildIdVector(sheets);
85 // sort by name
86 CPred Pred;
87 sort(sheets.begin(), sheets.end(), Pred);
89 // display.
90 FILE *out= nlfopen("sheetid.txt", "wb");
91 if(out)
93 for(uint i=0;i<sheets.size();i++)
95 fprintf(out, "%s : %d\n", sheets[i].toString().c_str(), sheets[i].asInt());
97 fclose(out);
100 return 0;