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

dreammaster paulfgilbert at gmail.com
Wed Jan 2 07:41:52 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:
c02d1f5432 GLK: FROTZ: Beginnings of setting window positions and size


Commit: c02d1f543282a5fe277302700c53e63a1213c319
    https://github.com/scummvm/scummvm/commit/c02d1f543282a5fe277302700c53e63a1213c319
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2019-01-01T22:40:32-08:00

Commit Message:
GLK: FROTZ: Beginnings of setting window positions and size

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


diff --git a/engines/glk/frotz/processor_windows.cpp b/engines/glk/frotz/processor_windows.cpp
index 7b042d9..f0f6ffa 100644
--- a/engines/glk/frotz/processor_windows.cpp
+++ b/engines/glk/frotz/processor_windows.cpp
@@ -178,35 +178,19 @@ void Processor::z_set_margins() {
 }
 
 void Processor::z_move_window(void) {
-#ifdef TODO
 	zword win = winarg0();
 
 	flush_buffer();
 
-	wp[win].y_pos = zargs[1];
-	wp[win].x_pos = zargs[2];
-
-	if (win == cwin)
-		update_cursor();
-#endif
+	_wp[win].setPosition(Point(zargs[2], zargs[1]));
 }
 
 void Processor::z_window_size() {
-#ifdef TODO
 	zword win = winarg0();
 
 	flush_buffer();
 
-	wp[win].y_size = zargs[1];
-	wp[win].x_size = zargs[2];
-
-	/* Keep the cursor within the window */
-
-	if (wp[win].y_cursor > zargs[1] || wp[win].x_cursor > zargs[2])
-		reset_cursor(win);
-
-	os_window_height(win, wp[win].y_size);
-#endif
+	_wp[win].setSize(Point(zargs[2], zargs[1]));
 }
 
 void Processor::z_window_style() {
diff --git a/engines/glk/frotz/windows.cpp b/engines/glk/frotz/windows.cpp
index e30f61e..fdcfcf1 100644
--- a/engines/glk/frotz/windows.cpp
+++ b/engines/glk/frotz/windows.cpp
@@ -21,17 +21,60 @@
  */
 
 #include "glk/frotz/windows.h"
+#include "glk/frotz/frotz.h"
 
 namespace Glk {
 namespace Frotz {
 
 Windows::Windows() : _lower(_windows[0]), _upper(_windows[1]) {
+	for (size_t idx = 0; idx < 8; ++idx)
+		_windows[idx]._windows = this;
+}
+
+size_t Windows::size() const {
+	return (g_vm->h_version < 6) ? 2 : 8;
 }
 
 Window &Windows::operator[](uint idx) {
-	assert(idx < 8);
+	assert(idx < size());
 	return _windows[idx];
 }
 
+/*--------------------------------------------------------------------------*/
+
+winid_t Window::getWindow() {
+	if (!_win) {
+		// Window doesn't exist, so create it
+		// TODO
+	}
+
+	return _win;
+}
+
+void Window::setSize(const Point &newSize) {
+	winid_t win = getWindow();
+
+/* TODO
+	y_size = zargs[1];
+	_wp[win].x_size = zargs[2];
+
+	// Keep the cursor within the window
+	if (wp[win].y_cursor > zargs[1] || wp[win].x_cursor > zargs[2])
+		reset_cursor(win);
+
+	os_window_height(win, _wp[win].y_size);
+	*/
+}
+
+void Window::setPosition(const Point &newPos) {
+	winid_t win = getWindow();
+
+	/* TODO
+	if (win == cwin)
+		update_cursor();
+	*/
+}
+
+
 } // End of namespace Frotz
 } // End of namespace Glk
diff --git a/engines/glk/frotz/windows.h b/engines/glk/frotz/windows.h
index e685c4f..c94a1ed 100644
--- a/engines/glk/frotz/windows.h
+++ b/engines/glk/frotz/windows.h
@@ -29,13 +29,23 @@ namespace Glk {
 namespace Frotz {
 
 #include "glk/windows.h"
+#include "glk/utils.h"
+
+class Windows;
 
 /**
  * Represents one of the virtual windows
  */
 class Window {
+	friend class Windows;
 private:
+	Windows *_windows;
 	winid_t _win;
+private:
+	/**
+	 * Gets a reference to the window, creating a new one if one doesn't already exist
+	 */
+	winid_t getWindow();
 public:
 	/**
 	 * Constructor
@@ -69,10 +79,21 @@ public:
 	 * 4  y cursor        10  text style                  16 true foreground colour
 	 * 5  x cursor        11  colour data                 17 true background colour
 	 */
+	//zword &operator[](uint idx);
+
+	/**
+	 * Set the window size
+	 */
+	void setSize(const Point &newSize);
+
+	/**
+	 * Set the position of a window
+	 */
+	void setPosition(const Point &newPos);
 };
 
 /**
- * The Z-machine has 8 virtual windows
+ * Windows manager
  */
 class Windows {
 private:
@@ -87,6 +108,11 @@ public:
 	Windows();
 
 	/**
+	 * Returns the number of allowable windows
+	 */
+	size_t size() const;
+
+	/**
 	 * Array access
 	 */
 	Window &operator[](uint idx);





More information about the Scummvm-git-logs mailing list