Advanced Strategic Command
targetcoordinatelocator.cpp
Go to the documentation of this file.
1 
2 /***************************************************************************
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 2 of the License, or *
7  * (at your option) any later version. *
8  * *
9  ***************************************************************************/
10 
12 #include "../dialogs/fieldmarker.h"
13 #include "../spfst.h"
14 #include "../spfst-legacy.h"
15 #include "../mainscreenwidget.h"
16 #include "../mapdisplay.h"
17 #include "../iconrepository.h"
18 
19 
20 
21 SDL_Surface* TargetCoordinateLocator :: getImage()
22 {
23  return IconRepository::getIcon("target.png").getBaseSurface();
24 };
25 bool TargetCoordinateLocator :: eventMouseButtonDown (const SDL_MouseButtonEvent *button)
26 {
27  if ( button->button == 3 ) {
28  SelectFromMap sfm( positions, actmap, false, true);
29  sfm.Show();
30  sfm.RunModal();
31  }
32  if ( button->button == 1 ) {
34  md->cursor.goTo( *positions.begin() );
35  actmap->getCursor() = *positions.begin();
36  cursorMoved();
37  }
38 
39  return true;
40 }
41 
42 TargetCoordinateLocator::TargetCoordinateLocator(PG_Widget* parent, const PG_Point& pos, const SelectFromMap::CoordinateList& coordinates ) : PG_Image( parent, pos, getImage(), false )
43 {
44  positions = coordinates;
45 }
46 
MapCoordinate & getCursor()
Definition: gamemap.cpp:933
SDL_Surface * getBaseSurface()
Definition: surface.h:116
struct MapDisplayPG::Cursor cursor
void Show(bool fade=false)
bool eventMouseButtonDown(const SDL_MouseButtonEvent *button)
MapDisplayPG * getMapDisplay()
vector< MapCoordinate > CoordinateList
Definition: fieldmarker.h:45
static Surface & getIcon(const ASCString &name)
void goTo(const MapCoordinate &position)
MainScreenWidget * getMainScreenWidget()
sigc::signal< void > cursorMoved
Definition: spfst.cpp:48
GameMap * actmap
Definition: spfst.cpp:64
TargetCoordinateLocator(PG_Widget *parent, const PG_Point &pos, const SelectFromMap::CoordinateList &coordinates)