Initial commit

This commit is contained in:
2026-02-02 04:50:13 +01:00
commit 5b11698731
22592 changed files with 7677434 additions and 0 deletions

View File

@@ -0,0 +1,115 @@
/* 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 3 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 detail_surface.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "ultima/ultima1/u1gfx/drawing_support.h"
#include "ultima/ultima1/game.h"
#include "ultima/shared/early/ultima_early.h"
namespace Ultima {
namespace Ultima1 {
namespace U1Gfx {
DrawingSupport::DrawingSupport(const Shared::Gfx::VisualSurface &s) : _surface(s, s.getBounds()) {
_game = static_cast<Ultima1Game *>(g_vm->_game);
}
void DrawingSupport::drawFrame() {
// Big border around the screen
_surface.fillRect(Rect(0, 0, 317, 7), _game->_borderColor);
_surface.fillRect(Rect(0, 6, 7, 200), _game->_borderColor);
_surface.fillRect(Rect(313, 7, 320, 200), _game->_borderColor);
_surface.fillRect(Rect(0, 193, 320, 200), _game->_borderColor);
// Thin line on edge of big border
_surface.vLine(7, 7, 192, _game->_edgeColor);
_surface.vLine(312, 7, 192, _game->_edgeColor);
_surface.hLine(7, 7, 312, _game->_edgeColor);
_surface.hLine(7, 192, 312, _game->_edgeColor);
}
void DrawingSupport::drawGameFrame() {
// Big border around the screen
_surface.fillRect(Rect(0, 0, 317, 7), _game->_borderColor);
_surface.fillRect(Rect(0, 153, 320, 159), _game->_borderColor);
_surface.fillRect(Rect(0, 6, 7, 159), _game->_borderColor);
_surface.fillRect(Rect(313, 7, 320, 159), _game->_borderColor);
// Thin line on edge of big border
_surface.vLine(7, 7, 152, _game->_edgeColor);
_surface.vLine(312, 7, 152, _game->_edgeColor);
_surface.hLine(7, 7, 312, _game->_edgeColor);
_surface.hLine(7, 152, 312, _game->_edgeColor);
// Draw separator at bottom of screen
_surface.fillRect(Rect(241, 153, 247, 200), _game->_borderColor);
_surface.hLine(0, 159, 240, _game->_edgeColor);
_surface.hLine(247, 159, 320, _game->_edgeColor);
_surface.vLine(240, 159, 200, _game->_edgeColor);
_surface.vLine(247, 159, 200, _game->_edgeColor);
}
void DrawingSupport::roundFrameCorners(bool skipBottom) {
// Round the edges of the big outer border
for (int idx = 1; idx <= 4; ++idx) {
_surface.drawLine(0, idx, idx, 0, 0);
_surface.drawLine(319 - idx, 0, 319, idx, 0);
if (!skipBottom) {
_surface.drawLine(0, 199 - idx, idx, 199, 0);
_surface.drawLine(319, 199 - idx, 319 - idx, 199, 0);
}
}
_surface.drawPoint(Point(0, 0), 0);
_surface.drawPoint(Point(0, 5), 0);
_surface.drawPoint(Point(5, 0), 0);
_surface.drawPoint(Point(319, 0), 0);
_surface.drawPoint(Point(314, 0), 0);
_surface.drawPoint(Point(319, 5), 0);
if (!skipBottom) {
_surface.drawPoint(Point(0, 199), 0);
_surface.drawPoint(Point(0, 194), 0);
_surface.drawPoint(Point(5, 199), 0);
_surface.drawPoint(Point(319, 199), 0);
_surface.drawPoint(Point(319, 194), 0);
_surface.drawPoint(Point(314, 199), 0);
}
}
void DrawingSupport::drawRightArrow(const Point &pt) {
_surface.writeChar(16, pt, _game->_borderColor);
_surface.drawLine(pt.x, pt.y, pt.x + 7, pt.y + 3, _game->_edgeColor);
_surface.drawLine(pt.x + 7, pt.y + 3, pt.x, pt.y + 7, _game->_edgeColor);
_surface.drawLine(pt.x, pt.y + 1, pt.x, pt.y + 6, _game->_borderColor);
}
void DrawingSupport::drawLeftArrow(const Point &pt) {
_surface.writeChar(17, pt, _game->_borderColor);
_surface.drawLine(pt.x + 7, pt.y, pt.x, pt.y + 3, _game->_edgeColor);
_surface.drawLine(pt.x, pt.y + 3, pt.x + 7, pt.y + 7, _game->_edgeColor);
_surface.drawLine(pt.x + 7, pt.y + 1, pt.x + 7, pt.y + 6, _game->_borderColor);
}
} // End of namespace U1Gfx
} // End of namespace Ultima1
} // End of namespace Ultima

View File

@@ -0,0 +1,78 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ULTIMA_ULTIMA1_U1GFX_DRAWING_SUPPORT_H
#define ULTIMA_ULTIMA1_U1GFX_DRAWING_SUPPORT_H
#include "ultima/shared/gfx/visual_surface.h"
namespace Ultima {
namespace Ultima1 {
class Ultima1Game;
namespace U1Gfx {
/**
* Implements various support methods for drawing onto visual surfaces
*/
class DrawingSupport {
private:
Shared::Gfx::VisualSurface _surface;
Ultima1Game *_game;
private:
/**
* Tweaks the edges of a drawn border to give it a rounded effect
*/
void roundFrameCorners(bool skipBottom = false);
public:
/**
* Constructor
*/
DrawingSupport(const Shared::Gfx::VisualSurface &s);
/**
* Draws a frame around the entire screen
*/
void drawFrame();
/**
* Draw a frame around the viewport area of the screen, and a vertical separator line
* to the bottom of the screen to separate the status and info areas
*/
void drawGameFrame();
/**
* Draw a right arrow glyph
*/
void drawRightArrow(const Point &pt);
/**
* Draw a left arrow glyph
*/
void drawLeftArrow(const Point &pt);
};
} // End of namespace U1Gfx
} // End of namespace Shared
} // End of namespace Ultima
#endif

View File

@@ -0,0 +1,5 @@
#define flags_width 24
#define flags_height 8
static const unsigned char flags_bits[] = {
0x00,0x00,0x18,0x00,0x00,0x0c,0x00,0x03,0x07,0x01,0x3f,0x01,0x07,0x03,0x00,
0x0c,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00};

View File

@@ -0,0 +1,37 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#include "ultima/ultima1/u1gfx/info.h"
#include "ultima/ultima1/u1gfx/drawing_support.h"
#include "ultima/shared/early/game.h"
namespace Ultima {
namespace Ultima1 {
namespace U1Gfx {
void Info::drawPrompt(Shared::Gfx::VisualSurface &surf, const Point &pt) {
DrawingSupport ds(surf);
ds.drawRightArrow(pt);
}
} // End of namespace U1Gfx
} // End of namespace Ultima1
} // End of namespace Ultima

View File

@@ -0,0 +1,56 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ULTIMA_ULTIMA1_GFX_INFO_H
#define ULTIMA_ULTIMA1_GFX_INFO_H
#include "ultima/shared/gfx/info.h"
namespace Ultima {
namespace Ultima1 {
namespace U1Gfx {
/**
* Textual info area, showing what commands area done, and any responses to them
*/
class Info : public Shared::Info {
protected:
/**
* Draws a prompt character
*/
void drawPrompt(Shared::Gfx::VisualSurface &surf, const Point &pt) override;
public:
/**
* Constructor
*/
Info(TreeItem *parent) : Shared::Info(parent, TextRect(0, 21, 29, 24)) {}
/**
* Destructor
*/
~Info() override {}
};
} // End of namespace U1Gfx
} // End of namespace Ultima1
} // End of namespace Ultima
#endif

View File

@@ -0,0 +1,153 @@
#define logo_width 275
#define logo_height 64
static const unsigned char logo_bits[] = {
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0x07,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0xff,0xff,0xff,0x3f,0xff,
0xf3,0x3f,0xff,0xf3,0x3f,0xff,0xf3,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x06,
0xff,0xff,0xff,0x9f,0xff,0xf9,0x9f,0xff,0xf1,0x9f,0xff,0xf9,0x9f,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0x7f,0x06,0xff,0xff,0xff,0x9f,0xff,0xf9,0x9f,0xff,0xe0,0x9f,
0xff,0xf9,0x9f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x07,0xff,0xff,0xff,0xcf,0xff,
0xfc,0xcf,0x3f,0xe0,0xcf,0xff,0xfc,0xcf,0xff,0x00,0x00,0xff,0xff,0x03,0x00,
0xfc,0xff,0xff,0xff,0x03,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x07,
0xff,0xff,0xff,0xcf,0xff,0xfc,0xcf,0x1f,0xc0,0xcf,0xff,0xfc,0xcf,0x0f,0x00,
0x00,0xfc,0x3f,0x00,0x00,0xf0,0xff,0xf0,0x3f,0x00,0x00,0xf0,0x3f,0xfc,0x0f,
0xff,0x7f,0xf8,0x9f,0x07,0xff,0xff,0xff,0xe7,0x7f,0xfe,0xe7,0x07,0xc0,0xe7,
0x7f,0xfe,0xe7,0x07,0x00,0x00,0xf0,0x0f,0x00,0x00,0xc0,0x7f,0xf8,0x0f,0x00,
0x00,0xc0,0x3f,0xfc,0x0f,0xff,0x7f,0xf8,0x9f,0x07,0xff,0xff,0xff,0xe7,0x7f,
0xfe,0xe7,0x03,0x80,0xe7,0x7f,0xfe,0xe7,0x83,0xff,0x7f,0xf0,0x0f,0xfe,0xff,
0xc1,0x7f,0xf8,0x07,0xff,0xff,0xc1,0x1f,0xfe,0x07,0xfe,0x3f,0xfc,0xcf,0x07,
0xff,0xff,0xff,0xf3,0x3f,0xff,0xf3,0x00,0x80,0xf3,0x3f,0xff,0xf3,0xe1,0xff,
0x7f,0xf8,0x87,0xff,0xff,0xe1,0x3f,0xfc,0x87,0xff,0xff,0xe1,0x1f,0xfe,0x07,
0xfe,0x3f,0xfc,0xcf,0x07,0xff,0xff,0xff,0xf3,0x3f,0xff,0x73,0x00,0x00,0xf3,
0x3f,0xff,0xf3,0xe1,0xff,0x7f,0xf8,0x87,0xff,0xff,0xe1,0x3f,0xfc,0xc3,0xff,
0xff,0xe1,0x0f,0xff,0x03,0xfe,0x1f,0xfe,0xe7,0x07,0xff,0xff,0xff,0x01,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xf0,0xff,0x3f,0xfc,0xc3,0xff,0xff,
0xf0,0x1f,0xfe,0xc3,0xff,0xff,0xff,0x0f,0xff,0x03,0xfc,0x1f,0xfe,0xe7,0x07,
0xff,0xff,0xff,0xf9,0x9f,0xff,0xf9,0x87,0xff,0xf9,0x9f,0xff,0xf9,0xf0,0xff,
0x3f,0xfc,0xc3,0xff,0xff,0xf0,0x1f,0xfe,0xe1,0xff,0xff,0xff,0x87,0xff,0x01,
0xfc,0x0f,0xff,0xf3,0x07,0xff,0xff,0xff,0xfc,0xcf,0xff,0xfc,0xc3,0xff,0xfc,
0xcf,0xff,0x7c,0xf8,0xff,0x1f,0xfe,0xe1,0xff,0x7f,0xf8,0x0f,0xff,0xe1,0xff,
0xff,0xff,0x87,0xff,0x21,0xfc,0x0f,0xff,0xf3,0x07,0xff,0xff,0xff,0xfc,0xcf,
0xff,0xfc,0xc3,0xff,0xfc,0xcf,0xff,0x7c,0xf8,0xff,0x1f,0xfe,0xe1,0xff,0x3f,
0xf8,0x0f,0xff,0xf0,0xff,0xff,0xff,0xc3,0xff,0x70,0xf8,0x87,0xff,0xf9,0x07,
0xff,0xff,0x7f,0xfe,0xe7,0x7f,0xfe,0xe1,0x7f,0xfe,0xe7,0x7f,0x3e,0xfc,0xff,
0x0f,0xff,0xf0,0xff,0x03,0xfc,0x87,0xff,0xf0,0xff,0xff,0xff,0xc3,0xff,0x70,
0xf8,0x87,0xff,0xf9,0x07,0xff,0xff,0x7f,0xfe,0xe7,0x7f,0xfe,0xe1,0x7f,0xfe,
0xe7,0x7f,0x3e,0xfc,0xff,0x0f,0xff,0xf0,0x0f,0x00,0xff,0x87,0x7f,0xf8,0xff,
0xff,0xff,0xe1,0x7f,0x78,0xf8,0xc3,0xff,0xfc,0x07,0xff,0xff,0x3f,0xff,0xf3,
0x3f,0xff,0xf0,0x3f,0xff,0xf3,0x3f,0x1f,0xfe,0xff,0x87,0x7f,0xf8,0x03,0xf0,
0xff,0xc3,0x7f,0xf8,0xff,0xff,0xff,0xe1,0x7f,0xf8,0xf0,0xc3,0xff,0xfc,0x07,
0xff,0xff,0x3f,0xff,0xf3,0x3f,0xff,0xf0,0x3f,0xff,0xf3,0x3f,0x1f,0xfe,0xff,
0x87,0x7f,0xf8,0x81,0xff,0xff,0xc3,0x3f,0xfc,0x0f,0x80,0xff,0xf0,0x3f,0xfc,
0xf0,0xe1,0x7f,0xfe,0x07,0xff,0xff,0x9f,0xff,0xf9,0x9f,0x7f,0xf8,0x9f,0xff,
0xf9,0x9f,0x0f,0xff,0xff,0xc3,0x3f,0xfc,0xe1,0xff,0xff,0xe1,0x3f,0xfc,0x0f,
0x00,0xff,0xf0,0x3f,0xfc,0xf0,0xe1,0x7f,0xfe,0x07,0xff,0xff,0x9f,0xff,0xf9,
0x9f,0x7f,0xf8,0x9f,0xff,0xf9,0x9f,0x0f,0xff,0xff,0xc3,0x3f,0xfc,0xc3,0xff,
0xff,0xe1,0x1f,0xfe,0x0f,0x00,0x7f,0xf8,0x1f,0xfe,0xe1,0xf0,0x3f,0xff,0x07,
0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x87,0xff,0xff,
0xe1,0x1f,0xfe,0x87,0xff,0xff,0xf0,0x1f,0xfe,0xff,0x83,0x7f,0xf8,0x1f,0xfe,
0xe1,0xf0,0x3f,0xff,0x07,0xff,0xff,0xcf,0xff,0xfc,0xcf,0x3f,0xfc,0xcf,0xff,
0xfc,0xcf,0x87,0xff,0xff,0xe1,0x1f,0xfe,0x0f,0xff,0xff,0xf0,0x0f,0xff,0xff,
0x87,0x3f,0xfc,0x0f,0xff,0x61,0xf8,0x9f,0xff,0x07,0xff,0xff,0xe7,0x7f,0xfe,
0xe7,0x1f,0xfe,0xe7,0x7f,0xfe,0xe7,0xc3,0xff,0xff,0xf0,0x0f,0xff,0x1f,0xfe,
0x7f,0xf8,0x0f,0xff,0xff,0xc3,0x3f,0xfc,0x0f,0xff,0x43,0xf8,0x9f,0xff,0x07,
0xff,0xff,0xe7,0x3f,0xfe,0xe7,0x1f,0xfe,0xe7,0x7f,0xfc,0xe7,0xc3,0xff,0xff,
0xf0,0x0f,0xff,0x3f,0xfc,0x7f,0xf8,0x87,0xff,0xff,0xc3,0x1f,0xfe,0x87,0xff,
0x03,0xfc,0xcf,0xff,0x07,0xff,0xff,0xf3,0x0f,0xff,0xf3,0x0f,0xff,0xf3,0x3f,
0xf8,0xf3,0xe1,0xff,0x7f,0xf8,0x87,0xff,0x7f,0xf8,0x3f,0xfc,0x87,0xff,0xff,
0xe1,0x1f,0xfe,0x87,0xff,0x03,0xfc,0xcf,0xff,0x07,0xff,0xff,0xf3,0x03,0xff,
0xf3,0x0f,0xff,0xf3,0x3f,0xf0,0xf3,0xe1,0xff,0x7f,0xf8,0x87,0xff,0xff,0xf0,
0x3f,0xfc,0xc3,0xff,0xff,0xe1,0x0f,0xff,0xc3,0xff,0x07,0xfe,0xe7,0xff,0x07,
0xff,0xff,0x79,0x80,0xff,0xf9,0x87,0xff,0xf9,0x1f,0xe0,0xf9,0xc0,0xff,0x1f,
0xfc,0xc3,0xff,0xff,0xf0,0x1f,0xfe,0x03,0xff,0x7f,0xf0,0x0f,0xff,0xc3,0xff,
0x07,0xfe,0xe7,0xff,0x07,0xff,0xff,0x19,0x80,0xff,0xf9,0x87,0xff,0xf9,0x1f,
0xc0,0xf9,0x00,0x00,0x00,0xfc,0xc3,0xff,0xff,0xf0,0x1f,0xfe,0x03,0x00,0x00,
0xf8,0x87,0xff,0xe1,0xff,0x07,0xff,0xf3,0xff,0x07,0xff,0xff,0x06,0xc0,0xff,
0xfc,0xc3,0xff,0xfc,0x0f,0x80,0xfd,0x03,0x00,0x00,0xff,0xe1,0xff,0xff,0xf0,
0x0f,0xff,0x0f,0x00,0x00,0xfc,0x87,0xff,0xe1,0xff,0x07,0xff,0xf3,0xff,0x07,
0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x0f,0x00,0xf0,
0xff,0xe1,0xff,0x7f,0xf8,0x0f,0xff,0x3f,0x00,0xc0,0xff,0xc3,0xff,0xf0,0xff,
0x87,0xff,0xf9,0xff,0x07,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf9,0xff,0x07,0xff,0xff,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0xff,0x07,
0xff,0xbf,0x03,0xf0,0x3f,0xff,0xf0,0x3f,0xff,0x03,0x60,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xfc,0xff,0x07,0xff,0x3f,0x0f,0xf0,0x3f,0xff,0xf0,0x3f,0xff,0x03,
0x38,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xfe,0xff,0x07,0xff,0x9f,0x1f,0xf8,0x9f,
0x7f,0xf8,0x9f,0xff,0x01,0x9f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xfe,0xff,0x07,
0xff,0x9f,0x3f,0xf8,0x9f,0x7f,0xf8,0x9f,0xff,0xc1,0x9f,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0x3f,0xff,0xff,0x07,0xff,0xcf,0x7f,0xfc,0xcf,0x3f,0xfc,0xcf,0xff,0xf8,
0xcf,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0xff,0xff,0x07,0xff,0xcf,0xff,0xfc,0xcf,
0x3f,0xfc,0xcf,0xff,0xfc,0xcf,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x9f,0xff,0xff,0x07,
0xff,0xe7,0x7f,0xfe,0xe7,0x1f,0xfe,0xe7,0x7f,0xfe,0xe7,0x1f,0xe0,0xe1,0xe1,
0x07,0xf8,0x00,0xe0,0x01,0x78,0xf8,0x87,0x0f,0xf0,0x3f,0x3c,0x1c,0x7e,0xe0,
0xff,0x9f,0xff,0xff,0x07,0xff,0xe7,0x7f,0xfe,0xe7,0x1f,0xfe,0xe7,0x7f,0xfe,
0xe7,0x03,0xe0,0xe1,0xe1,0x00,0xf8,0x00,0xe0,0x01,0x78,0xf8,0x87,0x01,0xf0,
0x3f,0x3c,0x1c,0x1e,0xe0,0xff,0xcf,0xff,0xff,0x07,0xff,0x03,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xf0,0xe1,0xff,0xf0,0x70,0xf8,0xff,0x0f,0xff,0xf0,
0x3f,0xf0,0xc0,0xf0,0xff,0x1f,0x1e,0x0c,0x0f,0xff,0xff,0xcf,0xff,0xff,0x07,
0xff,0xf3,0x3f,0xff,0xf3,0x0f,0xff,0xf3,0x3f,0xff,0xf3,0xf0,0xff,0xf0,0x30,
0xfc,0xff,0x0f,0xff,0xf0,0x3f,0x30,0x40,0xf8,0xff,0x1f,0x1e,0x0c,0x87,0xff,
0xff,0xe7,0xff,0xff,0x07,0xff,0xf9,0x9f,0xff,0xf9,0x87,0xff,0xf9,0x9f,0xff,
0x79,0xf8,0x7f,0x78,0x18,0xfe,0xff,0x87,0x7f,0xf8,0x1f,0x00,0x20,0xfc,0xff,
0x0f,0x0f,0x84,0xc3,0xff,0xff,0xe7,0xff,0xff,0x07,0xff,0xf9,0x9f,0xff,0xf9,
0x87,0xff,0xf9,0x9f,0xff,0xf9,0xf0,0x7f,0x78,0x38,0xfc,0xff,0x87,0x7f,0xf8,
0x1f,0x06,0x20,0xfc,0xff,0x0f,0x0f,0x84,0xc3,0xff,0xff,0xf3,0xff,0xff,0x07,
0xff,0xfc,0xcf,0xff,0xfc,0xc3,0xff,0xfc,0xcf,0xff,0xfc,0x01,0x7e,0x00,0x7c,
0x80,0xff,0xc3,0x3f,0x80,0x0f,0xc7,0x70,0x00,0xff,0x87,0x07,0xc0,0xe1,0xff,
0xff,0xf3,0xff,0xff,0x07,0xff,0xfc,0xcf,0xff,0xfc,0xc3,0xff,0xfc,0xcf,0xff,
0xfc,0x0f,0x78,0x00,0xff,0x03,0xfe,0xc3,0x3f,0x80,0x0f,0xff,0xf0,0x03,0xfc,
0x87,0x07,0xc0,0xe1,0xff,0xff,0xf9,0xff,0xff,0x07,0x7f,0xfe,0xe7,0x7f,0xfe,
0xe1,0x7f,0xfe,0xe7,0x7f,0xfe,0xff,0xf0,0xe1,0xff,0x3f,0xfc,0xe1,0x1f,0xfe,
0x87,0x7f,0xf8,0x7f,0xf8,0xc3,0x03,0xe0,0xf0,0xff,0xff,0xf9,0xff,0xff,0x07,
0x7f,0xfe,0xe7,0x7f,0xfe,0xe1,0x7f,0xfe,0xe7,0x7f,0xfe,0xff,0xf0,0xe1,0xff,
0x3f,0xfc,0xe1,0x1f,0xfe,0x87,0x7f,0xf8,0x7f,0xf8,0xc3,0x43,0xe0,0xf0,0xff,
0xff,0xfc,0xff,0xff,0x07,0x3f,0xff,0xf3,0x3f,0xff,0xf0,0x3f,0xff,0xf3,0x3f,
0xff,0x7f,0xf8,0xf0,0xff,0x1f,0xfe,0xf0,0x0f,0xff,0xc3,0x3f,0xfc,0x3f,0xfc,
0xe1,0x61,0x70,0xf8,0xff,0xff,0xfc,0xff,0xff,0x07,0x3f,0xff,0xf3,0x3f,0xff,
0xf0,0x3f,0xff,0xf3,0x3f,0xff,0x3f,0xfc,0xf0,0xff,0x0f,0xff,0xf0,0x0f,0xff,
0xc3,0x3f,0xfc,0x1f,0xfe,0xe1,0x61,0x70,0xf8,0xff,0x7f,0xfe,0xff,0xff,0x07,
0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x7f,0x00,0x7e,0xf8,0x1f,
0x80,0x7f,0xf8,0x07,0xe0,0xe1,0x1f,0x3e,0x00,0xff,0xf0,0x70,0xf8,0x80,0xe7,
0x7f,0xfe,0xff,0xff,0x07,0x9f,0xff,0xf9,0x9f,0x01,0x00,0x9c,0xff,0xf9,0x9f,
0x7f,0xc0,0x7f,0xf8,0x1f,0xe0,0x7f,0xf8,0x07,0xe0,0xe1,0x1f,0x3e,0xc0,0xff,
0xf0,0x70,0xf8,0x81,0xe7,0x3f,0xff,0xff,0xff,0x07,0xcf,0xff,0xfc,0xcf,0x03,
0x00,0xce,0xff,0xfc,0xcf,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0xff,0xff,0xff,0x07,
0xcf,0xff,0xfc,0xcf,0x03,0x80,0xcf,0xff,0xfc,0xcf,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0x9f,0xff,0xff,0xff,0x07,0xe7,0x7f,0xfe,0xe7,0x07,0xc0,0xe7,0x7f,0xfe,0xe7,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0x9f,0xff,0xff,0xff,0x07,0xe7,0x7f,0xfe,0xe7,0x07,
0xf0,0xe7,0x7f,0xfe,0xe7,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xcf,0xff,0xff,0xff,0x07,
0xf3,0x3f,0xff,0xf3,0x07,0xf8,0xf3,0x3f,0xff,0xf3,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xcf,0xff,0xff,0xff,0x07,0xf3,0x3f,0xff,0xf3,0x0f,0xfe,0xf3,0x3f,0xff,0xf3,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xe7,0xff,0xff,0xff,0x07,0xf9,0x9f,0xff,0xf9,0x8f,
0xff,0xf9,0x9f,0xff,0xf9,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe7,0xff,0xff,0xff,0x07,
0xf9,0x9f,0xff,0xf9,0xcf,0xff,0xf9,0x9f,0xff,0xf9,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xf3,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0x07,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0x07};

View File

@@ -0,0 +1,98 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#include "ultima/ultima1/u1gfx/sprites.h"
#include "ultima/shared/early/ultima_early.h"
#include "ultima/shared/early/game.h"
namespace Ultima {
namespace Ultima1 {
namespace U1Gfx {
BEGIN_MESSAGE_MAP(Sprites, Shared::TreeItem)
ON_MESSAGE(FrameMsg)
END_MESSAGE_MAP()
#define ANIMATE_FRAME_DELAY 200
void Sprites::load(bool isOverworld) {
_isOverworld = isOverworld;
if (isOverworld)
Shared::Gfx::Sprites::load("t1ktiles.bin", 4);
else
Shared::Gfx::Sprites::load("t1ktown.bin", 4, 8, 8);
}
bool Sprites::FrameMsg(CFrameMsg *msg) {
if (!empty() && _isOverworld) {
animateWater();
}
++_frameCtr;
return false;
}
void Sprites::animateWater() {
byte lineBuffer[16];
Shared::Gfx::Sprite &sprite = (*this)[0];
Common::copy(sprite.getBasePtr(0, 15), sprite.getBasePtr(0, 16), lineBuffer);
Common::copy_backward(sprite.getBasePtr(0, 0), sprite.getBasePtr(0, 15), sprite.getBasePtr(0, 16));
Common::copy(lineBuffer, lineBuffer + 16, sprite.getBasePtr(0, 0));
}
Shared::Gfx::Sprite &Sprites::operator[](uint idx) {
int offset = 2;
if ((_frameCtr % 6) == 0)
offset = 0;
else if ((_frameCtr % 3) == 0)
offset = 1;
if (!_isOverworld) {
// Don't do overworld tile animations within the cities and castles
return Shared::Gfx::Sprites::operator[](idx);
} else if (idx == 4 && offset != 2) {
// Castle flag waving
return Shared::Gfx::Sprites::operator[](4 + offset);
} else if (idx == 6) {
// City flag waving
return Shared::Gfx::Sprites::operator[](7 + ((_frameCtr & 3) ? 1 : 0));
} else {
if (idx >= 7 && idx < 50)
idx += 2;
if (idx == 14 || idx == 25) {
// Transports
return Shared::Gfx::Sprites::operator[](idx + (_frameCtr & 1));
} else if (idx >= 19 && idx <= 47) {
// Random monster animation
return Shared::Gfx::Sprites::operator[](idx + (g_vm->getRandomNumber(1, 100) & 1));
} else {
return Shared::Gfx::Sprites::operator[](idx);
}
}
}
} // End of namespace U1Gfx
} // End of namespace Ultima1
} // End of namespace Ultima

View File

@@ -0,0 +1,80 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ULTIMA_ULTIMA1_U1GFX_SPRITES_H
#define ULTIMA_ULTIMA1_U1GFX_SPRITES_H
#include "ultima/shared/gfx/sprites.h"
#include "ultima/shared/core/tree_item.h"
#include "ultima/shared/early/ultima_early.h"
#include "ultima/shared/engine/messages.h"
namespace Ultima {
namespace Ultima1 {
namespace U1Gfx {
using Shared::CFrameMsg;
/**
* Displays the total hits, food, experience, and coins you have
*/
class Sprites : public Shared::Gfx::Sprites, public Shared::TreeItem {
DECLARE_MESSAGE_MAP;
bool FrameMsg(CFrameMsg *msg);
private:
bool _isOverworld;
uint _frameCtr;
private:
/**
* Animates the water sprite by rotating it's lines vertically
*/
void animateWater();
public:
CLASSDEF;
/**
* Constructor
*/
Sprites(TreeItem *parent) : Shared::Gfx::Sprites(), TreeItem(), _isOverworld(false), _frameCtr(0) {
addUnder(parent);
}
/**
* Destructor
*/
~Sprites() override {}
/**
* Return a specific sprite
*/
Shared::Gfx::Sprite &operator[](uint idx) override;
/**
* Loads the Ultima 1 sprites
*/
void load(bool isOverworld);
};
} // End of namespace U1Gfx
} // End of namespace Ultima1
} // End of namespace Ultima
#endif

View File

@@ -0,0 +1,80 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#include "ultima/ultima1/u1gfx/status.h"
#include "ultima/ultima1/game.h"
#include "ultima/ultima1/core/resources.h"
namespace Ultima {
namespace Ultima1 {
namespace U1Gfx {
BEGIN_MESSAGE_MAP(Status, Shared::Gfx::VisualItem)
ON_MESSAGE(FrameMsg)
END_MESSAGE_MAP()
Status::Status(Shared::TreeItem *parent) : Shared::Gfx::VisualItem("Status", TextRect(31, 21, 39, 24), parent),
_hitPoints(0), _food(0), _experience(0), _coins(0) {
}
bool Status::FrameMsg(CFrameMsg *msg) {
// If any of the figures have changed, mark the display as dirty
const Ultima1Game *game = static_cast<const Ultima1Game *>(getGame());
const Shared::Character &c = *game->_party;
if (c._hitPoints != _hitPoints || c._food != _food || c._experience != _experience || c._coins != _coins)
setDirty(true);
return true;
}
void Status::draw() {
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
const Shared::Character &c = *game->_party;
// Update the local copy of the fields
_hitPoints = c._hitPoints;
_food = c._food;
_experience = c._experience;
_coins = c._coins;
// Clear the status area
Shared::Gfx::VisualSurface s = getSurface();
s.clear();
// Iterate through displaying the values
const uint *vals[4] = { &_hitPoints, &_food, &_experience, &_coins };
int count = game->isVGA() ? 3 : 4;
for (int idx = 0; idx < count; ++idx) {
// Write header
s.writeString(game->_res->STATUS_TEXT[idx], TextPoint(0, idx));
uint value = MIN(*vals[idx], (uint)9999);
s.writeString(Common::String::format("%4u", value), TextPoint(5, idx));
}
_isDirty = false;
}
} // End of namespace U1Gfx
} // End of namespace Ultima1
} // End of namespace Ultima

View File

@@ -0,0 +1,57 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ULTIMA_ULTIMA1_U1GFX_STATUS_H
#define ULTIMA_ULTIMA1_U1GFX_STATUS_H
#include "ultima/shared/gfx/visual_item.h"
namespace Ultima {
namespace Ultima1 {
namespace U1Gfx {
using Shared::CFrameMsg;
/**
* Displays the total hits, food, experience, and coins you have
*/
class Status : public Shared::Gfx::VisualItem {
DECLARE_MESSAGE_MAP;
bool FrameMsg(CFrameMsg *msg);
private:
uint _hitPoints, _food, _experience, _coins;
private:
public:
CLASSDEF;
Status(TreeItem *parent);
~Status() override {}
/**
* Draw the contents
*/
void draw() override;
};
} // End of namespace U1Gfx
} // End of namespace Ultima1
} // End of namespace Ultima
#endif

View File

@@ -0,0 +1,86 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#include "ultima/ultima1/u1gfx/text_cursor.h"
#include "ultima/shared/early/ultima_early.h"
#include "ultima/shared/gfx/screen.h"
#include "common/system.h"
#include "graphics/managed_surface.h"
namespace Ultima {
namespace Ultima1 {
namespace U1Gfx {
#define CURSOR_ANIM_FRAME_TIME 100
#define CURSOR_W 8
#define CURSOR_H 8
static const byte TEXT_CURSOR_FRAMES[4][8] = {
{ 0x66, 0x3C, 0x18, 0x66, 0x66, 0x18, 0x3C, 0x66 },
{ 0x3C, 0x18, 0x66, 0x24, 0x24, 0x66, 0x18, 0x3C },
{ 0x18, 0x66, 0x24, 0x3C, 0x3C, 0x24, 0x66, 0x18 },
{ 0x66, 0x24, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x66 }
};
U1TextCursor::U1TextCursor(const byte &fgColor, const byte &bgColor) : _fgColor(fgColor),
_bgColor(bgColor), _frameNum(0), _lastFrameFrame(0) {
_bounds = Common::Rect(0, 0, 8, 8);
}
void U1TextCursor::update() {
uint32 time = getTime();
if (!_visible || !_fgColor || (time - _lastFrameFrame) < CURSOR_ANIM_FRAME_TIME)
return;
// Increment to next frame
_lastFrameFrame = time;
_frameNum = (_frameNum + 1) % 3;
markAsDirty();
}
void U1TextCursor::draw() {
if (!_visible)
return;
// Get the surface area to draw the cursor on
Graphics::ManagedSurface s(8, 8);
// Loop to draw the cursor
for (int y = 0; y < CURSOR_H; ++y) {
byte *lineP = (byte *)s.getBasePtr(0, y);
byte bits = TEXT_CURSOR_FRAMES[_frameNum][y];
for (int x = 0; x < CURSOR_W; ++x, ++lineP, bits >>= 1) {
*lineP = (bits & 1) ? _fgColor : _bgColor;
}
}
g_system->copyRectToScreen(s.getPixels(), s.pitch, _bounds.left, _bounds.top, _bounds.width(), _bounds.height());
}
uint32 U1TextCursor::getTime() {
return g_system->getMillis();
}
} // End of namespace U1Gfx
} // End of namespace Ultima1
} // End of namespace Ultima

View File

@@ -0,0 +1,67 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ULTIMA_ULTIMA1_U1GFX_TEXT_CURSOR_H
#define ULTIMA_ULTIMA1_U1GFX_TEXT_CURSOR_H
#include "ultima/shared/gfx/text_cursor.h"
namespace Ultima {
namespace Ultima1 {
namespace U1Gfx {
class U1TextCursor : public Shared::Gfx::TextCursor {
private:
const byte &_fgColor, &_bgColor;
int _frameNum;
uint32 _lastFrameFrame;
private:
/**
* Get the current game milliseconds
*/
uint32 getTime();
public:
/**
* Constructor
*/
U1TextCursor(const byte &fgColor, const byte &bgColor);
/**
* Destructor
*/
~U1TextCursor() override {}
/**
* Update the cursor
*/
void update() override;
/**
* Draw the cursor
*/
void draw() override;
};
} // End of namespace U1Gfx
} // End of namespace Ultima1
} // End of namespace Ultima
#endif

View File

@@ -0,0 +1,405 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#include "ultima/ultima1/u1gfx/view_char_gen.h"
#include "ultima/ultima1/u1gfx/drawing_support.h"
#include "ultima/ultima1/core/resources.h"
#include "ultima/ultima1/maps/map.h"
#include "ultima/ultima1/u1gfx/text_cursor.h"
#include "ultima/ultima1/game.h"
#include "ultima/shared/gfx/text_input.h"
#include "ultima/shared/early/font_resources.h"
#include "ultima/shared/early/ultima_early.h"
namespace Ultima {
namespace Ultima1 {
namespace U1Gfx {
BEGIN_MESSAGE_MAP(ViewCharacterGeneration, Shared::Gfx::VisualItem)
ON_MESSAGE(KeypressMsg)
ON_MESSAGE(ShowMsg)
ON_MESSAGE(TextInputMsg)
END_MESSAGE_MAP()
ViewCharacterGeneration::ViewCharacterGeneration(Shared::TreeItem *parent) :
Shared::Gfx::VisualItem("CharGen", Rect(0, 0, 320, 200), parent) {
_textInput = new Shared::Gfx::TextInput(getGame());
}
ViewCharacterGeneration::~ViewCharacterGeneration() {
delete _textInput;
}
void ViewCharacterGeneration::setMode(uint flags) {
_flags = flags;
setDirty();
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
Shared::Gfx::TextCursor *textCursor = game->_textCursor;
textCursor->setVisible(false);
if (flags & FLAG_FRAME) {
// Set up character and attributes pointers
_character = *game->_party;
_attributes[0] = &_character->_strength;
_attributes[1] = &_character->_agility;
_attributes[2] = &_character->_stamina;
_attributes[3] = &_character->_charisma;
_attributes[4] = &_character->_wisdom;
_attributes[5] = &_character->_intelligence;
// Set character to default
_pointsRemaining = 30;
_selectedAttribute = 0;
_character->_strength = 10;
_character->_agility = 10;
_character->_stamina = 10;
_character->_charisma = 10;
_character->_wisdom = 10;
_character->_intelligence = 10;
} else if (_flags & FLAG_RACE) {
textCursor->setPosition(TextPoint(20, 17));
textCursor->setVisible(true);
} else if (_flags & FLAG_SEX) {
textCursor->setPosition(TextPoint(19, 17));
textCursor->setVisible(true);
} else if (_flags & FLAG_CLASS) {
textCursor->setPosition(TextPoint(21, 17));
textCursor->setVisible(true);
} else if (_flags & FLAG_NAME) {
_textInput->show(TextPoint(19, 17), false, 14, game->_textColor);
} else if (_flags & FLAG_SAVE) {
textCursor->setPosition(TextPoint(30, 22));
textCursor->setVisible(true);
}
}
void ViewCharacterGeneration::draw() {
Shared::Gfx::VisualItem::draw();
Shared::Gfx::VisualSurface s = getSurface();
if (_flags & FLAG_FRAME)
drawFrame(s);
if (_flags & FLAG_POINTS)
drawPointsRemaining(s);
if (_flags & FLAG_ATTRIBUTES)
drawAttributes(s);
if (_flags & FLAG_ATTR_POINTERS)
drawAttributePointers(s);
if (_flags & FLAG_HELP)
drawHelp(s);
if (_flags & FLAG_RACE)
drawRace(s);
if (_flags & FLAG_SEX)
drawSex(s);
if (_flags & FLAG_CLASS)
drawClass(s);
if (_flags & FLAG_NAME)
drawName(s);
if (_flags & FLAG_SAVE)
drawSave(s);
}
void ViewCharacterGeneration::drawFrame(Shared::Gfx::VisualSurface &s) {
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
// Clear the view and draw the outer frame
s.clear();
DrawingSupport ds(s);
ds.drawFrame();
// Draw the header on the top
ds.drawRightArrow(TextPoint(8, 0));
s.writeString(game->_res->CHAR_GEN_TEXT[0], TextPoint(9, 0), game->_edgeColor);
ds.drawLeftArrow(TextPoint(31, 0));
}
void ViewCharacterGeneration::drawPointsRemaining(Shared::Gfx::VisualSurface &s) {
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
s.writeString(Common::String::format(game->_res->CHAR_GEN_TEXT[1], _pointsRemaining), TextPoint(6, 4));
}
void ViewCharacterGeneration::drawAttributes(Shared::Gfx::VisualSurface &s) {
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
s.writeString(Common::String::format(game->_res->CHAR_GEN_TEXT[2],
_character->_strength, _character->_agility, _character->_stamina,
_character->_charisma, _character->_wisdom, _character->_intelligence),
TextPoint(12, 6));
}
void ViewCharacterGeneration::drawAttributePointers(Shared::Gfx::VisualSurface &s) {
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
DrawingSupport ds(s);
s.fillRect(Common::Rect(11 * 8, 6 * 8, 12 * 8, 12 * 8), game->_bgColor);
s.fillRect(Common::Rect(30 * 8, 6 * 8, 31 * 8, 12 * 8), game->_bgColor);
if (_selectedAttribute != -1) {
ds.drawRightArrow(TextPoint(11, _selectedAttribute + 6));
ds.drawLeftArrow(TextPoint(30, _selectedAttribute + 6));
}
}
void ViewCharacterGeneration::drawHelp(Shared::Gfx::VisualSurface &s) {
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
s.writeString(game->_res->CHAR_GEN_TEXT[3], TextPoint(2, 16));
}
void ViewCharacterGeneration::drawRace(Shared::Gfx::VisualSurface &s) {
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
s.fillRect(TextRect(6, 2, 37, 4), game->_bgColor);
s.fillRect(TextRect(2, 16, 37, 21), game->_bgColor);
s.writeString(game->_res->CHAR_GEN_TEXT[6], TextPoint(3, 17));
s.writeString(Common::String::format(game->_res->CHAR_GEN_TEXT[4],
game->_res->RACE_NAMES[0], game->_res->RACE_NAMES[1],
game->_res->RACE_NAMES[2], game->_res->RACE_NAMES[3]),
TextPoint(12, 19));
}
void ViewCharacterGeneration::drawSex(Shared::Gfx::VisualSurface &s) {
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
s.writeString(game->_res->CHAR_GEN_TEXT[9], TextPoint(14, 13));
s.writeString(game->_res->RACE_NAMES[_character->_race]);
s.fillRect(Rect(14, 128, 302, 184), game->_bgColor);
s.writeString(game->_res->CHAR_GEN_TEXT[7], TextPoint(3, 17));
s.writeString(Common::String::format(game->_res->CHAR_GEN_TEXT[5],
game->_res->SEX_NAMES[0], game->_res->SEX_NAMES[1]), TextPoint(12, 19));
}
void ViewCharacterGeneration::drawClass(Shared::Gfx::VisualSurface &s) {
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
s.writeString(game->_res->CHAR_GEN_TEXT[10], TextPoint(15, 14));
s.writeString(game->_res->SEX_NAMES[_character->_sex]);
s.fillRect(Rect(14, 128, 302, 184), game->_bgColor);
s.writeString(game->_res->CHAR_GEN_TEXT[8], TextPoint(3, 17));
s.writeString(Common::String::format(game->_res->CHAR_GEN_TEXT[4],
game->_res->CLASS_NAMES[0], game->_res->CLASS_NAMES[1],
game->_res->CLASS_NAMES[2], game->_res->CLASS_NAMES[3]),
TextPoint(12, 19));
}
void ViewCharacterGeneration::drawName(Shared::Gfx::VisualSurface &s) {
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
s.writeString(game->_res->CHAR_GEN_TEXT[11], TextPoint(13, 15));
s.writeString(game->_res->CLASS_NAMES[_character->_class]);
s.fillRect(Rect(14, 128, 302, 184), game->_bgColor);
s.writeString(game->_res->CHAR_GEN_TEXT[12], TextPoint(3, 17));
}
void ViewCharacterGeneration::drawSave(Shared::Gfx::VisualSurface &s) {
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
s.fillRect(Rect(14, 128, 302, 184), game->_bgColor);
s.writeString(_character->_name, TextPoint(12, 4));
s.writeString(game->_res->CHAR_GEN_TEXT[13], TextPoint(3, 22));
}
void ViewCharacterGeneration::setRace(int raceNum) {
_character->_race = raceNum;
switch (raceNum) {
case 0:
_character->_intelligence += 5;
break;
case 1:
_character->_agility += 5;
break;
case 2:
_character->_strength += 5;
break;
case 3:
_character->_wisdom += 10;
_character->_strength -= 5;
break;
default:
break;
}
setMode(FLAG_SEX | FLAG_ATTRIBUTES);
}
void ViewCharacterGeneration::setSex(int sexNum) {
_character->_sex = (Shared::Sex)sexNum;
setMode(FLAG_CLASS);
}
void ViewCharacterGeneration::setClass(int classNum) {
_character->_class = classNum;
switch (classNum) {
case 0:
_character->_strength += 10;
_character->_agility += 10;
break;
case 1:
_character->_wisdom += 10;
break;
case 2:
_character->_intelligence += 10;
break;
case 3:
_character->_agility += 10;
break;
default:
break;
}
setMode(FLAG_NAME | FLAG_ATTRIBUTES);
}
bool ViewCharacterGeneration::ShowMsg(CShowMsg *msg) {
Shared::Gfx::VisualItem::ShowMsg(msg);
setMode(FLAG_INITIAL);
return true;
}
bool ViewCharacterGeneration::HideMsg(CHideMsg *msg) {
Shared::Gfx::VisualItem::HideMsg(msg);
getGame()->_textCursor->setVisible(false);
return true;
}
bool ViewCharacterGeneration::KeypressMsg(CKeypressMsg *msg) {
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
if (_flags & FLAG_RACE) {
if (msg->_keyState.keycode >= Common::KEYCODE_a && msg->_keyState.keycode <= Common::KEYCODE_d)
setRace(msg->_keyState.keycode - Common::KEYCODE_a);
} else if (_flags & FLAG_SEX) {
if (msg->_keyState.keycode >= Common::KEYCODE_a && msg->_keyState.keycode <= Common::KEYCODE_b)
setSex(msg->_keyState.keycode - Common::KEYCODE_a);
} else if (_flags & FLAG_CLASS) {
if (msg->_keyState.keycode >= Common::KEYCODE_a && msg->_keyState.keycode <= Common::KEYCODE_d)
setClass(msg->_keyState.keycode - Common::KEYCODE_a);
} else if (_flags & FLAG_NAME) {
// Shouldn't reach here, since during name entry, keypresses go to text input
} else if (_flags & FLAG_SAVE) {
if (msg->_keyState.keycode == Common::KEYCODE_y) {
// Save the game
if (save())
setView("Game");
else
setView("Title");
} else if (msg->_keyState.keycode == Common::KEYCODE_n) {
// Start at the beginning again
setMode(FLAG_INITIAL);
}
} else {
// Initial attributes allocation
switch (msg->_keyState.keycode) {
case Common::KEYCODE_UP:
case Common::KEYCODE_KP8:
_selectedAttribute = (_selectedAttribute == 0) ? ATTRIBUTE_COUNT - 1 : _selectedAttribute - 1;
setMode(FLAG_ATTR_POINTERS);
break;
case Common::KEYCODE_DOWN:
case Common::KEYCODE_KP2:
_selectedAttribute = (_selectedAttribute == ATTRIBUTE_COUNT - 1) ? 0 : _selectedAttribute + 1;
setMode(FLAG_ATTR_POINTERS);
break;
case Common::KEYCODE_LEFT:
case Common::KEYCODE_KP4:
if (*_attributes[_selectedAttribute] > 10) {
++_pointsRemaining;
--*_attributes[_selectedAttribute];
}
setMode(FLAG_ATTRIBUTES | FLAG_POINTS);
break;
case Common::KEYCODE_RIGHT:
case Common::KEYCODE_KP6:
if (_pointsRemaining > 0 && *_attributes[_selectedAttribute] < 25) {
--_pointsRemaining;
++*_attributes[_selectedAttribute];
}
setMode(FLAG_ATTRIBUTES | FLAG_POINTS);
break;
case Common::KEYCODE_SPACE:
if (_pointsRemaining == 0) {
// Switch over to selecting race
game->playFX(1);
_selectedAttribute = -1;
setMode(FLAG_RACE | FLAG_ATTR_POINTERS);
} else {
game->playFX(0);
}
break;
case Common::KEYCODE_ESCAPE:
// Switch back to main menu
setView("Title");
break;
default:
break;
}
}
return true;
}
bool ViewCharacterGeneration::TextInputMsg(CTextInputMsg *msg) {
if (!msg->_escaped && !msg->_text.empty()) {
// Name provided
_character->_name = msg->_text;
_textInput->hide();
setMode(FLAG_SAVE);
}
return true;
}
bool ViewCharacterGeneration::save() {
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
game->_randomSeed = game->getRandomNumber(0xfffffff);
// Set the default position
Shared::Maps::Map *map = game->_map;
map->load(Ultima1::Maps::MAPID_OVERWORLD);
map->setPosition(Point(49, 40));
// Set other character properties
_character->_hitPoints = 150;
_character->_coins = 100;
_character->_food = 200;
_character->_experience = 0;
_character->_equippedWeapon = 1;
_character->_weapons[1]->_quantity = 1; // Dagger
_character->_equippedArmour = 1;
_character->_armour[1]->_quantity = 1; // Leather armour
_character->_equippedSpell = 0;
return g_vm->saveGameDialog();
}
} // End of namespace U1Gfx
} // End of namespace Shared
} // End of namespace Ultima

View File

@@ -0,0 +1,160 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ULTIMA_ULTIMA1_GFX_VIEW_CHAR_GEN_H
#define ULTIMA_ULTIMA1_GFX_VIEW_CHAR_GEN_H
#include "ultima/shared/gfx/visual_container.h"
#include "ultima/shared/gfx/text_input.h"
#include "ultima/shared/core/party.h"
#include "graphics/managed_surface.h"
namespace Ultima {
namespace Ultima1 {
namespace U1Gfx {
#define ATTRIBUTE_COUNT 6
using Shared::CKeypressMsg;
using Shared::CShowMsg;
using Shared::CHideMsg;
using Shared::CTextInputMsg;
/**
* This class implements the character generation view
*/
class ViewCharacterGeneration : public Shared::Gfx::VisualItem {
DECLARE_MESSAGE_MAP;
bool KeypressMsg(CKeypressMsg *msg);
bool ShowMsg(CShowMsg *msg);
bool HideMsg(CHideMsg *msg);
bool TextInputMsg(CTextInputMsg *msg);
private:
enum Flag {
FLAG_FRAME = 1, FLAG_POINTS = 2, FLAG_ATTRIBUTES = 4, FLAG_ATTR_POINTERS = 8, FLAG_HELP = 16,
FLAG_RACE = 32, FLAG_SEX = 64, FLAG_CLASS = 128, FLAG_NAME = 256, FLAG_SAVE = 512,
FLAG_INITIAL = FLAG_FRAME | FLAG_POINTS | FLAG_ATTRIBUTES | FLAG_ATTR_POINTERS | FLAG_HELP
};
uint _flags;
Shared::Character *_character;
int _pointsRemaining;
int _selectedAttribute;
uint *_attributes[ATTRIBUTE_COUNT];
Shared::Gfx::TextInput *_textInput;
private:
/**
* Set state within the view
*/
void setMode(uint flags);
/**
* Draw the outer frame for the view
*/
void drawFrame(Shared::Gfx::VisualSurface &s);
/**
* Draw points remaining
*/
void drawPointsRemaining(Shared::Gfx::VisualSurface &s);
/**
* Draw the attribute list
*/
void drawAttributes(Shared::Gfx::VisualSurface &s);
/**
* Draw the pointers to the currently selected attribute
*/
void drawAttributePointers(Shared::Gfx::VisualSurface &s);
/**
* Draw the help text
*/
void drawHelp(Shared::Gfx::VisualSurface &s);
/**
* Draw the race selection
*/
void drawRace(Shared::Gfx::VisualSurface &s);
/**
* Draw the sex selection
*/
void drawSex(Shared::Gfx::VisualSurface &s);
/**
* Draw the class selection
*/
void drawClass(Shared::Gfx::VisualSurface &s);
/**
* Draw the name entry
*/
void drawName(Shared::Gfx::VisualSurface &s);
/**
* Draw the save prompt
*/
void drawSave(Shared::Gfx::VisualSurface &s);
/**
* Set the character's race
*/
void setRace(int raceNum);
/**
* Set the character's sex
*/
void setSex(int sexNum);
/**
* Set the character's class
*/
void setClass(int classNum);
/**
* Set final properties and save the game
*/
bool save();
public:
CLASSDEF;
/**
* Constructor
*/
ViewCharacterGeneration(Shared::TreeItem *parent = nullptr);
/**
* Destructor
*/
~ViewCharacterGeneration() override;
/**
* Draw the game screen
*/
void draw() override;
};
} // End of namespace U1Gfx
} // End of namespace Shared
} // End of namespace Ultima
#endif

View File

@@ -0,0 +1,290 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#include "ultima/ultima1/u1gfx/view_game.h"
#include "ultima/shared/actions/huh.h"
#include "ultima/shared/actions/pass.h"
#include "ultima/shared/maps/map.h"
#include "ultima/ultima1/game.h"
#include "ultima/ultima1/u1gfx/drawing_support.h"
#include "ultima/ultima1/u1gfx/info.h"
#include "ultima/ultima1/u1gfx/status.h"
#include "ultima/ultima1/u1gfx/viewport_dungeon.h"
#include "ultima/ultima1/u1gfx/viewport_map.h"
#include "ultima/ultima1/actions/map_action.h"
#include "ultima/ultima1/actions/move.h"
#include "ultima/ultima1/actions/attack.h"
#include "ultima/ultima1/actions/quit.h"
#include "ultima/ultima1/actions/ready.h"
#include "ultima/ultima1/actions/stats.h"
#include "ultima/ultima1/core/resources.h"
#include "ultima/shared/gfx/text_cursor.h"
#include "ultima/shared/engine/messages.h"
namespace Ultima {
namespace Ultima1 {
namespace Actions {
MAP_ACTION(Board, 1, board)
MAP_ACTION(Cast, 2, cast)
MAP_ACTION(Drop, 3, drop)
MAP_ACTION_END_TURN(Enter, 4, enter)
MAP_ACTION_END_TURN(Get, 6, get)
MAP_ACTION_END_TURN(HyperJump, 7, hyperjump)
MAP_ACTION_END_TURN(Inform, 8, inform)
MAP_ACTION_END_TURN(Climb, 10, climb)
MAP_ACTION_END_TURN(Open, 14, open)
MAP_ACTION_END_TURN(Steal, 18, steal)
MAP_ACTION(Transact, 19, talk)
MAP_ACTION_END_TURN(Unlock, 20, unlock)
MAP_ACTION_END_TURN(ViewChange, 21, view)
MAP_ACTION_END_TURN(ExitTransport, 23, disembark)
}
namespace U1Gfx {
BEGIN_MESSAGE_MAP(ViewGame, Shared::Gfx::VisualContainer)
ON_MESSAGE(ShowMsg)
ON_MESSAGE(EndOfTurnMsg)
ON_MESSAGE(FrameMsg)
ON_MESSAGE(CharacterInputMsg)
END_MESSAGE_MAP()
ViewGame::ViewGame(TreeItem *parent) : Shared::Gfx::VisualContainer("Game", Rect(0, 0, 320, 200), parent), _frameCtr(0) {
_info = new Info(this);
_status = new Status(this);
_viewportDungeon = new ViewportDungeon(this);
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
_viewportMap = new ViewportMap(this);
_actions.resize(22);
_actions[0] = new Actions::Move(this);
_actions[1] = new Shared::Actions::Huh(this, game->_res->HUH);
_actions[2] = new Actions::Attack(this);
_actions[3] = new Actions::Board(this);
_actions[4] = new Actions::Cast(this);
_actions[5] = new Actions::Drop(this);
_actions[6] = new Actions::Enter(this);
_actions[7] = new Actions::Fire(this);
_actions[8] = new Actions::Get(this);
_actions[9] = new Actions::HyperJump(this);
_actions[10] = new Actions::Inform(this);
_actions[11] = new Actions::Climb(this);
_actions[12] = new Actions::Open(this);
_actions[13] = new Shared::Actions::Pass(this, game->_res->ACTION_NAMES[15]);
_actions[14] = new Actions::Quit(this);
_actions[15] = new Actions::Ready(this);
_actions[16] = new Actions::Steal(this);
_actions[17] = new Actions::Transact(this);
_actions[18] = new Actions::Unlock(this);
_actions[19] = new Actions::ViewChange(this);
_actions[20] = new Actions::ExitTransport(this);
_actions[21] = new Actions::Stats(this);
}
ViewGame::~ViewGame() {
delete _info;
delete _status;
delete _viewportDungeon;
delete _viewportMap;
for (uint idx = 0; idx < _actions.size(); ++idx)
delete _actions[idx];
}
void ViewGame::draw() {
Shared::Gfx::VisualSurface s = getSurface();
if (_isDirty) {
// Draw the overal frame
s.clear();
DrawingSupport ds(s);
ds.drawGameFrame();
drawIndicators();
setDirty();
}
if (_info->isDirty())
_info->draw();
if (_status->isDirty())
_status->draw();
Maps::Ultima1Map *map = static_cast<Maps::Ultima1Map *>(getGame()->getMap());
switch (map->_mapType) {
case Maps::MAP_DUNGEON:
_viewportDungeon->draw();
break;
default:
_viewportMap->draw();
break;
}
_isDirty = false;
}
void ViewGame::drawIndicators() {
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
Maps::Ultima1Map *map = static_cast<Maps::Ultima1Map *>(game->getMap());
Shared::Gfx::VisualSurface s = getSurface();
DrawingSupport ds(s);
if (map->_mapType == Maps::MAP_DUNGEON) {
// Draw the dungeon level indicator
ds.drawRightArrow(TextPoint(15, 0));
s.writeString(game->_res->DUNGEON_LEVEL, TextPoint(16, 0));
s.writeString(Common::String::format("%2d", map->getLevel()), TextPoint(23, 0));
ds.drawLeftArrow(TextPoint(26, 0));
// Draw the current direction
const char *dir = game->_res->DIRECTION_NAMES[map->getDirection() - 1];
ds.drawRightArrow(TextPoint(16, 19));
s.writeString(" ", TextPoint(17, 19));
s.writeString(dir, TextPoint(19 - (7 - strlen(dir)) / 2, 19));
ds.drawLeftArrow(TextPoint(24, 19));
}
}
bool ViewGame::ShowMsg(CShowMsg *msg) {
// Set the info area to prompt for a command
Shared::CInfoGetCommandKeypress cmdMsg(this);
cmdMsg.execute(this);
return true;
}
bool ViewGame::EndOfTurnMsg(CEndOfTurnMsg *msg) {
// Set the info area to prompt for the next command
Shared::CInfoGetCommandKeypress cmdMsg(this);
cmdMsg.execute(this);
return false;
}
#define FRAME_REDUCTION_RATE 5
bool ViewGame::FrameMsg(CFrameMsg *msg) {
if (_frameCtr == FRAME_REDUCTION_RATE) {
// Ignore frame message at the start of passing reduced frame rate to child views
return false;
} else if (++_frameCtr == FRAME_REDUCTION_RATE) {
msg->execute(this, nullptr, Shared::MSGFLAG_SCAN);
_frameCtr = 0;
}
return true;
}
/**
* Dispatch action
*/
template<class T>
void dispatchKey(ViewGame *game) {
T dMsg;
dMsg.execute(game);
}
#define CHECK(KEYCODE, MSG_CLASS) else if (msg->_keyState.keycode == KEYCODE) { dispatchKey<MSG_CLASS>(this); }
bool ViewGame::checkMovement(const Common::KeyState &keyState) {
Shared::Maps::Direction dir = Shared::Maps::MapWidget::directionFromKey(keyState.keycode);
switch (dir) {
case Shared::Maps::DIR_WEST: {
if (keyState.flags & Common::KBD_SHIFT) {
Shared::CAttackMsg attack(Shared::Maps::DIR_LEFT);
attack.execute(this);
} else {
Shared::CMoveMsg move(Shared::Maps::DIR_LEFT);
move.execute(this);
}
break;
}
case Shared::Maps::DIR_EAST: {
if (keyState.flags & Common::KBD_SHIFT) {
Shared::CAttackMsg attack(Shared::Maps::DIR_RIGHT);
attack.execute(this);
} else {
Shared::CMoveMsg move(Shared::Maps::DIR_RIGHT);
move.execute(this);
}
break;
}
case Shared::Maps::DIR_UP: {
if (keyState.flags & Common::KBD_SHIFT) {
Shared::CAttackMsg attack(Shared::Maps::DIR_UP);
attack.execute(this);
} else {
Shared::CMoveMsg move(Shared::Maps::DIR_UP);
move.execute(this);
}
break;
}
case Shared::Maps::DIR_DOWN: {
if (keyState.flags & Common::KBD_SHIFT) {
Shared::CAttackMsg attack(Shared::Maps::DIR_DOWN);
attack.execute(this);
} else {
Shared::CMoveMsg move(Shared::Maps::DIR_DOWN);
move.execute(this);
}
break;
}
default:
return false;
}
return true;
}
bool ViewGame::CharacterInputMsg(CCharacterInputMsg *msg) {
if (checkMovement(msg->_keyState)) {}
CHECK(Common::KEYCODE_a, Shared::CAttackMsg)
CHECK(Common::KEYCODE_b, Shared::CBoardMsg)
CHECK(Common::KEYCODE_c, Shared::CCastMsg)
CHECK(Common::KEYCODE_d, Shared::CDropMsg)
CHECK(Common::KEYCODE_e, Shared::CEnterMsg)
CHECK(Common::KEYCODE_f, Shared::CFireMsg)
CHECK(Common::KEYCODE_g, Shared::CGetMsg)
CHECK(Common::KEYCODE_h, Shared::CHyperJumpMsg)
CHECK(Common::KEYCODE_i, Shared::CInformMsg)
CHECK(Common::KEYCODE_k, Shared::CClimbMsg)
CHECK(Common::KEYCODE_o, Shared::COpenMsg)
CHECK(Common::KEYCODE_q, Shared::CQuitMsg)
CHECK(Common::KEYCODE_r, Shared::CReadyMsg)
CHECK(Common::KEYCODE_s, Shared::CStealMsg)
CHECK(Common::KEYCODE_t, Shared::CTransactMsg)
CHECK(Common::KEYCODE_u, Shared::CUnlockMsg)
CHECK(Common::KEYCODE_v, Shared::CViewChangeMsg)
CHECK(Common::KEYCODE_x, Shared::CExitTransportMsg)
CHECK(Common::KEYCODE_z, Shared::CStatsMsg)
CHECK(Common::KEYCODE_SPACE, Shared::CPassMsg)
else {
// Fallback for unknown key
dispatchKey<Shared::CPassMsg>(this);
}
return true;
}
} // End of namespace U1Gfx
} // End of namespace Shared
} // End of namespace Ultima

View File

@@ -0,0 +1,91 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ULTIMA_ULTIMA1_GFX_VIEW_GAME_H
#define ULTIMA_ULTIMA1_GFX_VIEW_GAME_H
#include "ultima/shared/gfx/visual_container.h"
#include "ultima/shared/gfx/bitmap.h"
namespace Ultima {
namespace Shared {
class Info;
class ViewportDungeon;
namespace Actions {
class Action;
} // End of namespace Actions
} // End of namespace Shared
namespace Ultima1 {
namespace U1Gfx {
class Status;
class ViewportMap;
using Shared::CShowMsg;
using Shared::CEndOfTurnMsg;
using Shared::CFrameMsg;
using Shared::CCharacterInputMsg;
/**
* This class implements a standard view screen that shows a status and log area, as well as either
* a map or dungeon view covering the bulk of the screen
*/
class ViewGame : public Shared::Gfx::VisualContainer {
DECLARE_MESSAGE_MAP;
bool ShowMsg(CShowMsg *msg);
bool EndOfTurnMsg(CEndOfTurnMsg *msg);
bool FrameMsg(CFrameMsg *msg);
bool CharacterInputMsg(CCharacterInputMsg *msg);
private:
Shared::Info *_info;
Shared::ViewportDungeon *_viewportDungeon;
ViewportMap *_viewportMap;
Status *_status;
Common::Array<Shared::Actions::Action *> _actions;
int _frameCtr;
private:
/**
* Draws level & direction indicators when in a dungeon
*/
void drawIndicators();
/**
* Handle movement keys
*/
bool checkMovement(const Common::KeyState &keyState);
public:
CLASSDEF;
ViewGame(TreeItem *parent = nullptr);
~ViewGame() override;
/**
* Draw the game screen
*/
void draw() override;
};
} // End of namespace U1Gfx
} // End of namespace Shared
} // End of namespace Ultima
#endif

View File

@@ -0,0 +1,330 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#include "ultima/ultima1/u1gfx/view_title.h"
#include "ultima/ultima1/u1gfx/drawing_support.h"
#include "ultima/ultima1/core/resources.h"
#include "ultima/ultima1/game.h"
#include "ultima/shared/core/file.h"
#include "ultima/shared/gfx/text_cursor.h"
#include "ultima/shared/early/font_resources.h"
#include "ultima/shared/early/ultima_early.h"
#include "graphics/blit.h"
#include "image/xbm.h"
#include "ultima/ultima1/u1gfx/flags.xbm"
#include "ultima/ultima1/u1gfx/logo.xbm"
namespace Ultima {
namespace Ultima1 {
namespace U1Gfx {
BEGIN_MESSAGE_MAP(ViewTitle, Shared::Gfx::VisualItem)
ON_MESSAGE(ShowMsg)
ON_MESSAGE(KeypressMsg)
ON_MESSAGE(FrameMsg)
END_MESSAGE_MAP()
void load16(Graphics::ManagedSurface &s, Common::ReadStream &in) {
byte *destP = (byte *)s.getPixels();
byte v;
for (int idx = 0; idx < (s.w * s.h); idx += 2) {
v = in.readByte();
*destP++ = v & 0xf;
*destP++ = v >> 4;
}
}
ViewTitle::ViewTitle(Shared::TreeItem *parent) : Shared::Gfx::VisualItem("Title", Rect(0, 0, 320, 200), parent) {
// In XBM images, 0 is white and 1 is black.
// We need to remap this to the order required by the engine.
static const uint32 logo_map[] = { 1, 0 };
static const uint32 flags_map[] = { 11, 10 };
setMode(TITLEMODE_COPYRIGHT);
// Load the Origin logo
Image::XBMDecoder logo;
if (!logo.loadBits(logo_bits, logo_width, logo_height))
error("Couldn't load logo");
const Graphics::Surface *src = logo.getSurface();
_logo.create(src->w, src->h);
Graphics::crossBlitMap((byte *)_logo.getPixels(), (const byte *)src->getPixels(),
_logo.pitch, src->pitch, _logo.w, _logo.h,
_logo.format.bytesPerPixel, logo_map);
// Load the Ultima castle bitmap
Shared::File f("castle.16");
_castle.create(320, 200);
load16(_castle, f);
f.close();
// Load the flags
Image::XBMDecoder flags;
if (!flags.loadBits(flags_bits, flags_width, flags_height))
error("Could not load flags");
src = flags.getSurface();
for (int idx = 0; idx < 3; ++idx) {
_flags[idx].create(8, 8);
Graphics::crossBlitMap((byte *)_flags[idx].getPixels(), (const byte *)src->getBasePtr(idx * 8, 8),
_flags[idx].pitch, src->pitch, _flags[idx].w, _flags[idx].h,
_flags[idx].format.bytesPerPixel, flags_map);
}
}
void ViewTitle::draw() {
VisualItem::draw();
switch (_mode) {
case TITLEMODE_COPYRIGHT:
drawCopyrightView();
break;
case TITLEMODE_PRESENTS:
drawPresentsView();
break;
case TITLEMODE_CASTLE:
drawCastleView();
break;
case TITLEMODE_TRADEMARKS:
drawTrademarksView();
break;
case TITLEMODE_MAIN_MENU:
drawMainMenu();
break;
default:
break;
}
}
void ViewTitle::drawCopyrightView() {
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
Shared::Gfx::VisualSurface s = getSurface();
s.clear();
// Draw horizontal title lines
for (int idx = 0; idx < 3; ++idx) {
s.hLine(112, idx + 58, 200, 1);
s.hLine(112, idx + 74, 200, 1);
}
// Write text
s.writeString(game->_res->TITLE_MESSAGES[0], TextPoint(16, 8), game->_whiteColor);
s.writeString(game->_res->TITLE_MESSAGES[1], TextPoint(8, 11), game->_whiteColor);
s.writeString(game->_res->TITLE_MESSAGES[2], TextPoint(0, 21), game->_whiteColor);
}
void ViewTitle::drawPresentsView() {
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
Shared::Gfx::VisualSurface s = getSurface();
switch (_counter) {
case 0:
s.clear();
s.blitFrom(_logo, Point(20, 21));
s.writeString(game->_res->TITLE_MESSAGES[3], TextPoint(14, 13));
break;
case 1:
s.writeString(game->_res->TITLE_MESSAGES[4], TextPoint(5, 12));
s.writeString(game->_res->TITLE_MESSAGES[5], TextPoint(5, 13));
s.writeString(game->_res->TITLE_MESSAGES[6], TextPoint(5, 14));
break;
case 2:
s.fillRect(Rect(0, 12 * 8, 320, 15 * 8), game->_bgColor);
s.writeString(game->_res->TITLE_MESSAGES[7], TextPoint(6, 12));
s.writeString(game->_res->TITLE_MESSAGES[8], TextPoint(6, 13));
break;
default:
break;
}
}
void ViewTitle::drawCastleView() {
Shared::Gfx::VisualSurface s = getSurface();
if (_counter == 0)
s.blitFrom(_castle);
drawCastleFlag(s, 123);
drawCastleFlag(s, 196);
}
void ViewTitle::drawCastleFlag(Shared::Gfx::VisualSurface &s, int xp) {
s.blitFrom(_flags[getGame()->getRandomNumber(0, 2)], Common::Point(xp, 55));
}
void ViewTitle::drawTrademarksView() {
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
Shared::Gfx::VisualSurface s = getSurface();
if (_counter == 0)
s.clear();
if (_counter < 32) {
s.blitFrom(_logo, Common::Rect(0, 0, _logo.w, _counter + 1), Point(20, 21));
s.blitFrom(_logo, Common::Rect(0, _logo.h - _counter - 1, _logo.w, _logo.h),
Common::Point(20, 21 + _logo.h - _counter - 1));
} else {
s.writeString(game->_res->TITLE_MESSAGES[9], TextPoint(1, 17));
s.writeString(game->_res->TITLE_MESSAGES[10], TextPoint(2, 18));
s.writeString(game->_res->TITLE_MESSAGES[11], TextPoint(11, 19));
s.writeString(game->_res->TITLE_MESSAGES[12], TextPoint(6, 23));
}
}
void ViewTitle::drawMainMenu() {
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
Shared::Gfx::VisualSurface s = getSurface();
DrawingSupport ds(s);
s.clear();
ds.drawFrame();
s.writeString(game->_res->MAIN_MENU_TEXT[0], TextPoint(12, 6));
s.writeString(game->_res->MAIN_MENU_TEXT[1], TextPoint(14, 9));
s.writeString(game->_res->MAIN_MENU_TEXT[2], TextPoint(14, 10));
s.writeString(game->_res->MAIN_MENU_TEXT[3], TextPoint(13, 11));
s.writeString(game->_res->MAIN_MENU_TEXT[4], TextPoint(8, 14));
s.writeString(game->_res->MAIN_MENU_TEXT[5], TextPoint(8, 15));
s.writeString(game->_res->MAIN_MENU_TEXT[6], TextPoint(13, 18));
}
void ViewTitle::setTitlePalette() {
const byte PALETTE[] = { 0, 1, 2, 3, 4, 5, 6, 7, 56, 57, 58, 59, 60, 61, 62, 63 };
getGame()->setEGAPalette(PALETTE);
}
void ViewTitle::setCastlePalette() {
const byte PALETTE[] = { 0, 24, 7, 63, 63, 34, 58, 14, 20, 7, 61, 59, 1, 57, 7, 63 };
getGame()->setEGAPalette(PALETTE);
}
bool ViewTitle::FrameMsg(CFrameMsg *msg) {
uint32 time = getGame()->getMillis();
if (time < _expiryTime)
return true;
setDirty();
switch (_mode) {
case TITLEMODE_COPYRIGHT:
setMode(TITLEMODE_PRESENTS);
break;
case TITLEMODE_PRESENTS:
_expiryTime = time + 3000;
if (++_counter == 3)
setMode(TITLEMODE_CASTLE);
break;
case TITLEMODE_CASTLE:
_expiryTime = time + 200;
if (++_counter == 100)
setMode(TITLEMODE_PRESENTS);
break;
case TITLEMODE_TRADEMARKS:
_expiryTime = time + 20;
++_counter;
if (_counter == 32) {
_expiryTime = time + 4000;
} else if (_counter == 33) {
setMode(TITLEMODE_MAIN_MENU);
}
break;
default:
break;
}
return true;
}
void ViewTitle::setMode(TitleMode mode) {
_expiryTime = getGame()->getMillis();
_counter = 0;
_mode = mode;
setDirty();
setTitlePalette();
switch (mode) {
case TITLEMODE_COPYRIGHT:
_expiryTime += 4000;
break;
case TITLEMODE_PRESENTS:
_expiryTime += 3000;
break;
case TITLEMODE_CASTLE:
setCastlePalette();
break;
case TITLEMODE_MAIN_MENU: {
Shared::Gfx::TextCursor *textCursor = getGame()->_textCursor;
textCursor->setPosition(TextPoint(25, 18));
textCursor->setVisible(true);
break;
}
default:
break;
}
}
bool ViewTitle::ShowMsg(CShowMsg *msg) {
Shared::Gfx::VisualItem::ShowMsg(msg);
if (_mode == TITLEMODE_MAIN_MENU) {
// Returning to main menu from another screen
setMode(TITLEMODE_MAIN_MENU);
}
return true;
}
bool ViewTitle::KeypressMsg(CKeypressMsg *msg) {
uint32 time = getGame()->getMillis();
if (_mode == TITLEMODE_MAIN_MENU) {
if (msg->_keyState.keycode == Common::KEYCODE_a || msg->_keyState.keycode == Common::KEYCODE_b) {
// Hide the cursor
Shared::Gfx::TextCursor *textCursor = getGame()->_textCursor;
textCursor->setVisible(false);
if (msg->_keyState.keycode == Common::KEYCODE_a) {
setView("CharGen");
} else {
if (!g_vm->loadGameDialog())
textCursor->setVisible(true);
}
}
} else if (_mode != TITLEMODE_TRADEMARKS) {
// Switch to the trademarks view
_mode = TITLEMODE_TRADEMARKS;
_expiryTime = time;
_counter = -1;
}
return true;
}
} // End of namespace U1Gfx
} // End of namespace Shared
} // End of namespace Ultima

View File

@@ -0,0 +1,116 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ULTIMA_ULTIMA1_GFX_VIEW_MAP_H
#define ULTIMA_ULTIMA1_GFX_VIEW_MAP_H
#include "ultima/shared/gfx/visual_container.h"
#include "ultima/shared/gfx/bitmap.h"
#include "graphics/managed_surface.h"
namespace Ultima {
namespace Ultima1 {
namespace U1Gfx {
using Shared::CShowMsg;
using Shared::CKeypressMsg;
using Shared::CFrameMsg;
/**
* This class implements the title screen, which shows the copyright screens and Ultima castle screen,
* as well as the main menu
*/
class ViewTitle : public Shared::Gfx::VisualItem {
DECLARE_MESSAGE_MAP;
bool ShowMsg(CShowMsg *msg);
bool KeypressMsg(CKeypressMsg *msg);
bool FrameMsg(CFrameMsg *msg);
private:
Graphics::ManagedSurface _logo, _castle;
Graphics::ManagedSurface _flags[3];
enum TitleMode { TITLEMODE_COPYRIGHT, TITLEMODE_PRESENTS, TITLEMODE_CASTLE, TITLEMODE_TRADEMARKS, TITLEMODE_MAIN_MENU };
TitleMode _mode;
uint32 _expiryTime;
int _counter;
private:
/**
* Shows the initial copyright screen
*/
void drawCopyrightView();
/**
* Draws the presents view
*/
void drawPresentsView();
/**
* Draws the castle view
*/
void drawCastleView();
/**
* Animates the castle flags
*/
void drawCastleFlag(Shared::Gfx::VisualSurface &s, int xp);
/**
* Draws the trademarks view
*/
void drawTrademarksView();
/**
* Draws the main menu
*/
void drawMainMenu();
/**
* Sets up the palette for the castle view
*/
void setCastlePalette();
/**
* Sets up the palette for the title views
*/
void setTitlePalette();
/**
* Sets the current mode (display) within the title
*/
void setMode(TitleMode mode);
public:
CLASSDEF;
/**
* Constructor
*/
ViewTitle(Shared::TreeItem *parent = nullptr);
/**
* Draw the game screen
*/
void draw() override;
};
} // End of namespace U1Gfx
} // End of namespace Shared
} // End of namespace Ultima
#endif

View File

@@ -0,0 +1,43 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#include "ultima/ultima1/u1gfx/viewport_dungeon.h"
#include "ultima/ultima1/widgets/dungeon_widget.h"
#include "ultima/shared/early/ultima_early.h"
namespace Ultima {
namespace Ultima1 {
namespace U1Gfx {
Shared::DungeonSurface ViewportDungeon::getSurface() {
Graphics::ManagedSurface src(*g_vm->_screen, _bounds);
return Shared::DungeonSurface(src, _bounds, getGame(), &drawWidget);
}
void ViewportDungeon::drawWidget(Graphics::ManagedSurface &s, uint widgetId, uint distance, byte color) {
// Pass on to the dungeon widget drawer
Graphics::ManagedSurface surf(s, Common::Rect(-8, -8, s.w - 8, s.h - 8));
Widgets::DungeonWidget::drawWidget(surf, (Widgets::DungeonWidgetId)widgetId, distance, color);
}
} // End of namespace U1Gfx
} // End of namespace Ultima1
} // End of namespace Ultima

View File

@@ -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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ULTIMA_ULTIMA1_U1GFX_VIEWPORT_DUNGEON_H
#define ULTIMA_ULTIMA1_U1GFX_VIEWPORT_DUNGEON_H
#include "ultima/shared/gfx/viewport_dungeon.h"
namespace Ultima {
namespace Ultima1 {
namespace U1Gfx {
class ViewportDungeon : public Shared::ViewportDungeon {
private:
/**
* Draws a dungeon widget
*/
static void drawWidget(Graphics::ManagedSurface &s, uint widgetId, uint distance, byte color);
protected:
/**
* Returns the surface for rendering the dungeon
*/
Shared::DungeonSurface getSurface() override;
public:
ViewportDungeon(TreeItem *parent) : Shared::ViewportDungeon(parent) {}
~ViewportDungeon() override {}
};
} // End of namespace U1Gfx
} // End of namespace Ultima1
} // End of namespace Ultima
#endif

View File

@@ -0,0 +1,63 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#include "ultima/ultima1/u1gfx/viewport_map.h"
#include "ultima/ultima1/u1gfx/sprites.h"
#include "ultima/ultima1/game.h"
namespace Ultima {
namespace Ultima1 {
namespace U1Gfx {
BEGIN_MESSAGE_MAP(ViewportMap, Shared::ViewportMap)
ON_MESSAGE(FrameMsg)
END_MESSAGE_MAP()
ViewportMap::ViewportMap(TreeItem *parent) : Shared::ViewportMap(parent), _mapType(Maps::MAP_OVERWORLD) {
_sprites = new Sprites(this);
}
ViewportMap::~ViewportMap() {
}
void ViewportMap::draw() {
Maps::Ultima1Map *map = static_cast<Maps::Ultima1Map *>(getGame()->getMap());
// If necessary, load the sprites for rendering the map
if (_sprites->empty() || _mapType != map->_mapType) {
_mapType = map->_mapType;
Sprites *sprites = static_cast<Sprites *>(_sprites);
sprites->load(_mapType == Maps::MAP_OVERWORLD);
}
// Draw the map
Shared::ViewportMap::draw();
}
bool ViewportMap::FrameMsg(CFrameMsg *msg) {
// To allow map to animate, on each frame mark the map as dirty again
setDirty(true);
return true;
}
} // End of namespace U1Gfx
} // End of namespace Ultima1
} // End of namespace Ultima

View File

@@ -0,0 +1,62 @@
/* 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 3 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, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef ULTIMA_ULTIMA1_GFX_VIEWPORT_MAP_H
#define ULTIMA_ULTIMA1_GFX_VIEWPORT_MAP_H
#include "ultima/shared/gfx/viewport_map.h"
#include "ultima/ultima1/maps/map.h"
namespace Ultima {
namespace Ultima1 {
namespace U1Gfx {
using Shared::CFrameMsg;
class ViewportMap : public Shared::ViewportMap {
DECLARE_MESSAGE_MAP;
bool FrameMsg(CFrameMsg *msg);
private:
Maps::MapType _mapType;
public:
CLASSDEF;
/**
* Constructor
*/
ViewportMap(Shared::TreeItem *parent);
/**
* Destructor
*/
~ViewportMap() override;
/**
* Draws the map
*/
void draw() override;
};
} // End of namespace U1Gfx
} // End of namespace Ultima1
} // End of namespace Ultima
#endif