From e76f4155d52e7f79fd40e4f9ac0b9321c1ab9706 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Sat, 28 May 2011 02:17:19 +0200 Subject: + sandstone --- src/mapnode.cpp | 8 ++++++++ src/mapnode.h | 1 + src/materials.cpp | 1 + src/server.cpp | 16 ++++++++++++++++ src/tile.cpp | 1 + 5 files changed, 27 insertions(+) (limited to 'src') diff --git a/src/mapnode.cpp b/src/mapnode.cpp index ca36697ef..c006b8222 100644 --- a/src/mapnode.cpp +++ b/src/mapnode.cpp @@ -181,6 +181,14 @@ void init_mapnode() f->is_ground_content = true; f->dug_item = std::string("MaterialItem ")+itos(i)+" 1"; + i = CONTENT_SANDSTONE; + f = &g_content_features[i]; + f->setAllTextures("sandstone.png"); + f->setInventoryTextureCube("sandstone.png", "sandstone.png", "sandstone.png"); + f->param_type = CPT_MINERAL; + f->is_ground_content = true; + f->dug_item = std::string("MaterialItem ")+itos(CONTENT_SAND)+" 1"; + i = CONTENT_TREE; f = &g_content_features[i]; f->setAllTextures("tree.png"); diff --git a/src/mapnode.h b/src/mapnode.h index 57382aa2b..ad256585f 100644 --- a/src/mapnode.h +++ b/src/mapnode.h @@ -101,6 +101,7 @@ void init_content_inventory_texture_paths(); #define CONTENT_STEEL 19 #define CONTENT_GLASS 20 #define CONTENT_FENCE 21 +#define CONTENT_SANDSTONE 22 /* Content feature list diff --git a/src/materials.cpp b/src/materials.cpp index 841f1d655..60c1894bf 100644 --- a/src/materials.cpp +++ b/src/materials.cpp @@ -59,6 +59,7 @@ void initializeMaterialProperties() */ setStoneLikeDiggingProperties(CONTENT_STONE, 1.0); + setStoneLikeDiggingProperties(CONTENT_SANDSTONE, 1.0); setStoneLikeDiggingProperties(CONTENT_MESE, 0.5); setStoneLikeDiggingProperties(CONTENT_COALSTONE, 1.5); setStoneLikeDiggingProperties(CONTENT_FURNACE, 3.0); diff --git a/src/server.cpp b/src/server.cpp index 9248e6298..c7b64f413 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -3972,6 +3972,21 @@ void Server::UpdateCrafting(u16 peer_id) found = true; } } + + // Sandstone + if(!found) + { + ItemSpec specs[9]; + specs[3] = ItemSpec(ITEM_MATERIAL, CONTENT_SAND); + specs[4] = ItemSpec(ITEM_MATERIAL, CONTENT_SAND); + specs[6] = ItemSpec(ITEM_MATERIAL, CONTENT_SAND); + specs[7] = ItemSpec(ITEM_MATERIAL, CONTENT_SAND); + if(checkItemCombination(items, specs)) + { + rlist->addItem(new MaterialItem(CONTENT_SANDSTONE, 1)); + found = true; + } + } } } // if creative_mode == false @@ -4060,6 +4075,7 @@ void setCreativeInventory(Player *player) CONTENT_MUD, CONTENT_STONE, CONTENT_SAND, + CONTENT_SANDSTONE, CONTENT_TREE, CONTENT_LEAVES, CONTENT_GLASS, diff --git a/src/tile.cpp b/src/tile.cpp index dabc1dcf3..8b0c3f2ea 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -506,6 +506,7 @@ void TextureSource::buildMainAtlas() sourcelist.push_back("stone.png"); sourcelist.push_back("mud.png"); sourcelist.push_back("sand.png"); + sourcelist.push_back("sandstone.png"); sourcelist.push_back("grass.png"); sourcelist.push_back("grass_footsteps.png"); sourcelist.push_back("tree.png"); -- cgit v1.2.3 From 544aeb08404f8bb6848f64140909715afbf7d1f1 Mon Sep 17 00:00:00 2001 From: teddydestodes Date: Sun, 29 May 2011 19:17:42 +0200 Subject: fast_move and free_move can now be toggled --- src/defaultsettings.cpp | 2 ++ src/game.cpp | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) (limited to 'src') diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index f11b0b2d7..e2ace0fe2 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -40,6 +40,8 @@ void set_default_settings() g_settings.setDefault("keymap_inventory", "KEY_KEY_I"); g_settings.setDefault("keymap_chat", "KEY_KEY_T"); g_settings.setDefault("keymap_rangeselect", "KEY_KEY_R"); + g_settings.setDefault("keymap_freemove", "KEY_KEY_K"); + g_settings.setDefault("keymap_fastmove", "KEY_KEY_J"); // Some (temporary) keys for debugging g_settings.setDefault("keymap_special1", "KEY_KEY_E"); g_settings.setDefault("keymap_print_debug_stacks", "KEY_KEY_P"); diff --git a/src/game.cpp b/src/game.cpp index 603a86da3..7970a6ed9 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1147,6 +1147,28 @@ void the_game( &g_menumgr, dest, L""))->drop(); } + else if(input->wasKeyDown(getKeySetting("keymap_freemove"))) + { + if(g_settings.getBool("free_move")) + { + g_settings.set("free_move","false"); + } + else + { + g_settings.set("free_move","true"); + } + } + else if(input->wasKeyDown(getKeySetting("keymap_fastmove"))) + { + if(g_settings.getBool("fast_move")) + { + g_settings.set("fast_move","false"); + } + else + { + g_settings.set("fast_move","true"); + } + } // Item selection with mouse wheel { -- cgit v1.2.3 From 289e31ed981371fa05bd02488e38e2d0f0f5effe Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Mon, 30 May 2011 14:42:08 +0200 Subject: + cactii --- src/map.cpp | 34 +++++++++++++++++++++++++++------- src/mapnode.cpp | 10 ++++++++++ src/mapnode.h | 1 + src/materials.cpp | 1 + src/server.cpp | 1 + src/tile.cpp | 2 ++ 6 files changed, 42 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/map.cpp b/src/map.cpp index a49de3c46..c48599d47 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2045,6 +2045,20 @@ void make_tree(VoxelManipulator &vmanip, v3s16 p0) } } +void make_cactus(VoxelManipulator &vmanip, v3s16 p0) +{ + MapNode cactusnode(CONTENT_CACTUS); + + s16 trunk_h = 3; + v3s16 p1 = p0; + for(s16 ii=0; ii y_nodes_max - 6) continue; v3s16 p(x,y,z); - /* - Trees grow only on mud and grass - */ { u32 i = data->vmanip.m_area.index(v3s16(p)); MapNode *n = &data->vmanip.m_data[i]; - if(n->d != CONTENT_MUD && n->d != CONTENT_GRASS) + if(n->d != CONTENT_MUD && n->d != CONTENT_GRASS && n->d != CONTENT_SAND) continue; + // Trees grow only on mud and grass + if(n->d == CONTENT_MUD || n->d == CONTENT_GRASS) + { + p.Y++; + make_tree(data->vmanip, p); + } + // Cactii grow only on sand + if(n->d == CONTENT_SAND) + { + p.Y++; + make_cactus(data->vmanip, p); + } } - p.Y++; - // Make a tree - make_tree(data->vmanip, p); } } /*u32 tree_max = relative_area / 60; diff --git a/src/mapnode.cpp b/src/mapnode.cpp index c006b8222..8ceeecfba 100644 --- a/src/mapnode.cpp +++ b/src/mapnode.cpp @@ -215,6 +215,16 @@ void init_mapnode() } f->dug_item = std::string("MaterialItem ")+itos(i)+" 1"; + i = CONTENT_CACTUS; + f = &g_content_features[i]; + f->setAllTextures("cactus_side.png"); + f->setTexture(0, "cactus_top.png"); + f->setTexture(1, "cactus_top.png"); + f->setInventoryTextureCube("cactus_top.png", "cactus_side.png", "cactus_side.png"); + f->param_type = CPT_MINERAL; + f->is_ground_content = true; + f->dug_item = std::string("MaterialItem ")+itos(i)+" 1"; + i = CONTENT_GLASS; f = &g_content_features[i]; f->light_propagates = true; diff --git a/src/mapnode.h b/src/mapnode.h index ad256585f..c4dcbfbe5 100644 --- a/src/mapnode.h +++ b/src/mapnode.h @@ -102,6 +102,7 @@ void init_content_inventory_texture_paths(); #define CONTENT_GLASS 20 #define CONTENT_FENCE 21 #define CONTENT_SANDSTONE 22 +#define CONTENT_CACTUS 23 /* Content feature list diff --git a/src/materials.cpp b/src/materials.cpp index 60c1894bf..a1d419562 100644 --- a/src/materials.cpp +++ b/src/materials.cpp @@ -73,6 +73,7 @@ void initializeMaterialProperties() setWoodLikeDiggingProperties(CONTENT_TREE, 1.0); setWoodLikeDiggingProperties(CONTENT_LEAVES, 0.15); + setWoodLikeDiggingProperties(CONTENT_CACTUS, 0.75); setWoodLikeDiggingProperties(CONTENT_GLASS, 0.15); setWoodLikeDiggingProperties(CONTENT_FENCE, 0.75); setWoodLikeDiggingProperties(CONTENT_WOOD, 0.75); diff --git a/src/server.cpp b/src/server.cpp index c7b64f413..994e62eaf 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -4078,6 +4078,7 @@ void setCreativeInventory(Player *player) CONTENT_SANDSTONE, CONTENT_TREE, CONTENT_LEAVES, + CONTENT_CACTUS, CONTENT_GLASS, CONTENT_FENCE, CONTENT_MESE, diff --git a/src/tile.cpp b/src/tile.cpp index 8b0c3f2ea..2a2d2a70c 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -513,6 +513,8 @@ void TextureSource::buildMainAtlas() sourcelist.push_back("tree_top.png"); sourcelist.push_back("water.png"); sourcelist.push_back("leaves.png"); + sourcelist.push_back("cactus_side.png"); + sourcelist.push_back("cactus_top.png"); sourcelist.push_back("glass.png"); sourcelist.push_back("mud.png^grass_side.png"); sourcelist.push_back("cobble.png"); -- cgit v1.2.3 From b461213ddbdb838f76f22ece59d1c64d1485b8ee Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Tue, 31 May 2011 02:56:23 +0200 Subject: * improved fence dimensions (cuboid side lengths now multiples of 2, textures should fit better) --- src/mapblock.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mapblock.cpp b/src/mapblock.cpp index c448ef236..d98bfaf1e 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -1563,8 +1563,8 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data) u8 l = decode_light(undiminish_light(n.getLightBlend(data->m_daynight_ratio))); video::SColor c(255,l,l,l); - const f32 post_rad=(f32)BS/10; - const f32 bar_rad=(f32)BS/20; + const f32 post_rad=(f32)BS/(32.0/4.0); + const f32 bar_rad=(f32)BS/(32.0/2.0); const f32 bar_len=(f32)(BS/2)-post_rad; // The post - always present @@ -1581,12 +1581,12 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data) { pos = intToFloat(p+blockpos_nodes, BS); pos.X += BS/2; - pos.Y += BS/4; + pos.Y += 3*bar_rad; makeCuboid(material_wood, &collector, &pa_wood, c, pos, bar_len,bar_rad,bar_rad); - pos.Y -= BS/2; + pos.Y -= 6*bar_rad; makeCuboid(material_wood, &collector, &pa_wood, c, pos, bar_len,bar_rad,bar_rad); @@ -1600,11 +1600,11 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data) { pos = intToFloat(p+blockpos_nodes, BS); pos.Z += BS/2; - pos.Y += BS/4; + pos.Y += 3*bar_rad; makeCuboid(material_wood, &collector, &pa_wood, c, pos, bar_rad,bar_rad,bar_len); - pos.Y -= BS/2; + pos.Y -= 6*bar_rad; makeCuboid(material_wood, &collector, &pa_wood, c, pos, bar_rad,bar_rad,bar_len); -- cgit v1.2.3 From 6ca51de990f7b58001e1da93d949023cee697173 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Tue, 31 May 2011 02:56:41 +0200 Subject: + fence inventory icon --- src/mapnode.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/mapnode.cpp b/src/mapnode.cpp index 8ceeecfba..cfb1a493f 100644 --- a/src/mapnode.cpp +++ b/src/mapnode.cpp @@ -236,6 +236,7 @@ void init_mapnode() i = CONTENT_FENCE; f = &g_content_features[i]; + f->setInventoryTexture("fence.png"); f->light_propagates = true; f->param_type = CPT_LIGHT; f->is_ground_content = true; -- cgit v1.2.3 From d7b768dc4b94786474c35a6ae7ea2000d7e11626 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Tue, 31 May 2011 22:04:09 +0200 Subject: + brick --- src/mapnode.cpp | 8 ++++++++ src/mapnode.h | 1 + src/materials.cpp | 1 + src/server.cpp | 1 + src/tile.cpp | 1 + 5 files changed, 12 insertions(+) (limited to 'src') diff --git a/src/mapnode.cpp b/src/mapnode.cpp index cfb1a493f..72cd762c6 100644 --- a/src/mapnode.cpp +++ b/src/mapnode.cpp @@ -189,6 +189,14 @@ void init_mapnode() f->is_ground_content = true; f->dug_item = std::string("MaterialItem ")+itos(CONTENT_SAND)+" 1"; + i = CONTENT_BRICK; + f = &g_content_features[i]; + f->setAllTextures("brick.png"); + f->setInventoryTextureCube("brick.png", "brick.png", "brick.png"); + f->param_type = CPT_MINERAL; + f->is_ground_content = true; + f->dug_item = std::string("MaterialItem ")+itos(i)+" 1"; + i = CONTENT_TREE; f = &g_content_features[i]; f->setAllTextures("tree.png"); diff --git a/src/mapnode.h b/src/mapnode.h index c4dcbfbe5..5022031de 100644 --- a/src/mapnode.h +++ b/src/mapnode.h @@ -103,6 +103,7 @@ void init_content_inventory_texture_paths(); #define CONTENT_FENCE 21 #define CONTENT_SANDSTONE 22 #define CONTENT_CACTUS 23 +#define CONTENT_BRICK 24 /* Content feature list diff --git a/src/materials.cpp b/src/materials.cpp index a1d419562..0c744af9f 100644 --- a/src/materials.cpp +++ b/src/materials.cpp @@ -60,6 +60,7 @@ void initializeMaterialProperties() setStoneLikeDiggingProperties(CONTENT_STONE, 1.0); setStoneLikeDiggingProperties(CONTENT_SANDSTONE, 1.0); + setStoneLikeDiggingProperties(CONTENT_BRICK, 3.0); setStoneLikeDiggingProperties(CONTENT_MESE, 0.5); setStoneLikeDiggingProperties(CONTENT_COALSTONE, 1.5); setStoneLikeDiggingProperties(CONTENT_FURNACE, 3.0); diff --git a/src/server.cpp b/src/server.cpp index 994e62eaf..dfc05f7d3 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -4076,6 +4076,7 @@ void setCreativeInventory(Player *player) CONTENT_STONE, CONTENT_SAND, CONTENT_SANDSTONE, + CONTENT_BRICK, CONTENT_TREE, CONTENT_LEAVES, CONTENT_CACTUS, diff --git a/src/tile.cpp b/src/tile.cpp index 2a2d2a70c..361de704c 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -507,6 +507,7 @@ void TextureSource::buildMainAtlas() sourcelist.push_back("mud.png"); sourcelist.push_back("sand.png"); sourcelist.push_back("sandstone.png"); + sourcelist.push_back("brick.png"); sourcelist.push_back("grass.png"); sourcelist.push_back("grass_footsteps.png"); sourcelist.push_back("tree.png"); -- cgit v1.2.3 From ba1460a5822d38dc6617717fa5fec9b033bb0a29 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Wed, 1 Jun 2011 04:57:46 +0200 Subject: + clay and associated items --- src/inventory.cpp | 8 +++++++- src/map.cpp | 12 +++++++++++- src/mapnode.cpp | 10 +++++++++- src/mapnode.h | 1 + src/materials.cpp | 1 + src/server.cpp | 31 +++++++++++++++++++++++++++++++ src/tile.cpp | 1 + 7 files changed, 61 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/inventory.cpp b/src/inventory.cpp index 47a8d4de9..3f83c7419 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -160,8 +160,12 @@ video::ITexture * CraftItem::getImage() name = "lump_of_coal.png"; else if(m_subname == "lump_of_iron") name = "lump_of_iron.png"; + else if(m_subname == "lump_of_clay") + name = "lump_of_clay.png"; else if(m_subname == "steel_ingot") name = "steel_ingot.png"; + else if(m_subname == "clay_brick") + name = "clay_brick.png"; else if(m_subname == "rat") name = "rat.png"; else @@ -199,7 +203,7 @@ u16 CraftItem::getDropCount() bool CraftItem::isCookable() { - if(m_subname == "lump_of_iron") + if(m_subname == "lump_of_iron" || m_subname == "lump_of_clay") { return true; } @@ -212,6 +216,8 @@ InventoryItem *CraftItem::createCookResult() { return new CraftItem("steel_ingot", 1); } + else if(m_subname == "lump_of_clay") + return new CraftItem("clay_brick", 1); return NULL; } diff --git a/src/map.cpp b/src/map.cpp index c48599d47..bf9f38c87 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -3141,6 +3141,13 @@ void makeChunk(ChunkMakeData *data) if(have_sand == false) continue; + // Determine whether to have clay in the sand here + double claynoise = noise2d_perlin( + 0.5+(float)p2d.X/500, 0.5+(float)p2d.Y/500, + data->seed+4321, 8, 0.95); + + bool have_clay = have_sand && (claynoise > 0.95); + // Find ground level s16 surface_y = find_ground_level_clever(data->vmanip, p2d); @@ -3157,7 +3164,10 @@ void makeChunk(ChunkMakeData *data) MapNode *n = &data->vmanip.m_data[i]; if(n->d == CONTENT_MUD || n->d == CONTENT_GRASS) { - n->d = CONTENT_SAND; + if(have_clay && (surface_y == WATER_LEVEL)) + n->d = CONTENT_CLAY; + else + n->d = CONTENT_SAND; } else { diff --git a/src/mapnode.cpp b/src/mapnode.cpp index 72cd762c6..cef9bbf03 100644 --- a/src/mapnode.cpp +++ b/src/mapnode.cpp @@ -189,13 +189,21 @@ void init_mapnode() f->is_ground_content = true; f->dug_item = std::string("MaterialItem ")+itos(CONTENT_SAND)+" 1"; + i = CONTENT_CLAY; + f = &g_content_features[i]; + f->setAllTextures("clay.png"); + f->setInventoryTextureCube("clay.png", "clay.png", "clay.png"); + f->param_type = CPT_MINERAL; + f->is_ground_content = true; + f->dug_item = std::string("CraftItem lump_of_clay 4"); + i = CONTENT_BRICK; f = &g_content_features[i]; f->setAllTextures("brick.png"); f->setInventoryTextureCube("brick.png", "brick.png", "brick.png"); f->param_type = CPT_MINERAL; f->is_ground_content = true; - f->dug_item = std::string("MaterialItem ")+itos(i)+" 1"; + f->dug_item = std::string("CraftItem clay_brick 4"); i = CONTENT_TREE; f = &g_content_features[i]; diff --git a/src/mapnode.h b/src/mapnode.h index 5022031de..e8cc0ab51 100644 --- a/src/mapnode.h +++ b/src/mapnode.h @@ -104,6 +104,7 @@ void init_content_inventory_texture_paths(); #define CONTENT_SANDSTONE 22 #define CONTENT_CACTUS 23 #define CONTENT_BRICK 24 +#define CONTENT_CLAY 25 /* Content feature list diff --git a/src/materials.cpp b/src/materials.cpp index 0c744af9f..8c23056f2 100644 --- a/src/materials.cpp +++ b/src/materials.cpp @@ -71,6 +71,7 @@ void initializeMaterialProperties() setDirtLikeDiggingProperties(CONTENT_GRASS, 1.0); setDirtLikeDiggingProperties(CONTENT_GRASS_FOOTSTEPS, 1.0); setDirtLikeDiggingProperties(CONTENT_SAND, 1.0); + setDirtLikeDiggingProperties(CONTENT_CLAY, 1.0); setWoodLikeDiggingProperties(CONTENT_TREE, 1.0); setWoodLikeDiggingProperties(CONTENT_LEAVES, 0.15); diff --git a/src/server.cpp b/src/server.cpp index dfc05f7d3..17850c5fa 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -3987,6 +3987,36 @@ void Server::UpdateCrafting(u16 peer_id) found = true; } } + + // Clay + if(!found) + { + ItemSpec specs[9]; + specs[3] = ItemSpec(ITEM_CRAFT, "lump_of_clay"); + specs[4] = ItemSpec(ITEM_CRAFT, "lump_of_clay"); + specs[6] = ItemSpec(ITEM_CRAFT, "lump_of_clay"); + specs[7] = ItemSpec(ITEM_CRAFT, "lump_of_clay"); + if(checkItemCombination(items, specs)) + { + rlist->addItem(new MaterialItem(CONTENT_CLAY, 1)); + found = true; + } + } + + // Brick + if(!found) + { + ItemSpec specs[9]; + specs[3] = ItemSpec(ITEM_CRAFT, "clay_brick"); + specs[4] = ItemSpec(ITEM_CRAFT, "clay_brick"); + specs[6] = ItemSpec(ITEM_CRAFT, "clay_brick"); + specs[7] = ItemSpec(ITEM_CRAFT, "clay_brick"); + if(checkItemCombination(items, specs)) + { + rlist->addItem(new MaterialItem(CONTENT_BRICK, 1)); + found = true; + } + } } } // if creative_mode == false @@ -4076,6 +4106,7 @@ void setCreativeInventory(Player *player) CONTENT_STONE, CONTENT_SAND, CONTENT_SANDSTONE, + CONTENT_CLAY, CONTENT_BRICK, CONTENT_TREE, CONTENT_LEAVES, diff --git a/src/tile.cpp b/src/tile.cpp index 361de704c..71e0c9638 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -507,6 +507,7 @@ void TextureSource::buildMainAtlas() sourcelist.push_back("mud.png"); sourcelist.push_back("sand.png"); sourcelist.push_back("sandstone.png"); + sourcelist.push_back("clay.png"); sourcelist.push_back("brick.png"); sourcelist.push_back("grass.png"); sourcelist.push_back("grass_footsteps.png"); -- cgit v1.2.3 From 5f52a622b6a2602742ea472c1163eba2acf17fb6 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Wed, 1 Jun 2011 08:09:28 +0200 Subject: * clay is rarer now --- src/map.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/map.cpp b/src/map.cpp index bf9f38c87..ac5bd7d14 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -3144,9 +3144,9 @@ void makeChunk(ChunkMakeData *data) // Determine whether to have clay in the sand here double claynoise = noise2d_perlin( 0.5+(float)p2d.X/500, 0.5+(float)p2d.Y/500, - data->seed+4321, 8, 0.95); + data->seed+4321, 6, 0.95); - bool have_clay = have_sand && (claynoise > 0.95); + bool have_clay = have_sand && (claynoise > 1.25); // Find ground level s16 surface_y = find_ground_level_clever(data->vmanip, p2d); -- cgit v1.2.3 From 9de57d13bc7a97fba17da5807e1ef57d96586deb Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Tue, 31 May 2011 08:56:23 +0800 Subject: * improved fence dimensions (cuboid side lengths now multiples of 2, textures should fit better) --- src/mapblock.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/mapblock.cpp b/src/mapblock.cpp index c448ef236..d98bfaf1e 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -1563,8 +1563,8 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data) u8 l = decode_light(undiminish_light(n.getLightBlend(data->m_daynight_ratio))); video::SColor c(255,l,l,l); - const f32 post_rad=(f32)BS/10; - const f32 bar_rad=(f32)BS/20; + const f32 post_rad=(f32)BS/(32.0/4.0); + const f32 bar_rad=(f32)BS/(32.0/2.0); const f32 bar_len=(f32)(BS/2)-post_rad; // The post - always present @@ -1581,12 +1581,12 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data) { pos = intToFloat(p+blockpos_nodes, BS); pos.X += BS/2; - pos.Y += BS/4; + pos.Y += 3*bar_rad; makeCuboid(material_wood, &collector, &pa_wood, c, pos, bar_len,bar_rad,bar_rad); - pos.Y -= BS/2; + pos.Y -= 6*bar_rad; makeCuboid(material_wood, &collector, &pa_wood, c, pos, bar_len,bar_rad,bar_rad); @@ -1600,11 +1600,11 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data) { pos = intToFloat(p+blockpos_nodes, BS); pos.Z += BS/2; - pos.Y += BS/4; + pos.Y += 3*bar_rad; makeCuboid(material_wood, &collector, &pa_wood, c, pos, bar_rad,bar_rad,bar_len); - pos.Y -= BS/2; + pos.Y -= 6*bar_rad; makeCuboid(material_wood, &collector, &pa_wood, c, pos, bar_rad,bar_rad,bar_len); -- cgit v1.2.3 From 2f2f28d3985a226a6babe87f1cdc506e1c0604bc Mon Sep 17 00:00:00 2001 From: MrLoom Date: Wed, 1 Jun 2011 14:13:22 +0200 Subject: MacOSX build support --- src/CMakeLists.txt | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 49982d310..617a452b6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -35,13 +35,24 @@ else() find_package(JPEG REQUIRED) find_package(BZip2 REQUIRED) find_package(PNG REQUIRED) + if(APPLE) + FIND_LIBRARY(CARBON_LIB Carbon) + FIND_LIBRARY(COCOA_LIB Cocoa) + FIND_LIBRARY(IOKIT_LIB IOKit) + mark_as_advanced( + CARBON_LIB + COCOA_LIB + IOKIT_LIB + ) + SET(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} ${CARBON_LIB} ${COCOA_LIB} ${IOKIT_LIB}) + endif(APPLE) endif(BUILD_CLIENT) find_package(ZLIB REQUIRED) set(PLATFORM_LIBS -lpthread) #set(CLIENT_PLATFORM_LIBS -lXxf86vm) # This way Xxf86vm is found on OpenBSD too find_library(XXF86VM_LIBRARY Xxf86vm) - set(CLIENT_PLATFORM_LIBS ${XXF86VM_LIBRARY}) + set(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} ${XXF86VM_LIBRARY}) endif() configure_file( @@ -174,8 +185,14 @@ else() set(WARNING_FLAGS "") endif() - set(WARNING_FLAGS "${WARNING_FLAGS} -Wno-unused-but-set-variable") - + if(NOT APPLE) + set(WARNING_FLAGS "${WARNING_FLAGS} -Wno-unused-but-set-variable") + endif() + if(APPLE) + set(CMAKE_OSX_ARCHITECTURES i386 CACHE STRING "do not build for 64-bit" FORCE) + set(ARCH i386) + endif() + set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${WARNING_FLAGS} -O3 -ffast-math -Wall -fomit-frame-pointer -pipe -funroll-loops") set(CMAKE_CXX_FLAGS_DEBUG "-g -O1 -Wall") -- cgit v1.2.3 From 6434f64ab41c344ba7474305a9e6a6ad7a36a7a5 Mon Sep 17 00:00:00 2001 From: teddydestodes Date: Wed, 1 Jun 2011 19:44:07 +0200 Subject: added new submenu for key assignment configwriting/saving isn't complete and will break your config if you use fancy keys --- src/CMakeLists.txt | 1 + src/guiKeyChangeMenu.cpp | 598 +++++++++++++++++++++++++++++++++++++++++++++++ src/guiKeyChangeMenu.h | 133 +++++++++++ src/guiMainMenu.cpp | 71 +++--- src/guiMainMenu.h | 83 ++++--- src/guiMessageMenu.h | 48 ++-- src/keycode.cpp | 78 +++++-- src/keycode.h | 4 +- 8 files changed, 913 insertions(+), 103 deletions(-) create mode 100644 src/guiKeyChangeMenu.cpp create mode 100644 src/guiKeyChangeMenu.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 617a452b6..9d5cf7d2c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -100,6 +100,7 @@ set(minetest_SRCS clientobject.cpp guiFurnaceMenu.cpp guiMainMenu.cpp + guiKeyChangeMenu.cpp guiMessageMenu.cpp guiTextInputMenu.cpp guiInventoryMenu.cpp diff --git a/src/guiKeyChangeMenu.cpp b/src/guiKeyChangeMenu.cpp new file mode 100644 index 000000000..3e594aeca --- /dev/null +++ b/src/guiKeyChangeMenu.cpp @@ -0,0 +1,598 @@ +/* + Minetest-delta + Copyright (C) 2010-11 celeron55, Perttu Ahola + Copyright (C) 2011 Ciaran Gultnieks + Copyright (C) 2011 teddydestodes + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "guiKeyChangeMenu.h" +#include "debug.h" +#include "serialization.h" +#include "keycode.h" +#include "main.h" +#include + +GUIKeyChangeMenu::GUIKeyChangeMenu(gui::IGUIEnvironment* env, + gui::IGUIElement* parent, s32 id, IMenuManager *menumgr) : + GUIModalMenu(env, parent, id, menumgr) +{ + activeKey = -1; + init_keys(); +} + +GUIKeyChangeMenu::~GUIKeyChangeMenu() +{ + removeChildren(); +} + +void GUIKeyChangeMenu::removeChildren() +{ + const core::list &children = getChildren(); + core::list children_copy; + for (core::list::ConstIterator i = children.begin(); i + != children.end(); i++) + { + children_copy.push_back(*i); + } + for (core::list::Iterator i = children_copy.begin(); i + != children_copy.end(); i++) + { + (*i)->remove(); + } +} + +void GUIKeyChangeMenu::regenerateGui(v2u32 screensize) +{ + /* + Remove stuff + */ + removeChildren(); + + /* + Calculate new sizes and positions + */ + + v2s32 size(620, 430); + + core::rect < s32 > rect(screensize.X / 2 - size.X / 2, + screensize.Y / 2 - size.Y / 2, screensize.X / 2 + size.X / 2, + screensize.Y / 2 + size.Y / 2); + + DesiredRect = rect; + recalculateAbsolutePosition(false); + + v2s32 topleft(0, 0); + + { + core::rect < s32 > rect(0, 0, 125, 20); + rect += topleft + v2s32(25, 3); + const wchar_t *text = L"KEYBINDINGS"; + //gui::IGUIStaticText *t = + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + v2s32 offset(25, 40); + // buttons + + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Forward"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->forward = Environment->addButton(rect, this, + GUI_ID_KEY_FORWARD_BUTTON, + narrow_to_wide(KeyNames[key_forward]).c_str()); + } + + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Backward"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->backward = Environment->addButton(rect, this, + GUI_ID_KEY_BACKWARD_BUTTON, + narrow_to_wide(KeyNames[key_backward]).c_str()); + } + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Left"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->left = Environment->addButton(rect, this, GUI_ID_KEY_LEFT_BUTTON, + narrow_to_wide(KeyNames[key_left]).c_str()); + } + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Right"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->right = Environment->addButton(rect, this, + GUI_ID_KEY_RIGHT_BUTTON, + narrow_to_wide(KeyNames[key_right]).c_str()); + } + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Use"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->use = Environment->addButton(rect, this, GUI_ID_KEY_USE_BUTTON, + narrow_to_wide(KeyNames[key_use]).c_str()); + } + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Sneak"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->sneak = Environment->addButton(rect, this, + GUI_ID_KEY_SNEAK_BUTTON, + narrow_to_wide(KeyNames[key_sneak]).c_str()); + } + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Jump"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->jump = Environment->addButton(rect, this, GUI_ID_KEY_JUMP_BUTTON, + narrow_to_wide(KeyNames[key_jump]).c_str()); + } + + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Inventory"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->inventory = Environment->addButton(rect, this, + GUI_ID_KEY_INVENTORY_BUTTON, + narrow_to_wide(KeyNames[key_inventory]).c_str()); + } + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Chat"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->chat = Environment->addButton(rect, this, GUI_ID_KEY_CHAT_BUTTON, + narrow_to_wide(KeyNames[key_chat]).c_str()); + } + + //next col + offset = v2s32(250, 40); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Toggle fly"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->fly = Environment->addButton(rect, this, GUI_ID_KEY_FLY_BUTTON, + narrow_to_wide(KeyNames[key_fly]).c_str()); + } + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Toggle fast"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->fast = Environment->addButton(rect, this, GUI_ID_KEY_FAST_BUTTON, + narrow_to_wide(KeyNames[key_fast]).c_str()); + } + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Range select"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->range = Environment->addButton(rect, this, + GUI_ID_KEY_RANGE_BUTTON, + narrow_to_wide(KeyNames[key_range]).c_str()); + } + + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Print stacks"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->dump = Environment->addButton(rect, this, GUI_ID_KEY_DUMP_BUTTON, + narrow_to_wide(KeyNames[key_dump]).c_str()); + } + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(size.X - 100 - 20, size.Y - 40); + Environment->addButton(rect, this, GUI_ID_BACK_BUTTON, L"Save"); + } + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(size.X - 100 - 20 - 100 - 20, size.Y - 40); + Environment->addButton(rect, this, GUI_ID_ABORT_BUTTON, L"Cancel"); + } +} + +void GUIKeyChangeMenu::drawMenu() +{ + gui::IGUISkin* skin = Environment->getSkin(); + if (!skin) + return; + video::IVideoDriver* driver = Environment->getVideoDriver(); + + video::SColor bgcolor(140, 0, 0, 0); + + { + core::rect < s32 > rect(0, 0, 620, 620); + rect += AbsoluteRect.UpperLeftCorner; + driver->draw2DRectangle(bgcolor, rect, &AbsoluteClippingRect); + } + + gui::IGUIElement::draw(); +} + +bool GUIKeyChangeMenu::acceptInput() +{ + g_settings.set("keymap_forward", keycode_to_keyname(key_forward)); + g_settings.set("keymap_backward", keycode_to_keyname(key_backward)); + g_settings.set("keymap_left", keycode_to_keyname(key_left)); + g_settings.set("keymap_right", keycode_to_keyname(key_right)); + g_settings.set("keymap_jump", keycode_to_keyname(key_jump)); + g_settings.set("keymap_sneak", keycode_to_keyname(key_sneak)); + g_settings.set("keymap_inventory", keycode_to_keyname(key_inventory)); + g_settings.set("keymap_chat", keycode_to_keyname(key_chat)); + g_settings.set("keymap_rangeselect", keycode_to_keyname(key_range)); + g_settings.set("keymap_freemove", keycode_to_keyname(key_fly)); + g_settings.set("keymap_fastmove", keycode_to_keyname(key_fast)); + g_settings.set("keymap_special1", keycode_to_keyname(key_use)); + g_settings.set("keymap_print_debug_stacks", keycode_to_keyname(key_dump)); + //clearKeyCache(); Y U NO SCOPE?! + return true; +} +void GUIKeyChangeMenu::init_keys() +{ + key_forward = getKeySetting("keymap_forward"); + key_backward = getKeySetting("keymap_backward"); + key_left = getKeySetting("keymap_left"); + key_right = getKeySetting("keymap_right"); + key_jump = getKeySetting("keymap_jump"); + key_sneak = getKeySetting("keymap_sneak"); + key_inventory = getKeySetting("keymap_inventory"); + key_chat = getKeySetting("keymap_chat"); + key_range = getKeySetting("keymap_rangeselect"); + key_fly = getKeySetting("keymap_freemove"); + key_fast = getKeySetting("keymap_fastmove"); + key_use = getKeySetting("keymap_special1"); + key_dump = getKeySetting("keymap_print_debug_stacks"); +} + +bool GUIKeyChangeMenu::resetMenu() +{ + if (activeKey >= 0) + { + switch (activeKey) + { + case GUI_ID_KEY_FORWARD_BUTTON: + this->forward->setText( + narrow_to_wide(KeyNames[key_forward]).c_str()); + break; + case GUI_ID_KEY_BACKWARD_BUTTON: + this->backward->setText( + narrow_to_wide(KeyNames[key_backward]).c_str()); + break; + case GUI_ID_KEY_LEFT_BUTTON: + this->left->setText(narrow_to_wide(KeyNames[key_left]).c_str()); + break; + case GUI_ID_KEY_RIGHT_BUTTON: + this->right->setText(narrow_to_wide(KeyNames[key_right]).c_str()); + break; + case GUI_ID_KEY_JUMP_BUTTON: + this->jump->setText(narrow_to_wide(KeyNames[key_jump]).c_str()); + break; + case GUI_ID_KEY_SNEAK_BUTTON: + this->sneak->setText(narrow_to_wide(KeyNames[key_sneak]).c_str()); + break; + case GUI_ID_KEY_INVENTORY_BUTTON: + this->inventory->setText( + narrow_to_wide(KeyNames[key_inventory]).c_str()); + break; + case GUI_ID_KEY_CHAT_BUTTON: + this->chat->setText(narrow_to_wide(KeyNames[key_chat]).c_str()); + break; + case GUI_ID_KEY_RANGE_BUTTON: + this->range->setText(narrow_to_wide(KeyNames[key_range]).c_str()); + break; + case GUI_ID_KEY_FLY_BUTTON: + this->fly->setText(narrow_to_wide(KeyNames[key_fly]).c_str()); + break; + case GUI_ID_KEY_FAST_BUTTON: + this->fast->setText(narrow_to_wide(KeyNames[key_fast]).c_str()); + break; + case GUI_ID_KEY_USE_BUTTON: + this->use->setText(narrow_to_wide(KeyNames[key_use]).c_str()); + break; + case GUI_ID_KEY_DUMP_BUTTON: + this->dump->setText(narrow_to_wide(KeyNames[key_dump]).c_str()); + break; + } + activeKey = -1; + return false; + } + return true; +} +bool GUIKeyChangeMenu::OnEvent(const SEvent& event) +{ + if (event.EventType == EET_KEY_INPUT_EVENT && activeKey >= 0 + && event.KeyInput.PressedDown) + { + if (activeKey == GUI_ID_KEY_FORWARD_BUTTON) + { + this->forward->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_forward = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_BACKWARD_BUTTON) + { + this->backward->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_backward = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_LEFT_BUTTON) + { + this->left->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_left = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_RIGHT_BUTTON) + { + this->right->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_right = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_JUMP_BUTTON) + { + this->jump->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_jump = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_SNEAK_BUTTON) + { + this->sneak->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_sneak = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_INVENTORY_BUTTON) + { + this->inventory->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_inventory = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_CHAT_BUTTON) + { + this->chat->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_chat = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_RANGE_BUTTON) + { + this->range->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_range = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_FLY_BUTTON) + { + this->fly->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_fly = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_FAST_BUTTON) + { + this->fast->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_fast = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_USE_BUTTON) + { + this->use->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_use = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_DUMP_BUTTON) + { + this->dump->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_dump = event.KeyInput.Key; + } + + activeKey = -1; + return true; + } + if (event.EventType == EET_GUI_EVENT) + { + if (event.GUIEvent.EventType == gui::EGET_ELEMENT_FOCUS_LOST + && isVisible()) + { + if (!canTakeFocus(event.GUIEvent.Element)) + { + dstream << "GUIMainMenu: Not allowing focus change." + << std::endl; + // Returning true disables focus change + return true; + } + } + if (event.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED) + { + switch (event.GUIEvent.Caller->getID()) + { + case GUI_ID_BACK_BUTTON: //back + acceptInput(); + quitMenu(); + return true; + case GUI_ID_ABORT_BUTTON: //abort + quitMenu(); + return true; + case GUI_ID_KEY_FORWARD_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->forward->setText(L"press Key"); + break; + case GUI_ID_KEY_BACKWARD_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->backward->setText(L"press Key"); + break; + case GUI_ID_KEY_LEFT_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->left->setText(L"press Key"); + break; + case GUI_ID_KEY_RIGHT_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->right->setText(L"press Key"); + break; + case GUI_ID_KEY_USE_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->use->setText(L"press Key"); + break; + case GUI_ID_KEY_FLY_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->fly->setText(L"press Key"); + break; + case GUI_ID_KEY_FAST_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->fast->setText(L"press Key"); + break; + case GUI_ID_KEY_JUMP_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->jump->setText(L"press Key"); + break; + case GUI_ID_KEY_CHAT_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->chat->setText(L"press Key"); + break; + case GUI_ID_KEY_SNEAK_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->sneak->setText(L"press Key"); + break; + case GUI_ID_KEY_INVENTORY_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->inventory->setText(L"press Key"); + break; + case GUI_ID_KEY_DUMP_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->dump->setText(L"press Key"); + break; + case GUI_ID_KEY_RANGE_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->range->setText(L"press Key"); + break; + } + //Buttons + + } + } + return Parent ? Parent->OnEvent(event) : false; +} + diff --git a/src/guiKeyChangeMenu.h b/src/guiKeyChangeMenu.h new file mode 100644 index 000000000..389ce7aee --- /dev/null +++ b/src/guiKeyChangeMenu.h @@ -0,0 +1,133 @@ +/* + Minetest-delta + Copyright (C) 2010-11 celeron55, Perttu Ahola + Copyright (C) 2011 Ciaran Gultnieks + Copyright (C) 2011 teddydestodes + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef GUIKEYCHANGEMENU_HEADER +#define GUIKEYCHANGEMENU_HEADER + +#include "common_irrlicht.h" +#include "utility.h" +#include "modalMenu.h" +#include "client.h" +#include + +static const char *KeyNames[] = + { "-", "Left Button", "Right Button", "Cancel", "Middle Button", "X Button 1", + "X Button 2", "-", "Back", "Tab", "-", "-", "Clear", "Return", "-", + "-", "Shift", "Control", "Menu", "Pause", "Capital", "Kana", "-", + "Junja", "Final", "Kanji", "-", "Escape", "Convert", "Nonconvert", + "Accept", "Mode Change", "Space", "Priot", "Next", "End", "Home", + "Left", "Up", "Right", "Down", "Select", "Print", "Execute", + "Snapshot", "Insert", "Delete", "Help", "0", "1", "2", "3", "4", "5", + "6", "7", "8", "9", "-", "-", "-", "-", "-", "-", "-", "A", "B", "C", + "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", + "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "Left Windows", + "Right Windows", "Apps", "-", "Sleep", "Numpad 0", "Numpad 1", + "Numpad 2", "Numpad 3", "Numpad 4", "Numpad 5", "Numpad 6", "Numpad 7", + "Numpad 8", "Numpad 9", "Numpad *", "Numpad +", "Numpad /", "Numpad -", + "Numpad .", "Numpad /", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", + "F9", "F10", "F11", "F12", "F13", "F14", "F15", "F16", "F17", "F18", + "F19", "F20", "F21", "F22", "F23", "F24", "-", "-", "-", "-", "-", "-", + "-", "-", "Num Lock", "Scroll Lock", "-", "-", "-", "-", "-", "-", "-", + "-", "-", "-", "-", "-", "-", "-", "Left Shift", "Right Shight", + "Left Control", "Right Control", "Left Menu", "Right Menu", "-", "-", + "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", + "-", "-", "-", "-", "-", "Plus", "Comma", "Minus", "Period", "-", "-", + "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", + "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", + "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", + "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "Attn", "CrSel", + "ExSel", "Erase OEF", "Play", "Zoom", "PA1", "OEM Clear", "-" }; + enum + { + GUI_ID_BACK_BUTTON = 101, GUI_ID_ABORT_BUTTON, GUI_ID_SCROLL_BAR, + //buttons + GUI_ID_KEY_FORWARD_BUTTON, + GUI_ID_KEY_BACKWARD_BUTTON, + GUI_ID_KEY_LEFT_BUTTON, + GUI_ID_KEY_RIGHT_BUTTON, + GUI_ID_KEY_USE_BUTTON, + GUI_ID_KEY_FLY_BUTTON, + GUI_ID_KEY_FAST_BUTTON, + GUI_ID_KEY_JUMP_BUTTON, + GUI_ID_KEY_CHAT_BUTTON, + GUI_ID_KEY_SNEAK_BUTTON, + GUI_ID_KEY_INVENTORY_BUTTON, + GUI_ID_KEY_DUMP_BUTTON, + GUI_ID_KEY_RANGE_BUTTON + }; + +class GUIKeyChangeMenu: public GUIModalMenu +{ +public: + GUIKeyChangeMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent, + s32 id, IMenuManager *menumgr); + ~GUIKeyChangeMenu(); + + void removeChildren(); + /* + Remove and re-add (or reposition) stuff + */ + void regenerateGui(v2u32 screensize); + + void drawMenu(); + + bool acceptInput(); + + bool OnEvent(const SEvent& event); + +private: + + void init_keys(); + + bool resetMenu(); + + gui::IGUIButton *forward; + gui::IGUIButton *backward; + gui::IGUIButton *left; + gui::IGUIButton *right; + gui::IGUIButton *use; + gui::IGUIButton *sneak; + gui::IGUIButton *jump; + gui::IGUIButton *inventory; + gui::IGUIButton *fly; + gui::IGUIButton *fast; + gui::IGUIButton *range; + gui::IGUIButton *dump; + gui::IGUIButton *chat; + + u32 activeKey; + u32 key_forward; + u32 key_backward; + u32 key_left; + u32 key_right; + u32 key_use; + u32 key_sneak; + u32 key_jump; + u32 key_inventory; + u32 key_fly; + u32 key_fast; + u32 key_range; + u32 key_chat; + u32 key_dump; +}; + +#endif + diff --git a/src/guiMainMenu.cpp b/src/guiMainMenu.cpp index a30e006a6..cea32860b 100644 --- a/src/guiMainMenu.cpp +++ b/src/guiMainMenu.cpp @@ -18,10 +18,13 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "guiMainMenu.h" +#include "guiKeyChangeMenu.h" #include "debug.h" #include "serialization.h" #include + + GUIMainMenu::GUIMainMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent, s32 id, IMenuManager *menumgr, @@ -34,6 +37,10 @@ GUIMainMenu::GUIMainMenu(gui::IGUIEnvironment* env, m_gamecallback(gamecallback) { assert(m_data); + this->env = env; + this->parent = parent; + this->id = id; + this->menumgr = menumgr; } GUIMainMenu::~GUIMainMenu() @@ -70,35 +77,35 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) // Client options { - gui::IGUIElement *e = getElementFromId(258); + gui::IGUIElement *e = getElementFromId(GUI_ID_NAME_INPUT); if(e != NULL) text_name = e->getText(); else text_name = m_data->name; } { - gui::IGUIElement *e = getElementFromId(256); + gui::IGUIElement *e = getElementFromId(GUI_ID_ADDRESS_INPUT); if(e != NULL) text_address = e->getText(); else text_address = m_data->address; } { - gui::IGUIElement *e = getElementFromId(257); + gui::IGUIElement *e = getElementFromId(GUI_ID_PORT_INPUT); if(e != NULL) text_port = e->getText(); else text_port = m_data->port; } { - gui::IGUIElement *e = getElementFromId(263); + gui::IGUIElement *e = getElementFromId(GUI_ID_FANCYTREE_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) fancy_trees = ((gui::IGUICheckBox*)e)->isChecked(); else fancy_trees = m_data->fancy_trees; } { - gui::IGUIElement *e = getElementFromId(262); + gui::IGUIElement *e = getElementFromId(GUI_ID_SMOOTH_LIGHTING_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) smooth_lighting = ((gui::IGUICheckBox*)e)->isChecked(); else @@ -107,14 +114,14 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) // Server options { - gui::IGUIElement *e = getElementFromId(259); + gui::IGUIElement *e = getElementFromId(GUI_ID_CREATIVE_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) creative_mode = ((gui::IGUICheckBox*)e)->isChecked(); else creative_mode = m_data->creative_mode; } { - gui::IGUIElement *e = getElementFromId(261); + gui::IGUIElement *e = getElementFromId(GUI_ID_DAMAGE_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) enable_damage = ((gui::IGUICheckBox*)e)->isChecked(); else @@ -175,7 +182,7 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) core::rect rect(0, 0, 230, 30); rect += topleft_client + v2s32(160, 50); gui::IGUIElement *e = - Environment->addEditBox(text_name.c_str(), rect, true, this, 258); + Environment->addEditBox(text_name.c_str(), rect, true, this, GUI_ID_NAME_INPUT); if(text_name == L"") Environment->setFocus(e); } @@ -198,7 +205,7 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) core::rect rect(0, 0, 230, 30); rect += topleft_client + v2s32(160, 100); gui::IGUIElement *e = - Environment->addEditBox(text_address.c_str(), rect, true, this, 256); + Environment->addEditBox(text_address.c_str(), rect, true, this, GUI_ID_ADDRESS_INPUT); if(text_name != L"") Environment->setFocus(e); } @@ -206,7 +213,7 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) core::rect rect(0, 0, 120, 30); //rect += topleft_client + v2s32(160+250+20, 125); rect += topleft_client + v2s32(size_client.X-60-100, 100); - Environment->addEditBox(text_port.c_str(), rect, true, this, 257); + Environment->addEditBox(text_port.c_str(), rect, true, this, GUI_ID_PORT_INPUT); } { core::rect rect(0, 0, 400, 20); @@ -217,13 +224,13 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) { core::rect rect(0, 0, 250, 30); rect += topleft_client + v2s32(35, 150); - Environment->addCheckBox(fancy_trees, rect, this, 263, + Environment->addCheckBox(fancy_trees, rect, this, GUI_ID_FANCYTREE_CB, L"Fancy trees"); } { core::rect rect(0, 0, 250, 30); rect += topleft_client + v2s32(35, 150+30); - Environment->addCheckBox(smooth_lighting, rect, this, 262, + Environment->addCheckBox(smooth_lighting, rect, this, GUI_ID_SMOOTH_LIGHTING_CB, L"Smooth Lighting"); } // Start game button @@ -231,9 +238,16 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) core::rect rect(0, 0, 180, 30); //rect += topleft_client + v2s32(size_client.X/2-180/2, 225-30/2); rect += topleft_client + v2s32(size_client.X-180-40, 150+25); - Environment->addButton(rect, this, 257, L"Start Game / Connect"); + Environment->addButton(rect, this, GUI_ID_JOIN_GAME_BUTTON, L"Start Game / Connect"); } + // Key change button + { + core::rect rect(0, 0, 100, 30); + //rect += topleft_client + v2s32(size_client.X/2-180/2, 225-30/2); + rect += topleft_client + v2s32(size_client.X-180-40-100-20, 150+25); + Environment->addButton(rect, this, GUI_ID_CHANGE_KEYS_BUTTON, L"Change keys"); + } /* Server section */ @@ -254,19 +268,19 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) { core::rect rect(0, 0, 250, 30); rect += topleft_server + v2s32(35, 30); - Environment->addCheckBox(creative_mode, rect, this, 259, L"Creative Mode"); + Environment->addCheckBox(creative_mode, rect, this, GUI_ID_CREATIVE_CB, L"Creative Mode"); } { core::rect rect(0, 0, 250, 30); rect += topleft_server + v2s32(35, 60); - Environment->addCheckBox(enable_damage, rect, this, 261, L"Enable Damage"); + Environment->addCheckBox(enable_damage, rect, this, GUI_ID_DAMAGE_CB, L"Enable Damage"); } // Map delete button { core::rect rect(0, 0, 130, 30); //rect += topleft_server + v2s32(size_server.X-40-130, 100+25); rect += topleft_server + v2s32(40, 100+25); - Environment->addButton(rect, this, 260, L"Delete map"); + Environment->addButton(rect, this, GUI_ID_DELETE_MAP_BUTTON, L"Delete map"); } } @@ -300,7 +314,7 @@ void GUIMainMenu::drawMenu() void GUIMainMenu::acceptInput() { { - gui::IGUIElement *e = getElementFromId(258); + gui::IGUIElement *e = getElementFromId(GUI_ID_NAME_INPUT); if(e != NULL) m_data->name = e->getText(); } @@ -310,32 +324,32 @@ void GUIMainMenu::acceptInput() m_data->password = e->getText(); } { - gui::IGUIElement *e = getElementFromId(256); + gui::IGUIElement *e = getElementFromId(GUI_ID_ADDRESS_INPUT); if(e != NULL) m_data->address = e->getText(); } { - gui::IGUIElement *e = getElementFromId(257); + gui::IGUIElement *e = getElementFromId(GUI_ID_PORT_INPUT); if(e != NULL) m_data->port = e->getText(); } { - gui::IGUIElement *e = getElementFromId(259); + gui::IGUIElement *e = getElementFromId(GUI_ID_CREATIVE_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) m_data->creative_mode = ((gui::IGUICheckBox*)e)->isChecked(); } { - gui::IGUIElement *e = getElementFromId(261); + gui::IGUIElement *e = getElementFromId(GUI_ID_DAMAGE_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) m_data->enable_damage = ((gui::IGUICheckBox*)e)->isChecked(); } { - gui::IGUIElement *e = getElementFromId(262); + gui::IGUIElement *e = getElementFromId(GUI_ID_SMOOTH_LIGHTING_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) m_data->smooth_lighting = ((gui::IGUICheckBox*)e)->isChecked(); } { - gui::IGUIElement *e = getElementFromId(263); + gui::IGUIElement *e = getElementFromId(GUI_ID_FANCYTREE_CB); if(e != NULL && e->getType() == gui::EGUIET_CHECK_BOX) m_data->fancy_trees = ((gui::IGUICheckBox*)e)->isChecked(); } @@ -377,11 +391,16 @@ bool GUIMainMenu::OnEvent(const SEvent& event) { switch(event.GUIEvent.Caller->getID()) { - case 257: // Start game + case GUI_ID_JOIN_GAME_BUTTON: // Start game acceptInput(); quitMenu(); return true; - case 260: // Delete map + case GUI_ID_CHANGE_KEYS_BUTTON: { + GUIKeyChangeMenu *kmenu = new GUIKeyChangeMenu(env, parent, -1,menumgr); + kmenu->drop(); + return true; + } + case GUI_ID_DELETE_MAP_BUTTON: // Delete map // Don't accept input data, just set deletion request m_data->delete_map = true; m_accepted = true; @@ -393,7 +412,7 @@ bool GUIMainMenu::OnEvent(const SEvent& event) { switch(event.GUIEvent.Caller->getID()) { - case 256: case 257: case 258: case 264: + case GUI_ID_ADDRESS_INPUT: case GUI_ID_PORT_INPUT: case GUI_ID_NAME_INPUT: case 264: acceptInput(); quitMenu(); return true; diff --git a/src/guiMainMenu.h b/src/guiMainMenu.h index edd519024..6c028c6e5 100644 --- a/src/guiMainMenu.h +++ b/src/guiMainMenu.h @@ -1,21 +1,21 @@ /* -Minetest-c55 -Copyright (C) 2010 celeron55, Perttu Ahola + Minetest-c55 + Copyright (C) 2010 celeron55, Perttu Ahola -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ #ifndef GUIMAINMENU_HEADER #define GUIMAINMENU_HEADER @@ -27,21 +27,35 @@ with this program; if not, write to the Free Software Foundation, Inc., // For IGameCallback #include "guiPauseMenu.h" +enum +{ + GUI_ID_QUIT_BUTTON = 101, + GUI_ID_NAME_INPUT, + GUI_ID_ADDRESS_INPUT, + GUI_ID_PORT_INPUT, + GUI_ID_FANCYTREE_CB, + GUI_ID_SMOOTH_LIGHTING_CB, + GUI_ID_DAMAGE_CB, + GUI_ID_CREATIVE_CB, + GUI_ID_JOIN_GAME_BUTTON, + GUI_ID_CHANGE_KEYS_BUTTON, + GUI_ID_DELETE_MAP_BUTTON +}; + struct MainMenuData { - MainMenuData(): + MainMenuData() : // Client opts - fancy_trees(false), - smooth_lighting(false), - // Server opts - creative_mode(false), - enable_damage(false), - // Actions - delete_map(false) - {} + fancy_trees(false), smooth_lighting(false), + // Server opts + creative_mode(false), enable_damage(false), + // Actions + delete_map(false) + { + } // These are in the native format of the gui elements - + // Client options std::wstring address; std::wstring port; @@ -56,20 +70,23 @@ struct MainMenuData bool delete_map; }; -class GUIMainMenu : public GUIModalMenu +class GUIMainMenu: public GUIModalMenu { public: - GUIMainMenu(gui::IGUIEnvironment* env, - gui::IGUIElement* parent, s32 id, - IMenuManager *menumgr, - MainMenuData *data, + GUIMainMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent, s32 id, + IMenuManager *menumgr, MainMenuData *data, IGameCallback *gamecallback); ~GUIMainMenu(); - + + gui::IGUIEnvironment* env; + gui::IGUIElement* parent; + s32 id; + IMenuManager *menumgr; + void removeChildren(); /* - Remove and re-add (or reposition) stuff - */ + Remove and re-add (or reposition) stuff + */ void regenerateGui(v2u32 screensize); void drawMenu(); @@ -82,7 +99,7 @@ public: } bool OnEvent(const SEvent& event); - + private: MainMenuData *m_data; bool m_accepted; diff --git a/src/guiMessageMenu.h b/src/guiMessageMenu.h index 82c40ce09..8f48b6626 100644 --- a/src/guiMessageMenu.h +++ b/src/guiMessageMenu.h @@ -1,21 +1,21 @@ /* -Minetest-c55 -Copyright (C) 2010 celeron55, Perttu Ahola + Minetest-c55 + Copyright (C) 2010 celeron55, Perttu Ahola -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ #ifndef GUIMESSAGEMENU_HEADER #define GUIMESSAGEMENU_HEADER @@ -25,19 +25,17 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "utility.h" #include -class GUIMessageMenu : public GUIModalMenu +class GUIMessageMenu: public GUIModalMenu { public: - GUIMessageMenu(gui::IGUIEnvironment* env, - gui::IGUIElement* parent, s32 id, - IMenuManager *menumgr, - std::wstring message_text); + GUIMessageMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent, s32 id, + IMenuManager *menumgr, std::wstring message_text); ~GUIMessageMenu(); - + void removeChildren(); /* - Remove and re-add (or reposition) stuff - */ + Remove and re-add (or reposition) stuff + */ void regenerateGui(v2u32 screensize); void drawMenu(); @@ -45,13 +43,13 @@ public: bool OnEvent(const SEvent& event); /* - true = ok'd - */ + true = ok'd + */ bool getStatus() { return m_status; } - + private: std::wstring m_message_text; bool m_status; diff --git a/src/keycode.cpp b/src/keycode.cpp index ad3c0b401..993426053 100644 --- a/src/keycode.cpp +++ b/src/keycode.cpp @@ -1,25 +1,24 @@ /* -Minetest-c55 -Copyright (C) 2010-2011 celeron55, Perttu Ahola + Minetest-c55 + Copyright (C) 2010-2011 celeron55, Perttu Ahola -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ #include "keycode.h" #include "main.h" // For g_settings - #define CHECKKEY(x){if(strcmp(name, #x)==0) return irr::x;} irr::EKEY_CODE keyname_to_keycode(const char *name) @@ -171,9 +170,48 @@ irr::EKEY_CODE keyname_to_keycode(const char *name) return irr::KEY_KEY_CODES_COUNT; } +static const char *KeyNames[] = +{ "-", "KEY_LBUTTON", "KEY_RBUTTON", "Cancel", "Middle Button", "X Button 1", + "X Button 2", "-", "Back", "Tab", "-", "-", "Clear", "Return", "-", + "-", "KEY_SHIFT", "Control", "Menu", "Pause", "Capital", "Kana", "-", + "Junja", "Final", "Kanji", "-", "Escape", "Convert", "Nonconvert", + "Accept", "Mode Change", "KEY_SPACE", "Priot", "Next", "KEY_END", + "KEY_HOME", "Left", "Up", "Right", "Down", "Select", "KEY_PRINT", + "Execute", "Snapshot", "Insert", "Delete", "Help", "KEY_KEY_0", + "KEY_KEY_1", "KEY_KEY_2", "KEY_KEY_3", "KEY_KEY_4", "KEY_KEY_5", + "KEY_KEY_6", "KEY_KEY_7", "KEY_KEY_8", "KEY_KEY_9", "-", "-", "-", "-", + "-", "-", "-", "KEY_KEY_A", "KEY_KEY_B", "KEY_KEY_C", "KEY_KEY_D", + "KEY_KEY_E", "KEY_KEY_F", "KEY_KEY_G", "KEY_KEY_H", "KEY_KEY_I", + "KEY_KEY_J", "KEY_KEY_K", "KEY_KEY_L", "KEY_KEY_M", "KEY_KEY_N", + "KEY_KEY_O", "KEY_KEY_P", "KEY_KEY_Q", "KEY_KEY_R", "KEY_KEY_S", + "KEY_KEY_T", "KEY_KEY_U", "KEY_KEY_V", "KEY_KEY_W", "KEY_KEY_X", + "KEY_KEY_Y", "KEY_KEY_Z", "Left Windows", "Right Windows", "Apps", "-", + "Sleep", "KEY_NUMPAD0", "KEY_NUMPAD1", "KEY_NUMPAD2", "KEY_NUMPAD3", + "KEY_NUMPAD4", "KEY_NUMPAD5", "KEY_NUMPAD6", "KEY_NUMPAD7", + "KEY_NUMPAD8", "KEY_NUMPAD9", "Numpad *", "Numpad +", "Numpad /", + "Numpad -", "Numpad .", "Numpad /", "KEY_F1", "KEY_F2", "KEY_F3", + "KEY_F4", "KEY_F5", "KEY_F6", "KEY_F7", "KEY_F8", "KEY_F9", "KEY_F10", + "KEY_F11", "KEY_F12", "KEY_F13", "KEY_F14", "KEY_F15", "KEY_F16", + "KEY_F17", "KEY_F18", "KEY_F19", "KEY_F20", "KEY_F21", "KEY_F22", + "KEY_F23", "KEY_F24", "-", "-", "-", "-", "-", "-", "-", "-", + "Num Lock", "Scroll Lock", "-", "-", "-", "-", "-", "-", "-", "-", "-", + "-", "-", "-", "-", "-", "KEY_LSHIFT", "KEY_RSHIFT", "Left Control", + "Right Control", "Left Menu", "Right Menu", "-", "-", "-", "-", "-", + "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", + "-", "-", "Plus", "Comma", "Minus", "Period", "-", "-", "-", "-", "-", + "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", + "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", + "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", + "-", "-", "-", "-", "-", "-", "-", "-", "Attn", "CrSel", "ExSel", + "Erase OEF", "Play", "Zoom", "PA1", "OEM Clear", "-" }; + +std::string keycode_to_keyname(s32 keycode) +{ + return KeyNames[keycode]; +} /* - Key config -*/ + Key config + */ // A simple cache for quicker lookup core::map g_key_setting_cache; @@ -182,11 +220,15 @@ irr::EKEY_CODE getKeySetting(const char *settingname) { core::map::Node *n; n = g_key_setting_cache.find(settingname); - if(n) + if (n) return n->getValue(); irr::EKEY_CODE c = keyname_to_keycode(g_settings.get(settingname).c_str()); g_key_setting_cache.insert(settingname, c); return c; } +void clearKeyCache() +{ + g_key_setting_cache.clear(); +} diff --git a/src/keycode.h b/src/keycode.h index f19fe3442..614f2e584 100644 --- a/src/keycode.h +++ b/src/keycode.h @@ -21,11 +21,13 @@ with this program; if not, write to the Free Software Foundation, Inc., #define KEYCODE_HEADER #include "common_irrlicht.h" +#include irr::EKEY_CODE keyname_to_keycode(const char *name); // Key configuration getter irr::EKEY_CODE getKeySetting(const char *settingname); - +std::string keycode_to_keyname(s32 keycode); +void clearCache(); #endif -- cgit v1.2.3 From ccc0420c52d341ea20ff879aac7520179ca24bdf Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Fri, 3 Jun 2011 00:55:28 +0200 Subject: + papyrus --- src/map.cpp | 27 ++++++++++++++++++++++++-- src/mapblock.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/mapnode.cpp | 10 ++++++++++ src/mapnode.h | 1 + src/materials.cpp | 1 + src/server.cpp | 1 + src/tile.cpp | 1 + 7 files changed, 97 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/map.cpp b/src/map.cpp index ac5bd7d14..fc674d263 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2045,6 +2045,20 @@ void make_tree(VoxelManipulator &vmanip, v3s16 p0) } } +void make_papyrus(VoxelManipulator &vmanip, v3s16 p0) +{ + MapNode papyrusnode(CONTENT_PAPYRUS); + + s16 trunk_h = myrand_range(2, 3); + v3s16 p1 = p0; + for(s16 ii=0; iivmanip, v2s16(x,z)); // Don't make a tree under water level - if(y < WATER_LEVEL) + if(y < WATER_LEVEL - 1) continue; // Don't make a tree so high that it doesn't fit if(y > y_nodes_max - 6) @@ -3236,6 +3250,15 @@ void makeChunk(ChunkMakeData *data) MapNode *n = &data->vmanip.m_data[i]; if(n->d != CONTENT_MUD && n->d != CONTENT_GRASS && n->d != CONTENT_SAND) continue; + // Papyrus grows only on mud and in water + if(n->d == CONTENT_MUD && y == WATER_LEVEL - 1) + { + p.Y++; + make_papyrus(data->vmanip, p); + } + // Don't make a tree under water level + if(y < WATER_LEVEL) + continue; // Trees grow only on mud and grass if(n->d == CONTENT_MUD || n->d == CONTENT_GRASS) { @@ -3243,7 +3266,7 @@ void makeChunk(ChunkMakeData *data) make_tree(data->vmanip, p); } // Cactii grow only on sand - if(n->d == CONTENT_SAND) + else if(n->d == CONTENT_SAND) { p.Y++; make_cactus(data->vmanip, p); diff --git a/src/mapblock.cpp b/src/mapblock.cpp index d98bfaf1e..c6b82634d 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -987,6 +987,16 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data) g_texturesource->getTextureId("wood.png")); material_wood.setTexture(0, pa_wood.atlas); + // Papyrus material + video::SMaterial material_papyrus; + material_papyrus.setFlag(video::EMF_LIGHTING, false); + material_papyrus.setFlag(video::EMF_BILINEAR_FILTER, false); + material_papyrus.setFlag(video::EMF_FOG_ENABLE, true); + material_papyrus.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; + AtlasPointer pa_papyrus = g_texturesource->getTexture( + g_texturesource->getTextureId("papyrus.png")); + material_papyrus.setTexture(0, pa_papyrus.atlas); + for(s16 z=0; zm_daynight_ratio))); + video::SColor c(255,l,l,l); + + for(u32 j=0; j<4; j++) + { + video::S3DVertex vertices[4] = + { + video::S3DVertex(-BS/2,-BS/2,0, 0,0,0, c, + pa_papyrus.x0(), pa_papyrus.y1()), + video::S3DVertex(BS/2,-BS/2,0, 0,0,0, c, + pa_papyrus.x1(), pa_papyrus.y1()), + video::S3DVertex(BS/2,BS/2,0, 0,0,0, c, + pa_papyrus.x1(), pa_papyrus.y0()), + video::S3DVertex(-BS/2,BS/2,0, 0,0,0, c, + pa_papyrus.x0(), pa_papyrus.y0()), + }; + + if(j == 0) + { + for(u16 i=0; i<4; i++) + vertices[i].Pos.rotateXZBy(45); + } + else if(j == 1) + { + for(u16 i=0; i<4; i++) + vertices[i].Pos.rotateXZBy(-45); + } + else if(j == 2) + { + for(u16 i=0; i<4; i++) + vertices[i].Pos.rotateXZBy(135); + } + else if(j == 3) + { + for(u16 i=0; i<4; i++) + vertices[i].Pos.rotateXZBy(-135); + } + for(u16 i=0; i<4; i++) + { + vertices[i].Pos += intToFloat(p + blockpos_nodes, BS); + } + u16 indices[] = {0,1,2,2,3,0}; + // Add to mesh collector + collector.append(material_papyrus, vertices, 4, indices, 6); + } + } } diff --git a/src/mapnode.cpp b/src/mapnode.cpp index cef9bbf03..954c85f2f 100644 --- a/src/mapnode.cpp +++ b/src/mapnode.cpp @@ -241,6 +241,16 @@ void init_mapnode() f->is_ground_content = true; f->dug_item = std::string("MaterialItem ")+itos(i)+" 1"; + i = CONTENT_PAPYRUS; + f = &g_content_features[i]; + f->setInventoryTexture("papyrus.png"); + f->light_propagates = true; + f->param_type = CPT_LIGHT; + f->is_ground_content = true; + f->dug_item = std::string("MaterialItem ")+itos(i)+" 1"; + f->solidness = 0; // drawn separately, makes no faces + f->walkable = false; + i = CONTENT_GLASS; f = &g_content_features[i]; f->light_propagates = true; diff --git a/src/mapnode.h b/src/mapnode.h index e8cc0ab51..52d0199c4 100644 --- a/src/mapnode.h +++ b/src/mapnode.h @@ -105,6 +105,7 @@ void init_content_inventory_texture_paths(); #define CONTENT_CACTUS 23 #define CONTENT_BRICK 24 #define CONTENT_CLAY 25 +#define CONTENT_PAPYRUS 26 /* Content feature list diff --git a/src/materials.cpp b/src/materials.cpp index 8c23056f2..e95ca7ba9 100644 --- a/src/materials.cpp +++ b/src/materials.cpp @@ -76,6 +76,7 @@ void initializeMaterialProperties() setWoodLikeDiggingProperties(CONTENT_TREE, 1.0); setWoodLikeDiggingProperties(CONTENT_LEAVES, 0.15); setWoodLikeDiggingProperties(CONTENT_CACTUS, 0.75); + setWoodLikeDiggingProperties(CONTENT_PAPYRUS, 0.25); setWoodLikeDiggingProperties(CONTENT_GLASS, 0.15); setWoodLikeDiggingProperties(CONTENT_FENCE, 0.75); setWoodLikeDiggingProperties(CONTENT_WOOD, 0.75); diff --git a/src/server.cpp b/src/server.cpp index 17850c5fa..e9875456c 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -4111,6 +4111,7 @@ void setCreativeInventory(Player *player) CONTENT_TREE, CONTENT_LEAVES, CONTENT_CACTUS, + CONTENT_PAPYRUS, CONTENT_GLASS, CONTENT_FENCE, CONTENT_MESE, diff --git a/src/tile.cpp b/src/tile.cpp index 71e0c9638..c77262c49 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -517,6 +517,7 @@ void TextureSource::buildMainAtlas() sourcelist.push_back("leaves.png"); sourcelist.push_back("cactus_side.png"); sourcelist.push_back("cactus_top.png"); + sourcelist.push_back("papyrus.png"); sourcelist.push_back("glass.png"); sourcelist.push_back("mud.png^grass_side.png"); sourcelist.push_back("cobble.png"); -- cgit v1.2.3 From 8835433b5ef23c22b3b84045af6f97dc52883ef1 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Fri, 3 Jun 2011 13:12:56 +0200 Subject: + paper, book, bookshelf --- src/inventory.cpp | 4 ++++ src/mapnode.cpp | 11 +++++++++++ src/mapnode.h | 1 + src/materials.cpp | 1 + src/server.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ src/tile.cpp | 1 + 6 files changed, 67 insertions(+) (limited to 'src') diff --git a/src/inventory.cpp b/src/inventory.cpp index 3f83c7419..cb398a537 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -156,6 +156,10 @@ video::ITexture * CraftItem::getImage() if(m_subname == "Stick") name = "stick.png"; + else if(m_subname == "paper") + name = "paper.png"; + else if(m_subname == "book") + name = "book.png"; else if(m_subname == "lump_of_coal") name = "lump_of_coal.png"; else if(m_subname == "lump_of_iron") diff --git a/src/mapnode.cpp b/src/mapnode.cpp index 954c85f2f..7e97a8d04 100644 --- a/src/mapnode.cpp +++ b/src/mapnode.cpp @@ -251,6 +251,17 @@ void init_mapnode() f->solidness = 0; // drawn separately, makes no faces f->walkable = false; + i = CONTENT_BOOKSHELF; + f = &g_content_features[i]; + f->setAllTextures("bookshelf.png"); + f->setTexture(0, "wood.png"); + f->setTexture(1, "wood.png"); + // FIXME: setInventoryTextureCube() only cares for the first texture + f->setInventoryTextureCube("bookshelf.png", "bookshelf.png", "bookshelf.png"); + //f->setInventoryTextureCube("wood.png", "bookshelf.png", "bookshelf.png"); + f->param_type = CPT_MINERAL; + f->is_ground_content = true; + i = CONTENT_GLASS; f = &g_content_features[i]; f->light_propagates = true; diff --git a/src/mapnode.h b/src/mapnode.h index 52d0199c4..57335b741 100644 --- a/src/mapnode.h +++ b/src/mapnode.h @@ -106,6 +106,7 @@ void init_content_inventory_texture_paths(); #define CONTENT_BRICK 24 #define CONTENT_CLAY 25 #define CONTENT_PAPYRUS 26 +#define CONTENT_BOOKSHELF 27 /* Content feature list diff --git a/src/materials.cpp b/src/materials.cpp index e95ca7ba9..7815f593e 100644 --- a/src/materials.cpp +++ b/src/materials.cpp @@ -80,6 +80,7 @@ void initializeMaterialProperties() setWoodLikeDiggingProperties(CONTENT_GLASS, 0.15); setWoodLikeDiggingProperties(CONTENT_FENCE, 0.75); setWoodLikeDiggingProperties(CONTENT_WOOD, 0.75); + setWoodLikeDiggingProperties(CONTENT_BOOKSHELF, 0.75); setWoodLikeDiggingProperties(CONTENT_CHEST, 1.0); g_material_properties[CONTENT_SIGN_WALL].setDiggingProperties("", diff --git a/src/server.cpp b/src/server.cpp index e9875456c..f40ed05a5 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -4017,6 +4017,54 @@ void Server::UpdateCrafting(u16 peer_id) found = true; } } + + // Paper + if(!found) + { + ItemSpec specs[9]; + specs[3] = ItemSpec(ITEM_MATERIAL, CONTENT_PAPYRUS); + specs[4] = ItemSpec(ITEM_MATERIAL, CONTENT_PAPYRUS); + specs[5] = ItemSpec(ITEM_MATERIAL, CONTENT_PAPYRUS); + if(checkItemCombination(items, specs)) + { + rlist->addItem(new CraftItem("paper", 1)); + found = true; + } + } + + // Book + if(!found) + { + ItemSpec specs[9]; + specs[1] = ItemSpec(ITEM_CRAFT, "paper"); + specs[4] = ItemSpec(ITEM_CRAFT, "paper"); + specs[7] = ItemSpec(ITEM_CRAFT, "paper"); + if(checkItemCombination(items, specs)) + { + rlist->addItem(new CraftItem("book", 1)); + found = true; + } + } + + // Book shelf + if(!found) + { + ItemSpec specs[9]; + specs[0] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD); + specs[1] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD); + specs[2] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD); + specs[3] = ItemSpec(ITEM_CRAFT, "book"); + specs[4] = ItemSpec(ITEM_CRAFT, "book"); + specs[5] = ItemSpec(ITEM_CRAFT, "book"); + specs[6] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD); + specs[7] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD); + specs[8] = ItemSpec(ITEM_MATERIAL, CONTENT_WOOD); + if(checkItemCombination(items, specs)) + { + rlist->addItem(new MaterialItem(CONTENT_BOOKSHELF, 1)); + found = true; + } + } } } // if creative_mode == false @@ -4112,6 +4160,7 @@ void setCreativeInventory(Player *player) CONTENT_LEAVES, CONTENT_CACTUS, CONTENT_PAPYRUS, + CONTENT_BOOKSHELF, CONTENT_GLASS, CONTENT_FENCE, CONTENT_MESE, diff --git a/src/tile.cpp b/src/tile.cpp index c77262c49..c703e147c 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -518,6 +518,7 @@ void TextureSource::buildMainAtlas() sourcelist.push_back("cactus_side.png"); sourcelist.push_back("cactus_top.png"); sourcelist.push_back("papyrus.png"); + sourcelist.push_back("bookshelf.png"); sourcelist.push_back("glass.png"); sourcelist.push_back("mud.png^grass_side.png"); sourcelist.push_back("cobble.png"); -- cgit v1.2.3 From f625a22e012e7d750b340c7713c47bfd296a585b Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Fri, 3 Jun 2011 13:13:31 +0200 Subject: * point out setInventoryTextureCube() is broken with a FIXME --- src/tile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/tile.cpp b/src/tile.cpp index c703e147c..77084bf10 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -1092,7 +1092,7 @@ bool generate_image(std::string part_of_name, video::IImage *& baseimg, imagename_right, device); assert(img_top && img_left && img_right); - // TODO: Create textures from images + // FIXME: Create textures from left and right images video::ITexture *texture_top = driver->addTexture( (imagename_top + "__temp__").c_str(), img_top); assert(texture_top); -- cgit v1.2.3 From 3be6891938fec9927854a0f0abe821a6271bba23 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Tue, 7 Jun 2011 19:24:30 +0200 Subject: + rail --- src/mapblock.cpp | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/mapnode.cpp | 11 ++++++ src/mapnode.h | 1 + src/materials.cpp | 1 + src/server.cpp | 21 +++++++++++ 5 files changed, 138 insertions(+) (limited to 'src') diff --git a/src/mapblock.cpp b/src/mapblock.cpp index c6b82634d..71044652d 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -1672,6 +1672,110 @@ scene::SMesh* makeMapBlockMesh(MeshMakeData *data) collector.append(material_papyrus, vertices, 4, indices, 6); } } + else if(n.d == CONTENT_RAIL) + { + u8 l = decode_light(n.getLightBlend(data->m_daynight_ratio)); + video::SColor c(255,l,l,l); + + bool is_rail_x [] = { false, false }; /* x-1, x+1 */ + bool is_rail_z [] = { false, false }; /* z-1, z+1 */ + + MapNode n_minus_x = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x-1,y,z)); + MapNode n_plus_x = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x+1,y,z)); + MapNode n_minus_z = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x,y,z-1)); + MapNode n_plus_z = data->m_vmanip.getNodeNoEx(blockpos_nodes + v3s16(x,y,z+1)); + + if(n_minus_x.d == CONTENT_RAIL) + is_rail_x[0] = true; + if(n_plus_x.d == CONTENT_RAIL) + is_rail_x[1] = true; + if(n_minus_z.d == CONTENT_RAIL) + is_rail_z[0] = true; + if(n_plus_z.d == CONTENT_RAIL) + is_rail_z[1] = true; + + float d = (float)BS/16; + video::S3DVertex vertices[4] = + { + video::S3DVertex(-BS/2,-BS/2+d,-BS/2, 0,0,0, c, + 0, 1), + video::S3DVertex(BS/2,-BS/2+d,-BS/2, 0,0,0, c, + 1, 1), + video::S3DVertex(BS/2,-BS/2+d,BS/2, 0,0,0, c, + 1, 0), + video::S3DVertex(-BS/2,-BS/2+d,BS/2, 0,0,0, c, + 0, 0), + }; + + video::SMaterial material_rail; + material_rail.setFlag(video::EMF_LIGHTING, false); + material_rail.setFlag(video::EMF_BACK_FACE_CULLING, false); + material_rail.setFlag(video::EMF_BILINEAR_FILTER, false); + material_rail.setFlag(video::EMF_FOG_ENABLE, true); + material_rail.MaterialType + = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; + + int adjacencies = is_rail_x[0] + is_rail_x[1] + is_rail_z[0] + is_rail_z[1]; + + // Assign textures + if(adjacencies < 2) + material_rail.setTexture(0, g_texturesource->getTextureRaw("rail.png")); + else if(adjacencies == 2) + { + if((is_rail_x[0] && is_rail_x[1]) || (is_rail_z[0] && is_rail_z[1])) + material_rail.setTexture(0, g_texturesource->getTextureRaw("rail.png")); + else + material_rail.setTexture(0, g_texturesource->getTextureRaw("rail_curved.png")); + } + else if(adjacencies == 3) + material_rail.setTexture(0, g_texturesource->getTextureRaw("rail_t_junction.png")); + else if(adjacencies == 4) + material_rail.setTexture(0, g_texturesource->getTextureRaw("rail_crossing.png")); + + // Rotate textures + int angle = 0; + + if(adjacencies == 1) + { + if(is_rail_x[0] || is_rail_x[1]) + angle = 90; + } + else if(adjacencies == 2) + { + if(is_rail_x[0] && is_rail_x[1]) + angle = 90; + else if(is_rail_x[0] && is_rail_z[0]) + angle = 270; + else if(is_rail_x[0] && is_rail_z[1]) + angle = 180; + else if(is_rail_x[1] && is_rail_z[1]) + angle = 90; + } + else if(adjacencies == 3) + { + if(!is_rail_x[0]) + angle=0; + if(!is_rail_x[1]) + angle=180; + if(!is_rail_z[0]) + angle=90; + if(!is_rail_z[1]) + angle=270; + } + + if(angle != 0) { + for(u16 i=0; i<4; i++) + vertices[i].Pos.rotateXZBy(angle); + } + + for(s32 i=0; i<4; i++) + { + vertices[i].Pos += intToFloat(p + blockpos_nodes, BS); + } + + u16 indices[] = {0,1,2,2,3,0}; + collector.append(material_rail, vertices, 4, indices, 6); + } } diff --git a/src/mapnode.cpp b/src/mapnode.cpp index 7e97a8d04..1c0a2740b 100644 --- a/src/mapnode.cpp +++ b/src/mapnode.cpp @@ -281,6 +281,17 @@ void init_mapnode() f->solidness = 0; // drawn separately, makes no faces f->air_equivalent = true; // grass grows underneath + i = CONTENT_RAIL; + f = &g_content_features[i]; + f->setInventoryTexture("rail.png"); + f->light_propagates = true; + f->param_type = CPT_LIGHT; + f->is_ground_content = true; + f->dug_item = std::string("MaterialItem ")+itos(i)+" 1"; + f->solidness = 0; // drawn separately, makes no faces + f->air_equivalent = true; // grass grows underneath + f->walkable = false; + // Deprecated i = CONTENT_COALSTONE; f = &g_content_features[i]; diff --git a/src/mapnode.h b/src/mapnode.h index 57335b741..409fe2bcf 100644 --- a/src/mapnode.h +++ b/src/mapnode.h @@ -107,6 +107,7 @@ void init_content_inventory_texture_paths(); #define CONTENT_CLAY 25 #define CONTENT_PAPYRUS 26 #define CONTENT_BOOKSHELF 27 +#define CONTENT_RAIL 28 /* Content feature list diff --git a/src/materials.cpp b/src/materials.cpp index 7815f593e..a8a9a94a8 100644 --- a/src/materials.cpp +++ b/src/materials.cpp @@ -79,6 +79,7 @@ void initializeMaterialProperties() setWoodLikeDiggingProperties(CONTENT_PAPYRUS, 0.25); setWoodLikeDiggingProperties(CONTENT_GLASS, 0.15); setWoodLikeDiggingProperties(CONTENT_FENCE, 0.75); + setDirtLikeDiggingProperties(CONTENT_RAIL, 0.75); setWoodLikeDiggingProperties(CONTENT_WOOD, 0.75); setWoodLikeDiggingProperties(CONTENT_BOOKSHELF, 0.75); setWoodLikeDiggingProperties(CONTENT_CHEST, 1.0); diff --git a/src/server.cpp b/src/server.cpp index f40ed05a5..4e9ff076f 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -3915,6 +3915,26 @@ void Server::UpdateCrafting(u16 peer_id) } } + // Rail + if(!found) + { + ItemSpec specs[9]; + specs[0] = ItemSpec(ITEM_CRAFT, "steel_ingot"); + specs[1] = ItemSpec(ITEM_CRAFT, "Stick"); + specs[2] = ItemSpec(ITEM_CRAFT, "steel_ingot"); + specs[3] = ItemSpec(ITEM_CRAFT, "steel_ingot"); + specs[4] = ItemSpec(ITEM_CRAFT, "Stick"); + specs[5] = ItemSpec(ITEM_CRAFT, "steel_ingot"); + specs[6] = ItemSpec(ITEM_CRAFT, "steel_ingot"); + specs[7] = ItemSpec(ITEM_CRAFT, "Stick"); + specs[8] = ItemSpec(ITEM_CRAFT, "steel_ingot"); + if(checkItemCombination(items, specs)) + { + rlist->addItem(new MaterialItem(CONTENT_RAIL, 15)); + found = true; + } + } + // Chest if(!found) { @@ -4163,6 +4183,7 @@ void setCreativeInventory(Player *player) CONTENT_BOOKSHELF, CONTENT_GLASS, CONTENT_FENCE, + CONTENT_RAIL, CONTENT_MESE, CONTENT_WATERSOURCE, CONTENT_CLOUD, -- cgit v1.2.3 From 158b054e72582005d895f1ed0e1cb0c9b22a8e57 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Wed, 8 Jun 2011 05:27:51 +0200 Subject: + rail block bounding box --- src/game.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src') diff --git a/src/game.cpp b/src/game.cpp index 7970a6ed9..bbd0a22ef 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -530,6 +530,43 @@ void getPointedNode(Client *client, v3f player_position, } } } + else if(n.d == CONTENT_RAIL) + { + v3s16 dir = unpackDir(n.dir); + v3f dir_f = v3f(dir.X, dir.Y, dir.Z); + dir_f *= BS/2 - BS/6 - BS/20; + v3f cpf = npf + dir_f; + f32 distance = (cpf - camera_position).getLength(); + + float d = (float)BS/16; + v3f vertices[4] = + { + v3f(BS/2, -BS/2+d, -BS/2), + v3f(-BS/2, -BS/2, BS/2), + }; + + for(s32 i=0; i<2; i++) + { + vertices[i] += npf; + } + + core::aabbox3d box; + + box = core::aabbox3d(vertices[0]); + box.addInternalPoint(vertices[1]); + + if(distance < mindistance) + { + if(box.intersectsWithLine(shootline)) + { + nodefound = true; + nodepos = np; + neighbourpos = np; + mindistance = distance; + nodehilightbox = box; + } + } + } /* Regular blocks */ -- cgit v1.2.3 From 4f44cabe1cdadc926d55f7a24235b618d2c3c163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20R=C3=BChl?= Date: Sun, 26 Jun 2011 12:52:03 +0200 Subject: small fix --- src/guiKeyChangeMenu.cpp | 598 +++++++++++++++++++++++++++++++++++++++++++++++ src/guiKeyChangeMenu.h | 133 +++++++++++ 2 files changed, 731 insertions(+) create mode 100644 src/guiKeyChangeMenu.cpp create mode 100644 src/guiKeyChangeMenu.h (limited to 'src') diff --git a/src/guiKeyChangeMenu.cpp b/src/guiKeyChangeMenu.cpp new file mode 100644 index 000000000..3e594aeca --- /dev/null +++ b/src/guiKeyChangeMenu.cpp @@ -0,0 +1,598 @@ +/* + Minetest-delta + Copyright (C) 2010-11 celeron55, Perttu Ahola + Copyright (C) 2011 Ciaran Gultnieks + Copyright (C) 2011 teddydestodes + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "guiKeyChangeMenu.h" +#include "debug.h" +#include "serialization.h" +#include "keycode.h" +#include "main.h" +#include + +GUIKeyChangeMenu::GUIKeyChangeMenu(gui::IGUIEnvironment* env, + gui::IGUIElement* parent, s32 id, IMenuManager *menumgr) : + GUIModalMenu(env, parent, id, menumgr) +{ + activeKey = -1; + init_keys(); +} + +GUIKeyChangeMenu::~GUIKeyChangeMenu() +{ + removeChildren(); +} + +void GUIKeyChangeMenu::removeChildren() +{ + const core::list &children = getChildren(); + core::list children_copy; + for (core::list::ConstIterator i = children.begin(); i + != children.end(); i++) + { + children_copy.push_back(*i); + } + for (core::list::Iterator i = children_copy.begin(); i + != children_copy.end(); i++) + { + (*i)->remove(); + } +} + +void GUIKeyChangeMenu::regenerateGui(v2u32 screensize) +{ + /* + Remove stuff + */ + removeChildren(); + + /* + Calculate new sizes and positions + */ + + v2s32 size(620, 430); + + core::rect < s32 > rect(screensize.X / 2 - size.X / 2, + screensize.Y / 2 - size.Y / 2, screensize.X / 2 + size.X / 2, + screensize.Y / 2 + size.Y / 2); + + DesiredRect = rect; + recalculateAbsolutePosition(false); + + v2s32 topleft(0, 0); + + { + core::rect < s32 > rect(0, 0, 125, 20); + rect += topleft + v2s32(25, 3); + const wchar_t *text = L"KEYBINDINGS"; + //gui::IGUIStaticText *t = + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + v2s32 offset(25, 40); + // buttons + + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Forward"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->forward = Environment->addButton(rect, this, + GUI_ID_KEY_FORWARD_BUTTON, + narrow_to_wide(KeyNames[key_forward]).c_str()); + } + + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Backward"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->backward = Environment->addButton(rect, this, + GUI_ID_KEY_BACKWARD_BUTTON, + narrow_to_wide(KeyNames[key_backward]).c_str()); + } + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Left"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->left = Environment->addButton(rect, this, GUI_ID_KEY_LEFT_BUTTON, + narrow_to_wide(KeyNames[key_left]).c_str()); + } + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Right"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->right = Environment->addButton(rect, this, + GUI_ID_KEY_RIGHT_BUTTON, + narrow_to_wide(KeyNames[key_right]).c_str()); + } + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Use"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->use = Environment->addButton(rect, this, GUI_ID_KEY_USE_BUTTON, + narrow_to_wide(KeyNames[key_use]).c_str()); + } + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Sneak"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->sneak = Environment->addButton(rect, this, + GUI_ID_KEY_SNEAK_BUTTON, + narrow_to_wide(KeyNames[key_sneak]).c_str()); + } + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Jump"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->jump = Environment->addButton(rect, this, GUI_ID_KEY_JUMP_BUTTON, + narrow_to_wide(KeyNames[key_jump]).c_str()); + } + + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Inventory"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->inventory = Environment->addButton(rect, this, + GUI_ID_KEY_INVENTORY_BUTTON, + narrow_to_wide(KeyNames[key_inventory]).c_str()); + } + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Chat"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->chat = Environment->addButton(rect, this, GUI_ID_KEY_CHAT_BUTTON, + narrow_to_wide(KeyNames[key_chat]).c_str()); + } + + //next col + offset = v2s32(250, 40); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Toggle fly"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->fly = Environment->addButton(rect, this, GUI_ID_KEY_FLY_BUTTON, + narrow_to_wide(KeyNames[key_fly]).c_str()); + } + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Toggle fast"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->fast = Environment->addButton(rect, this, GUI_ID_KEY_FAST_BUTTON, + narrow_to_wide(KeyNames[key_fast]).c_str()); + } + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Range select"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->range = Environment->addButton(rect, this, + GUI_ID_KEY_RANGE_BUTTON, + narrow_to_wide(KeyNames[key_range]).c_str()); + } + + offset += v2s32(0, 25); + { + core::rect < s32 > rect(0, 0, 100, 20); + rect += topleft + v2s32(offset.X, offset.Y); + const wchar_t *text = L"Print stacks"; + Environment->addStaticText(text, rect, false, true, this, -1); + //t->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + } + + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(offset.X + 105, offset.Y - 5); + this->dump = Environment->addButton(rect, this, GUI_ID_KEY_DUMP_BUTTON, + narrow_to_wide(KeyNames[key_dump]).c_str()); + } + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(size.X - 100 - 20, size.Y - 40); + Environment->addButton(rect, this, GUI_ID_BACK_BUTTON, L"Save"); + } + { + core::rect < s32 > rect(0, 0, 100, 30); + rect += topleft + v2s32(size.X - 100 - 20 - 100 - 20, size.Y - 40); + Environment->addButton(rect, this, GUI_ID_ABORT_BUTTON, L"Cancel"); + } +} + +void GUIKeyChangeMenu::drawMenu() +{ + gui::IGUISkin* skin = Environment->getSkin(); + if (!skin) + return; + video::IVideoDriver* driver = Environment->getVideoDriver(); + + video::SColor bgcolor(140, 0, 0, 0); + + { + core::rect < s32 > rect(0, 0, 620, 620); + rect += AbsoluteRect.UpperLeftCorner; + driver->draw2DRectangle(bgcolor, rect, &AbsoluteClippingRect); + } + + gui::IGUIElement::draw(); +} + +bool GUIKeyChangeMenu::acceptInput() +{ + g_settings.set("keymap_forward", keycode_to_keyname(key_forward)); + g_settings.set("keymap_backward", keycode_to_keyname(key_backward)); + g_settings.set("keymap_left", keycode_to_keyname(key_left)); + g_settings.set("keymap_right", keycode_to_keyname(key_right)); + g_settings.set("keymap_jump", keycode_to_keyname(key_jump)); + g_settings.set("keymap_sneak", keycode_to_keyname(key_sneak)); + g_settings.set("keymap_inventory", keycode_to_keyname(key_inventory)); + g_settings.set("keymap_chat", keycode_to_keyname(key_chat)); + g_settings.set("keymap_rangeselect", keycode_to_keyname(key_range)); + g_settings.set("keymap_freemove", keycode_to_keyname(key_fly)); + g_settings.set("keymap_fastmove", keycode_to_keyname(key_fast)); + g_settings.set("keymap_special1", keycode_to_keyname(key_use)); + g_settings.set("keymap_print_debug_stacks", keycode_to_keyname(key_dump)); + //clearKeyCache(); Y U NO SCOPE?! + return true; +} +void GUIKeyChangeMenu::init_keys() +{ + key_forward = getKeySetting("keymap_forward"); + key_backward = getKeySetting("keymap_backward"); + key_left = getKeySetting("keymap_left"); + key_right = getKeySetting("keymap_right"); + key_jump = getKeySetting("keymap_jump"); + key_sneak = getKeySetting("keymap_sneak"); + key_inventory = getKeySetting("keymap_inventory"); + key_chat = getKeySetting("keymap_chat"); + key_range = getKeySetting("keymap_rangeselect"); + key_fly = getKeySetting("keymap_freemove"); + key_fast = getKeySetting("keymap_fastmove"); + key_use = getKeySetting("keymap_special1"); + key_dump = getKeySetting("keymap_print_debug_stacks"); +} + +bool GUIKeyChangeMenu::resetMenu() +{ + if (activeKey >= 0) + { + switch (activeKey) + { + case GUI_ID_KEY_FORWARD_BUTTON: + this->forward->setText( + narrow_to_wide(KeyNames[key_forward]).c_str()); + break; + case GUI_ID_KEY_BACKWARD_BUTTON: + this->backward->setText( + narrow_to_wide(KeyNames[key_backward]).c_str()); + break; + case GUI_ID_KEY_LEFT_BUTTON: + this->left->setText(narrow_to_wide(KeyNames[key_left]).c_str()); + break; + case GUI_ID_KEY_RIGHT_BUTTON: + this->right->setText(narrow_to_wide(KeyNames[key_right]).c_str()); + break; + case GUI_ID_KEY_JUMP_BUTTON: + this->jump->setText(narrow_to_wide(KeyNames[key_jump]).c_str()); + break; + case GUI_ID_KEY_SNEAK_BUTTON: + this->sneak->setText(narrow_to_wide(KeyNames[key_sneak]).c_str()); + break; + case GUI_ID_KEY_INVENTORY_BUTTON: + this->inventory->setText( + narrow_to_wide(KeyNames[key_inventory]).c_str()); + break; + case GUI_ID_KEY_CHAT_BUTTON: + this->chat->setText(narrow_to_wide(KeyNames[key_chat]).c_str()); + break; + case GUI_ID_KEY_RANGE_BUTTON: + this->range->setText(narrow_to_wide(KeyNames[key_range]).c_str()); + break; + case GUI_ID_KEY_FLY_BUTTON: + this->fly->setText(narrow_to_wide(KeyNames[key_fly]).c_str()); + break; + case GUI_ID_KEY_FAST_BUTTON: + this->fast->setText(narrow_to_wide(KeyNames[key_fast]).c_str()); + break; + case GUI_ID_KEY_USE_BUTTON: + this->use->setText(narrow_to_wide(KeyNames[key_use]).c_str()); + break; + case GUI_ID_KEY_DUMP_BUTTON: + this->dump->setText(narrow_to_wide(KeyNames[key_dump]).c_str()); + break; + } + activeKey = -1; + return false; + } + return true; +} +bool GUIKeyChangeMenu::OnEvent(const SEvent& event) +{ + if (event.EventType == EET_KEY_INPUT_EVENT && activeKey >= 0 + && event.KeyInput.PressedDown) + { + if (activeKey == GUI_ID_KEY_FORWARD_BUTTON) + { + this->forward->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_forward = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_BACKWARD_BUTTON) + { + this->backward->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_backward = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_LEFT_BUTTON) + { + this->left->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_left = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_RIGHT_BUTTON) + { + this->right->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_right = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_JUMP_BUTTON) + { + this->jump->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_jump = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_SNEAK_BUTTON) + { + this->sneak->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_sneak = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_INVENTORY_BUTTON) + { + this->inventory->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_inventory = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_CHAT_BUTTON) + { + this->chat->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_chat = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_RANGE_BUTTON) + { + this->range->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_range = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_FLY_BUTTON) + { + this->fly->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_fly = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_FAST_BUTTON) + { + this->fast->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_fast = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_USE_BUTTON) + { + this->use->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_use = event.KeyInput.Key; + } + else if (activeKey == GUI_ID_KEY_DUMP_BUTTON) + { + this->dump->setText( + narrow_to_wide(KeyNames[event.KeyInput.Key]).c_str()); + this->key_dump = event.KeyInput.Key; + } + + activeKey = -1; + return true; + } + if (event.EventType == EET_GUI_EVENT) + { + if (event.GUIEvent.EventType == gui::EGET_ELEMENT_FOCUS_LOST + && isVisible()) + { + if (!canTakeFocus(event.GUIEvent.Element)) + { + dstream << "GUIMainMenu: Not allowing focus change." + << std::endl; + // Returning true disables focus change + return true; + } + } + if (event.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED) + { + switch (event.GUIEvent.Caller->getID()) + { + case GUI_ID_BACK_BUTTON: //back + acceptInput(); + quitMenu(); + return true; + case GUI_ID_ABORT_BUTTON: //abort + quitMenu(); + return true; + case GUI_ID_KEY_FORWARD_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->forward->setText(L"press Key"); + break; + case GUI_ID_KEY_BACKWARD_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->backward->setText(L"press Key"); + break; + case GUI_ID_KEY_LEFT_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->left->setText(L"press Key"); + break; + case GUI_ID_KEY_RIGHT_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->right->setText(L"press Key"); + break; + case GUI_ID_KEY_USE_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->use->setText(L"press Key"); + break; + case GUI_ID_KEY_FLY_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->fly->setText(L"press Key"); + break; + case GUI_ID_KEY_FAST_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->fast->setText(L"press Key"); + break; + case GUI_ID_KEY_JUMP_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->jump->setText(L"press Key"); + break; + case GUI_ID_KEY_CHAT_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->chat->setText(L"press Key"); + break; + case GUI_ID_KEY_SNEAK_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->sneak->setText(L"press Key"); + break; + case GUI_ID_KEY_INVENTORY_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->inventory->setText(L"press Key"); + break; + case GUI_ID_KEY_DUMP_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->dump->setText(L"press Key"); + break; + case GUI_ID_KEY_RANGE_BUTTON: + resetMenu(); + activeKey = event.GUIEvent.Caller->getID(); + this->range->setText(L"press Key"); + break; + } + //Buttons + + } + } + return Parent ? Parent->OnEvent(event) : false; +} + diff --git a/src/guiKeyChangeMenu.h b/src/guiKeyChangeMenu.h new file mode 100644 index 000000000..389ce7aee --- /dev/null +++ b/src/guiKeyChangeMenu.h @@ -0,0 +1,133 @@ +/* + Minetest-delta + Copyright (C) 2010-11 celeron55, Perttu Ahola + Copyright (C) 2011 Ciaran Gultnieks + Copyright (C) 2011 teddydestodes + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef GUIKEYCHANGEMENU_HEADER +#define GUIKEYCHANGEMENU_HEADER + +#include "common_irrlicht.h" +#include "utility.h" +#include "modalMenu.h" +#include "client.h" +#include + +static const char *KeyNames[] = + { "-", "Left Button", "Right Button", "Cancel", "Middle Button", "X Button 1", + "X Button 2", "-", "Back", "Tab", "-", "-", "Clear", "Return", "-", + "-", "Shift", "Control", "Menu", "Pause", "Capital", "Kana", "-", + "Junja", "Final", "Kanji", "-", "Escape", "Convert", "Nonconvert", + "Accept", "Mode Change", "Space", "Priot", "Next", "End", "Home", + "Left", "Up", "Right", "Down", "Select", "Print", "Execute", + "Snapshot", "Insert", "Delete", "Help", "0", "1", "2", "3", "4", "5", + "6", "7", "8", "9", "-", "-", "-", "-", "-", "-", "-", "A", "B", "C", + "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", + "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "Left Windows", + "Right Windows", "Apps", "-", "Sleep", "Numpad 0", "Numpad 1", + "Numpad 2", "Numpad 3", "Numpad 4", "Numpad 5", "Numpad 6", "Numpad 7", + "Numpad 8", "Numpad 9", "Numpad *", "Numpad +", "Numpad /", "Numpad -", + "Numpad .", "Numpad /", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", + "F9", "F10", "F11", "F12", "F13", "F14", "F15", "F16", "F17", "F18", + "F19", "F20", "F21", "F22", "F23", "F24", "-", "-", "-", "-", "-", "-", + "-", "-", "Num Lock", "Scroll Lock", "-", "-", "-", "-", "-", "-", "-", + "-", "-", "-", "-", "-", "-", "-", "Left Shift", "Right Shight", + "Left Control", "Right Control", "Left Menu", "Right Menu", "-", "-", + "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", + "-", "-", "-", "-", "-", "Plus", "Comma", "Minus", "Period", "-", "-", + "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", + "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", + "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", + "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "Attn", "CrSel", + "ExSel", "Erase OEF", "Play", "Zoom", "PA1", "OEM Clear", "-" }; + enum + { + GUI_ID_BACK_BUTTON = 101, GUI_ID_ABORT_BUTTON, GUI_ID_SCROLL_BAR, + //buttons + GUI_ID_KEY_FORWARD_BUTTON, + GUI_ID_KEY_BACKWARD_BUTTON, + GUI_ID_KEY_LEFT_BUTTON, + GUI_ID_KEY_RIGHT_BUTTON, + GUI_ID_KEY_USE_BUTTON, + GUI_ID_KEY_FLY_BUTTON, + GUI_ID_KEY_FAST_BUTTON, + GUI_ID_KEY_JUMP_BUTTON, + GUI_ID_KEY_CHAT_BUTTON, + GUI_ID_KEY_SNEAK_BUTTON, + GUI_ID_KEY_INVENTORY_BUTTON, + GUI_ID_KEY_DUMP_BUTTON, + GUI_ID_KEY_RANGE_BUTTON + }; + +class GUIKeyChangeMenu: public GUIModalMenu +{ +public: + GUIKeyChangeMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent, + s32 id, IMenuManager *menumgr); + ~GUIKeyChangeMenu(); + + void removeChildren(); + /* + Remove and re-add (or reposition) stuff + */ + void regenerateGui(v2u32 screensize); + + void drawMenu(); + + bool acceptInput(); + + bool OnEvent(const SEvent& event); + +private: + + void init_keys(); + + bool resetMenu(); + + gui::IGUIButton *forward; + gui::IGUIButton *backward; + gui::IGUIButton *left; + gui::IGUIButton *right; + gui::IGUIButton *use; + gui::IGUIButton *sneak; + gui::IGUIButton *jump; + gui::IGUIButton *inventory; + gui::IGUIButton *fly; + gui::IGUIButton *fast; + gui::IGUIButton *range; + gui::IGUIButton *dump; + gui::IGUIButton *chat; + + u32 activeKey; + u32 key_forward; + u32 key_backward; + u32 key_left; + u32 key_right; + u32 key_use; + u32 key_sneak; + u32 key_jump; + u32 key_inventory; + u32 key_fly; + u32 key_fast; + u32 key_range; + u32 key_chat; + u32 key_dump; +}; + +#endif + -- cgit v1.2.3 From 7efe89ff584b2c0338dcede4c1e08504d0158780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20R=C3=BChl?= Date: Sun, 26 Jun 2011 13:47:21 +0200 Subject: backported cactus, papyrus and clay --- src/mapgen.cpp | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 67 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 801dd72b1..71696a349 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -151,6 +151,34 @@ static void make_tree(VoxelManipulator &vmanip, v3s16 p0) } } +void make_papyrus(VoxelManipulator &vmanip, v3s16 p0) +{ + MapNode papyrusnode(CONTENT_PAPYRUS); + + s16 trunk_h = myrand_range(2, 3); + v3s16 p1 = p0; + for(s16 ii=0; iiseed+4321, 6, 0.95); + + have_clay = have_sand && (claynoise > 1.25); + // Use fast index incrementing s16 start_y = node_max.Y+2; v3s16 em = vmanip.m_area.getExtent(); @@ -1778,7 +1815,10 @@ void make_block(BlockMakeData *data) { if(have_sand) { - vmanip.m_data[i] = MapNode(CONTENT_SAND); + if (have_clay) + vmanip.m_data[i] = MapNode(CONTENT_CLAY); + else + vmanip.m_data[i] = MapNode(CONTENT_SAND); } #if 1 else if(current_depth==0 && !water_detected @@ -1823,7 +1863,7 @@ void make_block(BlockMakeData *data) //s16 y = find_ground_level(data->vmanip, v2s16(x,z)); s16 y = find_ground_level_from_noise(data->seed, v2s16(x,z), 4); // Don't make a tree under water level - if(y < WATER_LEVEL) + if(y < WATER_LEVEL - 1) continue; // Make sure tree fits (only trees whose starting point is // at this block are added) @@ -1847,19 +1887,36 @@ void make_block(BlockMakeData *data) // If not found, handle next one if(found == false) continue; - /* - Trees grow only on mud and grass - */ + { u32 i = data->vmanip->m_area.index(p); MapNode *n = &data->vmanip->m_data[i]; - if(n->d != CONTENT_MUD && n->d != CONTENT_GRASS) + + if(n->d != CONTENT_MUD && n->d != CONTENT_GRASS && n->d != CONTENT_SAND) + continue; + + // Papyrus grows only on mud and in water + if(n->d == CONTENT_MUD && y == WATER_LEVEL - 1) + { + p.Y++; + make_papyrus(vmanip, p); + } + // Don't make a tree under water level + if(y < WATER_LEVEL) continue; + // Trees grow only on mud and grass + if(n->d == CONTENT_MUD || n->d == CONTENT_GRASS) + { + p.Y++; + make_tree(vmanip, p); + } + // Cactii grow only on sand + else if(n->d == CONTENT_SAND) + { + p.Y++; + make_cactus(vmanip, p); + } } - // Tree will be placed one higher - p.Y++; - // Make a tree - make_tree(vmanip, p); } #if 0 -- cgit v1.2.3 From 692bd66011774c92cdd6ca7983e47745ab1937d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Proch=C3=A1zka?= Date: Mon, 11 Jul 2011 14:29:59 +0200 Subject: + farmesh config options --- src/defaultsettings.cpp | 2 ++ src/farmesh.cpp | 14 +++++++------- src/farmesh.h | 3 ++- src/game.cpp | 8 +------- 4 files changed, 12 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 74d323237..ac1983ed1 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -68,6 +68,8 @@ void set_default_settings() g_settings.setDefault("fast_move", "false"); g_settings.setDefault("invert_mouse", "false"); g_settings.setDefault("enable_farmesh", "false"); + g_settings.setDefault("farmesh_trees", "true"); + g_settings.setDefault("farmesh_distance", "40"); g_settings.setDefault("enable_clouds", "true"); g_settings.setDefault("invisible_stone", "false"); diff --git a/src/farmesh.cpp b/src/farmesh.cpp index 72dbe11c2..a35983729 100644 --- a/src/farmesh.cpp +++ b/src/farmesh.cpp @@ -70,6 +70,7 @@ FarMesh::FarMesh( m_box = core::aabbox3d(-BS*1000000,-BS*31000,-BS*1000000, BS*1000000,BS*31000,BS*1000000); + trees = g_settings.getBool("farmesh_trees"); } FarMesh::~FarMesh() @@ -312,12 +313,11 @@ void FarMesh::render() } else { - /*// Trees if there are over 0.01 trees per MapNode - if(tree_amount_avg > 0.01) + // Trees if there are over 0.01 trees per MapNode + if(trees && tree_amount_avg > 0.01) c = video::SColor(255,50,128,50); else - c = video::SColor(255,107,134,51);*/ - c = video::SColor(255,107,134,51); + c = video::SColor(255,107,134,51); ground_is_mud = true; } } @@ -350,7 +350,7 @@ void FarMesh::render() video::EVT_STANDARD, scene::EPT_TRIANGLES, video::EIT_16BIT); // Add some trees if appropriate - if(tree_amount_avg >= 0.0065 && steepness < 1.4 + if(trees && tree_amount_avg >= 0.0065 && steepness < 1.4 && ground_is_mud == true) { driver->setMaterial(m_materials[1]); @@ -403,11 +403,11 @@ void FarMesh::step(float dtime) m_time += dtime; } -void FarMesh::update(v2f camera_p, float brightness, s16 render_range) +void FarMesh::update(v2f camera_p, float brightness) { m_camera_pos = camera_p; m_brightness = brightness; - m_render_range = render_range; + m_render_range = g_settings.getS16("farmesh_distance")*10; } diff --git a/src/farmesh.h b/src/farmesh.h index 0a30a8aef..577224e15 100644 --- a/src/farmesh.h +++ b/src/farmesh.h @@ -67,7 +67,7 @@ public: void step(float dtime); - void update(v2f camera_p, float brightness, s16 render_range); + void update(v2f camera_p, float brightness); private: video::SMaterial m_materials[FARMESH_MATERIAL_COUNT]; @@ -79,6 +79,7 @@ private: float m_time; Client *m_client; s16 m_render_range; + bool trees; }; #endif diff --git a/src/game.cpp b/src/game.cpp index 5632c1805..367abebe1 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1874,15 +1874,9 @@ void the_game( */ if(farmesh) { - farmesh_range = draw_control.wanted_range * 10; - if(draw_control.range_all && farmesh_range < 500) - farmesh_range = 500; - if(farmesh_range > 1000) - farmesh_range = 1000; - farmesh->step(dtime); farmesh->update(v2f(player_position.X, player_position.Z), - 0.05+brightness*0.95, farmesh_range); + 0.05+brightness*0.95); } // Store brightness value -- cgit v1.2.3 From a676493f46984efc4aa8cc14374f44b0ae0bd549 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Wed, 13 Jul 2011 16:21:20 +0200 Subject: * regression fix, papyrus should appear again now --- src/mapgen.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 71696a349..b7e077f68 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -1863,7 +1863,7 @@ void make_block(BlockMakeData *data) //s16 y = find_ground_level(data->vmanip, v2s16(x,z)); s16 y = find_ground_level_from_noise(data->seed, v2s16(x,z), 4); // Don't make a tree under water level - if(y < WATER_LEVEL - 1) + if(y < WATER_LEVEL) continue; // Make sure tree fits (only trees whose starting point is // at this block are added) @@ -1878,7 +1878,7 @@ void make_block(BlockMakeData *data) { u32 i = data->vmanip->m_area.index(p); MapNode *n = &data->vmanip->m_data[i]; - if(n->d != CONTENT_AIR && n->d != CONTENT_IGNORE) + if(n->d != CONTENT_AIR && n->d != CONTENT_WATERSOURCE && n->d != CONTENT_IGNORE) { found = true; break; @@ -1896,22 +1896,19 @@ void make_block(BlockMakeData *data) continue; // Papyrus grows only on mud and in water - if(n->d == CONTENT_MUD && y == WATER_LEVEL - 1) + if(n->d == CONTENT_MUD && y <= WATER_LEVEL) { p.Y++; make_papyrus(vmanip, p); } - // Don't make a tree under water level - if(y < WATER_LEVEL) - continue; - // Trees grow only on mud and grass - if(n->d == CONTENT_MUD || n->d == CONTENT_GRASS) + // Trees grow only on mud and grass, on land + else if((n->d == CONTENT_MUD || n->d == CONTENT_GRASS) && y > WATER_LEVEL + 2) { p.Y++; make_tree(vmanip, p); } - // Cactii grow only on sand - else if(n->d == CONTENT_SAND) + // Cactii grow only on sand, on land + else if(n->d == CONTENT_SAND && y > WATER_LEVEL + 2) { p.Y++; make_cactus(vmanip, p); -- cgit v1.2.3 From b96450b58666b26e960684b398c54201736e8274 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Wed, 13 Jul 2011 23:10:41 +0200 Subject: * slightly different values for 3d perlin noise --- src/mapgen.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mapgen.cpp b/src/mapgen.cpp index b7e077f68..0fd2e4c82 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -903,8 +903,8 @@ NoiseParams get_cave_noise2_params(u64 seed) NoiseParams get_ground_noise1_params(u64 seed) { - return NoiseParams(NOISE_PERLIN, seed+983240, 5, - 0.60, 100.0, 30.0); + return NoiseParams(NOISE_PERLIN, seed+983240, 4, + 0.55, 80.0, 40.0); } NoiseParams get_ground_crumbleness_params(u64 seed) @@ -939,7 +939,7 @@ bool val_is_ground(double ground_noise1_val, v3s16 p, u64 seed) double f = 0.8 + noise2d_perlin( 0.5+(float)p.X/250, 0.5+(float)p.Z/250, - seed+920381, 3, 0.5); + seed+920381, 3, 0.45); if(f < 0.01) f = 0.01; else if(f >= 1.0) -- cgit v1.2.3 From 5383aa847f1b9d5400def4f2a1b83904dcea9db9 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Wed, 13 Jul 2011 23:12:18 +0200 Subject: * possible fix for large cubic holes in map --- src/mapgen.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 0fd2e4c82..a491ac81a 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -1317,7 +1317,8 @@ void make_block(BlockMakeData *data) data->seed, v2s16(blockpos.X, blockpos.Z), 1); // Maximum amount of ground above the bottom of the central block s16 maximum_ground_depth = maximum_groundlevel - node_min.Y; - + + #if 0 /* Special case for high air or water: Just fill with air and water. */ @@ -1351,6 +1352,7 @@ void make_block(BlockMakeData *data) // We're done return; } + #endif /* If block is deep underground, this is set to true and ground -- cgit v1.2.3 From 5146c826be9386cc2adeb8f678063a2f9cfc1dee Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Thu, 14 Jul 2011 16:17:50 +0200 Subject: * possibly improved water flow, by flyx86 - When flowing liquid starts to flow down, it stops contributing to its neighboring nodes' liquid level (possibly transforming it back to air) - Flowing liquid turns into a source if there are at least 2 adjacent liquid source nodes - If a new liquid flow reaches existing flowing liquid, the existing liquid is now updated properly. --- src/content_mapnode.cpp | 2 ++ src/map.cpp | 46 +++++++++++++++++++++++++++++++++++++++------- src/mapnode.h | 4 +++- 3 files changed, 44 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/content_mapnode.cpp b/src/content_mapnode.cpp index 2e7a240f3..38356599f 100644 --- a/src/content_mapnode.cpp +++ b/src/content_mapnode.cpp @@ -276,6 +276,7 @@ void content_mapnode_init() f->buildable_to = true; f->liquid_type = LIQUID_FLOWING; f->liquid_alternative_flowing = CONTENT_WATER; + f->liquid_alternative_source = CONTENT_WATERSOURCE; i = CONTENT_WATERSOURCE; f = &content_features(i); @@ -307,6 +308,7 @@ void content_mapnode_init() f->liquid_type = LIQUID_SOURCE; f->dug_item = std::string("MaterialItem ")+itos(i)+" 1"; f->liquid_alternative_flowing = CONTENT_WATER; + f->liquid_alternative_source = CONTENT_WATERSOURCE; i = CONTENT_TORCH; f = &content_features(i); diff --git a/src/map.cpp b/src/map.cpp index 0de9cf18e..d3e898357 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1204,16 +1204,24 @@ void Map::removeNodeAndUpdate(v3s16 p, /* Add neighboring liquid nodes to transform queue. + + Also add horizontal neighbors of node on top of removed node + because they could be affected of the water on top flowing + down instead of into them. */ - v3s16 dirs[6] = { + v3s16 dirs[10] = { v3s16(0,0,1), // back v3s16(0,1,0), // top + v3s16(1,1,0), // topright + v3s16(-1,1,0), // topleft + v3s16(0,1,1), // topback + v3s16(0,1,-1), // topfront v3s16(1,0,0), // right v3s16(0,0,-1), // front v3s16(0,-1,0), // bottom v3s16(-1,0,0), // left }; - for(u16 i=0; i<6; i++) + for(u16 i=0; i<10; i++) { try { @@ -1510,6 +1518,9 @@ void Map::transformLiquids(core::map & modified_blocks) // Turn possible source into non-source u8 nonsource_c = make_liquid_flowing(n0.d); + // Counts surrounding liquid source blocks + u8 surrounding_sources = 0; + /* If not source, check that some node flows into this one and what is the level of liquid in this one @@ -1547,7 +1558,9 @@ void Map::transformLiquids(core::map & modified_blocks) } bool n2_is_source = !content_flowing_liquid(n2.d); s8 n2_liquid_level = 8; - if(n2_is_source == false) + if(n2_is_source) + surrounding_sources++; + else n2_liquid_level = n2.param2 & 0x07; s8 new_liquid_level = -1; @@ -1561,7 +1574,20 @@ void Map::transformLiquids(core::map & modified_blocks) } else if(n2_liquid_level > 0) { - new_liquid_level = n2_liquid_level - 1; + // If the neighbor node isn't a source and flows downwards, + // it doesn't flow into this node + if (n2_is_source) + { + new_liquid_level = n2_liquid_level - 1; + } + else + { + // Node below n2 + MapNode n3 = getNodeNoEx(p2 + v3s16(0,-1,0)); + // NOTE: collision of different liquids not yet handled here. + if (content_features(n3.d).liquid_type != LIQUID_FLOWING) + new_liquid_level = n2_liquid_level - 1; + } } if(new_liquid_level > new_liquid_level_max) @@ -1577,9 +1603,14 @@ void Map::transformLiquids(core::map & modified_blocks) If liquid level should be something else, update it and add all the neighboring water nodes to the transform queue. */ - if(new_liquid_level_max != liquid_level) + if(new_liquid_level_max != liquid_level || (!is_source && surrounding_sources >= 2)) { - if(new_liquid_level_max == -1) + if (surrounding_sources >= 2) + { + n0.d = content_features(n0.d).liquid_alternative_source; + setNode(p0,n0); + } + else if(new_liquid_level_max == -1) { // Remove water alltoghether n0.d = CONTENT_AIR; @@ -1589,6 +1620,7 @@ void Map::transformLiquids(core::map & modified_blocks) else { n0.param2 = new_liquid_level_max; + liquid_level = new_liquid_level_max; setNode(p0, n0); } @@ -1706,7 +1738,7 @@ void Map::transformLiquids(core::map & modified_blocks) } else { - if(liquid_next_level > liquid_level) + if(liquid_next_level > n2_liquid_level) { n2.param2 = liquid_next_level; setNode(p2, n2); diff --git a/src/mapnode.h b/src/mapnode.h index d975a50c4..d4ba0fed5 100644 --- a/src/mapnode.h +++ b/src/mapnode.h @@ -141,8 +141,10 @@ struct ContentFeatures NodeMetadata *initial_metadata; // If the content is liquid, this is the flowing version of the liquid. - // If content is liquid, this is the same content. + // If content is flowing liquid, this is the same content. u8 liquid_alternative_flowing; + // If the content is liquid, this is the source version of the liquid. + u8 liquid_alternative_source; // Amount of light the node emits u8 light_source; -- cgit v1.2.3 From 287b735224a905cbc679420aea64c9ac8289c488 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Fri, 15 Jul 2011 02:23:41 +0200 Subject: * possibly nicer trees --- src/mapgen.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mapgen.cpp b/src/mapgen.cpp index d7b6e56c4..bb4785bbf 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -85,7 +85,7 @@ static void make_tree(VoxelManipulator &vmanip, v3s16 p0) MapNode treenode(CONTENT_TREE); MapNode leavesnode(CONTENT_LEAVES); - s16 trunk_h = myrand_range(3, 6); + s16 trunk_h = myrand_range(4, 5); v3s16 p1 = p0; for(s16 ii=0; ii leaves_d(new u8[leaves_a.getVolume()]); Buffer leaves_d(leaves_a.getVolume()); for(s32 i=0; i Date: Fri, 15 Jul 2011 06:37:47 +0200 Subject: * regression fix, clay occurs again now --- src/mapgen.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/mapgen.cpp b/src/mapgen.cpp index bb4785bbf..dfea862a5 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -1840,13 +1840,6 @@ void make_block(BlockMakeData *data) bool water_detected = false; bool have_clay = false; - // Determine whether to have clay in the sand here - double claynoise = noise2d_perlin( - 0.5+(float)p2d.X/500, 0.5+(float)p2d.Y/500, - data->seed+4321, 6, 0.95); - - have_clay = have_sand && (claynoise > 1.25); - // Use fast index incrementing s16 start_y = node_max.Y+2; v3s16 em = vmanip.m_area.getExtent(); @@ -1873,6 +1866,15 @@ void make_block(BlockMakeData *data) { if(have_sand) { + // Determine whether to have clay in the sand here + double claynoise = noise2d_perlin( + 0.5+(float)p2d.X/500, 0.5+(float)p2d.Y/500, + data->seed+4321, 6, 0.95) + 0.5; + + have_clay = (y <= WATER_LEVEL) && (y >= WATER_LEVEL-2) && ( + ((claynoise > 0) && (claynoise < 0.04) && (current_depth == 0)) || + ((claynoise > 0) && (claynoise < 0.12) && (current_depth == 1)) + ); if (have_clay) vmanip.m_data[i] = MapNode(CONTENT_CLAY); else -- cgit v1.2.3 From 5086bd5664a0b7d60ed8aae757bf0312d9f159e4 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Fri, 15 Jul 2011 20:16:02 +0200 Subject: * fix automerge regression --- src/environment.cpp | 78 ++++------------------------------------------------- 1 file changed, 5 insertions(+), 73 deletions(-) (limited to 'src') diff --git a/src/environment.cpp b/src/environment.cpp index 0dab54213..d55aa38d1 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -594,7 +594,7 @@ void ServerEnvironment::activateBlock(MapBlock *block, u32 additional_dtime) block->setTimestamp(m_game_time); //dstream<<"Block is "<getBlockNoCreateNoEx(p); if(block==NULL) continue; + // Set current time as timestamp (and let it set ChangedFlag) - block->setTimestamp(m_game_time); } @@ -770,75 +770,7 @@ void ServerEnvironment::step(float dtime) if(block==NULL) continue; - // Get time difference - u32 dtime_s = 0; - u32 stamp = block->getTimestamp(); - if(m_game_time > stamp && stamp != BLOCK_TIMESTAMP_UNDEFINED) - dtime_s = m_game_time - block->getTimestamp(); - - // Set current time as timestamp (and let it set ChangedFlag) - block->setTimestamp(m_game_time); - - //dstream<<"Block is "<m_node_metadata.step((float)dtime_s); - if(changed) - { - MapEditEvent event; - event.type = MEET_BLOCK_NODE_METADATA_CHANGED; - event.p = p; - m_map->dispatchEvent(&event); - - block->setChangedFlag(); - } - - // TODO: Do something - // TODO: Implement usage of ActiveBlockModifier - - // Here's a quick demonstration - v3s16 p0; - for(p0.X=0; p0.XgetPosRelative(); - MapNode n = block->getNodeNoEx(p0); - // Test something: - // Convert all mud under proper day lighting to grass - if(n.d == CONTENT_MUD) - { - if(dtime_s > 300) - { - MapNode n_top = block->getNodeNoEx(p0+v3s16(0,1,0)); - if(content_features(n_top.d).air_equivalent && - n_top.getLight(LIGHTBANK_DAY) >= 13) - { - n.d = CONTENT_GRASS; - m_map->addNodeWithEvent(p, n); - } - } - } - /* - Convert grass into mud if under something else than air - */ - else if(n.d == CONTENT_GRASS) - { - //if(myrand()%20 == 0) - { - MapNode n_top = block->getNodeNoEx(p0+v3s16(0,1,0)); - if(n_top.d != CONTENT_AIR - && n_top.d != CONTENT_IGNORE) - { - n.d = CONTENT_MUD; - m_map->addNodeWithEvent(p, n); - } - } - } - } + activateBlock(block); } } @@ -954,8 +886,8 @@ void ServerEnvironment::step(float dtime) n.d = CONTENT_MUD; m_map->addNodeWithEvent(p, n); } - } } + } } } } -- cgit v1.2.3 From 13b2bad54b79aa6209febbb532147d8a219a4282 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Sun, 17 Jul 2011 22:33:18 +0200 Subject: =?UTF-8?q?*=20changed=20GUI=20to=20indicate=20Minetest=20=CE=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/game.cpp | 2 +- src/guiPauseMenu.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/game.cpp b/src/game.cpp index d77b45da5..0f858e879 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2021,7 +2021,7 @@ void the_game( endscenetime_avg = endscenetime_avg * 0.95 + (float)endscenetime*0.05; char temptext[300]; - snprintf(temptext, 300, "Minetest-c55 %s (" + snprintf(temptext, 300, "Minetest-delta %s (" "R: range_all=%i" ")" " drawtime=%.0f, beginscenetime=%.0f" diff --git a/src/guiPauseMenu.cpp b/src/guiPauseMenu.cpp index d32d1a10b..1a885a6ea 100644 --- a/src/guiPauseMenu.cpp +++ b/src/guiPauseMenu.cpp @@ -166,8 +166,8 @@ void GUIPauseMenu::regenerateGui(v2u32 screensize) );*/ std::ostringstream os; - os<<"Minetest-c55\n"; - os<<"by Perttu Ahola\n"; + os<<"Minetest-delta\n"; + os<<"by Perttu Ahola and contributors\n"; os<<"celeron55@gmail.com\n"; os< Date: Sat, 16 Jul 2011 16:01:37 +0200 Subject: * refactored liquid transformation code (has some flaws) Completely rewrote the liquid transformation. The algorithm now exclusively modifies the current node in one iteration. Another change is that MapNode.param2 now stores a bit that tells other nodes if a flowing liquid node flows downwards. This is accomplished by two masks on param2 for the "flow down" bit and the "liquid level" bits. This will be the base of future improvements to the liquid flow. However, in the current state flowing liquid does not always disappear when cut off its source. Be aware that this branch is work in progress. --- src/content_mapblock.cpp | 2 +- src/map.cpp | 451 +++++++++++++++++++++-------------------------- src/mapnode.h | 7 + 3 files changed, 208 insertions(+), 252 deletions(-) (limited to 'src') diff --git a/src/content_mapblock.cpp b/src/content_mapblock.cpp index 4c28fe3c6..d8bf71dc0 100644 --- a/src/content_mapblock.cpp +++ b/src/content_mapblock.cpp @@ -375,7 +375,7 @@ void mapblock_mesh_generate_special(MeshMakeData *data, if(n2.d == CONTENT_WATERSOURCE) level = (-0.5+node_water_level) * BS; else if(n2.d == CONTENT_WATER) - level = (-0.5 + ((float)n2.param2 + 0.5) / 8.0 + level = (-0.5 + ((float)(n2.param2 & LIQUID_LEVEL_MASK) + 0.5) / 8.0 * node_water_level) * BS; // Check node above neighbor. diff --git a/src/map.cpp b/src/map.cpp index 10e1302b1..298826e7e 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1086,7 +1086,7 @@ void Map::addNodeAndUpdate(v3s16 p, MapNode n, v3s16 p2 = p + dirs[i]; MapNode n2 = getNode(p2); - if(content_liquid(n2.d)) + if(content_liquid(n2.d) || n2.d == CONTENT_AIR) { m_transforming_liquid.push_back(p2); } @@ -1241,18 +1241,10 @@ void Map::removeNodeAndUpdate(v3s16 p, /* Add neighboring liquid nodes to transform queue. - - Also add horizontal neighbors of node on top of removed node - because they could be affected of the water on top flowing - down instead of into them. */ v3s16 dirs[10] = { v3s16(0,0,1), // back v3s16(0,1,0), // top - v3s16(1,1,0), // topright - v3s16(-1,1,0), // topleft - v3s16(0,1,1), // topback - v3s16(0,1,-1), // topfront v3s16(1,0,0), // right v3s16(0,0,-1), // front v3s16(0,-1,0), // bottom @@ -1266,7 +1258,7 @@ void Map::removeNodeAndUpdate(v3s16 p, v3s16 p2 = p + dirs[i]; MapNode n2 = getNode(p2); - if(content_liquid(n2.d)) + if(content_liquid(n2.d) || n2.d == CONTENT_AIR) { m_transforming_liquid.push_back(p2); } @@ -1546,6 +1538,17 @@ void Map::PrintInfo(std::ostream &out) #define WATER_DROP_BOOST 4 +enum NeighborType { + NEIGHBOR_UPPER, + NEIGHBOR_SAME_LEVEL, + NEIGHBOR_LOWER +}; +struct NodeNeighbor { + MapNode n; + NeighborType t; + v3s16 p; +}; + void Map::transformLiquids(core::map & modified_blocks) { DSTACK(__FUNCTION_NAME); @@ -1565,264 +1568,210 @@ void Map::transformLiquids(core::map & modified_blocks) v3s16 p0 = m_transforming_liquid.pop_front(); MapNode n0 = getNodeNoEx(p0); - - // Don't deal with non-liquids - if(content_liquid(n0.d) == false) - continue; - - bool is_source = !content_flowing_liquid(n0.d); - - u8 liquid_level = 8; - if(is_source == false) - liquid_level = n0.param2 & 0x0f; - - // Turn possible source into non-source - u8 nonsource_c = make_liquid_flowing(n0.d); - - // Counts surrounding liquid source blocks - u8 surrounding_sources = 0; - + /* - If not source, check that some node flows into this one - and what is the level of liquid in this one - */ - if(is_source == false) - { - s8 new_liquid_level_max = -1; - - v3s16 dirs_from[5] = { - v3s16(0,1,0), // top - v3s16(0,0,1), // back - v3s16(1,0,0), // right - v3s16(0,0,-1), // front - v3s16(-1,0,0), // left - }; - for(u16 i=0; i<5; i++) - { - bool from_top = (i==0); - - v3s16 p2 = p0 + dirs_from[i]; - MapNode n2 = getNodeNoEx(p2); - - if(content_liquid(n2.d)) - { - u8 n2_nonsource_c = make_liquid_flowing(n2.d); - // Check that the liquids are the same type - if(n2_nonsource_c != nonsource_c) - { - dstream<<"WARNING: Not handling: different liquids" - " collide"<= 7 - WATER_DROP_BOOST) - new_liquid_level = 7; - else - new_liquid_level = n2_liquid_level + WATER_DROP_BOOST; + break; + case LIQUID_SOURCE: + // if this node is not (yet) of a liquid type, choose the first liquid type we encounter + if (liquid_kind == CONTENT_AIR) + liquid_kind = content_features(nb.n.d).liquid_alternative_flowing; + if (content_features(nb.n.d).liquid_alternative_flowing !=liquid_kind) { + neutrals[num_neutrals++] = nb; + } else { + sources[num_sources++] = nb; } - else if(n2_liquid_level > 0) - { - // If the neighbor node isn't a source and flows downwards, - // it doesn't flow into this node - if (n2_is_source) - { - new_liquid_level = n2_liquid_level - 1; - } - else - { - // Node below n2 - MapNode n3 = getNodeNoEx(p2 + v3s16(0,-1,0)); - // NOTE: collision of different liquids not yet handled here. - if (content_features(n3.d).liquid_type != LIQUID_FLOWING) - new_liquid_level = n2_liquid_level - 1; + break; + case LIQUID_FLOWING: + // if this node is not (yet) of a liquid type, choose the first liquid type we encounter + // (while ignoring flowing liquids at the lowest level, which cannot flow into this node) + if (liquid_kind == CONTENT_AIR && ((nb.n.param2 & LIQUID_LEVEL_MASK) > 0)) + liquid_kind = content_features(nb.n.d).liquid_alternative_flowing; + if (content_features(nb.n.d).liquid_alternative_flowing != liquid_kind) { + neutrals[num_neutrals++] = nb; + } else { + // order flowing neighbors by liquid level descending + int insert_at = 0; + while (insert_at < num_flows && ((flows[insert_at].n.param2 & LIQUID_LEVEL_MASK) > + (nb.n.param2 & LIQUID_LEVEL_MASK))) { + insert_at++; } + flows[insert_at] = nb; + num_flows++; + if (nb.t == NEIGHBOR_LOWER) + flowing_down = true; } - - if(new_liquid_level > new_liquid_level_max) - new_liquid_level_max = new_liquid_level; - } - } //for - - /* - If liquid level should be something else, update it and - add all the neighboring water nodes to the transform queue. - */ - if(new_liquid_level_max != liquid_level || (!is_source && surrounding_sources >= 2)) - { - if (surrounding_sources >= 2) - { - n0.d = content_features(n0.d).liquid_alternative_source; - setNode(p0,n0); - } - else if(new_liquid_level_max == -1) - { - // Remove water alltoghether - n0.d = CONTENT_AIR; - n0.param2 = 0; - setNode(p0, n0); - } - else - { - n0.param2 = new_liquid_level_max; - liquid_level = new_liquid_level_max; - setNode(p0, n0); - } - - // Block has been modified - { - v3s16 blockpos = getNodeBlockPos(p0); - MapBlock *block = getBlockNoCreateNoEx(blockpos); - if(block != NULL) - modified_blocks.insert(blockpos, block); - } - - /* - Add neighboring non-source liquid nodes to transform queue. - */ - v3s16 dirs[6] = { - v3s16(0,0,1), // back - v3s16(0,1,0), // top - v3s16(1,0,0), // right - v3s16(0,0,-1), // front - v3s16(0,-1,0), // bottom - v3s16(-1,0,0), // left - }; - for(u16 i=0; i<6; i++) - { - v3s16 p2 = p0 + dirs[i]; - - MapNode n2 = getNodeNoEx(p2); - if(content_flowing_liquid(n2.d)) - { - m_transforming_liquid.push_back(p2); - } - } + break; } } - - // Get a new one from queue if the node has turned into non-water - if(content_liquid(n0.d) == false) - continue; - + /* - Flow water from this node - */ - v3s16 dirs_to[5] = { - v3s16(0,-1,0), // bottom - v3s16(0,0,1), // back - v3s16(1,0,0), // right - v3s16(0,0,-1), // front - v3s16(-1,0,0), // left - }; - for(u16 i=0; i<5; i++) - { - bool to_bottom = (i == 0); - - // If liquid is at lowest possible height, it's not going - // anywhere except down - if(liquid_level == 0 && to_bottom == false) - continue; - - u8 liquid_next_level = 0; - // If going to bottom - if(to_bottom) - { - //liquid_next_level = 7; - if(liquid_level >= 7 - WATER_DROP_BOOST) - liquid_next_level = 7; - else - liquid_next_level = liquid_level + WATER_DROP_BOOST; + decide on the type (and possibly level) of the current node + */ + u8 new_node_content; + s8 new_node_level = -1; + if (num_sources >= 2 || liquid_type == LIQUID_SOURCE) { + // liquid_kind will be set to either the flowing alternative of the node (if it's a liquid) + // or the flowing alternative of the first of the surrounding sources (if it's air), so + // it's perfectly safe to use liquid_kind here to determine the new node content. + new_node_content = content_features(liquid_kind).liquid_alternative_source; + } else if (num_sources == 1 && sources[0].t != NEIGHBOR_LOWER) { + // liquid_kind is set properly, see above + new_node_content = liquid_kind; + new_node_level = 7; + } else { + // no surrounding sources, so get the maximum level that can flow into this node + for (u16 i = 0; i < num_flows; i++) { + u8 nb_liquid_level = (flows[i].n.param2 & LIQUID_LEVEL_MASK); + switch (flows[i].t) { + case NEIGHBOR_UPPER: + if (nb_liquid_level + WATER_DROP_BOOST > new_node_level) { + new_node_level = 7; + if (nb_liquid_level + WATER_DROP_BOOST < 7) + new_node_level = nb_liquid_level + WATER_DROP_BOOST; + } + break; + case NEIGHBOR_LOWER: + break; + case NEIGHBOR_SAME_LEVEL: + if ((flows[i].n.param2 & LIQUID_FLOW_DOWN_MASK) != LIQUID_FLOW_DOWN_MASK && + nb_liquid_level > 0 && nb_liquid_level - 1 > new_node_level) { + new_node_level = nb_liquid_level - 1; + } + break; + } } + if (new_node_level >= 0) + new_node_content = liquid_kind; else - liquid_next_level = liquid_level - 1; - - bool n2_changed = false; - bool flowed = false; - - v3s16 p2 = p0 + dirs_to[i]; - - MapNode n2 = getNodeNoEx(p2); - //dstream<<"[1] n2.param="<<(int)n2.param< n2_liquid_level) - { - n2.param2 = liquid_next_level; - setNode(p2, n2); - - n2_changed = true; - flowed = true; - } + for (u16 i = 0; i < num_airs; i++) { + if (airs[i].t != NEIGHBOR_UPPER && (airs[i].t == NEIGHBOR_LOWER || new_node_level > 0)) + m_transforming_liquid.push_back(airs[i].p); } - } - else if(n2.d == CONTENT_AIR) - { - n2.d = nonsource_c; - n2.param2 = liquid_next_level; - setNode(p2, n2); - - n2_changed = true; - flowed = true; - } - - //dstream<<"[2] n2.param="<<(int)n2.param<= 100000) - if(loopcount >= initial_size * 1) + if(loopcount >= initial_size * 1) { break; + } } //dstream<<"Map::transformLiquids(): loopcount="< Date: Sun, 17 Jul 2011 04:01:31 +0200 Subject: fixed refactoring issues // slowed down water flow a bit * liquid flow no longer does random things when transformed * if a flowi ng liquid node doesn't have a solid block as neighbor, its spread distan ce is shortened by 1 --- src/map.cpp | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/map.cpp b/src/map.cpp index 298826e7e..19ed32317 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1240,17 +1240,19 @@ void Map::removeNodeAndUpdate(v3s16 p, } /* - Add neighboring liquid nodes to transform queue. + Add neighboring liquid nodes and this node to transform queue. + (it's vital for the node itself to get updated last.) */ - v3s16 dirs[10] = { + v3s16 dirs[7] = { v3s16(0,0,1), // back v3s16(0,1,0), // top v3s16(1,0,0), // right v3s16(0,0,-1), // front v3s16(0,-1,0), // bottom v3s16(-1,0,0), // left + v3s16(0,0,0), // self }; - for(u16 i=0; i<10; i++) + for(u16 i=0; i<7; i++) { try { @@ -1602,7 +1604,7 @@ void Map::transformLiquids(core::map & modified_blocks) v3s16( 1, 0, 0), // right v3s16(-1, 0, 0), // left v3s16( 0, 0, 1), // back - v3s16( 0, 0,-1) // front + v3s16( 0, 0,-1), // front }; NodeNeighbor sources[6]; // surrounding sources int num_sources = 0; @@ -1655,11 +1657,13 @@ void Map::transformLiquids(core::map & modified_blocks) neutrals[num_neutrals++] = nb; } else { // order flowing neighbors by liquid level descending - int insert_at = 0; + u16 insert_at = 0; while (insert_at < num_flows && ((flows[insert_at].n.param2 & LIQUID_LEVEL_MASK) > (nb.n.param2 & LIQUID_LEVEL_MASK))) { insert_at++; } + for (u16 j = insert_at; j < num_flows; j++) + flows[j + 1] = flows[j]; flows[insert_at] = nb; num_flows++; if (nb.t == NEIGHBOR_LOWER) @@ -1705,6 +1709,20 @@ void Map::transformLiquids(core::map & modified_blocks) break; } } + // don't flow as far in open terrain - if there isn't at least one adjacent solid block, + // substract another unit from the resulting water level. + if (!flowing_down && new_node_level >= 1) { + bool at_wall = false; + for (u16 i = 0; i < num_neutrals; i++) { + if (neutrals[i].t == NEIGHBOR_SAME_LEVEL) { + at_wall = true; + break; + } + } + if (!at_wall) + new_node_level -= 1; + } + if (new_node_level >= 0) new_node_content = liquid_kind; else @@ -1715,11 +1733,12 @@ void Map::transformLiquids(core::map & modified_blocks) check if anything has changed. if not, just continue with the next node. */ if (new_node_content == n0.d && (content_features(n0.d).liquid_type != LIQUID_FLOWING || - ((n0.param2 & LIQUID_LEVEL_MASK) == (u8)new_node_level) && + ((n0.param2 & LIQUID_LEVEL_MASK) == (u8)new_node_level && ((n0.param2 & LIQUID_FLOW_DOWN_MASK) == LIQUID_FLOW_DOWN_MASK) - == flowing_down)) + == flowing_down))) continue; + /* update the current node */ @@ -1737,6 +1756,9 @@ void Map::transformLiquids(core::map & modified_blocks) if(block != NULL) modified_blocks.insert(blockpos, block); + /* + enqueue neighbors for update if neccessary + */ switch (content_features(n0.d).liquid_type) { case LIQUID_SOURCE: // make sure source flows into all neighboring nodes -- cgit v1.2.3 From b7862805c8d6228ad7302887e72c12d644da6dd1 Mon Sep 17 00:00:00 2001 From: Felix Krause Date: Sun, 17 Jul 2011 13:15:33 +0200 Subject: fixes to liquid transformation --- src/map.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/map.cpp b/src/map.cpp index 19ed32317..1596f12ef 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1651,7 +1651,7 @@ void Map::transformLiquids(core::map & modified_blocks) case LIQUID_FLOWING: // if this node is not (yet) of a liquid type, choose the first liquid type we encounter // (while ignoring flowing liquids at the lowest level, which cannot flow into this node) - if (liquid_kind == CONTENT_AIR && ((nb.n.param2 & LIQUID_LEVEL_MASK) > 0)) + if (liquid_kind == CONTENT_AIR) liquid_kind = content_features(nb.n.d).liquid_alternative_flowing; if (content_features(nb.n.d).liquid_alternative_flowing != liquid_kind) { neutrals[num_neutrals++] = nb; @@ -1746,7 +1746,7 @@ void Map::transformLiquids(core::map & modified_blocks) n0.d = new_node_content; if (content_features(n0.d).liquid_type == LIQUID_FLOWING) { // set level to last 3 bits, flowing down bit to 4th bit - n0.param2 = (flowing_down ? LIQUID_FLOW_DOWN_MASK : 0x00) | (new_node_level & LIQUID_LEVEL_MASK); + n0.param2 = (flowing_down ? LIQUID_FLOW_DOWN_MASK : 0x00) | (new_node_level & LIQUID_LEVEL_MASK); } else { n0.param2 = 0; } @@ -1776,10 +1776,10 @@ void Map::transformLiquids(core::map & modified_blocks) break; case LIQUID_FLOWING: for (u16 i = 0; i < num_flows; i++) { - u8 flow_level = (flows[i].n.param2 & LIQUID_LEVEL_MASK); + /*u8 flow_level = (flows[i].n.param2 & LIQUID_LEVEL_MASK); // liquid_level is still the ORIGINAL level of this node. if (flows[i].t != NEIGHBOR_UPPER && ((flow_level < liquid_level || flow_level < new_node_level) || - flow_down_enabled)) + flow_down_enabled))*/ m_transforming_liquid.push_back(flows[i].p); } for (u16 i = 0; i < num_airs; i++) { @@ -1791,7 +1791,7 @@ void Map::transformLiquids(core::map & modified_blocks) loopcount++; //if(loopcount >= 100000) - if(loopcount >= initial_size * 1) { + if(loopcount >= initial_size * 10) { break; } } -- cgit v1.2.3 From 466f9d87b655e743499e78b39c6c31c781fed422 Mon Sep 17 00:00:00 2001 From: Felix Krause Date: Sun, 17 Jul 2011 13:55:59 +0200 Subject: final fixes to liquid flow, works now as intended --- src/map.cpp | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/map.cpp b/src/map.cpp index 1596f12ef..cf8692bff 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1612,7 +1612,7 @@ void Map::transformLiquids(core::map & modified_blocks) int num_flows = 0; NodeNeighbor airs[6]; // surrounding air int num_airs = 0; - NodeNeighbor neutrals[6]; // nodes that are solid, another kind of liquid + NodeNeighbor neutrals[6]; // nodes that are solid or another kind of liquid int num_neutrals = 0; bool flowing_down = false; for (u16 i = 0; i < 6; i++) { @@ -1631,7 +1631,7 @@ void Map::transformLiquids(core::map & modified_blocks) case LIQUID_NONE: if (nb.n.d == CONTENT_AIR) { airs[num_airs++] = nb; - // if the current nodes happens to be a flowing node, it will start to flow down here. + // if the current node happens to be a flowing node, it will start to flow down here. if (nb.t == NEIGHBOR_LOWER) flowing_down = true; } else { @@ -1650,22 +1650,12 @@ void Map::transformLiquids(core::map & modified_blocks) break; case LIQUID_FLOWING: // if this node is not (yet) of a liquid type, choose the first liquid type we encounter - // (while ignoring flowing liquids at the lowest level, which cannot flow into this node) if (liquid_kind == CONTENT_AIR) liquid_kind = content_features(nb.n.d).liquid_alternative_flowing; if (content_features(nb.n.d).liquid_alternative_flowing != liquid_kind) { neutrals[num_neutrals++] = nb; } else { - // order flowing neighbors by liquid level descending - u16 insert_at = 0; - while (insert_at < num_flows && ((flows[insert_at].n.param2 & LIQUID_LEVEL_MASK) > - (nb.n.param2 & LIQUID_LEVEL_MASK))) { - insert_at++; - } - for (u16 j = insert_at; j < num_flows; j++) - flows[j + 1] = flows[j]; - flows[insert_at] = nb; - num_flows++; + flows[num_flows++] = nb; if (nb.t == NEIGHBOR_LOWER) flowing_down = true; } @@ -1776,10 +1766,10 @@ void Map::transformLiquids(core::map & modified_blocks) break; case LIQUID_FLOWING: for (u16 i = 0; i < num_flows; i++) { - /*u8 flow_level = (flows[i].n.param2 & LIQUID_LEVEL_MASK); + u8 flow_level = (flows[i].n.param2 & LIQUID_LEVEL_MASK); // liquid_level is still the ORIGINAL level of this node. if (flows[i].t != NEIGHBOR_UPPER && ((flow_level < liquid_level || flow_level < new_node_level) || - flow_down_enabled))*/ + flow_down_enabled)) m_transforming_liquid.push_back(flows[i].p); } for (u16 i = 0; i < num_airs; i++) { -- cgit v1.2.3 From 890d3468e757421629b31dca9198677bdd974f50 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Mon, 18 Jul 2011 22:50:14 +0200 Subject: + volumetric clouds (thanks teddydestodes) --- src/clouds.cpp | 73 +++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 62 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/clouds.cpp b/src/clouds.cpp index 122beedac..022550414 100644 --- a/src/clouds.cpp +++ b/src/clouds.cpp @@ -125,22 +125,73 @@ void Clouds::render() m_seed, 3, 0.4); if(noise < 0.8) continue; - - v2f p1 = p0 + v2f(1,1)*cloud_size; - //video::SColor c(128,255,255,255); float b = m_brightness; video::SColor c(128,b*230,b*230,b*255); - video::S3DVertex vertices[4] = + + video::S3DVertex v[4] = { - video::S3DVertex(p0.X,m_cloud_y,p0.Y, 0,0,0, c, 0,1), - video::S3DVertex(p0.X,m_cloud_y,p1.Y, 0,0,0, c, 1,1), - video::S3DVertex(p1.X,m_cloud_y,p1.Y, 0,0,0, c, 1,0), - video::S3DVertex(p1.X,m_cloud_y,p0.Y, 0,0,0, c, 0,0), + video::S3DVertex(0,0,0, 0,0,0, c, 0, 1), + video::S3DVertex(0,0,0, 0,0,0, c, 1, 1), + video::S3DVertex(0,0,0, 0,0,0, c, 1, 0), + video::S3DVertex(0,0,0, 0,0,0, c, 0, 0) }; - u16 indices[] = {0,1,2,2,3,0}; - driver->drawVertexPrimitiveList(vertices, 4, indices, 2, - video::EVT_STANDARD, scene::EPT_TRIANGLES, video::EIT_16BIT); + + f32 rx = cloud_size; + f32 ry = 16*BS; + f32 rz = cloud_size; + + for(int i=0;i<6;i++) + { + switch(i) + { + case 0: // top + v[0].Pos.X=-rx; v[0].Pos.Y= ry; v[0].Pos.Z=-rz; + v[1].Pos.X=-rx; v[1].Pos.Y= ry; v[1].Pos.Z= rz; + v[2].Pos.X= rx; v[2].Pos.Y= ry; v[2].Pos.Z= rz; + v[3].Pos.X= rx; v[3].Pos.Y= ry, v[3].Pos.Z=-rz; + break; + case 1: // back + v[0].Pos.X=-rx; v[0].Pos.Y= ry; v[0].Pos.Z=-rz; + v[1].Pos.X= rx; v[1].Pos.Y= ry; v[1].Pos.Z=-rz; + v[2].Pos.X= rx; v[2].Pos.Y=-ry; v[2].Pos.Z=-rz; + v[3].Pos.X=-rx; v[3].Pos.Y=-ry, v[3].Pos.Z=-rz; + break; + case 2: //right + v[0].Pos.X= rx; v[0].Pos.Y= ry; v[0].Pos.Z=-rz; + v[1].Pos.X= rx; v[1].Pos.Y= ry; v[1].Pos.Z= rz; + v[2].Pos.X= rx; v[2].Pos.Y=-ry; v[2].Pos.Z= rz; + v[3].Pos.X= rx; v[3].Pos.Y=-ry, v[3].Pos.Z=-rz; + break; + case 3: // front + v[0].Pos.X= rx; v[0].Pos.Y= ry; v[0].Pos.Z= rz; + v[1].Pos.X=-rx; v[1].Pos.Y= ry; v[1].Pos.Z= rz; + v[2].Pos.X=-rx; v[2].Pos.Y=-ry; v[2].Pos.Z= rz; + v[3].Pos.X= rx; v[3].Pos.Y=-ry, v[3].Pos.Z= rz; + break; + case 4: // left + v[0].Pos.X=-rx; v[0].Pos.Y= ry; v[0].Pos.Z= rz; + v[1].Pos.X=-rx; v[1].Pos.Y= ry; v[1].Pos.Z=-rz; + v[2].Pos.X=-rx; v[2].Pos.Y=-ry; v[2].Pos.Z=-rz; + v[3].Pos.X=-rx; v[3].Pos.Y=-ry, v[3].Pos.Z= rz; + break; + case 5: // bottom + v[0].Pos.X= rx; v[0].Pos.Y=-ry; v[0].Pos.Z= rz; + v[1].Pos.X=-rx; v[1].Pos.Y=-ry; v[1].Pos.Z= rz; + v[2].Pos.X=-rx; v[2].Pos.Y=-ry; v[2].Pos.Z=-rz; + v[3].Pos.X= rx; v[3].Pos.Y=-ry, v[3].Pos.Z=-rz; + break; + } + + v3f pos = v3f(p0.X,m_cloud_y,p0.Y); + + for(u16 i=0; i<4; i++) + v[i].Pos += pos; + u16 indices[] = {0,1,2,2,3,0}; + driver->drawVertexPrimitiveList(v, 4, indices, 2, + video::EVT_STANDARD, scene::EPT_TRIANGLES, video::EIT_16BIT); + } + } } -- cgit v1.2.3 From a99b7e6e050c40d95d788d2dec56bf3b56c5844f Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Tue, 19 Jul 2011 01:43:30 +0200 Subject: + fake shading for the volumetric clouds --- src/clouds.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/clouds.cpp b/src/clouds.cpp index 022550414..19bcca942 100644 --- a/src/clouds.cpp +++ b/src/clouds.cpp @@ -127,18 +127,21 @@ void Clouds::render() continue; float b = m_brightness; - video::SColor c(128,b*230,b*230,b*255); + video::SColor c_top(128,b*240,b*240,b*255); + video::SColor c_side_1(128,b*230,b*230,b*255); + video::SColor c_side_2(128,b*220,b*220,b*245); + video::SColor c_bottom(128,b*205,b*205,b*230); video::S3DVertex v[4] = { - video::S3DVertex(0,0,0, 0,0,0, c, 0, 1), - video::S3DVertex(0,0,0, 0,0,0, c, 1, 1), - video::S3DVertex(0,0,0, 0,0,0, c, 1, 0), - video::S3DVertex(0,0,0, 0,0,0, c, 0, 0) + video::S3DVertex(0,0,0, 0,0,0, c_top, 0, 1), + video::S3DVertex(0,0,0, 0,0,0, c_top, 1, 1), + video::S3DVertex(0,0,0, 0,0,0, c_top, 1, 0), + video::S3DVertex(0,0,0, 0,0,0, c_top, 0, 0) }; f32 rx = cloud_size; - f32 ry = 16*BS; + f32 ry = 8*BS; f32 rz = cloud_size; for(int i=0;i<6;i++) @@ -152,30 +155,40 @@ void Clouds::render() v[3].Pos.X= rx; v[3].Pos.Y= ry, v[3].Pos.Z=-rz; break; case 1: // back + for(int j=0;j<4;j++) + v[j].Color=c_side_1; v[0].Pos.X=-rx; v[0].Pos.Y= ry; v[0].Pos.Z=-rz; v[1].Pos.X= rx; v[1].Pos.Y= ry; v[1].Pos.Z=-rz; v[2].Pos.X= rx; v[2].Pos.Y=-ry; v[2].Pos.Z=-rz; v[3].Pos.X=-rx; v[3].Pos.Y=-ry, v[3].Pos.Z=-rz; break; case 2: //right + for(int j=0;j<4;j++) + v[j].Color=c_side_2; v[0].Pos.X= rx; v[0].Pos.Y= ry; v[0].Pos.Z=-rz; v[1].Pos.X= rx; v[1].Pos.Y= ry; v[1].Pos.Z= rz; v[2].Pos.X= rx; v[2].Pos.Y=-ry; v[2].Pos.Z= rz; v[3].Pos.X= rx; v[3].Pos.Y=-ry, v[3].Pos.Z=-rz; break; case 3: // front + for(int j=0;j<4;j++) + v[j].Color=c_side_1; v[0].Pos.X= rx; v[0].Pos.Y= ry; v[0].Pos.Z= rz; v[1].Pos.X=-rx; v[1].Pos.Y= ry; v[1].Pos.Z= rz; v[2].Pos.X=-rx; v[2].Pos.Y=-ry; v[2].Pos.Z= rz; v[3].Pos.X= rx; v[3].Pos.Y=-ry, v[3].Pos.Z= rz; break; case 4: // left + for(int j=0;j<4;j++) + v[j].Color=c_side_2; v[0].Pos.X=-rx; v[0].Pos.Y= ry; v[0].Pos.Z= rz; v[1].Pos.X=-rx; v[1].Pos.Y= ry; v[1].Pos.Z=-rz; v[2].Pos.X=-rx; v[2].Pos.Y=-ry; v[2].Pos.Z=-rz; v[3].Pos.X=-rx; v[3].Pos.Y=-ry, v[3].Pos.Z= rz; break; case 5: // bottom + for(int j=0;j<4;j++) + v[j].Color=c_bottom; v[0].Pos.X= rx; v[0].Pos.Y=-ry; v[0].Pos.Z= rz; v[1].Pos.X=-rx; v[1].Pos.Y=-ry; v[1].Pos.Z= rz; v[2].Pos.X=-rx; v[2].Pos.Y=-ry; v[2].Pos.Z=-rz; -- cgit v1.2.3 From 57fcfb2b0d90f14b89f9844c8b59bcaa7bb86b85 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Tue, 19 Jul 2011 02:02:50 +0200 Subject: * initialize liquid_kind properly so compiler does not bitch about it --- src/map.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/map.cpp b/src/map.cpp index cf8692bff..aa064637f 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1575,7 +1575,7 @@ void Map::transformLiquids(core::map & modified_blocks) Collect information about current node */ s8 liquid_level = -1; - u8 liquid_kind; + u8 liquid_kind = CONTENT_IGNORE; LiquidType liquid_type = content_features(n0.d).liquid_type; switch (liquid_type) { case LIQUID_SOURCE: -- cgit v1.2.3 From 6791c856b27fb48bf8676f5a3f66c9f6cd1b43c4 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Wed, 20 Jul 2011 02:44:51 +0200 Subject: * by popular request, fewer clouds --- src/clouds.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/clouds.cpp b/src/clouds.cpp index 19bcca942..d754cc15e 100644 --- a/src/clouds.cpp +++ b/src/clouds.cpp @@ -84,7 +84,7 @@ void Clouds::render() */ const s16 cloud_radius_i = 12; - const float cloud_size = BS*50; + const float cloud_size = BS*48; const v2f cloud_speed(-BS*2, 0); // Position of cloud noise origin in world coordinates @@ -123,7 +123,7 @@ void Clouds::render() (float)p_in_noise_i.X*cloud_size/BS/200, (float)p_in_noise_i.Y*cloud_size/BS/200, m_seed, 3, 0.4); - if(noise < 0.8) + if(noise < 0.95) continue; float b = m_brightness; -- cgit v1.2.3 From 6a8328de7970edd2a1c0472289a903a75ad9daf7 Mon Sep 17 00:00:00 2001 From: Constantin Wenger Date: Wed, 20 Jul 2011 16:51:19 +0200 Subject: added gettext support german translation file and bashscript to update translations --- src/CMakeLists.txt | 41 +++++++++++++++++++++++++++++++++++++++++ src/gettext.h | 12 ++++++++++++ src/guiMainMenu.cpp | 26 ++++++++++++-------------- src/guiMessageMenu.cpp | 4 +++- src/guiPasswordChange.cpp | 16 +++++++--------- src/guiPauseMenu.cpp | 36 +++++++++++++++++++----------------- src/guiTextInputMenu.cpp | 4 +++- src/main.cpp | 5 +++++ 8 files changed, 102 insertions(+), 42 deletions(-) create mode 100644 src/gettext.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dfe5b5753..fd1591423 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,6 +27,14 @@ if(WIN32) CACHE FILEPATH "Path to zlibwapi.lib") set(ZLIB_DLL "${PROJECT_SOURCE_DIR}/../../zlib125dll/dll32/zlibwapi.dll" CACHE FILEPATH "Path to zlibwapi.dll (for installation)") + set(GETTEXT_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/../../gettext/include" + CACHE PATH "gettext include directory") + set(GETTEXT_BIN_DIR "${PROJECT_SOURCE_DIR}/../../gettext/bin" + CACHE PATH "gettext bin directory") + set(GETTEXT_LIBRARIES "${PROJECT_SOURCE_DIR}/../../gettext/lib/intl.lib" + CACHE FILEPATH "gettext intl.lib") + set(IRRLICHT_SOURCE_DIR "${PROJECT_SOURCE_DIR}/../../irrlicht-1.7.2" + CACHE PATH "irrlicht dir") else() # Unix probably if(BUILD_CLIENT) @@ -134,6 +142,7 @@ include_directories( ${ZLIB_INCLUDE_DIR} ${CMAKE_BUILD_TYPE} ${PNG_INCLUDE_DIR} + ${GETTEXT_INCLUDE_DIR} "${PROJECT_SOURCE_DIR}/jthread" "${PROJECT_SOURCE_DIR}/sqlite" ) @@ -151,6 +160,7 @@ if(BUILD_CLIENT) ${BZIP2_LIBRARIES} ${PNG_LIBRARIES} ${X11_LIBRARIES} + ${GETTEXT_LIBRARIES} ${PLATFORM_LIBS} ${CLIENT_PLATFORM_LIBS} jthread @@ -208,6 +218,10 @@ else() set(ARCH i386) endif() + if(WIN32) + set(CMAKE_EXE_LINKER_FLAGS "-lintl -L ${GETTEXT_BIN_DIR}") + endif() + set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${RELEASE_WARNING_FLAGS} ${WARNING_FLAGS} -O3 -ffast-math -Wall -fomit-frame-pointer -pipe -funroll-loops") set(CMAKE_CXX_FLAGS_DEBUG "-g -O1 -Wall ${WARNING_FLAGS}") @@ -239,6 +253,8 @@ if(BUILD_CLIENT) install(FILES ${images} DESTINATION ${DATADIR}) + install(FILES ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-c55.mo DESTINATION locale/de/LC_MESSAGES) + if(WIN32) if(DEFINED IRRLICHT_DLL) install(FILES ${IRRLICHT_DLL} DESTINATION ${BINDIR}) @@ -246,6 +262,10 @@ if(BUILD_CLIENT) if(DEFINED ZLIB_DLL) install(FILES ${ZLIB_DLL} DESTINATION ${BINDIR}) endif() + if(DEFINED GETTEXT_BIN_DIR) + install(FILES ${GETTEXT_BIN_DIR}/libintl3.dll DESTINATION ${BINDIR}) + install(FILES ${GETTEXT_BIN_DIR}/libiconv2.dll DESTINATION ${BINDIR}) + endif() endif() endif(BUILD_CLIENT) @@ -253,6 +273,27 @@ if(BUILD_SERVER) install(TARGETS minetestserver DESTINATION ${BINDIR}) endif(BUILD_SERVER) +if(WIN32) + set(GETTEXT_MSGFMT "${GETTEXT_BIN_DIR}/msgfmt" CACHE FILEPATH "path to msgfmt") +elseif(APPLE) + set(GETTEXT_MSGFMT "${GETTEXT_BIN_DIR}/msgfmt" CACHE FILEPATH "path to msgfmt") +else() + set(GETTEXT_MSGFMT "msgfmt") +endif() + +add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES COMMENT "mo-update [de]: Creating locale directory.") + +add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-c55.mo + COMMAND ${GETTEXT_MSGFMT} -o ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-c55.mo ${CMAKE_SOURCE_DIR}/po/de/minetest-c55.po + DEPENDS + ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES + ${CMAKE_SOURCE_DIR}/po/de/minetest-c55.po + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/po/de + COMMENT "mo-update [de]: Creating mo file." + ) +add_custom_target(translation_de ALL COMMENT "mo update [de]" DEPENDS ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-c55.mo) + # Subdirectories add_subdirectory(jthread) diff --git a/src/gettext.h b/src/gettext.h new file mode 100644 index 000000000..7f5f56e49 --- /dev/null +++ b/src/gettext.h @@ -0,0 +1,12 @@ +#include +#define _(String) gettext(String) +#define gettext_noop(String) String +#define N_(String) gettext_noop (String) + +inline wchar_t* chartowchar_t(char *str) +{ + size_t l = strlen(str)+1; + wchar_t* nstr = new wchar_t[l]; + mbstowcs(nstr, str, l); + return nstr; +} diff --git a/src/guiMainMenu.cpp b/src/guiMainMenu.cpp index cea32860b..f557f4dc0 100644 --- a/src/guiMainMenu.cpp +++ b/src/guiMainMenu.cpp @@ -25,6 +25,8 @@ with this program; if not, write to the Free Software Foundation, Inc., +#include "gettext.h" + GUIMainMenu::GUIMainMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent, s32 id, IMenuManager *menumgr, @@ -175,8 +177,7 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) { core::rect rect(0, 0, 110, 20); rect += topleft_client + v2s32(35, 50+6); - const wchar_t *text = L"Name/Password"; - Environment->addStaticText(text, rect, false, true, this, -1); + Environment->addStaticText(chartowchar_t(gettext("Name/Password")), rect, false, true, this, -1); } { core::rect rect(0, 0, 230, 30); @@ -198,8 +199,7 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) { core::rect rect(0, 0, 110, 20); rect += topleft_client + v2s32(35, 100+6); - const wchar_t *text = L"Address/Port"; - Environment->addStaticText(text, rect, false, true, this, -1); + Environment->addStaticText(chartowchar_t(gettext("Address/Port")), rect, false, true, this, -1); } { core::rect rect(0, 0, 230, 30); @@ -217,28 +217,26 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) } { core::rect rect(0, 0, 400, 20); - rect += topleft_client + v2s32(160, 100+35); - const wchar_t *text = L"Leave address blank to start a local server."; - Environment->addStaticText(text, rect, false, true, this, -1); + Environment->addStaticText(chartowchar_t(gettext("Leave address blank to start a local server.")), rect, false, true, this, -1); } { core::rect rect(0, 0, 250, 30); rect += topleft_client + v2s32(35, 150); Environment->addCheckBox(fancy_trees, rect, this, GUI_ID_FANCYTREE_CB, - L"Fancy trees"); + chartowchar_t(gettext("Fancy trees"))); } { core::rect rect(0, 0, 250, 30); rect += topleft_client + v2s32(35, 150+30); Environment->addCheckBox(smooth_lighting, rect, this, GUI_ID_SMOOTH_LIGHTING_CB, - L"Smooth Lighting"); + chartowchar_t(gettext("Smooth Lighting"))); } // Start game button { core::rect rect(0, 0, 180, 30); //rect += topleft_client + v2s32(size_client.X/2-180/2, 225-30/2); rect += topleft_client + v2s32(size_client.X-180-40, 150+25); - Environment->addButton(rect, this, GUI_ID_JOIN_GAME_BUTTON, L"Start Game / Connect"); + Environment->addButton(rect, this, GUI_ID_JOIN_GAME_BUTTON, chartowchar_t(gettext("Start Game / Connect"))); } // Key change button @@ -246,7 +244,7 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) core::rect rect(0, 0, 100, 30); //rect += topleft_client + v2s32(size_client.X/2-180/2, 225-30/2); rect += topleft_client + v2s32(size_client.X-180-40-100-20, 150+25); - Environment->addButton(rect, this, GUI_ID_CHANGE_KEYS_BUTTON, L"Change keys"); + Environment->addButton(rect, this, GUI_ID_CHANGE_KEYS_BUTTON, chartowchar_t(gettext("Change keys"))); } /* Server section @@ -268,19 +266,19 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) { core::rect rect(0, 0, 250, 30); rect += topleft_server + v2s32(35, 30); - Environment->addCheckBox(creative_mode, rect, this, GUI_ID_CREATIVE_CB, L"Creative Mode"); + Environment->addCheckBox(creative_mode, rect, this, GUI_ID_CREATIVE_CB, chartowchar_t(gettext("Creative Mode"))); } { core::rect rect(0, 0, 250, 30); rect += topleft_server + v2s32(35, 60); - Environment->addCheckBox(enable_damage, rect, this, GUI_ID_DAMAGE_CB, L"Enable Damage"); + Environment->addCheckBox(enable_damage, rect, this, GUI_ID_DAMAGE_CB, chartowchar_t(gettext("Enable Damage"))); } // Map delete button { core::rect rect(0, 0, 130, 30); //rect += topleft_server + v2s32(size_server.X-40-130, 100+25); rect += topleft_server + v2s32(40, 100+25); - Environment->addButton(rect, this, GUI_ID_DELETE_MAP_BUTTON, L"Delete map"); + Environment->addButton(rect, this, GUI_ID_DELETE_MAP_BUTTON, chartowchar_t(gettext("Delete map"))); } } diff --git a/src/guiMessageMenu.cpp b/src/guiMessageMenu.cpp index 192911355..e4e582ab1 100644 --- a/src/guiMessageMenu.cpp +++ b/src/guiMessageMenu.cpp @@ -22,6 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "serialization.h" #include +#include "gettext.h" + GUIMessageMenu::GUIMessageMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent, s32 id, IMenuManager *menumgr, @@ -87,7 +89,7 @@ void GUIMessageMenu::regenerateGui(v2u32 screensize) core::rect rect(0, 0, 140, 30); rect = rect + v2s32(size.X/2-140/2, size.Y/2-30/2+25); gui::IGUIElement *e = - Environment->addButton(rect, this, 257, L"Proceed"); + Environment->addButton(rect, this, 257, chartowchar_t(gettext("Proceed"))); Environment->setFocus(e); } } diff --git a/src/guiPasswordChange.cpp b/src/guiPasswordChange.cpp index ec1cd029a..79601a99f 100644 --- a/src/guiPasswordChange.cpp +++ b/src/guiPasswordChange.cpp @@ -21,6 +21,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "serialization.h" #include +#include "gettext.h" + const int ID_oldPassword = 256; const int ID_newPassword1 = 257; const int ID_newPassword2 = 258; @@ -97,8 +99,7 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize) { core::rect rect(0, 0, 110, 20); rect += topleft_client + v2s32(35, ypos+6); - const wchar_t *text = L"Old Password"; - Environment->addStaticText(text, rect, false, true, this, -1); + Environment->addStaticText(chartowchar_t(gettext("Old Password")), rect, false, true, this, -1); } { core::rect rect(0, 0, 230, 30); @@ -112,8 +113,7 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize) { core::rect rect(0, 0, 110, 20); rect += topleft_client + v2s32(35, ypos+6); - const wchar_t *text = L"New Password"; - Environment->addStaticText(text, rect, false, true, this, -1); + Environment->addStaticText(chartowchar_t(gettext("New Password")), rect, false, true, this, -1); } { core::rect rect(0, 0, 230, 30); @@ -126,8 +126,7 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize) { core::rect rect(0, 0, 110, 20); rect += topleft_client + v2s32(35, ypos+6); - const wchar_t *text = L"Confirm Password"; - Environment->addStaticText(text, rect, false, true, this, -1); + Environment->addStaticText(chartowchar_t(gettext("Confirm Password")), rect, false, true, this, -1); } { core::rect rect(0, 0, 230, 30); @@ -141,16 +140,15 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize) { core::rect rect(0, 0, 140, 30); rect = rect + v2s32(size.X/2-140/2, ypos); - Environment->addButton(rect, this, ID_change, L"Change"); + Environment->addButton(rect, this, ID_change, chartowchar_t(gettext("Change"))); } ypos += 50; { core::rect rect(0, 0, 300, 20); rect += topleft_client + v2s32(35, ypos); - const wchar_t *text = L"Passwords do not match!"; IGUIElement *e = - Environment->addStaticText(text, rect, false, true, this, ID_message); + Environment->addStaticText(chartowchar_t(gettext("Passwords do not match!")), rect, false, true, this, ID_message); e->setVisible(false); } diff --git a/src/guiPauseMenu.cpp b/src/guiPauseMenu.cpp index 1a885a6ea..5f40a4820 100644 --- a/src/guiPauseMenu.cpp +++ b/src/guiPauseMenu.cpp @@ -24,6 +24,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "config.h" #include "main.h" +#include "gettext.h" + GUIPauseMenu::GUIPauseMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent, s32 id, IGameCallback *gamecallback, @@ -104,43 +106,43 @@ void GUIPauseMenu::regenerateGui(v2u32 screensize) { core::rect rect(0, 0, 140, btn_height); rect = rect + v2s32(size.X/2-140/2, btn_y); - Environment->addButton(rect, this, 256, L"Continue"); + Environment->addButton(rect, this, 256, chartowchar_t(gettext("Continue"))); } btn_y += btn_height + btn_gap; { core::rect rect(0, 0, 140, btn_height); rect = rect + v2s32(size.X/2-140/2, btn_y); - Environment->addButton(rect, this, 261, L"Change Password"); + Environment->addButton(rect, this, 261, chartowchar_t(gettext("Change Password"))); } btn_y += btn_height + btn_gap; { core::rect rect(0, 0, 140, btn_height); rect = rect + v2s32(size.X/2-140/2, btn_y); - Environment->addButton(rect, this, 260, L"Disconnect"); + Environment->addButton(rect, this, 260, chartowchar_t(gettext("Disconnect"))); } btn_y += btn_height + btn_gap; { core::rect rect(0, 0, 140, btn_height); rect = rect + v2s32(size.X/2-140/2, btn_y); - Environment->addButton(rect, this, 257, L"Exit to OS"); + Environment->addButton(rect, this, 257, chartowchar_t(gettext("Exit to OS"))); } { core::rect rect(0, 0, 180, 240); rect = rect + v2s32(size.X/2 + 90, size.Y/2-rect.getHeight()/2); - const wchar_t *text = - L"Keys:\n" - L"- WASD: Walk\n" - L"- Mouse left: dig blocks\n" - L"- Mouse right: place blocks\n" - L"- Mouse wheel: select item\n" - L"- 0...9: select item\n" - L"- Shift: sneak\n" - L"- R: Toggle viewing all loaded chunks\n" - L"- I: Inventory menu\n" - L"- ESC: This menu\n" - L"- T: Chat\n"; - Environment->addStaticText(text, rect, false, true, this, 258); + Environment->addStaticText(chartowchar_t(gettext( + "Keys:\n" + "- WASD: Walk\n" + "- Mouse left: dig blocks\n" + "- Mouse right: place blocks\n" + "- Mouse wheel: select item\n" + "- 0...9: select item\n" + "- Shift: sneak\n" + "- R: Toggle viewing all loaded chunks\n" + "- I: Inventory menu\n" + "- ESC: This menu\n" + "- T: Chat\n" + )), rect, false, true, this, 258); } { core::rect rect(0, 0, 180, 220); diff --git a/src/guiTextInputMenu.cpp b/src/guiTextInputMenu.cpp index 2cb8cae62..b15f8bc07 100644 --- a/src/guiTextInputMenu.cpp +++ b/src/guiTextInputMenu.cpp @@ -22,6 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "serialization.h" #include +#include "gettext.h" + GUITextInputMenu::GUITextInputMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent, s32 id, IMenuManager *menumgr, @@ -105,7 +107,7 @@ void GUITextInputMenu::regenerateGui(v2u32 screensize) { core::rect rect(0, 0, 140, 30); rect = rect + v2s32(size.X/2-140/2, size.Y/2-30/2+25); - Environment->addButton(rect, this, 257, L"Proceed"); + Environment->addButton(rect, this, 257, chartowchar_t(gettext("Proceed"))); } } diff --git a/src/main.cpp b/src/main.cpp index 698c5fc71..1cc479d65 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -401,6 +401,8 @@ Doing currently: #include "keycode.h" #include "tile.h" +#include "gettext.h" + // This makes textures ITextureSource *g_texturesource = NULL; @@ -1058,6 +1060,9 @@ int main(int argc, char *argv[]) std::locale::global(std::locale("C")); // This enables printing all characters in bitmap font setlocale(LC_CTYPE, "en_US"); + setlocale(LC_ALL, ""); + bindtextdomain("minetest-c55", "./../locale"); + textdomain("minetest-c55"); /* Parse command line -- cgit v1.2.3 From 3321edae77184ae9693e3b74c9ea6235ec1f9029 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Tue, 19 Jul 2011 20:02:31 +0200 Subject: Use system sqlite3/jthread libs if available --- src/CMakeLists.txt | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fd1591423..e1de23663 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -43,6 +43,8 @@ else() find_package(JPEG REQUIRED) find_package(BZip2 REQUIRED) find_package(PNG REQUIRED) + find_package(Jthread REQUIRED) + find_package(Sqlite3 REQUIRED) if(APPLE) FIND_LIBRARY(CARBON_LIB Carbon) FIND_LIBRARY(COCOA_LIB Cocoa) @@ -143,8 +145,8 @@ include_directories( ${CMAKE_BUILD_TYPE} ${PNG_INCLUDE_DIR} ${GETTEXT_INCLUDE_DIR} - "${PROJECT_SOURCE_DIR}/jthread" - "${PROJECT_SOURCE_DIR}/sqlite" + ${JTHREAD_INCLUDE_DIR} + ${SQLITE3_INCLUDE_DIR} ) set(EXECUTABLE_OUTPUT_PATH ../bin) @@ -163,8 +165,8 @@ if(BUILD_CLIENT) ${GETTEXT_LIBRARIES} ${PLATFORM_LIBS} ${CLIENT_PLATFORM_LIBS} - jthread - sqlite3 + ${JTHREAD_LIBRARY} + ${SQLITE3_LIBRARY} ) endif(BUILD_CLIENT) @@ -174,8 +176,8 @@ if(BUILD_SERVER) minetestserver ${ZLIB_LIBRARIES} ${PLATFORM_LIBS} - jthread - sqlite3 + ${JTHREAD_LIBRARY} + ${SQLITE3_LIBRARY} ) endif(BUILD_SERVER) @@ -296,7 +298,14 @@ add_custom_target(translation_de ALL COMMENT "mo update [de]" DEPENDS ${CMAKE_BI # Subdirectories -add_subdirectory(jthread) +if (JTHREAD_FOUND) +else (JTHREAD_FOUND) + add_subdirectory(jthread) +endif (JTHREAD_FOUND) + +if (SQLITE3_FOUND) +else (SQLITE3_FOUND) add_subdirectory(sqlite) +endif (SQLITE3_FOUND) #end -- cgit v1.2.3 From 8fa94c3547dc7bd25e9bb7f0c404a00028a1107d Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Wed, 8 Jun 2011 17:27:30 +0200 Subject: Check the data path before usage When not running in place, check if the assumed data path in ../share/APPNAME exists. If it doesn't exist, fall back to ../data instead. This allows the program to run successfully from the checkout directory even without the run-in-place flag active. --- src/porting.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/porting.cpp b/src/porting.cpp index 7de042ab5..ff8cb3862 100644 --- a/src/porting.cpp +++ b/src/porting.cpp @@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "porting.h" #include "config.h" #include "debug.h" +#include "filesys.h" #ifdef __APPLE__ #include "CoreFoundation/CoreFoundation.h" @@ -210,6 +211,11 @@ void initializePaths() path_data = std::string(buf) + "/../share/" + APPNAME; //path_data = std::string(INSTALL_PREFIX) + "/share/" + APPNAME; + if (!fs::PathExists(path_data)) { + dstream<<"WARNING: data path " << path_data << " not found!"; + path_data = std::string(buf) + "/../data"; + dstream<<" Trying " << path_data << std::endl; + } path_userdata = std::string(getenv("HOME")) + "/." + APPNAME; -- cgit v1.2.3 From 52df1b598c253eda7b9e33cf9b7e97d16c7dc138 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Thu, 9 Jun 2011 22:31:40 +0200 Subject: Set the window caption for the initial window too --- src/main.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 1cc479d65..7d0ea12ab 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1350,6 +1350,9 @@ int main(int argc, char *argv[]) // Set device in game parameters device = device; + + // Set the window caption + device->setWindowCaption(L"Minetest [Main Menu]"); // Create time getter g_timegetter = new IrrlichtTimeGetter(device); -- cgit v1.2.3 From c6d99fbe0c42b86585263a2562db671d9c168581 Mon Sep 17 00:00:00 2001 From: Constantin Wenger Date: Wed, 20 Jul 2011 18:49:18 +0200 Subject: fixed problem with wront paths in gettext --- src/main.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 1cc479d65..00248a203 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1060,10 +1060,6 @@ int main(int argc, char *argv[]) std::locale::global(std::locale("C")); // This enables printing all characters in bitmap font setlocale(LC_CTYPE, "en_US"); - setlocale(LC_ALL, ""); - bindtextdomain("minetest-c55", "./../locale"); - textdomain("minetest-c55"); - /* Parse command line */ @@ -1135,6 +1131,10 @@ int main(int argc, char *argv[]) // Create user data directory fs::CreateDir(porting::path_userdata); + + setlocale(LC_ALL, ""); + bindtextdomain("minetest-c55", (porting::path_userdata+"/locale").c_str()); + textdomain("minetest-c55"); // Initialize debug streams #ifdef RUN_IN_PLACE -- cgit v1.2.3 From 8129d16dd3f7e5575c444b4792e667a1e3df98e2 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Wed, 20 Jul 2011 22:04:24 +0200 Subject: + fireflies --- src/content_cao.cpp | 157 +++++++++++++++++++++++++++++++++++++++++ src/content_cao.h | 42 +++++++++++ src/content_inventory.cpp | 9 ++- src/content_object.h | 1 + src/content_sao.cpp | 175 ++++++++++++++++++++++++++++++++++++++++++++++ src/content_sao.h | 24 +++++++ src/environment.cpp | 3 +- 7 files changed, 409 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/content_cao.cpp b/src/content_cao.cpp index dc5ac400f..dfeaea85a 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -752,4 +752,161 @@ void Oerkki1CAO::initialize(const std::string &data) updateNodePos(); } +/* + FireflyCAO +*/ + +// Prototype +FireflyCAO proto_FireflyCAO; + +FireflyCAO::FireflyCAO(): + ClientActiveObject(0), + m_selection_box(-BS/3.,0.0,-BS/3., BS/3.,BS/2.,BS/3.), + m_node(NULL), + m_position(v3f(0,10*BS,0)), + m_yaw(0) +{ + ClientActiveObject::registerType(getType(), create); +} +FireflyCAO::~FireflyCAO() +{ +} + +ClientActiveObject* FireflyCAO::create() +{ + return new FireflyCAO(); +} + +void FireflyCAO::addToScene(scene::ISceneManager *smgr) +{ + if(m_node != NULL) + return; + + video::IVideoDriver* driver = smgr->getVideoDriver(); + + scene::SMesh *mesh = new scene::SMesh(); + scene::IMeshBuffer *buf = new scene::SMeshBuffer(); + video::SColor c(255,255,255,255); + video::S3DVertex vertices[4] = + { + video::S3DVertex(0,0,0, 0,0,0, c, 0,1), + video::S3DVertex(BS/2,0,0, 0,0,0, c, 1,1), + video::S3DVertex(BS/2,BS/2,0, 0,0,0, c, 1,0), + video::S3DVertex(0,BS/2,0, 0,0,0, c, 0,0), + }; + u16 indices[] = {0,1,2,2,3,0}; + buf->append(vertices, 4, indices, 6); + // Set material + buf->getMaterial().setFlag(video::EMF_LIGHTING, false); + buf->getMaterial().setFlag(video::EMF_BACK_FACE_CULLING, false); + //buf->getMaterial().setTexture(0, NULL); + buf->getMaterial().setTexture + (0, driver->getTexture(getTexturePath("firefly.png").c_str())); + buf->getMaterial().setFlag(video::EMF_BILINEAR_FILTER, false); + buf->getMaterial().setFlag(video::EMF_FOG_ENABLE, true); + buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; + // Add to mesh + mesh->addMeshBuffer(buf); + buf->drop(); + m_node = smgr->addMeshSceneNode(mesh, NULL); + mesh->drop(); + // Set it to use the materials of the meshbuffers directly. + // This is needed for changing the texture in the future + m_node->setReadOnlyMaterials(true); + updateNodePos(); +} + +void FireflyCAO::removeFromScene() +{ + if(m_node == NULL) + return; + + m_node->remove(); + m_node = NULL; +} + +void FireflyCAO::updateLight(u8 light_at_pos) +{ + if(m_node == NULL) + return; + + u8 li = 255; + video::SColor color(255,li,li,li); + + scene::IMesh *mesh = m_node->getMesh(); + if(mesh == NULL) + return; + + u16 mc = mesh->getMeshBufferCount(); + for(u16 j=0; jgetMeshBuffer(j); + video::S3DVertex *vertices = (video::S3DVertex*)buf->getVertices(); + u16 vc = buf->getVertexCount(); + for(u16 i=0; isetPosition(m_position); + m_node->setPosition(pos_translator.vect_show); + + v3f rot = m_node->getRotation(); + rot.Y = 180.0 - m_yaw; + m_node->setRotation(rot); +} + +void FireflyCAO::step(float dtime, ClientEnvironment *env) +{ + pos_translator.translate(dtime); + updateNodePos(); +} + +void FireflyCAO::processMessage(const std::string &data) +{ + //dstream<<"FireflyCAO: Got message"<* getSelectionBox() + {return &m_selection_box;} + v3f getPosition() + {return m_position;} + +private: + core::aabbox3d m_selection_box; + scene::IMeshSceneNode *m_node; + v3f m_position; + float m_yaw; + SmoothTranslator pos_translator; +}; + #endif diff --git a/src/content_inventory.cpp b/src/content_inventory.cpp index 7d995cb5f..1068defb5 100644 --- a/src/content_inventory.cpp +++ b/src/content_inventory.cpp @@ -65,6 +65,8 @@ std::string item_craft_get_image_name(const std::string &subname) return "clay_brick.png"; else if(subname == "rat") return "rat.png"; + else if(subname == "firefly") + return "firefly.png"; else return "cloud.png"; // just something } @@ -77,13 +79,18 @@ ServerActiveObject* item_craft_create_object(const std::string &subname, ServerActiveObject *obj = new RatSAO(env, id, pos); return obj; } + else if(subname == "firefly") + { + ServerActiveObject *obj = new FireflySAO(env, id, pos); + return obj; + } return NULL; } s16 item_craft_get_drop_count(const std::string &subname) { - if(subname == "rat") + if(subname == "rat" || subname == "firefly") return 1; return -1; diff --git a/src/content_object.h b/src/content_object.h index ecabd8a38..47f93d7d4 100644 --- a/src/content_object.h +++ b/src/content_object.h @@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #define ACTIVEOBJECT_TYPE_ITEM 2 #define ACTIVEOBJECT_TYPE_RAT 3 #define ACTIVEOBJECT_TYPE_OERKKI1 4 +#define ACTIVEOBJECT_TYPE_FIREFLY 5 #endif diff --git a/src/content_sao.cpp b/src/content_sao.cpp index c41f4ed78..aeeafc2f8 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -693,4 +693,179 @@ void Oerkki1SAO::doDamage(u16 d) } } +/* + FireflySAO +*/ + +// Prototype +FireflySAO proto_FireflySAO(NULL, 0, v3f(0,0,0)); + +FireflySAO::FireflySAO(ServerEnvironment *env, u16 id, v3f pos): + ServerActiveObject(env, id, pos), + m_is_active(false), + m_speed_f(0,0,0) +{ + ServerActiveObject::registerType(getType(), create); + + m_oldpos = v3f(0,0,0); + m_last_sent_position = v3f(0,0,0); + m_yaw = 0; + m_counter1 = 0; + m_counter2 = 0; + m_age = 0; + m_touching_ground = false; +} + +ServerActiveObject* FireflySAO::create(ServerEnvironment *env, u16 id, v3f pos, + const std::string &data) +{ + std::istringstream is(data, std::ios::binary); + char buf[1]; + // read version + is.read(buf, 1); + u8 version = buf[0]; + // check if version is supported + if(version != 0) + return NULL; + return new FireflySAO(env, id, pos); +} + +void FireflySAO::step(float dtime, bool send_recommended) +{ + assert(m_env); + + if(m_is_active == false) + { + if(m_inactive_interval.step(dtime, 0.5)==false) + return; + } + + /* + The AI + */ + + // Apply (less) gravity + m_speed_f.Y -= dtime*3*BS; + + /* + Move around if some player is close + */ + bool player_is_close = false; + // Check connected players + core::list players = m_env->getPlayers(true); + core::list::Iterator i; + for(i = players.begin(); + i != players.end(); i++) + { + Player *player = *i; + v3f playerpos = player->getPosition(); + if(m_base_position.getDistanceFrom(playerpos) < BS*10.0) + { + player_is_close = true; + break; + } + } + + m_is_active = player_is_close; + + if(player_is_close == false) + { + m_speed_f.X = 0; + m_speed_f.Z = 0; + } + else + { + // Move around + v3f dir(cos(m_yaw/180*PI),0,sin(m_yaw/180*PI)); + f32 speed = BS/2; + m_speed_f.X = speed * dir.X; + m_speed_f.Z = speed * dir.Z; + + if(m_touching_ground && (m_oldpos - m_base_position).getLength() + < dtime*speed/2) + { + m_counter1 -= dtime; + if(m_counter1 < 0.0) + { + m_counter1 += 1.0; + m_speed_f.Y = 5.0*BS; + } + } + + { + m_counter2 -= dtime; + if(m_counter2 < 0.0) + { + m_counter2 += (float)(myrand()%100)/100*3.0; + m_yaw += ((float)(myrand()%200)-100)/100*180; + m_yaw = wrapDegrees(m_yaw); + } + } + } + + m_oldpos = m_base_position; + /* + Move it, with collision detection + */ + + core::aabbox3d box(-BS/3.,0.0,-BS/3., BS/3.,BS*2./3.,BS/3.); + collisionMoveResult moveresult; + // Maximum movement without glitches + f32 pos_max_d = BS*0.25; + // Limit speed + if(m_speed_f.getLength()*dtime > pos_max_d) + m_speed_f *= pos_max_d / (m_speed_f.getLength()*dtime); + v3f pos_f = getBasePosition(); + v3f pos_f_old = pos_f; + moveresult = collisionMoveSimple(&m_env->getMap(), pos_max_d, + box, dtime, pos_f, m_speed_f); + m_touching_ground = moveresult.touching_ground; + + setBasePosition(pos_f); + + if(send_recommended == false) + return; + + if(pos_f.getDistanceFrom(m_last_sent_position) > 0.05*BS) + { + m_last_sent_position = pos_f; + + std::ostringstream os(std::ios::binary); + // command (0 = update position) + writeU8(os, 0); + // pos + writeV3F1000(os, m_base_position); + // yaw + writeF1000(os, m_yaw); + // create message and add to list + ActiveObjectMessage aom(getId(), false, os.str()); + m_messages_out.push_back(aom); + } +} + +std::string FireflySAO::getClientInitializationData() +{ + std::ostringstream os(std::ios::binary); + // version + writeU8(os, 0); + // pos + writeV3F1000(os, m_base_position); + return os.str(); +} + +std::string FireflySAO::getStaticData() +{ + //dstream<<__FUNCTION_NAME< Date: Wed, 20 Jul 2011 22:49:48 +0200 Subject: Move package search out of conditional This unbreaks the Windows build which would otherwise have problems at the jthread level. --- src/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e1de23663..72f79976c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -43,8 +43,6 @@ else() find_package(JPEG REQUIRED) find_package(BZip2 REQUIRED) find_package(PNG REQUIRED) - find_package(Jthread REQUIRED) - find_package(Sqlite3 REQUIRED) if(APPLE) FIND_LIBRARY(CARBON_LIB Carbon) FIND_LIBRARY(COCOA_LIB Cocoa) @@ -65,6 +63,9 @@ else() set(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} ${XXF86VM_LIBRARY}) endif() +find_package(Jthread REQUIRED) +find_package(Sqlite3 REQUIRED) + configure_file( "${PROJECT_SOURCE_DIR}/cmake_config.h.in" "${PROJECT_BINARY_DIR}/cmake_config.h" -- cgit v1.2.3 From 9cb5f70be56dbbbb75bb12de23f05243d2173030 Mon Sep 17 00:00:00 2001 From: Weedy Date: Thu, 21 Jul 2011 02:30:21 -0400 Subject: Fix win32 MSVC compile. (screw gettext) --- src/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 72f79976c..a578eeb79 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -31,8 +31,8 @@ if(WIN32) CACHE PATH "gettext include directory") set(GETTEXT_BIN_DIR "${PROJECT_SOURCE_DIR}/../../gettext/bin" CACHE PATH "gettext bin directory") - set(GETTEXT_LIBRARIES "${PROJECT_SOURCE_DIR}/../../gettext/lib/intl.lib" - CACHE FILEPATH "gettext intl.lib") + set(GETTEXT_LIBRARIES "${PROJECT_SOURCE_DIR}/../../gettext/lib/libintl.lib" + CACHE FILEPATH "gettext libintl.lib") set(IRRLICHT_SOURCE_DIR "${PROJECT_SOURCE_DIR}/../../irrlicht-1.7.2" CACHE PATH "irrlicht dir") else() @@ -277,7 +277,7 @@ if(BUILD_SERVER) endif(BUILD_SERVER) if(WIN32) - set(GETTEXT_MSGFMT "${GETTEXT_BIN_DIR}/msgfmt" CACHE FILEPATH "path to msgfmt") + set(GETTEXT_MSGFMT "${GETTEXT_BIN_DIR}/msgfmt.exe" CACHE FILEPATH "path to msgfmt") elseif(APPLE) set(GETTEXT_MSGFMT "${GETTEXT_BIN_DIR}/msgfmt" CACHE FILEPATH "path to msgfmt") else() -- cgit v1.2.3 From 36d8f91f1acfaec345c44fc5518b3acbcafad695 Mon Sep 17 00:00:00 2001 From: Weedy Date: Thu, 21 Jul 2011 02:36:30 -0400 Subject: Tweak makefiles to add -delta suffix. --- src/CMakeLists.txt | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a578eeb79..2e99ec0c9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -project(minetest) +project(minetest-delta) cmake_minimum_required( VERSION 2.6 ) if(RUN_IN_PLACE) @@ -153,9 +153,9 @@ include_directories( set(EXECUTABLE_OUTPUT_PATH ../bin) if(BUILD_CLIENT) - add_executable(minetest ${minetest_SRCS}) + add_executable(${PROJECT_NAME} ${minetest_SRCS}) target_link_libraries( - minetest + ${PROJECT_NAME} ${ZLIB_LIBRARIES} ${IRRLICHT_LIBRARY} ${OPENGL_LIBRARIES} @@ -172,9 +172,9 @@ if(BUILD_CLIENT) endif(BUILD_CLIENT) if(BUILD_SERVER) - add_executable(minetestserver ${minetestserver_SRCS}) + add_executable(${PROJECT_NAME}server ${minetestserver_SRCS}) target_link_libraries( - minetestserver + ${PROJECT_NAME}server ${ZLIB_LIBRARIES} ${PLATFORM_LIBS} ${JTHREAD_LIBRARY} @@ -199,7 +199,7 @@ if(MSVC) set(CMAKE_CXX_FLAGS_DEBUG "/MDd /Zi /Ob0 /Od /RTC1") if(BUILD_SERVER) - set_target_properties(minetestserver PROPERTIES + set_target_properties(${PROJECT_NAME}server PROPERTIES COMPILE_DEFINITIONS "SERVER") endif(BUILD_SERVER) @@ -233,7 +233,7 @@ else() endif() if(BUILD_SERVER) - set_target_properties(minetestserver PROPERTIES + set_target_properties(${PROJECT_NAME}server PROPERTIES COMPILE_DEFINITIONS "SERVER") endif(BUILD_SERVER) @@ -250,13 +250,13 @@ endif() install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../minetest.conf.example" DESTINATION ${EXAMPLE_CONF_DIR}) if(BUILD_CLIENT) - install(TARGETS minetest DESTINATION ${BINDIR}) + install(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR}) file(GLOB images "${CMAKE_CURRENT_SOURCE_DIR}/../data/*.png") install(FILES ${images} DESTINATION ${DATADIR}) - install(FILES ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-c55.mo DESTINATION locale/de/LC_MESSAGES) + install(FILES ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-delta.mo DESTINATION locale/de/LC_MESSAGES) if(WIN32) if(DEFINED IRRLICHT_DLL) @@ -273,7 +273,7 @@ if(BUILD_CLIENT) endif(BUILD_CLIENT) if(BUILD_SERVER) - install(TARGETS minetestserver DESTINATION ${BINDIR}) + install(TARGETS ${PROJECT_NAME}server DESTINATION ${BINDIR}) endif(BUILD_SERVER) if(WIN32) @@ -287,15 +287,15 @@ endif() add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES COMMENT "mo-update [de]: Creating locale directory.") add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-c55.mo - COMMAND ${GETTEXT_MSGFMT} -o ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-c55.mo ${CMAKE_SOURCE_DIR}/po/de/minetest-c55.po + OUTPUT ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-delta.mo + COMMAND ${GETTEXT_MSGFMT} -o ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-delta.mo ${CMAKE_SOURCE_DIR}/po/de/minetest-c55.po DEPENDS ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES ${CMAKE_SOURCE_DIR}/po/de/minetest-c55.po WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/po/de COMMENT "mo-update [de]: Creating mo file." ) -add_custom_target(translation_de ALL COMMENT "mo update [de]" DEPENDS ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-c55.mo) +add_custom_target(translation_de ALL COMMENT "mo update [de]" DEPENDS ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-delta.mo) # Subdirectories -- cgit v1.2.3 From fd70bbd36785c27fa8ef8229eee79fac32557e42 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Thu, 21 Jul 2011 07:53:13 +0200 Subject: Make gettext optional --- src/CMakeLists.txt | 66 +++++++++++++++++++++++++++++++++--------------------- src/gettext.h | 9 +++++++- 2 files changed, 48 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2e99ec0c9..fb8f419e5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,6 +5,16 @@ if(RUN_IN_PLACE) add_definitions ( -DRUN_IN_PLACE ) endif(RUN_IN_PLACE) +if(USE_GETTEXT) + add_definitions( -DUSE_GETTEXT ) + message(STATUS "GetText enabled") +else() + set(GETTEXT_INCLUDE_DIR "") + set(GETTEXT_BIN_DIR "") + set(GETTEXT_LIBRARIES "") + message(STATUS "GetText disabled") +endif(USE_GETTEXT) + if(NOT MSVC) set(USE_GPROF 0 CACHE BOOL "Use -pg flag for g++") endif() @@ -27,14 +37,16 @@ if(WIN32) CACHE FILEPATH "Path to zlibwapi.lib") set(ZLIB_DLL "${PROJECT_SOURCE_DIR}/../../zlib125dll/dll32/zlibwapi.dll" CACHE FILEPATH "Path to zlibwapi.dll (for installation)") - set(GETTEXT_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/../../gettext/include" + set(IRRLICHT_SOURCE_DIR "${PROJECT_SOURCE_DIR}/../../irrlicht-1.7.2" + CACHE PATH "irrlicht dir") + if (USE_GETTEXT) + set(GETTEXT_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/../../gettext/include" CACHE PATH "gettext include directory") - set(GETTEXT_BIN_DIR "${PROJECT_SOURCE_DIR}/../../gettext/bin" + set(GETTEXT_BIN_DIR "${PROJECT_SOURCE_DIR}/../../gettext/bin" CACHE PATH "gettext bin directory") - set(GETTEXT_LIBRARIES "${PROJECT_SOURCE_DIR}/../../gettext/lib/libintl.lib" + set(GETTEXT_LIBRARIES "${PROJECT_SOURCE_DIR}/../../gettext/lib/libintl.lib" CACHE FILEPATH "gettext libintl.lib") - set(IRRLICHT_SOURCE_DIR "${PROJECT_SOURCE_DIR}/../../irrlicht-1.7.2" - CACHE PATH "irrlicht dir") + endif(USE_GETTEXT) else() # Unix probably if(BUILD_CLIENT) @@ -221,7 +233,7 @@ else() set(ARCH i386) endif() - if(WIN32) + if(WIN32 AND USE_GETTEXT) set(CMAKE_EXE_LINKER_FLAGS "-lintl -L ${GETTEXT_BIN_DIR}") endif() @@ -265,7 +277,7 @@ if(BUILD_CLIENT) if(DEFINED ZLIB_DLL) install(FILES ${ZLIB_DLL} DESTINATION ${BINDIR}) endif() - if(DEFINED GETTEXT_BIN_DIR) + if(USE_GETTEXT AND DEFINED GETTEXT_BIN_DIR) install(FILES ${GETTEXT_BIN_DIR}/libintl3.dll DESTINATION ${BINDIR}) install(FILES ${GETTEXT_BIN_DIR}/libiconv2.dll DESTINATION ${BINDIR}) endif() @@ -276,26 +288,28 @@ if(BUILD_SERVER) install(TARGETS ${PROJECT_NAME}server DESTINATION ${BINDIR}) endif(BUILD_SERVER) -if(WIN32) - set(GETTEXT_MSGFMT "${GETTEXT_BIN_DIR}/msgfmt.exe" CACHE FILEPATH "path to msgfmt") -elseif(APPLE) - set(GETTEXT_MSGFMT "${GETTEXT_BIN_DIR}/msgfmt" CACHE FILEPATH "path to msgfmt") -else() - set(GETTEXT_MSGFMT "msgfmt") -endif() +if (USE_GETTEXT) + if(WIN32) + set(GETTEXT_MSGFMT "${GETTEXT_BIN_DIR}/msgfmt.exe" CACHE FILEPATH "path to msgfmt") + elseif(APPLE) + set(GETTEXT_MSGFMT "${GETTEXT_BIN_DIR}/msgfmt" CACHE FILEPATH "path to msgfmt") + else() + set(GETTEXT_MSGFMT "msgfmt") + endif() + + add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES COMMENT "mo-update [de]: Creating locale directory.") -add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES COMMENT "mo-update [de]: Creating locale directory.") - -add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-delta.mo - COMMAND ${GETTEXT_MSGFMT} -o ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-delta.mo ${CMAKE_SOURCE_DIR}/po/de/minetest-c55.po - DEPENDS - ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES - ${CMAKE_SOURCE_DIR}/po/de/minetest-c55.po - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/po/de - COMMENT "mo-update [de]: Creating mo file." - ) -add_custom_target(translation_de ALL COMMENT "mo update [de]" DEPENDS ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-delta.mo) + add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-delta.mo + COMMAND ${GETTEXT_MSGFMT} -o ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-delta.mo ${CMAKE_SOURCE_DIR}/po/de/minetest-c55.po + DEPENDS + ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES + ${CMAKE_SOURCE_DIR}/po/de/minetest-c55.po + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/po/de + COMMENT "mo-update [de]: Creating mo file." + ) + add_custom_target(translation_de ALL COMMENT "mo update [de]" DEPENDS ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-delta.mo) +endif(USE_GETTEXT) # Subdirectories diff --git a/src/gettext.h b/src/gettext.h index 7f5f56e49..8ddb95346 100644 --- a/src/gettext.h +++ b/src/gettext.h @@ -1,9 +1,16 @@ +#ifdef USE_GETTEXT #include +#else +#define gettext(String) String +#define bindtextdomain(domain, dir) /* */ +#define textdomain(domain) /* */ +#endif + #define _(String) gettext(String) #define gettext_noop(String) String #define N_(String) gettext_noop (String) -inline wchar_t* chartowchar_t(char *str) +inline wchar_t* chartowchar_t(const char *str) { size_t l = strlen(str)+1; wchar_t* nstr = new wchar_t[l]; -- cgit v1.2.3 From b99174cb0c680396373c0190d4c04afa7e28028f Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Thu, 21 Jul 2011 12:33:29 +0200 Subject: Refactor and clean up gettext management --- src/CMakeLists.txt | 54 ++++++++++++++++++++++++++---------------------------- 1 file changed, 26 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fb8f419e5..8785a0e3f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,12 +6,22 @@ if(RUN_IN_PLACE) endif(RUN_IN_PLACE) if(USE_GETTEXT) - add_definitions( -DUSE_GETTEXT ) - message(STATUS "GetText enabled") -else() - set(GETTEXT_INCLUDE_DIR "") - set(GETTEXT_BIN_DIR "") - set(GETTEXT_LIBRARIES "") + find_package(GettextLib REQUIRED) + if (GETTEXT_FOUND) + add_definitions( -DUSE_GETTEXT ) + message(STATUS "gettext include path: ${GETTEXT_INCLUDE_DIR}") + message(STATUS "gettext msgfmt path: ${GETTEXT_MSGFMT}") + if(WIN32) + message(STATUS "gettext library: ${GETTEXT_LIBRARY}") + message(STATUS "gettext dll: ${GETTEXT_DLL}") + message(STATUS "gettext iconv dll: ${GETTEXT_ICONV_DLL}") + endif() + message(STATUS "GetText enabled") + else() + message(ERROR "GetText enabled but not found, disabling") + set(USE_GETTEXT FALSE) + endif(GETTEXT_FOUND) +else(USE_GETTEXT) message(STATUS "GetText disabled") endif(USE_GETTEXT) @@ -39,14 +49,6 @@ if(WIN32) CACHE FILEPATH "Path to zlibwapi.dll (for installation)") set(IRRLICHT_SOURCE_DIR "${PROJECT_SOURCE_DIR}/../../irrlicht-1.7.2" CACHE PATH "irrlicht dir") - if (USE_GETTEXT) - set(GETTEXT_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/../../gettext/include" - CACHE PATH "gettext include directory") - set(GETTEXT_BIN_DIR "${PROJECT_SOURCE_DIR}/../../gettext/bin" - CACHE PATH "gettext bin directory") - set(GETTEXT_LIBRARIES "${PROJECT_SOURCE_DIR}/../../gettext/lib/libintl.lib" - CACHE FILEPATH "gettext libintl.lib") - endif(USE_GETTEXT) else() # Unix probably if(BUILD_CLIENT) @@ -175,7 +177,7 @@ if(BUILD_CLIENT) ${BZIP2_LIBRARIES} ${PNG_LIBRARIES} ${X11_LIBRARIES} - ${GETTEXT_LIBRARIES} + ${GETTEXT_LIBRARY} ${PLATFORM_LIBS} ${CLIENT_PLATFORM_LIBS} ${JTHREAD_LIBRARY} @@ -234,7 +236,7 @@ else() endif() if(WIN32 AND USE_GETTEXT) - set(CMAKE_EXE_LINKER_FLAGS "-lintl -L ${GETTEXT_BIN_DIR}") + set(CMAKE_EXE_LINKER_FLAGS "-l${GETTEXT_LIBRARY}") endif() set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${RELEASE_WARNING_FLAGS} ${WARNING_FLAGS} -O3 -ffast-math -Wall -fomit-frame-pointer -pipe -funroll-loops") @@ -277,10 +279,14 @@ if(BUILD_CLIENT) if(DEFINED ZLIB_DLL) install(FILES ${ZLIB_DLL} DESTINATION ${BINDIR}) endif() - if(USE_GETTEXT AND DEFINED GETTEXT_BIN_DIR) - install(FILES ${GETTEXT_BIN_DIR}/libintl3.dll DESTINATION ${BINDIR}) - install(FILES ${GETTEXT_BIN_DIR}/libiconv2.dll DESTINATION ${BINDIR}) - endif() + if(USE_GETTEXT) + if(defined GETTEXT_DLL) + install(FILES ${GETTEXT_DLL} DESTINATION ${BINDIR}) + endif() + if(defined GETTEXT_ICONV_DLL) + install(FILES ${GETTEXT_ICONV_DLL} DESTINATION ${BINDIR}) + endif() + endif(USE_GETTEXT) endif() endif(BUILD_CLIENT) @@ -289,14 +295,6 @@ if(BUILD_SERVER) endif(BUILD_SERVER) if (USE_GETTEXT) - if(WIN32) - set(GETTEXT_MSGFMT "${GETTEXT_BIN_DIR}/msgfmt.exe" CACHE FILEPATH "path to msgfmt") - elseif(APPLE) - set(GETTEXT_MSGFMT "${GETTEXT_BIN_DIR}/msgfmt" CACHE FILEPATH "path to msgfmt") - else() - set(GETTEXT_MSGFMT "msgfmt") - endif() - add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES COMMENT "mo-update [de]: Creating locale directory.") add_custom_command( -- cgit v1.2.3 From adb7181969a6398762873298ef0b50ca575d7b31 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Thu, 21 Jul 2011 13:59:50 +0200 Subject: Uppercase DEFINED or cmake 2.8.4 complains --- src/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8785a0e3f..2d7a7fc68 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -280,10 +280,10 @@ if(BUILD_CLIENT) install(FILES ${ZLIB_DLL} DESTINATION ${BINDIR}) endif() if(USE_GETTEXT) - if(defined GETTEXT_DLL) + if(DEFINED GETTEXT_DLL) install(FILES ${GETTEXT_DLL} DESTINATION ${BINDIR}) endif() - if(defined GETTEXT_ICONV_DLL) + if(DEFINED GETTEXT_ICONV_DLL) install(FILES ${GETTEXT_ICONV_DLL} DESTINATION ${BINDIR}) endif() endif(USE_GETTEXT) -- cgit v1.2.3 From 7b93fb59cfbc9d89e13b8046634c0ab5a1a4a691 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Thu, 21 Jul 2011 14:46:14 +0200 Subject: Only install locale files if using gettext --- src/CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2d7a7fc68..6cc5c035f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -270,8 +270,10 @@ if(BUILD_CLIENT) install(FILES ${images} DESTINATION ${DATADIR}) - install(FILES ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-delta.mo DESTINATION locale/de/LC_MESSAGES) - + if (USE_GETTEXT) + install(FILES ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-delta.mo DESTINATION locale/de/LC_MESSAGES) + endif() + if(WIN32) if(DEFINED IRRLICHT_DLL) install(FILES ${IRRLICHT_DLL} DESTINATION ${BINDIR}) -- cgit v1.2.3 From 02695bebc632042dd684991665b93925b974d7d4 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Thu, 21 Jul 2011 14:50:15 +0200 Subject: Find correct library for MSVC vs MingW in Winows --- src/CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6cc5c035f..c018d8e56 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -235,10 +235,6 @@ else() set(ARCH i386) endif() - if(WIN32 AND USE_GETTEXT) - set(CMAKE_EXE_LINKER_FLAGS "-l${GETTEXT_LIBRARY}") - endif() - set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${RELEASE_WARNING_FLAGS} ${WARNING_FLAGS} -O3 -ffast-math -Wall -fomit-frame-pointer -pipe -funroll-loops") set(CMAKE_CXX_FLAGS_DEBUG "-g -O1 -Wall ${WARNING_FLAGS}") -- cgit v1.2.3 From aa6506ce9617d2a889f4937b525be15d8bdcb589 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Thu, 21 Jul 2011 15:12:58 +0200 Subject: Restore "Leave address blank" position --- src/guiMainMenu.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/guiMainMenu.cpp b/src/guiMainMenu.cpp index f557f4dc0..707a96e3b 100644 --- a/src/guiMainMenu.cpp +++ b/src/guiMainMenu.cpp @@ -217,6 +217,7 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) } { core::rect rect(0, 0, 400, 20); + rect += topleft_client + v2s32(160, 100+35); Environment->addStaticText(chartowchar_t(gettext("Leave address blank to start a local server.")), rect, false, true, this, -1); } { -- cgit v1.2.3 From 767280577b89503d5a0c7034fd66eae1694d0ce9 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Thu, 21 Jul 2011 15:16:59 +0200 Subject: Reorganize cmake gettext message output to ease debugging --- src/CMakeLists.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c018d8e56..8c6e1d450 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,18 +7,18 @@ endif(RUN_IN_PLACE) if(USE_GETTEXT) find_package(GettextLib REQUIRED) + message(STATUS "gettext include path: ${GETTEXT_INCLUDE_DIR}") + message(STATUS "gettext msgfmt path: ${GETTEXT_MSGFMT}") + if(WIN32) + message(STATUS "gettext library: ${GETTEXT_LIBRARY}") + message(STATUS "gettext dll: ${GETTEXT_DLL}") + message(STATUS "gettext iconv dll: ${GETTEXT_ICONV_DLL}") + endif() if (GETTEXT_FOUND) add_definitions( -DUSE_GETTEXT ) - message(STATUS "gettext include path: ${GETTEXT_INCLUDE_DIR}") - message(STATUS "gettext msgfmt path: ${GETTEXT_MSGFMT}") - if(WIN32) - message(STATUS "gettext library: ${GETTEXT_LIBRARY}") - message(STATUS "gettext dll: ${GETTEXT_DLL}") - message(STATUS "gettext iconv dll: ${GETTEXT_ICONV_DLL}") - endif() message(STATUS "GetText enabled") else() - message(ERROR "GetText enabled but not found, disabling") + message(STATUS "ERROR: GetText enabled but not found, disabling") set(USE_GETTEXT FALSE) endif(GETTEXT_FOUND) else(USE_GETTEXT) -- cgit v1.2.3 From cbf2ac5e8f3b4043b1eaeca0a3260b2c90b85be6 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Thu, 21 Jul 2011 15:40:00 +0200 Subject: * different collision box for fireflies so they now hover above the ground --- src/content_sao.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/content_sao.cpp b/src/content_sao.cpp index aeeafc2f8..0b81855c1 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -809,7 +809,7 @@ void FireflySAO::step(float dtime, bool send_recommended) Move it, with collision detection */ - core::aabbox3d box(-BS/3.,0.0,-BS/3., BS/3.,BS*2./3.,BS/3.); + core::aabbox3d box(-BS/3.,-BS*2/3.0,-BS/3., BS/3.,BS*4./3.,BS/3.); collisionMoveResult moveresult; // Maximum movement without glitches f32 pos_max_d = BS*0.25; -- cgit v1.2.3 From 8048961cc571efafe493bda2e082c27cce643414 Mon Sep 17 00:00:00 2001 From: Cyriaque Skrapits Date: Thu, 21 Jul 2011 16:09:57 +0200 Subject: Added french translation. --- src/CMakeLists.txt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 72f79976c..532ac9fee 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -257,7 +257,8 @@ if(BUILD_CLIENT) install(FILES ${images} DESTINATION ${DATADIR}) install(FILES ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-c55.mo DESTINATION locale/de/LC_MESSAGES) - + install(FILES ${CMAKE_BINARY_DIR}/locale/fr/LC_MESSAGES/minetest-c55.mo DESTINATION locale/fr/LC_MESSAGES) + if(WIN32) if(DEFINED IRRLICHT_DLL) install(FILES ${IRRLICHT_DLL} DESTINATION ${BINDIR}) @@ -285,6 +286,7 @@ else() endif() add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES COMMENT "mo-update [de]: Creating locale directory.") +add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/locale/fr/LC_MESSAGES COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/locale/fr/LC_MESSAGES COMMENT "mo-update [fr]: Creating locale directory.") add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-c55.mo @@ -295,7 +297,19 @@ add_custom_command( WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/po/de COMMENT "mo-update [de]: Creating mo file." ) +add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/locale/fr/LC_MESSAGES/minetest-c55.mo + COMMAND ${GETTEXT_MSGFMT} -o ${CMAKE_BINARY_DIR}/locale/fr/LC_MESSAGES/minetest-c55.mo ${CMAKE_SOURCE_DIR}/po/fr/minetest-c55.po + DEPENDS + ${CMAKE_BINARY_DIR}/locale/fr/LC_MESSAGES + ${CMAKE_SOURCE_DIR}/po/fr/minetest-c55.po + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/po/fr + COMMENT "mo-update [fr]: Creating mo file." + ) + add_custom_target(translation_de ALL COMMENT "mo update [de]" DEPENDS ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-c55.mo) +add_custom_target(translation_fr ALL COMMENT "mo update [fr]" DEPENDS ${CMAKE_BINARY_DIR}/locale/fr/LC_MESSAGES/minetest-c55.mo) + # Subdirectories -- cgit v1.2.3 From 2b3bc337087a7df15bbc7a745ee36e718e6d3950 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Thu, 21 Jul 2011 23:28:30 +0300 Subject: added some TODOs to main.cpp --- src/main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index 3edf79bd2..505f82fc7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -339,6 +339,12 @@ TODO: Merge bahamada's audio stuff (clean patch available) TODO: Merge key configuration menu (no clean patch available) +TODO: Add some kind of content range validation to mapnode serialization + +TODO: Make sure menu text position is fixed + +TODO: Fix sector over limits error + Making it more portable: ------------------------ -- cgit v1.2.3 From 3d53cc2c1122741df2dd4506ca5e7e188824b5c3 Mon Sep 17 00:00:00 2001 From: Constantin Wenger Date: Thu, 21 Jul 2011 16:44:43 +0200 Subject: changed some lines to fit the 80chars limit --- src/guiMainMenu.cpp | 26 +++++++++++++++++--------- src/guiMessageMenu.cpp | 3 ++- src/guiPasswordChange.cpp | 13 +++++++++---- src/guiPauseMenu.cpp | 12 ++++++++---- src/guiTextInputMenu.cpp | 3 ++- 5 files changed, 38 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/guiMainMenu.cpp b/src/guiMainMenu.cpp index 707a96e3b..1d7f224f6 100644 --- a/src/guiMainMenu.cpp +++ b/src/guiMainMenu.cpp @@ -177,7 +177,8 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) { core::rect rect(0, 0, 110, 20); rect += topleft_client + v2s32(35, 50+6); - Environment->addStaticText(chartowchar_t(gettext("Name/Password")), rect, false, true, this, -1); + Environment->addStaticText(chartowchar_t(gettext("Name/Password")), + rect, false, true, this, -1); } { core::rect rect(0, 0, 230, 30); @@ -199,7 +200,8 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) { core::rect rect(0, 0, 110, 20); rect += topleft_client + v2s32(35, 100+6); - Environment->addStaticText(chartowchar_t(gettext("Address/Port")), rect, false, true, this, -1); + Environment->addStaticText(chartowchar_t(gettext("Address/Port")), + rect, false, true, this, -1); } { core::rect rect(0, 0, 230, 30); @@ -218,13 +220,14 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) { core::rect rect(0, 0, 400, 20); rect += topleft_client + v2s32(160, 100+35); - Environment->addStaticText(chartowchar_t(gettext("Leave address blank to start a local server.")), rect, false, true, this, -1); + Environment->addStaticText(chartowchar_t(gettext("Leave address blank to start a local server.")), + rect, false, true, this, -1); } { core::rect rect(0, 0, 250, 30); rect += topleft_client + v2s32(35, 150); Environment->addCheckBox(fancy_trees, rect, this, GUI_ID_FANCYTREE_CB, - chartowchar_t(gettext("Fancy trees"))); + chartowchar_t(gettext("Fancy trees"))); } { core::rect rect(0, 0, 250, 30); @@ -237,7 +240,8 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) core::rect rect(0, 0, 180, 30); //rect += topleft_client + v2s32(size_client.X/2-180/2, 225-30/2); rect += topleft_client + v2s32(size_client.X-180-40, 150+25); - Environment->addButton(rect, this, GUI_ID_JOIN_GAME_BUTTON, chartowchar_t(gettext("Start Game / Connect"))); + Environment->addButton(rect, this, GUI_ID_JOIN_GAME_BUTTON, + chartowchar_t(gettext("Start Game / Connect"))); } // Key change button @@ -245,7 +249,8 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) core::rect rect(0, 0, 100, 30); //rect += topleft_client + v2s32(size_client.X/2-180/2, 225-30/2); rect += topleft_client + v2s32(size_client.X-180-40-100-20, 150+25); - Environment->addButton(rect, this, GUI_ID_CHANGE_KEYS_BUTTON, chartowchar_t(gettext("Change keys"))); + Environment->addButton(rect, this, GUI_ID_CHANGE_KEYS_BUTTON, + chartowchar_t(gettext("Change keys"))); } /* Server section @@ -267,19 +272,22 @@ void GUIMainMenu::regenerateGui(v2u32 screensize) { core::rect rect(0, 0, 250, 30); rect += topleft_server + v2s32(35, 30); - Environment->addCheckBox(creative_mode, rect, this, GUI_ID_CREATIVE_CB, chartowchar_t(gettext("Creative Mode"))); + Environment->addCheckBox(creative_mode, rect, this, GUI_ID_CREATIVE_CB, + chartowchar_t(gettext("Creative Mode"))); } { core::rect rect(0, 0, 250, 30); rect += topleft_server + v2s32(35, 60); - Environment->addCheckBox(enable_damage, rect, this, GUI_ID_DAMAGE_CB, chartowchar_t(gettext("Enable Damage"))); + Environment->addCheckBox(enable_damage, rect, this, GUI_ID_DAMAGE_CB, + chartowchar_t(gettext("Enable Damage"))); } // Map delete button { core::rect rect(0, 0, 130, 30); //rect += topleft_server + v2s32(size_server.X-40-130, 100+25); rect += topleft_server + v2s32(40, 100+25); - Environment->addButton(rect, this, GUI_ID_DELETE_MAP_BUTTON, chartowchar_t(gettext("Delete map"))); + Environment->addButton(rect, this, GUI_ID_DELETE_MAP_BUTTON, + chartowchar_t(gettext("Delete map"))); } } diff --git a/src/guiMessageMenu.cpp b/src/guiMessageMenu.cpp index e4e582ab1..155be6029 100644 --- a/src/guiMessageMenu.cpp +++ b/src/guiMessageMenu.cpp @@ -89,7 +89,8 @@ void GUIMessageMenu::regenerateGui(v2u32 screensize) core::rect rect(0, 0, 140, 30); rect = rect + v2s32(size.X/2-140/2, size.Y/2-30/2+25); gui::IGUIElement *e = - Environment->addButton(rect, this, 257, chartowchar_t(gettext("Proceed"))); + Environment->addButton(rect, this, 257, + chartowchar_t(gettext("Proceed"))); Environment->setFocus(e); } } diff --git a/src/guiPasswordChange.cpp b/src/guiPasswordChange.cpp index 79601a99f..fabe75110 100644 --- a/src/guiPasswordChange.cpp +++ b/src/guiPasswordChange.cpp @@ -99,7 +99,8 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize) { core::rect rect(0, 0, 110, 20); rect += topleft_client + v2s32(35, ypos+6); - Environment->addStaticText(chartowchar_t(gettext("Old Password")), rect, false, true, this, -1); + Environment->addStaticText(chartowchar_t(gettext("Old Password")), + rect, false, true, this, -1); } { core::rect rect(0, 0, 230, 30); @@ -113,7 +114,8 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize) { core::rect rect(0, 0, 110, 20); rect += topleft_client + v2s32(35, ypos+6); - Environment->addStaticText(chartowchar_t(gettext("New Password")), rect, false, true, this, -1); + Environment->addStaticText(chartowchar_t(gettext("New Password")), + rect, false, true, this, -1); } { core::rect rect(0, 0, 230, 30); @@ -126,7 +128,8 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize) { core::rect rect(0, 0, 110, 20); rect += topleft_client + v2s32(35, ypos+6); - Environment->addStaticText(chartowchar_t(gettext("Confirm Password")), rect, false, true, this, -1); + Environment->addStaticText(chartowchar_t(gettext("Confirm Password")), + rect, false, true, this, -1); } { core::rect rect(0, 0, 230, 30); @@ -148,7 +151,9 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize) core::rect rect(0, 0, 300, 20); rect += topleft_client + v2s32(35, ypos); IGUIElement *e = - Environment->addStaticText(chartowchar_t(gettext("Passwords do not match!")), rect, false, true, this, ID_message); + Environment->addStaticText( + chartowchar_t(gettext("Passwords do not match!")), + rect, false, true, this, ID_message); e->setVisible(false); } diff --git a/src/guiPauseMenu.cpp b/src/guiPauseMenu.cpp index 5f40a4820..61485518c 100644 --- a/src/guiPauseMenu.cpp +++ b/src/guiPauseMenu.cpp @@ -106,25 +106,29 @@ void GUIPauseMenu::regenerateGui(v2u32 screensize) { core::rect rect(0, 0, 140, btn_height); rect = rect + v2s32(size.X/2-140/2, btn_y); - Environment->addButton(rect, this, 256, chartowchar_t(gettext("Continue"))); + Environment->addButton(rect, this, 256, + chartowchar_t(gettext("Continue"))); } btn_y += btn_height + btn_gap; { core::rect rect(0, 0, 140, btn_height); rect = rect + v2s32(size.X/2-140/2, btn_y); - Environment->addButton(rect, this, 261, chartowchar_t(gettext("Change Password"))); + Environment->addButton(rect, this, 261, + chartowchar_t(gettext("Change Password"))); } btn_y += btn_height + btn_gap; { core::rect rect(0, 0, 140, btn_height); rect = rect + v2s32(size.X/2-140/2, btn_y); - Environment->addButton(rect, this, 260, chartowchar_t(gettext("Disconnect"))); + Environment->addButton(rect, this, 260, + chartowchar_t(gettext("Disconnect"))); } btn_y += btn_height + btn_gap; { core::rect rect(0, 0, 140, btn_height); rect = rect + v2s32(size.X/2-140/2, btn_y); - Environment->addButton(rect, this, 257, chartowchar_t(gettext("Exit to OS"))); + Environment->addButton(rect, this, 257, + chartowchar_t(gettext("Exit to OS"))); } { diff --git a/src/guiTextInputMenu.cpp b/src/guiTextInputMenu.cpp index b15f8bc07..252e452f5 100644 --- a/src/guiTextInputMenu.cpp +++ b/src/guiTextInputMenu.cpp @@ -107,7 +107,8 @@ void GUITextInputMenu::regenerateGui(v2u32 screensize) { core::rect rect(0, 0, 140, 30); rect = rect + v2s32(size.X/2-140/2, size.Y/2-30/2+25); - Environment->addButton(rect, this, 257, chartowchar_t(gettext("Proceed"))); + Environment->addButton(rect, this, 257, + chartowchar_t(gettext("Proceed"))); } } -- cgit v1.2.3 From bc05bd8b59af9cef363cebf320f65a5283b0dea6 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Fri, 22 Jul 2011 08:33:08 +0200 Subject: Use project name for mo files --- src/CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f3dee7f30..feaf0eb98 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -267,8 +267,8 @@ if(BUILD_CLIENT) install(FILES ${images} DESTINATION ${DATADIR}) if (USE_GETTEXT) - install(FILES ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-delta.mo DESTINATION locale/de/LC_MESSAGES) - install(FILES ${CMAKE_BINARY_DIR}/locale/fr/LC_MESSAGES/minetest-c55.mo DESTINATION locale/fr/LC_MESSAGES) + install(FILES ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/${PROJECT_NAME}.mo DESTINATION locale/de/LC_MESSAGES) + install(FILES ${CMAKE_BINARY_DIR}/locale/fr/LC_MESSAGES/${PROJECT_NAME}.mo DESTINATION locale/fr/LC_MESSAGES) endif() if(WIN32) @@ -298,7 +298,7 @@ if (USE_GETTEXT) add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/locale/fr/LC_MESSAGES COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/locale/fr/LC_MESSAGES COMMENT "mo-update [fr]: Creating locale directory.") add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-delta.mo + OUTPUT ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/${PROJECT_NAME}.mo COMMAND ${GETTEXT_MSGFMT} -o ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-delta.mo ${CMAKE_SOURCE_DIR}/po/de/minetest-c55.po DEPENDS ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES @@ -307,7 +307,7 @@ if (USE_GETTEXT) COMMENT "mo-update [de]: Creating mo file." ) add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/locale/fr/LC_MESSAGES/minetest-c55.mo + OUTPUT ${CMAKE_BINARY_DIR}/locale/fr/LC_MESSAGES/${PROJECT_NAME}.mo COMMAND ${GETTEXT_MSGFMT} -o ${CMAKE_BINARY_DIR}/locale/fr/LC_MESSAGES/minetest-c55.mo ${CMAKE_SOURCE_DIR}/po/fr/minetest-c55.po DEPENDS ${CMAKE_BINARY_DIR}/locale/fr/LC_MESSAGES @@ -316,8 +316,8 @@ if (USE_GETTEXT) COMMENT "mo-update [fr]: Creating mo file." ) - add_custom_target(translation_de ALL COMMENT "mo update [de]" DEPENDS ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-delta.mo) - add_custom_target(translation_fr ALL COMMENT "mo update [fr]" DEPENDS ${CMAKE_BINARY_DIR}/locale/fr/LC_MESSAGES/minetest-c55.mo) + add_custom_target(translation_de ALL COMMENT "mo update [de]" DEPENDS ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/${PROJECT_NAME}.mo) + add_custom_target(translation_fr ALL COMMENT "mo update [fr]" DEPENDS ${CMAKE_BINARY_DIR}/locale/fr/LC_MESSAGES/${PROJECT_NAME}.mo) endif(USE_GETTEXT) # Subdirectories -- cgit v1.2.3 From 0ec749317cfa36e68150dd634c2c9ffdb8027588 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Fri, 22 Jul 2011 09:36:17 +0200 Subject: Refactor mo creation/installation --- src/CMakeLists.txt | 51 ++++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index feaf0eb98..4427a1380 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,7 +16,7 @@ if(USE_GETTEXT) endif() if (GETTEXT_FOUND) add_definitions( -DUSE_GETTEXT ) - message(STATUS "GetText enabled") + message(STATUS "GetText enabled; locales found: ${GETTEXT_AVAILABLE_LOCALES}") else() message(STATUS "ERROR: GetText enabled but not found, disabling") set(USE_GETTEXT FALSE) @@ -267,8 +267,11 @@ if(BUILD_CLIENT) install(FILES ${images} DESTINATION ${DATADIR}) if (USE_GETTEXT) - install(FILES ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/${PROJECT_NAME}.mo DESTINATION locale/de/LC_MESSAGES) - install(FILES ${CMAKE_BINARY_DIR}/locale/fr/LC_MESSAGES/${PROJECT_NAME}.mo DESTINATION locale/fr/LC_MESSAGES) + foreach(LOCALE ${GETTEXT_AVAILABLE_LOCALES}) + set_mo_paths(MO_BUILD_PATH MO_DEST_PATH ${LOCALE}) + set(MO_BUILD_PATH "${MO_BUILD_PATH}/${PROJECT_NAME}.mo") + install(FILES ${MO_BUILD_PATH} DESTINATION ${MO_DEST_PATH}) + endforeach(LOCALE ${GETTEXT_AVAILABLE_LOCALES}) endif() if(WIN32) @@ -294,30 +297,28 @@ if(BUILD_SERVER) endif(BUILD_SERVER) if (USE_GETTEXT) - add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES COMMENT "mo-update [de]: Creating locale directory.") - add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/locale/fr/LC_MESSAGES COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/locale/fr/LC_MESSAGES COMMENT "mo-update [fr]: Creating locale directory.") - - add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/${PROJECT_NAME}.mo - COMMAND ${GETTEXT_MSGFMT} -o ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/minetest-delta.mo ${CMAKE_SOURCE_DIR}/po/de/minetest-c55.po - DEPENDS - ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES - ${CMAKE_SOURCE_DIR}/po/de/minetest-c55.po - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/po/de - COMMENT "mo-update [de]: Creating mo file." - ) - add_custom_command( - OUTPUT ${CMAKE_BINARY_DIR}/locale/fr/LC_MESSAGES/${PROJECT_NAME}.mo - COMMAND ${GETTEXT_MSGFMT} -o ${CMAKE_BINARY_DIR}/locale/fr/LC_MESSAGES/minetest-c55.mo ${CMAKE_SOURCE_DIR}/po/fr/minetest-c55.po - DEPENDS - ${CMAKE_BINARY_DIR}/locale/fr/LC_MESSAGES - ${CMAKE_SOURCE_DIR}/po/fr/minetest-c55.po - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/po/fr - COMMENT "mo-update [fr]: Creating mo file." + set(MO_FILES) + foreach(LOCALE ${GETTEXT_AVAILABLE_LOCALES}) + set_mo_paths(MO_BUILD_PATH MO_DEST_PATH ${LOCALE}) + add_custom_command(OUTPUT ${MO_BUILD_PATH} + COMMAND ${CMAKE_COMMAND} -E make_directory ${MO_BUILD_PATH} + COMMENT "mo-update [${LOCALE}]: Creating locale directory.") + + set(MO_FILE_PATH "${MO_BUILD_PATH}/${PROJECT_NAME}.mo") + set(PO_FILE_PATH "${GETTEXT_PO_PATH}/${LOCALE}/minetest-c55.po") + + add_custom_command( + OUTPUT ${MO_FILE_PATH} + COMMAND ${GETTEXT_MSGFMT} -o ${MO_FILE_PATH} ${PO_FILE_PATH} + DEPENDS ${MO_BUILD_PATH} ${PO_FILE_PATH} + WORKING_DIRECTORY "${GETTEXT_PO_PATH}/${LOCALE}" + COMMENT "mo-update [${LOCALE}]: Creating mo file." ) - add_custom_target(translation_de ALL COMMENT "mo update [de]" DEPENDS ${CMAKE_BINARY_DIR}/locale/de/LC_MESSAGES/${PROJECT_NAME}.mo) - add_custom_target(translation_fr ALL COMMENT "mo update [fr]" DEPENDS ${CMAKE_BINARY_DIR}/locale/fr/LC_MESSAGES/${PROJECT_NAME}.mo) + set(MO_FILES ${MO_FILES} ${MO_FILE_PATH}) + endforeach(LOCALE ${GETTEXT_AVAILABLE_LOCALES}) + + add_custom_target(translations ALL COMMENT "mo update" DEPENDS ${MO_FILES}) endif(USE_GETTEXT) # Subdirectories -- cgit v1.2.3 From 8f2409a1b41bbe32abf626b06e1b90f6cc7118c8 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Fri, 22 Jul 2011 09:58:02 +0200 Subject: Static naming of po file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The po file should not be named c55 if we're in ∆. But since it is not exposed at installation time, we don't actually need its name to be based on the project name at all, so just call it minetest.po --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4427a1380..61fb20680 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -305,7 +305,7 @@ if (USE_GETTEXT) COMMENT "mo-update [${LOCALE}]: Creating locale directory.") set(MO_FILE_PATH "${MO_BUILD_PATH}/${PROJECT_NAME}.mo") - set(PO_FILE_PATH "${GETTEXT_PO_PATH}/${LOCALE}/minetest-c55.po") + set(PO_FILE_PATH "${GETTEXT_PO_PATH}/${LOCALE}/minetest.po") add_custom_command( OUTPUT ${MO_FILE_PATH} -- cgit v1.2.3 From aaa165f985ec30e96ae9a975c9ad96d6e99f5ac7 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Fri, 22 Jul 2011 10:55:05 +0200 Subject: updatepo cmake rule Get rid of the system-specific updatelocales.sh and introduce an updatepo cmake rule. po files are also updated before creating the mo files, and we now keep the .pot file (in the po/en directory). To stabilize the po file creation, file contents are sorted by source filename. Update po files in the process. --- src/CMakeLists.txt | 58 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 61fb20680..0c4b41829 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -297,28 +297,54 @@ if(BUILD_SERVER) endif(BUILD_SERVER) if (USE_GETTEXT) + add_custom_command(OUTPUT "${GETTEXT_PO_PATH}/en" + COMMAND ${CMAKE_COMMAND} -E make_directory "${GETTEXT_PO_PATH}/en" + COMMENT "po-update [en]: creating translation template base directory") + set(POT_FILE "${GETTEXT_PO_PATH}/en/minetest.pot") + file(GLOB GETTEXT_POT_DEPS *.cpp *.h) + file(GLOB GETTEXT_POT_DEPS_REL RELATIVE ${CMAKE_SOURCE_DIR} *.cpp *.h) + add_custom_command(OUTPUT ${POT_FILE} + COMMAND ${GETTEXT_EXTRACT} -F -n -o ${POT_FILE} ${GETTEXT_POT_DEPS_REL} + DEPENDS "${GETTEXT_PO_PATH}/en" ${GETTEXT_POT_DEPS} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMENT "po-update [en]: updating translation template") + + set(PO_FILES) set(MO_FILES) + foreach(LOCALE ${GETTEXT_AVAILABLE_LOCALES}) - set_mo_paths(MO_BUILD_PATH MO_DEST_PATH ${LOCALE}) - add_custom_command(OUTPUT ${MO_BUILD_PATH} - COMMAND ${CMAKE_COMMAND} -E make_directory ${MO_BUILD_PATH} - COMMENT "mo-update [${LOCALE}]: Creating locale directory.") - - set(MO_FILE_PATH "${MO_BUILD_PATH}/${PROJECT_NAME}.mo") - set(PO_FILE_PATH "${GETTEXT_PO_PATH}/${LOCALE}/minetest.po") - - add_custom_command( - OUTPUT ${MO_FILE_PATH} - COMMAND ${GETTEXT_MSGFMT} -o ${MO_FILE_PATH} ${PO_FILE_PATH} - DEPENDS ${MO_BUILD_PATH} ${PO_FILE_PATH} - WORKING_DIRECTORY "${GETTEXT_PO_PATH}/${LOCALE}" - COMMENT "mo-update [${LOCALE}]: Creating mo file." - ) + # skip the 'en' locale which is treated separately + if (NOT LOCALE STREQUAL "en") + set(PO_FILE_PATH "${GETTEXT_PO_PATH}/${LOCALE}/minetest.po") + add_custom_command(OUTPUT ${PO_FILE_PATH} + COMMAND ${GETTEXT_MSGMERGE} -F -U ${PO_FILE_PATH} ${POT_FILE} + DEPENDS ${POT_FILE} + WORKING_DIRECTORY "${GETTEXT_PO_PATH}/${LOCALE}" + COMMENT "po-update [${LOCALE}]: updating strings") - set(MO_FILES ${MO_FILES} ${MO_FILE_PATH}) + + set_mo_paths(MO_BUILD_PATH MO_DEST_PATH ${LOCALE}) + add_custom_command(OUTPUT ${MO_BUILD_PATH} + COMMAND ${CMAKE_COMMAND} -E make_directory ${MO_BUILD_PATH} + COMMENT "mo-update [${LOCALE}]: Creating locale directory.") + + set(MO_FILE_PATH "${MO_BUILD_PATH}/${PROJECT_NAME}.mo") + + add_custom_command( + OUTPUT ${MO_FILE_PATH} + COMMAND ${GETTEXT_MSGFMT} -o ${MO_FILE_PATH} ${PO_FILE_PATH} + DEPENDS ${MO_BUILD_PATH} ${PO_FILE_PATH} + WORKING_DIRECTORY "${GETTEXT_PO_PATH}/${LOCALE}" + COMMENT "mo-update [${LOCALE}]: Creating mo file." + ) + + set(MO_FILES ${MO_FILES} ${MO_FILE_PATH}) + set(PO_FILES ${PO_FILES} ${PO_FILE_PATH}) + endif(NOT LOCALE STREQUAL "en") endforeach(LOCALE ${GETTEXT_AVAILABLE_LOCALES}) add_custom_target(translations ALL COMMENT "mo update" DEPENDS ${MO_FILES}) + add_custom_target(updatepo COMMENT "po update" DEPENDS ${PO_FILES}) endif(USE_GETTEXT) # Subdirectories -- cgit v1.2.3 From bf3dfec7d6d171c5c83142319067153f2637b0a8 Mon Sep 17 00:00:00 2001 From: Constantin Wenger Date: Fri, 22 Jul 2011 12:54:07 +0200 Subject: fixed problem with displaying special chars --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.cpp b/src/main.cpp index b6a53566e..a7634a3c1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1132,7 +1132,7 @@ int main(int argc, char *argv[]) // Create user data directory fs::CreateDir(porting::path_userdata); - setlocale(LC_ALL, ""); + setlocale(LC_MESSAGES, ""); bindtextdomain("minetest-c55", (porting::path_userdata+"/locale").c_str()); textdomain("minetest-c55"); -- cgit v1.2.3 From 965352287391eb46695546efce3e26a2e576a340 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Fri, 22 Jul 2011 14:42:04 +0200 Subject: Declare USE_GETTEXT option --- src/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0c4b41829..dc9dc03a6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,6 +5,8 @@ if(RUN_IN_PLACE) add_definitions ( -DRUN_IN_PLACE ) endif(RUN_IN_PLACE) +OPTION(USE_GETTEXT "Use GetText for internationalization" OFF) + if(USE_GETTEXT) find_package(GettextLib REQUIRED) message(STATUS "gettext include path: ${GETTEXT_INCLUDE_DIR}") -- cgit v1.2.3 From a12229f27148b9aec64c0fdeb1d739ad2062ac93 Mon Sep 17 00:00:00 2001 From: Constantin Wenger Date: Fri, 22 Jul 2011 20:19:43 +0200 Subject: fixed some problems with filenames of the translations --- src/CMakeLists.txt | 2 +- src/main.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dc9dc03a6..c93762cab 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -330,7 +330,7 @@ if (USE_GETTEXT) COMMAND ${CMAKE_COMMAND} -E make_directory ${MO_BUILD_PATH} COMMENT "mo-update [${LOCALE}]: Creating locale directory.") - set(MO_FILE_PATH "${MO_BUILD_PATH}/${PROJECT_NAME}.mo") + set(MO_FILE_PATH "${MO_BUILD_PATH}/minetest.mo") add_custom_command( OUTPUT ${MO_FILE_PATH} diff --git a/src/main.cpp b/src/main.cpp index a7634a3c1..b94d0c361 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1133,8 +1133,8 @@ int main(int argc, char *argv[]) fs::CreateDir(porting::path_userdata); setlocale(LC_MESSAGES, ""); - bindtextdomain("minetest-c55", (porting::path_userdata+"/locale").c_str()); - textdomain("minetest-c55"); + bindtextdomain("minetest", (porting::path_userdata+"/locale").c_str()); + textdomain("minetest"); // Initialize debug streams #ifdef RUN_IN_PLACE -- cgit v1.2.3 From 6c2d95f8686a7c08ed8648aa111accef50f58f73 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Fri, 22 Jul 2011 21:53:50 +0200 Subject: * key change menu now saving immediately --- src/guiKeyChangeMenu.cpp | 2 +- src/keycode.h | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/guiKeyChangeMenu.cpp b/src/guiKeyChangeMenu.cpp index 3e594aeca..4a11cf93c 100644 --- a/src/guiKeyChangeMenu.cpp +++ b/src/guiKeyChangeMenu.cpp @@ -338,7 +338,7 @@ bool GUIKeyChangeMenu::acceptInput() g_settings.set("keymap_fastmove", keycode_to_keyname(key_fast)); g_settings.set("keymap_special1", keycode_to_keyname(key_use)); g_settings.set("keymap_print_debug_stacks", keycode_to_keyname(key_dump)); - //clearKeyCache(); Y U NO SCOPE?! + clearKeyCache(); return true; } void GUIKeyChangeMenu::init_keys() diff --git a/src/keycode.h b/src/keycode.h index 9c62004d8..300682b12 100644 --- a/src/keycode.h +++ b/src/keycode.h @@ -24,11 +24,13 @@ with this program; if not, write to the Free Software Foundation, Inc., #include irr::EKEY_CODE keyname_to_keycode(const char *name); +std::string keycode_to_keyname(s32 keycode); // Key configuration getter irr::EKEY_CODE getKeySetting(const char *settingname); -std::string keycode_to_keyname(s32 keycode); -void clearCache(); + +// Clear fast lookup cache +void clearKeyCache(); #endif -- cgit v1.2.3 From 976ec31c1faedc3a34935c3aafd6a868e222d1ad Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 23 Jul 2011 16:46:34 +0300 Subject: switched to old transformLiquids, new one is not ready --- src/map.cpp | 423 +++++++++++++++++++++++++++++++----------------------------- 1 file changed, 216 insertions(+), 207 deletions(-) (limited to 'src') diff --git a/src/map.cpp b/src/map.cpp index e1769b8ef..ab4acd4d5 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1540,17 +1540,6 @@ void Map::PrintInfo(std::ostream &out) #define WATER_DROP_BOOST 4 -enum NeighborType { - NEIGHBOR_UPPER, - NEIGHBOR_SAME_LEVEL, - NEIGHBOR_LOWER -}; -struct NodeNeighbor { - MapNode n; - NeighborType t; - v3s16 p; -}; - void Map::transformLiquids(core::map & modified_blocks) { DSTACK(__FUNCTION_NAME); @@ -1570,220 +1559,240 @@ void Map::transformLiquids(core::map & modified_blocks) v3s16 p0 = m_transforming_liquid.pop_front(); MapNode n0 = getNodeNoEx(p0); - - /* - Collect information about current node - */ - s8 liquid_level = -1; - u8 liquid_kind = CONTENT_IGNORE; - LiquidType liquid_type = content_features(n0.d).liquid_type; - switch (liquid_type) { - case LIQUID_SOURCE: - liquid_level = 8; - liquid_kind = content_features(n0.d).liquid_alternative_flowing; - break; - case LIQUID_FLOWING: - liquid_level = (n0.param2 & LIQUID_LEVEL_MASK); - liquid_kind = n0.d; - break; - case LIQUID_NONE: - // if this is an air node, it *could* be transformed into a liquid. otherwise, - // continue with the next node. - if (n0.d != CONTENT_AIR) - continue; - liquid_kind = CONTENT_AIR; - break; - } - + + // Don't deal with non-liquids + if(content_liquid(n0.d) == false) + continue; + + bool is_source = !content_flowing_liquid(n0.d); + + u8 liquid_level = 8; + if(is_source == false) + liquid_level = n0.param2 & 0x0f; + + // Turn possible source into non-source + u8 nonsource_c = make_liquid_flowing(n0.d); + /* - Collect information about the environment - */ - v3s16 dirs[6] = { - v3s16( 0, 1, 0), // top - v3s16( 0,-1, 0), // bottom - v3s16( 1, 0, 0), // right - v3s16(-1, 0, 0), // left - v3s16( 0, 0, 1), // back - v3s16( 0, 0,-1), // front - }; - NodeNeighbor sources[6]; // surrounding sources - int num_sources = 0; - NodeNeighbor flows[6]; // surrounding flowing liquid nodes - int num_flows = 0; - NodeNeighbor airs[6]; // surrounding air - int num_airs = 0; - NodeNeighbor neutrals[6]; // nodes that are solid or another kind of liquid - int num_neutrals = 0; - bool flowing_down = false; - for (u16 i = 0; i < 6; i++) { - NeighborType nt = NEIGHBOR_SAME_LEVEL; - switch (i) { - case 0: - nt = NEIGHBOR_UPPER; - break; - case 1: - nt = NEIGHBOR_LOWER; - break; - } - v3s16 npos = p0 + dirs[i]; - NodeNeighbor nb = {getNodeNoEx(npos), nt, npos}; - switch (content_features(nb.n.d).liquid_type) { - case LIQUID_NONE: - if (nb.n.d == CONTENT_AIR) { - airs[num_airs++] = nb; - // if the current node happens to be a flowing node, it will start to flow down here. - if (nb.t == NEIGHBOR_LOWER) - flowing_down = true; - } else { - neutrals[num_neutrals++] = nb; + If not source, check that some node flows into this one + and what is the level of liquid in this one + */ + if(is_source == false) + { + s8 new_liquid_level_max = -1; + + v3s16 dirs_from[5] = { + v3s16(0,1,0), // top + v3s16(0,0,1), // back + v3s16(1,0,0), // right + v3s16(0,0,-1), // front + v3s16(-1,0,0), // left + }; + for(u16 i=0; i<5; i++) + { + bool from_top = (i==0); + + v3s16 p2 = p0 + dirs_from[i]; + MapNode n2 = getNodeNoEx(p2); + + if(content_liquid(n2.d)) + { + u8 n2_nonsource_c = make_liquid_flowing(n2.d); + // Check that the liquids are the same type + if(n2_nonsource_c != nonsource_c) + { + dstream<<"WARNING: Not handling: different liquids" + " collide"<= 7 - WATER_DROP_BOOST) + new_liquid_level = 7; + else + new_liquid_level = n2_liquid_level + WATER_DROP_BOOST; } - break; - case LIQUID_FLOWING: - // if this node is not (yet) of a liquid type, choose the first liquid type we encounter - if (liquid_kind == CONTENT_AIR) - liquid_kind = content_features(nb.n.d).liquid_alternative_flowing; - if (content_features(nb.n.d).liquid_alternative_flowing != liquid_kind) { - neutrals[num_neutrals++] = nb; - } else { - flows[num_flows++] = nb; - if (nb.t == NEIGHBOR_LOWER) - flowing_down = true; + else if(n2_liquid_level > 0) + { + new_liquid_level = n2_liquid_level - 1; } - break; - } - } - - /* - decide on the type (and possibly level) of the current node - */ - u8 new_node_content; - s8 new_node_level = -1; - if (num_sources >= 2 || liquid_type == LIQUID_SOURCE) { - // liquid_kind will be set to either the flowing alternative of the node (if it's a liquid) - // or the flowing alternative of the first of the surrounding sources (if it's air), so - // it's perfectly safe to use liquid_kind here to determine the new node content. - new_node_content = content_features(liquid_kind).liquid_alternative_source; - } else if (num_sources == 1 && sources[0].t != NEIGHBOR_LOWER) { - // liquid_kind is set properly, see above - new_node_content = liquid_kind; - new_node_level = 7; - } else { - // no surrounding sources, so get the maximum level that can flow into this node - for (u16 i = 0; i < num_flows; i++) { - u8 nb_liquid_level = (flows[i].n.param2 & LIQUID_LEVEL_MASK); - switch (flows[i].t) { - case NEIGHBOR_UPPER: - if (nb_liquid_level + WATER_DROP_BOOST > new_node_level) { - new_node_level = 7; - if (nb_liquid_level + WATER_DROP_BOOST < 7) - new_node_level = nb_liquid_level + WATER_DROP_BOOST; - } - break; - case NEIGHBOR_LOWER: - break; - case NEIGHBOR_SAME_LEVEL: - if ((flows[i].n.param2 & LIQUID_FLOW_DOWN_MASK) != LIQUID_FLOW_DOWN_MASK && - nb_liquid_level > 0 && nb_liquid_level - 1 > new_node_level) { - new_node_level = nb_liquid_level - 1; - } - break; + + if(new_liquid_level > new_liquid_level_max) + new_liquid_level_max = new_liquid_level; } - } - // don't flow as far in open terrain - if there isn't at least one adjacent solid block, - // substract another unit from the resulting water level. - if (!flowing_down && new_node_level >= 1) { - bool at_wall = false; - for (u16 i = 0; i < num_neutrals; i++) { - if (neutrals[i].t == NEIGHBOR_SAME_LEVEL) { - at_wall = true; - break; + } //for + + /* + If liquid level should be something else, update it and + add all the neighboring water nodes to the transform queue. + */ + if(new_liquid_level_max != liquid_level) + { + if(new_liquid_level_max == -1) + { + // Remove water alltoghether + n0.d = CONTENT_AIR; + n0.param2 = 0; + setNode(p0, n0); + } + else + { + n0.param2 = new_liquid_level_max; + setNode(p0, n0); + } + + // Block has been modified + { + v3s16 blockpos = getNodeBlockPos(p0); + MapBlock *block = getBlockNoCreateNoEx(blockpos); + if(block != NULL) + modified_blocks.insert(blockpos, block); + } + + /* + Add neighboring non-source liquid nodes to transform queue. + */ + v3s16 dirs[6] = { + v3s16(0,0,1), // back + v3s16(0,1,0), // top + v3s16(1,0,0), // right + v3s16(0,0,-1), // front + v3s16(0,-1,0), // bottom + v3s16(-1,0,0), // left + }; + for(u16 i=0; i<6; i++) + { + v3s16 p2 = p0 + dirs[i]; + + MapNode n2 = getNodeNoEx(p2); + if(content_flowing_liquid(n2.d)) + { + m_transforming_liquid.push_back(p2); } } - if (!at_wall) - new_node_level -= 1; } - - if (new_node_level >= 0) - new_node_content = liquid_kind; - else - new_node_content = CONTENT_AIR; } - - /* - check if anything has changed. if not, just continue with the next node. - */ - if (new_node_content == n0.d && (content_features(n0.d).liquid_type != LIQUID_FLOWING || - ((n0.param2 & LIQUID_LEVEL_MASK) == (u8)new_node_level && - ((n0.param2 & LIQUID_FLOW_DOWN_MASK) == LIQUID_FLOW_DOWN_MASK) - == flowing_down))) + + // Get a new one from queue if the node has turned into non-water + if(content_liquid(n0.d) == false) continue; - - - /* - update the current node - */ - bool flow_down_enabled = (flowing_down && ((n0.param2 & LIQUID_FLOW_DOWN_MASK) != LIQUID_FLOW_DOWN_MASK)); - n0.d = new_node_content; - if (content_features(n0.d).liquid_type == LIQUID_FLOWING) { - // set level to last 3 bits, flowing down bit to 4th bit - n0.param2 = (flowing_down ? LIQUID_FLOW_DOWN_MASK : 0x00) | (new_node_level & LIQUID_LEVEL_MASK); - } else { - n0.param2 = 0; - } - setNode(p0, n0); - v3s16 blockpos = getNodeBlockPos(p0); - MapBlock *block = getBlockNoCreateNoEx(blockpos); - if(block != NULL) - modified_blocks.insert(blockpos, block); - + /* - enqueue neighbors for update if neccessary - */ - switch (content_features(n0.d).liquid_type) { - case LIQUID_SOURCE: - // make sure source flows into all neighboring nodes - for (u16 i = 0; i < num_flows; i++) - if (flows[i].t != NEIGHBOR_UPPER) - m_transforming_liquid.push_back(flows[i].p); - for (u16 i = 0; i < num_airs; i++) - if (airs[i].t != NEIGHBOR_UPPER) - m_transforming_liquid.push_back(airs[i].p); - break; - case LIQUID_NONE: - // this flow has turned to air; neighboring flows might need to do the same - for (u16 i = 0; i < num_flows; i++) - m_transforming_liquid.push_back(flows[i].p); - break; - case LIQUID_FLOWING: - for (u16 i = 0; i < num_flows; i++) { - u8 flow_level = (flows[i].n.param2 & LIQUID_LEVEL_MASK); - // liquid_level is still the ORIGINAL level of this node. - if (flows[i].t != NEIGHBOR_UPPER && ((flow_level < liquid_level || flow_level < new_node_level) || - flow_down_enabled)) - m_transforming_liquid.push_back(flows[i].p); + Flow water from this node + */ + v3s16 dirs_to[5] = { + v3s16(0,-1,0), // bottom + v3s16(0,0,1), // back + v3s16(1,0,0), // right + v3s16(0,0,-1), // front + v3s16(-1,0,0), // left + }; + for(u16 i=0; i<5; i++) + { + bool to_bottom = (i == 0); + + // If liquid is at lowest possible height, it's not going + // anywhere except down + if(liquid_level == 0 && to_bottom == false) + continue; + + u8 liquid_next_level = 0; + // If going to bottom + if(to_bottom) + { + //liquid_next_level = 7; + if(liquid_level >= 7 - WATER_DROP_BOOST) + liquid_next_level = 7; + else + liquid_next_level = liquid_level + WATER_DROP_BOOST; + } + else + liquid_next_level = liquid_level - 1; + + bool n2_changed = false; + bool flowed = false; + + v3s16 p2 = p0 + dirs_to[i]; + + MapNode n2 = getNodeNoEx(p2); + //dstream<<"[1] n2.param="<<(int)n2.param< 0)) - m_transforming_liquid.push_back(airs[i].p); + + if(n2_is_source) + { + // Just flow into the source, nothing changes. + // n2_changed is not set because destination didn't change + flowed = true; + } + else + { + if(liquid_next_level > liquid_level) + { + n2.param2 = liquid_next_level; + setNode(p2, n2); + + n2_changed = true; + flowed = true; + } } + } + else if(n2.d == CONTENT_AIR) + { + n2.d = nonsource_c; + n2.param2 = liquid_next_level; + setNode(p2, n2); + + n2_changed = true; + flowed = true; + } + + //dstream<<"[2] n2.param="<<(int)n2.param<= 100000) - if(loopcount >= initial_size * 10) { + if(loopcount >= initial_size * 1) break; - } } //dstream<<"Map::transformLiquids(): loopcount="<