mail[Wesnoth-commits] r20187 - in /trunk/src: dialogs.cpp menu_events.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by gurt on September 08, 2007 - 04:12:
Author: hajo
Date: Sat Sep  8 04:11:52 2007
New Revision: 20187

URL: http://svn.gna.org/viewcvs/wesnoth?rev=20187&view=rev
Log:
Doxygen, comment, Contrast/colors for stats-dialog and unit_preview_pane.

Modified:
    trunk/src/dialogs.cpp
    trunk/src/menu_events.cpp

Modified: trunk/src/dialogs.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/dialogs.cpp?rev=20187&r1=20186&r2=20187&view=diff
==============================================================================
--- trunk/src/dialogs.cpp (original)
+++ trunk/src/dialogs.cpp Sat Sep  8 04:11:52 2007
@@ -11,6 +11,9 @@
 
    See the COPYING file for more details.
 */
+
+//! @file dialogs.cpp 
+//! Various dialogs: advance_unit, show_objectives, save+load game, 
network::connection.
 
 #include "global.hpp"
 
@@ -25,6 +28,7 @@
 #include "menu_events.hpp"
 #include "minimap.hpp"
 #include "replay.hpp"
+//#include "sound.hpp" 
 #include "thread.hpp"
 #include "wassert.hpp"
 #include "wml_separators.hpp"
@@ -118,12 +122,13 @@
 
        LOG_DP << "animating advancement...\n";
        animate_unit_advancement(info,units,loc,gui,size_t(res));
-
-       // in some rare cases the unit can have enough XP to advance again so 
try to do that,
-       // make sure that we're no entering an infinite level loop
+       
+       // In some rare cases the unit can have enough XP to advance again, 
+       // so try to do that. 
+       // Make sure that we don't enter an infinite level loop.
        u = units.find(loc);
        if(u != units.end()) {
-               // level 10 unit gives 80 XP and the highest mainline is 
level 5
+               // Level 10 unit gives 80 XP and the highest mainline is 
level 5
                if(u->second.experience() < 81) {
                        advance_unit(info, map, units, loc, gui, 
random_choice, add_replay_event);
                } else {
@@ -151,8 +156,8 @@
                return false;
        }
 
-       //when the unit advances, it fades to white, and then switches to the
-       //new unit, then fades back to the normal colour
+       // When the unit advances, it fades to white, and then switches 
+       // to the new unit, then fades back to the normal colour
 
        if(!gui.video().update_locked()) {
                u->second.set_leveling_out(gui,u->first);
@@ -173,7 +178,7 @@
                LOG_NG << "firing advance event (AMLA)\n";
                game_events::fire("advance",loc);
 
-               amla_unit.get_experience(-amla_unit.max_experience()); 
//subtract xp required
+               amla_unit.get_experience(-amla_unit.max_experience()); // 
subtract xp required
                amla_unit.add_modification("advance",*mod_options[choice - 
options.size()]);
                units.replace(new 
std::pair<gamemap::location,unit>(loc,amla_unit));
 
@@ -261,7 +266,7 @@
        return res;
 }
 
-//a class to handle deleting a saved game
+//! Class to handle deleting a saved game.
 namespace {
 
 class delete_save : public gui::dialog_button_action
@@ -281,14 +286,14 @@
        const size_t index = size_t(menu_selection);
        if(index < saves_.size()) {
 
-               //see if we should ask the user for deletion confirmation
+               // See if we should ask the user for deletion confirmation
                if(preferences::ask_delete_saves()) {
                        gui::dialog dmenu(disp_,"",
                                               _("Do you really want to 
delete this game?"),
                                               gui::YES_NO);
                        dmenu.add_option(_("Don't ask me again!"), true);
                        const int res = dmenu.show();
-                       //see if the user doesn't want to be asked this again
+                       // See if the user doesn't want to be asked this again
                        if(dmenu.option_checked()) {
                                preferences::set_ask_delete_saves(false);
                        }
@@ -298,10 +303,10 @@
                        }
                }
 
-               //delete the file
+               // Delete the file
                delete_game(saves_[index].name);
 
-               //remove it from the list of saves
+               // Remove it from the list of saves
                saves_.erase(saves_.begin() + index);
 
                if(index < summaries_.size()) {
@@ -447,7 +452,7 @@
 
        std::stringstream str;
 
-       // escape all special characters in filenames
+       // Escape all special characters in filenames
        std::string name = (*info_)[index_].name;
        str << font::BOLD_TEXT << utils::escape(name) << "\n" << time_buf;
 
@@ -508,17 +513,17 @@
        if(current_time.tm_year == save_time.tm_year) {
                const int days_apart = current_time.tm_yday - 
save_time.tm_yday;
                if(days_apart == 0) {
-                       //save is from today
+                       // save is from today
                        format_string = _("%H:%M");
                } else if(days_apart > 0 && days_apart <= 
current_time.tm_wday) {
-                       //save is from this week
+                       // save is from this week
                        format_string = _("%A, %H:%M");
                } else {
-                       //save is from current year
+                       // save is from current year
                        format_string = _("%b %d");
                }
        } else {
-               //save is from a different year
+               // save is from a different year
                format_string = _("%b %d %y");
        }
 
@@ -531,7 +536,7 @@
        return buf;
 }
 
-} //end anon namespace
+} // end anon namespace
 
 std::string load_game_dialog(display& disp, const config& game_config, const 
game_data& data, bool* show_replay)
 {
@@ -584,7 +589,7 @@
                          gui::OK_CANCEL);
        lmenu.set_menu(items, &sorter);
        lmenu.add_pane(&save_preview);
-       //create an option for whether the replay should be shown or not
+       // create an option for whether the replay should be shown or not
        if(show_replay != NULL)
                lmenu.add_option(_("Show replay"), false);
        lmenu.add_button(delete_button);
@@ -611,6 +616,7 @@
        static const int unit_preview_border = 10;
 }
 
+//! Show unit-stats in a side-pane to unit-list, recall-list, etc.
 unit_preview_pane::unit_preview_pane(game_display& disp, const gamemap* map, 
const unit& u, TYPE type, bool on_left_side)
                                    : gui::preview_pane(disp.video()), 
disp_(disp),
                                      
details_button_(disp.video(),_("Profile"),gui::button::TYPE_PRESS,"lite_small",gui::button::MINIMUM_SPACE),
@@ -691,7 +697,7 @@
                image_rect = rect;
        }
 
-       //place the 'unit profile' button
+       // Place the 'unit profile' button
        if(map_ != NULL) {
                const SDL_Rect button_loc = {right_align ? area.x : area.x + 
area.w - details_button_.location().w,
                                             image_rect.y + image_rect.h,
@@ -705,13 +711,20 @@
                std::stringstream desc;
                desc << font::NORMAL_TEXT << u.description();
                const std::string description = desc.str();
-               description_rect = 
font::text_area(description,font::SIZE_NORMAL);
-               description_rect = 
font::draw_text(&video(),area,font::SIZE_NORMAL,font::NORMAL_COLOUR,desc.str(),right_align
 ? image_rect.x : image_rect.x + image_rect.w - 
description_rect.w,image_rect.y+image_rect.h+details_button_.location().h);
-       }
-
+               description_rect = font::text_area(description, 
font::SIZE_NORMAL);
+               description_rect = font::draw_text(&video(), area, 
+                                                       font::SIZE_NORMAL, 
font::NORMAL_COLOUR, 
+                                                       desc.str(), 
right_align ?  image_rect.x : 
+                                                       image_rect.x + 
image_rect.w - description_rect.w, 
+                                                       image_rect.y + 
image_rect.h + details_button_.location().h);
+       }
+
+//%%
        std::stringstream details;
        details << u.language_name()
-                       << "\n" << _("level") << " "
+                       << "\n" 
+                       << font::BOLD_TEXT  
+                       << _("level") << " "
                        << u.level() << "\n"
                        << unit_type::alignment_description(u.alignment()) << 
"\n"
                        << u.traits_description() << " \n";
@@ -727,43 +740,33 @@
 
        details << " \n";
 
-       //display in green/white/red depending on hitpoints
-       if(u.hitpoints() <= u.max_hitpoints()/3)
-               details << font::BAD_TEXT;
-       else if(u.hitpoints() > 2*(u.max_hitpoints()/3))
-               details << font::GOOD_TEXT;
-
-       details << _("HP: ") << u.hitpoints()
-                       << "/" << u.max_hitpoints() << "\n";
-
-       if(u.can_advance() == false) {
-               details << _("XP: ") << u.experience() << "/-";
-       } else {
-               //if killing a unit the same level as us would level us up,
-               //then display in green
-               if(u.max_experience() - u.experience() < 
game_config::kill_experience) {
-                       details << font::GOOD_TEXT;
-               }
-
-               details << _("XP: ") << u.experience() << "/" << 
u.max_experience();
-       }
+       // Use same coloring as in generate_report.cpp:
+       details << font::color2markup(u.hp_color()) << _("HP: ")
+                       << u.hitpoints() << "/" << u.max_hitpoints() << "\n";
+
+       details << font::color2markup(u.xp_color()) << _("XP: ")  
+                       << u.experience() << "/" << u.max_experience();
 
        if(weapons_) {
                details << "\n"
                                << _("Moves: ") << u.movement_left() << "/"
                                << u.total_movement()
                                << "\n";
-
+//%%
                std::vector<attack_type>& attacks = u.attacks();
                for(std::vector<attack_type>::iterator at_it = 
attacks.begin();
                    at_it != attacks.end(); ++at_it) {
                        at_it->set_specials_context(gamemap::location(),u);
 
-                       details << "\n" << at_it->name()
+                       details << "\n" 
+                                       << "<245,230,193>"              // 
see generate_report() in generate_report.cpp
+                                       << at_it->name() 
                                << " (" << gettext(at_it->type().c_str()) << 
")\n";
 
-                       details << at_it->weapon_specials(true);
+                       details << "<166,146,117>  "
+                                       << at_it->weapon_specials(true);
                        details << "\n"
+                                       << "<166,146,117>  "
                                << at_it->damage() << "-" << 
at_it->num_attacks() << " -- "
                                << _(at_it->range().c_str());
                }
@@ -891,7 +894,7 @@
        const size_t border = 20;
 #endif
        const int left = disp.w()/2 - width/2;
-       const int top = disp.h()/2 - height/2;
+       const int top  = disp.h()/2 - height/2;
 
        const events::event_context dialog_events_context;
 
@@ -949,7 +952,7 @@
                                                           
network::get_receive_stats);
 }
 
-}
+} // end namespace dialogs
 
 namespace {
 
@@ -992,7 +995,7 @@
        const size_t height = 20;
 #endif
        const int left = disp.w()/2 - width/2;
-       const int top = disp.h()/2 - height/2;
+       const int top  = disp.h()/2 - height/2;
 
        const events::event_context dialog_events_context;
 
@@ -1010,4 +1013,4 @@
        return network::connect(hostname,port,waiter);
 }
 
-} //end namespace dialogs
+} // end namespace dialogs

Modified: trunk/src/menu_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/menu_events.cpp?rev=20187&r1=20186&r2=20187&view=diff
==============================================================================
--- trunk/src/menu_events.cpp (original)
+++ trunk/src/menu_events.cpp Sat Sep  8 04:11:52 2007
@@ -12,6 +12,10 @@
 
    See the COPYING file for more details.
 */
+
+//! @file menu_events.cpp
+//! Operations activated from menus/hotkeys while playing a game.
+//! E.g. Unitlist, status_table, save_game, save_map, chat, show_help, etc.
 
 #include "global.hpp"
 
@@ -91,7 +95,7 @@
                set_result(gui::CLOSE_DIALOG);
        }
 
-       //prepare the sub-dialog for Statistic Details
+       // Prepare the sub-dialog for Statistic Details
        std::string title;
        std::vector<std::string> items_sub;
        switch(result()) {
@@ -143,7 +147,7 @@
        stats_ = statistics::calculate_stats(0, team_num_);
        int n;
        std::vector<std::string> items;
-       //prepare the menu items
+       // Prepare the menu items
        {
                std::stringstream str;
                n = statistics::sum_str_int_map(stats_.recruits);
@@ -164,7 +168,8 @@
                std::stringstream str;
                n = statistics::sum_str_int_map(stats_.advanced_to);
                unit_count_[2] = n;
-               str << _("Advancements") << COLUMN_SEPARATOR << n;
+        str << font::BOLD_TEXT << _("Advancements") << COLUMN_SEPARATOR
+            << font::BOLD_TEXT << n;
                items.push_back(str.str());
        }
 
@@ -186,7 +191,8 @@
 
        {
                std::stringstream str;
-               str << _("Damage Inflicted") << COLUMN_SEPARATOR << 
stats_.damage_inflicted;
+        str << font::BOLD_TEXT << _("Damage Inflicted") << COLUMN_SEPARATOR
+            << font::BOLD_TEXT << stats_.damage_inflicted;
                items.push_back(str.str());
        }
 
@@ -198,8 +204,8 @@
 
        {
                std::stringstream str;
-               str << _("Damage Inflicted (EV)") << COLUMN_SEPARATOR
-                       << (stats_.expected_damage_inflicted / 100.0);
+        str << font::BOLD_TEXT << _("Damage Inflicted (EV)") << 
COLUMN_SEPARATOR
+            << font::BOLD_TEXT << (stats_.expected_damage_inflicted / 100.0);
                items.push_back(str.str());
        }
 
@@ -216,7 +222,7 @@
 {
 }
 
-} //end anonymous namespace
+} // end anonymous namespace
 
 namespace events{
 
@@ -337,14 +343,19 @@
                                continue;
 
                        std::stringstream row;
-                       // if a unit is already selected on the map, we do 
the same in the unit list dialog
+                       // If a unit is already selected on the map, we do 
the same in the unit list dialog
                        if (gui_->selected_hex() == i->first) {
                                 row << DEFAULT_ITEM;
                                 selected = units_list.size();
                        }
 //%%
-                       // If unit is leader, show name in golden
+                       // If unit is leader, show name in special color, 
e.g. gold/silver
                        //! @todo TODO: hero just has overlay 
"misc/hero-icon.png" - needs an ability to query
+
+                       if(i->second.can_recruit() ) {
+                               row << "<255,255,200>";
+//              row << "<205,173,0>";   // gold3
+                       }
                        row << i->second.language_name() << COLUMN_SEPARATOR;
                        if(i->second.can_recruit() ) {
                                row << "<255,255,200>";
@@ -2191,4 +2202,5 @@
 
                network::send_data(cfg);
        }
-}
+} // end namespace events
+




Related Messages


Powered by MHonArc, Updated Sat Sep 08 04:40:20 2007