aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api
ModeNameSize
-rw-r--r--CMakeLists.txt859logplain
-rw-r--r--l_areastore.cpp9080logplain
-rw-r--r--l_areastore.h1868logplain
-rw-r--r--l_base.cpp2000logplain
-rw-r--r--l_base.h1906logplain
-rw-r--r--l_craft.cpp11763logplain
-rw-r--r--l_craft.h1592logplain
-rw-r--r--l_env.cpp25564logplain
-rw-r--r--l_env.h6343logplain
-rw-r--r--l_internal.h2124logplain
-rw-r--r--l_inventory.cpp13417logplain
-rw-r--r--l_inventory.h3980logplain
-rw-r--r--l_item.cpp14740logplain
-rw-r--r--l_item.h4330logplain
-rw-r--r--l_mainmenu.cpp30953logplain
-rw-r--r--l_mainmenu.h4007logplain
-rw-r--r--l_mapgen.cpp35601logplain
-rw-r--r--l_mapgen.h3493logplain
-rw-r--r--l_nodemeta.cpp9041logplain
-rw-r--r--l_nodemeta.h3014logplain
-rw-r--r--l_nodetimer.cpp4451logplain
-rw-r--r--l_nodetimer.h1773logplain
-rw-r--r--l_noise.cpp15532logplain
-rw-r--r--l_noise.h4590logplain
-rw-r--r--l_object.cpp44629logplain
-rw-r--r--l_object.h8150logplain
-rw-r--r--l_particles.cpp7099logplain
-rw-r--r--l_particles.h1148logplain
-rw-r--r--l_rollback.cpp3552logplain
-rw-r--r--l_rollback.h1278logplain
-rw-r--r--l_server.cpp13620logplain
-rw-r--r--l_server.h2904logplain
-rw-r--r--l_settings.cpp5319logplain
-rw-r--r--l_settings.h1868logplain
-rw-r--r--l_util.cpp10031logplain
-rw-r--r--l_util.h2826logplain
-rw-r--r--l_vmanip.cpp10621logplain
-rw-r--r--l_vmanip.h2274logplain
an> #include "guiChatConsole.h" #include "chat.h" #include "client.h" #include "debug.h" #include "gettime.h" #include "keycode.h" #include "settings.h" #include "main.h" // for g_settings #include "porting.h" #include "tile.h" #include "IGUIFont.h" #include <string> #include "gettext.h" #if USE_FREETYPE #include "xCGUITTFont.h" #endif inline u32 clamp_u8(s32 value) { return (u32) MYMIN(MYMAX(value, 0), 255); } GUIChatConsole::GUIChatConsole( gui::IGUIEnvironment* env, gui::IGUIElement* parent, s32 id, ChatBackend* backend, Client* client ): IGUIElement(gui::EGUIET_ELEMENT, env, parent, id, core::rect<s32>(0,0,100,100)), m_chat_backend(backend), m_client(client), m_screensize(v2u32(0,0)), m_animate_time_old(0), m_open(false), m_height(0), m_desired_height(0), m_desired_height_fraction(0.0), m_height_speed(5.0), m_open_inhibited(0), m_cursor_blink(0.0), m_cursor_blink_speed(0.0), m_cursor_height(0.0), m_background(NULL), m_background_color(255, 0, 0, 0), m_font(NULL), m_fontsize(0, 0) { m_animate_time_old = getTimeMs(); // load background settings bool console_color_set = !g_settings->get("console_color").empty(); s32 console_alpha = g_settings->getS32("console_alpha"); // load the background texture depending on settings m_background_color.setAlpha(clamp_u8(console_alpha)); if (console_color_set) { v3f console_color = g_settings->getV3F("console_color"); m_background_color.setRed(clamp_u8(myround(console_color.X))); m_background_color.setGreen(clamp_u8(myround(console_color.Y))); m_background_color.setBlue(clamp_u8(myround(console_color.Z))); } else { m_background = env->getVideoDriver()->getTexture(getTexturePath("background_chat.jpg").c_str()); m_background_color.setRed(255); m_background_color.setGreen(255); m_background_color.setBlue(255); } // load the font // FIXME should a custom texture_path be searched too? std::string font_name = g_settings->get("mono_font_path"); #if USE_FREETYPE m_use_freetype = g_settings->getBool("freetype"); if (m_use_freetype) { u16 font_size = g_settings->getU16("mono_font_size"); m_font = gui::CGUITTFont::createTTFont(env, font_name.c_str(), font_size); } else { m_font = env->getFont(font_name.c_str()); } #else m_font = env->getFont(font_name.c_str()); #endif if (m_font == NULL) { dstream << "Unable to load font: " << font_name << std::endl; } else { core::dimension2d<u32> dim = m_font->getDimension(L"M"); m_fontsize = v2u32(dim.Width, dim.Height); dstream << "Font size: " << m_fontsize.X << " " << m_fontsize.Y << std::endl; } m_fontsize.X = MYMAX(m_fontsize.X, 1); m_fontsize.Y = MYMAX(m_fontsize.Y, 1); // set default cursor options setCursor(true, true, 2.0, 0.1); } GUIChatConsole::~GUIChatConsole() { #if USE_FREETYPE if (m_use_freetype) m_font->drop(); #endif } void GUIChatConsole::openConsole(f32 height) { m_open = true; m_desired_height_fraction = height; m_desired_height = height * m_screensize.Y; reformatConsole(); } bool GUIChatConsole::isOpen() const { return m_open; } bool GUIChatConsole::isOpenInhibited() const { return m_open_inhibited > 0; } void GUIChatConsole::closeConsole() { m_open = false; } void GUIChatConsole::closeConsoleAtOnce() { m_open = false; m_height = 0; recalculateConsolePosition(); } f32 GUIChatConsole::getDesiredHeight() const { return m_desired_height_fraction; } void GUIChatConsole::setCursor( bool visible, bool blinking, f32 blink_speed, f32 relative_height) { if (visible) { if (blinking) { // leave m_cursor_blink unchanged m_cursor_blink_speed = blink_speed; } else { m_cursor_blink = 0x8000; // on m_cursor_blink_speed = 0.0; } } else { m_cursor_blink = 0; // off m_cursor_blink_speed = 0.0; } m_cursor_height = relative_height; } void GUIChatConsole::draw() { if(!IsVisible) return; video::IVideoDriver* driver = Environment->getVideoDriver(); // Check screen size v2u32 screensize = driver->getScreenSize(); if (screensize != m_screensize) { // screen size has changed // scale current console height to new window size if (m_screensize.Y != 0) m_height = m_height * screensize.Y / m_screensize.Y; m_desired_height = m_desired_height_fraction * m_screensize.Y; m_screensize = screensize; reformatConsole(); } // Animation u32 now = getTimeMs();