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

md5checkdialog.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 COPYRIGHT
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 "common/system.h"
00024 #include "common/translation.h"
00025 
00026 #include "gui/gui-manager.h"
00027 #include "gui/ThemeEval.h"
00028 #include "gui/widget.h"
00029 
00030 #include "engines/grim/md5checkdialog.h"
00031 #include "engines/grim/md5check.h"
00032 
00033 namespace Grim {
00034 
00035 MD5CheckDialog::MD5CheckDialog() :
00036         GUI::Dialog(30, 20, 260, 124) {
00037 
00038     const int screenW = g_system->getOverlayWidth();
00039     const int screenH = g_system->getOverlayHeight();
00040 
00041     Common::String message = _(
00042         "ResidualVM will now verify the game data files, to make sure you have the best gaming experience.\n"
00043         "This may take a while, please wait.\nSuccessive runs will not check them again.");
00044 
00045     // First, determine the size the dialog needs. For this we have to break
00046     // down the string into lines, and taking the maximum of their widths.
00047     // Using this, and accounting for the space the button(s) need, we can set
00048     // the real size of the dialog
00049     Common::Array<Common::String> lines;
00050     g_gui.getFont().wordWrapText(message, screenW - 2 * 20, lines);
00051     _w = screenW - 20;
00052     int maxlineWidth = _w - 20;
00053 
00054     int lineCount = lines.size();
00055 
00056     _h = 60 + kLineHeight;
00057 
00058     // Limit the number of lines so that the dialog still fits on the screen.
00059     if (lineCount > (screenH - 20 - _h) / kLineHeight) {
00060         lineCount = (screenH - 20 - _h) / kLineHeight;
00061     }
00062     _h += lineCount * kLineHeight;
00063 
00064     // Center the dialog
00065     _x = (screenW - _w) / 2;
00066     _y = (screenH - _h) / 2;
00067 
00068     // Each line is represented by one static text item.
00069     int height = 10;
00070     for (int i = 0; i < lineCount; i++) {
00071         new GUI::StaticTextWidget(this, 10, height, maxlineWidth, kLineHeight,
00072                                   lines[i], Graphics::kTextAlignCenter);
00073         height += kLineHeight;
00074     }
00075     height += 20;
00076 
00077     _progressSliderWidget = new GUI::SliderWidget(this, 20, height + 10, _w - 40, 10);
00078 
00079     check();
00080 }
00081 
00082 void MD5CheckDialog::check() {
00083     _checkOk = true;
00084     MD5Check::startCheckFiles();
00085 }
00086 
00087 void MD5CheckDialog::handleTickle() {
00088     int p, t;
00089     Common::String filename;
00090     if (!MD5Check::advanceCheck(&p, &t)) {
00091         _checkOk = false;
00092     }
00093     _progressSliderWidget->setValue(p * 100 / t);
00094     _progressSliderWidget->markAsDirty();
00095 
00096     if (p == t) {
00097         setResult(_checkOk);
00098         close();
00099     }
00100 }
00101 
00102 }


Generated on Sat May 18 2019 05:01:09 for ResidualVM by doxygen 1.7.1
curved edge   curved edge