[Scummvm-git-logs] scummvm master -> 12f97f724af89b30b5c27071d6cd126fef0f3137
sev-
noreply at scummvm.org
Wed Nov 27 23:12:42 UTC 2024
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:
12f97f724a Revert "SWORD25: Removed a lot of debug/unimplemented/unused functions"
Commit: 12f97f724af89b30b5c27071d6cd126fef0f3137
https://github.com/scummvm/scummvm/commit/12f97f724af89b30b5c27071d6cd126fef0f3137
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2024-11-28T00:12:29+01:00
Commit Message:
Revert "SWORD25: Removed a lot of debug/unimplemented/unused functions"
This reverts imost of commit 42670975acf72ca52bbf73c0f0c0295b07c0a50a.
Changed paths:
engines/sword25/gfx/graphicengine.cpp
engines/sword25/gfx/graphicengine.h
engines/sword25/gfx/graphicengine_script.cpp
engines/sword25/input/inputengine.cpp
engines/sword25/input/inputengine.h
engines/sword25/input/inputengine_script.cpp
engines/sword25/math/geometry_script.cpp
diff --git a/engines/sword25/gfx/graphicengine.cpp b/engines/sword25/gfx/graphicengine.cpp
index fe5d0d489cb..a86039525a0 100644
--- a/engines/sword25/gfx/graphicengine.cpp
+++ b/engines/sword25/gfx/graphicengine.cpp
@@ -148,6 +148,32 @@ bool GraphicEngine::endFrame() {
g_system->updateScreen();
+ // Debug-Lines zeichnen
+ if (!_debugLines.empty()) {
+#if 0
+ glEnable(GL_LINE_SMOOTH);
+ glBegin(GL_LINES);
+
+ Common::Array<DebugLine>::const_iterator iter = m_DebugLines.begin();
+ for (; iter != m_DebugLines.end(); ++iter) {
+ const uint &Color = (*iter).Color;
+ const BS_Vertex &Start = (*iter).Start;
+ const BS_Vertex &End = (*iter).End;
+
+ glColor4ub((Color >> 16) & 0xff, (Color >> 8) & 0xff, Color & 0xff, Color >> 24);
+ glVertex2d(Start.X, Start.Y);
+ glVertex2d(End.X, End.Y);
+ }
+
+ glEnd();
+ glDisable(GL_LINE_SMOOTH);
+#endif
+
+ warning("STUB: Drawing debug lines");
+
+ _debugLines.clear();
+ }
+
return true;
}
@@ -341,6 +367,15 @@ bool GraphicEngine::canLoadResource(const Common::String &filename) {
filename.hasPrefix("/saves");
}
+
+// -----------------------------------------------------------------------------
+// DEBUGGING
+// -----------------------------------------------------------------------------
+
+void GraphicEngine::drawDebugLine(const Vertex &start, const Vertex &end, uint color) {
+ _debugLines.push_back(DebugLine(start, end, color));
+}
+
void GraphicEngine::updateLastFrameDuration() {
// Record current time
const uint currentTime = Kernel::getInstance()->getMilliTicks();
diff --git a/engines/sword25/gfx/graphicengine.h b/engines/sword25/gfx/graphicengine.h
index 76bf0fbddeb..ce98d9f3b4b 100644
--- a/engines/sword25/gfx/graphicengine.h
+++ b/engines/sword25/gfx/graphicengine.h
@@ -119,6 +119,20 @@ public:
*/
bool endFrame();
+ // Debug methods
+
+ /**
+ * Draws a line in the frame buffer
+ *
+ * This method must be called between calls to StartFrame() and EndFrame(), and is intended only for debugging
+ * purposes. The line will only appear for a single frame. If the line is to be shown permanently, it must be
+ * called for every frame.
+ * @param Start The starting point of the line
+ * @param End The ending point of the line
+ * @param Color The color of the line. The default is BS_RGB (255,255,255) (White)
+ */
+ void drawDebugLine(const Vertex &start, const Vertex &end, uint color = BS_RGB(255, 255, 255));
+
/**
* Creates a thumbnail with the dimensions of 200x125. This will not include the top and bottom of the screen..
* the interface boards the image as a 16th of it's original size.
@@ -203,6 +217,13 @@ public:
*/
bool getVsync() const;
+ /**
+ * Returns true if the engine is running in Windowed mode.
+ */
+ bool isWindowed() {
+ return false;
+ }
+
/**
* Fills a rectangular area of the frame buffer with a color.
* Notes: It is possible to create transparent rectangles by passing a color with an Alpha value of 255.
@@ -280,6 +301,7 @@ private:
uint _color;
};
+ Common::Array<DebugLine> _debugLines;
};
} // End of namespace Sword25
diff --git a/engines/sword25/gfx/graphicengine_script.cpp b/engines/sword25/gfx/graphicengine_script.cpp
index d9b0c612deb..d8e432ae25b 100644
--- a/engines/sword25/gfx/graphicengine_script.cpp
+++ b/engines/sword25/gfx/graphicengine_script.cpp
@@ -197,7 +197,6 @@ static int init(lua_State *L) {
lua_pushbooleancpp(L, pGE->init(static_cast<int>(luaL_checknumber(L, 1)), static_cast<int>(luaL_checknumber(L, 2)),
static_cast<int>(luaL_checknumber(L, 3))));
break;
- case 4:
default:
lua_pushbooleancpp(L, pGE->init(static_cast<int>(luaL_checknumber(L, 1)), static_cast<int>(luaL_checknumber(L, 2)),
static_cast<int>(luaL_checknumber(L, 3)), static_cast<int>(luaL_checknumber(L, 4))));
@@ -256,6 +255,34 @@ static int endFrame(lua_State *L) {
return 1;
}
+static int drawDebugLine(lua_State *L) {
+ GraphicEngine *pGE = getGE();
+
+ Vertex start;
+ Vertex end;
+ Vertex::luaVertexToVertex(L, 1, start);
+ Vertex::luaVertexToVertex(L, 2, end);
+ pGE->drawDebugLine(start, end, GraphicEngine::luaColorToARGBColor(L, 3));
+
+ return 0;
+}
+
+static int getDisplayWidth(lua_State *L) {
+ GraphicEngine *pGE = getGE();
+
+ lua_pushnumber(L, pGE->getDisplayWidth());
+
+ return 1;
+}
+
+static int getDisplayHeight(lua_State *L) {
+ GraphicEngine *pGE = getGE();
+
+ lua_pushnumber(L, pGE->getDisplayHeight());
+
+ return 1;
+}
+
static int getBitDepth(lua_State *L) {
GraphicEngine *pGE = getGE();
@@ -280,6 +307,21 @@ static int isVsync(lua_State *L) {
return 1;
}
+static int isWindowed(lua_State *L) {
+ GraphicEngine *pGE = getGE();
+
+ lua_pushbooleancpp(L, pGE->isWindowed());
+
+ return 1;
+}
+
+static int getFPSCount(lua_State *L) {
+ // Used in a debug function
+ lua_pushnumber(L, 0);
+
+ return 1;
+}
+
static int getLastFrameDuration(lua_State *L) {
GraphicEngine *pGE = getGE();
@@ -308,15 +350,23 @@ static int getSecondaryFrameDuration(lua_State *L) {
return 1;
}
+static int saveScreenshot(lua_State *L) {
+ // This is used by system/debug.lua only. We do not implement this; support
+ // for taking screenshots is a backend feature.
+ lua_pushbooleancpp(L, false);
+
+ return 1;
+}
+
static int saveThumbnailScreenshot(lua_State *L) {
GraphicEngine *pGE = getGE();
lua_pushbooleancpp(L, pGE->saveThumbnailScreenshot(luaL_checkstring(L, 1)));
return 1;
}
-// Marks a function that should never be used
-static int dummyFuncError(lua_State *L) {
- error("Dummy function invoked by LUA");
+static int getRepaintedPixels(lua_State *L) {
+ // Used in a debug function.
+ lua_pushnumber(L, 0);
return 1;
}
@@ -324,21 +374,21 @@ static const luaL_reg GFX_FUNCTIONS[] = {
{"Init", init},
{"StartFrame", startFrame},
{"EndFrame", endFrame},
- {"DrawDebugLine", dummyFuncError},
+ {"DrawDebugLine", drawDebugLine},
{"SetVsync", setVsync},
- {"GetDisplayWidth", dummyFuncError},
- {"GetDisplayHeight", dummyFuncError},
+ {"GetDisplayWidth", getDisplayWidth},
+ {"GetDisplayHeight", getDisplayHeight},
{"GetBitDepth", getBitDepth},
{"IsVsync", isVsync},
- {"IsWindowed", dummyFuncError},
- {"GetFPSCount", dummyFuncError},
+ {"IsWindowed", isWindowed},
+ {"GetFPSCount", getFPSCount},
{"GetLastFrameDuration", getLastFrameDuration},
{"StopMainTimer", stopMainTimer},
{"ResumeMainTimer", resumeMainTimer},
{"GetSecondaryFrameDuration", getSecondaryFrameDuration},
- {"SaveScreenshot", dummyFuncError},
+ {"SaveScreenshot", saveScreenshot},
{"NewAnimationTemplate", newAnimationTemplate},
- {"GetRepaintedPixels", dummyFuncError},
+ {"GetRepaintedPixels", getRepaintedPixels},
{"SaveThumbnailScreenshot", saveThumbnailScreenshot},
{0, 0}
};
@@ -734,6 +784,27 @@ static int b_getPixel(lua_State *L) {
return 1;
}
+static int b_isScalingAllowed(lua_State *L) {
+ RenderObjectPtr<Bitmap> bitmapPtr = checkBitmap(L);
+ assert(bitmapPtr.isValid());
+ lua_pushbooleancpp(L, bitmapPtr->isScalingAllowed());
+ return 1;
+}
+
+static int b_isAlphaAllowed(lua_State *L) {
+ RenderObjectPtr<Bitmap> bitmapPtr = checkBitmap(L);
+ assert(bitmapPtr.isValid());
+ lua_pushbooleancpp(L, bitmapPtr->isAlphaAllowed());
+ return 1;
+}
+
+static int b_isTintingAllowed(lua_State *L) {
+ RenderObjectPtr<Bitmap> bitmapPtr = checkBitmap(L);
+ assert(bitmapPtr.isValid());
+ lua_pushbooleancpp(L, bitmapPtr->isColorModulationAllowed());
+ return 1;
+}
+
static int b_remove(lua_State *L) {
RenderObjectPtr<RenderObject> roPtr = checkRenderObject(L);
assert(roPtr.isValid());
@@ -756,9 +827,9 @@ static const luaL_reg BITMAP_METHODS[] = {
{"IsFlipH", b_isFlipH},
{"IsFlipV", b_isFlipV},
{"GetPixel", b_getPixel},
- {"IsScalingAllowed", dummyFuncError},
- {"IsAlphaAllowed", dummyFuncError},
- {"IsTintingAllowed", dummyFuncError},
+ {"IsScalingAllowed", b_isScalingAllowed},
+ {"IsAlphaAllowed", b_isAlphaAllowed},
+ {"IsTintingAllowed", b_isTintingAllowed},
{"Remove", b_remove},
{0, 0}
};
diff --git a/engines/sword25/input/inputengine.cpp b/engines/sword25/input/inputengine.cpp
index fdcc866a9cc..a560aa1b704 100644
--- a/engines/sword25/input/inputengine.cpp
+++ b/engines/sword25/input/inputengine.cpp
@@ -206,6 +206,16 @@ bool InputEngine::wasKeyDown(uint keyCode) {
((_keyboardState[_currentState ^ 1][keyCode] & 0x80) != 0);
}
+void InputEngine::setMouseX(int posX) {
+ _mouseX = posX;
+ g_system->warpMouse(_mouseX, _mouseY);
+}
+
+void InputEngine::setMouseY(int posY) {
+ _mouseY = posY;
+ g_system->warpMouse(_mouseX, _mouseY);
+}
+
void InputEngine::setCharacterCallback(CharacterCallback callback) {
_characterCallback = callback;
}
diff --git a/engines/sword25/input/inputengine.h b/engines/sword25/input/inputengine.h
index d9a13dc8df7..276fc45d1fb 100644
--- a/engines/sword25/input/inputengine.h
+++ b/engines/sword25/input/inputengine.h
@@ -226,6 +226,16 @@ public:
*/
int getMouseY();
+ /**
+ * Sets the X position of the cursor in pixels
+ */
+ void setMouseX(int posX);
+
+ /**
+ * Sets the Y position of the cursor in pixels
+ */
+ void setMouseY(int posY);
+
/**
* Returns true if a given key was pressed
* @param KeyCode The key code to be checked
diff --git a/engines/sword25/input/inputengine_script.cpp b/engines/sword25/input/inputengine_script.cpp
index 2a51d180444..3eb79047dec 100644
--- a/engines/sword25/input/inputengine_script.cpp
+++ b/engines/sword25/input/inputengine_script.cpp
@@ -163,22 +163,58 @@ static int wasKeyDown(lua_State *L) {
return 1;
}
+static int setMouseX(lua_State *L) {
+ InputEngine *pIE = getIE();
+
+ pIE->setMouseX((int)luaL_checknumber(L, 1));
+ return 0;
+}
+
+static int setMouseY(lua_State *L) {
+ InputEngine *pIE = getIE();
+
+ pIE->setMouseY((int)luaL_checknumber(L, 1));
+ return 0;
+}
+
static void theCharacterCallback(int character) {
characterCallbackPtr->_character = static_cast<byte>(character);
lua_State *L = static_cast<lua_State *>(Kernel::getInstance()->getScript()->getScriptObject());
characterCallbackPtr->invokeCallbackFunctions(L, 1);
}
+static int registerCharacterCallback(lua_State *L) {
+ luaL_checktype(L, 1, LUA_TFUNCTION);
+ characterCallbackPtr->registerCallbackFunction(L, 1);
+
+ return 0;
+}
+
+static int unregisterCharacterCallback(lua_State *L) {
+ luaL_checktype(L, 1, LUA_TFUNCTION);
+ characterCallbackPtr->unregisterCallbackFunction(L, 1);
+
+ return 0;
+}
+
static void theCommandCallback(int command) {
commandCallbackPtr->_command = static_cast<InputEngine::KEY_COMMANDS>(command);
lua_State *L = static_cast<lua_State *>(Kernel::getInstance()->getScript()->getScriptObject());
commandCallbackPtr->invokeCallbackFunctions(L, 1);
}
-// Marks a function that should never be used
-static int dummyFuncError(lua_State *L) {
- error("Dummy function invoked by LUA");
- return 1;
+static int registerCommandCallback(lua_State *L) {
+ luaL_checktype(L, 1, LUA_TFUNCTION);
+ commandCallbackPtr->registerCallbackFunction(L, 1);
+
+ return 0;
+}
+
+static int unregisterCommandCallback(lua_State *L) {
+ luaL_checktype(L, 1, LUA_TFUNCTION);
+ commandCallbackPtr->unregisterCallbackFunction(L, 1);
+
+ return 0;
}
static const char *PACKAGE_LIBRARY_NAME = "Input";
@@ -193,14 +229,14 @@ static const luaL_reg PACKAGE_FUNCTIONS[] = {
{"IsLeftDoubleClick", isLeftDoubleClick},
{"GetMouseX", getMouseX},
{"GetMouseY", getMouseY},
- {"SetMouseX", dummyFuncError},
- {"SetMouseY", dummyFuncError},
+ {"SetMouseX", setMouseX},
+ {"SetMouseY", setMouseY},
{"IsKeyDown", isKeyDown},
{"WasKeyDown", wasKeyDown},
- {"RegisterCharacterCallback", dummyFuncError}, // debug
- {"UnregisterCharacterCallback", dummyFuncError},
- {"RegisterCommandCallback", dummyFuncError},
- {"UnregisterCommandCallback", dummyFuncError},
+ {"RegisterCharacterCallback", registerCharacterCallback},
+ {"UnregisterCharacterCallback", unregisterCharacterCallback},
+ {"RegisterCommandCallback", registerCommandCallback},
+ {"UnregisterCommandCallback", unregisterCommandCallback},
{0, 0}
};
diff --git a/engines/sword25/math/geometry_script.cpp b/engines/sword25/math/geometry_script.cpp
index 623992e03f9..0198762a582 100644
--- a/engines/sword25/math/geometry_script.cpp
+++ b/engines/sword25/math/geometry_script.cpp
@@ -334,6 +334,45 @@ static int r_setY(lua_State *L) {
return 0;
}
+static void drawPolygon(const Polygon &polygon, uint color, const Vertex &offset) {
+ GraphicEngine *pGE = Kernel::getInstance()->getGfx();
+ assert(pGE);
+
+ for (int i = 0; i < polygon.vertexCount - 1; i++)
+ pGE->drawDebugLine(polygon.vertices[i] + offset, polygon.vertices[i + 1] + offset, color);
+
+ pGE->drawDebugLine(polygon.vertices[polygon.vertexCount - 1] + offset, polygon.vertices[0] + offset, color);
+}
+
+static void drawRegion(const Region ®ion, uint color, const Vertex &offset) {
+ drawPolygon(region.getContour(), color, offset);
+ for (int i = 0; i < region.getHoleCount(); i++)
+ drawPolygon(region.getHole(i), color, offset);
+}
+
+static int r_draw(lua_State *L) {
+ Region *pR = checkRegion(L);
+ assert(pR);
+
+ switch (lua_gettop(L)) {
+ case 3: {
+ Vertex offset;
+ Vertex::luaVertexToVertex(L, 3, offset);
+ drawRegion(*pR, GraphicEngine::luaColorToARGBColor(L, 2), offset);
+ }
+ break;
+
+ case 2:
+ drawRegion(*pR, GraphicEngine::luaColorToARGBColor(L, 2), Vertex(0, 0));
+ break;
+
+ default:
+ drawRegion(*pR, BS_RGB(255, 255, 255), Vertex(0, 0));
+ }
+
+ return 0;
+}
+
static int r_getCentroid(lua_State *L) {
Region *RPtr = checkRegion(L);
assert(RPtr);
@@ -350,12 +389,6 @@ static int r_delete(lua_State *L) {
return 0;
}
-// Marks a function that should never be used
-static int dummyFuncError(lua_State *L) {
- error("Dummy function invoked by LUA");
- return 1;
-}
-
static const luaL_reg REGION_METHODS[] = {
{"SetPos", r_setPos},
{"SetX", r_setX},
@@ -365,7 +398,7 @@ static const luaL_reg REGION_METHODS[] = {
{"GetX", r_getX},
{"GetY", r_getY},
{"IsValid", r_isValid},
- {"Draw", dummyFuncError},
+ {"Draw", r_draw},
{"GetCentroid", r_getCentroid},
{0, 0}
};
More information about the Scummvm-git-logs
mailing list