Sun, 11 Aug 2013 03:47:58 +0300
made it compile on windows/qt5
13
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
1 | /* |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
2 | * ZanDemo: Zandronum demo launcher |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
3 | * Copyright (C) 2013 Santeri Piippo |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
4 | * |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
8 | * (at your option) any later version. |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
9 | * |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
13 | * GNU General Public License for more details. |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
14 | * |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
17 | */ |
9bdddd2ccde6
now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents:
10
diff
changeset
|
18 | |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #include "misc.h" |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
21 | uint32 makeByteID (uint8 a, uint8 b, uint8 c, uint8 d) { |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
22 | return a | (b << 8) | (c << 16) | (d << 24); |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
23 | } |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
24 | |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
25 | // ============================================================================= |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
26 | // ----------------------------------------------------------------------------- |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
27 | str binaryConfigName (str ver) { |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
28 | return fmt ("binaries/%1", ver); |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
29 | } |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
30 | |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
31 | // ============================================================================= |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
32 | // ----------------------------------------------------------------------------- |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
33 | list<var> getVersionsList() { |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
34 | QSettings cfg; |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
35 | return cfg.value ("binarynames", list<var>()).toList(); |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
36 | } |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
37 | |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
38 | // ============================================================================= |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
39 | // ----------------------------------------------------------------------------- |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
40 | list<var> getReleasesList() { |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
41 | QSettings cfg; |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
42 | return cfg.value ("releasenames", list<var>()).toList(); |
8
e8f645d9f28f
Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
43 | } |
e8f645d9f28f
Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
44 | |
e8f645d9f28f
Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
45 | // ============================================================================= |
e8f645d9f28f
Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
46 | // ----------------------------------------------------------------------------- |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
47 | void addVersion (str name, bool isRelease, str binaryPath) { |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
48 | QSettings cfg; |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
49 | list<var> versions = getVersionsList(); |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
50 | versions << var (name); |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
51 | cfg.setValue ("binarynames", versions); |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
52 | cfg.setValue (binaryConfigName (name), binaryPath); |
8
e8f645d9f28f
Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
53 | |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
54 | if (isRelease) { |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
55 | versions = getReleasesList(); |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
56 | versions << var (name); |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
57 | cfg.setValue ("releasenames", versions); |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
58 | } |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
59 | |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
60 | cfg.sync(); |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
61 | } |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
62 | |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
63 | // ============================================================================= |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
64 | // ----------------------------------------------------------------------------- |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
65 | str basename (str path) { |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
66 | long lastpos = path.lastIndexOf ("/"); |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
67 | |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
68 | if (lastpos != -1) |
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
69 | return path.mid (lastpos + 1); |
8
e8f645d9f28f
Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
70 | |
e8f645d9f28f
Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
71 | return path; |
10
bc1414343e19
Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents:
8
diff
changeset
|
72 | } |