1 /* Written by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
2 * Understanding is not required. Only obedience.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
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 General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 import arsd
.simpledisplay
;
34 // ////////////////////////////////////////////////////////////////////////// //
35 __gshared string RcDir
= "~/.xreader";
36 __gshared string stateFileName
;
38 __gshared
float shipAngle
= 0;
39 __gshared
bool showShip
= false;
41 __gshared EliteModel shipModel
;
44 // ////////////////////////////////////////////////////////////////////////// //
45 __gshared string textFontName
= "~/ttf/ms/arial.ttf:noaa";
46 __gshared string textiFontName
= "~/ttf/ms/ariali.ttf:noaa";
47 __gshared string textbFontName
= "~/ttf/ms/arialbd.ttf:noaa";
48 __gshared string textzFontName
= "~/ttf/ms/arialbi.ttf:noaa";
49 __gshared string monoFontName
= "~/ttf/ms/cour.ttf:noaa";
50 __gshared string monoiFontName
= "~/ttf/ms/couri.ttf:noaa";
51 __gshared string monobFontName
= "~/ttf/ms/courbd.ttf:noaa";
52 __gshared string monozFontName
= "~/ttf/ms/courbi.ttf:noaa";
53 __gshared string uiFontName
= "~/ttf/ms/verdana.ttf:noaa";
54 __gshared string galmapFontName
= "~/ttf/ms/verdana.ttf:noaa";
55 __gshared
int GWidth
= 900;
56 __gshared
int GHeight
= 1024;
57 __gshared
int fsizeText
= 24;
58 __gshared
int fsizeUI
= 16;
59 __gshared
int fGalMapSize
= 16;
60 __gshared
bool sbLeft
= false;
61 __gshared
bool interAllowed
= false;
63 __gshared
bool flagNanoAA
= false;
64 __gshared
bool flagNanoSS
= false;
66 __gshared NVGColor colorDim
= NVGColor(0, 0, 0, 0);
67 __gshared NVGColor colorBack
= NVGColor(0x2a, 0x2a, 0x2a);
68 __gshared NVGColor colorText
= NVGColor(0xff, 0x7f, 0x00);
69 __gshared NVGColor colorTextHi
= NVGColor(0xff, 0xff, 0x00);
70 __gshared NVGColor colorTextHref
= NVGColor(0, 0, 0x80);
72 __gshared
int uiFont
, galmapFont
;
73 __gshared
int textFont
, textiFont
, textbFont
, textzFont
;
74 __gshared
int monoFont
, monoiFont
, monobFont
, monozFont
;
76 __gshared
bool optJustify
= false;
79 // ////////////////////////////////////////////////////////////////////////// //
80 BookInfo
[] loadDetailedHistory () {
84 foreach (string line
; VFile(buildPath(RcDir
, ".lastfile")).byLineCopy
) {
86 if (line
.length
== 0 || line
[0] == '#' || line
[0] == ';') continue;
88 res
~= loadBookInfo(line
);
89 res
[$-1].diskfile
= line
.idup
;
90 } catch (Exception e
) {}
92 } catch (Exception
) {}
97 // ////////////////////////////////////////////////////////////////////////// //
98 __gshared string
[] eliteShipFiles
;
101 void loadEliteShips () {
103 import std
.path
: extension
;
104 vfsAddPak(buildPath(RcDir
, "eliteships.zip"), "oxm:");
105 //scope(exit) vfsRemovePack(buildPath(RcDir, "eliteships.zip"), "oxm:");
106 foreach (immutable idx
, ref de; vfsFileList
) {
107 //writeln("<", de.name, ">");
108 if (de.name
.length
> 4 && de.name
[0..4] == "oxm:" && strEquCI(de.name
.extension
, ".oxm")) {
110 import core.memory : GC;
112 auto mdl = new EliteModel(de.name);
116 eliteShipFiles ~= de.name;
117 } catch (Exception e) {}
120 eliteShipFiles
~= de.name
;
126 // ////////////////////////////////////////////////////////////////////////// //
127 VFile
fwritef(A
...) (VFile fl
, string fmt
, /*lazy*/ A args
) {
128 import std
.string
: format
;
129 auto s
= format(fmt
, args
);
130 if (s
.length
) fl
.rawWriteExact(s
[]);
135 // ////////////////////////////////////////////////////////////////////////// //
140 fl
= VFile(buildPath(RcDir
, ".config.ui"));
141 } catch (Exception
) {
143 try { import std
.file
; mkdirRecurse(RcDir
); } catch (Exception
) {}
144 fl
= VFile(buildPath(RcDir
, ".config.ui"), "w");
145 fl
.fwritef("width=%s\n", GWidth
);
146 fl
.fwritef("height=%s\n", GHeight
);
147 fl
.fwritef("font-text=%s\n", textFontName
);
148 fl
.fwritef("font-text-italic=%s\n", textiFontName
);
149 fl
.fwritef("font-text-bold=%s\n", textbFontName
);
150 fl
.fwritef("font-text-bold-italic=%s\n", textzFontName
);
151 fl
.fwritef("font-mono=%s\n", monoFontName
);
152 fl
.fwritef("font-mono-italic=%s\n", monoiFontName
);
153 fl
.fwritef("font-mono-bold=%s\n", monobFontName
);
154 fl
.fwritef("font-mono-bold-italic=%s\n", monozFontName
);
155 fl
.fwritef("font-ui=%s\n", uiFontName
);
156 fl
.fwritef("font-galmap=%s\n", galmapFontName
);
157 fl
.fwritef("text-size=%s\n", fsizeText
);
158 fl
.fwritef("ui-text-size=%s\n", fsizeUI
);
159 fl
.fwritef("galmap-text-size=%s\n", fGalMapSize
);
160 fl
.fwritef("scrollbar-on-left=%s\n", sbLeft
);
161 fl
.fwritef("interference=%s\n", interAllowed
);
162 fl
.fwritef("color-dim=0x%08x\n", colorDim
.asUintHtml
);
163 fl
.fwritef("color-back=0x%08x\n", colorBack
.asUintHtml
);
164 fl
.fwritef("color-text=0x%08x\n", colorText
.asUintHtml
);
165 fl
.fwritef("color-text-hi=0x%08x\n", colorTextHi
.asUintHtml
);
166 fl
.fwritef("color-text-href=0x%08x\n", colorTextHref
.asUintHtml
);
167 fl
.fwritef("nano-aa=%s\n", flagNanoAA
);
168 fl
.fwritef("nano-ss=%s\n", flagNanoSS
);
169 fl
.fwritef("justify-text=%s\n", optJustify
);
170 } catch (Exception
) {}
174 "font-text", &textFontName
,
175 "font-text-italic", &textiFontName
,
176 "font-text-bold", &textbFontName
,
177 "font-text-bold-italic", &textzFontName
,
178 "font-text-italic-bold", &textzFontName
,
179 "font-mono", &monoFontName
,
180 "font-mono-italic", &monoiFontName
,
181 "font-mono-bold", &monobFontName
,
182 "font-mono-bold-italic", &monozFontName
,
183 "font-mono-italic-bold", &monozFontName
,
184 "font-ui", &uiFontName
,
185 "font-galmap", &galmapFontName
,
188 "text-size", &fsizeText
,
189 "ui-text-size", &fsizeUI
,
190 "galmap-text-size", &fGalMapSize
,
191 "scrollbar-on-left", &sbLeft
,
192 "interference", &interAllowed
,
193 "color-dim", &colorDim
,
194 "color-back", &colorBack
,
195 "color-text", &colorText
,
196 "color-text-hi", &colorTextHi
,
197 "color-text-href", &colorTextHref
,
198 "nano-aa", &flagNanoAA
,
199 "nano-ss", &flagNanoSS
,
200 "justify-text", &optJustify
,
205 // ////////////////////////////////////////////////////////////////////////// //
206 bool isComment (const(char)[] s
) {
207 while (s
.length
&& s
.ptr
[0] <= ' ') s
= s
[1..$];
208 return (s
.length
> 0 && s
.ptr
[0] == '#');