src/misc.h

Sun, 08 Sep 2013 22:57:06 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Sun, 08 Sep 2013 22:57:06 +0300
changeset 34
cf0dfddf30f7
parent 30
6b82f6a3ad53
child 37
c82a86ea87be
permissions
-rw-r--r--

tag 0.1 beta

13
9bdddd2ccde6 now with 3691% extra legalese!
Teemu Piippo <crimsondusk64@gmail.com>
parents: 10
diff changeset
1 /*
30
6b82f6a3ad53 renamed the project to ZCinema
Teemu Piippo <crimsondusk64@gmail.com>
parents: 25
diff changeset
2 * ZCinema: Zandronum demo launcher
13
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
30
6b82f6a3ad53 renamed the project to ZCinema
Teemu Piippo <crimsondusk64@gmail.com>
parents: 25
diff changeset
19 #ifndef ZCINEMA_MISC_H
6b82f6a3ad53 renamed the project to ZCinema
Teemu Piippo <crimsondusk64@gmail.com>
parents: 25
diff changeset
20 #define ZCINEMA_MISC_H
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 #include "types.h"
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23
10
bc1414343e19 Overhauled the way versions are handled, it's all kept dynamically now.
Teemu Piippo <crimsondusk64@gmail.com>
parents: 8
diff changeset
24 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
25 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
26 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
27 void addVersion (str name, bool isRelease, str binaryPath);
25
256bb5c6b77f Added a version data editor
Teemu Piippo <crimsondusk64@gmail.com>
parents: 20
diff changeset
28 bool confirm (str text);
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29
20
a5457405cc9b Use the cfg:: namespace system I made up a while ago instead of using QSettings directly, it's unsafe
Teemu Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
30 QList<QVariant> getVersions();
a5457405cc9b Use the cfg:: namespace system I made up a while ago instead of using QSettings directly, it's unsafe
Teemu Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
31
6
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 // -----------------------------------------------------------------------------
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 // Templated clamp
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 template<class T> static inline T clamp (T a, T min, T max) {
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
35 return (a > max) ? max : (a < min) ? min : a;
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 // Templated minimum
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 template<class T> static inline T min (T a, T b) {
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40 return (a < b) ? a : b;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43 // Templated maximum
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 template<class T> static inline T max (T a, T b) {
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
45 return (a > b) ? a : b;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
47
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
48 // Templated absolute value
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
49 template<class T> static inline T abs (T a) {
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50 return (a >= 0) ? a : -a;
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51 }
67b6ef6917ba Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52
30
6b82f6a3ad53 renamed the project to ZCinema
Teemu Piippo <crimsondusk64@gmail.com>
parents: 25
diff changeset
53 #endif // ZCINEMA_MISC_H

mercurial