[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src font.cpp font.hpp game.cpp editor/e...
From: |
Philippe Plantier |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src font.cpp font.hpp game.cpp editor/e... |
Date: |
Sat, 26 Feb 2005 13:52:25 -0500 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Philippe Plantier <address@hidden> 05/02/26 18:52:24
Modified files:
src : font.cpp font.hpp game.cpp
src/editor : editor_main.cpp
Log message:
Fixed the fonts and i18n not working properly in the editor.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/font.cpp.diff?tr1=1.102&tr2=1.103&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/font.hpp.diff?tr1=1.48&tr2=1.49&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/game.cpp.diff?tr1=1.198&tr2=1.199&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/editor/editor_main.cpp.diff?tr1=1.26&tr2=1.27&r1=text&r2=text
Patches:
Index: wesnoth/src/editor/editor_main.cpp
diff -u wesnoth/src/editor/editor_main.cpp:1.26
wesnoth/src/editor/editor_main.cpp:1.27
--- wesnoth/src/editor/editor_main.cpp:1.26 Mon Feb 21 09:05:51 2005
+++ wesnoth/src/editor/editor_main.cpp Sat Feb 26 18:52:24 2005
@@ -205,6 +205,22 @@
// settings. Maybe they should be moved? Or set an EDITOR define and
// make it load that way maybe.
defines_map["MULTIPLAYER"] = preproc_define();
+
+ //Set the locale first, then read the configuration, or else WML
+ //strings are not correctly translated. Does this work on on the win32
+ //platform?
+ const bool lang_res = ::set_language(get_locale());
+ if(!lang_res) {
+ std::cerr << "No translation for locale '" <<
get_locale().language
+ << "', default to system locale\n";
+
+ const bool lang_res = ::set_language(known_languages[0]);
+ if(!lang_res) {
+ std::cerr << "Language data not found\n";
+ }
+ }
+
+ //Read the configuration af
config cfg;
try {
cfg.read(preprocess_file("data/game.cfg", &defines_map));
@@ -212,8 +228,7 @@
catch (config::error e) {
std::cerr << "Error when reading game config: '" << e.message
<< "'" << std::endl;
}
-
- set_language(known_languages[0]);
+ font::load_font_config();
if(mapdata.empty()) {
for(int i = 0; i != 20; ++i) {
Index: wesnoth/src/font.cpp
diff -u wesnoth/src/font.cpp:1.102 wesnoth/src/font.cpp:1.103
--- wesnoth/src/font.cpp:1.102 Sat Feb 26 18:10:01 2005
+++ wesnoth/src/font.cpp Sat Feb 26 18:52:23 2005
@@ -1,4 +1,4 @@
-/* $Id: font.cpp,v 1.102 2005/02/26 18:10:01 gruikya Exp $ */
+/* $Id: font.cpp,v 1.103 2005/02/26 18:52:23 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -1207,3 +1207,74 @@
}
}
+
+namespace {
+ bool add_font_to_fontlist(config* fonts_config,
std::vector<font::subset_descriptor>& fontlist, const std::string& name)
+ {
+ config* font = fonts_config->find_child("font", "name", name);
+ if(font == NULL)
+ return false;
+
+ fontlist.push_back(font::subset_descriptor());
+ fontlist.back().name = name;
+ std::vector<std::string> ranges =
utils::split((*font)["codepoints"]);
+
+ for(std::vector<std::string>::const_iterator itor =
ranges.begin();
+ itor != ranges.end(); ++itor) {
+
+ std::vector<std::string> r = utils::split(*itor, '-');
+ if(r.size() == 1) {
+ size_t r1 = lexical_cast_default<size_t>(r[0],
0);
+
fontlist.back().present_codepoints.push_back(std::pair<size_t, size_t>(r1, r1));
+ } else if(r.size() == 2) {
+ size_t r1 = lexical_cast_default<size_t>(r[0],
0);
+ size_t r2 = lexical_cast_default<size_t>(r[1],
0);
+
+
fontlist.back().present_codepoints.push_back(std::pair<size_t, size_t>(r1, r2));
+ }
+ }
+ }
+}
+
+namespace font {
+
+bool load_font_config()
+{
+ //read font config separately, so we do not have to re-read the whole
+ //config when changing languages
+ config cfg;
+ try {
+ cfg.read(preprocess_file("data/fonts.cfg"));
+ } catch(config::error&) {
+ std::cerr << "Could not read fonts.cfg\n";
+ return false;
+ }
+
+ config* fonts_config = cfg.child("fonts");
+ if(fonts_config == NULL)
+ return false;
+
+ std::set<std::string> known_fonts;
+ const config::child_list fonts = fonts_config->get_children("font");
+ for (config::child_list::const_iterator child = fonts.begin(); child !=
fonts.end(); ++child) {
+ known_fonts.insert((**child)["name"]);
+ }
+
+ const std::vector<std::string> font_order =
utils::split((*fonts_config)["order"]);
+ std::vector<font::subset_descriptor> fontlist;
+ std::vector<std::string>::const_iterator font;
+ for(font = font_order.begin(); font != font_order.end(); ++font) {
+ add_font_to_fontlist(fonts_config, fontlist, *font);
+ known_fonts.erase(*font);
+ }
+ std::set<std::string>::const_iterator kfont;
+ for(kfont = known_fonts.begin(); kfont != known_fonts.end(); ++kfont) {
+ add_font_to_fontlist(fonts_config, fontlist, *kfont);
+ }
+
+ if(fontlist.empty())
+ return false;
+
+ font::set_font_list(fontlist);
+}
+}
Index: wesnoth/src/font.hpp
diff -u wesnoth/src/font.hpp:1.48 wesnoth/src/font.hpp:1.49
--- wesnoth/src/font.hpp:1.48 Sat Feb 26 18:10:01 2005
+++ wesnoth/src/font.hpp Sat Feb 26 18:52:24 2005
@@ -1,4 +1,4 @@
-/* $Id: font.hpp,v 1.48 2005/02/26 18:10:01 gruikya Exp $ */
+/* $Id: font.hpp,v 1.49 2005/02/26 18:52:24 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -181,6 +181,8 @@
void draw_floating_labels(surface screen);
void undraw_floating_labels(surface screen);
+bool load_font_config();
+
}
#endif
Index: wesnoth/src/game.cpp
diff -u wesnoth/src/game.cpp:1.198 wesnoth/src/game.cpp:1.199
--- wesnoth/src/game.cpp:1.198 Sat Feb 26 18:10:01 2005
+++ wesnoth/src/game.cpp Sat Feb 26 18:52:24 2005
@@ -1,4 +1,4 @@
-/* $Id: game.cpp,v 1.198 2005/02/26 18:10:01 gruikya Exp $ */
+/* $Id: game.cpp,v 1.199 2005/02/26 18:52:24 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -318,7 +318,6 @@
bool init_video();
bool init_config();
bool init_language();
- bool init_fonts();
bool play_test();
bool play_multiplayer_mode();
@@ -618,74 +617,6 @@
return true;
}
-namespace {
- bool add_font_to_fontlist(config* fonts_config,
std::vector<font::subset_descriptor>& fontlist, const std::string& name)
- {
- config* font = fonts_config->find_child("font", "name", name);
- if(font == NULL)
- return false;
-
- fontlist.push_back(font::subset_descriptor());
- fontlist.back().name = name;
- std::vector<std::string> ranges =
utils::split((*font)["codepoints"]);
-
- for(std::vector<std::string>::const_iterator itor =
ranges.begin();
- itor != ranges.end(); ++itor) {
-
- std::vector<std::string> r = utils::split(*itor, '-');
- if(r.size() == 1) {
- size_t r1 = lexical_cast_default<size_t>(r[0],
0);
-
fontlist.back().present_codepoints.push_back(std::pair<size_t, size_t>(r1, r1));
- } else if(r.size() == 2) {
- size_t r1 = lexical_cast_default<size_t>(r[0],
0);
- size_t r2 = lexical_cast_default<size_t>(r[1],
0);
-
-
fontlist.back().present_codepoints.push_back(std::pair<size_t, size_t>(r1, r2));
- }
- }
- }
-}
-
-bool game_controller::init_fonts()
-{
- //read font config separately, so we do not have to re-read the whole
- //config when changing languages
- config cfg;
- try {
- cfg.read(preprocess_file("data/fonts.cfg"));
- } catch(config::error&) {
- std::cerr << "Could not read fonts.cfg\n";
- return false;
- }
-
- config* fonts_config = cfg.child("fonts");
- if(fonts_config == NULL)
- return false;
-
- std::set<std::string> known_fonts;
- const config::child_list fonts = fonts_config->get_children("font");
- for (config::child_list::const_iterator child = fonts.begin(); child !=
fonts.end(); ++child) {
- known_fonts.insert((**child)["name"]);
- }
-
- const std::vector<std::string> font_order =
utils::split((*fonts_config)["order"]);
- std::vector<font::subset_descriptor> fontlist;
- std::vector<std::string>::const_iterator font;
- for(font = font_order.begin(); font != font_order.end(); ++font) {
- add_font_to_fontlist(fonts_config, fontlist, *font);
- known_fonts.erase(*font);
- }
- std::set<std::string>::const_iterator kfont;
- for(kfont = known_fonts.begin(); kfont != known_fonts.end(); ++kfont) {
- add_font_to_fontlist(fonts_config, fontlist, *kfont);
- }
-
- if(fontlist.empty())
- return false;
-
- font::set_font_list(fontlist);
-}
-
bool game_controller::play_test()
{
if(test_mode_ == false) {
@@ -1442,7 +1373,7 @@
use_caching_ = old_cache;
}
- init_fonts();
+ font::load_font_config();
hotkey::load_descriptions();
return false;
@@ -1664,7 +1595,7 @@
}
#endif
- res = game.init_fonts();
+ res = font::load_font_config();
if(res == false) {
std::cerr << "could not initialize fonts\n";
return 0;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Wesnoth-cvs-commits] wesnoth/src font.cpp font.hpp game.cpp editor/e...,
Philippe Plantier <=