[Scummvm-git-logs] scummvm master -> 6329f73c9ee3b30e04da89b7ac0b98c581e72c0c
sev-
sev at scummvm.org
Wed Dec 14 20:10:42 CET 2016
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:
34a9c588b0 GRAPHICS: Added stub for MacText class
aecc17e5a5 GRAPHICS: Further work on MacText class
6329f73c9e GRAPHICS: Implemented basic rendering for MacText
Commit: 34a9c588b001e137243f12ae8de3bc82d692de27
https://github.com/scummvm/scummvm/commit/34a9c588b001e137243f12ae8de3bc82d692de27
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-12-14T20:10:32+01:00
Commit Message:
GRAPHICS: Added stub for MacText class
Changed paths:
A graphics/macgui/mactext.cpp
A graphics/macgui/mactext.h
graphics/module.mk
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
new file mode 100644
index 0000000..20b2ef6
--- /dev/null
+++ b/graphics/macgui/mactext.cpp
@@ -0,0 +1,32 @@
+/* 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "graphics/macgui/mactext.h"
+
+namespace Graphics {
+
+MacText::MacText(Common::String s, Graphics::Font *font, int maxWidth) {
+ _str = s;
+ _font = font;
+ _maxWidth = maxWidth;
+}
+
+} // End of namespace Graphics
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
new file mode 100644
index 0000000..694e14e
--- /dev/null
+++ b/graphics/macgui/mactext.h
@@ -0,0 +1,42 @@
+/* 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef GRAPHICS_MACGUI_MACTEXT_H
+#define GRAPHICS_MACGUI_MACTEXT_H
+
+#include "graphics/fontman.h"
+
+namespace Graphics {
+
+class MacText {
+public:
+ MacText(Common::String s, Graphics::Font *font, int maxWidth = -1);
+
+private:
+ Common::String _str;
+ Graphics::Font *_font;
+ int _maxWidth;
+};
+
+} // End of namespace Graphics
+
+#endif
diff --git a/graphics/module.mk b/graphics/module.mk
index b6e704b..51e2ef7 100644
--- a/graphics/module.mk
+++ b/graphics/module.mk
@@ -14,6 +14,7 @@ MODULE_OBJS := \
maccursor.o \
macgui/macfontmanager.o \
macgui/macmenu.o \
+ macgui/mactext.o \
macgui/macwindow.o \
macgui/macwindowborder.o \
macgui/macwindowmanager.o \
Commit: aecc17e5a5726206c39f7f2a773788f64c103b1e
https://github.com/scummvm/scummvm/commit/aecc17e5a5726206c39f7f2a773788f64c103b1e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-12-14T20:10:32+01:00
Commit Message:
GRAPHICS: Further work on MacText class
Changed paths:
graphics/macgui/mactext.cpp
graphics/macgui/mactext.h
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 20b2ef6..7e937de 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -20,6 +20,7 @@
*/
#include "graphics/macgui/mactext.h"
+#include "graphics/font.h"
namespace Graphics {
@@ -27,6 +28,54 @@ MacText::MacText(Common::String s, Graphics::Font *font, int maxWidth) {
_str = s;
_font = font;
_maxWidth = maxWidth;
+ _interLinear = 2; // 2 pixels by default
+
+ _textMaxWidth = -1;
+
+ splitString();
+}
+
+void MacText::splitString() {
+ const char *s = _str.c_str();
+
+ Common::String tmp;
+ bool prevCR;
+
+ while (*s) {
+ if (*s == '\n' && prevCR) { // trean \r\n as one
+ prevCR = false;
+ continue;
+ }
+
+ if (*s == '\r')
+ prevCR = true;
+
+ if (*s == '\r' || *s == '\n') {
+ _text.push_back(tmp);
+ _widths.push_back(_font->getStringWidth(tmp));
+
+ tmp.clear();
+
+ continue;
+ }
+
+ tmp += *s;
+ }
+
+ calcMaxWidth();
+}
+
+void MacText::calcMaxWidth() {
+ int max = -1;
+
+ for (uint i = 0; i < _widths.size(); i++)
+ if (max < _widths[i])
+ max = _widths[i];
+
+ _textMaxWidth = max;
+}
+
+void MacText::render() {
}
} // End of namespace Graphics
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index 694e14e..6f49133d 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -31,10 +31,23 @@ class MacText {
public:
MacText(Common::String s, Graphics::Font *font, int maxWidth = -1);
+ void setInterLinear(int interLinear) { _interLinear = interLinear; }
+
+private:
+ void splitString();
+ void render();
+ void calcMaxWidth();
+
private:
Common::String _str;
Graphics::Font *_font;
int _maxWidth;
+ int _interLinear;
+
+ Common::Array<Common::String> _text;
+ Common::Array<int> _widths;
+
+ int _textMaxWidth;
};
} // End of namespace Graphics
Commit: 6329f73c9ee3b30e04da89b7ac0b98c581e72c0c
https://github.com/scummvm/scummvm/commit/6329f73c9ee3b30e04da89b7ac0b98c581e72c0c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-12-14T20:10:32+01:00
Commit Message:
GRAPHICS: Implemented basic rendering for MacText
Changed paths:
graphics/macgui/mactext.cpp
graphics/macgui/mactext.h
diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 7e937de..f7b2ed9 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -24,15 +24,20 @@
namespace Graphics {
-MacText::MacText(Common::String s, Graphics::Font *font, int maxWidth) {
+MacText::MacText(Common::String s, Graphics::Font *font, int fgcolor, int bgcolor, int maxWidth) {
_str = s;
_font = font;
+ _fgcolor = fgcolor;
+ _bgcolor = bgcolor;
_maxWidth = maxWidth;
- _interLinear = 2; // 2 pixels by default
+
+ _interLinear = 0; // 0 pixels between the lines by default
_textMaxWidth = -1;
splitString();
+
+ _fullRefresh = true;
}
void MacText::splitString() {
@@ -62,6 +67,9 @@ void MacText::splitString() {
tmp += *s;
}
+ if (_text.size())
+ _text.push_back(tmp);
+
calcMaxWidth();
}
@@ -76,6 +84,21 @@ void MacText::calcMaxWidth() {
}
void MacText::render() {
+ if (_fullRefresh) {
+ _surface.create(_textMaxWidth, _text.size() * (_font->getFontHeight() + _interLinear));
+
+ _surface.clear(_bgcolor);
+
+ int y = 0;
+
+ for (uint i = 0; i < _text.size(); i++) {
+ _font->drawString(&_surface, _text[i], 0, y, _textMaxWidth, _fgcolor);
+
+ y += _font->getFontHeight() + _interLinear;
+ }
+
+ _fullRefresh = false;
+ }
}
} // End of namespace Graphics
diff --git a/graphics/macgui/mactext.h b/graphics/macgui/mactext.h
index 6f49133d..cf97584 100644
--- a/graphics/macgui/mactext.h
+++ b/graphics/macgui/mactext.h
@@ -24,12 +24,13 @@
#define GRAPHICS_MACGUI_MACTEXT_H
#include "graphics/fontman.h"
+#include "graphics/managed_surface.h"
namespace Graphics {
class MacText {
public:
- MacText(Common::String s, Graphics::Font *font, int maxWidth = -1);
+ MacText(Common::String s, Graphics::Font *font, int fgcolor, int bgcolor, int maxWidth = -1);
void setInterLinear(int interLinear) { _interLinear = interLinear; }
@@ -41,6 +42,8 @@ private:
private:
Common::String _str;
Graphics::Font *_font;
+ int _fgcolor, _bgcolor;
+
int _maxWidth;
int _interLinear;
@@ -48,6 +51,9 @@ private:
Common::Array<int> _widths;
int _textMaxWidth;
+
+ Graphics::ManagedSurface _surface;
+ bool _fullRefresh;
};
} // End of namespace Graphics
More information about the Scummvm-git-logs
mailing list