Wed, 10 Apr 2013 01:27:06 +0300
Added icons for undo and redo
48
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | /* |
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | * Copyright (C) 2013 Santeri `arezey` Piippo |
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | * |
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | * |
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | * |
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | */ |
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | |
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | #include "common.h" |
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | #include "colors.h" |
72
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
21 | #include "file.h" |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
22 | #include "misc.h" |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
23 | #include <qcolor.h> |
48
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | |
68
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
25 | static color* g_LDColors[MAX_COLORS]; |
48
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | static bool g_bColorsInit = false; |
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | |
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | void initColors () { |
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | if (g_bColorsInit) |
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | return; |
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | |
72
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
32 | // Always make sure there's 16 and 24 available. They're special like that. |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
33 | color* maincolor = new color; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
34 | maincolor->zColorString = "#AAAAAA"; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
35 | maincolor->qColor = maincolor->zColorString.chars(); |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
36 | maincolor->qEdge = "#000000"; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
37 | g_LDColors[dMainColor] = maincolor; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
38 | |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
39 | color* edgecolor = new color; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
40 | edgecolor->zColorString = "#000000"; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
41 | edgecolor->qEdge = edgecolor->qColor = edgecolor->zColorString.chars(); |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
42 | g_LDColors[dEdgeColor] = edgecolor; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
43 | |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
44 | parseLDConfig (); |
48
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
45 | |
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
46 | g_bColorsInit = true; |
68
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
47 | } |
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
48 | |
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
49 | // ============================================================================= |
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
50 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
51 | // ============================================================================= |
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
52 | color* getColor (short dColorNum) { |
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
53 | // Check bounds |
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
54 | if (dColorNum < 0 || dColorNum >= MAX_COLORS) |
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
55 | return nullptr; |
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
56 | |
c637b172d565
Further fixes to bad color handling. Allow main color be represented with arbitrary transparency.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
67
diff
changeset
|
57 | return g_LDColors[dColorNum]; |
72
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
58 | } |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
59 | |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
60 | // ============================================================================= |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
61 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
62 | // ============================================================================= |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
63 | static bool parseLDConfigTag (stringparser& pars, char const* sTag, str& zVal) { |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
64 | short dPos; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
65 | if (!pars.findToken (dPos, sTag, 1)) |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
66 | return false; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
67 | |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
68 | return pars.getToken (zVal, dPos + 1); |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
69 | } |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
70 | |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
71 | // ============================================================================= |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
72 | // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
73 | // ============================================================================= |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
74 | void parseLDConfig () { |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
75 | FILE* fp = openLDrawFile ("LDConfig.ldr", false); |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
76 | |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
77 | if (!fp) |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
78 | return; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
79 | |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
80 | // Even though LDConfig.ldr is technically an LDraw file, parsing it as one |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
81 | // would be overkill by any standard. |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
82 | char line[1024]; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
83 | while (fgets (line, sizeof line, fp)) { |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
84 | if (strlen (line) == 0 || line[0] != '0') |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
85 | continue; // empty or illogical |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
86 | |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
87 | str zLine = line; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
88 | zLine.replace ("\n", ""); |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
89 | zLine.replace ("\r", ""); |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
90 | |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
91 | stringparser pars (zLine, ' '); |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
92 | short dCode = 0, dAlpha = 255; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
93 | str zName, zColor, zEdge, zValue; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
94 | |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
95 | // Check 0 !COLOUR, parse the name |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
96 | if (!pars.tokenCompare (0, "0") || !pars.tokenCompare (1, "!COLOUR") || !pars.getToken (zName, 2)) |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
97 | continue; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
98 | |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
99 | // Replace underscores in the name with spaces for readability |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
100 | zName.replace ("_", " "); |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
101 | |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
102 | // get the CODE tag |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
103 | if (!parseLDConfigTag (pars, "CODE", zValue)) |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
104 | continue; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
105 | |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
106 | // Ensure that the code is within range. must be within 0 - 512 |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
107 | dCode = atoi (zValue); |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
108 | if (dCode < 0 || dCode >= 512) |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
109 | continue; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
110 | |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
111 | // Don't let LDConfig.ldr override the special colors 16 and 24. However, |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
112 | // do take the name it gives for the color |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
113 | if (dCode == dMainColor || dCode == dEdgeColor) { |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
114 | g_LDColors[dCode]->zName = zName; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
115 | continue; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
116 | } |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
117 | |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
118 | // VALUE tag |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
119 | if (!parseLDConfigTag (pars, "VALUE", zColor)) |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
120 | continue; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
121 | |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
122 | // EDGE tag |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
123 | if (!parseLDConfigTag (pars, "EDGE", zEdge)) |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
124 | continue; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
125 | |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
126 | // Ensure that our colors are correct |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
127 | QColor qColor (zColor.chars()), |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
128 | qEdge (zEdge.chars()); |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
129 | |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
130 | if (!qColor.isValid () || !qEdge.isValid ()) |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
131 | continue; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
132 | |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
133 | // Parse alpha if given. |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
134 | if (parseLDConfigTag (pars, "ALPHA", zValue)) |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
135 | dAlpha = clamp<short> (atoi (zValue), 0, 255); |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
136 | |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
137 | color* col = new color; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
138 | col->zName = zName; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
139 | col->qColor = qColor; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
140 | col->qEdge = qEdge; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
141 | col->zColorString = zColor; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
142 | col->qColor.setAlpha (dAlpha); |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
143 | |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
144 | g_LDColors[dCode] = col; |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
145 | } |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
146 | |
5755c02d89f0
Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
71
diff
changeset
|
147 | fclose (fp); |
48
113eb6446c61
Color dialog almost up and running. Need to make it actually selectable now. TODO: make it read LDConfig.ldr
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
148 | } |