ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

saveloadmenu.h

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the AUTHORS
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef STARK_UI_MENU_SAVELOAD_MENU_H
00024 #define STARK_UI_MENU_SAVELOAD_MENU_H
00025 
00026 #include "engines/stark/ui/menu/locationscreen.h"
00027 
00028 #include "engines/stark/visual/text.h"
00029 
00030 #include "common/error.h"
00031 
00032 namespace Stark {
00033 
00034 namespace Gfx {
00035 class Texture;
00036 class SurfaceRenderer;  
00037 }
00038 
00039 class SaveDataWidget;
00040 
00044 class SaveLoadMenuScreen : public StaticLocationScreen {
00045 public:
00046     static const int _slotPerRow = 3;
00047     static const int _slotPerColumn = 3;
00048     static const int _slotPerPage = 9;
00049 
00050     SaveLoadMenuScreen(Gfx::Driver *gfx, Cursor *cursor, Screen::Name screenName);
00051     virtual ~SaveLoadMenuScreen();
00052 
00053     // StaticLocationScreen API
00054     void open() override;
00055     void close() override;
00056 
00058     virtual void onWidgetSelected(SaveDataWidget *widget) = 0;
00059 
00061     virtual bool isSaveMenu() = 0;
00062 
00063 protected:
00064     static void checkError(Common::Error error);
00065 
00066     enum WidgetIndex {
00067         kWidgetSaveText = 3,
00068         kWidgetLoadText = 4,
00069         kWidgetBack = 5,
00070         kWidgetNext = 6
00071     };
00072 
00073 private:
00074     // Start from zero
00075     int _page;
00076     int _maxPage;
00077 
00078     void backHandler();
00079     
00080     void prevPageHandler() { changePage(_page - 1); }
00081     void nextPageHandler() { changePage(_page + 1); }
00082 
00083     void removeSaveDataWidgets();
00084     void loadSaveData(int page);
00085     void changePage(int page);
00086     int computeMaxPage();
00087 };
00088 
00092 class SaveMenuScreen : public SaveLoadMenuScreen {
00093 public:
00094     SaveMenuScreen(Gfx::Driver *gfx, Cursor *cursor) : 
00095             SaveLoadMenuScreen(gfx, cursor, Screen::kScreenSaveMenu),
00096             _slotToSaveAfterConfirm(nullptr) {}
00097     virtual ~SaveMenuScreen() {}
00098 
00099     // SaveLoadMenuScreen API
00100     void open() override;
00101 
00102     void onWidgetSelected(SaveDataWidget *widget) override;
00103 
00104     bool isSaveMenu() override { return true; }
00105 
00106 private:
00107     void saveGameToSlot(SaveDataWidget *widget);
00108     void saveConfirmSlot();
00109 
00110     SaveDataWidget *_slotToSaveAfterConfirm;
00111 };
00112 
00116 class LoadMenuScreen : public SaveLoadMenuScreen {
00117 public:
00118     LoadMenuScreen(Gfx::Driver *gfx, Cursor *cursor) : 
00119             SaveLoadMenuScreen(gfx, cursor, Screen::kScreenLoadMenu),
00120             _slotToLoadAfterConfirm(-1) {}
00121     ~LoadMenuScreen() override {}
00122 
00123     // SaveLoadMenuScreen API
00124     void open() override;
00125 
00126     void onWidgetSelected(SaveDataWidget *widget) override;
00127 
00128     bool isSaveMenu() override { return false; }
00129 
00130 private:
00131     void loadConfirmSlot();
00132 
00133     int _slotToLoadAfterConfirm;
00134 };
00135 
00139 class SaveDataWidget : public StaticLocationWidget {
00140 public:
00141     SaveDataWidget(int slot, Gfx::Driver *gfx, SaveLoadMenuScreen *screen);
00142     ~SaveDataWidget();
00143 
00144     // StaticLocationWidget API
00145     void render() override;
00146     bool isMouseInside(const Common::Point &mousePos) const override;
00147     void onClick() override;
00148     void onMouseMove(const Common::Point &mousePos) override;
00149     void onScreenChanged() override;
00150 
00151     int getSlot() { return _slot; }
00152     Common::String getName() { return _name; }
00153 
00155     void loadSaveDataElements();
00156 
00158     bool hasSave() { return _hasSave; }
00159 
00160 private:
00161     static const Color _outlineColor;
00162     static const Color _textColor;
00163 
00164     int _slot;
00165     SaveLoadMenuScreen *_screen;
00166 
00167     Common::Point _thumbPos, _textDescPos, _textTimePos;
00168     int _thumbWidth, _thumbHeight;
00169 
00170     Gfx::Texture *_texture;
00171     Gfx::Texture *_outline;
00172     Gfx::SurfaceRenderer *_surfaceRenderer;
00173 
00174     VisualText _textDesc, _textTime;
00175 
00176     bool _isMouseHovered;
00177     bool _hasSave;
00178 
00179     Common::String _name;
00180 };
00181 
00182 } // End of namespace Stark
00183 
00184 #endif // STARK_UI_MENU_SETTING_MENU_H


Generated on Sat Jul 13 2019 05:01:14 for ResidualVM by doxygen 1.7.1
curved edge   curved edge