creates a new text node * Dynamically create a new text node. * * @name gui.new_text_node * @param pos [type:vector3|vector4] node position * @param text [type:string] node text * @return node [type:node] new text node */
| 1718 | * @return node [type:node] new text node |
| 1719 | */ |
| 1720 | static int LuaNewTextNode(lua_State* L) |
| 1721 | { |
| 1722 | Point3 pos = GetPositionFromArgumentIndex(L, 1); |
| 1723 | const char* text = luaL_checkstring(L, 2); |
| 1724 | Scene* scene = GuiScriptInstance_Check(L); |
| 1725 | void* font = scene->m_DefaultFont; |
| 1726 | Vector3 size = Vector3(1,1,1); |
| 1727 | if (font != 0x0) |
| 1728 | { |
| 1729 | dmGui::TextMetrics metrics; |
| 1730 | scene->m_Context->m_GetTextMetricsCallback(font, text, 0.0f, false, 1, 0, &metrics); |
| 1731 | size.setX(metrics.m_Width); |
| 1732 | size.setY(metrics.m_MaxAscent + metrics.m_MaxDescent); |
| 1733 | } |
| 1734 | |
| 1735 | return LuaDoNewNode(L, scene, pos, size, NODE_TYPE_TEXT, 0, text, font); |
| 1736 | } |
| 1737 | |
| 1738 | /*# creates a new pie node |
| 1739 | * Dynamically create a new pie node. |
nothing calls this directly
no test coverage detected