diff --git a/engines/ultima/module.mk b/engines/ultima/module.mk index f1c5adb27ad..ea50d3b5e49 100644 --- a/engines/ultima/module.mk +++ b/engines/ultima/module.mk @@ -72,6 +72,7 @@ MODULE_OBJS += \ ultima1/maps/map_tile.o \ ultima1/u1dialogs/dialog.o \ ultima1/u1dialogs/drop.o \ + ultima1/u1dialogs/full_screen_dialog.o \ ultima1/u1dialogs/grocery.o \ ultima1/u1gfx/drawing_support.o \ ultima1/u1gfx/info.o \ diff --git a/engines/ultima/ultima1/core/resources.cpp b/engines/ultima/ultima1/core/resources.cpp index 96ce7b29fdf..490427bd9f6 100644 --- a/engines/ultima/ultima1/core/resources.cpp +++ b/engines/ultima/ultima1/core/resources.cpp @@ -596,6 +596,10 @@ const char *const SRC_NOTHING_HERE = " - nothing here!"; const char *const SRC_SOLD = "Sold!"; const char *const SRC_CANT_AFFORD = "Thou canst not afford it!"; const char *const SRC_DROP_PENCE_WEAPON_ARMOR = "Drop Pence,Weapon,Armour:"; +const char *const SRC_DROP_PENCE = "pence"; +const char *const SRC_DROP_WEAPON = "weapon"; +const char *const SRC_DROP_ARMOR = "armor"; + const char *const SRC_GROCERY_SELL = "Used food? No thanks!"; const char *const SRC_GROCERY_PACKS1 = "Packs of 10 food cost %d pence"; const char *const SRC_GROCERY_PACKS2 = "each. How many dost thou"; @@ -673,6 +677,10 @@ GameResources::GameResources(Shared::Resources *resManager) : LocalResourceFile( SOLD = SRC_SOLD; CANT_AFFORD = SRC_CANT_AFFORD; DROP_PENCE_WEAPON_ARMOR = SRC_DROP_PENCE_WEAPON_ARMOR; + DROP_PENCE = SRC_DROP_PENCE; + DROP_WEAPON = SRC_DROP_WEAPON; + DROP_ARMOR = SRC_DROP_ARMOR; + Common::copy(&SRC_GROCERY_NAMES[0], &SRC_GROCERY_NAMES[8], GROCERY_NAMES); GROCERY_SELL = SRC_GROCERY_SELL; GROCERY_PACKS1 = SRC_GROCERY_PACKS1; @@ -747,6 +755,10 @@ void GameResources::synchronize() { syncString(SOLD); syncString(CANT_AFFORD); syncString(DROP_PENCE_WEAPON_ARMOR); + syncString(DROP_PENCE); + syncString(DROP_WEAPON); + syncString(DROP_ARMOR); + syncStrings(GROCERY_NAMES, 8); syncString(GROCERY_SELL); syncString(GROCERY_PACKS1); diff --git a/engines/ultima/ultima1/core/resources.h b/engines/ultima/ultima1/core/resources.h index f441f3ba680..b278716e26b 100644 --- a/engines/ultima/ultima1/core/resources.h +++ b/engines/ultima/ultima1/core/resources.h @@ -100,6 +100,10 @@ public: const char *SOLD; const char *CANT_AFFORD; const char *DROP_PENCE_WEAPON_ARMOR; + const char *DROP_PENCE; + const char *DROP_WEAPON; + const char *DROP_ARMOR; + const char *GROCERY_NAMES[8]; const char *GROCERY_SELL; const char *GROCERY_PACKS1; diff --git a/engines/ultima/ultima1/u1dialogs/drop.cpp b/engines/ultima/ultima1/u1dialogs/drop.cpp index cc924284abc..46e9a1b74be 100644 --- a/engines/ultima/ultima1/u1dialogs/drop.cpp +++ b/engines/ultima/ultima1/u1dialogs/drop.cpp @@ -34,9 +34,7 @@ BEGIN_MESSAGE_MAP(Drop, Dialog) ON_MESSAGE(KeypressMsg) END_MESSAGE_MAP() -Drop::Drop(Ultima1Game *game) : Dialog(game), _mode(SELECT) { - // The drop dialog covers the entire screen, but doesn't erase what's under it - _bounds = Common::Rect(0, 0, 320, 200); +Drop::Drop(Ultima1Game *game) : FullScreenDialog(game), _mode(SELECT) { } bool Drop::KeypressMsg(CKeypressMsg &msg) { @@ -101,15 +99,41 @@ void Drop::drawSelection() { } void Drop::drawDropPence() { - // TODO + Shared::Gfx::VisualSurface s = getSurface(); + Common::String text = Common::String::format("%s %s: ", _game->_res->ACTION_NAMES[3], _game->_res->DROP_PENCE); + s.fillRect(TextRect(1, 24, 28, 24), _game->_bgColor); + s.writeString(text, TextPoint(1, 24), _game->_textColor); + + _game->_textCursor->setPosition(TextPoint(1 + text.size(), 24)); + _game->_textCursor->setVisible(true); } void Drop::drawDropWeapon() { - // TODO + drawFrame(_game->_res->ACTION_NAMES[3]); + + // Draw drop weapon text at the bottom and enable cursor + Shared::Gfx::VisualSurface s = getSurface(); + Common::String text = Common::String::format("%s %s: ", _game->_res->ACTION_NAMES[3], _game->_res->DROP_WEAPON); + s.fillRect(TextRect(1, 24, 28, 24), _game->_bgColor); + s.writeString(text, TextPoint(1, 24), _game->_textColor); + + // Show cursor in the info area + _game->_textCursor->setPosition(TextPoint(1 + text.size(), 24)); + _game->_textCursor->setVisible(true); } void Drop::drawDropArmor() { - // TODO + drawFrame(_game->_res->ACTION_NAMES[3]); + + // Draw drop weapon text at the bottom and enable cursor + Shared::Gfx::VisualSurface s = getSurface(); + Common::String text = Common::String::format("%s %s: ", _game->_res->ACTION_NAMES[3], _game->_res->DROP_ARMOR); + s.fillRect(TextRect(1, 24, 28, 24), _game->_bgColor); + s.writeString(text, TextPoint(1, 24), _game->_textColor); + + // Show cursor in the info area + _game->_textCursor->setPosition(TextPoint(1 + text.size(), 24)); + _game->_textCursor->setVisible(true); } } // End of namespace U1Dialogs diff --git a/engines/ultima/ultima1/u1dialogs/drop.h b/engines/ultima/ultima1/u1dialogs/drop.h index d5015116286..cb51355a0f8 100644 --- a/engines/ultima/ultima1/u1dialogs/drop.h +++ b/engines/ultima/ultima1/u1dialogs/drop.h @@ -23,7 +23,7 @@ #ifndef ULTIMA_ULTIMA1_U1DIALOGS_DROP_H #define ULTIMA_ULTIMA1_U1DIALOGS_DROP_H -#include "ultima/ultima1/u1dialogs/dialog.h" +#include "ultima/ultima1/u1dialogs/full_screen_dialog.h" namespace Ultima { namespace Ultima1 { @@ -34,7 +34,7 @@ using Shared::CKeypressMsg; /** * Implements the drop dialog */ -class Drop : public Dialog { +class Drop : public FullScreenDialog { DECLARE_MESSAGE_MAP; bool KeypressMsg(CKeypressMsg &msg); diff --git a/engines/ultima/ultima1/u1dialogs/full_screen_dialog.cpp b/engines/ultima/ultima1/u1dialogs/full_screen_dialog.cpp new file mode 100644 index 00000000000..b81be6809d5 --- /dev/null +++ b/engines/ultima/ultima1/u1dialogs/full_screen_dialog.cpp @@ -0,0 +1,51 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "ultima/ultima1/u1dialogs/full_screen_dialog.h" +#include "ultima/ultima1/u1gfx/drawing_support.h" +#include "ultima/ultima1/game.h" + +namespace Ultima { +namespace Ultima1 { +namespace U1Dialogs { + +FullScreenDialog::FullScreenDialog(Ultima1Game *game) : Dialog(game) { + _bounds = Common::Rect(0, 0, 320, 200); +} + +void FullScreenDialog::drawFrame(const Common::String &title) { + Shared::Gfx::VisualSurface s = getSurface(); + U1Gfx::DrawingSupport ds(s); + s.fillRect(TextRect(0, 0, 40, 20), _game->_bgColor); + ds.drawGameFrame(); + + size_t titleLen = title.size() + 2; + size_t xStart = 20 - titleLen / 2; + ds.drawRightArrow(TextPoint(xStart - 1, 0)); + s.fillRect(TextRect(xStart, 0, xStart + titleLen, 0), 0); + s.writeString(title, TextPoint(xStart + 1, 0), _game->_textColor); + ds.drawLeftArrow(TextPoint(xStart + titleLen, 0)); +} + +} // End of namespace U1Dialogs +} // End of namespace Gfx +} // End of namespace Ultima diff --git a/engines/ultima/ultima1/u1dialogs/full_screen_dialog.h b/engines/ultima/ultima1/u1dialogs/full_screen_dialog.h new file mode 100644 index 00000000000..63123579926 --- /dev/null +++ b/engines/ultima/ultima1/u1dialogs/full_screen_dialog.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#ifndef ULTIMA_ULTIMA1_U1DIALOGS_FULL_SCREEN_DIALOG_H +#define ULTIMA_ULTIMA1_U1DIALOGS_FULL_SCREEN_DIALOG_H + +#include "ultima/ultima1/u1dialogs/dialog.h" + +namespace Ultima { +namespace Ultima1 { +namespace U1Dialogs { + +/** + * Base class for dialogs that cover the entire game area, with the exception of the + * info & status areas at the bottom of the screen + */ +class FullScreenDialog : public Dialog { +protected: + /** + * Draw the frame + */ + void drawFrame(const Common::String &title); +public: + /** + * Constructor + */ + FullScreenDialog(Ultima1Game *game); +}; + +} // End of namespace U1Dialogs +} // End of namespace Ultima1 +} // End of namespace Ultima + +#endif