Add option to set water opaque (mainly for stylistic choice)

This commit is contained in:
Perttu Ahola 2011-11-03 23:06:57 +02:00
parent f5995337e8
commit d0fdfd44c5
5 changed files with 39 additions and 9 deletions

@ -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)
{

@ -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.

@ -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;

@ -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;

@ -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));