aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/content_cao.cpp3
-rw-r--r--src/content_sao.cpp4
-rw-r--r--src/genericobject.cpp5
-rw-r--r--src/genericobject.h4
-rw-r--r--src/script/lua_api/l_object.cpp21
-rw-r--r--src/script/lua_api/l_object.h8
6 files changed, 25 insertions, 20 deletions
diff --git a/src/content_cao.cpp b/src/content_cao.cpp
index 5bf4d8e9c..fe560a41a 100644
--- a/src/content_cao.cpp
+++ b/src/content_cao.cpp
@@ -1715,7 +1715,8 @@ void GenericCAO::processMessage(const std::string &data)
int rating = readS16(is);
m_armor_groups[name] = rating;
}
- } else if (cmd == GENERIC_CMD_SET_NAMETAG_COLOR) {
+ } else if (cmd == GENERIC_CMD_UPDATE_NAMETAG_ATTRIBUTES) {
+ u8 version = readU8(is); // forward compatibility
m_nametag_color = readARGB8(is);
if (m_textnode != NULL) {
m_textnode->setTextColor(m_nametag_color);
diff --git a/src/content_sao.cpp b/src/content_sao.cpp
index c7f4b60c7..1f7323c9c 100644
--- a/src/content_sao.cpp
+++ b/src/content_sao.cpp
@@ -814,7 +814,7 @@ std::string PlayerSAO::getClientInitializationData(u16 protocol_version)
os<<serializeLongString(gob_cmd_update_physics_override(m_physics_override_speed,
m_physics_override_jump, m_physics_override_gravity, m_physics_override_sneak,
m_physics_override_sneak_glitch)); // 5
- os << serializeLongString(gob_cmd_set_nametag_color(m_nametag_color)); // 6
+ os << serializeLongString(gob_cmd_update_nametag_attributes(m_nametag_color)); // 6
}
else
{
@@ -971,7 +971,7 @@ void PlayerSAO::step(float dtime, bool send_recommended)
if (m_nametag_sent == false) {
m_nametag_sent = true;
- std::string str = gob_cmd_set_nametag_color(m_nametag_color);
+ std::string str = gob_cmd_update_nametag_attributes(m_nametag_color);
// create message and add to list
ActiveObjectMessage aom(getId(), true, str);
m_messages_out.push(aom);
diff --git a/src/genericobject.cpp b/src/genericobject.cpp
index 1f4f59e92..78dc7fa91 100644
--- a/src/genericobject.cpp
+++ b/src/genericobject.cpp
@@ -170,12 +170,13 @@ std::string gob_cmd_update_attachment(int parent_id, std::string bone, v3f posit
return os.str();
}
-std::string gob_cmd_set_nametag_color(video::SColor color)
+std::string gob_cmd_update_nametag_attributes(video::SColor color)
{
std::ostringstream os(std::ios::binary);
// command
- writeU8(os, GENERIC_CMD_SET_NAMETAG_COLOR);
+ writeU8(os, GENERIC_CMD_UPDATE_NAMETAG_ATTRIBUTES);
// parameters
+ writeU8(os, 1); // version for forward compatibility
writeARGB8(os, color);
return os.str();
}
diff --git a/src/genericobject.h b/src/genericobject.h
index 854950d27..2233e4ea0 100644
--- a/src/genericobject.h
+++ b/src/genericobject.h
@@ -34,7 +34,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define GENERIC_CMD_SET_BONE_POSITION 7
#define GENERIC_CMD_SET_ATTACHMENT 8
#define GENERIC_CMD_SET_PHYSICS_OVERRIDE 9
-#define GENERIC_CMD_SET_NAMETAG_COLOR 10
+#define GENERIC_CMD_UPDATE_NAMETAG_ATTRIBUTES 10
#include "object_properties.h"
std::string gob_cmd_set_properties(const ObjectProperties &prop);
@@ -73,7 +73,7 @@ std::string gob_cmd_update_bone_position(std::string bone, v3f position, v3f rot
std::string gob_cmd_update_attachment(int parent_id, std::string bone, v3f position, v3f rotation);
-std::string gob_cmd_set_nametag_color(video::SColor color);
+std::string gob_cmd_update_nametag_attributes(video::SColor color);
#endif
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp
index c639a4834..845aab732 100644
--- a/src/script/lua_api/l_object.cpp
+++ b/src/script/lua_api/l_object.cpp
@@ -1274,8 +1274,8 @@ int ObjectRef::l_override_day_night_ratio(lua_State *L)
return 1;
}
-// set_nametag_color(self, color)
-int ObjectRef::l_set_nametag_color(lua_State *L)
+// set_nametag_attributes(self, attributes)
+int ObjectRef::l_set_nametag_attributes(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
@@ -1283,17 +1283,18 @@ int ObjectRef::l_set_nametag_color(lua_State *L)
if (playersao == NULL)
return 0;
- video::SColor color(255,255,255,255);
- if (!lua_isnil(L, 2))
- color = readARGB8(L, 2);
+ video::SColor color = playersao->getNametagColor();
+ lua_getfield(L, 2, "color");
+ if (!lua_isnil(L, -1))
+ color = readARGB8(L, -1);
playersao->setNametagColor(color);
lua_pushboolean(L, true);
return 1;
}
-// get_nametag_color(self)
-int ObjectRef::l_get_nametag_color(lua_State *L)
+// get_nametag_attributes(self)
+int ObjectRef::l_get_nametag_attributes(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
ObjectRef *ref = checkobject(L, 1);
@@ -1304,6 +1305,7 @@ int ObjectRef::l_get_nametag_color(lua_State *L)
video::SColor color = playersao->getNametagColor();
lua_newtable(L);
+ lua_newtable(L);
lua_pushnumber(L, color.getAlpha());
lua_setfield(L, -2, "a");
lua_pushnumber(L, color.getRed());
@@ -1312,6 +1314,7 @@ int ObjectRef::l_get_nametag_color(lua_State *L)
lua_setfield(L, -2, "g");
lua_pushnumber(L, color.getBlue());
lua_setfield(L, -2, "b");
+ lua_setfield(L, -2, "color");
return 1;
}
@@ -1438,7 +1441,7 @@ const luaL_reg ObjectRef::methods[] = {
luamethod(ObjectRef, override_day_night_ratio),
luamethod(ObjectRef, set_local_animation),
luamethod(ObjectRef, set_eye_offset),
- luamethod(ObjectRef, set_nametag_color),
- luamethod(ObjectRef, get_nametag_color),
+ luamethod(ObjectRef, set_nametag_attributes),
+ luamethod(ObjectRef, get_nametag_attributes),
{0,0}
};
diff --git a/src/script/lua_api/l_object.h b/src/script/lua_api/l_object.h
index 1f2931f29..af3ed5ef0 100644
--- a/src/script/lua_api/l_object.h
+++ b/src/script/lua_api/l_object.h
@@ -240,11 +240,11 @@ private:
// set_eye_offset(self, v3f first pv, v3f third pv)
static int l_set_eye_offset(lua_State *L);
- // set_nametag_color(self, color)
- static int l_set_nametag_color(lua_State *L);
+ // set_nametag_attributes(self, attributes)
+ static int l_set_nametag_attributes(lua_State *L);
- // get_nametag_color(self)
- static int l_get_nametag_color(lua_State *L);
+ // get_nametag_attributes(self)
+ static int l_get_nametag_attributes(lua_State *L);
public:
ObjectRef(ServerActiveObject *object);
g formspec field elements currently active */ void gotText(const StringMap &fields); /** * receive text/events transmitted by guiFormSpecMenu * @param text textual representation of event */ void gotText(const std::wstring &text); private: /** target to transmit data to */ GUIEngine *m_engine = nullptr; }; /** GUIEngine specific implementation of ISimpleTextureSource */ class MenuTextureSource : public ISimpleTextureSource { public: /** * default constructor * @param driver the video driver to load textures from */ MenuTextureSource(video::IVideoDriver *driver) : m_driver(driver) {}; /** * destructor, removes all loaded textures */ virtual ~MenuTextureSource(); /** * get a texture, loading it if required * @param name path to the texture * @param id receives the texture ID, always 0 in this implementation */ video::ITexture *getTexture(const std::string &name, u32 *id = NULL); private: /** driver to get textures from */ video::IVideoDriver *m_driver = nullptr; /** set of texture names to delete */ std::set<std::string> m_to_delete; }; /** GUIEngine specific implementation of OnDemandSoundFetcher */ class MenuMusicFetcher: public OnDemandSoundFetcher { public: /** * get sound file paths according to sound name * @param name sound name * @param dst_paths receives possible paths to sound files * @param dst_datas receives binary sound data (not used here) */ void fetchSounds(const std::string &name, std::set<std::string> &dst_paths, std::set<std::string> &dst_datas); private: /** set of fetched sound names */ std::set<std::string> m_fetched; }; /** implementation of main menu based uppon formspecs */ class GUIEngine { /** grant ModApiMainMenu access to private members */ friend class ModApiMainMenu; friend class ModApiSound; public: /** * default constructor * @param dev device to draw at * @param parent parent gui element * @param menumgr manager to add menus to * @param smgr scene manager to add scene elements to * @param data struct to transfer data to main game handling */ GUIEngine(JoystickController *joystick, gui::IGUIElement *parent, IMenuManager *menumgr, MainMenuData *data, bool &kill); /** default destructor */ virtual ~GUIEngine(); /** * return MainMenuScripting interface */ MainMenuScripting *getScriptIface() { return m_script; } /** * return dir of current menuscript */ std::string getScriptDir() { return m_scriptdir; } /** pass async callback to scriptengine **/ unsigned int queueAsync(const std::string &serialized_fct, const std::string &serialized_params); private: /** find and run the main menu script */ bool loadMainMenuScript(); /** run main menu loop */ void run(); /** update size of topleftext element */ void updateTopLeftTextSize(); /** parent gui element */ gui::IGUIElement *m_parent = nullptr; /** manager to add menus to */ IMenuManager *m_menumanager = nullptr; /** scene manager to add scene elements to */ scene::ISceneManager *m_smgr = nullptr; /** pointer to data beeing transfered back to main game handling */ MainMenuData *m_data = nullptr; /** pointer to texture source */ ISimpleTextureSource *m_texture_source = nullptr; /** pointer to soundmanager*/ ISoundManager *m_sound_manager = nullptr; /** representation of form source to be used in mainmenu formspec */ FormspecFormSource *m_formspecgui = nullptr; /** formspec input receiver */ TextDestGuiEngine *m_buttonhandler = nullptr; /** the formspec menu */ GUIFormSpecMenu *m_menu = nullptr; /** reference to kill variable managed by SIGINT handler */ bool &m_kill; /** variable used to abort menu and return back to main game handling */ bool m_startgame = false; /** scripting interface */ MainMenuScripting *m_script = nullptr; /** script basefolder */ std::string m_scriptdir = ""; void setFormspecPrepend(const std::string &fs); /** * draw background layer * @param driver to use for drawing */ void drawBackground(video::IVideoDriver *driver); /** * draw overlay layer * @param driver to use for drawing */ void drawOverlay(video::IVideoDriver *driver); /** * draw header layer * @param driver to use for drawing */ void drawHeader(video::IVideoDriver *driver); /** * draw footer layer * @param driver to use for drawing */ void drawFooter(video::IVideoDriver *driver); /** * load a texture for a specified layer * @param layer draw layer to specify texture * @param texturepath full path of texture to load */ bool setTexture(texture_layer layer, const std::string &texturepath, bool tile_image, unsigned int minsize); /** * download a file using curl * @param url url to download * @param target file to store to */ static bool downloadFile(const std::string &url, const std::string &target); /** array containing pointers to current specified texture layers */ image_definition m_textures[TEX_LAYER_MAX]; /** * specify text to appear as top left string * @param text to set */ void setTopleftText(const std::string &text); /** pointer to gui element shown at topleft corner */ irr::gui::IGUIStaticText *m_irr_toplefttext = nullptr; /** and text that is in it */ EnrichedString m_toplefttext; /** initialize cloud subsystem */ void cloudInit(); /** do preprocessing for cloud subsystem */ void cloudPreProcess(); /** do postprocessing for cloud subsystem */ void cloudPostProcess(u32 frametime_min, IrrlichtDevice *device); /** internam data required for drawing clouds */ struct clouddata { /** delta time since last cloud processing */ f32 dtime; /** absolute time of last cloud processing */ u32 lasttime; /** pointer to cloud class */ Clouds *clouds = nullptr; /** camera required for drawing clouds */ scene::ICameraSceneNode *camera = nullptr; }; /** is drawing of clouds enabled atm */ bool m_clouds_enabled = true; /** data used to draw clouds */ clouddata m_cloud; /** start playing a sound and return handle */ s32 playSound(const SimpleSoundSpec &spec, bool looped); /** stop playing a sound started with playSound() */ void stopSound(s32 handle); };