aboutsummaryrefslogtreecommitdiff
path: root/src/genericobject.h
Commit message (Collapse)AuthorAge
* Fix some issues with animations, and allow non-looped animations to be definedMirceaKitsune2015-06-22
|
* Generic CAO cleanups and renames for clarificationest312015-06-20
| | | | | | | | * Use enum for GENERIC_CMD_* * Rename m_attachements to attachement_parent_ids (public member and clearer name) * Rename GENERIC_CMD_SET_ATTACHMENT to GENERIC_CMD_ATTACH_TO * USHRT_MAX + 1 buffer sizes to prevent overflows as @kahrl suggested * Remove unneccessary m_id from GenericCAO (shadowing protected superclass member for no reason) as @kahrl suggested
* Generalize core.get/set_nametag_color into core.get/set_nametag_attributesTeTpaAka2015-05-15
|
* Add get and set functions for the nametag colorTeTpaAka2015-05-15
|
* Add sneak and sneak_glitch to set_physics_override()PilzAdam2013-12-03
|
* Allow modifying movement speed, jump height and gravity per-player via the ↵MirceaKitsune2013-04-05
| | | | Lua API.
* Update Copyright YearsSfan52013-02-24
|
* Change Minetest-c55 to MinetestPilzAdam2013-02-24
|
* Fix Taoki's messed up generic object command idsPerttu Ahola2012-11-29
|
* A bunch of fixesMirceaKitsune2012-11-25
| | | | | | | | | | | | No longer hide players who are dead. With models, a death animation should be used instead Some changes requested by celeron55 Rename a lot of things in the code, and use better lua api function names Minor code corrections Bump protocol version up, since the models / animations / attachments code creates new client<->server messages
* Send animations, bone overrides and attachments in entity initialization. ↵MirceaKitsune2012-11-25
| | | | | | | | | | | | | | | | | | | | Clients no longer have to be near an object when an animation or attachment is set to see the changes, and newly connected clients (or a client that simply renders the object for the first time) will get all of those settings. Therefore, the lua script no longer needs to run every X seconds either, just once per entity. Finish fixing the material color code. But it won't work until MineTest has dynamic lighting... another day another feature. Extra checks for the bone positioning / rotation code Many checks and consistency improvements to the client attachment code Make a separate function for checking if a client object is attached. A more in-depth change will be needed here to fix reading of invalid pointers Use a different method of fetching the parent. Fixes the mass segmentation faults when rendering an attachment (some still happen though) Major change to how attachments are handled. Fix the last segmentaton fault, which was due to the parent becoming invalid while being refreshed / removed which would bause the child to remain attached to nothing. Parents remove their children when being deleted themselves and add them back when re-added. Attachments are stored inside a 2D a vector which easily allows both a child to find their parent and a parent to find its children. Remove attachment list entry when an object is being permanently removed. Also avoid duplicate entries in this list when re-attaching the same object The "big code comments" can now go away. Client attachments almost work properly, and I know what else needs to be done
* Complete the attachment framework.MirceaKitsune2012-11-25
| | | | | | | | | | | | The child ID can now be checked against the parent ID in content_cao.cpp so the parent can be detected. Actual attachment code to come Divide attachment system between server attachments and client attachments, neither coded right now. As explained in the code comment: // Attachments need to be handled on both the server and client. // If we attach only on the server, models (which are client-side) // can't be read so we don't know the origin and orientation of bones. // If we attach only on the client, the real position of attachments is // not updated and you can't click them for example.
* Framework for the attachment system, new object property which allows ↵MirceaKitsune2012-11-25
| | | | | | | | | | | | | | changing the color and alpha of mesh materials New object property which allows changing the color and alpha of mesh materials. Due to the current lighting systems it doesn't work yet, but the full implementation is there Framework for the attachment system, with no actual functionality yet Send bone and player object to the setAttachment function in content_sao.cpp, but we need a way to translate it there and send it to the client I will also want position and rotation offsets to be possible to apply to attachments Network object ID from server to client. This will be used to identify the parent client-side and know what to attach to
* Get the new animation framework properly workingMirceaKitsune2012-11-25
| | | | | | Store start and end frames as v2f Also move bone animations to their own function instead of object properties
* Joint positioning and rotation code, and fix a problem related to their lua APIMirceaKitsune2012-11-25
| | | | Attempt to move the animation system to a more correct implementation, rather than using object properties. Incomplete and breaks functionality
* Optimize headersPerttu Ahola2012-06-17
|
* Switch the license to be LGPLv2/later, with small parts still remaining as ↵Perttu Ahola2012-06-05
| | | | GPLv2/later, by agreement of major contributors
* ObjectPropertiesPerttu Ahola2012-03-30
|
* Use GenericCAO in place of LuaEntityCAO and PlayerCAOPerttu Ahola2012-03-29
hl num">255, 0, 0, 0); } void GameUI::init() { // First line of debug text m_guitext = gui::StaticText::add(guienv, utf8_to_wide(PROJECT_NAME_C).c_str(), core::rect<s32>(0, 0, 0, 0), false, false, guiroot); // Second line of debug text m_guitext2 = gui::StaticText::add(guienv, L"", core::rect<s32>(0, 0, 0, 0), false, false, guiroot); // Chat text m_guitext_chat = gui::StaticText::add(guienv, L"", core::rect<s32>(0, 0, 0, 0), //false, false); // Disable word wrap as of now false, true, guiroot); u16 chat_font_size = g_settings->getU16("chat_font_size"); if (chat_font_size != 0) { m_guitext_chat->setOverrideFont(g_fontengine->getFont( chat_font_size, FM_Unspecified)); } // At the middle of the screen // Object infos are shown in this u32 chat_font_height = m_guitext_chat->getActiveFont()->getDimension(L"Ay").Height; m_guitext_info = gui::StaticText::add(guienv, L"", core::rect<s32>(0, 0, 400, g_fontengine->getTextHeight() * 5 + 5) + v2s32(100, chat_font_height * (g_settings->getU16("recent_chat_messages") + 3)), false, true, guiroot); // Status text (displays info when showing and hiding GUI stuff, etc.) m_guitext_status = gui::StaticText::add(guienv, L"<Status>", core::rect<s32>(0, 0, 0, 0), false, false, guiroot); m_guitext_status->setVisible(false); // Profiler text (size is updated when text is updated) m_guitext_profiler = gui::StaticText::add(guienv, L"<Profiler>", core::rect<s32>(0, 0, 0, 0), false, false, guiroot); m_guitext_profiler->setOverrideFont(g_fontengine->getFont( g_fontengine->getDefaultFontSize() * 0.9f, FM_Mono)); m_guitext_profiler->setVisible(false); } void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_control, const CameraOrientation &cam, const PointedThing &pointed_old, const GUIChatConsole *chat_console, float dtime) { v2u32 screensize = RenderingEngine::get_instance()->getWindowSize(); if (m_flags.show_debug) { static float drawtime_avg = 0; drawtime_avg = drawtime_avg * 0.95 + stats.drawtime * 0.05; u16 fps = 1.0 / stats.dtime_jitter.avg; std::ostringstream os(std::ios_base::binary); os << std::fixed << PROJECT_NAME_C " " << g_version_hash << " | FPS: " << fps << std::setprecision(0) << " | drawtime: " << drawtime_avg << "ms" << std::setprecision(1) << " | dtime jitter: " << (stats.dtime_jitter.max_fraction * 100.0) << "%" << std::setprecision(1) << " | view range: " << (draw_control->range_all ? "All" : itos(draw_control->wanted_range)) << std::setprecision(2) << " | RTT: " << (client->getRTT() * 1000.0f) << "ms"; setStaticText(m_guitext, utf8_to_wide(os.str()).c_str()); m_guitext->setRelativePosition(core::rect<s32>(5, 5, screensize.X, 5 + g_fontengine->getTextHeight())); } // Finally set the guitext visible depending on the flag m_guitext->setVisible(m_flags.show_debug); if (m_flags.show_debug) { LocalPlayer *player = client->getEnv().getLocalPlayer(); v3f player_position = player->getPosition(); std::ostringstream os(std::ios_base::binary); os << std::setprecision(1) << std::fixed << "pos: (" << (player_position.X / BS) << ", " << (player_position.Y / BS) << ", " << (player_position.Z / BS) << ") | yaw: " << (wrapDegrees_0_360(cam.camera_yaw)) << "° " << yawToDirectionString(cam.camera_yaw) << " | pitch: " << (-wrapDegrees_180(cam.camera_pitch)) << "°" << " | seed: " << ((u64)client->getMapSeed()); if (pointed_old.type == POINTEDTHING_NODE) { ClientMap &map = client->getEnv().getClientMap(); const NodeDefManager *nodedef = client->getNodeDefManager(); MapNode n = map.getNode(pointed_old.node_undersurface); if (n.getContent() != CONTENT_IGNORE && nodedef->get(n).name != "unknown") { os << ", pointed: " << nodedef->get(n).name << ", param2: " << (u64) n.getParam2(); } } setStaticText(m_guitext2, utf8_to_wide(os.str()).c_str()); m_guitext2->setRelativePosition(core::rect<s32>(5, 5 + g_fontengine->getTextHeight(), screensize.X, 5 + g_fontengine->getTextHeight() * 2 )); } m_guitext2->setVisible(m_flags.show_debug); setStaticText(m_guitext_info, m_infotext.c_str()); m_guitext_info->setVisible(m_flags.show_hud && g_menumgr.menuCount() == 0); static const float statustext_time_max = 1.5f; if (!m_statustext.empty()) { m_statustext_time += dtime; if (m_statustext_time >= statustext_time_max) { clearStatusText(); m_statustext_time = 0.0f; } } setStaticText(m_guitext_status, m_statustext.c_str()); m_guitext_status->setVisible(!m_statustext.empty()); if (!m_statustext.empty()) { s32 status_width = m_guitext_status->getTextWidth(); s32 status_height = m_guitext_status->getTextHeight(); s32 status_y = screensize.Y - 150; s32 status_x = (screensize.X - status_width) / 2; m_guitext_status->setRelativePosition(core::rect<s32>(status_x , status_y - status_height, status_x + status_width, status_y)); // Fade out video::SColor final_color = m_statustext_initial_color; final_color.setAlpha(0); video::SColor fade_color = m_statustext_initial_color.getInterpolated_quadratic( m_statustext_initial_color, final_color, m_statustext_time / statustext_time_max); m_guitext_status->setOverrideColor(fade_color); m_guitext_status->enableOverrideColor(true); } // Hide chat when console is visible m_guitext_chat->setVisible(isChatVisible() && !chat_console->isVisible()); } void GameUI::initFlags() { m_flags = GameUI::Flags(); m_flags.show_debug = g_settings->getBool("show_debug"); } void GameUI::showMinimap(bool show) { m_flags.show_minimap = show; } void GameUI::showTranslatedStatusText(const char *str) { const wchar_t *wmsg = wgettext(str); showStatusText(wmsg); delete[] wmsg; } void GameUI::setChatText(const EnrichedString &chat_text, u32 recent_chat_count) { // Update gui element size and position s32 chat_y = 5; if (m_flags.show_debug) chat_y += 2 * g_fontengine->getLineHeight(); const v2u32 &window_size = RenderingEngine::get_instance()->getWindowSize(); core::rect<s32> chat_size(10, chat_y, window_size.X - 20, 0); chat_size.LowerRightCorner.Y = std::min((s32)window_size.Y, m_guitext_chat->getTextHeight() + chat_y); m_guitext_chat->setRelativePosition(chat_size); setStaticText(m_guitext_chat, chat_text); m_recent_chat_count = recent_chat_count; } void GameUI::updateProfiler() { if (m_profiler_current_page != 0) { std::ostringstream os(std::ios_base::binary); os << " Profiler page " << (int)m_profiler_current_page << ", elapsed: " << g_profiler->getElapsedMs() << " ms)" << std::endl; int lines = g_profiler->print(os, m_profiler_current_page, m_profiler_max_page); ++lines; EnrichedString str(utf8_to_wide(os.str())); str.setBackground(video::SColor(120, 0, 0, 0)); setStaticText(m_guitext_profiler, str); core::dimension2d<u32> size = m_guitext_profiler->getOverrideFont()-> getDimension(str.c_str()); core::position2di upper_left(6, 50); core::position2di lower_right = upper_left; lower_right.X += size.Width + 10; lower_right.Y += size.Height; m_guitext_profiler->setRelativePosition(core::rect<s32>(upper_left, lower_right)); } m_guitext_profiler->setVisible(m_profiler_current_page != 0); } void GameUI::toggleChat() { m_flags.show_chat = !m_flags.show_chat; if (m_flags.show_chat) showTranslatedStatusText("Chat shown"); else showTranslatedStatusText("Chat hidden"); } void GameUI::toggleHud() { m_flags.show_hud = !m_flags.show_hud; if (m_flags.show_hud) showTranslatedStatusText("HUD shown"); else showTranslatedStatusText("HUD hidden"); } void GameUI::toggleProfiler() { m_profiler_current_page = (m_profiler_current_page + 1) % (m_profiler_max_page + 1); // FIXME: This updates the profiler with incomplete values updateProfiler(); if (m_profiler_current_page != 0) { wchar_t buf[255]; const wchar_t* str = wgettext("Profiler shown (page %d of %d)"); swprintf(buf, sizeof(buf) / sizeof(wchar_t), str, m_profiler_current_page, m_profiler_max_page); delete[] str; showStatusText(buf); } else { showTranslatedStatusText("Profiler hidden"); } } void GameUI::deleteFormspec() { if (m_formspec) { m_formspec->drop(); m_formspec = nullptr; } m_formname.clear(); }