1 | #include "Localization.h"
|
---|
2 | #include "../Daodan_Config.h"
|
---|
3 | #include "../Daodan_Patch.h"
|
---|
4 | #include "../Inifile_Reader.h"
|
---|
5 | #include "Utility.h"
|
---|
6 | #include "Cheater.h"
|
---|
7 |
|
---|
8 | #include <beaengine/BeaEngine.h>
|
---|
9 |
|
---|
10 | void LocalizationIniCallback(const char* section, const char* name, const char* value)
|
---|
11 | {
|
---|
12 | if (!_stricmp(name, "blam"))
|
---|
13 | {
|
---|
14 | char* str = _strdup(value);
|
---|
15 | DDrPatch_Int32((int*)(OniExe + 0x0010fb73), (int)str);
|
---|
16 | }
|
---|
17 | else if (!_stricmp(name, "damn"))
|
---|
18 | {
|
---|
19 | char* str = _strdup(value);
|
---|
20 | DDrPatch_Int32((int*)(OniExe + 0x0010fb6e), (int)str);
|
---|
21 | }
|
---|
22 | else if (!_stricmp(name, "savepoint"))
|
---|
23 | {
|
---|
24 | char* str = malloc(strlen(value) + 10);
|
---|
25 | memset(str, ' ', 5);
|
---|
26 | strcpy(str+5, value);
|
---|
27 | strcpy(str + strlen(str), " %d");
|
---|
28 | bool b1 = DDrPatch_Int32((int*)(OniExe + 0x000fd730), (int)str);
|
---|
29 | bool b2 = DDrPatch_Int32((int*)(OniExe + 0x000fd738), (int)str);
|
---|
30 | }
|
---|
31 | else if (!_stricmp(name, "syndicatewarehouse"))
|
---|
32 | {
|
---|
33 | char* str = _strdup(value);
|
---|
34 | DDrPatch_Int32((int*)(OniExe + 0x000fd71a), (int)str);
|
---|
35 | DDrPatch_Int32((int*)(OniExe + 0x0010ef75), (int)str);
|
---|
36 | }
|
---|
37 | else if (!_stricmp(name, "shapeshifter_on"))
|
---|
38 | DDr_CheatTable[0].message_on = _strdup(value);
|
---|
39 | else if (!_stricmp(name, "shapeshifter_off"))
|
---|
40 | DDr_CheatTable[0].message_off = _strdup(value);
|
---|
41 | else if (!_stricmp(name, "liveforever_on"))
|
---|
42 | DDr_CheatTable[1].message_on = _strdup(value);
|
---|
43 | else if (!_stricmp(name, "liveforever_off"))
|
---|
44 | DDr_CheatTable[1].message_off = _strdup(value);
|
---|
45 | else if (!_stricmp(name, "touchofdeath_on"))
|
---|
46 | DDr_CheatTable[2].message_on = _strdup(value);
|
---|
47 | else if (!_stricmp(name, "touchofdeath_off"))
|
---|
48 | DDr_CheatTable[2].message_off = _strdup(value);
|
---|
49 | else if (!_stricmp(name, "canttouchthis_on"))
|
---|
50 | DDr_CheatTable[3].message_on = _strdup(value);
|
---|
51 | else if (!_stricmp(name, "canttouchthis_off"))
|
---|
52 | DDr_CheatTable[3].message_off = _strdup(value);
|
---|
53 | else if (!_stricmp(name, "fatloot_on"))
|
---|
54 | DDr_CheatTable[4].message_on = _strdup(value);
|
---|
55 | else if (!_stricmp(name, "glassworld_on"))
|
---|
56 | DDr_CheatTable[5].message_on = _strdup(value);
|
---|
57 | else if (!_stricmp(name, "glassworld_off"))
|
---|
58 | DDr_CheatTable[5].message_off = _strdup(value);
|
---|
59 | else if (!_stricmp(name, "winlevel_on"))
|
---|
60 | DDr_CheatTable[6].message_on = _strdup(value);
|
---|
61 | else if (!_stricmp(name, "loselevel_on"))
|
---|
62 | DDr_CheatTable[7].message_on = _strdup(value);
|
---|
63 | else if (!_stricmp(name, "bighead_on"))
|
---|
64 | DDr_CheatTable[8].message_on = _strdup(value);
|
---|
65 | else if (!_stricmp(name, "bighead_off"))
|
---|
66 | DDr_CheatTable[8].message_off = _strdup(value);
|
---|
67 | else if (!_stricmp(name, "minime_on"))
|
---|
68 | DDr_CheatTable[9].message_on = _strdup(value);
|
---|
69 | else if (!_stricmp(name, "minime_off"))
|
---|
70 | DDr_CheatTable[9].message_off = _strdup(value);
|
---|
71 | else if (!_stricmp(name, "superammo_on"))
|
---|
72 | DDr_CheatTable[10].message_on = _strdup(value);
|
---|
73 | else if (!_stricmp(name, "superammo_off"))
|
---|
74 | DDr_CheatTable[10].message_off = _strdup(value);
|
---|
75 | else if (!_stricmp(name, "devmode_on"))
|
---|
76 | {
|
---|
77 | char* str = _strdup(value);
|
---|
78 | DDr_CheatTable[11].message_on = str;
|
---|
79 | DDr_CheatTable[cheat_x].message_on = str;
|
---|
80 | }
|
---|
81 | else if (!_stricmp(name, "devmode_off"))
|
---|
82 | {
|
---|
83 | char* str = _strdup(value);
|
---|
84 | DDr_CheatTable[11].message_off = str;
|
---|
85 | DDr_CheatTable[cheat_x].message_off = str;
|
---|
86 | }
|
---|
87 | else if (!_stricmp(name, "reservoirdogs_on"))
|
---|
88 | DDr_CheatTable[12].message_on = _strdup(value);
|
---|
89 | else if (!_stricmp(name, "reservoirdogs_off"))
|
---|
90 | DDr_CheatTable[12].message_off = _strdup(value);
|
---|
91 | else if (!_stricmp(name, "roughjustice_on"))
|
---|
92 | DDr_CheatTable[13].message_on = _strdup(value);
|
---|
93 | else if (!_stricmp(name, "roughjustice_off"))
|
---|
94 | DDr_CheatTable[13].message_off = _strdup(value);
|
---|
95 | else if (!_stricmp(name, "chenille_on"))
|
---|
96 | DDr_CheatTable[14].message_on = _strdup(value);
|
---|
97 | else if (!_stricmp(name, "chenille_off"))
|
---|
98 | DDr_CheatTable[14].message_off = _strdup(value);
|
---|
99 | else if (!_stricmp(name, "behemoth_on"))
|
---|
100 | DDr_CheatTable[15].message_on = _strdup(value);
|
---|
101 | else if (!_stricmp(name, "behemoth_off"))
|
---|
102 | DDr_CheatTable[15].message_off = _strdup(value);
|
---|
103 | else if (!_stricmp(name, "elderrune_on"))
|
---|
104 | DDr_CheatTable[16].message_on = _strdup(value);
|
---|
105 | else if (!_stricmp(name, "elderrune_off"))
|
---|
106 | DDr_CheatTable[16].message_off = _strdup(value);
|
---|
107 | else if (!_stricmp(name, "moonshadow_on"))
|
---|
108 | DDr_CheatTable[17].message_on = _strdup(value);
|
---|
109 | else if (!_stricmp(name, "moonshadow_off"))
|
---|
110 | DDr_CheatTable[17].message_off = _strdup(value);
|
---|
111 | else if (!_stricmp(name, "munitionfrenzy_on"))
|
---|
112 | DDr_CheatTable[18].message_on = _strdup(value);
|
---|
113 | else if (!_stricmp(name, "fistsoflegend_on"))
|
---|
114 | DDr_CheatTable[19].message_on = _strdup(value);
|
---|
115 | else if (!_stricmp(name, "fistsoflegend_off"))
|
---|
116 | DDr_CheatTable[19].message_off = _strdup(value);
|
---|
117 | else if (!_stricmp(name, "killmequick_on"))
|
---|
118 | DDr_CheatTable[20].message_on = _strdup(value);
|
---|
119 | else if (!_stricmp(name, "killmequick_off"))
|
---|
120 | DDr_CheatTable[20].message_off = _strdup(value);
|
---|
121 | else if (!_stricmp(name, "carousel_on"))
|
---|
122 | DDr_CheatTable[21].message_on = _strdup(value);
|
---|
123 | else if (!_stricmp(name, "carousel_off"))
|
---|
124 | DDr_CheatTable[21].message_off = _strdup(value);
|
---|
125 | }
|
---|
126 |
|
---|
127 | void DD_Localization()
|
---|
128 | {
|
---|
129 | char* lang = DDrConfig_GetOptOfType("options.language", C_STRING)->value.stringVal;
|
---|
130 | char filename[50] = "daodan_locales/";
|
---|
131 | strcpy(filename + strlen(filename), lang);
|
---|
132 | strcpy(filename + strlen(filename), ".ini");
|
---|
133 | // STARTUPMESSAGE("Locale file: %s", filename);
|
---|
134 | if (_stricmp(lang, "en"))
|
---|
135 | {
|
---|
136 | STARTUPMESSAGE("Language: %s", lang);
|
---|
137 | uint32_t attr = GetFileAttributes("daodan_locales");
|
---|
138 | if (attr == INVALID_FILE_ATTRIBUTES)
|
---|
139 | {
|
---|
140 | STARTUPMESSAGE("Locales folder does not exist", 0);
|
---|
141 | return;
|
---|
142 | }
|
---|
143 | if ((attr & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY)
|
---|
144 | {
|
---|
145 | STARTUPMESSAGE("Locales folder does not exist", 0);
|
---|
146 | return;
|
---|
147 | }
|
---|
148 |
|
---|
149 | if (GetFileAttributes(filename) == INVALID_FILE_ATTRIBUTES)
|
---|
150 | {
|
---|
151 | STARTUPMESSAGE("Locale file for language \"%s\" does not exist", lang);
|
---|
152 | return;
|
---|
153 | }
|
---|
154 |
|
---|
155 | if (!Inifile_Read(filename, LocalizationIniCallback))
|
---|
156 | STARTUPMESSAGE("Error reading %s, check your syntax!", filename);
|
---|
157 | }
|
---|
158 | }
|
---|
159 |
|
---|