Re: 2 important questions regarding BGT.

2016-05-21 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: 2 important questions regarding BGT.

If you want to make translations user-editable, like Swamp, then you wouldn't be able to use serialization.The key is to understand how to store and retrieve information in strings.I'd probably do it like this (just an example; you will probably need to come up with something more suited to your project):string translate(string source) {
string result;
language.get(source, result);
return (result=="") ? source : result;
}

bool load_translation(string language) {
if(!file_exists(language + ".lng")) return false;
file fin;
fin.open(language + ".lng", "r");
string txt=string_replace(fin.read(0), "\r", "\n", true); // Windows line breaks are weird.
fin.close();
string[] lines=string_split(txt, "\n", true);
for(uint i=0; i<lines.length(); i+=2) {
if(i<lines.length()-1) lang.set(lines[i], lines[i+1]);
}
return true;
}I would probably use serialization for other settings, though, since you wouldn't need to edit your save/load functions when you add/remove settings.For example:dictionary config;

void load_settings() {
if(!file_exists("my_game.cfg")) return;
file fin;
fin.open("my_game.cfg", "rb");
config=deserialize(fin.read(0)); // You could encrypt it, if you want.
fin.close();
}

void save_settings() {
file fout;
fout.open("my_game.cfg", "wb");
fout.write(serialize(config));
fout.close();
}

void main() {
load_settings();
if(config.exists("language")) {
string language;
config.get("language", language);
load_translation(language);
}
if(config.exists("no logo")==false) logo();
// Etc...
}

void settings_menu() {
// If you use a dynamic_menu, it might look like this:
int result=settingsmenu.run("settingsmenu.ogg", false);
string n=settingsmenu.get_item_name(result);
if(n=="logo")
{
if(config.exists("no logo")) config.delete("no logo"); // I forget the method name for removing from dictionaries. Remove? Destroy?
else config.set("no logo", 1);
}
else if(n=="language") {
dynamic_menu languagemenu;
string[] files=find_files("*.lng");
for(uint i=0; i<files.length(); i++) {
languagemenu.add_item_tts(string_left(files[i], files[i].length()-4), files[i]);
}
languagemenu.add_item_tts("cancel", "cancel");
result=languagemenu.run(translate("choose language"), true);
n=languagemenu.get_item_name(result);
if(n!="cancel") config.set("language", n);
}
}hth

URL: http://forum.audiogames.net/viewtopic.php?pid=261251#p261251





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

2 important questions regarding BGT.

2016-05-20 Thread AudioGames . net Forum — Developers room : Sajad via Audiogames-reflector


  


2 important questions regarding BGT.

Hello everyone!I've learned many things from audio games, and wanna learn more. There are people who can answer my questions I hope someone can answer.First question:How can I make my games multilingual using LNG files? Or is there any way to make my games in other languages?2 let's say we created a multilingual game, I want when a user chooses a language it will be forever with him, it means, when he open the game, he wouldn't have to choose arabic if he choosed it before.Also: I have a music, and I want to do the same with languages. An option to disable logo/music or enable it. Regards.!

URL: http://forum.audiogames.net/viewtopic.php?pid=261107#p261107





___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector