mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-16 06:39:17 +00:00
MADS: Copy protection dialog is starting to be displayed
This commit is contained in:
parent
6c354bccf2
commit
6b774d2284
@ -34,7 +34,7 @@ Dialog::Dialog(MADSEngine *vm): _vm(vm), _savedSurface(nullptr),
|
||||
}
|
||||
|
||||
Dialog::~Dialog() {
|
||||
delete _savedSurface;
|
||||
restore(_vm->_screen);
|
||||
}
|
||||
|
||||
|
||||
@ -46,9 +46,11 @@ void Dialog::save(MSurface *s) {
|
||||
}
|
||||
|
||||
void Dialog::restore(MSurface *s) {
|
||||
_savedSurface->copyTo(s, _position);
|
||||
delete _savedSurface;
|
||||
_savedSurface = nullptr;
|
||||
if (_savedSurface) {
|
||||
_savedSurface->copyTo(s, _position);
|
||||
delete _savedSurface;
|
||||
_savedSurface = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void Dialog::draw() {
|
||||
@ -109,26 +111,28 @@ TextDialog::TextDialog(MADSEngine *vm, const Common::String &fontName,
|
||||
_numLines = 0;
|
||||
Common::fill(&_lineXp[0], &_lineXp[TEXT_DIALOG_MAX_LINES], 0);
|
||||
|
||||
// Save the high end of the palette, and set up the entries for dialog display
|
||||
Common::copy(&_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3],
|
||||
&_vm->_palette->_mainPalette[TEXTDIALOG_CONTENT1 * 3 + 8 * 3],
|
||||
&_savedPalette[0]);
|
||||
Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_CONTENT1, 2, 0x24, 0x20);
|
||||
Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_EDGE, 2, 0x27, 0x1C);
|
||||
Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FC, 2, 0x24, 0x20);
|
||||
Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FE, 1, 0x37, 0x37);
|
||||
Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_CONTENT1, 2, 0x90, 0x80);
|
||||
Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_EDGE, 2, 0x9C, 0x70);
|
||||
Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FC, 2, 0x90, 0x80);
|
||||
Palette::setGradient(_vm->_palette->_mainPalette, TEXTDIALOG_FE, 1, 0xDC, 0xDC);
|
||||
|
||||
_vm->_palette->setPalette(_vm->_palette->_mainPalette + (TEXTDIALOG_CONTENT1 * 3),
|
||||
TEXTDIALOG_CONTENT1, 8);
|
||||
}
|
||||
|
||||
TextDialog::~TextDialog() {
|
||||
restorePalette();
|
||||
}
|
||||
|
||||
void TextDialog::addLine(const Common::String &line, bool underline) {
|
||||
if (_lineWidth > 0 || _currentX > 0)
|
||||
incNumLines();
|
||||
|
||||
int stringWidth = _vm->_font->getWidth(line);
|
||||
int stringWidth = _vm->_font->getWidth(line, 1);
|
||||
if (stringWidth >= _innerWidth || (int)line.size() >= _lineSize) {
|
||||
wordWrap(line);
|
||||
} else {
|
||||
@ -249,17 +253,17 @@ void TextDialog::draw() {
|
||||
_position.x + _width - 4);
|
||||
} else {
|
||||
// Draw a text line
|
||||
int xp = (_lineXp[lineNum] & 0x7F) + 5;
|
||||
int xp = (_lineXp[lineNum] & 0x7F) + _position.x + 5;
|
||||
int yp = lineYp;
|
||||
if (_lineXp[lineNum] & 0x40)
|
||||
++yp;
|
||||
|
||||
_vm->_font->writeString(_vm->_screen, _lines[lineNum],
|
||||
Common::Point(xp, yp), 1);
|
||||
Common::Point(xp, yp), 0, 1);
|
||||
|
||||
if (_lineXp[lineNum] & 0x80) {
|
||||
// Draw an underline under the text
|
||||
int lineWidth = _vm->_font->getWidth(_lines[lineNum]);
|
||||
int lineWidth = _vm->_font->getWidth(_lines[lineNum], 1);
|
||||
_vm->_screen->setColor(TEXTDIALOG_BLACK);
|
||||
_vm->_screen->hLine(xp, yp + _vm->_font->getHeight(), xp + lineWidth);
|
||||
}
|
||||
@ -269,6 +273,12 @@ void TextDialog::draw() {
|
||||
}
|
||||
}
|
||||
|
||||
void TextDialog::restorePalette() {
|
||||
Common::copy(&_savedPalette[0], &_savedPalette[8 * 3],
|
||||
&_vm->_palette->_mainPalette[248 * 3]);
|
||||
_vm->_palette->setPalette(_vm->_palette->_mainPalette, 248, 8);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
MessageDialog::MessageDialog(MADSEngine *vm, int maxChars, ...):
|
||||
@ -286,7 +296,13 @@ MessageDialog::MessageDialog(MADSEngine *vm, int maxChars, ...):
|
||||
}
|
||||
|
||||
void MessageDialog::show() {
|
||||
draw();
|
||||
_vm->_events->showCursor();
|
||||
|
||||
while (!_vm->shouldQuit() && !_vm->_events->_keyPressed &&
|
||||
!_vm->_events->_mouseClicked) {
|
||||
_vm->_events->delay(1);
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace MADS
|
||||
|
@ -99,6 +99,11 @@ private:
|
||||
* Append text to the currently end line.
|
||||
*/
|
||||
void appendLine(const Common::String &line);
|
||||
|
||||
/**
|
||||
* Clean up after finishing displaying the dialog
|
||||
*/
|
||||
void restorePalette();
|
||||
protected:
|
||||
Common::String _fontName;
|
||||
int _innerWidth;
|
||||
|
@ -37,6 +37,8 @@ EventsManager::EventsManager(MADSEngine *vm) {
|
||||
_cursorSprites = nullptr;
|
||||
_gameCounter = 0;
|
||||
_priorFrameTime = 0;
|
||||
_keyPressed = false;
|
||||
_mouseClicked = false;
|
||||
}
|
||||
|
||||
EventsManager::~EventsManager() {
|
||||
@ -72,9 +74,6 @@ void EventsManager::changeCursor() {
|
||||
|
||||
void EventsManager::pollEvents() {
|
||||
checkForNextFrameCounter();
|
||||
_mouseClicked = false;
|
||||
_mouseReleased = false;
|
||||
_keyPressed = false;
|
||||
|
||||
Common::Event event;
|
||||
while (g_system->getEventManager()->pollEvent(event)) {
|
||||
@ -82,7 +81,6 @@ void EventsManager::pollEvents() {
|
||||
switch (event.type) {
|
||||
case Common::EVENT_QUIT:
|
||||
case Common::EVENT_RTL:
|
||||
case Common::EVENT_KEYUP:
|
||||
return;
|
||||
|
||||
case Common::EVENT_KEYDOWN:
|
||||
@ -95,13 +93,16 @@ void EventsManager::pollEvents() {
|
||||
_keyPressed = true;
|
||||
}
|
||||
return;
|
||||
case Common::EVENT_KEYUP:
|
||||
_keyPressed = false;
|
||||
return;
|
||||
case Common::EVENT_LBUTTONDOWN:
|
||||
case Common::EVENT_RBUTTONDOWN:
|
||||
_mouseClicked = true;
|
||||
return;
|
||||
case Common::EVENT_LBUTTONUP:
|
||||
case Common::EVENT_RBUTTONUP:
|
||||
_mouseReleased = true;
|
||||
_mouseClicked = false;
|
||||
return;
|
||||
case Common::EVENT_MOUSEMOVE:
|
||||
_mousePos = event.mouse;
|
||||
|
@ -55,7 +55,6 @@ private:
|
||||
public:
|
||||
SpriteAsset *_cursorSprites;
|
||||
bool _mouseClicked;
|
||||
bool _mouseReleased;
|
||||
bool _keyPressed;
|
||||
public:
|
||||
/**
|
||||
|
@ -31,13 +31,6 @@ namespace MADS {
|
||||
|
||||
namespace Nebular {
|
||||
|
||||
bool CopyProtectionDialog::show(MADSEngine *vm) {
|
||||
CopyProtectionDialog *dlg = new CopyProtectionDialog(vm, false);
|
||||
|
||||
delete dlg;
|
||||
return true;
|
||||
}
|
||||
|
||||
CopyProtectionDialog::CopyProtectionDialog(MADSEngine *vm, bool priorAnswerWrong):
|
||||
TextDialog(vm, FONT_INTERFACE, Common::Point(-1, -1), 32) {
|
||||
getHogAnusEntry(_hogEntry);
|
||||
@ -76,6 +69,20 @@ CopyProtectionDialog::CopyProtectionDialog(MADSEngine *vm, bool priorAnswerWrong
|
||||
wordWrap(" ");
|
||||
wordWrap("\n");
|
||||
|
||||
// TODO: Rest of setup
|
||||
}
|
||||
|
||||
bool CopyProtectionDialog::show() {
|
||||
draw();
|
||||
_vm->_events->showCursor();
|
||||
|
||||
// TODO: Replace with text input
|
||||
while (!_vm->shouldQuit() && !_vm->_events->_keyPressed &&
|
||||
!_vm->_events->_mouseClicked) {
|
||||
_vm->_events->delay(1);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CopyProtectionDialog::getHogAnusEntry(HOGANUS &entry) {
|
||||
|
@ -43,20 +43,20 @@ class CopyProtectionDialog: public TextDialog {
|
||||
private:
|
||||
HOGANUS _hogEntry;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
CopyProtectionDialog(MADSEngine *vm, bool priorAnswerWrong);
|
||||
|
||||
/**
|
||||
* Get a random copy protection entry from the HOGANUS resource
|
||||
*/
|
||||
bool getHogAnusEntry(HOGANUS &entry);
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
CopyProtectionDialog(MADSEngine *vm, bool priorAnswerWrong);
|
||||
|
||||
/**
|
||||
* Show the dialog
|
||||
*/
|
||||
static bool show(MADSEngine *vm);
|
||||
bool show();
|
||||
};
|
||||
|
||||
} // End of namespace Nebular
|
||||
|
@ -41,11 +41,10 @@ bool GameNebular::checkCopyProtection() {
|
||||
if (!ConfMan.getBool("copy_protection"))
|
||||
return true;
|
||||
|
||||
MessageDialog *dlg = new MessageDialog(_vm, 40, "Line 1", "Line 2", nullptr);
|
||||
CopyProtectionDialog *dlg = new CopyProtectionDialog(_vm, false);
|
||||
dlg->show();
|
||||
delete dlg;
|
||||
|
||||
//CopyProtectionDialog::show(_vm);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user