diff options
author | Eugene Sandulenko | 2015-12-26 13:12:30 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2015-12-27 15:41:03 +0100 |
commit | 91d5b8b17e7a600ab4e2d8def5a2d24b14cb1d57 (patch) | |
tree | 05e42ef0bdce22a3225f1c20203187ce62ddc6e2 | |
parent | ab34bafc31475d79ff74887f38631c993e4db9b2 (diff) | |
download | scummvm-rg350-91d5b8b17e7a600ab4e2d8def5a2d24b14cb1d57.tar.gz scummvm-rg350-91d5b8b17e7a600ab4e2d8def5a2d24b14cb1d57.tar.bz2 scummvm-rg350-91d5b8b17e7a600ab4e2d8def5a2d24b14cb1d57.zip |
WAGE: Started border drawing implementation
-rw-r--r-- | engines/wage/design.h | 6 | ||||
-rw-r--r-- | engines/wage/gui.cpp | 141 | ||||
-rw-r--r-- | engines/wage/gui.h | 70 | ||||
-rw-r--r-- | engines/wage/module.mk | 3 | ||||
-rw-r--r-- | engines/wage/wage.cpp | 9 | ||||
-rw-r--r-- | engines/wage/wage.h | 8 |
6 files changed, 229 insertions, 8 deletions
diff --git a/engines/wage/design.h b/engines/wage/design.h index f5f707ef7f..97ee92f8db 100644 --- a/engines/wage/design.h +++ b/engines/wage/design.h @@ -54,12 +54,6 @@ namespace Wage { -enum { - kColorBlack = 0, - kColorGray = 1, - kColorWhite = 2 -}; - class Design { public: Design(Common::SeekableReadStream *data); diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp new file mode 100644 index 0000000000..420a584e53 --- /dev/null +++ b/engines/wage/gui.cpp @@ -0,0 +1,141 @@ +/* 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. + * + * MIT License: + * + * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + */ + +#include "wage/wage.h" +#include "wage/gui.h" + +namespace Wage { + +Gui::Gui() { +} + +Gui::~Gui() { +} + +void Gui::drawBox(Graphics::Surface *g, int x, int y, int w, int h) { + Common::Rect r(x, y, x + w, y + h); + + g->frameRect(r, kColorBlack); +} + +void Gui::paintBorder(Graphics::Surface *g, int x, int y, int width, int height) { + int size = 17; + drawBox(g, x, y, size, size); + drawBox(g, x+width-size-1, y, size, size); + drawBox(g, x+width-size-1, y+height-size-1, size, size); + drawBox(g, x, y+height-size-1, size, size); + drawBox(g, x + size, y + 2, width - 2*size - 1, size - 4); + drawBox(g, x + size, y + height - size + 1, width - 2*size - 1, size - 4); + drawBox(g, x + 2, y + size, size - 4, height - 2*size - 1); + drawBox(g, x + width - size + 1, y + size, size - 4, height - 2*size-1); + +#if 0 + if (active) { + g.setColor(Color.BLACK); + g.fillRect(x + size, y + 5, width - 2*size - 1, 8); + g.fillRect(x + size, y + height - 13, width - 2*size - 1, 8); + g.fillRect(x + 5, y + size, 8, height - 2*size - 1); + if (!scrollable) { + g.fillRect(x + width - 13, y + size, 8, height - 2*size - 1); + } else { + int pixels[][] = new int[][] { + {0,0,0,0,0,1,1,0,0,0,0,0}, + {0,0,0,0,1,1,1,1,0,0,0,0}, + {0,0,0,1,1,1,1,1,1,0,0,0}, + {0,0,1,1,1,1,1,1,1,1,0,0}, + {0,1,1,1,1,1,1,1,1,1,1,0}, + {1,1,1,1,1,1,1,1,1,1,1,1}}; + final int h = pixels.length; + final int w = pixels[0].length; + int x1 = x + width - 15; + int y1 = y + size + 1; + for (int yy = 0; yy < h; yy++) { + for (int xx = 0; xx < w; xx++) { + if (pixels[yy][xx] != 0) { + g.drawRect(x1+xx, y1+yy, 0, 0); + } + } + } + g.fillRect(x + width - 13, y + size + h, 8, height - 2*size - 1 - h*2); + y1 += height - 2*size - h - 2; + for (int yy = 0; yy < h; yy++) { + for (int xx = 0; xx < w; xx++) { + if (pixels[h-yy-1][xx] != 0) { + g.drawRect(x1+xx, y1+yy, 0, 0); + } + } + } + } + if (closeable) { + if (closeBoxPressed) { + g.fillRect(x + 6, y + 6, 6, 6); + } else { + drawBox(g, x + 5, y + 5, 7, 7); + } + } + } + + if (title != null) { + // TODO: This "Chicago" is not faithful to the original one on the Mac. + Font f = new Font("Chicago", Font.BOLD, 12); + int w = g.getFontMetrics(f).stringWidth(title) + 6; + int maxWidth = width - size*2 - 7; + if (w > maxWidth) { + w = maxWidth; + } + drawBox(g, x + (width - w) / 2, y, w, size); + g.setFont(f); + Shape clip = g.getClip(); + g.setClip(x + (width - w) / 2, y, w, size); + g.drawString(title, x + (width - w) / 2 + 3, y + size - 4); + g.setClip(clip); + } +#endif +} + + +} // End of namespace Wage diff --git a/engines/wage/gui.h b/engines/wage/gui.h new file mode 100644 index 0000000000..0e5be4fb8f --- /dev/null +++ b/engines/wage/gui.h @@ -0,0 +1,70 @@ +/* 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. + * + * MIT License: + * + * Copyright (c) 2009 Alexei Svitkine, Eugene Sandulenko + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + */ + +#ifndef WAGE_GUI_H +#define WAGE_GUI_H + +#include "graphics/surface.h" +#include "common/rect.h" + +namespace Wage { + +class Gui { +public: + Gui(); + ~Gui(); + + void paintBorder(Graphics::Surface *g, int x, int y, int width, int height); + +private: + void drawBox(Graphics::Surface *g, int x, int y, int w, int h); + +}; + +} // End of namespace Wage + +#endif diff --git a/engines/wage/module.mk b/engines/wage/module.mk index 19d56cfc67..5356902474 100644 --- a/engines/wage/module.mk +++ b/engines/wage/module.mk @@ -4,6 +4,7 @@ MODULE_OBJS := \ design.o \ detection.o \ entities.o \ + gui.o \ script.o \ util.o \ wage.o \ @@ -17,5 +18,5 @@ ifeq ($(ENABLE_WAGE), DYNAMIC_PLUGIN) PLUGIN := 1 endif -# Include common rules +# Include common rules include $(srcdir)/rules.mk diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp index 99d8205913..acff92f38b 100644 --- a/engines/wage/wage.cpp +++ b/engines/wage/wage.cpp @@ -61,6 +61,7 @@ #include "wage/wage.h" #include "wage/design.h" #include "wage/entities.h" +#include "wage/gui.h" #include "wage/script.h" #include "wage/world.h" @@ -101,6 +102,8 @@ Common::Error WageEngine::run() { debug("WageEngine::init"); + _gui = new Gui(); + // Your main event loop should be (invoked from) here. _resManager = new Common::MacResManager(); _resManager->open(getGameFile()); @@ -122,7 +125,11 @@ Common::Error WageEngine::run() { _world->_player->_currentScene = _world->_orderedScenes[1]; //_world->_globalScript->execute(_world, 1, &input, NULL, this); - _world->_orderedScenes[4]->paint(&screen); + Scene *scene = _world->_orderedScenes[1]; + + scene->paint(&screen); + _gui->paintBorder(&screen, 0, 0, scene->_design->getBounds()->width(), scene->_design->getBounds()->height()); + g_system->copyRectToScreen(screen.getPixels(), screen.pitch, 0, 0, screen.w, screen.h); while (true) { diff --git a/engines/wage/wage.h b/engines/wage/wage.h index 4d75acef96..614b5a12d5 100644 --- a/engines/wage/wage.h +++ b/engines/wage/wage.h @@ -63,6 +63,7 @@ namespace Wage { class Console; class Chr; class Designed; +class Gui; class Obj; class Scene; class World; @@ -88,6 +89,12 @@ enum { // the current limitation is 32 debug levels (1 << 31 is the last one) }; +enum { + kColorBlack = 0, + kColorGray = 1, + kColorWhite = 2 +}; + Common::String readPascalString(Common::SeekableReadStream *in); Common::Rect *readRect(Common::SeekableReadStream *in); @@ -115,6 +122,7 @@ private: public: Common::RandomSource *_rnd; + Gui *_gui; World *_world; Scene *_lastScene; |