[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[netPanzer-CVS] netpanzer/src/NetPanzer/Classes SelectionList.c...
From: |
Hankin Chick |
Subject: |
[netPanzer-CVS] netpanzer/src/NetPanzer/Classes SelectionList.c... |
Date: |
Wed, 12 Nov 2003 03:28:32 -0500 |
CVSROOT: /cvsroot/netpanzer
Module name: netpanzer
Branch:
Changes by: Hankin Chick <address@hidden> 03/11/12 03:28:31
Modified files:
src/NetPanzer/Classes: SelectionList.cpp SelectionList.hpp
WorldInputCmdProcessor.cpp
WorldInputCmdProcessor.hpp
Log message:
press 1-9 to select groups
hold down 1-9 keys together to select multiple groups
press ctrl 1-9 to make groups
alt 1-9 to cycle
Patches:
Index: netpanzer/src/NetPanzer/Classes/SelectionList.cpp
diff -u netpanzer/src/NetPanzer/Classes/SelectionList.cpp:1.5
netpanzer/src/NetPanzer/Classes/SelectionList.cpp:1.6
--- netpanzer/src/NetPanzer/Classes/SelectionList.cpp:1.5 Tue Sep 16
16:16:11 2003
+++ netpanzer/src/NetPanzer/Classes/SelectionList.cpp Wed Nov 12 03:28:31 2003
@@ -19,6 +19,7 @@
#include "SelectionList.hpp"
#include "UnitInterface.hpp"
#include "PlayerInterface.hpp"
+#include "Log.hpp"
int selectKey( void *key, UnitState *comp )
{
@@ -230,23 +231,29 @@
void SelectionList::copyList( SelectionList &source_list )
{
+ unGroup();
+
+ addList(source_list);
+
+}
+
+void SelectionList::addList( SelectionList &source_list )
+{
unsigned long list_index;
unsigned long list_size;
- deselect();
- unit_list.removeAll();
-
- list_size = source_list.unit_list.getSize();
+ list_size=source_list.unit_list.contains;
for ( list_index = 0; list_index < list_size; list_index++ ) {
- unit_list.add( source_list.unit_list[ list_index ], list_index );
+ unit_list.add( source_list.unit_list[ list_index ], unit_list.contains
);
}
- unit_list.contains = source_list.unit_list.contains;
unit_cycle_index = source_list.unit_cycle_index;
resetUnitCycling();
}
+
+
unsigned short SelectionList::getHeadUnitType( void )
{
Index: netpanzer/src/NetPanzer/Classes/SelectionList.hpp
diff -u netpanzer/src/NetPanzer/Classes/SelectionList.hpp:1.5
netpanzer/src/NetPanzer/Classes/SelectionList.hpp:1.6
--- netpanzer/src/NetPanzer/Classes/SelectionList.hpp:1.5 Tue Sep 16
16:16:11 2003
+++ netpanzer/src/NetPanzer/Classes/SelectionList.hpp Wed Nov 12 03:28:31 2003
@@ -73,6 +73,7 @@
void cycleNextUnit( void );
void copyList( SelectionList &source_list );
+ void addList( SelectionList &source_list );
void validateList( void );
Index: netpanzer/src/NetPanzer/Classes/WorldInputCmdProcessor.cpp
diff -u netpanzer/src/NetPanzer/Classes/WorldInputCmdProcessor.cpp:1.24
netpanzer/src/NetPanzer/Classes/WorldInputCmdProcessor.cpp:1.25
--- netpanzer/src/NetPanzer/Classes/WorldInputCmdProcessor.cpp:1.24 Sun Nov
9 02:54:17 2003
+++ netpanzer/src/NetPanzer/Classes/WorldInputCmdProcessor.cpp Wed Nov 12
03:28:31 2003
@@ -16,6 +16,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <config.h>
+#include <sstream>
#include "WorldInputCmdProcessor.hpp"
#include "MouseInterface.hpp"
@@ -36,6 +37,7 @@
#include "PlacementMatrix.hpp"
#include "Sound.hpp"
#include "ScreenSurface.hpp"
+#include "Log.hpp"
#include "GameConfig.hpp"
@@ -297,19 +299,63 @@
void WorldInputCmdProcessor::evaluateGroupingKeys( void )
{
- bool shift_status = false;
bool alt_status = false;
+ bool ctrl_status = false;
- if( (KeyboardInterface::getKeyState( SDLK_LSHIFT ) == true) ||
- (KeyboardInterface::getKeyState( SDLK_RSHIFT ) == true)
+ if( (KeyboardInterface::getKeyState( SDLK_LCTRL ) == true) ||
+ (KeyboardInterface::getKeyState( SDLK_RCTRL ) == true)
) {
- shift_status = true;
+ ctrl_status = true;
}
- if( (KeyboardInterface::getKeyState( SDLK_LALT ) == true) ) {
+ if( (KeyboardInterface::getKeyState( SDLK_LALT ) == true) ||
+ (KeyboardInterface::getKeyState( SDLK_RALT ) == true)
+ ) {
alt_status = true;
}
+ unsigned selected_bits=0;
+ int released=0;
+ for(int key_code=SDLK_0; key_code<=SDLK_9; key_code++) {
+ unsigned int b=1 << (key_code-SDLK_0);
+ if ( (KeyboardInterface::getKeyState( key_code ) == true) ) {
+ selected_bits|=b;
+ }
+ else if(current_selection_list_bits&b) {
+ // we've released a key
+ released++;
+ }
+ }
+ if(released==0 && selected_bits>0 &&
selected_bits!=current_selection_list_bits) {
+ // we've pressed down a number key
+ if(ctrl_status != true && alt_status != true) {
+ working_list.unGroup();
+ }
+ for(int key_code=SDLK_0; key_code<=SDLK_9; key_code++) {
+ if ( (KeyboardInterface::getKeyState( key_code ) != true) ) {
+ continue;
+ }
+ int n=key_code-SDLK_0;
+ if(ctrl_status == true) {
+ setSelectionList(n);
+ std::stringstream s;
+ s << "Group " << n << " Created";
+ ConsoleInterface::postMessage( s.str().c_str() );
+ continue;
+ }
+ if(alt_status == true) {
+ cycleSelectedUnits(n);
+ continue;
+ }
+ working_list.addList( selection_group_lists[ n ] );
+//LOG(("select:%i,working:%i,",n,working_list.unit_list.contains));
+ }
+ if(alt_status != true) {
+ working_list.select();
+ }
+ }
+ current_selection_list_bits=selected_bits;
+#if 0
//*********************************************************
if ( (KeyboardInterface::getKeyState( SDLK_1 ) == true) &&
(KeyboardInterface::getPrevKeyState( SDLK_1) == false) ) {
@@ -449,6 +495,7 @@
cycleSelectedUnits(0);
}
} // ** if
+#endif
}
@@ -549,6 +596,7 @@
return( select_success );
} else {
current_selection_list_index = 0xFFFF;
+ current_selection_list_bits=0;
return( select_success );
}
@@ -638,6 +686,7 @@
working_list.selectUnit( world_pos );
}
+ current_selection_list_bits=0;
current_selection_list_index = 0xFFFF;
if ( working_list.unit_list.containsItems() > 0 ) {
UnitBase *unit =
UnitInterface::getUnit(working_list.unit_list[0]);
Index: netpanzer/src/NetPanzer/Classes/WorldInputCmdProcessor.hpp
diff -u netpanzer/src/NetPanzer/Classes/WorldInputCmdProcessor.hpp:1.7
netpanzer/src/NetPanzer/Classes/WorldInputCmdProcessor.hpp:1.8
--- netpanzer/src/NetPanzer/Classes/WorldInputCmdProcessor.hpp:1.7 Sun Nov
9 02:54:17 2003
+++ netpanzer/src/NetPanzer/Classes/WorldInputCmdProcessor.hpp Wed Nov 12
03:28:31 2003
@@ -44,6 +44,7 @@
SelectionList selection_group_lists[10];
SelectionList working_list;
unsigned long current_selection_list_index;
+ unsigned int current_selection_list_bits;
SelectionList target_list;
void initializeSelectionLists( void );
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [netPanzer-CVS] netpanzer/src/NetPanzer/Classes SelectionList.c...,
Hankin Chick <=