gui/auxiliary/tips.hpp

Go to the documentation of this file.
00001 /* $Id: tips.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2010 - 2012 by Mark de Wever <koraq@xs4all.nl>
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 #ifndef GUI_AUXILIARY_TIPS_HPP_INCLUDED
00017 #define GUI_AUXILIARY_TIPS_HPP_INCLUDED
00018 
00019 #include "tstring.hpp"
00020 
00021 #include <vector>
00022 
00023 class config;
00024 
00025 namespace gui2 {
00026 
00027 class ttip;
00028 
00029 namespace tips {
00030 
00031 /**
00032  * Loads the tips from a config.
00033  *
00034  * @param cfg                     A config with the tips.
00035  *
00036  * @returns                       The loaded tips.
00037  */
00038 std::vector<ttip> load(const config& cfg);
00039 
00040 /**
00041  * Shuffles the tips.
00042  *
00043  * This routine shuffles the tips and filters out the unwanted ones.
00044  *
00045  * @param tips                    The tips.
00046  *
00047  * @returns                       The filtered tips in random order.
00048  */
00049 std::vector<ttip> shuffle(const std::vector<ttip>& tips);
00050 
00051 } // namespace tips {
00052 
00053 /** The tips of day structure. */
00054 class ttip
00055 {
00056 public:
00057 
00058     const t_string& text() const { return text_; }
00059     const t_string& source() const { return source_; }
00060 
00061 private:
00062     friend std::vector<ttip> tips::load(const config&);
00063     friend std::vector<ttip> tips::shuffle(const std::vector<ttip>& tips);
00064     ttip(const t_string& text
00065             , const t_string& source
00066             , const std::string& unit_filter);
00067 
00068     /** The text of the tip. */
00069     t_string text_;
00070 
00071     /** The source of the tip. */
00072     t_string source_;
00073 
00074     /**
00075      * List of units to filter the tip upon.
00076      *
00077      * If the list is empty the tip is shown.
00078      * Else the unit must have encountered at least one of the units in the
00079      * list.
00080      */
00081     std::vector<std::string> unit_filter_;
00082 };
00083 
00084 } // namespace gui2
00085 
00086 #endif
00087 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:02:54 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs