mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-01 17:38:41 +00:00
merged the content type extension and delta
This commit is contained in:
commit
2587bb361c
69 changed files with 3756 additions and 159 deletions
|
@ -1,10 +1,32 @@
|
|||
project(minetest)
|
||||
project(minetest-delta)
|
||||
cmake_minimum_required( VERSION 2.6 )
|
||||
|
||||
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}")
|
||||
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 enabled; locales found: ${GETTEXT_AVAILABLE_LOCALES}")
|
||||
else()
|
||||
message(STATUS "ERROR: GetText enabled but not found, disabling")
|
||||
set(USE_GETTEXT FALSE)
|
||||
endif(GETTEXT_FOUND)
|
||||
else(USE_GETTEXT)
|
||||
message(STATUS "GetText disabled")
|
||||
endif(USE_GETTEXT)
|
||||
|
||||
if(NOT MSVC)
|
||||
set(USE_GPROF 0 CACHE BOOL "Use -pg flag for g++")
|
||||
endif()
|
||||
|
@ -27,6 +49,8 @@ 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(IRRLICHT_SOURCE_DIR "${PROJECT_SOURCE_DIR}/../../irrlicht-1.7.2"
|
||||
CACHE PATH "irrlicht dir")
|
||||
else()
|
||||
# Unix probably
|
||||
if(BUILD_CLIENT)
|
||||
|
@ -55,6 +79,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"
|
||||
|
@ -110,6 +137,7 @@ set(minetest_SRCS
|
|||
clouds.cpp
|
||||
clientobject.cpp
|
||||
guiMainMenu.cpp
|
||||
guiKeyChangeMenu.cpp
|
||||
guiMessageMenu.cpp
|
||||
guiTextInputMenu.cpp
|
||||
guiInventoryMenu.cpp
|
||||
|
@ -133,16 +161,17 @@ include_directories(
|
|||
${ZLIB_INCLUDE_DIR}
|
||||
${CMAKE_BUILD_TYPE}
|
||||
${PNG_INCLUDE_DIR}
|
||||
"${PROJECT_SOURCE_DIR}/jthread"
|
||||
"${PROJECT_SOURCE_DIR}/sqlite"
|
||||
${GETTEXT_INCLUDE_DIR}
|
||||
${JTHREAD_INCLUDE_DIR}
|
||||
${SQLITE3_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
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}
|
||||
|
@ -150,21 +179,22 @@ if(BUILD_CLIENT)
|
|||
${BZIP2_LIBRARIES}
|
||||
${PNG_LIBRARIES}
|
||||
${X11_LIBRARIES}
|
||||
${GETTEXT_LIBRARY}
|
||||
${PLATFORM_LIBS}
|
||||
${CLIENT_PLATFORM_LIBS}
|
||||
jthread
|
||||
sqlite3
|
||||
${JTHREAD_LIBRARY}
|
||||
${SQLITE3_LIBRARY}
|
||||
)
|
||||
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
|
||||
sqlite3
|
||||
${JTHREAD_LIBRARY}
|
||||
${SQLITE3_LIBRARY}
|
||||
)
|
||||
endif(BUILD_SERVER)
|
||||
|
||||
|
@ -185,7 +215,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)
|
||||
|
||||
|
@ -215,7 +245,7 @@ else()
|
|||
endif()
|
||||
|
||||
if(BUILD_SERVER)
|
||||
set_target_properties(minetestserver PROPERTIES
|
||||
set_target_properties(${PROJECT_NAME}server PROPERTIES
|
||||
COMPILE_DEFINITIONS "SERVER")
|
||||
endif(BUILD_SERVER)
|
||||
|
||||
|
@ -232,12 +262,20 @@ 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})
|
||||
|
||||
if (USE_GETTEXT)
|
||||
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)
|
||||
if(DEFINED IRRLICHT_DLL)
|
||||
install(FILES ${IRRLICHT_DLL} DESTINATION ${BINDIR})
|
||||
|
@ -245,16 +283,82 @@ if(BUILD_CLIENT)
|
|||
if(DEFINED ZLIB_DLL)
|
||||
install(FILES ${ZLIB_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)
|
||||
|
||||
if(BUILD_SERVER)
|
||||
install(TARGETS minetestserver DESTINATION ${BINDIR})
|
||||
install(TARGETS ${PROJECT_NAME}server DESTINATION ${BINDIR})
|
||||
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})
|
||||
# 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_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}/minetest.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
|
||||
|
||||
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
|
||||
|
|
|
@ -5,7 +5,7 @@ Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
|
|||
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
|
||||
MeshUpdateQueue::(at your option) any later version.
|
||||
(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
|
||||
|
@ -328,7 +328,8 @@ void Client::step(float dtime)
|
|||
|
||||
core::list<v3s16> deleted_blocks;
|
||||
|
||||
g_settings.getFloat("client_unload_unused_data_timeout");
|
||||
float delete_unused_sectors_timeout =
|
||||
g_settings.getFloat("client_delete_unused_sectors_timeout");
|
||||
|
||||
// Delete sector blocks
|
||||
/*u32 num = m_env.getMap().unloadUnusedData
|
||||
|
|
|
@ -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,24 +123,88 @@ 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;
|
||||
|
||||
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::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(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_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)
|
||||
};
|
||||
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 = 8*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
|
||||
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;
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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; j<mc; j++)
|
||||
{
|
||||
scene::IMeshBuffer *buf = mesh->getMeshBuffer(j);
|
||||
video::S3DVertex *vertices = (video::S3DVertex*)buf->getVertices();
|
||||
u16 vc = buf->getVertexCount();
|
||||
for(u16 i=0; i<vc; i++)
|
||||
{
|
||||
vertices[i].Color = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
v3s16 FireflyCAO::getLightPosition()
|
||||
{
|
||||
return floatToInt(m_position+v3f(0,BS*0.5,0), BS);
|
||||
}
|
||||
|
||||
void FireflyCAO::updateNodePos()
|
||||
{
|
||||
if(m_node == NULL)
|
||||
return;
|
||||
|
||||
//m_node->setPosition(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"<<std::endl;
|
||||
std::istringstream is(data, std::ios::binary);
|
||||
// command
|
||||
u8 cmd = readU8(is);
|
||||
if(cmd == 0)
|
||||
{
|
||||
// pos
|
||||
m_position = readV3F1000(is);
|
||||
pos_translator.update(m_position);
|
||||
// yaw
|
||||
m_yaw = readF1000(is);
|
||||
updateNodePos();
|
||||
}
|
||||
}
|
||||
|
||||
void FireflyCAO::initialize(const std::string &data)
|
||||
{
|
||||
//dstream<<"FireflyCAO: Got init data"<<std::endl;
|
||||
|
||||
{
|
||||
std::istringstream is(data, std::ios::binary);
|
||||
// version
|
||||
u8 version = readU8(is);
|
||||
// check version
|
||||
if(version != 0)
|
||||
return;
|
||||
// pos
|
||||
m_position = readV3F1000(is);
|
||||
pos_translator.init(m_position);
|
||||
}
|
||||
|
||||
updateNodePos();
|
||||
}
|
||||
|
|
|
@ -243,6 +243,48 @@ private:
|
|||
bool m_damage_texture_enabled;
|
||||
};
|
||||
|
||||
/*
|
||||
FireflyCAO
|
||||
*/
|
||||
|
||||
class FireflyCAO : public ClientActiveObject
|
||||
{
|
||||
public:
|
||||
FireflyCAO();
|
||||
virtual ~FireflyCAO();
|
||||
|
||||
u8 getType() const
|
||||
{
|
||||
return ACTIVEOBJECT_TYPE_FIREFLY;
|
||||
}
|
||||
|
||||
static ClientActiveObject* create();
|
||||
|
||||
void addToScene(scene::ISceneManager *smgr);
|
||||
void removeFromScene();
|
||||
void updateLight(u8 light_at_pos);
|
||||
v3s16 getLightPosition();
|
||||
void updateNodePos();
|
||||
|
||||
void step(float dtime, ClientEnvironment *env);
|
||||
|
||||
void processMessage(const std::string &data);
|
||||
|
||||
void initialize(const std::string &data);
|
||||
|
||||
core::aabbox3d<f32>* getSelectionBox()
|
||||
{return &m_selection_box;}
|
||||
v3f getPosition()
|
||||
{return m_position;}
|
||||
|
||||
private:
|
||||
core::aabbox3d<f32> m_selection_box;
|
||||
scene::IMeshSceneNode *m_node;
|
||||
v3f m_position;
|
||||
float m_yaw;
|
||||
SmoothTranslator pos_translator;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -262,6 +262,24 @@ InventoryItem *craft_get_result(InventoryItem **items)
|
|||
}
|
||||
}
|
||||
|
||||
// Rail
|
||||
{
|
||||
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))
|
||||
{
|
||||
return new MaterialItem(CONTENT_RAIL, 15);
|
||||
}
|
||||
}
|
||||
|
||||
// Chest
|
||||
{
|
||||
ItemSpec specs[9];
|
||||
|
@ -314,6 +332,87 @@ InventoryItem *craft_get_result(InventoryItem **items)
|
|||
}
|
||||
}
|
||||
|
||||
// Sandstone
|
||||
{
|
||||
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))
|
||||
{
|
||||
return new MaterialItem(CONTENT_SANDSTONE, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Clay
|
||||
{
|
||||
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))
|
||||
{
|
||||
return new MaterialItem(CONTENT_CLAY, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Brick
|
||||
{
|
||||
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))
|
||||
{
|
||||
return new MaterialItem(CONTENT_BRICK, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Paper
|
||||
{
|
||||
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))
|
||||
{
|
||||
return new CraftItem("paper", 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Book
|
||||
{
|
||||
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))
|
||||
{
|
||||
return new CraftItem("book", 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Book shelf
|
||||
{
|
||||
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))
|
||||
{
|
||||
return new MaterialItem(CONTENT_BOOKSHELF, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -354,10 +453,17 @@ void craft_set_creative_inventory(Player *player)
|
|||
CONTENT_MUD,
|
||||
CONTENT_STONE,
|
||||
CONTENT_SAND,
|
||||
CONTENT_SANDSTONE,
|
||||
CONTENT_CLAY,
|
||||
CONTENT_BRICK,
|
||||
CONTENT_TREE,
|
||||
CONTENT_LEAVES,
|
||||
CONTENT_CACTUS,
|
||||
CONTENT_PAPYRUS,
|
||||
CONTENT_BOOKSHELF,
|
||||
CONTENT_GLASS,
|
||||
CONTENT_FENCE,
|
||||
CONTENT_RAIL,
|
||||
CONTENT_MESE,
|
||||
CONTENT_WATERSOURCE,
|
||||
CONTENT_CLOUD,
|
||||
|
|
|
@ -49,14 +49,24 @@ std::string item_craft_get_image_name(const std::string &subname)
|
|||
{
|
||||
if(subname == "Stick")
|
||||
return "stick.png";
|
||||
else if(subname == "paper")
|
||||
return "paper.png";
|
||||
else if(subname == "book")
|
||||
return "book.png";
|
||||
else if(subname == "lump_of_coal")
|
||||
return "lump_of_coal.png";
|
||||
else if(subname == "lump_of_iron")
|
||||
return "lump_of_iron.png";
|
||||
else if(subname == "lump_of_clay")
|
||||
return "lump_of_clay.png";
|
||||
else if(subname == "steel_ingot")
|
||||
return "steel_ingot.png";
|
||||
else if(subname == "clay_brick")
|
||||
return "clay_brick.png";
|
||||
else if(subname == "rat")
|
||||
return "rat.png";
|
||||
else if(subname == "firefly")
|
||||
return "firefly.png";
|
||||
else
|
||||
return "cloud.png"; // just something
|
||||
}
|
||||
|
@ -69,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;
|
||||
|
@ -83,7 +98,7 @@ s16 item_craft_get_drop_count(const std::string &subname)
|
|||
|
||||
bool item_craft_is_cookable(const std::string &subname)
|
||||
{
|
||||
if(subname == "lump_of_iron")
|
||||
if(subname == "lump_of_iron" || subname == "lump_of_clay")
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
@ -93,6 +108,8 @@ InventoryItem* item_craft_create_cook_result(const std::string &subname)
|
|||
{
|
||||
if(subname == "lump_of_iron")
|
||||
return new CraftItem("steel_ingot", 1);
|
||||
else if(subname == "lump_of_clay")
|
||||
return new CraftItem("clay_brick", 1);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -188,6 +188,16 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
|||
material_general.setFlag(video::EMF_FOG_ENABLE, true);
|
||||
material_general.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
|
||||
|
||||
|
||||
// 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; z<MAP_BLOCKSIZE; z++)
|
||||
for(s16 y=0; y<MAP_BLOCKSIZE; y++)
|
||||
for(s16 x=0; x<MAP_BLOCKSIZE; x++)
|
||||
|
@ -895,15 +905,6 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
|||
vertices[i].Pos.rotateXZBy(90);
|
||||
}
|
||||
else if(j == 4)
|
||||
{
|
||||
for(u16 i=0; i<4; i++)
|
||||
vertices[i].Pos.rotateYZBy(-90);
|
||||
}
|
||||
else if(j == 5)
|
||||
{
|
||||
for(u16 i=0; i<4; i++)
|
||||
vertices[i].Pos.rotateYZBy(90);
|
||||
}
|
||||
|
||||
for(u16 i=0; i<4; i++)
|
||||
{
|
||||
|
@ -916,7 +917,160 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
|
|||
}
|
||||
}
|
||||
#endif
|
||||
else if(n.getContent() == CONTENT_PAPYRUS)
|
||||
{
|
||||
u8 l = decode_light(undiminish_light(n.getLightBlend(data->m_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);
|
||||
}
|
||||
}
|
||||
else if(n.getContent() == 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.getContent() == CONTENT_RAIL)
|
||||
is_rail_x[0] = true;
|
||||
if(n_plus_x.getContent() == CONTENT_RAIL)
|
||||
is_rail_x[1] = true;
|
||||
if(n_minus_z.getContent() == CONTENT_RAIL)
|
||||
is_rail_z[0] = true;
|
||||
if(n_plus_z.getContent() == 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -47,6 +47,12 @@ content_t trans_table_19[][2] = {
|
|||
{CONTENT_GLASS, 20},
|
||||
{CONTENT_MOSSYCOBBLE, 22},
|
||||
{CONTENT_GRAVEL, 23},
|
||||
{CONTENT_SANDSTONE, 24},
|
||||
{CONTENT_CACTUS, 25},
|
||||
{CONTENT_BRICK, 26},
|
||||
{CONTENT_CLAY, 27},
|
||||
{CONTENT_PAPYRUS, 28},
|
||||
{CONTENT_BOOKSHELF, 29},
|
||||
};
|
||||
|
||||
MapNode mapnode_translate_from_internal(MapNode n_from, u8 version)
|
||||
|
@ -152,6 +158,33 @@ void content_mapnode_init()
|
|||
f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
|
||||
setDirtLikeDiggingProperties(f->digging_properties, 1.75);
|
||||
|
||||
i = CONTENT_SANDSTONE;
|
||||
f = &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";
|
||||
setDirtLikeDiggingProperties(f->digging_properties, 1.0);
|
||||
|
||||
i = CONTENT_CLAY;
|
||||
f = &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");
|
||||
setDirtLikeDiggingProperties(f->digging_properties, 1.0);
|
||||
|
||||
i = CONTENT_BRICK;
|
||||
f = &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("CraftItem clay_brick 4");
|
||||
setStoneLikeDiggingProperties(f->digging_properties, 1.0);
|
||||
|
||||
i = CONTENT_TREE;
|
||||
f = &content_features(i);
|
||||
f->setAllTextures("tree.png");
|
||||
|
@ -180,6 +213,40 @@ void content_mapnode_init()
|
|||
f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";
|
||||
setWoodLikeDiggingProperties(f->digging_properties, 0.15);
|
||||
|
||||
i = CONTENT_CACTUS;
|
||||
f = &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";
|
||||
setWoodLikeDiggingProperties(f->digging_properties, 0.75);
|
||||
|
||||
i = CONTENT_PAPYRUS;
|
||||
f = &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;
|
||||
setWoodLikeDiggingProperties(f->digging_properties, 0.25);
|
||||
|
||||
i = CONTENT_BOOKSHELF;
|
||||
f = &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;
|
||||
setWoodLikeDiggingProperties(f->digging_properties, 0.75);
|
||||
|
||||
i = CONTENT_GLASS;
|
||||
f = &content_features(i);
|
||||
f->light_propagates = true;
|
||||
|
@ -201,6 +268,18 @@ void content_mapnode_init()
|
|||
f->setInventoryTexture("item_fence.png");
|
||||
setWoodLikeDiggingProperties(f->digging_properties, 0.75);
|
||||
|
||||
i = CONTENT_RAIL;
|
||||
f = &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;
|
||||
setDirtLikeDiggingProperties(f->digging_properties, 0.75);
|
||||
|
||||
// Deprecated
|
||||
i = CONTENT_COALSTONE;
|
||||
f = &content_features(i);
|
||||
|
@ -255,6 +334,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);
|
||||
|
@ -286,6 +366,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);
|
||||
|
|
|
@ -34,7 +34,7 @@ MapNode mapnode_translate_to_internal(MapNode n_from, u8 version);
|
|||
|
||||
// 0x000...0x07f (0...127): param2 is fully usable
|
||||
// 126 and 127 are reserved.
|
||||
// Use these sparingly, only when the extra space in param2 is needed.
|
||||
// Use these sparingly, only when the extra space in param2 might be needed.
|
||||
#define CONTENT_STONE 0
|
||||
#define CONTENT_WATER 2
|
||||
#define CONTENT_TORCH 3
|
||||
|
@ -42,10 +42,10 @@ MapNode mapnode_translate_to_internal(MapNode n_from, u8 version);
|
|||
#define CONTENT_SIGN_WALL 14
|
||||
#define CONTENT_CHEST 15
|
||||
#define CONTENT_FURNACE 16
|
||||
//#define CONTENT_WORKBENCH 17
|
||||
#define CONTENT_FENCE 21
|
||||
#define CONTENT_RAIL 30
|
||||
|
||||
// 0x800...0xfff: param2 higher 4 bytes are not usable
|
||||
// 0x800...0xfff (2048...4095): higher 4 bytes of param2 are not usable
|
||||
#define CONTENT_GRASS 0x800 //1
|
||||
#define CONTENT_TREE 0x801 //4
|
||||
#define CONTENT_LEAVES 0x802 //5
|
||||
|
@ -62,6 +62,13 @@ MapNode mapnode_translate_to_internal(MapNode n_from, u8 version);
|
|||
#define CONTENT_GLASS 0x80c //20
|
||||
#define CONTENT_MOSSYCOBBLE 0x80d //22
|
||||
#define CONTENT_GRAVEL 0x80e //23
|
||||
#define CONTENT_SANDSTONE 0x80f //24
|
||||
#define CONTENT_CACTUS 0x810 //25
|
||||
#define CONTENT_BRICK 0x811 //26
|
||||
#define CONTENT_CLAY 0x812 //27
|
||||
#define CONTENT_PAPYRUS 0x813 //28
|
||||
#define CONTENT_BOOKSHELF 0x814 //29
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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<Player*> players = m_env->getPlayers(true);
|
||||
core::list<Player*>::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<f32> 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;
|
||||
// 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<<std::endl;
|
||||
std::ostringstream os(std::ios::binary);
|
||||
// version
|
||||
writeU8(os, 0);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
InventoryItem* FireflySAO::createPickedUpItem()
|
||||
{
|
||||
std::istringstream is("CraftItem firefly 1", std::ios_base::binary);
|
||||
InventoryItem *item = InventoryItem::deSerialize(is);
|
||||
return item;
|
||||
}
|
||||
|
|
|
@ -113,6 +113,30 @@ private:
|
|||
float m_after_jump_timer;
|
||||
};
|
||||
|
||||
class FireflySAO : public ServerActiveObject
|
||||
{
|
||||
public:
|
||||
FireflySAO(ServerEnvironment *env, u16 id, v3f pos);
|
||||
u8 getType() const
|
||||
{return ACTIVEOBJECT_TYPE_FIREFLY;}
|
||||
static ServerActiveObject* create(ServerEnvironment *env, u16 id, v3f pos,
|
||||
const std::string &data);
|
||||
void step(float dtime, bool send_recommended);
|
||||
std::string getClientInitializationData();
|
||||
std::string getStaticData();
|
||||
InventoryItem* createPickedUpItem();
|
||||
private:
|
||||
bool m_is_active;
|
||||
IntervalLimiter m_inactive_interval;
|
||||
v3f m_speed_f;
|
||||
v3f m_oldpos;
|
||||
v3f m_last_sent_position;
|
||||
float m_yaw;
|
||||
float m_counter1;
|
||||
float m_counter2;
|
||||
float m_age;
|
||||
bool m_touching_ground;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -70,6 +70,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");
|
||||
g_settings.setDefault("screenshot_path", ".");
|
||||
|
|
|
@ -976,7 +976,8 @@ void ServerEnvironment::step(float dtime)
|
|||
//TestSAO *obj = new TestSAO(this, 0, pos);
|
||||
//ServerActiveObject *obj = new ItemSAO(this, 0, pos, "CraftItem Stick 1");
|
||||
//ServerActiveObject *obj = new RatSAO(this, 0, pos);
|
||||
ServerActiveObject *obj = new Oerkki1SAO(this, 0, pos);
|
||||
//ServerActiveObject *obj = new Oerkki1SAO(this, 0, pos);
|
||||
ServerActiveObject *obj = new FireflySAO(this, 0, pos);
|
||||
addActiveObject(obj);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -70,6 +70,7 @@ FarMesh::FarMesh(
|
|||
m_box = core::aabbox3d<f32>(-BS*1000000,-BS*31000,-BS*1000000,
|
||||
BS*1000000,BS*31000,BS*1000000);
|
||||
|
||||
trees = g_settings.getBool("farmesh_trees");
|
||||
}
|
||||
|
||||
FarMesh::~FarMesh()
|
||||
|
@ -313,12 +314,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;
|
||||
}
|
||||
}
|
||||
|
@ -351,7 +351,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]);
|
||||
|
@ -404,11 +404,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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
47
src/game.cpp
47
src/game.cpp
|
@ -538,6 +538,43 @@ void getPointedNode(Client *client, v3f player_position,
|
|||
}
|
||||
}
|
||||
}
|
||||
else if(n.getContent() == CONTENT_RAIL)
|
||||
{
|
||||
v3s16 dir = unpackDir(n.param0);
|
||||
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<f32> box;
|
||||
|
||||
box = core::aabbox3d<f32>(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
|
||||
*/
|
||||
|
@ -1915,15 +1952,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
|
||||
|
@ -1990,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"
|
||||
|
|
19
src/gettext.h
Normal file
19
src/gettext.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
#ifdef USE_GETTEXT
|
||||
#include <libintl.h>
|
||||
#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(const char *str)
|
||||
{
|
||||
size_t l = strlen(str)+1;
|
||||
wchar_t* nstr = new wchar_t[l];
|
||||
mbstowcs(nstr, str, l);
|
||||
return nstr;
|
||||
}
|
598
src/guiKeyChangeMenu.cpp
Normal file
598
src/guiKeyChangeMenu.cpp
Normal file
|
@ -0,0 +1,598 @@
|
|||
/*
|
||||
Minetest-delta
|
||||
Copyright (C) 2010-11 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
Copyright (C) 2011 Ciaran Gultnieks <ciaran@ciarang.com>
|
||||
Copyright (C) 2011 teddydestodes <derkomtur@schattengang.net>
|
||||
|
||||
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 <string>
|
||||
|
||||
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<gui::IGUIElement*> &children = getChildren();
|
||||
core::list<gui::IGUIElement*> children_copy;
|
||||
for (core::list<gui::IGUIElement*>::ConstIterator i = children.begin(); i
|
||||
!= children.end(); i++)
|
||||
{
|
||||
children_copy.push_back(*i);
|
||||
}
|
||||
for (core::list<gui::IGUIElement*>::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();
|
||||
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;
|
||||
}
|
||||
|
133
src/guiKeyChangeMenu.h
Normal file
133
src/guiKeyChangeMenu.h
Normal file
|
@ -0,0 +1,133 @@
|
|||
/*
|
||||
Minetest-delta
|
||||
Copyright (C) 2010-11 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
Copyright (C) 2011 Ciaran Gultnieks <ciaran@ciarang.com>
|
||||
Copyright (C) 2011 teddydestodes <derkomtur@schattengang.net>
|
||||
|
||||
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 <string>
|
||||
|
||||
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
|
||||
|
|
@ -18,10 +18,15 @@ 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 <string>
|
||||
|
||||
|
||||
|
||||
#include "gettext.h"
|
||||
|
||||
GUIMainMenu::GUIMainMenu(gui::IGUIEnvironment* env,
|
||||
gui::IGUIElement* parent, s32 id,
|
||||
IMenuManager *menumgr,
|
||||
|
@ -34,6 +39,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 +79,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 +116,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
|
||||
|
@ -168,14 +177,14 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
|
|||
{
|
||||
core::rect<s32> 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<s32> 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);
|
||||
}
|
||||
|
@ -191,14 +200,14 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
|
|||
{
|
||||
core::rect<s32> 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<s32> 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,34 +215,43 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
|
|||
core::rect<s32> 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<s32> 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<s32> rect(0, 0, 250, 30);
|
||||
rect += topleft_client + v2s32(35, 150);
|
||||
Environment->addCheckBox(fancy_trees, rect, this, 263,
|
||||
L"Fancy trees");
|
||||
Environment->addCheckBox(fancy_trees, rect, this, GUI_ID_FANCYTREE_CB,
|
||||
chartowchar_t(gettext("Fancy trees")));
|
||||
}
|
||||
{
|
||||
core::rect<s32> rect(0, 0, 250, 30);
|
||||
rect += topleft_client + v2s32(35, 150+30);
|
||||
Environment->addCheckBox(smooth_lighting, rect, this, 262,
|
||||
L"Smooth Lighting");
|
||||
Environment->addCheckBox(smooth_lighting, rect, this, GUI_ID_SMOOTH_LIGHTING_CB,
|
||||
chartowchar_t(gettext("Smooth Lighting")));
|
||||
}
|
||||
// Start game button
|
||||
{
|
||||
core::rect<s32> 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,
|
||||
chartowchar_t(gettext("Start Game / Connect")));
|
||||
}
|
||||
|
||||
// Key change button
|
||||
{
|
||||
core::rect<s32> 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")));
|
||||
}
|
||||
/*
|
||||
Server section
|
||||
*/
|
||||
|
@ -254,19 +272,22 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
|
|||
{
|
||||
core::rect<s32> 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,
|
||||
chartowchar_t(gettext("Creative Mode")));
|
||||
}
|
||||
{
|
||||
core::rect<s32> 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,
|
||||
chartowchar_t(gettext("Enable Damage")));
|
||||
}
|
||||
// Map delete button
|
||||
{
|
||||
core::rect<s32> 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 world");
|
||||
Environment->addButton(rect, this, GUI_ID_DELETE_MAP_BUTTON,
|
||||
chartowchar_t(gettext("Delete map")));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -300,7 +321,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 +331,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 +398,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 +419,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;
|
||||
|
|
|
@ -27,6 +27,21 @@ 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():
|
||||
|
@ -87,6 +102,11 @@ private:
|
|||
MainMenuData *m_data;
|
||||
bool m_accepted;
|
||||
IGameCallback *m_gamecallback;
|
||||
|
||||
gui::IGUIEnvironment* env;
|
||||
gui::IGUIElement* parent;
|
||||
s32 id;
|
||||
IMenuManager *menumgr;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -22,6 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include "serialization.h"
|
||||
#include <string>
|
||||
|
||||
#include "gettext.h"
|
||||
|
||||
GUIMessageMenu::GUIMessageMenu(gui::IGUIEnvironment* env,
|
||||
gui::IGUIElement* parent, s32 id,
|
||||
IMenuManager *menumgr,
|
||||
|
@ -87,7 +89,8 @@ void GUIMessageMenu::regenerateGui(v2u32 screensize)
|
|||
core::rect<s32> 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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include "serialization.h"
|
||||
#include <string>
|
||||
|
||||
#include "gettext.h"
|
||||
|
||||
const int ID_oldPassword = 256;
|
||||
const int ID_newPassword1 = 257;
|
||||
const int ID_newPassword2 = 258;
|
||||
|
@ -97,8 +99,8 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize)
|
|||
{
|
||||
core::rect<s32> 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<s32> rect(0, 0, 230, 30);
|
||||
|
@ -112,8 +114,8 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize)
|
|||
{
|
||||
core::rect<s32> 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<s32> rect(0, 0, 230, 30);
|
||||
|
@ -126,8 +128,8 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize)
|
|||
{
|
||||
core::rect<s32> 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<s32> rect(0, 0, 230, 30);
|
||||
|
@ -141,16 +143,17 @@ void GUIPasswordChange::regenerateGui(v2u32 screensize)
|
|||
{
|
||||
core::rect<s32> 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<s32> 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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,47 @@ void GUIPauseMenu::regenerateGui(v2u32 screensize)
|
|||
{
|
||||
core::rect<s32> 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<s32> 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<s32> 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<s32> 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<s32> 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<s32> rect(0, 0, 180, 220);
|
||||
|
@ -166,8 +172,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<<BUILD_INFO<<"\n";
|
||||
os<<"ud_path = "<<wrap_rows(porting::path_userdata, 20)<<"\n";
|
||||
|
|
|
@ -22,6 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include "serialization.h"
|
||||
#include <string>
|
||||
|
||||
#include "gettext.h"
|
||||
|
||||
GUITextInputMenu::GUITextInputMenu(gui::IGUIEnvironment* env,
|
||||
gui::IGUIElement* parent, s32 id,
|
||||
IMenuManager *menumgr,
|
||||
|
@ -105,7 +107,8 @@ void GUITextInputMenu::regenerateGui(v2u32 screensize)
|
|||
{
|
||||
core::rect<s32> 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")));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -171,6 +171,46 @@ 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
|
||||
*/
|
||||
|
@ -189,4 +229,7 @@ irr::EKEY_CODE getKeySetting(const char *settingname)
|
|||
return c;
|
||||
}
|
||||
|
||||
|
||||
void clearKeyCache()
|
||||
{
|
||||
g_key_setting_cache.clear();
|
||||
}
|
||||
|
|
|
@ -21,11 +21,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#define KEYCODE_HEADER
|
||||
|
||||
#include "common_irrlicht.h"
|
||||
#include <string>
|
||||
|
||||
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);
|
||||
|
||||
// Clear fast lookup cache
|
||||
void clearKeyCache();
|
||||
|
||||
#endif
|
||||
|
||||
|
|
15
src/main.cpp
15
src/main.cpp
|
@ -357,6 +357,12 @@ TODO: Merge bahamada's audio stuff (clean patch available)
|
|||
|
||||
TODO: Move content_features to mapnode_content_features.{h,cpp} or so
|
||||
|
||||
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:
|
||||
------------------------
|
||||
|
||||
|
@ -419,6 +425,8 @@ Doing currently:
|
|||
#include "keycode.h"
|
||||
#include "tile.h"
|
||||
|
||||
#include "gettext.h"
|
||||
|
||||
// This makes textures
|
||||
ITextureSource *g_texturesource = NULL;
|
||||
|
||||
|
@ -1148,6 +1156,10 @@ int main(int argc, char *argv[])
|
|||
|
||||
// Create user data directory
|
||||
fs::CreateDir(porting::path_userdata);
|
||||
|
||||
setlocale(LC_MESSAGES, "");
|
||||
bindtextdomain("minetest", (porting::path_userdata+"/locale").c_str());
|
||||
textdomain("minetest");
|
||||
|
||||
// Initialize debug streams
|
||||
#ifdef RUN_IN_PLACE
|
||||
|
@ -1363,6 +1375,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);
|
||||
|
|
|
@ -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[6] = {
|
||||
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<6; i++)
|
||||
for(u16 i=0; i<7; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -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<trunk_h; ii++)
|
||||
{
|
||||
|
@ -97,7 +97,7 @@ static void make_tree(VoxelManipulator &vmanip, v3s16 p0)
|
|||
// p1 is now the last piece of the trunk
|
||||
p1.Y -= 1;
|
||||
|
||||
VoxelArea leaves_a(v3s16(-2,-2,-2), v3s16(2,2,2));
|
||||
VoxelArea leaves_a(v3s16(-2,-1,-2), v3s16(2,2,2));
|
||||
//SharedPtr<u8> leaves_d(new u8[leaves_a.getVolume()]);
|
||||
Buffer<u8> leaves_d(leaves_a.getVolume());
|
||||
for(s32 i=0; i<leaves_a.getVolume(); i++)
|
||||
|
@ -152,6 +152,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; ii<trunk_h; ii++)
|
||||
{
|
||||
if(vmanip.m_area.contains(p1))
|
||||
vmanip.m_data[vmanip.m_area.index(p1)] = papyrusnode;
|
||||
p1.Y++;
|
||||
}
|
||||
}
|
||||
|
||||
void make_cactus(VoxelManipulator &vmanip, v3s16 p0)
|
||||
{
|
||||
MapNode cactusnode(CONTENT_CACTUS);
|
||||
|
||||
s16 trunk_h = 3;
|
||||
v3s16 p1 = p0;
|
||||
for(s16 ii=0; ii<trunk_h; ii++)
|
||||
{
|
||||
if(vmanip.m_area.contains(p1))
|
||||
vmanip.m_data[vmanip.m_area.index(p1)] = cactusnode;
|
||||
p1.Y++;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void make_randomstone(VoxelManipulator &vmanip, v3s16 p0)
|
||||
{
|
||||
|
@ -909,8 +937,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)
|
||||
|
@ -945,7 +973,7 @@ bool val_is_ground(double ground_noise1_val, v3s16 p, u64 seed)
|
|||
|
||||
double f = 0.55 + 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)
|
||||
|
@ -1345,7 +1373,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.
|
||||
*/
|
||||
|
@ -1379,6 +1408,7 @@ void make_block(BlockMakeData *data)
|
|||
// We're done
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
If block is deep underground, this is set to true and ground
|
||||
|
@ -1808,6 +1838,8 @@ void make_block(BlockMakeData *data)
|
|||
u32 current_depth = 0;
|
||||
bool air_detected = false;
|
||||
bool water_detected = false;
|
||||
bool have_clay = false;
|
||||
|
||||
// Use fast index incrementing
|
||||
s16 start_y = node_max.Y+2;
|
||||
v3s16 em = vmanip.m_area.getExtent();
|
||||
|
@ -1834,7 +1866,19 @@ void make_block(BlockMakeData *data)
|
|||
{
|
||||
if(have_sand)
|
||||
{
|
||||
vmanip.m_data[i] = MapNode(CONTENT_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
|
||||
vmanip.m_data[i] = MapNode(CONTENT_SAND);
|
||||
}
|
||||
#if 1
|
||||
else if(current_depth==0 && !water_detected
|
||||
|
@ -1894,7 +1938,7 @@ void make_block(BlockMakeData *data)
|
|||
{
|
||||
u32 i = data->vmanip->m_area.index(p);
|
||||
MapNode *n = &data->vmanip->m_data[i];
|
||||
if(n->getContent() != CONTENT_AIR && n->getContent() != CONTENT_IGNORE)
|
||||
if(n->getContent() != CONTENT_AIR && n->getContent() != CONTENT_WATERSOURCE && n->getContent() != CONTENT_IGNORE)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
|
@ -1903,19 +1947,33 @@ 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->getContent() != CONTENT_MUD && n->getContent() != CONTENT_GRASS)
|
||||
continue;
|
||||
|
||||
if(n->getContent() != CONTENT_MUD && n->getContent() != CONTENT_GRASS && n->getContent() != CONTENT_SAND)
|
||||
continue;
|
||||
|
||||
// Papyrus grows only on mud and in water
|
||||
if(n->getContent() == CONTENT_MUD && y <= WATER_LEVEL)
|
||||
{
|
||||
p.Y++;
|
||||
make_papyrus(vmanip, p);
|
||||
}
|
||||
// Trees grow only on mud and grass, on land
|
||||
else if((n->getContent() == CONTENT_MUD || n->getContent() == CONTENT_GRASS) && y > WATER_LEVEL + 2)
|
||||
{
|
||||
p.Y++;
|
||||
make_tree(vmanip, p);
|
||||
}
|
||||
// Cactii grow only on sand, on land
|
||||
else if(n->getContent() == CONTENT_SAND && y > WATER_LEVEL + 2)
|
||||
{
|
||||
p.Y++;
|
||||
make_cactus(vmanip, p);
|
||||
}
|
||||
}
|
||||
// Tree will be placed one higher
|
||||
p.Y++;
|
||||
// Make a tree
|
||||
make_tree(vmanip, p);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
|
|
@ -148,6 +148,8 @@ struct ContentFeatures
|
|||
// If the content is liquid, this is the flowing version of the liquid.
|
||||
// If content is liquid, this is the same content.
|
||||
content_t liquid_alternative_flowing;
|
||||
// If the content is liquid, this is the source version of the liquid.
|
||||
content_t liquid_alternative_source;
|
||||
|
||||
// Amount of light the node emits
|
||||
u8 light_source;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue