wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth ./changelog data/game.cfg src/hotkeys.c...


From: John McNabb
Subject: [Wesnoth-cvs-commits] wesnoth ./changelog data/game.cfg src/hotkeys.c...
Date: Wed, 18 May 2005 10:06:30 -0400

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     John McNabb <address@hidden>    05/05/18 14:06:30

Modified files:
        .              : changelog 
        data           : game.cfg 
        src            : hotkeys.cpp hotkeys.hpp playturn.cpp 
                         playturn.hpp unit.cpp unit.hpp 

Log message:
        new hotkeys

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/changelog.diff?tr1=1.675&tr2=1.676&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/data/game.cfg.diff?tr1=1.155&tr2=1.156&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/hotkeys.cpp.diff?tr1=1.76&tr2=1.77&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/hotkeys.hpp.diff?tr1=1.59&tr2=1.60&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/playturn.cpp.diff?tr1=1.371&tr2=1.372&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/playturn.hpp.diff?tr1=1.67&tr2=1.68&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/unit.cpp.diff?tr1=1.151&tr2=1.152&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/unit.hpp.diff?tr1=1.68&tr2=1.69&r1=text&r2=text

Patches:
Index: wesnoth/changelog
diff -u wesnoth/changelog:1.675 wesnoth/changelog:1.676
--- wesnoth/changelog:1.675     Tue May 17 20:44:10 2005
+++ wesnoth/changelog   Wed May 18 14:06:22 2005
@@ -1,5 +1,7 @@
 CVS HEAD:
  * user interface improvements:
+   * added hotkey for cycle to previous unit (shift-N) (part of #10703)
+   * added hotkey for hold position (patch 3994)
    * made the right Command key on Mac OS X work like the left one
    * made the 100 gold minimum for next scenario explicitly mentioned (#12987)
    * made menu widgets sortable
Index: wesnoth/data/game.cfg
diff -u wesnoth/data/game.cfg:1.155 wesnoth/data/game.cfg:1.156
--- wesnoth/data/game.cfg:1.155 Fri May  6 01:13:27 2005
+++ wesnoth/data/game.cfg       Wed May 18 14:06:29 2005
@@ -161,10 +161,20 @@
        key=n
        [/hotkey]
        [hotkey]
+       command=cycleback
+       key=n
+       shift=yes
+       [/hotkey]
+       [hotkey]
        command=endunitturn
        key=" "
        [/hotkey]
        [hotkey]
+       command=holdposition
+       key=" "
+       shift=yes
+       [/hotkey]
+       [hotkey]
        command=leader
        key=l
        [/hotkey]
@@ -330,10 +340,20 @@
        key=n
        [/hotkey]
        [hotkey]
+       command=cycleback
+       key=n
+       shift=yes
+       [/hotkey]
+       [hotkey]
        command=endunitturn
        key=" "
        [/hotkey]
        [hotkey]
+       command=holdposition
+       key=" "
+       shift=yes
+       [/hotkey]
+       [hotkey]
        command=leader
        key=l
        [/hotkey]
Index: wesnoth/src/hotkeys.cpp
diff -u wesnoth/src/hotkeys.cpp:1.76 wesnoth/src/hotkeys.cpp:1.77
--- wesnoth/src/hotkeys.cpp:1.76        Thu May 12 20:47:05 2005
+++ wesnoth/src/hotkeys.cpp     Wed May 18 14:06:29 2005
@@ -1,4 +1,4 @@
-/* $Id: hotkeys.cpp,v 1.76 2005/05/12 20:47:05 ott Exp $ */
+/* $Id: hotkeys.cpp,v 1.77 2005/05/18 14:06:29 darthfool Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -43,6 +43,8 @@
        bool hidden;
 } hotkey_list_[] = {
        { hotkey::HOTKEY_CYCLE_UNITS, "cycle", N_("Next unit"), false },
+       { hotkey::HOTKEY_CYCLE_BACK_UNITS, "cycleback", N_("Previous unit"), 
false },
+       { hotkey::HOTKEY_UNIT_HOLD_POSITION, "holdposition", N_("Hold 
Position"), false},
        { hotkey::HOTKEY_END_UNIT_TURN, "endunitturn", N_("End Unit Turn"), 
false },
        { hotkey::HOTKEY_LEADER, "leader", N_("Leader"), false },
        { hotkey::HOTKEY_UNDO, "undo", N_("Undo"), false },
@@ -411,10 +413,18 @@
                        if(executor)
                                executor->cycle_units();
                        break;
+               case HOTKEY_CYCLE_BACK_UNITS:
+                       if(executor)
+                               executor->cycle_back_units();
+                       break;
                case HOTKEY_ENDTURN:
                        if(executor)
                                executor->end_turn();
                        break;
+               case HOTKEY_UNIT_HOLD_POSITION:
+                       if(executor)
+                executor->unit_hold_position();
+                       break;
                case HOTKEY_END_UNIT_TURN:
                        if(executor)
                                executor->end_unit_turn();
Index: wesnoth/src/hotkeys.hpp
diff -u wesnoth/src/hotkeys.hpp:1.59 wesnoth/src/hotkeys.hpp:1.60
--- wesnoth/src/hotkeys.hpp:1.59        Sun Apr 17 20:42:10 2005
+++ wesnoth/src/hotkeys.hpp     Wed May 18 14:06:29 2005
@@ -1,4 +1,4 @@
-/* $Id: hotkeys.hpp,v 1.59 2005/04/17 20:42:10 gruikya Exp $ */
+/* $Id: hotkeys.hpp,v 1.60 2005/05/18 14:06:29 darthfool Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -28,7 +28,8 @@
 namespace hotkey {
 
 enum HOTKEY_COMMAND {
-       HOTKEY_CYCLE_UNITS, HOTKEY_END_UNIT_TURN, HOTKEY_LEADER,
+       HOTKEY_CYCLE_UNITS,HOTKEY_CYCLE_BACK_UNITS, HOTKEY_UNIT_HOLD_POSITION, 
+       HOTKEY_END_UNIT_TURN, HOTKEY_LEADER,
        HOTKEY_UNDO, HOTKEY_REDO,
        HOTKEY_ZOOM_IN, HOTKEY_ZOOM_OUT, HOTKEY_ZOOM_DEFAULT,
        HOTKEY_FULLSCREEN, HOTKEY_SCREENSHOT, HOTKEY_ACCELERATED,
@@ -129,8 +130,10 @@
 public:
 
        virtual void cycle_units() {}
+       virtual void cycle_back_units() {}
        virtual void end_turn() {}
        virtual void goto_leader() {}
+       virtual void unit_hold_position() {}
        virtual void end_unit_turn() {}
        virtual void undo() {}
        virtual void redo() {}
Index: wesnoth/src/playturn.cpp
diff -u wesnoth/src/playturn.cpp:1.371 wesnoth/src/playturn.cpp:1.372
--- wesnoth/src/playturn.cpp:1.371      Tue May 17 20:34:56 2005
+++ wesnoth/src/playturn.cpp    Wed May 18 14:06:30 2005
@@ -1,4 +1,4 @@
-/* $Id: playturn.cpp,v 1.371 2005/05/17 20:34:56 ott Exp $ */
+/* $Id: playturn.cpp,v 1.372 2005/05/18 14:06:30 darthfool Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -1036,6 +1036,7 @@
        //commands we can always do
        case hotkey::HOTKEY_LEADER:
        case hotkey::HOTKEY_CYCLE_UNITS:
+       case hotkey::HOTKEY_CYCLE_BACK_UNITS:
        case hotkey::HOTKEY_ZOOM_IN:
        case hotkey::HOTKEY_ZOOM_OUT:
        case hotkey::HOTKEY_ZOOM_DEFAULT:
@@ -1091,6 +1092,7 @@
                return !browse_ && !commands_disabled && 
current_team().auto_shroud_updates() == false;
 
        //commands we can only do if we are actually playing, not just viewing
+       case hotkey::HOTKEY_UNIT_HOLD_POSITION:
        case hotkey::HOTKEY_END_UNIT_TURN:
        case hotkey::HOTKEY_RECRUIT:
        case hotkey::HOTKEY_REPEAT_RECRUIT:
@@ -1203,9 +1205,7 @@
 
 void turn_info::cycle_units()
 {
-
        unit_map::const_iterator it = units_.find(next_unit_);
-       unit_map::const_iterator yellow_it = units_.end();
        if(it != units_.end()) {
                for(++it; it != units_.end(); ++it) {
                        if(unit_in_cycle(it)) {
@@ -1244,6 +1244,47 @@
        }
 }
 
+void turn_info::cycle_back_units()
+{
+       unit_map::const_iterator it = units_.find(next_unit_);
+       if(it != units_.begin()) {
+               for(--it; it != units_.begin(); --it) {
+                       if(unit_in_cycle(it)) {
+                               break;
+                       }
+               }
+       }
+
+       if(it == units_.begin()) {
+               for(it = units_.end(); it != units_.begin(); --it) {
+                       if(unit_in_cycle(it)) {
+                               break;
+                       }
+               }
+       }
+
+       if(it != units_.begin() && !gui_.fogged(it->first.x,it->first.y)) {
+               const bool ignore_zocs = it->second.type().is_skirmisher();
+               const bool teleport = it->second.type().teleports();
+               current_paths_ = 
paths(map_,status_,gameinfo_,units_,it->first,teams_,ignore_zocs,teleport,path_turns_);
+               gui_.set_paths(&current_paths_);
+
+               gui_.scroll_to_tile(it->first.x,it->first.y,display::WARP);
+       }
+
+       if(it != units_.begin()) {
+               next_unit_ = it->first;
+               selected_hex_ = next_unit_;
+               gui_.select_hex(selected_hex_);
+               gui_.highlight_hex(selected_hex_);
+               current_route_.steps.clear();
+               gui_.set_route(NULL);
+               show_attack_options(it);
+       } else {
+               next_unit_ = gamemap::location();
+       }
+}
+
 void turn_info::end_turn()
 {
        if(browse_)
@@ -1312,6 +1353,28 @@
        }
 }
 
+void turn_info::unit_hold_position()
+{
+       if(browse_)
+               return;
+
+       const unit_map::iterator un = units_.find(selected_hex_);
+       if(un != units_.end() && un->second.side() == team_num_ && 
un->second.movement_left() >= 0) {
+               un->second.set_hold_position(!un->second.hold_position());
+               gui_.draw_tile(selected_hex_.x,selected_hex_.y);
+
+               gui_.set_route(NULL);
+               gui_.set_paths(NULL);
+               current_paths_ = paths();
+               gui_.draw();
+
+               if(un->second.hold_position()) {
+                       un->second.set_user_end_turn(true);
+                       cycle_units();
+               }
+       }       
+}
+
 void turn_info::end_unit_turn()
 {
        if(browse_)
@@ -1320,6 +1383,9 @@
        const unit_map::iterator un = units_.find(selected_hex_);
        if(un != units_.end() && un->second.side() == team_num_ && 
un->second.movement_left() >= 0) {
                un->second.set_user_end_turn(!un->second.user_end_turn());
+               if(un->second.hold_position() && !un->second.user_end_turn()){
+                 un->second.set_hold_position(false);
+               }
                gui_.draw_tile(selected_hex_.x,selected_hex_.y);
 
                gui_.set_route(NULL);
Index: wesnoth/src/playturn.hpp
diff -u wesnoth/src/playturn.hpp:1.67 wesnoth/src/playturn.hpp:1.68
--- wesnoth/src/playturn.hpp:1.67       Thu Mar 24 21:18:26 2005
+++ wesnoth/src/playturn.hpp    Wed May 18 14:06:30 2005
@@ -1,4 +1,4 @@
-/* $Id: playturn.hpp,v 1.67 2005/03/24 21:18:26 silene Exp $ */
+/* $Id: playturn.hpp,v 1.68 2005/05/18 14:06:30 darthfool Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -136,8 +136,10 @@
        
        //overridden from command_executor
        virtual void cycle_units();
+       virtual void cycle_back_units();
        virtual void end_turn();
        virtual void goto_leader();
+       virtual void unit_hold_position();
        virtual void end_unit_turn();
        virtual void undo();
        virtual void redo();
Index: wesnoth/src/unit.cpp
diff -u wesnoth/src/unit.cpp:1.151 wesnoth/src/unit.cpp:1.152
--- wesnoth/src/unit.cpp:1.151  Tue May 10 22:15:57 2005
+++ wesnoth/src/unit.cpp        Wed May 18 14:06:30 2005
@@ -1,4 +1,4 @@
-/* $Id: unit.cpp,v 1.151 2005/05/10 22:15:57 Sirp Exp $ */
+/* $Id: unit.cpp,v 1.152 2005/05/18 14:06:30 darthfool Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -69,7 +69,8 @@
        moves_(0), user_end_turn_(false), facingLeft_(true),
        resting_(false),
        recruit_(false),
-       guardian_(false), upkeep_(UPKEEP_FREE)
+       guardian_(false), upkeep_(UPKEEP_FREE),
+       hold_position_(false)
 {
        read(data,cfg);
 }
@@ -98,6 +99,7 @@
               maxMovement_(type_->movement()),
               backupMaxMovement_(type_->movement()),
               resting_(false), recruit_(false), attacks_(type_->attacks()),
+              hold_position_(false),
               backupAttacks_(type_->attacks()),
                guardian_(false), upkeep_(UPKEEP_FULL_PRICE),
                unrenamable_(false)
@@ -125,6 +127,7 @@
        experience_(0),
        maxExperience_(type_->experience_needed()),
        backupMaxExperience_(type_->experience_needed()),
+       hold_position_(u.hold_position_),
        side_(u.side()), moves_(u.moves_),
        user_end_turn_(false), facingLeft_(u.facingLeft_),
        maxMovement_(type_->movement()),
@@ -262,10 +265,22 @@
 
 void unit::set_movement(int moves)
 {
+       hold_position_ = false;
        user_end_turn_ = false;
        moves_ = moves;
 }
 
+//This does not mark the unit's turn as being done even if value is true. To 
do that, either call void unit_hold_position(), or set_user_end_turn(value).
+void unit::set_hold_position(bool value)
+{
+       hold_position_ = value;
+}
+
+bool unit::hold_position() const
+{
+       return hold_position_;
+}
+
 void unit::set_user_end_turn(bool value)
 {
        user_end_turn_ = value;
@@ -279,6 +294,13 @@
 void unit::set_attacked()
 {
        moves_ = ATTACKED; 
+       set_hold_position(false);
+}
+
+void unit::unit_hold_position()
+{
+       hold_position_ = true;
+       user_end_turn_ = true;
 }
 
 void unit::end_unit_turn()
@@ -300,6 +322,9 @@
                set_flag("nightstalk");
        if(stone())
                set_attacked();
+       if (hold_position_) {
+               user_end_turn_ = true;
+       }
 }
 
 bool unit::move_interrupted() const {
Index: wesnoth/src/unit.hpp
diff -u wesnoth/src/unit.hpp:1.68 wesnoth/src/unit.hpp:1.69
--- wesnoth/src/unit.hpp:1.68   Fri Apr 29 21:37:26 2005
+++ wesnoth/src/unit.hpp        Wed May 18 14:06:30 2005
@@ -1,4 +1,4 @@
-/* $Id: unit.hpp,v 1.68 2005/04/29 21:37:26 silene Exp $ */
+/* $Id: unit.hpp,v 1.69 2005/05/18 14:06:30 darthfool Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -62,11 +62,14 @@
        bool can_recruit() const;
        int total_movement() const;
        int movement_left() const;
+       void set_hold_position(bool value);
+       bool hold_position() const;
        void set_user_end_turn(bool value=true);
        bool user_end_turn() const;
        bool can_attack() const;
        void set_movement(int moves);
        void set_attacked();
+       void unit_hold_position();
        void end_unit_turn();
        void new_turn();
        void end_turn();
@@ -188,6 +191,7 @@
        bool facingLeft_;
        int maxMovement_, backupMaxMovement_;
        bool resting_;
+       bool hold_position_;
 
        std::string underlying_description_, description_;
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]