MM: MM1: Load Xeen UI background

This commit is contained in:
Paul Gilbert 2022-06-01 20:26:51 -07:00 committed by Eugene Sandulenko
parent ffef7976f2
commit 5f79a8b266
No known key found for this signature in database
GPG Key ID: 014D387312D34F08
3 changed files with 64 additions and 4 deletions

View File

@ -22,11 +22,14 @@
#include "common/scummsys.h"
#include "common/config-manager.h"
#include "common/debug-channels.h"
#include "common/events.h"
#include "common/file.h"
#include "common/system.h"
#include "engines/util.h"
#include "graphics/palette.h"
#include "mm/mm1/mm1.h"
#include "mm/mm1/console.h"
#include "mm/mm1/gfx/gfx.h"
#include "mm/xeen/files.h"
namespace MM {
namespace MM1 {
@ -46,8 +49,15 @@ MM1Engine::~MM1Engine() {
Common::Error MM1Engine::run() {
// Initialize graphics mode
initGraphics(320, 200);
Gfx::GFX::setEgaPalette(0);
if (isEnhanced()) {
if (!setupEnhanced())
return Common::kNoError;
} else {
setupNormal();
}
// Setup console
setDebugger(new Console());
// Load globals
@ -58,5 +68,42 @@ Common::Error MM1Engine::run() {
return Common::kNoError;
}
bool MM1Engine::isEnhanced() const {
return (_gameDescription->features & GF_ENHANCED) != 0;
}
void MM1Engine::setupNormal() {
Gfx::GFX::setEgaPalette(0);
}
bool MM1Engine::setupEnhanced() {
if (!Common::File::exists("dark.cc")) {
GUIErrorMessage(
"In order to run in Enhanced mode, please copy dark.cc "
"from a copy of World of Xeen\n"
"or Dark Side of Xeen to your Might and Magic 1 game folder"
);
return false;
}
// Add the Dark Side dark.cc archive
::MM::Xeen::CCArchive *darkCC = new ::MM::Xeen::CCArchive(
"dark.cc", "dark", true);
SearchMan.add("dark", darkCC);
// Load the palette
Common::File f;
if (!f.open("dark.pal"))
error("Could not load palette");
byte pal[PALETTE_SIZE];
for (int i = 0; i < PALETTE_SIZE; ++i)
pal[i] = f.readByte() << 2;
g_system->getPaletteManager()->setPalette(pal, 0, PALETTE_COUNT);
return true;
}
} // End of namespace Xeen
} // End of namespace MM

View File

@ -42,6 +42,9 @@ private:
// Engine APIs
Common::Error run() override;
bool isEnhanced() const;
void setupNormal();
bool setupEnhanced();
public:
Globals _globals;
public:
@ -57,6 +60,7 @@ public:
int getRandomNumber(int maxNumber) {
return _randomSource.getRandomNumber(maxNumber);
}
Common::String getTargetName() const {
return _targetName;
}

View File

@ -19,6 +19,7 @@
*
*/
#include "common/file.h"
#include "mm/mm1/views_enh/game.h"
#include "mm/mm1/globals.h"
#include "mm/mm1/meta_engine.h"
@ -42,8 +43,16 @@ bool Game::msgUnfocus(const UnfocusMessage &msg) {
}
void Game::draw() {
if (_needsRedraw)
clearSurface();
if (_needsRedraw) {
// Load the Xeen background
Common::File f;
if (!f.open("back.raw"))
error("Could not load background");
Graphics::Surface s = getSurface();
f.read((byte *)s.getPixels(), s.w * s.h);
}
UIElement::draw();
}