Add option to set water opaque (mainly for stylistic choice)
authorPerttu Ahola <celeron55@gmail.com>
Thu, 3 Nov 2011 21:06:57 +0000 (23:06 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Thu, 3 Nov 2011 21:06:57 +0000 (23:06 +0200)
src/content_mapnode.cpp
src/defaultsettings.cpp
src/guiMainMenu.cpp
src/guiMainMenu.h
src/main.cpp

index ec0a7df05e3d09e7eee5484f7671536cad40ac32..bb6d7caa7284e82ecbb92c34636937b877d9ee38 100644 (file)
@@ -107,6 +107,7 @@ void content_mapnode_init()
        bool new_style_water = g_settings->getBool("new_style_water");
        bool new_style_leaves = g_settings->getBool("new_style_leaves");
        bool invisible_stone = g_settings->getBool("invisible_stone");
+       bool opaque_water = g_settings->getBool("opaque_water");
 
        content_t i;
        ContentFeatures *f = NULL;
@@ -398,7 +399,8 @@ void content_mapnode_init()
        f->liquid_alternative_source = CONTENT_WATERSOURCE;
        f->liquid_viscosity = WATER_VISC;
 #ifndef SERVER
-       f->vertex_alpha = WATER_ALPHA;
+       if(!opaque_water)
+               f->vertex_alpha = WATER_ALPHA;
        f->post_effect_color = video::SColor(64, 100, 100, 200);
        if(f->special_material == NULL && g_texturesource)
        {
@@ -408,7 +410,8 @@ void content_mapnode_init()
                f->special_material->setFlag(video::EMF_BACK_FACE_CULLING, false);
                f->special_material->setFlag(video::EMF_BILINEAR_FILTER, false);
                f->special_material->setFlag(video::EMF_FOG_ENABLE, true);
-               f->special_material->MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
+               if(!opaque_water)
+                       f->special_material->MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
                AtlasPointer *pa_water1 = new AtlasPointer(g_texturesource->getTexture(
                                g_texturesource->getTextureId("water.png")));
                f->special_material->setTexture(0, pa_water1->atlas);
@@ -432,8 +435,10 @@ void content_mapnode_init()
                if(g_texturesource)
                        t.texture = g_texturesource->getTexture("water.png");
                
-               t.alpha = WATER_ALPHA;
-               t.material_type = MATERIAL_ALPHA_VERTEX;
+               if(!opaque_water){
+                       t.alpha = WATER_ALPHA;
+                       t.material_type = MATERIAL_ALPHA_VERTEX;
+               }
                t.material_flags &= ~MATERIAL_FLAG_BACKFACE_CULLING;
                f->setAllTiles(t);
 #endif
@@ -450,7 +455,8 @@ void content_mapnode_init()
        f->liquid_alternative_source = CONTENT_WATERSOURCE;
        f->liquid_viscosity = WATER_VISC;
 #ifndef SERVER
-       f->vertex_alpha = WATER_ALPHA;
+       if(!opaque_water)
+               f->vertex_alpha = WATER_ALPHA;
        f->post_effect_color = video::SColor(64, 100, 100, 200);
        if(f->special_material == NULL && g_texturesource)
        {
index 74c9af1c3b5048586179c1b6d18d2022b1fc8bc7..fbc22867d1505783c6858c29cdadc1eba7fd03af 100644 (file)
@@ -79,6 +79,7 @@ void set_default_settings(Settings *settings)
        settings->setDefault("screenshot_path", ".");
        settings->setDefault("view_bobbing_amount", "1.0");
        settings->setDefault("enable_3d_clouds", "false");
+       settings->setDefault("opaque_water", "false");
 
        // Server stuff
        // "map-dir" doesn't exist by default.
index a0a23828ae61a4f68c12fabf337559e595927e49..43ec85c8a94f68682007314d120a3c00b4ec4f4c 100644 (file)
@@ -81,6 +81,7 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
        bool fancy_trees;
        bool smooth_lighting;
        bool clouds_3d;
+       bool opaque_water;
        
        // Client options
        {
@@ -125,6 +126,13 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
                else
                        clouds_3d = m_data->clouds_3d;
        }
+       {
+               gui::IGUIElement *e = getElementFromId(GUI_ID_OPAQUE_WATER_CB);
+               if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX)
+                       opaque_water = ((gui::IGUICheckBox*)e)->isChecked();
+               else
+                       opaque_water = m_data->opaque_water;
+       }
        
        // Server options
        {
@@ -260,6 +268,12 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
                Environment->addCheckBox(clouds_3d, rect, this, GUI_ID_3D_CLOUDS_CB,
                                wgettext("3D Clouds"));
        }
+       {
+               core::rect<s32> rect(0, 0, 250, 30);
+               rect += topleft_client + v2s32(35, 150+60);
+               Environment->addCheckBox(opaque_water, rect, this, GUI_ID_OPAQUE_WATER_CB,
+                               wgettext("Opaque water"));
+       }
        // Start game button
        {
                core::rect<s32> rect(0, 0, 180, 30);
@@ -377,9 +391,9 @@ void GUIMainMenu::acceptInput()
                        m_data->enable_damage = ((gui::IGUICheckBox*)e)->isChecked();
        }
        {
-               gui::IGUIElement *e = getElementFromId(GUI_ID_3D_CLOUDS_CB);
+               gui::IGUIElement *e = getElementFromId(GUI_ID_FANCYTREE_CB);
                if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX)
-                       m_data->clouds_3d = ((gui::IGUICheckBox*)e)->isChecked();
+                       m_data->fancy_trees = ((gui::IGUICheckBox*)e)->isChecked();
        }
        {
                gui::IGUIElement *e = getElementFromId(GUI_ID_SMOOTH_LIGHTING_CB);
@@ -387,9 +401,14 @@ void GUIMainMenu::acceptInput()
                        m_data->smooth_lighting = ((gui::IGUICheckBox*)e)->isChecked();
        }
        {
-               gui::IGUIElement *e = getElementFromId(GUI_ID_FANCYTREE_CB);
+               gui::IGUIElement *e = getElementFromId(GUI_ID_3D_CLOUDS_CB);
                if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX)
-                       m_data->fancy_trees = ((gui::IGUICheckBox*)e)->isChecked();
+                       m_data->clouds_3d = ((gui::IGUICheckBox*)e)->isChecked();
+       }
+       {
+               gui::IGUIElement *e = getElementFromId(GUI_ID_OPAQUE_WATER_CB);
+               if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX)
+                       m_data->opaque_water = ((gui::IGUICheckBox*)e)->isChecked();
        }
        
        m_accepted = true;
index a451a9c21ffb40bbac2e45b8e24623cc2af0f9ad..ba2fc6be5e2329265edaad51112bcab603a17426 100644 (file)
@@ -36,6 +36,7 @@ enum
        GUI_ID_FANCYTREE_CB,
        GUI_ID_SMOOTH_LIGHTING_CB,
        GUI_ID_3D_CLOUDS_CB,
+       GUI_ID_OPAQUE_WATER_CB,
        GUI_ID_DAMAGE_CB,
        GUI_ID_CREATIVE_CB,
        GUI_ID_JOIN_GAME_BUTTON,
@@ -66,6 +67,7 @@ struct MainMenuData
        bool fancy_trees;
        bool smooth_lighting;
        bool clouds_3d;
+       bool opaque_water;
        // Server options
        bool creative_mode;
        bool enable_damage;
index b25b2fa350d47096229c1a9e8bbb439a6727be27..b959d8c6433eb47cace7361eab82dab9ee67d4c2 100644 (file)
@@ -1547,6 +1547,7 @@ int main(int argc, char *argv[])
                                menudata.fancy_trees = g_settings->getBool("new_style_leaves");
                                menudata.smooth_lighting = g_settings->getBool("smooth_lighting");
                                menudata.clouds_3d = g_settings->getBool("enable_3d_clouds");
+                               menudata.opaque_water = g_settings->getBool("opaque_water");
                                menudata.creative_mode = g_settings->getBool("creative_mode");
                                menudata.enable_damage = g_settings->getBool("enable_damage");
 
@@ -1620,6 +1621,7 @@ int main(int argc, char *argv[])
                                g_settings->set("new_style_leaves", itos(menudata.fancy_trees));
                                g_settings->set("smooth_lighting", itos(menudata.smooth_lighting));
                                g_settings->set("enable_3d_clouds", itos(menudata.clouds_3d));
+                               g_settings->set("opaque_water", itos(menudata.opaque_water));
                                g_settings->set("creative_mode", itos(menudata.creative_mode));
                                g_settings->set("enable_damage", itos(menudata.enable_damage));