1#!
2
3use strict;
4use warnings;
5use Config;
6use File::Basename;
7
8
9#============================== Helper Functions ===============================
10
11sub QuoteRecString
12{
13	my $str=shift;
14
15	$str=~s/\\/\\\\/g;
16	$str=~s/\"/\\\"/g;
17	$str="\"$str\"";
18	return $str;
19}
20
21sub QuotePanelName
22{
23	my $str=shift;
24
25	$str=~s/\\/\\\\/g;
26	$str=~s/:/\\:/g;
27	return $str;
28}
29
30
31#================ Parse args and start writing the output file =================
32
33if (@ARGV != 1 or substr($ARGV[0],0,1) eq '-') {
34	print(STDERR "ERROR: Illegal arguments.\nUsage: $0 <output file>\n");
35	exit(1);
36}
37my $fh;
38if (!open($fh,">",$ARGV[0])) {
39	print(STDERR "ERROR: Cannot open or create \"$ARGV[0]\": $!.\n");
40	exit(1);
41}
42print($fh "#\%rec:emBookmarks\%#\n");
43
44
45#=============================== Bookmark: Help ================================
46
47print($fh '
48Bookmark: {
49	Name = "Help"
50	Description = "This brings you to the documentation area."
51	Icon = "help.tga"
52	Hotkey = "F1"
53	LocationIdentity = ":"
54	LocationRelX = -0.36326
55	LocationRelY = -0.37791
56	LocationRelA = 0.00621
57}
58');
59
60
61#============================= Bookmark: Home Dir ==============================
62
63my $loc='::FS::';
64if ($Config{'osname'} eq 'MSWin32') {
65	my $homeDir=$ENV{'USERPROFILE'};
66	for (my $i=0; $i<length($homeDir); ) {
67		my $j=index($homeDir,'\\',$i);
68		if ($j<$i) { $j=length($homeDir); }
69		if ($j>$i and ($j!=2 or substr($homeDir,1,1) ne ':')) {
70			$loc = $loc . '::' . QuotePanelName(substr($homeDir,$i,$j-$i));
71		}
72		$i=$j+1;
73	}
74}
75else {
76	my $homeDir=$ENV{'HOME'};
77	for (my $i=0; $i<length($homeDir); ) {
78		my $j=index($homeDir,'/',$i);
79		if ($j<$i) { $j=length($homeDir); }
80		if ($j>$i) {
81			$loc = $loc . '::' . QuotePanelName(substr($homeDir,$i,$j-$i));
82		}
83		$i=$j+1;
84	}
85}
86print($fh '
87Bookmark: {
88	Name = "Home"
89	Description = "This brings you to your home directory."
90	Icon = "home.tga"
91	Hotkey = "F6"
92	LocationIdentity = ' . QuoteRecString($loc) . '
93	VisitAtProgramStart = yes
94}
95');
96
97
98#============================= Bookmark: Root Dir ==============================
99
100print($fh '
101Bookmark: {
102	Name = "Root"
103	Description = "This brings you to the root directory of the file system."
104	Icon = "root.tga"
105	Hotkey = "F7"
106	LocationIdentity = "::FS::"
107}
108');
109
110
111#========================== Bookmark: Virtual Cosmos ===========================
112
113print($fh '
114Bookmark: {
115	Name = "Virtual Cosmos"
116	Icon = "virtual_cosmos.tga"
117	Hotkey = "F8"
118	LocationIdentity = ":"
119}
120');
121
122
123#============================= Bookmark: SilChess ==============================
124
125print($fh '
126Bookmark: {
127	Name = "Chess"
128	Icon = "silchess.tga"
129	LocationIdentity = "::Chess1:"
130}
131');
132
133
134#=============================== Bookmark: Mines ===============================
135
136print($fh '
137Bookmark: {
138	Name = "Mines"
139	Icon = "mines.tga"
140	LocationIdentity = "::Mines1:"
141}
142');
143
144
145#============================== Bookmark: Netwalk ==============================
146
147print($fh '
148Bookmark: {
149	Name = "Netwalk"
150	Icon = "netwalk.tga"
151	LocationIdentity = "::Netwalk1:"
152}
153');
154
155
156#=============================== Bookmark: Clock ===============================
157
158print($fh '
159Bookmark: {
160	Name = "Clock"
161	Icon = "clock.tga"
162	LocationIdentity = "::Clock1:"
163}
164');
165
166
167#=================================== The End ===================================
168
169close($fh);
170