1 |
gbeauche |
1.1 |
/* |
2 |
|
|
* user_strings_windows.cpp - Windows-specific localizable strings |
3 |
|
|
* |
4 |
|
|
* Basilisk II (C) 1997-2004 Christian Bauer |
5 |
|
|
* |
6 |
|
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
|
* it under the terms of the GNU General Public License as published by |
8 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
9 |
|
|
* (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* This program is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with this program; if not, write to the Free Software |
18 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 |
|
|
*/ |
20 |
|
|
|
21 |
|
|
#include "sysdeps.h" |
22 |
|
|
#include "user_strings.h" |
23 |
|
|
|
24 |
|
|
#define WIN32_LEAN_AND_MEAN |
25 |
|
|
#include <windows.h> |
26 |
|
|
|
27 |
|
|
|
28 |
|
|
// Platform-specific string definitions |
29 |
|
|
user_string_def platform_strings[] = { |
30 |
|
|
// Common strings that have a platform-specific variant |
31 |
|
|
{STR_VOLUME_IS_MOUNTED_WARN, "The volume '%s' is mounted under Unix. Basilisk II will try to unmount it."}, |
32 |
|
|
{STR_EXTFS_VOLUME_NAME, "My Computer"}, |
33 |
|
|
|
34 |
|
|
// Purely platform-specific strings |
35 |
|
|
{STR_NO_XVISUAL_ERR, "Cannot obtain appropriate X visual."}, |
36 |
|
|
{STR_VOSF_INIT_ERR, "Cannot initialize Video on SEGV signals."}, |
37 |
gbeauche |
1.2 |
{STR_SIG_INSTALL_ERR, "Cannot install %s handler (%s)."}, |
38 |
gbeauche |
1.1 |
{STR_TICK_THREAD_ERR, "Cannot create 60Hz thread (%s)."}, |
39 |
|
|
{STR_NO_AUDIO_WARN, "No audio device found, audio output will be disabled."}, |
40 |
|
|
{STR_KEYCODE_FILE_WARN, "Cannot open keycode translation file %s (%s)."}, |
41 |
|
|
{STR_KEYCODE_VENDOR_WARN, "Cannot find vendor '%s' in keycode translation file %s."}, |
42 |
|
|
{STR_WINDOW_TITLE_GRABBED, "Basilisk II (mouse grabbed, press Ctrl-F5 to release)"}, |
43 |
|
|
|
44 |
|
|
{-1, NULL} // End marker |
45 |
|
|
}; |
46 |
|
|
|
47 |
|
|
|
48 |
|
|
/* |
49 |
|
|
* Search for main volume name |
50 |
|
|
*/ |
51 |
|
|
|
52 |
|
|
static const char *get_volume_name(void) |
53 |
|
|
{ |
54 |
|
|
HKEY hHelpKey; |
55 |
|
|
DWORD key_type, cbData; |
56 |
|
|
|
57 |
|
|
static char volume[256]; |
58 |
|
|
memset(volume, 0, sizeof(volume)); |
59 |
|
|
|
60 |
|
|
// Try Windows 2000 key first |
61 |
|
|
if (ERROR_SUCCESS == RegOpenKey( |
62 |
|
|
HKEY_CURRENT_USER, |
63 |
|
|
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CLSID\\{20D04FE0-3AEA-1069-A2D8-08002B30309D}", |
64 |
|
|
&hHelpKey)) |
65 |
|
|
{ |
66 |
|
|
cbData = sizeof(volume); |
67 |
|
|
RegQueryValueEx( hHelpKey, 0, NULL, &key_type, (unsigned char *)volume, &cbData ); |
68 |
|
|
RegCloseKey(hHelpKey); |
69 |
|
|
} |
70 |
|
|
|
71 |
|
|
if (volume[0] == 0 && |
72 |
|
|
ERROR_SUCCESS == RegOpenKey( |
73 |
|
|
HKEY_CURRENT_USER, |
74 |
|
|
"Software\\Classes\\CLSID\\{20D04FE0-3AEA-1069-A2D8-08002B30309D}", |
75 |
|
|
&hHelpKey)) |
76 |
|
|
{ |
77 |
|
|
cbData = sizeof(volume); |
78 |
|
|
RegQueryValueEx( hHelpKey, 0, NULL, &key_type, (unsigned char *)volume, &cbData ); |
79 |
|
|
RegCloseKey(hHelpKey); |
80 |
|
|
} |
81 |
|
|
|
82 |
|
|
if (volume[0] == 0 && |
83 |
|
|
ERROR_SUCCESS == RegOpenKey( |
84 |
|
|
HKEY_CLASSES_ROOT, |
85 |
|
|
"CLSID\\{20D04FE0-3AEA-1069-A2D8-08002B30309D}", |
86 |
|
|
&hHelpKey)) |
87 |
|
|
{ |
88 |
|
|
cbData = sizeof(volume); |
89 |
|
|
RegQueryValueEx( hHelpKey, 0, NULL, &key_type, (unsigned char *)volume, &cbData ); |
90 |
|
|
RegCloseKey(hHelpKey); |
91 |
|
|
} |
92 |
|
|
|
93 |
|
|
// Fix the error that some "tweak" apps do. |
94 |
|
|
if (stricmp(volume, "%USERNAME% on %COMPUTER%") == 0) |
95 |
|
|
volume[0] = '\0'; |
96 |
|
|
|
97 |
|
|
// No volume name found, default to "My Computer" |
98 |
|
|
if (volume[0] == 0) |
99 |
|
|
strcpy(volume, "My Computer"); |
100 |
|
|
|
101 |
|
|
return volume; |
102 |
|
|
} |
103 |
|
|
|
104 |
|
|
|
105 |
|
|
/* |
106 |
|
|
* Fetch pointer to string, given the string number |
107 |
|
|
*/ |
108 |
|
|
|
109 |
|
|
const char *GetString(int num) |
110 |
|
|
{ |
111 |
|
|
// First, search for platform-specific variable string |
112 |
|
|
switch (num) { |
113 |
|
|
case STR_EXTFS_VOLUME_NAME: |
114 |
|
|
return get_volume_name(); |
115 |
|
|
} |
116 |
|
|
|
117 |
|
|
// Next, search for platform-specific constant string |
118 |
|
|
int i = 0; |
119 |
|
|
while (platform_strings[i].num >= 0) { |
120 |
|
|
if (platform_strings[i].num == num) |
121 |
|
|
return platform_strings[i].str; |
122 |
|
|
i++; |
123 |
|
|
} |
124 |
|
|
|
125 |
|
|
// Not found, search for common string |
126 |
|
|
i = 0; |
127 |
|
|
while (common_strings[i].num >= 0) { |
128 |
|
|
if (common_strings[i].num == num) |
129 |
|
|
return common_strings[i].str; |
130 |
|
|
i++; |
131 |
|
|
} |
132 |
|
|
return NULL; |
133 |
|
|
} |