/html; charset=UTF-8 Last-Modified: Sat, 21 Nov 2026 20:18:34 GMT Expires: Tue, 18 Nov 2036 20:18:34 GMT lua_api « script « src - minetest.git - modified minetest for gpcfs purposes
aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
ModeNameSize
-rw-r--r--CMakeLists.txt1476logplain
-rw-r--r--l_areastore.cpp9106logplain
-rw-r--r--l_areastore.h1764logplain
-rw-r--r--l_auth.cpp5592logplain
-rw-r--r--l_auth.h1497logplain
-rw-r--r--l_base.cpp3836logplain
-rw-r--r--l_base.h2737logplain
-rw-r--r--l_camera.cpp5767logplain
-rw-r--r--l_camera.h1730logplain
-rw-r--r--l_client.cpp10728logplain
-rw-r--r--l_client.h2853logplain
-rw-r--r--l_craft.cpp14465logplain
-rw-r--r--l_craft.h1583logplain
-rw-r--r--l_env.cpp37159logplain
-rw-r--r--l_env.h8893logplain
-rw-r--r--l_http.cpp6983logplain
-rw-r--r--l_http.h1687logplain
-rw-r--r--l_internal.h3047logplain
-rw-r--r--l_inventory.cpp14161logplain
-rw-r--r--l_inventory.h3798logplain
-rw-r--r--l_item.cpp17488logplain
-rw-r--r--l_item.h4660logplain
-rw-r--r--l_itemstackmeta.cpp3925logplain
-rw-r--r--l_itemstackmeta.h2007logplain
-rw-r--r--l_localplayer.cpp11400logplain
-rw-r--r--l_localplayer.h3091logplain
-rw-r--r--l_mainmenu.cpp26677logplain
-rw-r--r--l_mainmenu.h4174logplain
-rw-r--r--l_mapgen.cpp48391logplain
-rw-r--r--l_mapgen.h4763logplain
-rw-r--r--l_metadata.cpp6930logplain
-rw-r--r--l_metadata.h2134logplain
-rw-r--r--l_minimap.cpp5324logplain
-rw-r--r--l_minimap.h1673logplain
-rw-r--r--l_modchannels.cpp3863logplain
-rw-r--r--l_modchannels.h1749logplain
-rw-r--r--l_nodemeta.cpp7318logplain
-rw-r--r--l_nodemeta.h3083logplain
-rw-r--r--l_nodetimer.cpp3821logplain
-rw-r--r--l_nodetimer.h1672logplain
-rw-r--r--l_noise.cpp15781logplain
-rw-r--r--l_noise.h4547logplain
-rw-r--r--l_object.cpp61757logplain
-rw-r--r--l_object.h9684logplain
-rw-r--r--l_particles.cpp8203logplain
-rw-r--r--l_particles.h1084logplain
-rw-r--r--l_particles_local.cpp5439logplain
-rw-r--r--l_particles_local.h1137logplain
-rw-r--r--l_playermeta.cpp3334logplain
-rw-r--r--l_playermeta.h1735logplain
-rw-r--r--l_rollback.cpp3552logplain
-rw-r--r--l_rollback.h1219logplain
-rw-r--r--l_server.cpp14366logplain
-rw-r--r--l_server.h3054logplain
-rw-r--r--l_settings.cpp8149logplain
-rw-r--r--l_settings.h2426logplain
-rw-r--r--l_sound.cpp1434logplain
-rw-r--r--l_sound.h1086logplain
-rw-r--r--l_storage.cpp3977logplain
-rw-r--r--l_storage.h1647logplain
-rw-r--r--l_util.cpp13223logplain
-rw-r--r--l_util.h3034logplain
-rw-r--r--l_vmanip.cpp11028logplain
-rw-r--r--l_vmanip.h2239logplain
ass="hl kwc">gui::CGUITTFont*>(font); tmp->draw(str, r, previous_color, // FIXME HAlign == EGUIA_CENTER, VAlign == EGUIA_CENTER, (RestrainTextInside ? &AbsoluteClippingRect : NULL)); } else #endif { // Draw non-colored text font->draw(str.c_str(), r, str.getDefaultColor(), // TODO: Implement colorization HAlign == EGUIA_CENTER, VAlign == EGUIA_CENTER, (RestrainTextInside ? &AbsoluteClippingRect : NULL)); } r.LowerRightCorner.Y += height_line; r.UpperLeftCorner.Y += height_line; } } IGUIElement::draw(); } //! Sets another skin independent font. void StaticText::setOverrideFont(IGUIFont* font) { if (OverrideFont == font) return; if (OverrideFont) OverrideFont->drop(); OverrideFont = font; if (OverrideFont) OverrideFont->grab(); updateText(); } //! Gets the override font (if any) IGUIFont * StaticText::getOverrideFont() const { return OverrideFont; } //! Get the font which is used right now for drawing IGUIFont* StaticText::getActiveFont() const { if ( OverrideFont ) return OverrideFont; IGUISkin* skin = Environment->getSkin(); if (skin) return skin->getFont(); return 0; } //! Sets another color for the text. void StaticText::setOverrideColor(video::SColor color) { ColoredText.setDefaultColor(color); updateText(); } //! Sets another color for the text. void StaticText::setBackgroundColor(video::SColor color) { ColoredText.setBackground(color); Background = true; } //! Sets whether to draw the background void StaticText::setDrawBackground(bool draw) { Background = draw; } //! Gets the background color video::SColor StaticText::getBackgroundColor() const { IGUISkin *skin = Environment->getSkin(); return (ColoredText.hasBackground() || !skin) ? ColoredText.getBackground() : skin->getColor(gui::EGDC_3D_FACE); } //! Checks if background drawing is enabled bool StaticText::isDrawBackgroundEnabled() const { return Background; } //! Sets whether to draw the border void StaticText::setDrawBorder(bool draw) { Border = draw; } //! Checks if border drawing is enabled bool StaticText::isDrawBorderEnabled() const { return Border; } void StaticText::setTextRestrainedInside(bool restrainTextInside) { RestrainTextInside = restrainTextInside; } bool StaticText::isTextRestrainedInside() const { return RestrainTextInside; } void StaticText::setTextAlignment(EGUI_ALIGNMENT horizontal, EGUI_ALIGNMENT vertical) { HAlign = horizontal; VAlign = vertical; } #if IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR <= 7 const video::SColor& StaticText::getOverrideColor() const #else video::SColor StaticText::getOverrideColor() const #endif { return ColoredText.getDefaultColor(); } //! Sets if the static text should use the overide color or the //! color in the gui skin. void StaticText::enableOverrideColor(bool enable) { // TODO } bool StaticText::isOverrideColorEnabled() const { return true; } //! Enables or disables word wrap for using the static text as //! multiline text control. void StaticText::setWordWrap(bool enable) { WordWrap = enable; updateText(); } bool StaticText::isWordWrapEnabled() const { return WordWrap; } void StaticText::setRightToLeft(bool rtl) { if (RightToLeft != rtl) { RightToLeft = rtl; updateText(); } } bool StaticText::isRightToLeft() const { return RightToLeft; } //! Breaks the single text line. // Updates the font colors void StaticText::updateText() { const EnrichedString &cText = ColoredText; BrokenText.clear(); if (cText.hasBackground()) setBackgroundColor(cText.getBackground()); else setDrawBackground(false); if (!WordWrap) { BrokenText.push_back(cText); return; } // Update word wrap IGUISkin* skin = Environment->getSkin(); IGUIFont* font = getActiveFont(); if (!font) return; LastBreakFont = font; EnrichedString line; EnrichedString word; EnrichedString whitespace; s32 size = cText.size(); s32 length = 0; s32 elWidth = RelativeRect.getWidth(); if (Border) elWidth -= 2*skin->getSize(EGDS_TEXT_DISTANCE_X); wchar_t c; //std::vector<irr::video::SColor> colors; // We have to deal with right-to-left and left-to-right differently // However, most parts of the following code is the same, it's just // some order and boundaries which change. if (!RightToLeft) { // regular (left-to-right) for (s32 i=0; i<size; ++i) { c = cText.getString()[i]; bool lineBreak = false; if (c == L'\r') // Mac or Windows breaks { lineBreak = true; //if (Text[i+1] == L'\n') // Windows breaks //{ // Text.erase(i+1); // --size; //} c = '\0'; } else if (c == L'\n') // Unix breaks { lineBreak = true; c = '\0'; } bool isWhitespace = (c == L' ' || c == 0); if ( !isWhitespace ) { // part of a word //word += c; word.addChar(cText, i); } if ( isWhitespace || i == (size-1)) { if (word.size()) { // here comes the next whitespace, look if // we must break the last word to the next line. const s32 whitelgth = font->getDimension(whitespace.c_str()).Width; //const std::wstring sanitized = removeEscapes(word.c_str()); const s32 wordlgth = font->getDimension(word.c_str()).Width; if (wordlgth > elWidth) { // This word is too long to fit in the available space, look for // the Unicode Soft HYphen (SHY / 00AD) character for a place to // break the word at int where = core::stringw(word.c_str()).findFirst( wchar_t(0x00AD) ); if (where != -1) { EnrichedString first = word.substr(0, where); EnrichedString second = word.substr(where, word.size() - where); first.addCharNoColor(L'-'); BrokenText.push_back(line + first); const s32 secondLength = font->getDimension(second.c_str()).Width; length = secondLength; line = second; } else { // No soft hyphen found, so there's nothing more we can do // break to next line if (length) BrokenText.push_back(line); length = wordlgth; line = word; } } else if (length && (length + wordlgth + whitelgth > elWidth)) { // break to next line BrokenText.push_back(line); length = wordlgth; line = word; } else { // add word to line line += whitespace; line += word; length += whitelgth + wordlgth; } word.clear(); whitespace.clear(); } if ( isWhitespace && c != 0) { whitespace.addChar(cText, i); } // compute line break if (lineBreak) { line += whitespace; line += word; BrokenText.push_back(line); line.clear(); word.clear(); whitespace.clear(); length = 0; } } } line += whitespace; line += word; BrokenText.push_back(line); } else { // right-to-left for (s32 i=size; i>=0; --i) { c = cText.getString()[i]; bool lineBreak = false; if (c == L'\r') // Mac or Windows breaks { lineBreak = true; //if ((i>0) && Text[i-1] == L'\n') // Windows breaks //{ // Text.erase(i-1); // --size; //} c = '\0'; } else if (c == L'\n') // Unix breaks { lineBreak = true; c = '\0'; } if (c==L' ' || c==0 || i==0) { if (word.size()) { // here comes the next whitespace, look if // we must break the last word to the next line. const s32 whitelgth = font->getDimension(whitespace.c_str()).Width; const s32 wordlgth = font->getDimension(word.c_str()).Width; if (length && (length + wordlgth + whitelgth > elWidth)) { // break to next line BrokenText.push_back(line); length = wordlgth; line = word; } else { // add word to line line = whitespace + line; line = word + line; length += whitelgth + wordlgth; } word.clear(); whitespace.clear(); } if (c != 0) // whitespace = core::stringw(&c, 1) + whitespace; whitespace = cText.substr(i, 1) + whitespace; // compute line break if (lineBreak) { line = whitespace + line; line = word + line; BrokenText.push_back(line); line.clear(); word.clear(); whitespace.clear(); length = 0; } } else { // yippee this is a word.. //word = core::stringw(&c, 1) + word; word = cText.substr(i, 1) + word; } } line = whitespace + line; line = word + line; BrokenText.push_back(line); } } //! Sets the new caption of this element. void StaticText::setText(const wchar_t* text) { setText(EnrichedString(text, getOverrideColor())); } void StaticText::setText(const EnrichedString &text) { ColoredText = text; IGUIElement::setText(ColoredText.c_str()); updateText(); } void StaticText::updateAbsolutePosition() { IGUIElement::updateAbsolutePosition(); updateText(); } //! Returns the height of the text in pixels when it is drawn. s32 StaticText::getTextHeight() const { IGUIFont* font = getActiveFont(); if (!font) return 0; if (WordWrap) { s32 height = font->getDimension(L"A").Height + font->getKerningHeight(); return height * BrokenText.size(); } // There may be intentional new lines without WordWrap return font->getDimension(BrokenText[0].c_str()).Height; } s32 StaticText::getTextWidth() const { IGUIFont *font = getActiveFont(); if (!font) return 0; s32 widest = 0; for (const EnrichedString &line : BrokenText) { s32 width = font->getDimension(line.c_str()).Width; if (width > widest) widest = width; } return widest; } //! Writes attributes of the element. //! Implement this to expose the attributes of your element for //! scripting languages, editors, debuggers or xml serialization purposes. void StaticText::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const { IGUIStaticText::serializeAttributes(out,options); out->addBool ("Border", Border); out->addBool ("OverrideColorEnabled",true); out->addBool ("OverrideBGColorEnabled",ColoredText.hasBackground()); out->addBool ("WordWrap", WordWrap); out->addBool ("Background", Background); out->addBool ("RightToLeft", RightToLeft); out->addBool ("RestrainTextInside", RestrainTextInside); out->addColor ("OverrideColor", ColoredText.getDefaultColor()); out->addColor ("BGColor", ColoredText.getBackground()); out->addEnum ("HTextAlign", HAlign, GUIAlignmentNames); out->addEnum ("VTextAlign", VAlign, GUIAlignmentNames); // out->addFont ("OverrideFont", OverrideFont); } //! Reads attributes of the element void StaticText::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0) { IGUIStaticText::deserializeAttributes(in,options); Border = in->getAttributeAsBool("Border"); setWordWrap(in->getAttributeAsBool("WordWrap")); Background = in->getAttributeAsBool("Background"); RightToLeft = in->getAttributeAsBool("RightToLeft"); RestrainTextInside = in->getAttributeAsBool("RestrainTextInside"); if (in->getAttributeAsBool("OverrideColorEnabled")) ColoredText.setDefaultColor(in->getAttributeAsColor("OverrideColor")); if (in->getAttributeAsBool("OverrideBGColorEnabled")) ColoredText.setBackground(in->getAttributeAsColor("BGColor")); setTextAlignment( (EGUI_ALIGNMENT) in->getAttributeAsEnumeration("HTextAlign", GUIAlignmentNames), (EGUI_ALIGNMENT) in->getAttributeAsEnumeration("VTextAlign", GUIAlignmentNames)); // OverrideFont = in->getAttributeAsFont("OverrideFont"); } } // end namespace gui #endif // USE_FREETYPE } // end namespace irr #endif // _IRR_COMPILE_WITH_GUI_