mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-10 20:01:25 +00:00
ULTIMA1: Set up custom U1 Sprites class that can receive frame messages
This commit is contained in:
parent
c50c5bdbcb
commit
9c1c80d1f9
@ -32,7 +32,7 @@ MODULE_OBJS += \
|
||||
shared/gfx/font.o \
|
||||
shared/gfx/info.o \
|
||||
shared/gfx/screen.o \
|
||||
shared/gfx/sprite.o \
|
||||
shared/gfx/sprites.o \
|
||||
shared/gfx/viewport_dungeon.o \
|
||||
shared/gfx/viewport_map.o \
|
||||
shared/gfx/visual_container.o \
|
||||
@ -54,6 +54,7 @@ MODULE_OBJS += \
|
||||
ultima1/core/transports.o \
|
||||
ultima1/gfx/drawing_support.o \
|
||||
ultima1/gfx/game_view.o \
|
||||
ultima1/gfx/sprites.o \
|
||||
ultima1/gfx/status.o \
|
||||
ultima1/gfx/viewport_map.o \
|
||||
ultima1/game.o
|
||||
|
@ -55,18 +55,13 @@ int GameBase::getSavegameSlot() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GameBase::draw() {
|
||||
if (_currentView)
|
||||
_currentView->draw();
|
||||
}
|
||||
|
||||
void GameBase::mouseChanged() {
|
||||
|
||||
}
|
||||
|
||||
void GameBase::onIdle() {
|
||||
// Handle any drawing updates
|
||||
draw();
|
||||
update();
|
||||
}
|
||||
|
||||
#define HANDLE_MESSAGE(METHOD) \
|
||||
|
@ -105,12 +105,7 @@ public:
|
||||
virtual void starting();
|
||||
|
||||
/**
|
||||
* Main draw method for the game
|
||||
*/
|
||||
void draw();
|
||||
|
||||
/**
|
||||
* Called once every frame to update the game
|
||||
* Called once every frame to update the game and render the view
|
||||
*/
|
||||
void update();
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/shared/gfx/sprite.h"
|
||||
#include "ultima/shared/gfx/sprites.h"
|
||||
#include "ultima/shared/core/file.h"
|
||||
|
||||
namespace Ultima {
|
||||
@ -42,7 +42,7 @@ Sprite::Sprite(const byte *src, uint bpp, uint16 w, uint16 h) {
|
||||
|
||||
for (int y = 0; y < h; ++y) {
|
||||
byte *destP = (byte *)_surface.getBasePtr(0, y);
|
||||
|
||||
|
||||
for (int x = 0; x < w; ++x, v <<= bpp) {
|
||||
if ((x % (8 / bpp)) == 0)
|
||||
v = *src++;
|
@ -20,8 +20,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_SPRITE_H
|
||||
#define ULTIMA_SPRITE_H
|
||||
#ifndef ULTIMA_SPRITES_H
|
||||
#define ULTIMA_SPRITES_H
|
||||
|
||||
#include "common/array.h"
|
||||
#include "graphics/managed_surface.h"
|
||||
@ -61,18 +61,14 @@ public:
|
||||
void draw(Graphics::ManagedSurface &dest, const Common::Point &pt);
|
||||
|
||||
/**
|
||||
* Return the width of the sprite
|
||||
* Return the width of the sprite
|
||||
*/
|
||||
uint16 w() const {
|
||||
return _surface.w;
|
||||
}
|
||||
uint16 w() const { return _surface.w; }
|
||||
|
||||
/**
|
||||
* Return the height of the sprite
|
||||
*/
|
||||
uint16 h() const {
|
||||
return _surface.h;
|
||||
}
|
||||
uint16 h() const { return _surface.h; }
|
||||
};
|
||||
|
||||
class Sprites : public Common::Array<Sprite> {
|
@ -34,7 +34,7 @@ void ViewportMap::draw() {
|
||||
s.clear();
|
||||
|
||||
// Figure out how many tiles can fit into the display
|
||||
const Point spriteSize = _sprites.getSpriteSize();
|
||||
const Point spriteSize = _sprites->getSpriteSize();
|
||||
const Point visibleTiles(_bounds.width() / spriteSize.x, _bounds.height() / spriteSize.y);
|
||||
|
||||
// Get a reference to the map and get the starting tile position
|
||||
@ -49,11 +49,11 @@ void ViewportMap::draw() {
|
||||
|
||||
// Get the next tile to display and draw it
|
||||
map->getTileAt(Point(topLeft.x + x, topLeft.y + y), &tile);
|
||||
_sprites[tile._tileNum].draw(s, drawPos);
|
||||
(*_sprites)[tile._tileNum].draw(s, drawPos);
|
||||
|
||||
// Draw any widget on the tile
|
||||
if (tile._widget)
|
||||
_sprites[tile._widget->getTileNum()].draw(s, drawPos);
|
||||
(*_sprites)[tile._widget->getTileNum()].draw(s, drawPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
#define ULTIMA_SHARED_GFX_VIEWPORT_MAP_H
|
||||
|
||||
#include "ultima/shared/gfx/visual_item.h"
|
||||
#include "ultima/shared/gfx/sprite.h"
|
||||
#include "ultima/shared/gfx/sprites.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Shared {
|
||||
@ -32,14 +32,14 @@ namespace Shared {
|
||||
class ViewportMap : public Gfx::VisualItem {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
protected:
|
||||
Gfx::Sprites _sprites;
|
||||
Gfx::Sprites *_sprites;
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
ViewportMap(TreeItem *parent) : Gfx::VisualItem("ViewportMap", Rect(8, 8, 312, 152), parent) {}
|
||||
ViewportMap(TreeItem *parent) : Gfx::VisualItem("ViewportMap", Rect(8, 8, 312, 152), parent), _sprites(nullptr) {}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
|
39
engines/ultima/ultima1/gfx/sprites.cpp
Normal file
39
engines/ultima/ultima1/gfx/sprites.cpp
Normal file
@ -0,0 +1,39 @@
|
||||
/* 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 "ultima/ultima1/gfx/sprites.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Gfx {
|
||||
|
||||
BEGIN_MESSAGE_MAP(Sprites, TreeItem)
|
||||
ON_MESSAGE(FrameMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
bool Sprites::FrameMsg(CFrameMsg &msg) {
|
||||
return false;
|
||||
}
|
||||
|
||||
} // End of namespace U1Gfx
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
54
engines/ultima/ultima1/gfx/sprites.h
Normal file
54
engines/ultima/ultima1/gfx/sprites.h
Normal file
@ -0,0 +1,54 @@
|
||||
/* 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 ULTIMA_ULTIMA1_GFX_SPRITES_H
|
||||
#define ULTIMA_ULTIMA1_GFX_SPRITES_H
|
||||
|
||||
#include "ultima/shared/gfx/sprites.h"
|
||||
#include "ultima/shared/core/tree_item.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Gfx {
|
||||
|
||||
using Shared::CFrameMsg;
|
||||
|
||||
/**
|
||||
* Displays the total hits, food, experience, and coins you have
|
||||
*/
|
||||
class Sprites : public ::Ultima::Shared::Gfx::Sprites, public Shared::TreeItem {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool FrameMsg(CFrameMsg &msg);
|
||||
public:
|
||||
CLASSDEF;
|
||||
Sprites(TreeItem *parent) : ::Ultima::Shared::Gfx::Sprites(), TreeItem() {
|
||||
addUnder(parent);
|
||||
}
|
||||
virtual ~Sprites() {}
|
||||
};
|
||||
|
||||
} // End of namespace U1Gfx
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Xeen
|
||||
|
||||
#endif
|
@ -21,25 +21,30 @@
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/gfx/viewport_map.h"
|
||||
#include "ultima/ultima1/gfx/sprites.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Gfx {
|
||||
|
||||
ViewportMap::ViewportMap(TreeItem *parent) : Shared::ViewportMap(parent), _mapType(MAP_OVERWORLD) {
|
||||
_sprites = new Sprites(this);
|
||||
}
|
||||
|
||||
ViewportMap::~ViewportMap() {
|
||||
}
|
||||
|
||||
void ViewportMap::draw() {
|
||||
Ultima1Map *map = static_cast<Ultima1Map *>(getMap());
|
||||
|
||||
// If necessary, load the sprites for rendering the map
|
||||
if (_sprites.empty() || _mapType != map->_mapType) {
|
||||
if (_sprites->empty() || _mapType != map->_mapType) {
|
||||
_mapType = map->_mapType;
|
||||
|
||||
if (_mapType == MAP_OVERWORLD)
|
||||
_sprites.load("t1ktiles.bin", 4);
|
||||
_sprites->load("t1ktiles.bin", 4);
|
||||
else
|
||||
_sprites.load("t1ktown.bin", 4, 8, 8);
|
||||
_sprites->load("t1ktown.bin", 4, 8, 8);
|
||||
}
|
||||
|
||||
// Draw the map
|
||||
|
@ -34,8 +34,15 @@ class ViewportMap : public Shared::ViewportMap {
|
||||
private:
|
||||
MapType _mapType;
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
ViewportMap(TreeItem *parent);
|
||||
virtual ~ViewportMap() {}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~ViewportMap();
|
||||
|
||||
/**
|
||||
* Draws the map
|
||||
|
Loading…
x
Reference in New Issue
Block a user