Improve overlays
This commit is contained in:
parent
28fbf84855
commit
875c4b09a5
6 changed files with 77 additions and 24 deletions
|
@ -949,23 +949,23 @@ void GfxOpenGL::drawOverlay(const Overlay *overlay) {
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
|
||||||
|
float height = overlay->getHeight();
|
||||||
|
float width = overlay->getWidth();
|
||||||
|
float x = overlay->_x;
|
||||||
|
float y = overlay->_y;
|
||||||
|
|
||||||
// In Grim, the bottom edge of the sprite is at y=0 and
|
glBegin(GL_QUADS);
|
||||||
// the texture is flipped along the X-axis.
|
|
||||||
float height = overlay->_material->getData()->_textures[0]->_height;
|
|
||||||
float width = overlay->_material->getData()->_textures[0]->_width;
|
|
||||||
|
|
||||||
glBegin(GL_POLYGON);
|
|
||||||
glTexCoord2f(0.0f, 1.0f);
|
|
||||||
glVertex3f(0, height, 0.0f);
|
|
||||||
glTexCoord2f(0.0f, 0.0f);
|
glTexCoord2f(0.0f, 0.0f);
|
||||||
glVertex3f(0, 0, 0.0f);
|
glVertex2f(x, y);
|
||||||
glTexCoord2f(1.0f, 0.0f);
|
glTexCoord2f(1.0f, 0.0f);
|
||||||
glVertex3f(width, +0, 0.0f);
|
glVertex2f((x + width), y);
|
||||||
glTexCoord2f(1.0f, 1.0f);
|
glTexCoord2f(1.0f, 1.0f);
|
||||||
glVertex3f(width, height, 0.0f);
|
glVertex2f((x + width), (y + height));
|
||||||
|
glTexCoord2f(0.0f, 1.0f);
|
||||||
|
glVertex2f(x, (y + height));
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glEnable(GL_LIGHTING);
|
glEnable(GL_LIGHTING);
|
||||||
glDisable(GL_ALPHA_TEST);
|
glDisable(GL_ALPHA_TEST);
|
||||||
|
|
|
@ -313,7 +313,7 @@ Common::Error GrimEngine::run() {
|
||||||
|
|
||||||
bool fullscreen = ConfMan.getBool("fullscreen");
|
bool fullscreen = ConfMan.getBool("fullscreen");
|
||||||
createRenderer();
|
createRenderer();
|
||||||
g_driver->setupScreen(640, 480, fullscreen);
|
g_driver->setupScreen(1600, 900, fullscreen);
|
||||||
g_driver->loadEmergFont();
|
g_driver->loadEmergFont();
|
||||||
|
|
||||||
if (getGameType() == GType_MONKEY4 && SearchMan.hasFile("AMWI.m4b")) {
|
if (getGameType() == GType_MONKEY4 && SearchMan.hasFile("AMWI.m4b")) {
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "common/savefile.h"
|
#include "common/savefile.h"
|
||||||
#include "common/system.h"
|
#include "common/system.h"
|
||||||
#include "common/config-manager.h"
|
#include "common/config-manager.h"
|
||||||
|
#include "common/foreach.h"
|
||||||
|
|
||||||
#include "graphics/pixelbuffer.h"
|
#include "graphics/pixelbuffer.h"
|
||||||
#include "graphics/colormasks.h"
|
#include "graphics/colormasks.h"
|
||||||
|
@ -684,14 +685,34 @@ void Lua_V1::WidescreenCorrectionFactor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lua_V1::GetFontDimensions() {
|
void Lua_V1::GetFontDimensions() {
|
||||||
warning("Stub function: GetFontDimensions, returns 1");
|
// Taken from Lua_v2 and modified
|
||||||
lua_pushnumber(1);
|
lua_Object fontObj = lua_getparam(1);
|
||||||
|
if (!lua_isuserdata(fontObj) || lua_tag(fontObj) != Font::getStaticTag())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Font *font = Font::getPool().getObject(lua_getuserdata(fontObj));
|
||||||
|
|
||||||
|
if (font) {
|
||||||
|
int32 h = font->getBaseOffsetY();
|
||||||
|
int32 w = font->getCharKernedWidth('w');
|
||||||
|
lua_pushnumber(w);
|
||||||
|
lua_pushnumber(h);
|
||||||
|
} else {
|
||||||
|
warning("Lua_V1::GetFontDimensions for invalid font: returns 0,0");
|
||||||
|
lua_pushnumber(0.f);
|
||||||
|
lua_pushnumber(0.f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Lua_V1::OverlayDimensions() {
|
void Lua_V1::OverlayDimensions() {
|
||||||
warning("Stub function: OverlayDimensions, returns 1, 1");
|
lua_Object overlayObj = lua_getparam(1);
|
||||||
lua_pushnumber(1);
|
if (!lua_isuserdata(overlayObj) || lua_tag(overlayObj) != Overlay::getStaticTag())
|
||||||
lua_pushnumber(1);
|
return;
|
||||||
|
|
||||||
|
Overlay *overlay = Overlay::getPool().getObject(lua_getuserdata(overlayObj));
|
||||||
|
lua_pushnumber(overlay->getWidth());
|
||||||
|
lua_pushnumber(overlay->getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lua_V1::OverlayGetScreenSize() {
|
void Lua_V1::OverlayGetScreenSize() {
|
||||||
|
@ -701,14 +722,19 @@ void Lua_V1::OverlayGetScreenSize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lua_V1::OverlayCreate() {
|
void Lua_V1::OverlayCreate() {
|
||||||
warning("Stub function: OverlayCreate");
|
warning("Stub function: OverlayCreate missing table get");
|
||||||
lua_Object param1 = lua_getparam(1);
|
lua_Object param1 = lua_getparam(1);
|
||||||
if (!lua_isstring(param1)) {
|
lua_Object param2 = lua_getparam(2);
|
||||||
|
lua_Object param3 = lua_getparam(3);
|
||||||
|
if (!lua_isstring(param1) || !lua_isnumber(param2) || !lua_isnumber(param3)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const char *overlayName = lua_getstring(param1);
|
const char *overlayName = lua_getstring(param1);
|
||||||
|
float x = lua_getnumber(param2);
|
||||||
|
float y = lua_getnumber(param3);
|
||||||
|
|
||||||
Overlay *overlay = g_resourceloader->loadOverlay(overlayName);
|
Overlay *overlay = g_resourceloader->loadOverlay(overlayName);
|
||||||
|
overlay->setPos(x, y);
|
||||||
|
|
||||||
if (overlay) {
|
if (overlay) {
|
||||||
lua_pushusertag(overlay->getId(), overlay->getTag());
|
lua_pushusertag(overlay->getId(), overlay->getTag());
|
||||||
|
@ -718,7 +744,6 @@ void Lua_V1::OverlayCreate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lua_V1::OverlayDestroy() {
|
void Lua_V1::OverlayDestroy() {
|
||||||
warning("Stub function: OverlayDestroy");
|
|
||||||
lua_Object actorObj = lua_getparam(1);
|
lua_Object actorObj = lua_getparam(1);
|
||||||
if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != Overlay::getStaticTag())
|
if (!lua_isuserdata(actorObj) || lua_tag(actorObj) != Overlay::getStaticTag())
|
||||||
return;
|
return;
|
||||||
|
@ -727,6 +752,20 @@ void Lua_V1::OverlayDestroy() {
|
||||||
delete overlay;
|
delete overlay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Lua_V1::OverlayMove() {
|
||||||
|
lua_Object overlayObj = lua_getparam(1);
|
||||||
|
lua_Object param2 = lua_getparam(2);
|
||||||
|
lua_Object param3 = lua_getparam(3);
|
||||||
|
|
||||||
|
if (!lua_isuserdata(overlayObj) || lua_tag(overlayObj) != Overlay::getStaticTag())
|
||||||
|
return;
|
||||||
|
|
||||||
|
Overlay *overlay = Overlay::getPool().getObject(lua_getuserdata(overlayObj));
|
||||||
|
float x = lua_getnumber(param2);
|
||||||
|
float y = lua_getnumber(param3);
|
||||||
|
overlay->setPos(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
void Lua_V1::QueryActiveHotspots() {
|
void Lua_V1::QueryActiveHotspots() {
|
||||||
warning("Stub function: QueryActiveHotspots, returns empty table");
|
warning("Stub function: QueryActiveHotspots, returns empty table");
|
||||||
lua_Object resObj = lua_createtable();
|
lua_Object resObj = lua_createtable();
|
||||||
|
@ -823,7 +862,6 @@ STUB_FUNC(Lua_V1::UpdateUIButtons)
|
||||||
STUB_FUNC(Lua_V1::OverlayClearCache)
|
STUB_FUNC(Lua_V1::OverlayClearCache)
|
||||||
STUB_FUNC(Lua_V1::GetGameRenderMode)
|
STUB_FUNC(Lua_V1::GetGameRenderMode)
|
||||||
STUB_FUNC(Lua_V1::SetGameRenderMode)
|
STUB_FUNC(Lua_V1::SetGameRenderMode)
|
||||||
STUB_FUNC(Lua_V1::OverlayMove)
|
|
||||||
STUB_FUNC(Lua_V1::AddHotspot)
|
STUB_FUNC(Lua_V1::AddHotspot)
|
||||||
STUB_FUNC(Lua_V1::RemoveHotspot)
|
STUB_FUNC(Lua_V1::RemoveHotspot)
|
||||||
STUB_FUNC(Lua_V1::OverlayFade)
|
STUB_FUNC(Lua_V1::OverlayFade)
|
||||||
|
|
|
@ -238,7 +238,8 @@ MaterialData *MaterialData::getMaterialData(const Common::String &filename, Comm
|
||||||
++m->_refCount;
|
++m->_refCount;
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
if (m->_fname == filename && m->_cmap->getFilename() == cmap->getFilename()) {
|
// We need to allow null cmaps for remastered overlays
|
||||||
|
if (m->_fname == filename && (!(m->_cmap || cmap) || m->_cmap->getFilename() == cmap->getFilename())) {
|
||||||
++m->_refCount;
|
++m->_refCount;
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,8 @@
|
||||||
|
|
||||||
namespace Grim {
|
namespace Grim {
|
||||||
|
|
||||||
Overlay::Overlay(const Common::String &filename, Common::SeekableReadStream *data) {
|
Overlay::Overlay(const Common::String &filename, Common::SeekableReadStream *data) :
|
||||||
|
_x(0), _y(0) {
|
||||||
_material = g_resourceloader->loadMaterial(filename, NULL, true);
|
_material = g_resourceloader->loadMaterial(filename, NULL, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,4 +44,12 @@ void Overlay::draw() {
|
||||||
g_driver->drawOverlay(this);
|
g_driver->drawOverlay(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Overlay::getWidth() const {
|
||||||
|
return _material->getData()->_textures[0]->_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Overlay::getHeight() const {
|
||||||
|
return _material->getData()->_textures[0]->_height;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,9 @@ public:
|
||||||
~Overlay();
|
~Overlay();
|
||||||
|
|
||||||
void draw();
|
void draw();
|
||||||
|
void setPos(float x, float y) { _x = x; _y = y; }
|
||||||
|
int getWidth() const;
|
||||||
|
int getHeight() const;
|
||||||
|
|
||||||
static int32 getStaticTag() { return MKTAG('O','V','E','R'); }
|
static int32 getStaticTag() { return MKTAG('O','V','E','R'); }
|
||||||
|
|
||||||
|
@ -45,6 +48,8 @@ public:
|
||||||
|
|
||||||
//private:
|
//private:
|
||||||
Material *_material;
|
Material *_material;
|
||||||
|
float _x;
|
||||||
|
float _y;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue