[Scummvm-git-logs] scummvm master -> 1c5a8930b3ca16c1a1ce05500f9d52741de28a48

dreammaster paulfgilbert at gmail.com
Thu Mar 7 05:48:57 CET 2019


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

Summary:
1c5a8930b3 GLK: FROTZ: Create Glk windows on the fly as needed


Commit: 1c5a8930b3ca16c1a1ce05500f9d52741de28a48
    https://github.com/scummvm/scummvm/commit/1c5a8930b3ca16c1a1ce05500f9d52741de28a48
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2019-03-06T20:17:35-08:00

Commit Message:
GLK: FROTZ: Create Glk windows on the fly as needed

This is laying groundwork for properly supporting Shogun, which
sets up and uses Window 7

Changed paths:
    engines/glk/frotz/glk_interface.cpp
    engines/glk/frotz/processor_screen.cpp
    engines/glk/frotz/processor_windows.cpp
    engines/glk/frotz/windows.cpp
    engines/glk/frotz/windows.h


diff --git a/engines/glk/frotz/glk_interface.cpp b/engines/glk/frotz/glk_interface.cpp
index 69b1dc5..4d60fe7 100644
--- a/engines/glk/frotz/glk_interface.cpp
+++ b/engines/glk/frotz/glk_interface.cpp
@@ -542,6 +542,7 @@ void GlkInterface::showBeyondZorkTitle() {
 }
 
 void GlkInterface::os_draw_picture(int picture, const Common::Point &pos) {
+	assert(pos.x != 0 && pos.y != 0);
 	if (_wp._cwin == 0) {
 		// Picture embedded within the lower text area
 		glk_image_draw(_wp._lower, picture, imagealign_MarginLeft, 0);
diff --git a/engines/glk/frotz/processor_screen.cpp b/engines/glk/frotz/processor_screen.cpp
index 992df74..a3134d3 100644
--- a/engines/glk/frotz/processor_screen.cpp
+++ b/engines/glk/frotz/processor_screen.cpp
@@ -359,7 +359,7 @@ void Processor::z_set_colour() {
 	_wp[win][TRUE_BG_COLOR] = bg;
 
 	if (win == _wp._cwin || h_version != V6)
-		garglk_set_zcolors(fg, bg);
+		_wp.currWin().updateColors(fg, bg);
 }
 
 void Processor::z_set_font() {
@@ -440,35 +440,7 @@ void Processor::z_set_text_style() {
 	if (gos_linepending && _wp.currWin() == gos_linewin)
 		return;
 
-	if (style & REVERSE_STYLE) {
-		os_set_reverse_video(true);
-	}
-
-	if (style & FIXED_WIDTH_STYLE) {
-		if (curr_font == GRAPHICS_FONT)
-			glk_set_style(style_User1);			// character graphics
-		else if (style & BOLDFACE_STYLE && style & EMPHASIS_STYLE)
-			glk_set_style(style_BlockQuote);	// monoz
-		else if (style & EMPHASIS_STYLE)
-			glk_set_style(style_Alert);			// monoi
-		else if (style & BOLDFACE_STYLE)
-			glk_set_style(style_Subheader);		// monob
-		else
-			glk_set_style(style_Preformatted);	// monor
-	} else {
-		if (style & BOLDFACE_STYLE && style & EMPHASIS_STYLE)
-			glk_set_style(style_Note);			// propz
-		else if (style & EMPHASIS_STYLE)
-			glk_set_style(style_Emphasized);	// propi
-		else if (style & BOLDFACE_STYLE)
-			glk_set_style(style_Header);		// propb
-		else
-			glk_set_style(style_Normal);		// propr
-	}
-
-	if (curstyle == 0) {
-		os_set_reverse_video(false);
-	}
+	_wp[_wp._cwin].setStyle(style);
 }
 
 void Processor::z_set_window() {
diff --git a/engines/glk/frotz/processor_windows.cpp b/engines/glk/frotz/processor_windows.cpp
index a9591c3..2ebc960 100644
--- a/engines/glk/frotz/processor_windows.cpp
+++ b/engines/glk/frotz/processor_windows.cpp
@@ -59,8 +59,8 @@ void Processor::z_draw_picture() {
 			y = win[Y_CURSOR];
 	}
 
-	y += win[Y_POS] - 1;
 	x += win[X_POS] - 1;
+	y += win[Y_POS] - 1;
 
 	/* The following is necessary to make Amiga and Macintosh story
 	 * files work with MCGA graphics files.  Some screen-filling
diff --git a/engines/glk/frotz/windows.cpp b/engines/glk/frotz/windows.cpp
index 38e5dd9..0fe836a 100644
--- a/engines/glk/frotz/windows.cpp
+++ b/engines/glk/frotz/windows.cpp
@@ -30,8 +30,10 @@ namespace Glk {
 namespace Frotz {
 
 Windows::Windows() : _lower(_windows[0]), _upper(_windows[1]), _background(nullptr), _cwin(0) {
-	for (size_t idx = 0; idx < 8; ++idx)
+	for (size_t idx = 0; idx < 8; ++idx) {
 		_windows[idx]._windows = this;
+		_windows[idx]._index = idx;
+	}
 }
 
 size_t Windows::size() const {
@@ -49,7 +51,7 @@ void Windows::setup(bool isVersion6) {
 		// flexibility of wher we draw pictures, and the lower and upper areas sit on top of them
 		_background = g_vm->glk_window_open(0, 0, 0, wintype_Graphics, 0);
 		_background->setBackgroundColor(0xffffff);
-
+		/*
 		MonoFontInfo &fi = g_vm->_conf->_monoInfo;
 		_lower = g_vm->glk_window_open(g_vm->glk_window_get_root(),
 			winmethod_Arbitrary | winmethod_Fixed, 0, wintype_TextBuffer, 0);
@@ -59,15 +61,16 @@ void Windows::setup(bool isVersion6) {
 		_upper.setSize(Point(g_system->getWidth() / fi._cellW, 1));
 		_lower.setPosition(Point(1, 2));
 		_lower.setSize(Point(g_system->getWidth() / fi._cellW, g_system->getHeight() / fi._cellH - 1));
+		*/
 
 	} else {
 		_lower = g_vm->glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
 		_upper = g_vm->glk_window_open(_lower, winmethod_Above | winmethod_Fixed, 0, wintype_TextGrid, 0);
-	}
 
-	_lower.update();
-	_upper.update();
-	g_vm->glk_set_window(_lower);
+		_lower.update();
+		_upper.update();
+		g_vm->glk_set_window(_lower);
+	}
 }
 
 void Windows::setWindow(int win) {
@@ -176,6 +179,62 @@ void Window::updateColors(uint fore, uint back) {
 	updateColors();
 }
 
+void Window::setStyle(uint style) {
+	/*
+	if (style & REVERSE_STYLE) {
+		os_set_reverse_video(true);
+	}*/
+
+	if (!_win)
+		createGlkWindow();
+
+	if (style & FIXED_WIDTH_STYLE) {
+		if (g_vm->curr_font == GRAPHICS_FONT)
+			_win->_stream->setStyle(style_User1);			// character graphics
+		else if (style & BOLDFACE_STYLE && style & EMPHASIS_STYLE)
+			_win->_stream->setStyle(style_BlockQuote);	// monoz
+		else if (style & EMPHASIS_STYLE)
+			_win->_stream->setStyle(style_Alert);			// monoi
+		else if (style & BOLDFACE_STYLE)
+			_win->_stream->setStyle(style_Subheader);		// monob
+		else
+			_win->_stream->setStyle(style_Preformatted);	// monor
+	} else {
+		if (style & BOLDFACE_STYLE && style & EMPHASIS_STYLE)
+			_win->_stream->setStyle(style_Note);			// propz
+		else if (style & EMPHASIS_STYLE)
+			_win->_stream->setStyle(style_Emphasized);	// propi
+		else if (style & BOLDFACE_STYLE)
+			_win->_stream->setStyle(style_Header);		// propb
+		else
+			_win->_stream->setStyle(style_Normal);		// propr
+	}
+
+	/*
+	if (curstyle == 0) {
+		os_set_reverse_video(false);
+	}
+	*/
+}
+
+void Window::createGlkWindow() {
+	// Create a new window	
+	if (_index == 1) {
+		// Text grid window
+		_win = g_vm->glk_window_open(g_vm->glk_window_get_root(),
+			winmethod_Arbitrary | winmethod_Fixed, 0, wintype_TextGrid, 0);
+	} else {
+		// text buffer window
+		_win = g_vm->glk_window_open(g_vm->glk_window_get_root(),
+			winmethod_Arbitrary | winmethod_Fixed, 0, wintype_TextBuffer, 0);
+	}
+
+	setSize(Point(_properties[X_SIZE], _properties[Y_SIZE]));
+	setPosition(Point(_properties[X_POS], _properties[Y_POS]));
+
+	g_vm->glk_set_window(_win);
+}
+
 const uint &Window::getProperty(WindowProperty propType) {
 	if (_win)
 		update();
diff --git a/engines/glk/frotz/windows.h b/engines/glk/frotz/windows.h
index 9d9af2a..0f2bdff 100644
--- a/engines/glk/frotz/windows.h
+++ b/engines/glk/frotz/windows.h
@@ -77,6 +77,7 @@ class Window {
 	};
 private:
 	Windows *_windows;
+	int _index;
 	winid_t _win;
 	uint _properties[TRUE_BG_COLOR + 1];
 private:
@@ -99,6 +100,11 @@ private:
 	 * Updates the local window properties based on an attached Glk window
 	 */
 	void update();
+
+	/**
+	 * Creates a new Glk window to attach to the window
+	 */
+	void createGlkWindow();
 public:
 	/**
 	 * Constructor
@@ -162,6 +168,11 @@ public:
 	 * Update colors for the window
 	 */
 	void updateColors(uint fore, uint back);
+
+	/**
+	 * Set the textstyle
+	 */
+	void setStyle(uint style);
 };
 
 /**





More information about the Scummvm-git-logs mailing list