Author: uso
Date: Tue Aug 21 00:05:00 2007
New Revision: 19694

URL: http://svn.gna.org/viewcvs/wesnoth?rev=19694&view=rev
Log:
Add a second window to the "Status Table" which shows the basic game settings
for each player. Unfortunatly the current dialog implementation seems to allow
only 2 functional buttons together with a (menu)list, so I had to move the "Ok"
button which allows you to scroll to the selected leader to the second screen.
I hope this feature is not used too often, so it's ok there ...
I have mostly tested the "Game Settings" display with multiplayer games, please
test it with scenarios which have more special WML settings.

Modified:
    trunk/changelog
    trunk/players_changelog
    trunk/src/menu_events.cpp
    trunk/src/menu_events.hpp
    trunk/src/team.cpp
    trunk/src/team.hpp

Modified: trunk/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=19694&r1=19693&r2=19694&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Tue Aug 21 00:05:00 2007
@@ -102,6 +102,8 @@
      undo, attack dialog or right-click cancel
    * need only one right-click to open context-menu on an unselected enemy
    * selecting an enemy doesn't directly cancel its reachable zone
+   * there's a new "Game Settings" window which shows the basic game settings
+     for each player, accessible through the "More" button in the "Status 
Table"
  * WML engine:
    * now [base_unit]id= inside [unit] can extend upon existing unit types
    * new tag [filter_radius] to allow greater control over radius expansion

Modified: trunk/players_changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/players_changelog?rev=19694&r1=19693&r2=19694&view=diff
==============================================================================
--- trunk/players_changelog (original)
+++ trunk/players_changelog Tue Aug 21 00:05:00 2007
@@ -63,6 +63,8 @@
     * The 'more' and 'help' button in the title screen now have a tooltip.
     * Added a hotkey for clearing the chat messages.
     * Fixed the black corners on some maps.
+    * There's a new "Game Settings" window which shows the basic game settings
+      (accessible through the "More" button in the "Status Table").
 
   * Miscellaneous
     * Isle of Anduin renamed to Isle of Alduin to avoid copyright problems.

Modified: trunk/src/menu_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/menu_events.cpp?rev=19694&r1=19693&r2=19694&view=diff
==============================================================================
--- trunk/src/menu_events.cpp (original)
+++ trunk/src/menu_events.cpp Tue Aug 21 00:05:00 2007
@@ -524,9 +524,75 @@
                        items.push_back(str.str());
                }
 
+               gui::dialog slist(*gui_, _("Current Status"), "", 
gui::NULL_DIALOG);
+               slist.add_button(new gui::standard_dialog_button(gui_->video(), 
_("More"), 0, false),
+                                gui::dialog::BUTTON_STANDARD);
+               slist.add_button(new gui::standard_dialog_button(gui_->video(), 
_("Close"), 1, true),
+                                gui::dialog::BUTTON_STANDARD);
+               slist.set_menu(items, &sorter);
+
+               if (slist.show() >= 0) game_settings_table();
+       }
+
+       void menu_handler::game_settings_table()
+       {
+               std::stringstream heading;
+               heading << HEADING_PREFIX << _("Leader") << COLUMN_SEPARATOR
+                       << COLUMN_SEPARATOR
+                       << _("Side")              << COLUMN_SEPARATOR
+                       << _("Start\nGold")       << COLUMN_SEPARATOR
+                       << _("Base\nIncome")      << COLUMN_SEPARATOR
+                       << _("Gold Per\nVillage") << COLUMN_SEPARATOR
+                       << _("Fog")               << COLUMN_SEPARATOR
+                       << _("Shroud");
+
+               gui::menu::basic_sorter sorter;
+               
sorter.set_redirect_sort(0,1).set_alpha_sort(1).set_numeric_sort(2)
+                     
.set_numeric_sort(3).set_numeric_sort(4).set_numeric_sort(5)
+                     .set_alpha_sort(6).set_alpha_sort(7);
+
+               std::vector<std::string> items;
+               items.push_back(heading.str());
+
+               const team& viewing_team = teams_[gui_->viewing_team()];
+
+               for(size_t n = 0; n != teams_.size(); ++n) {
+                       if(teams_[n].is_empty()) {
+                               continue;
+                       }
+
+                       std::stringstream str;
+                       const unit_map::const_iterator leader = 
team_leader(n+1, units_);
+
+                       if(leader != units_.end()) {
+                               // Add leader image. If it's fogged
+                               // show only a random leader image.
+                               if (viewing_team.knows_about_team(n) || 
game_config::debug) {
+                                       str << IMAGE_PREFIX << 
leader->second.absolute_image();
+                               } else {
+                                       str << IMAGE_PREFIX << 
std::string("random-enemy.png");
+                               }
+#ifndef LOW_MEM
+                               str << "~RC(" << leader->second.team_color() << 
">"
+                                   << team::get_side_colour_index(n+1) << ")";
+#endif
+                       }
+
+                       str << COLUMN_SEPARATOR << team::get_side_highlight(n)
+                           << teams_[n].current_player() << COLUMN_SEPARATOR
+                           << n + 1 << COLUMN_SEPARATOR
+                           << teams_[n].start_gold() << COLUMN_SEPARATOR
+                           << teams_[n].base_income() << COLUMN_SEPARATOR
+                           << teams_[n].village_gold() << COLUMN_SEPARATOR
+                           << (teams_[n].uses_fog()    ? "yes" : "no") << 
COLUMN_SEPARATOR
+                           << (teams_[n].uses_shroud() ? "yes" : "no") << 
COLUMN_SEPARATOR;
+
+                       items.push_back(str.str());
+               }
+
                int selected = 0;
                {
-                       gui::dialog slist(*gui_, "", "", gui::OK_CANCEL);
+                       gui::dialog slist(*gui_, _("Game Settings"), "", 
gui::OK_CANCEL);
                        slist.set_menu(items, &sorter);
                        selected = slist.show();
                } // this will kill the dialog before scrolling

Modified: trunk/src/menu_events.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/menu_events.hpp?rev=19694&r1=19693&r2=19694&view=diff
==============================================================================
--- trunk/src/menu_events.hpp (original)
+++ trunk/src/menu_events.hpp Tue Aug 21 00:05:00 2007
@@ -133,6 +133,7 @@
        bool has_friends() const;
        bool clear_shroud(const unsigned int team_num);
        static void change_side_controller(const std::string& side, const 
std::string& player, bool own_side=false);
+       void game_settings_table();
 
        game_display* gui_;
        unit_map& units_;

Modified: trunk/src/team.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/team.cpp?rev=19694&r1=19693&r2=19694&view=diff
==============================================================================
--- trunk/src/team.cpp (original)
+++ trunk/src/team.cpp Tue Aug 21 00:05:00 2007
@@ -93,8 +93,15 @@
          ai_memory_.append(**aimem);
        }
 
-
        gold = cfg["gold"];
+
+       // at the start of a game we need to take the value from the gold 
setting,
+       // at this time "start_gold" is not set, but maybe there is a better way
+       // to check for a game start
+       // this also handles the loading of older save files, though with wrong
+       // values for the start gold in the game settings screen
+       start_gold = lexical_cast_default<int>(cfg["start_gold"],
+                                              lexical_cast<int>(gold));
        income = cfg["income"];
        name = cfg["name"];
        team_name = cfg["team_name"];
@@ -265,6 +272,7 @@
        cfg["ai_algorithm"] = ai_algorithm;
 
        cfg["gold"] = gold;
+       cfg["start_gold"] = lexical_cast<std::string>(start_gold).c_str();
        cfg["income"] = income;
        cfg["name"] = name;
        cfg["team_name"] = team_name;

Modified: trunk/src/team.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/team.hpp?rev=19694&r1=19693&r2=19694&view=diff
==============================================================================
--- trunk/src/team.hpp (original)
+++ trunk/src/team.hpp Tue Aug 21 00:05:00 2007
@@ -68,6 +68,7 @@
                void write(config& cfg) const;
                std::string name;
                std::string gold;
+               int start_gold;
                std::string income;
                int income_per_village;
                std::set<std::string> can_recruit;
@@ -128,6 +129,10 @@
                { return villages_.count(loc) > 0; }
 
        int gold() const { return gold_; }
+       int start_gold() const { return info_.start_gold; }
+       int base_income() const
+               { return atoi(info_.income.c_str()) + game_config::base_income; 
}
+       int village_gold() const { return info_.income_per_village; }
        int income() const
                { return atoi(info_.income.c_str()) + 
villages_.size()*info_.income_per_village+game_config::base_income; }
        void new_turn() { gold_ += income(); }


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to