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 shared static this () {
40 RcDir
= RcDir
.expandTilde
.absolutePath
;
44 __gshared
float shipAngle
= 0;
45 __gshared
bool showShip
= false;
47 __gshared EliteModel shipModel
;
50 // ////////////////////////////////////////////////////////////////////////// //
51 __gshared string textFontName
= "~/ttf/ms/arial.ttf:noaa";
52 __gshared string textiFontName
= "~/ttf/ms/ariali.ttf:noaa";
53 __gshared string textbFontName
= "~/ttf/ms/arialbd.ttf:noaa";
54 __gshared string textzFontName
= "~/ttf/ms/arialbi.ttf:noaa";
55 __gshared string monoFontName
= "~/ttf/ms/cour.ttf:noaa";
56 __gshared string monoiFontName
= "~/ttf/ms/couri.ttf:noaa";
57 __gshared string monobFontName
= "~/ttf/ms/courbd.ttf:noaa";
58 __gshared string monozFontName
= "~/ttf/ms/courbi.ttf:noaa";
59 __gshared string uiFontName
= "~/ttf/ms/verdana.ttf:noaa";
60 __gshared string galmapFontName
= "~/ttf/ms/verdana.ttf:noaa";
61 __gshared
int GWidth
= 900;
62 __gshared
int GHeight
= 1024;
63 __gshared
int fsizeText
= 24;
64 __gshared
int fsizeUI
= 16;
65 __gshared
int fGalMapSize
= 16;
66 __gshared
bool sbLeft
= false;
67 __gshared
bool interAllowed
= false;
69 __gshared
bool flagNanoAA
= false;
70 __gshared
bool flagNanoSS
= false;
72 __gshared NVGColor colorDim
= NVGColor(0, 0, 0, 0);
73 __gshared NVGColor colorBack
= NVGColor(0x2a, 0x2a, 0x2a);
74 __gshared NVGColor colorText
= NVGColor(0xff, 0x7f, 0x00);
75 __gshared NVGColor colorTextHi
= NVGColor(0xff, 0xff, 0x00);
76 __gshared NVGColor colorTextHref
= NVGColor(0, 0, 0x80);
78 __gshared
int uiFont
, galmapFont
;
79 __gshared
int textFont
, textiFont
, textbFont
, textzFont
;
80 __gshared
int monoFont
, monoiFont
, monobFont
, monozFont
;
82 __gshared
bool optJustify
= false;
85 enum MinWinWidth
= 320;
86 enum MinWinHeight
= 240;
89 // ////////////////////////////////////////////////////////////////////////// //
90 BookInfo
[] loadDetailedHistory () {
94 foreach (string line
; VFile(buildPath(RcDir
, ".lastfile")).byLineCopy
) {
96 if (line
.length
== 0 || line
[0] == '#' || line
[0] == ';') continue;
98 res
~= loadBookInfo(line
);
99 res
[$-1].diskfile
= line
.idup
;
100 } catch (Exception
) {}
102 } catch (Exception
) {}
107 // ////////////////////////////////////////////////////////////////////////// //
108 __gshared string
[] eliteShipFiles
;
111 void loadEliteShips () {
113 import std
.path
: extension
;
114 vfsAddPak(buildPath(RcDir
, "eliteships.zip"), "oxm:");
115 //scope(exit) vfsRemovePack(buildPath(RcDir, "eliteships.zip"), "oxm:");
116 foreach (immutable idx
, ref de; vfsFileList
) {
117 //writeln("<", de.name, ">");
118 if (de.name
.length
> 4 && de.name
[0..4] == "oxm:" && strEquCI(de.name
.extension
, ".oxm")) {
120 import core.memory : GC;
122 auto mdl = new EliteModel(de.name);
126 eliteShipFiles ~= de.name;
127 } catch (Exception e) {}
130 eliteShipFiles
~= de.name
;
136 // ////////////////////////////////////////////////////////////////////////// //
137 VFile
fwritef(A
...) (VFile fl
, string fmt
, /*lazy*/ A args
) {
138 import std
.string
: format
;
139 auto s
= format(fmt
, args
);
140 if (s
.length
) fl
.rawWriteExact(s
[]);
145 // ////////////////////////////////////////////////////////////////////////// //
150 fl
= VFile(buildPath(RcDir
, ".config.ui"));
151 } catch (Exception
) {
153 try { import std
.file
; mkdirRecurse(RcDir
); } catch (Exception
) {}
154 fl
= VFile(buildPath(RcDir
, ".config.ui"), "w");
155 fl
.fwritef("width=%s\n", GWidth
);
156 fl
.fwritef("height=%s\n", GHeight
);
157 fl
.fwritef("font-text=%s\n", textFontName
);
158 fl
.fwritef("font-text-italic=%s\n", textiFontName
);
159 fl
.fwritef("font-text-bold=%s\n", textbFontName
);
160 fl
.fwritef("font-text-bold-italic=%s\n", textzFontName
);
161 fl
.fwritef("font-mono=%s\n", monoFontName
);
162 fl
.fwritef("font-mono-italic=%s\n", monoiFontName
);
163 fl
.fwritef("font-mono-bold=%s\n", monobFontName
);
164 fl
.fwritef("font-mono-bold-italic=%s\n", monozFontName
);
165 fl
.fwritef("font-ui=%s\n", uiFontName
);
166 fl
.fwritef("font-galmap=%s\n", galmapFontName
);
167 fl
.fwritef("text-size=%s\n", fsizeText
);
168 fl
.fwritef("ui-text-size=%s\n", fsizeUI
);
169 fl
.fwritef("galmap-text-size=%s\n", fGalMapSize
);
170 fl
.fwritef("scrollbar-on-left=%s\n", sbLeft
);
171 fl
.fwritef("interference=%s\n", interAllowed
);
172 fl
.fwritef("color-dim=0x%08x\n", colorDim
.asUintHtml
);
173 fl
.fwritef("color-back=0x%08x\n", colorBack
.asUintHtml
);
174 fl
.fwritef("color-text=0x%08x\n", colorText
.asUintHtml
);
175 fl
.fwritef("color-text-hi=0x%08x\n", colorTextHi
.asUintHtml
);
176 fl
.fwritef("color-text-href=0x%08x\n", colorTextHref
.asUintHtml
);
177 fl
.fwritef("nano-aa=%s\n", flagNanoAA
);
178 fl
.fwritef("nano-ss=%s\n", flagNanoSS
);
179 fl
.fwritef("justify-text=%s\n", optJustify
);
180 } catch (Exception
) {}
184 "font-text", &textFontName
,
185 "font-text-italic", &textiFontName
,
186 "font-text-bold", &textbFontName
,
187 "font-text-bold-italic", &textzFontName
,
188 "font-text-italic-bold", &textzFontName
,
189 "font-mono", &monoFontName
,
190 "font-mono-italic", &monoiFontName
,
191 "font-mono-bold", &monobFontName
,
192 "font-mono-bold-italic", &monozFontName
,
193 "font-mono-italic-bold", &monozFontName
,
194 "font-ui", &uiFontName
,
195 "font-galmap", &galmapFontName
,
198 "text-size", &fsizeText
,
199 "ui-text-size", &fsizeUI
,
200 "galmap-text-size", &fGalMapSize
,
201 "scrollbar-on-left", &sbLeft
,
202 "interference", &interAllowed
,
203 "color-dim", &colorDim
,
204 "color-back", &colorBack
,
205 "color-text", &colorText
,
206 "color-text-hi", &colorTextHi
,
207 "color-text-href", &colorTextHref
,
208 "nano-aa", &flagNanoAA
,
209 "nano-ss", &flagNanoSS
,
210 "justify-text", &optJustify
,
215 // ////////////////////////////////////////////////////////////////////////// //
216 bool isComment (const(char)[] s
) {
217 while (s
.length
&& s
.ptr
[0] <= ' ') s
= s
[1..$];
218 return (s
.length
> 0 && s
.ptr
[0] == '#');