diff --git a/CMakeLists.txt b/CMakeLists.txt index cce226d56..1897e3e34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -540,8 +540,8 @@ set(LOVE_SRC_MODULE_GRAPHICS_ROOT src/modules/graphics/SpriteBatch.h src/modules/graphics/StreamBuffer.cpp src/modules/graphics/StreamBuffer.h - src/modules/graphics/Text.cpp - src/modules/graphics/Text.h + src/modules/graphics/TextBatch.cpp + src/modules/graphics/TextBatch.h src/modules/graphics/Texture.cpp src/modules/graphics/Texture.h src/modules/graphics/vertex.cpp @@ -570,8 +570,8 @@ set(LOVE_SRC_MODULE_GRAPHICS_ROOT src/modules/graphics/wrap_SpriteBatch.h src/modules/graphics/wrap_Texture.cpp src/modules/graphics/wrap_Texture.h - src/modules/graphics/wrap_Text.cpp - src/modules/graphics/wrap_Text.h + src/modules/graphics/wrap_TextBatch.cpp + src/modules/graphics/wrap_TextBatch.h src/modules/graphics/wrap_Video.cpp src/modules/graphics/wrap_Video.h ) diff --git a/platform/xcode/liblove.xcodeproj/project.pbxproj b/platform/xcode/liblove.xcodeproj/project.pbxproj index 6fa81d399..04bfbdc69 100644 --- a/platform/xcode/liblove.xcodeproj/project.pbxproj +++ b/platform/xcode/liblove.xcodeproj/project.pbxproj @@ -1133,12 +1133,12 @@ FADF53F81E3C7ACD00012CC0 /* Buffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FADF53F61E3C7ACD00012CC0 /* Buffer.cpp */; }; FADF53F91E3C7ACD00012CC0 /* Buffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FADF53F61E3C7ACD00012CC0 /* Buffer.cpp */; }; FADF53FA1E3C7ACD00012CC0 /* Buffer.h in Headers */ = {isa = PBXBuildFile; fileRef = FADF53F71E3C7ACD00012CC0 /* Buffer.h */; }; - FADF53FD1E3D74F200012CC0 /* Text.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FADF53FB1E3D74F200012CC0 /* Text.cpp */; }; - FADF53FE1E3D74F200012CC0 /* Text.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FADF53FB1E3D74F200012CC0 /* Text.cpp */; }; - FADF53FF1E3D74F200012CC0 /* Text.h in Headers */ = {isa = PBXBuildFile; fileRef = FADF53FC1E3D74F200012CC0 /* Text.h */; }; - FADF54021E3D77B500012CC0 /* wrap_Text.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FADF54001E3D77B500012CC0 /* wrap_Text.cpp */; }; - FADF54031E3D77B500012CC0 /* wrap_Text.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FADF54001E3D77B500012CC0 /* wrap_Text.cpp */; }; - FADF54041E3D77B500012CC0 /* wrap_Text.h in Headers */ = {isa = PBXBuildFile; fileRef = FADF54011E3D77B500012CC0 /* wrap_Text.h */; }; + FADF53FD1E3D74F200012CC0 /* TextBatch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FADF53FB1E3D74F200012CC0 /* TextBatch.cpp */; }; + FADF53FE1E3D74F200012CC0 /* TextBatch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FADF53FB1E3D74F200012CC0 /* TextBatch.cpp */; }; + FADF53FF1E3D74F200012CC0 /* TextBatch.h in Headers */ = {isa = PBXBuildFile; fileRef = FADF53FC1E3D74F200012CC0 /* TextBatch.h */; }; + FADF54021E3D77B500012CC0 /* wrap_TextBatch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FADF54001E3D77B500012CC0 /* wrap_TextBatch.cpp */; }; + FADF54031E3D77B500012CC0 /* wrap_TextBatch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FADF54001E3D77B500012CC0 /* wrap_TextBatch.cpp */; }; + FADF54041E3D77B500012CC0 /* wrap_TextBatch.h in Headers */ = {isa = PBXBuildFile; fileRef = FADF54011E3D77B500012CC0 /* wrap_TextBatch.h */; }; FADF54071E3D78F700012CC0 /* Video.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FADF54051E3D78F700012CC0 /* Video.cpp */; }; FADF54081E3D78F700012CC0 /* Video.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FADF54051E3D78F700012CC0 /* Video.cpp */; }; FADF54091E3D78F700012CC0 /* Video.h in Headers */ = {isa = PBXBuildFile; fileRef = FADF54061E3D78F700012CC0 /* Video.h */; }; @@ -2161,10 +2161,10 @@ FADF4CC52663D0EC004F95C1 /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; }; FADF53F61E3C7ACD00012CC0 /* Buffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Buffer.cpp; sourceTree = ""; }; FADF53F71E3C7ACD00012CC0 /* Buffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Buffer.h; sourceTree = ""; }; - FADF53FB1E3D74F200012CC0 /* Text.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Text.cpp; sourceTree = ""; }; - FADF53FC1E3D74F200012CC0 /* Text.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Text.h; sourceTree = ""; }; - FADF54001E3D77B500012CC0 /* wrap_Text.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Text.cpp; sourceTree = ""; }; - FADF54011E3D77B500012CC0 /* wrap_Text.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_Text.h; sourceTree = ""; }; + FADF53FB1E3D74F200012CC0 /* TextBatch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextBatch.cpp; sourceTree = ""; }; + FADF53FC1E3D74F200012CC0 /* TextBatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextBatch.h; sourceTree = ""; }; + FADF54001E3D77B500012CC0 /* wrap_TextBatch.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_TextBatch.cpp; sourceTree = ""; }; + FADF54011E3D77B500012CC0 /* wrap_TextBatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = wrap_TextBatch.h; sourceTree = ""; }; FADF54051E3D78F700012CC0 /* Video.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Video.cpp; sourceTree = ""; }; FADF54061E3D78F700012CC0 /* Video.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Video.h; sourceTree = ""; }; FADF540A1E3D7CDD00012CC0 /* wrap_Video.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = wrap_Video.cpp; sourceTree = ""; }; @@ -2876,8 +2876,8 @@ FADF542E1E3DABF600012CC0 /* SpriteBatch.h */, FA29C0041E12355B00268CD8 /* StreamBuffer.cpp */, FA2AF6721DAD62710032B62C /* StreamBuffer.h */, - FADF53FB1E3D74F200012CC0 /* Text.cpp */, - FADF53FC1E3D74F200012CC0 /* Text.h */, + FADF53FB1E3D74F200012CC0 /* TextBatch.cpp */, + FADF53FC1E3D74F200012CC0 /* TextBatch.h */, FA0B7BBE1A95902C000E1D17 /* Texture.cpp */, FA0B7BBF1A95902C000E1D17 /* Texture.h */, FA2AF6731DAD64970032B62C /* vertex.cpp */, @@ -2905,8 +2905,8 @@ FA1BA0B61E17043400AA2803 /* wrap_Shader.h */, FADF54321E3DAE6E00012CC0 /* wrap_SpriteBatch.cpp */, FADF54331E3DAE6E00012CC0 /* wrap_SpriteBatch.h */, - FADF54001E3D77B500012CC0 /* wrap_Text.cpp */, - FADF54011E3D77B500012CC0 /* wrap_Text.h */, + FADF54001E3D77B500012CC0 /* wrap_TextBatch.cpp */, + FADF54011E3D77B500012CC0 /* wrap_TextBatch.h */, FA620A301AA2F8DB005DB4C2 /* wrap_Texture.cpp */, FA620A311AA2F8DB005DB4C2 /* wrap_Texture.h */, FADF540A1E3D7CDD00012CC0 /* wrap_Video.cpp */, @@ -4248,7 +4248,7 @@ FABDA9EA2552448300B5C523 /* b2_world_callbacks.h in Headers */, FA0B7E7D1A95902C000E1D17 /* wrap_World.h in Headers */, FA0B7EBD1A95902C000E1D17 /* LuaThread.h in Headers */, - FADF53FF1E3D74F200012CC0 /* Text.h in Headers */, + FADF53FF1E3D74F200012CC0 /* TextBatch.h in Headers */, FA0B7DC01A95902C000E1D17 /* JoystickModule.h in Headers */, FA18CF3923DCF67900263725 /* spirv_msl.hpp in Headers */, FA0B7E871A95902C000E1D17 /* CoreAudioDecoder.h in Headers */, @@ -4483,7 +4483,7 @@ FABDA9CF2552448300B5C523 /* b2_mouse_joint.h in Headers */, FABDA9E42552448300B5C523 /* b2_collision.h in Headers */, FA41A3CA1C0A1F950084430C /* ASTCHandler.h in Headers */, - FADF54041E3D77B500012CC0 /* wrap_Text.h in Headers */, + FADF54041E3D77B500012CC0 /* wrap_TextBatch.h in Headers */, FA0B7ED31A95902C000E1D17 /* wrap_ThreadModule.h in Headers */, FAB922C6257D99EF0035DAD6 /* Range.h in Headers */, FAC756F61E4F99B400B91289 /* Effect.h in Headers */, @@ -4685,7 +4685,7 @@ FA1BA0A31E16D97500AA2803 /* wrap_Font.cpp in Sources */, FABDA9842552448200B5C523 /* b2_chain_polygon_contact.cpp in Sources */, FA0B7E0D1A95902C000E1D17 /* Fixture.cpp in Sources */, - FADF53FE1E3D74F200012CC0 /* Text.cpp in Sources */, + FADF53FE1E3D74F200012CC0 /* TextBatch.cpp in Sources */, FA0B7D191A95902C000E1D17 /* TrueTypeRasterizer.cpp in Sources */, FAC271E723B5B5B400C200D3 /* renderstate.cpp in Sources */, FA84DE6727791C36002674C6 /* GraphicsReadback.cpp in Sources */, @@ -4705,7 +4705,7 @@ FA0B7CE61A95902C000E1D17 /* wrap_Source.cpp in Sources */, FA9D8DDE1DEF842A002CD881 /* Drawable.cpp in Sources */, FA0B7CCE1A95902C000E1D17 /* Audio.cpp in Sources */, - FADF54031E3D77B500012CC0 /* wrap_Text.cpp in Sources */, + FADF54031E3D77B500012CC0 /* wrap_TextBatch.cpp in Sources */, FA0B7DCB1A95902C000E1D17 /* Keyboard.cpp in Sources */, FA0B7DFB1A95902C000E1D17 /* Body.cpp in Sources */, FA0B7ED21A95902C000E1D17 /* wrap_ThreadModule.cpp in Sources */, @@ -5124,7 +5124,7 @@ FAC7CD781FE35E95006A60C7 /* physfs_platform_qnx.c in Sources */, FA0B7D3C1A95902C000E1D17 /* Texture.cpp in Sources */, FABDA9EB2552448300B5C523 /* b2_collide_circle.cpp in Sources */, - FADF53FD1E3D74F200012CC0 /* Text.cpp in Sources */, + FADF53FD1E3D74F200012CC0 /* TextBatch.cpp in Sources */, FA84DE612778D7F3002674C6 /* SpirvIntrinsics.cpp in Sources */, FAFEB29C28F210550025D7D0 /* unixstream.c in Sources */, FA6A2B741F60B6710074C308 /* ByteData.cpp in Sources */, @@ -5139,7 +5139,7 @@ FA9D8DDD1DEF842A002CD881 /* Drawable.cpp in Sources */, FA0B7DFA1A95902C000E1D17 /* Body.cpp in Sources */, FAF6C9EB23C2DE2900D7B5BC /* GlslangToSpv.cpp in Sources */, - FADF54021E3D77B500012CC0 /* wrap_Text.cpp in Sources */, + FADF54021E3D77B500012CC0 /* wrap_TextBatch.cpp in Sources */, FA0B7ED11A95902C000E1D17 /* wrap_ThreadModule.cpp in Sources */, FAC7CD7F1FE35E95006A60C7 /* physfs_archiver_wad.c in Sources */, FA0B7EDF1A95902D000E1D17 /* wrap_Touch.cpp in Sources */, diff --git a/src/modules/graphics/Graphics.cpp b/src/modules/graphics/Graphics.cpp index 535f2cac4..9c9f71171 100644 --- a/src/modules/graphics/Graphics.cpp +++ b/src/modules/graphics/Graphics.cpp @@ -30,7 +30,7 @@ #include "ParticleSystem.h" #include "Font.h" #include "Video.h" -#include "Text.h" +#include "TextBatch.h" #include "common/deprecation.h" #include "common/config.h" @@ -439,9 +439,9 @@ Mesh *Graphics::newMesh(const std::vector &attributes, Pr return new Mesh(attributes, drawmode); } -love::graphics::Text *Graphics::newText(graphics::Font *font, const std::vector &text) +love::graphics::TextBatch *Graphics::newTextBatch(graphics::Font *font, const std::vector &text) { - return new Text(font, text); + return new TextBatch(font, text); } love::data::ByteData *Graphics::readbackBuffer(Buffer *buffer, size_t offset, size_t size, data::ByteData *dest, size_t destoffset) diff --git a/src/modules/graphics/Graphics.h b/src/modules/graphics/Graphics.h index a4e391213..e99aaed11 100644 --- a/src/modules/graphics/Graphics.h +++ b/src/modules/graphics/Graphics.h @@ -58,7 +58,7 @@ namespace graphics class SpriteBatch; class ParticleSystem; -class Text; +class TextBatch; class Video; class Buffer; @@ -460,7 +460,7 @@ public: Mesh *newMesh(const std::vector &vertexformat, const void *data, size_t datasize, PrimitiveType drawmode, BufferDataUsage usage); Mesh *newMesh(const std::vector &attributes, PrimitiveType drawmode); - Text *newText(Font *font, const std::vector &text = {}); + TextBatch *newTextBatch(Font *font, const std::vector &text = {}); data::ByteData *readbackBuffer(Buffer *buffer, size_t offset, size_t size, data::ByteData *dest, size_t destoffset); GraphicsReadback *readbackBufferAsync(Buffer *buffer, size_t offset, size_t size, data::ByteData *dest, size_t destoffset); diff --git a/src/modules/graphics/Text.cpp b/src/modules/graphics/TextBatch.cpp similarity index 88% rename from src/modules/graphics/Text.cpp rename to src/modules/graphics/TextBatch.cpp index b05eac6bf..23a17b5ad 100644 --- a/src/modules/graphics/Text.cpp +++ b/src/modules/graphics/TextBatch.cpp @@ -18,7 +18,7 @@ * 3. This notice may not be removed or altered from any source distribution. **/ -#include "Text.h" +#include "TextBatch.h" #include "Graphics.h" #include @@ -28,9 +28,9 @@ namespace love namespace graphics { -love::Type Text::type("Text", &Drawable::type); +love::Type TextBatch::type("TextBatch", &Drawable::type); -Text::Text(Font *font, const std::vector &text) +TextBatch::TextBatch(Font *font, const std::vector &text) : font(font) , vertexAttributes(Font::vertexFormat, 0) , vertexData(nullptr) @@ -41,13 +41,13 @@ Text::Text(Font *font, const std::vector &text) set(text); } -Text::~Text() +TextBatch::~TextBatch() { if (vertexData != nullptr) free(vertexData); } -void Text::uploadVertices(const std::vector &vertices, size_t vertoffset) +void TextBatch::uploadVertices(const std::vector &vertices, size_t vertoffset) { size_t offset = vertoffset * sizeof(Font::GlyphVertex); size_t datasize = vertices.size() * sizeof(Font::GlyphVertex); @@ -90,7 +90,7 @@ void Text::uploadVertices(const std::vector &vertices, size_t } } -void Text::regenerateVertices() +void TextBatch::regenerateVertices() { // If the font's texture cache was invalidated then we need to recreate the // text's vertices, since glyph texcoords might have changed. @@ -107,7 +107,7 @@ void Text::regenerateVertices() } } -void Text::addTextData(const TextData &t) +void TextBatch::addTextData(const TextData &t) { std::vector vertices; std::vector newcommands; @@ -172,12 +172,12 @@ void Text::addTextData(const TextData &t) regenerateVertices(); } -void Text::set(const std::vector &text) +void TextBatch::set(const std::vector &text) { return set(text, -1.0f, Font::ALIGN_MAX_ENUM); } -void Text::set(const std::vector &text, float wrap, Font::AlignMode align) +void TextBatch::set(const std::vector &text, float wrap, Font::AlignMode align) { if (text.empty() || (text.size() == 1 && text[0].str.empty())) return clear(); @@ -188,12 +188,12 @@ void Text::set(const std::vector &text, float wrap, Font::A addTextData({codepoints, wrap, align, {}, false, false, Matrix4()}); } -int Text::add(const std::vector &text, const Matrix4 &m) +int TextBatch::add(const std::vector &text, const Matrix4 &m) { return addf(text, -1.0f, Font::ALIGN_MAX_ENUM, m); } -int Text::addf(const std::vector &text, float wrap, Font::AlignMode align, const Matrix4 &m) +int TextBatch::addf(const std::vector &text, float wrap, Font::AlignMode align, const Matrix4 &m) { Font::ColoredCodepoints codepoints; Font::getCodepointsFromString(text, codepoints); @@ -203,7 +203,7 @@ int Text::addf(const std::vector &text, float wrap, Font::A return (int) textData.size() - 1; } -void Text::clear() +void TextBatch::clear() { textData.clear(); drawCommands.clear(); @@ -211,7 +211,7 @@ void Text::clear() vertOffset = 0; } -void Text::setFont(Font *f) +void TextBatch::setFont(Font *f) { font.set(f); @@ -221,12 +221,12 @@ void Text::setFont(Font *f) regenerateVertices(); } -Font *Text::getFont() const +Font *TextBatch::getFont() const { return font.get(); } -int Text::getWidth(int index) const +int TextBatch::getWidth(int index) const { if (index < 0) index = std::max((int) textData.size() - 1, 0); @@ -237,7 +237,7 @@ int Text::getWidth(int index) const return textData[index].textInfo.width; } -int Text::getHeight(int index) const +int TextBatch::getHeight(int index) const { if (index < 0) index = std::max((int) textData.size() - 1, 0); @@ -248,7 +248,7 @@ int Text::getHeight(int index) const return textData[index].textInfo.height; } -void Text::draw(Graphics *gfx, const Matrix4 &m) +void TextBatch::draw(Graphics *gfx, const Matrix4 &m) { if (vertexBuffer == nullptr || vertexData == nullptr || drawCommands.empty()) return; diff --git a/src/modules/graphics/Text.h b/src/modules/graphics/TextBatch.h similarity index 95% rename from src/modules/graphics/Text.h rename to src/modules/graphics/TextBatch.h index d41af1857..ec466827c 100644 --- a/src/modules/graphics/Text.h +++ b/src/modules/graphics/TextBatch.h @@ -34,14 +34,14 @@ namespace graphics class Graphics; -class Text : public Drawable +class TextBatch : public Drawable { public: static love::Type type; - Text(Font *font, const std::vector &text = {}); - virtual ~Text(); + TextBatch(Font *font, const std::vector &text = {}); + virtual ~TextBatch(); void set(const std::vector &text); void set(const std::vector &text, float wrap, Font::AlignMode align); diff --git a/src/modules/graphics/wrap_Graphics.cpp b/src/modules/graphics/wrap_Graphics.cpp index d3eb49432..76d6a3e64 100644 --- a/src/modules/graphics/wrap_Graphics.cpp +++ b/src/modules/graphics/wrap_Graphics.cpp @@ -2101,21 +2101,21 @@ int w_newMesh(lua_State *L) return 1; } -int w_newText(lua_State *L) +int w_newTextBatch(lua_State *L) { luax_checkgraphicscreated(L); graphics::Font *font = luax_checkfont(L, 1); - Text *t = nullptr; + TextBatch *t = nullptr; if (lua_isnoneornil(L, 2)) - luax_catchexcept(L, [&](){ t = instance()->newText(font); }); + luax_catchexcept(L, [&](){ t = instance()->newTextBatch(font); }); else { std::vector text; luax_checkcoloredstring(L, 2, text); - luax_catchexcept(L, [&](){ t = instance()->newText(font, text); }); + luax_catchexcept(L, [&](){ t = instance()->newTextBatch(font, text); }); } luax_pushtype(L, t); @@ -2123,6 +2123,12 @@ int w_newText(lua_State *L) return 1; } +int w_newText(lua_State *L) +{ + luax_markdeprecated(L, 1, "love.graphics.newText", API_FUNCTION, DEPRECATED_RENAMED, "love.graphics.newTextBatch"); + return w_newTextBatch(L); +} + int w_newVideo(lua_State *L) { luax_checkgraphicscreated(L); @@ -3769,7 +3775,7 @@ static const luaL_Reg functions[] = { "newVertexBuffer", w_newVertexBuffer }, { "newIndexBuffer", w_newIndexBuffer }, { "newMesh", w_newMesh }, - { "newText", w_newText }, + { "newTextBatch", w_newTextBatch }, { "_newVideo", w_newVideo }, { "readbackBuffer", w_readbackBuffer }, @@ -3895,6 +3901,7 @@ static const luaL_Reg functions[] = { "newArrayImage", w_newArrayImage }, { "newVolumeImage", w_newVolumeImage }, { "newCubeImage", w_newCubeImage }, + { "newText", w_newText }, { "getCanvasFormats", w_getCanvasFormats }, { "getImageFormats", w_getImageFormats }, @@ -3919,7 +3926,7 @@ static const lua_CFunction types[] = luaopen_particlesystem, luaopen_shader, luaopen_mesh, - luaopen_text, + luaopen_textbatch, luaopen_video, 0 }; diff --git a/src/modules/graphics/wrap_Graphics.h b/src/modules/graphics/wrap_Graphics.h index a2b9d0b89..fbd3e4026 100644 --- a/src/modules/graphics/wrap_Graphics.h +++ b/src/modules/graphics/wrap_Graphics.h @@ -29,7 +29,7 @@ #include "wrap_ParticleSystem.h" #include "wrap_Shader.h" #include "wrap_Mesh.h" -#include "wrap_Text.h" +#include "wrap_TextBatch.h" #include "wrap_Video.h" #include "wrap_Buffer.h" #include "wrap_GraphicsReadback.h" diff --git a/src/modules/graphics/wrap_Text.cpp b/src/modules/graphics/wrap_TextBatch.cpp similarity index 74% rename from src/modules/graphics/wrap_Text.cpp rename to src/modules/graphics/wrap_TextBatch.cpp index 98ed593d6..d49f12602 100644 --- a/src/modules/graphics/wrap_Text.cpp +++ b/src/modules/graphics/wrap_TextBatch.cpp @@ -18,7 +18,7 @@ * 3. This notice may not be removed or altered from any source distribution. **/ -#include "wrap_Text.h" +#include "wrap_TextBatch.h" #include "wrap_Font.h" #include "math/wrap_Transform.h" @@ -27,14 +27,14 @@ namespace love namespace graphics { -Text *luax_checktext(lua_State *L, int idx) +TextBatch *luax_checktextbatch(lua_State *L, int idx) { - return luax_checktype(L, idx); + return luax_checktype(L, idx); } -int w_Text_set(lua_State *L) +int w_TextBatch_set(lua_State *L) { - Text *t = luax_checktext(L, 1); + TextBatch *t = luax_checktextbatch(L, 1); std::vector newtext; luax_checkcoloredstring(L, 2, newtext); @@ -43,9 +43,9 @@ int w_Text_set(lua_State *L) return 0; } -int w_Text_setf(lua_State *L) +int w_TextBatch_setf(lua_State *L) { - Text *t = luax_checktext(L, 1); + TextBatch *t = luax_checktextbatch(L, 1); float wraplimit = (float) luaL_checknumber(L, 3); @@ -62,9 +62,9 @@ int w_Text_setf(lua_State *L) return 0; } -int w_Text_add(lua_State *L) +int w_TextBatch_add(lua_State *L) { - Text *t = luax_checktext(L, 1); + TextBatch *t = luax_checktextbatch(L, 1); int index = 0; @@ -96,9 +96,9 @@ int w_Text_add(lua_State *L) return 1; } -int w_Text_addf(lua_State *L) +int w_TextBatch_addf(lua_State *L) { - Text *t = luax_checktext(L, 1); + TextBatch *t = luax_checktextbatch(L, 1); int index = 0; @@ -138,72 +138,72 @@ int w_Text_addf(lua_State *L) return 1; } -int w_Text_clear(lua_State *L) +int w_TextBatch_clear(lua_State *L) { - Text *t = luax_checktext(L, 1); + TextBatch *t = luax_checktextbatch(L, 1); luax_catchexcept(L, [&](){ t->clear(); }); return 0; } -int w_Text_setFont(lua_State *L) +int w_TextBatch_setFont(lua_State *L) { - Text *t = luax_checktext(L, 1); + TextBatch *t = luax_checktextbatch(L, 1); Font *f = luax_checktype(L, 2); luax_catchexcept(L, [&](){ t->setFont(f); }); return 0; } -int w_Text_getFont(lua_State *L) +int w_TextBatch_getFont(lua_State *L) { - Text *t = luax_checktext(L, 1); + TextBatch *t = luax_checktextbatch(L, 1); Font *f = t->getFont(); luax_pushtype(L, f); return 1; } -int w_Text_getWidth(lua_State *L) +int w_TextBatch_getWidth(lua_State *L) { - Text *t = luax_checktext(L, 1); + TextBatch *t = luax_checktextbatch(L, 1); int index = (int) luaL_optinteger(L, 2, 0) - 1; lua_pushnumber(L, t->getWidth(index)); return 1; } -int w_Text_getHeight(lua_State *L) +int w_TextBatch_getHeight(lua_State *L) { - Text *t = luax_checktext(L, 1); + TextBatch *t = luax_checktextbatch(L, 1); int index = (int) luaL_optinteger(L, 2, 0) - 1; lua_pushnumber(L, t->getHeight(index)); return 1; } -int w_Text_getDimensions(lua_State *L) +int w_TextBatch_getDimensions(lua_State *L) { - Text *t = luax_checktext(L, 1); + TextBatch *t = luax_checktextbatch(L, 1); int index = (int) luaL_optinteger(L, 2, 0) - 1; lua_pushnumber(L, t->getWidth(index)); lua_pushnumber(L, t->getHeight(index)); return 2; } -static const luaL_Reg w_Text_functions[] = +static const luaL_Reg w_TextBatch_functions[] = { - { "set", w_Text_set }, - { "setf", w_Text_setf }, - { "add", w_Text_add }, - { "addf", w_Text_addf }, - { "clear", w_Text_clear }, - { "setFont", w_Text_setFont }, - { "getFont", w_Text_getFont }, - { "getWidth", w_Text_getWidth }, - { "getHeight", w_Text_getHeight }, - { "getDimensions", w_Text_getDimensions }, + { "set", w_TextBatch_set }, + { "setf", w_TextBatch_setf }, + { "add", w_TextBatch_add }, + { "addf", w_TextBatch_addf }, + { "clear", w_TextBatch_clear }, + { "setFont", w_TextBatch_setFont }, + { "getFont", w_TextBatch_getFont }, + { "getWidth", w_TextBatch_getWidth }, + { "getHeight", w_TextBatch_getHeight }, + { "getDimensions", w_TextBatch_getDimensions }, { 0, 0 } }; -extern "C" int luaopen_text(lua_State *L) +extern "C" int luaopen_textbatch(lua_State *L) { - return luax_register_type(L, &Text::type, w_Text_functions, nullptr); + return luax_register_type(L, &TextBatch::type, w_TextBatch_functions, nullptr); } } // graphics diff --git a/src/modules/graphics/wrap_Text.h b/src/modules/graphics/wrap_TextBatch.h similarity index 89% rename from src/modules/graphics/wrap_Text.h rename to src/modules/graphics/wrap_TextBatch.h index 3295e3fdc..23f16516e 100644 --- a/src/modules/graphics/wrap_Text.h +++ b/src/modules/graphics/wrap_TextBatch.h @@ -20,7 +20,7 @@ #pragma once -#include "Text.h" +#include "TextBatch.h" #include "common/runtime.h" namespace love @@ -28,8 +28,8 @@ namespace love namespace graphics { -Text *luax_checktext(lua_State *L, int idx); -extern "C" int luaopen_text(lua_State *L); +TextBatch *luax_checktextbatch(lua_State *L, int idx); +extern "C" int luaopen_textbatch(lua_State *L); } // graphics } // love