mirror of
https://github.com/joncampbell123/dosbox-x.git
synced 2025-10-19 19:44:43 +08:00
allow menu translations
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include "support.h"
|
||||
#include "setup.h"
|
||||
#include "control.h"
|
||||
#include "menu.h"
|
||||
#include <list>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
@@ -83,7 +84,7 @@ void LoadMessageFile(const char * fname) {
|
||||
return;
|
||||
}
|
||||
char linein[LINE_IN_MAXLEN];
|
||||
char name[LINE_IN_MAXLEN];
|
||||
char name[LINE_IN_MAXLEN], menu_name[LINE_IN_MAXLEN];
|
||||
char string[LINE_IN_MAXLEN*10];
|
||||
/* Start out with empty strings */
|
||||
name[0]=0;string[0]=0;
|
||||
@@ -103,15 +104,24 @@ void LoadMessageFile(const char * fname) {
|
||||
|
||||
/* New string name */
|
||||
if (linein[0]==':') {
|
||||
string[0]=0;
|
||||
strcpy(name,linein+1);
|
||||
string[0]=0;
|
||||
if (!strncasecmp(linein+1, "MENU:", 5)) {
|
||||
*name=0;
|
||||
strcpy(menu_name,linein+6);
|
||||
} else {
|
||||
*menu_name=0;
|
||||
strcpy(name,linein+1);
|
||||
}
|
||||
/* End of string marker */
|
||||
} else if (linein[0]=='.') {
|
||||
/* Replace/Add the string to the internal languagefile */
|
||||
/* Remove last newline (marker is \n.\n) */
|
||||
size_t ll = strlen(string);
|
||||
if(ll && string[ll - 1] == '\n') string[ll - 1] = 0; //Second if should not be needed, but better be safe.
|
||||
MSG_Replace(name,string);
|
||||
if (strlen(name))
|
||||
MSG_Replace(name,string);
|
||||
else if (strlen(menu_name)&&mainMenu.item_exists(menu_name))
|
||||
mainMenu.get_item(menu_name).set_text(string);
|
||||
} else {
|
||||
/* Normal string to be added */
|
||||
strcat(string,linein);
|
||||
@@ -138,6 +148,11 @@ bool MSG_Write(const char * location) {
|
||||
for(itmb tel=Lang.begin();tel!=Lang.end();++tel){
|
||||
fprintf(out,":%s\n%s\n.\n",(*tel).name.c_str(),(*tel).val.c_str());
|
||||
}
|
||||
std::vector<DOSBoxMenu::item> master_list = mainMenu.get_master_list();
|
||||
for (auto &id : master_list) {
|
||||
if (id.is_allocated()&&id.get_type()!=DOSBoxMenu::separator_type_id&&id.get_type()!=DOSBoxMenu::vseparator_type_id)
|
||||
fprintf(out,":MENU:%s\n%s\n.\n",id.get_name().c_str(),id.get_text().c_str());
|
||||
}
|
||||
fclose(out);
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user