Add option to use neither node highlighting nor outlining
authorezhh <owlecho@live.com>
Thu, 11 May 2017 22:18:36 +0000 (23:18 +0100)
committerCraig Robbins <kde.psych@gmail.com>
Mon, 15 May 2017 09:51:40 +0000 (19:51 +1000)
builtin/mainmenu/tab_settings.lua
builtin/settingtypes.txt
minetest.conf.example
src/hud.cpp
src/hud.h

index 69683eaa3ef7da9716323fa61d7a4a67d19851d6..5a8cc19b8e35b934c82cc1ddb395277bc2021ddd 100644 (file)
@@ -25,7 +25,8 @@ local labels = {
        },
        node_highlighting = {
                fgettext("Node Outlining"),
-               fgettext("Node Highlighting")
+               fgettext("Node Highlighting"),
+               fgettext("None")
        },
        filters = {
                fgettext("No Filter"),
@@ -52,7 +53,7 @@ local dd_options = {
        },
        node_highlighting = {
                table.concat(labels.node_highlighting, ","),
-               {"box", "halo"}
+               {"box", "halo", "none"}
        },
        filters = {
                table.concat(labels.filters, ","),
index 61c04e616a0b554b7061c863a677df6b9fa25be5..463ca0be9d304c259043e4ff02615124592f06ba 100644 (file)
@@ -344,7 +344,7 @@ enable_clouds (Clouds) bool true
 enable_3d_clouds (3D clouds) bool true
 
 #    Method used to highlight selected object.
-node_highlighting (Node highlighting) enum box box,halo
+node_highlighting (Node highlighting) enum box box,halo,none
 
 #    Adds particles when digging a node.
 enable_particles (Digging particles) bool true
index 6c6ce91b814cbe08f6318600b444c1fb0a5eae49..e9add15974c9ab478114d4a6b1af711cd453d3f9 100644 (file)
 # enable_3d_clouds = true
 
 #    Method used to highlight selected object.
-#    type: enum values: box, halo
+#    type: enum values: box, halo, none
 # node_highlighting = box
 
 #    Adds particles when digging a node.
index 9729013ee69adc92b48d8f03074e601e9cc68198..3e4162b6432bf47a94e4f6225bec7254d60fc320 100644 (file)
@@ -87,24 +87,31 @@ Hud::Hud(video::IVideoDriver *driver, scene::ISceneManager* smgr,
        m_halo_boxes.clear();
 
        m_selection_pos = v3f(0.0, 0.0, 0.0);
-       std::string mode = g_settings->get("node_highlighting");
+       std::string mode_setting = g_settings->get("node_highlighting");
+
+       if (mode_setting == "halo") {
+               m_mode = HIGHLIGHT_HALO;
+       } else if (mode_setting == "none") {
+               m_mode = HIGHLIGHT_NONE;
+       } else {
+               m_mode = HIGHLIGHT_BOX;
+       }
+
        m_selection_material.Lighting = false;
 
        if (g_settings->getBool("enable_shaders")) {
                IShaderSource *shdrsrc = client->getShaderSource();
                u16 shader_id = shdrsrc->getShader(
-                       mode == "halo" ? "selection_shader" : "default_shader", 1, 1);
+                       m_mode == HIGHLIGHT_HALO ? "selection_shader" : "default_shader", 1, 1);
                m_selection_material.MaterialType = shdrsrc->getShaderInfo(shader_id).material;
        } else {
                m_selection_material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
        }
 
-       if (mode == "box") {
-               m_use_selection_mesh = false;
+       if (m_mode == HIGHLIGHT_BOX) {
                m_selection_material.Thickness =
                        rangelim(g_settings->getS16("selectionbox_width"), 1, 5);
-       } else if (mode == "halo") {
-               m_use_selection_mesh = true;
+       } else if (m_mode == HIGHLIGHT_HALO) {
                m_selection_material.setTexture(0, tsrc->getTextureForMesh("halo.png"));
                m_selection_material.setFlag(video::EMF_BACK_FACE_CULLING, true);
        } else {
@@ -518,7 +525,7 @@ void Hud::setSelectionPos(const v3f &pos, const v3s16 &camera_offset)
 
 void Hud::drawSelectionMesh()
 {
-       if (!m_use_selection_mesh) {
+       if (m_mode == HIGHLIGHT_BOX) {
                // Draw 3D selection boxes
                video::SMaterial oldmaterial = driver->getMaterial2D();
                driver->setMaterial(m_selection_material);
@@ -538,7 +545,7 @@ void Hud::drawSelectionMesh()
                        driver->draw3DBox(box, video::SColor(255, r, g, b));
                }
                driver->setMaterial(oldmaterial);
-       } else if (m_selection_mesh) {
+       } else if (m_mode == HIGHLIGHT_HALO && m_selection_mesh) {
                // Draw selection mesh
                video::SMaterial oldmaterial = driver->getMaterial2D();
                driver->setMaterial(m_selection_material);
@@ -564,7 +571,7 @@ void Hud::drawSelectionMesh()
 void Hud::updateSelectionMesh(const v3s16 &camera_offset)
 {
        m_camera_offset = camera_offset;
-       if (!m_use_selection_mesh)
+       if (m_mode != HIGHLIGHT_HALO)
                return;
 
        if (m_selection_mesh) {
index efa0c3648b46e10529acafae9d32830c1042ae41..15c115d89e9b0046cc018dcc842eff79ee0d1c07 100644 (file)
--- a/src/hud.h
+++ b/src/hud.h
@@ -175,7 +175,11 @@ private:
        v3f m_selected_face_normal;
 
        video::SMaterial m_selection_material;
-       bool m_use_selection_mesh;
+
+       enum {
+               HIGHLIGHT_BOX,
+               HIGHLIGHT_HALO,
+               HIGHLIGHT_NONE } m_mode;
 };
 
 enum ItemRotationKind {