1 |
gbeauche |
1.1 |
/* |
2 |
|
|
* user_strings_windows.cpp - Windows-specific localizable strings |
3 |
|
|
* |
4 |
gbeauche |
1.4 |
* Basilisk II (C) 1997-2005 Christian Bauer |
5 |
gbeauche |
1.1 |
* |
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 |
gbeauche |
1.3 |
{STR_NO_WIN32_NT_4, "Basilisk II does not run on Windows NT versions less than 4.0"}, |
44 |
gbeauche |
1.1 |
|
45 |
|
|
{-1, NULL} // End marker |
46 |
|
|
}; |
47 |
|
|
|
48 |
|
|
|
49 |
|
|
/* |
50 |
|
|
* Search for main volume name |
51 |
|
|
*/ |
52 |
|
|
|
53 |
|
|
static const char *get_volume_name(void) |
54 |
|
|
{ |
55 |
|
|
HKEY hHelpKey; |
56 |
|
|
DWORD key_type, cbData; |
57 |
|
|
|
58 |
|
|
static char volume[256]; |
59 |
|
|
memset(volume, 0, sizeof(volume)); |
60 |
|
|
|
61 |
|
|
// Try Windows 2000 key first |
62 |
|
|
if (ERROR_SUCCESS == RegOpenKey( |
63 |
|
|
HKEY_CURRENT_USER, |
64 |
|
|
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\CLSID\\{20D04FE0-3AEA-1069-A2D8-08002B30309D}", |
65 |
|
|
&hHelpKey)) |
66 |
|
|
{ |
67 |
|
|
cbData = sizeof(volume); |
68 |
|
|
RegQueryValueEx( hHelpKey, 0, NULL, &key_type, (unsigned char *)volume, &cbData ); |
69 |
|
|
RegCloseKey(hHelpKey); |
70 |
|
|
} |
71 |
|
|
|
72 |
|
|
if (volume[0] == 0 && |
73 |
|
|
ERROR_SUCCESS == RegOpenKey( |
74 |
|
|
HKEY_CURRENT_USER, |
75 |
|
|
"Software\\Classes\\CLSID\\{20D04FE0-3AEA-1069-A2D8-08002B30309D}", |
76 |
|
|
&hHelpKey)) |
77 |
|
|
{ |
78 |
|
|
cbData = sizeof(volume); |
79 |
|
|
RegQueryValueEx( hHelpKey, 0, NULL, &key_type, (unsigned char *)volume, &cbData ); |
80 |
|
|
RegCloseKey(hHelpKey); |
81 |
|
|
} |
82 |
|
|
|
83 |
|
|
if (volume[0] == 0 && |
84 |
|
|
ERROR_SUCCESS == RegOpenKey( |
85 |
|
|
HKEY_CLASSES_ROOT, |
86 |
|
|
"CLSID\\{20D04FE0-3AEA-1069-A2D8-08002B30309D}", |
87 |
|
|
&hHelpKey)) |
88 |
|
|
{ |
89 |
|
|
cbData = sizeof(volume); |
90 |
|
|
RegQueryValueEx( hHelpKey, 0, NULL, &key_type, (unsigned char *)volume, &cbData ); |
91 |
|
|
RegCloseKey(hHelpKey); |
92 |
|
|
} |
93 |
|
|
|
94 |
|
|
// Fix the error that some "tweak" apps do. |
95 |
|
|
if (stricmp(volume, "%USERNAME% on %COMPUTER%") == 0) |
96 |
|
|
volume[0] = '\0'; |
97 |
|
|
|
98 |
|
|
// No volume name found, default to "My Computer" |
99 |
|
|
if (volume[0] == 0) |
100 |
|
|
strcpy(volume, "My Computer"); |
101 |
|
|
|
102 |
|
|
return volume; |
103 |
|
|
} |
104 |
|
|
|
105 |
|
|
|
106 |
|
|
/* |
107 |
|
|
* Fetch pointer to string, given the string number |
108 |
|
|
*/ |
109 |
|
|
|
110 |
|
|
const char *GetString(int num) |
111 |
|
|
{ |
112 |
|
|
// First, search for platform-specific variable string |
113 |
|
|
switch (num) { |
114 |
|
|
case STR_EXTFS_VOLUME_NAME: |
115 |
|
|
return get_volume_name(); |
116 |
|
|
} |
117 |
|
|
|
118 |
|
|
// Next, search for platform-specific constant string |
119 |
|
|
int i = 0; |
120 |
|
|
while (platform_strings[i].num >= 0) { |
121 |
|
|
if (platform_strings[i].num == num) |
122 |
|
|
return platform_strings[i].str; |
123 |
|
|
i++; |
124 |
|
|
} |
125 |
|
|
|
126 |
|
|
// Not found, search for common string |
127 |
|
|
i = 0; |
128 |
|
|
while (common_strings[i].num >= 0) { |
129 |
|
|
if (common_strings[i].num == num) |
130 |
|
|
return common_strings[i].str; |
131 |
|
|
i++; |
132 |
|
|
} |
133 |
|
|
return NULL; |
134 |
|
|
} |