[Scummvm-git-logs] scummvm master -> aab6fa0ec9f606d3e25c47f63b6c9922065b4be0

mduggan mgithub at guarana.org
Mon Apr 27 07:49:00 UTC 2020


This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
4ee413d652 ULTIMA8: Allow font choice in shape viewer
f57d50790c ULTIMA8: Avoid crash in crusader data
aab6fa0ec9 ULTIMA8: Make fonts render in crusader


Commit: 4ee413d652272b5cc5e134cfd9c6d27f19bce130
    https://github.com/scummvm/scummvm/commit/4ee413d652272b5cc5e134cfd9c6d27f19bce130
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2020-04-27T13:30:29+09:00

Commit Message:
ULTIMA8: Allow font choice in shape viewer

Changed paths:
    engines/ultima/ultima8/graphics/fonts/shape_font.cpp
    engines/ultima/ultima8/gumps/shape_viewer_gump.cpp
    engines/ultima/ultima8/gumps/shape_viewer_gump.h


diff --git a/engines/ultima/ultima8/graphics/fonts/shape_font.cpp b/engines/ultima/ultima8/graphics/fonts/shape_font.cpp
index 09f7d43b2b..c619e319e8 100644
--- a/engines/ultima/ultima8/graphics/fonts/shape_font.cpp
+++ b/engines/ultima/ultima8/graphics/fonts/shape_font.cpp
@@ -44,7 +44,11 @@ ShapeFont::~ShapeFont() {
 
 
 int ShapeFont::getWidth(char c) {
-	return getFrame(static_cast<unsigned char>(c))->_width;
+	const ShapeFrame *frame = getFrame(static_cast<unsigned char>(c));
+	if (frame)
+		return frame->_width;
+	else
+		return 0;
 }
 
 int ShapeFont::getHeight() {
diff --git a/engines/ultima/ultima8/gumps/shape_viewer_gump.cpp b/engines/ultima/ultima8/gumps/shape_viewer_gump.cpp
index 97712a68c1..b1160f1a2e 100644
--- a/engines/ultima/ultima8/gumps/shape_viewer_gump.cpp
+++ b/engines/ultima/ultima8/gumps/shape_viewer_gump.cpp
@@ -61,7 +61,8 @@ ShapeViewerGump::ShapeViewerGump(int x, int y, int width, int height,
                                  Std::vector<Std::pair<Std::string, ShapeArchive *> > &flexes,
                                  uint32 flags, int32 layer)
 		: ModalGump(x, y, width, height, 0, flags, layer),
-		_flexes(flexes), _curFlex(0), _curShape(0), _curFrame(0), _background(0) {
+		_flexes(flexes), _curFlex(0), _curShape(0), _curFrame(0),
+		_background(0), _fontNo(0) {
 	if (_flexes.size())
 		_flex = _flexes[0].second;
 	else
@@ -93,7 +94,10 @@ void ShapeViewerGump::PaintThis(RenderSurface *surf, int32 lerp_factor, bool /*s
 		surf->Paint(shape_, _curFrame, posx, posy);
 
 	RenderedText *rendtext;
-	Font *font = FontManager::get_instance()->getGameFont(0, true);
+	Font *font = FontManager::get_instance()->getGameFont(_fontNo, true);
+	if (!font)
+		return;
+
 	unsigned int remaining;
 
 	char buf1[50];
@@ -204,6 +208,14 @@ bool ShapeViewerGump::OnKeyDown(int key, int mod) {
 		_curFrame = 0;
 	}
 	break;
+	case Common::KEYCODE_f: {
+		_fontNo++;
+		if (_fontNo >= GameData::get_instance()->getFonts()->getCount())
+		{
+			_fontNo = 0;
+		}
+	}
+			break;
 	case Common::KEYCODE_ESCAPE: {
 		Close();
 	}
diff --git a/engines/ultima/ultima8/gumps/shape_viewer_gump.h b/engines/ultima/ultima8/gumps/shape_viewer_gump.h
index 877ee0c7b6..6d83213a9b 100644
--- a/engines/ultima/ultima8/gumps/shape_viewer_gump.h
+++ b/engines/ultima/ultima8/gumps/shape_viewer_gump.h
@@ -66,6 +66,9 @@ protected:
 
 	uint32 _background;
 
+	//! The font used in the shape viewer
+	uint32 _fontNo;
+
 	int32 _shapeW, _shapeH, _shapeX, _shapeY;
 };
 


Commit: f57d50790c144640fc3095cadaf9819fa7c6072b
    https://github.com/scummvm/scummvm/commit/f57d50790c144640fc3095cadaf9819fa7c6072b
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2020-04-27T16:41:27+09:00

Commit Message:
ULTIMA8: Avoid crash in crusader data

Changed paths:
    engines/ultima/ultima8/graphics/soft_render_surface.inl


diff --git a/engines/ultima/ultima8/graphics/soft_render_surface.inl b/engines/ultima/ultima8/graphics/soft_render_surface.inl
index fd0ee884f1..d396c5c730 100644
--- a/engines/ultima/ultima8/graphics/soft_render_surface.inl
+++ b/engines/ultima/ultima8/graphics/soft_render_surface.inl
@@ -172,6 +172,8 @@ const int32 neg = (FLIP_CONDITIONAL)?-1:0;
 		return;
 
 	const ShapeFrame *frame			= s->getFrame(framenum);
+	if (!frame)
+		return;
 	const uint8		*srcpixels		= frame->_pixels;
 	const uint8		*srcmask		= frame->_mask;
 	const uint32	*pal			= untformed_pal?


Commit: aab6fa0ec9f606d3e25c47f63b6c9922065b4be0
    https://github.com/scummvm/scummvm/commit/aab6fa0ec9f606d3e25c47f63b6c9922065b4be0
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2020-04-27T16:41:59+09:00

Commit Message:
ULTIMA8: Make fonts render in crusader

Changed paths:
    engines/ultima/ultima8/graphics/fonts/shape_font.cpp
    engines/ultima/ultima8/graphics/fonts/shape_font.h
    engines/ultima/ultima8/graphics/fonts/shape_rendered_text.cpp


diff --git a/engines/ultima/ultima8/graphics/fonts/shape_font.cpp b/engines/ultima/ultima8/graphics/fonts/shape_font.cpp
index c619e319e8..66f3392b01 100644
--- a/engines/ultima/ultima8/graphics/fonts/shape_font.cpp
+++ b/engines/ultima/ultima8/graphics/fonts/shape_font.cpp
@@ -21,6 +21,7 @@
  */
 
 #include "ultima/ultima8/misc/pent_include.h"
+#include "ultima/ultima8/kernel/core_app.h"
 #include "ultima/ultima8/graphics/fonts/shape_font.h"
 #include "ultima/ultima8/graphics/shape.h"
 #include "ultima/ultima8/graphics/shape_frame.h"
@@ -37,6 +38,7 @@ ShapeFont::ShapeFont(const uint8 *data_, uint32 size_,
                      const uint16 flexId_, const uint32 shapeNum_)
 	: Font(), Shape(data_, size_, format, flexId_, shapeNum_),
 	  _height(0), _baseLine(0), _vLead(-1), _hLead(0) {
+	_crusaderCharMap = GAME_IS_CRUSADER;
 }
 
 ShapeFont::~ShapeFont() {
@@ -44,17 +46,20 @@ ShapeFont::~ShapeFont() {
 
 
 int ShapeFont::getWidth(char c) {
-	const ShapeFrame *frame = getFrame(static_cast<unsigned char>(c));
+	const ShapeFrame *frame = getFrame(charToFrameNum(c));
 	if (frame)
 		return frame->_width;
 	else
-		return 0;
+		return 7; // small space..
 }
 
 int ShapeFont::getHeight() {
 	if (_height == 0) {
 		for (uint32 i = 0; i < frameCount(); i++) {
-			int h = getFrame(i)->_height;
+			const ShapeFrame *frame = getFrame(i);
+			if (!frame)
+				continue;
+			int h = frame->_height;
 
 			if (h > _height) _height = h;
 		}
@@ -92,6 +97,32 @@ void ShapeFont::getStringSize(const Std::string &text, int32 &width, int32 &heig
 	}
 }
 
+int ShapeFont::charToFrameNum(char c) const {
+	if (_crusaderCharMap) {
+		if (c < 41)
+			// ( and ) are combined into a single shape
+			return c;
+		// weirdly X and Y are swapped in both upper and lowercase
+		else if (c == 'X')
+			return 'X';
+		else if (c == 'Y')
+			return 'W';
+		else if (c < 96)
+			return c - 1;
+		else if (c == 96)
+			// no backquote char
+			return charToFrameNum('\'');
+		else if (c == 'x')
+			return 'w';
+		else if (c == 'y')
+			return 'v';
+		else
+			return c - 2;
+	} else {
+		return c;
+	}
+}
+
 RenderedText *ShapeFont::renderText(const Std::string &text,
                                     unsigned int &remaining,
                                     int32 width, int32 height_, TextAlign align,
diff --git a/engines/ultima/ultima8/graphics/fonts/shape_font.h b/engines/ultima/ultima8/graphics/fonts/shape_font.h
index 417cce07f5..a72583460f 100644
--- a/engines/ultima/ultima8/graphics/fonts/shape_font.h
+++ b/engines/ultima/ultima8/graphics/fonts/shape_font.h
@@ -35,6 +35,7 @@ class ShapeFont : public Font, public Shape {
 	int _baseLine;
 	int _vLead;
 	int _hLead;
+	bool _crusaderCharMap;
 
 public:
 	ShapeFont(const uint8 *data, uint32 size, const ConvertShapeFormat *format,
@@ -60,6 +61,8 @@ public:
 		_hLead = hl;
 	}
 
+	int charToFrameNum(char c) const;
+
 	void getStringSize(const Std::string &text,
 		int32 &width, int32 &height) override;
 
diff --git a/engines/ultima/ultima8/graphics/fonts/shape_rendered_text.cpp b/engines/ultima/ultima8/graphics/fonts/shape_rendered_text.cpp
index ffa9ad3430..18f5377590 100644
--- a/engines/ultima/ultima8/graphics/fonts/shape_rendered_text.cpp
+++ b/engines/ultima/ultima8/graphics/fonts/shape_rendered_text.cpp
@@ -56,7 +56,7 @@ void ShapeRenderedText::draw(RenderSurface *surface, int x, int y, bool /*destma
 		size_t textsize = iter->_text.size();
 
 		for (size_t i = 0; i < textsize; ++i) {
-			surface->Paint(_font, static_cast<unsigned char>(iter->_text[i]),
+			surface->Paint(_font, _font->charToFrameNum(iter->_text[i]),
 			               line_x, line_y);
 
 			if (i == iter->_cursor) {




More information about the Scummvm-git-logs mailing list