1 /* 2 * Copyright (C) 2002, 2004, 2008-2009, 2011-2013 by The Widelands Development Team 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 * 18 */ 19 20 #ifndef WL_WUI_WATCHWINDOW_H 21 #define WL_WUI_WATCHWINDOW_H 22 23 #include "logic/widelands_geometry.h" 24 25 #include "ui_basic/button.h" 26 #include "ui_basic/window.h" 27 #include "wui/mapview.h" 28 29 class InteractiveGameBase; 30 namespace Widelands { 31 class Game; 32 } 33 34 struct WatchWindow : public UI::Window { 35 WatchWindow(InteractiveGameBase& parent, 36 int32_t x, 37 int32_t y, 38 uint32_t w, 39 uint32_t h, 40 bool single_window_ = false); 41 ~WatchWindow() override; 42 43 boost::signals2::signal<void(Vector2f)> warp_mainview; 44 45 void add_view(Widelands::Coords); 46 void follow(Widelands::Bob* bob); 47 48 private: 49 static constexpr size_t kViews = 5; 50 51 // Holds information for a view 52 struct View { 53 MapView::View view; 54 Widelands::ObjectPointer tracking; // if non-null, we're tracking a Bob 55 }; 56 57 Widelands::Game& game() const; 58 59 void think() override; 60 void stop_tracking_by_drag(); 61 void draw(RenderTarget&) override; 62 void save_coords(); 63 void next_view(); 64 void close_cur_view(); 65 void toggle_buttons(); 66 67 void do_follow(); 68 void do_goto(); 69 void view_button_clicked(uint8_t index); 70 void set_current_view(uint8_t idx, bool save_previous = true); 71 72 InteractiveGameBase& parent_; 73 MapView map_view_; 74 uint32_t last_visit_; 75 bool single_window_; 76 uint8_t cur_index_; 77 UI::Button* view_btns_[kViews]; 78 std::vector<WatchWindow::View> views_; 79 }; 80 81 WatchWindow* show_watch_window(InteractiveGameBase&, const Widelands::Coords&); 82 83 #endif // end of include guard: WL_WUI_WATCHWINDOW_H 84