aboutsummaryrefslogtreecommitdiff
path: root/src/script
Commit message (Collapse)AuthorAge
* Make get_biome_list() error message more helpfulkwolekr2015-05-28
|
* Add some missing getter functions to the lua APITeTpaAka2015-05-28
| | | | | | | | | | | | | | | | | | | | | | | ObjectRef: get_properties get_armor_groups get_animation get_attach get_bone_position Players: get_physics_override hud_get_hotbar_itemcount hud_get_hotbar_image hud_get_hotbar_selected_image get_sky get_day_night_ratio get_local_animation get_eye_offset Global: minetest.get_gen_notify minetest.get_noiseparams
* Fix Windows build, clean up included headersSmallJoker2015-05-22
| | | | Also fix a startup error caused by s_security.cpp
* Replace instances of std::map<std::string, std::string> with StringMapkwolekr2015-05-19
| | | | | | Also, clean up surrounding code style Replace by-value parameter passing with const refs when possible Fix post-increment of iterators
* Fix null dereference when loading schematic from definition without a ↵kwolekr2015-05-17
| | | | NodeDefManager
* Record MapBlock modification reasons as flags instead of stringskwolekr2015-05-17
| | | | | This improves performance of MapBlock::raiseModified by a factor of 6. Also, clean up mapblock.h a bit and inline small functions.
* SAPI/Noise: Add PerlinNoiseMap:getMapSlice() functionkwolekr2015-05-17
| | | | | | This adds the ability to grab 'slices' of noise calculated by PerlinNoiseMap. Retrieving smaller slices of noise from the computation result as needed optimizes memory usage while maintaining a reasonable amount of CPU overhead.
* Add optional buffer param for bulk data array writes in Luakwolekr2015-05-17
|
* Fix current mod name change missed during rebaseShadowNinja2015-05-16
|
* SAPI: Accept either ARGB8 table or ColorString to specify colorskwolekr2015-05-16
|
* Add core.get_dir_listShadowNinja2015-05-16
|
* Add core.request_insecure_environment()ShadowNinja2015-05-16
|
* Add core.mkdirShadowNinja2015-05-16
|
* Add mod securityShadowNinja2015-05-16
| | | | Due to compatibility concerns, this is temporarily disabled.
* Add push_ARGB8 to script/common/c_converterTeTpaAka2015-05-15
|
* Generalize core.get/set_nametag_color into core.get/set_nametag_attributesTeTpaAka2015-05-15
|
* Add minetest.register_on_punchplayerBrandon2015-05-15
|
* Add get and set functions for the nametag colorTeTpaAka2015-05-15
|
* Fix compiler warning about sign comparisonest312015-05-13
|
* is_player() is no player-only functionest312015-05-12
|
* Make early protocol auth mechanism generic, and add SRPest312015-05-11
| | | | | | | Adds everything needed for SRP (and everything works too), but still deactivated, as protocol v25 init packets aren't final yet. Can be activated by changing the LATEST_PROTOCOL_VERSION header to 25 inside networkprotocol.h.
* Schematics: Add per-node force placement optionkwolekr2015-05-09
|
* Tests: Add schematic unittestskwolekr2015-05-08
| | | | | Improve schematic file-saving interface Add ability to create temporary test files
* Fix missing Y component assignment in check_v3fkwolekr2015-05-08
|
* Remove duplicate lua_getfield() in c_converter.cppKevin Ott2015-05-07
| | | | Fixes #2678
* Schematics: Add indent-with-space option for schematic Lua table serializationkwolekr2015-05-07
|
* NodeResolver: Remove NodeResolveMethodkwolekr2015-05-07
| | | | This simplifies NodeResolver logic and makes some interfaces cleaner.
* Fix error messages for type-checking Lua reading functionsShadowNinja2015-05-06
|
* Add core.find_nodes_with_meta() script APIkwolekr2015-05-05
|
* Ore: Add biomes parameterkwolekr2015-04-20
|
* Add 'persistence' alias for Lua noiseparams and validate more vector parameterskwolekr2015-04-19
|
* Biome API: Add biome-specific river waterparamat2015-04-19
|
* Schematics: Fix core.schematic_create()kwolekr2015-04-17
|
* Switch to check_v3s16 in l_mapgen.cpp and l_vmanip.cpp for type safetykwolekr2015-04-17
|
* Refactor around translatePasswordest312015-04-17
| | | | | | | Change types for passed password from wstring to string, which removes converting back and forth in most cases. Move the narrow_to_wide conversion, where its neccessary, closer to irrlicht. Remove trailing spaces in guiPasswordChange.cpp. Make parameters for translatePassword passed as const reference.
* Biomes: Remove referenced biomes from Decorations on clearkwolekr2015-04-16
|
* Schematics: Refactor NodeResolver and add NodeResolveMethodkwolekr2015-04-16
| | | | | | | | | NodeResolver name lists now belong to the NodeResolver object instead of the associated NodeDefManager. In addition to minimizing unnecessary abstraction and overhead, this move permits NodeResolvers to look up nodes that they had previously set pending for resolution. So far, this functionality has been used in the case of schematics for serialization/deserialization.
* Use std::vector instead of std::set for Environment::getObjectsInsideRadiusLoic Blot2015-04-16
| | | | | We are only iterating sequentially, we don't need a set here Also use a vector reference instead of a copy
* Schematics: Reorganize (de)serialization and add Lua serialization APIkwolekr2015-04-13
|
* Document for api functions that rely on current_modname, that it doesn't ↵est312015-04-08
| | | | work when not loading mods
* Schematics: Prepend mod path to relative schematic filepathskwolekr2015-04-08
|
* Move globals from main.cpp to more sane locationsCraig Robbins2015-04-01
| | | | | | | | | | | | Move debug streams to log.cpp|h Move GUI-related globals to clientlauncher Move g_settings and g_settings_path to settings.cpp|h Move g_menuclouds to clouds.cpp|h Move g_profiler to profiler.cpp|h
* ObjDefManager, Mapgen SAPI: Huge refactoringkwolekr2015-03-31
| | | | | | | - General code cleanup - Unified object creation and loading - Specifying objects in APIs is now orthogonal (i.e. anything can take an ID, name string, or the raw table definition (and automatically registers if present
* GenElementManager: Pass opaque handles to Lua and rename to ObjDefManagerkwolekr2015-03-31
| | | | Add core.clear_registered_schematics() and refactor schematics somewhat
* Fix typoCraig Robbins2015-03-29
|
* Add Lua function get_video_modes() for main menuCraig Robbins2015-03-28
| | | | Also updates and uses porting::getSupportedVideoModes()
* Clean up and tweak build systemShadowNinja2015-03-27
| | | | | | | | | | | | | | | | * Combine client and server man pages. * Update unit test options and available databases in man page. * Add `--worldname` to man page. * Fix a bunch of places where `"Minetest"` was used directly instead of `PROJECT_NAME`. * Disable server build by default on all operating systems. * Make `ENABLE_FREETYPE` not fail if FreeType isn't found. * Enable LevelDB, Redis, and FreeType detection by default. * Remove the `VERSION_PATCH_ORIG` hack. * Add option to search for and use system JSONCPP. * Remove broken LuaJIT version detection. * Rename `DISABLE_LUAJIT` to `ENABLE_LUAJIT`. * Rename `minetest_*` variables in `version.{h,cpp}` to `g_*`. * Clean up style of CMake files.
* lua_api/l_mapgen: generate_ores/decorations: make p1, p2 optionalparamat2015-03-24
|
* Add core.register_schematic() and cache schematics on usekwolekr2015-03-23
|
* Fix minetest.get_craft_recipe functionest312015-03-23
| | | | Previously, calling it resulted in a crash.
ss="hl opt">().Y - (height_total / 2); } else if (VAlign == EGUIA_LOWERRIGHT) { r.UpperLeftCorner.Y = r.LowerRightCorner.Y - height_total; } if (HAlign == EGUIA_LOWERRIGHT) { r.UpperLeftCorner.X = r.LowerRightCorner.X - getTextWidth(); } irr::video::SColor previous_color(255, 255, 255, 255); for (const EnrichedString &str : BrokenText) { if (HAlign == EGUIA_LOWERRIGHT) { r.UpperLeftCorner.X = frameRect.LowerRightCorner.X - font->getDimension(str.c_str()).Width; } //str = colorizeText(BrokenText[i].c_str(), colors, previous_color); //if (!colors.empty()) // previous_color = colors[colors.size() - 1]; #if USE_FREETYPE if (font->getType() == irr::gui::EGFT_CUSTOM) { irr::gui::CGUITTFont *tmp = static_cast<irr::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_