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

diarypages.cpp

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 #include "engines/stark/ui/menu/diarypages.h"
00024 
00025 #include "engines/stark/services/services.h"
00026 #include "engines/stark/services/userinterface.h"
00027 #include "engines/stark/services/diary.h"
00028 #include "engines/stark/services/staticprovider.h"
00029 
00030 #include "engines/stark/resources/location.h"
00031 #include "engines/stark/resources/layer.h"
00032 
00033 #include "engines/stark/gfx/renderentry.h"
00034 
00035 namespace Stark {
00036 
00037 DiaryPagesScreen::DiaryPagesScreen(Gfx::Driver *gfx, Cursor *cursor) :
00038         StaticLocationScreen(gfx, cursor, "DiaryPages", Screen::kScreenDiaryPages),
00039         _page(0) {
00040 }
00041 
00042 DiaryPagesScreen::~DiaryPagesScreen() {
00043 }
00044 
00045 void DiaryPagesScreen::open() {
00046     StaticLocationScreen::open();
00047     
00048     _widgets.push_back(new StaticLocationWidget(
00049             "BGImage",
00050             nullptr,
00051             nullptr));
00052 
00053     _widgets.push_back(new StaticLocationWidget(
00054             "Return",
00055             CLICK_HANDLER(DiaryPagesScreen, backHandler),
00056             nullptr));
00057     _widgets.back()->setupSounds(0, 1);
00058 
00059     _widgets.push_back(new StaticLocationWidget(
00060             "GoBack",
00061             CLICK_HANDLER(DiaryPagesScreen, backHandler),
00062             nullptr));
00063     _widgets.back()->setupSounds(0, 1);
00064 
00065     _widgets.push_back(new StaticLocationWidget(
00066             "Back",
00067             CLICK_HANDLER(DiaryPagesScreen, prevPageHandler),
00068             nullptr));
00069     _widgets.back()->setupSounds(0, 1);
00070 
00071     _widgets.push_back(new StaticLocationWidget(
00072             "Next",
00073             CLICK_HANDLER(DiaryPagesScreen, nextPageHandler),
00074             nullptr));
00075     _widgets.back()->setupSounds(0, 1);
00076 
00077     _page = StarkDiary->getPageIndex();
00078 
00079     if (StarkDiary->countDiary() > 0) {
00080         _widgets.push_back(new DiaryWidget(_page));
00081         _widgets[kWidgetBack]->setVisible(_page > 0);
00082         _widgets[kWidgetNext]->setVisible(_page < StarkDiary->countDiary() - 1);
00083     } else {
00084         _widgets[kWidgetBack]->setVisible(false);
00085         _widgets[kWidgetNext]->setVisible(false);
00086     }
00087 }
00088 
00089 void DiaryPagesScreen::close() {
00090     StarkDiary->setPageIndex(_page);
00091     StarkDiary->setDiaryAllRead();
00092     StaticLocationScreen::close();
00093 }
00094 
00095 void DiaryPagesScreen::backHandler() {
00096     StarkUserInterface->backPrevScreen();
00097 }
00098 
00099 void DiaryPagesScreen::changePage(uint page) {
00100     assert(page < StarkDiary->countDiary());
00101 
00102     delete _widgets.back();
00103     _widgets.pop_back();
00104     _widgets.push_back(new DiaryWidget(page));
00105 
00106     _widgets[kWidgetBack]->setVisible(page > 0);
00107     _widgets[kWidgetNext]->setVisible(page < StarkDiary->countDiary() - 1);
00108 
00109     _page = page;
00110 }
00111 
00112 DiaryWidget::DiaryWidget(uint diaryIndex):
00113         StaticLocationWidget(nullptr, nullptr, nullptr) {
00114     Resources::Location *location = StarkStaticProvider->getLocation();
00115     Resources::Layer *layer = location->getLayerByName(StarkDiary->getDiary(diaryIndex));
00116 
00117     if (!layer) {
00118         debug("Unable to retrieve diary in layer %s.", StarkDiary->getDiary(diaryIndex).c_str());
00119         return;
00120     }
00121 
00122     // Diary page layer contains only one item, the text
00123     _renderEntry = layer->listRenderEntries()[0];
00124 }
00125 
00126 } // End of namespace Stark


Generated on Sat Feb 16 2019 05:00:49 for ResidualVM by doxygen 1.7.1
curved edge   curved edge