editor/editor_preferences.cpp

Go to the documentation of this file.
00001 /* $Id: editor_preferences.cpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2009 - 2012 by Tomasz Sniatowski <kailoran@gmail.com>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 
00016 #include "editor/editor_preferences.hpp"
00017 #include "game_preferences.hpp"
00018 #include "serialization/string_utils.hpp"
00019 #include "util.hpp"
00020 
00021 namespace preferences {
00022 
00023 namespace editor {
00024 
00025     int auto_update_transitions() {
00026         return lexical_cast_default<int>(preferences::get("editor_auto_update_transitions"), TransitionUpdateMode::partial);
00027     }
00028 
00029     void set_auto_update_transitions(int value) {
00030         preferences::set("editor_auto_update_transitions", lexical_cast<std::string>(value));
00031     }
00032 
00033     bool use_mdi() {
00034         return preferences::get("editor_use_mdi", true);
00035     }
00036 
00037     void set_use_mdi(bool value) {
00038         preferences::set("editor_use_mdi", value);
00039     }
00040 
00041     std::string default_dir() {
00042         return preferences::get("editor_default_dir");
00043     }
00044 
00045     bool draw_terrain_codes() {
00046         return preferences::get("editor_draw_terrain_codes", false);
00047     }
00048 
00049     void set_draw_terrain_codes(bool value) {
00050         preferences::set("editor_draw_terrain_codes", value);
00051     }
00052 
00053     bool draw_hex_coordinates() {
00054         return preferences::get("editor_draw_hex_coordinates", false);
00055     }
00056 
00057     void set_draw_hex_coordinates(bool value) {
00058         preferences::set("editor_draw_hex_coordinates", value);
00059     }
00060 
00061     namespace {
00062         void normalize_editor_rgb(int rval)
00063         {
00064             if (rval < -255) {
00065                 rval = -255;
00066             }
00067             else if (rval > 255) {
00068                 rval = 255;
00069             }
00070         }
00071     }
00072 
00073     void set_tod_r(int value)
00074     {
00075         normalize_editor_rgb(value);
00076         preferences::set("editor_r",lexical_cast<std::string>(value));
00077     }
00078 
00079     void set_tod_g(int value)
00080     {
00081         normalize_editor_rgb(value);
00082         preferences::set("editor_g",lexical_cast<std::string>(value));
00083     }
00084 
00085     void set_tod_b(int value)
00086     {
00087         normalize_editor_rgb(value);
00088         preferences::set("editor_b",lexical_cast<std::string>(value));
00089     }
00090 
00091     int tod_r()
00092     {
00093         return lexical_cast_in_range<int>(preferences::get("editor_r"), 0, -255, 255);
00094     }
00095 
00096     int tod_g()
00097     {
00098         return lexical_cast_in_range<int>(preferences::get("editor_g"), 0, -255, 255);
00099     }
00100 
00101     int tod_b()
00102     {
00103         return lexical_cast_in_range<int>(preferences::get("editor_b"), 0, -255, 255);
00104     }
00105 
00106 } //end namespace editor
00107 
00108 } //end namespace preferences
00109 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:02:34 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs