1 /* 2 Copyright © 2011-2012 Clint Bellanger 3 Copyright © 2014 Henrik Andersson 4 Copyright © 2012-2015 Justin Jacobs 5 6 This file is part of FLARE. 7 8 FLARE is free software: you can redistribute it and/or modify it under the terms 9 of the GNU General Public License as published by the Free Software Foundation, 10 either version 3 of the License, or (at your option) any later version. 11 12 FLARE is distributed in the hope that it will be useful, but WITHOUT ANY 13 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 14 PARTICULAR PURPOSE. See the GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License along with 17 FLARE. If not, see http://www.gnu.org/licenses/ 18 */ 19 20 /** 21 * GameStateLoad 22 * 23 * Display the current save-game slots 24 * Allow the player to continue a previous game 25 * Allow the player to start a new game 26 * Allow the player to abandon a previous game 27 */ 28 29 #ifndef GAMESTATELOAD_H 30 #define GAMESTATELOAD_H 31 32 #include "CommonIncludes.h" 33 #include "GameSlotPreview.h" 34 #include "GameState.h" 35 #include "StatBlock.h" 36 #include "Utils.h" 37 #include "WidgetLabel.h" 38 39 class ItemManager; 40 class MenuConfirm; 41 class WidgetButton; 42 class WidgetLabel; 43 class WidgetScrollBar; 44 45 class GameSlot { 46 public: 47 unsigned id; 48 49 StatBlock stats; 50 std::string current_map; 51 unsigned long time_played; 52 53 std::vector<int> equipped; 54 GameSlotPreview preview; 55 Timer preview_turn_timer; 56 57 WidgetLabel label_name; 58 WidgetLabel label_level; 59 WidgetLabel label_class; 60 WidgetLabel label_map; 61 WidgetLabel label_slot_number; 62 63 GameSlot(); 64 ~GameSlot(); 65 }; 66 67 class GameStateLoad : public GameState { 68 private: 69 70 void loadGraphics(); 71 void loadPortrait(int slot); 72 std::string getMapName(const std::string& map_filename); 73 void updateButtons(); 74 void refreshWidgets(); 75 void logicLoading(); 76 void readGameSlots(); 77 void loadPreview(GameSlot *slot); 78 79 void scrollUp(); 80 void scrollDown(); 81 void scrollToSelected(); 82 void refreshScrollBar(); 83 void setSelectedSlot(int slot); 84 85 void refreshSavePaths(); 86 87 TabList tablist; 88 89 WidgetButton *button_exit; 90 WidgetButton *button_new; 91 WidgetButton *button_load; 92 WidgetButton *button_delete; 93 WidgetLabel *label_loading; 94 WidgetScrollBar *scrollbar; 95 96 MenuConfirm *confirm; 97 98 Sprite *background; 99 Sprite *selection; 100 Sprite *portrait_border; 101 Sprite *portrait; 102 std::vector<Rect> slot_pos; 103 104 std::vector<GameSlot *> game_slots; 105 106 bool loading_requested; 107 bool loading; 108 bool loaded; 109 bool delete_items; 110 111 LabelInfo name_pos; 112 LabelInfo level_pos; 113 LabelInfo class_pos; 114 LabelInfo map_pos; 115 LabelInfo slot_number_pos; 116 Point sprites_pos; 117 118 Rect portrait_dest; 119 120 Rect gameslot_pos; 121 122 int selected_slot; 123 int visible_slots; 124 int scroll_offset; 125 bool has_scroll_bar; 126 int game_slot_max; 127 int text_trim_boundary; 128 int portrait_align; 129 int gameslot_align; 130 131 public: 132 GameStateLoad(); 133 ~GameStateLoad(); 134 135 void logic(); 136 void render(); 137 }; 138 139 #endif 140