#include "gettext.h"
#include "log.h"
#include "filesys.h"
-
-/*
- TODO: Move content-aware stuff to separate file by adding properties
- and virtual interfaces
-*/
-#include "content_mapnode.h"
-#include "content_nodemeta.h"
+// Needed for determining pointing to nodes
+#include "mapnode_contentfeatures.h"
+#include "nodemetadata.h"
/*
Setting this to 1 enables a special camera mode that forces
Client *m_client;
};
-struct TextDestSignNode : public TextDest
+struct TextDestNodeMetadata : public TextDest
{
- TextDestSignNode(v3s16 p, Client *client)
+ TextDestNodeMetadata(v3s16 p, Client *client)
{
m_p = p;
m_client = client;
v3s16(-1,0,0), // left
};
- /*
- Meta-objects
- */
- if(n.getContent() == CONTENT_TORCH)
+ ContentFeatures &f = content_features(n);
+
+ if(f.selection_box.type == NODEBOX_FIXED)
{
- v3s16 dir = unpackDir(n.param2);
- 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();
+ f32 distance = (npf - camera_position).getLength();
- core::aabbox3d<f32> box;
-
- // bottom
- if(dir == v3s16(0,-1,0))
- {
- box = core::aabbox3d<f32>(
- npf - v3f(BS/6, BS/2, BS/6),
- npf + v3f(BS/6, -BS/2+BS/3*2, BS/6)
- );
- }
- // top
- else if(dir == v3s16(0,1,0))
- {
- box = core::aabbox3d<f32>(
- npf - v3f(BS/6, -BS/2+BS/3*2, BS/6),
- npf + v3f(BS/6, BS/2, BS/6)
- );
- }
- // side
- else
- {
- box = core::aabbox3d<f32>(
- cpf - v3f(BS/6, BS/3, BS/6),
- cpf + v3f(BS/6, BS/3, BS/6)
- );
- }
+ core::aabbox3d<f32> box = f.selection_box.fixed;
+ box.MinEdge += npf;
+ box.MaxEdge += npf;
if(distance < mindistance)
{
}
}
}
- else if(n.getContent() == CONTENT_SIGN_WALL)
+ else if(f.selection_box.type == NODEBOX_WALLMOUNTED)
{
v3s16 dir = unpackDir(n.param2);
v3f dir_f = v3f(dir.X, dir.Y, dir.Z);
v3f cpf = npf + dir_f;
f32 distance = (cpf - camera_position).getLength();
- v3f vertices[4] =
- {
- v3f(BS*0.42,-BS*0.35,-BS*0.4),
- v3f(BS*0.49, BS*0.35, BS*0.4),
- };
-
- for(s32 i=0; i<2; i++)
- {
- if(dir == v3s16(1,0,0))
- vertices[i].rotateXZBy(0);
- if(dir == v3s16(-1,0,0))
- vertices[i].rotateXZBy(180);
- if(dir == v3s16(0,0,1))
- vertices[i].rotateXZBy(90);
- if(dir == v3s16(0,0,-1))
- vertices[i].rotateXZBy(-90);
- if(dir == v3s16(0,-1,0))
- vertices[i].rotateXYBy(-90);
- if(dir == v3s16(0,1,0))
- vertices[i].rotateXYBy(90);
-
- 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;
- }
+
+ // top
+ if(dir == v3s16(0,1,0)){
+ box = f.selection_box.wall_top;
}
- }
-
- else if(n.getContent() == CONTENT_LADDER)
- {
- v3s16 dir = unpackDir(n.param2);
- 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();
-
- v3f vertices[4] =
- {
- v3f(BS*0.42,-BS/2,-BS/2),
- v3f(BS*0.49, BS/2, BS/2),
- };
-
- for(s32 i=0; i<2; i++)
- {
- if(dir == v3s16(1,0,0))
- vertices[i].rotateXZBy(0);
- if(dir == v3s16(-1,0,0))
- vertices[i].rotateXZBy(180);
- if(dir == v3s16(0,0,1))
- vertices[i].rotateXZBy(90);
- if(dir == v3s16(0,0,-1))
- vertices[i].rotateXZBy(-90);
- if(dir == v3s16(0,-1,0))
- vertices[i].rotateXYBy(-90);
- if(dir == v3s16(0,1,0))
- vertices[i].rotateXYBy(90);
-
- vertices[i] += npf;
+ // bottom
+ else if(dir == v3s16(0,-1,0)){
+ box = f.selection_box.wall_bottom;
}
+ // side
+ else{
+ v3f vertices[2] =
+ {
+ f.selection_box.wall_side.MinEdge,
+ f.selection_box.wall_side.MaxEdge
+ };
- core::aabbox3d<f32> box;
-
- box = core::aabbox3d<f32>(vertices[0]);
- box.addInternalPoint(vertices[1]);
-
- if(distance < mindistance)
- {
- if(box.intersectsWithLine(shootline))
+ for(s32 i=0; i<2; i++)
{
- nodefound = true;
- nodepos = np;
- neighbourpos = np;
- mindistance = distance;
- nodehilightbox = box;
+ if(dir == v3s16(-1,0,0))
+ vertices[i].rotateXZBy(0);
+ if(dir == v3s16(1,0,0))
+ vertices[i].rotateXZBy(180);
+ if(dir == v3s16(0,0,-1))
+ vertices[i].rotateXZBy(90);
+ if(dir == v3s16(0,0,1))
+ vertices[i].rotateXZBy(-90);
}
- }
- }
- 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;
+ box = core::aabbox3d<f32>(vertices[0]);
+ box.addInternalPoint(vertices[1]);
}
- core::aabbox3d<f32> box;
-
- box = core::aabbox3d<f32>(vertices[0]);
- box.addInternalPoint(vertices[1]);
-
+ box.MinEdge += npf;
+ box.MaxEdge += npf;
+
if(distance < mindistance)
{
if(box.intersectsWithLine(shootline))
}
}
}
- /*
- Regular blocks
- */
- else
+ else // NODEBOX_REGULAR
{
for(u16 i=0; i<6; i++)
{
//guitext_chat->setBackgroundColor(video::SColor(96,0,0,0));
core::list<ChatLine> chat_lines;
- // Profiler text
+ // Profiler text (size is updated when text is updated)
gui::IGUIStaticText *guitext_profiler = guienv->addStaticText(
L"<Profiler>",
- core::rect<s32>(6, 4+(text_height+5)*3, 400,
- (text_height+5)*3 + text_height*35),
+ core::rect<s32>(6, 4+(text_height+5)*2, 400,
+ (text_height+5)*2 + text_height*35),
false, false);
guitext_profiler->setBackgroundColor(video::SColor(80,0,0,0));
guitext_profiler->setVisible(false);
bool respawn_menu_active = false;
bool show_profiler = false;
+ bool force_fog_off = false;
+ bool disable_camera_update = false;
/*
Main loop
print_to_log = false;
profiler_print_interval = 5;
}
- if(m_profiler_interval.step(0.030, profiler_print_interval))
+ if(m_profiler_interval.step(dtime, profiler_print_interval))
{
if(print_to_log){
infostream<<"Profiler:"<<std::endl;
std::ostringstream os(std::ios_base::binary);
g_profiler->print(os);
- guitext_profiler->setText(narrow_to_wide(os.str()).c_str());
+ std::wstring text = narrow_to_wide(os.str());
+ guitext_profiler->setText(text.c_str());
g_profiler->clear();
+
+ s32 w = font->getDimension(text.c_str()).Width;
+ if(w < 400)
+ w = 400;
+ core::rect<s32> rect(6, 4+(text_height+5)*2, 12+w,
+ 8+(text_height+5)*2 +
+ font->getDimension(text.c_str()).Height);
+ guitext_profiler->setRelativePosition(rect);
}
/*
{
show_profiler = !show_profiler;
guitext_profiler->setVisible(show_profiler);
+ if(show_profiler)
+ chat_lines.push_back(ChatLine(L"Profiler disabled"));
+ else
+ chat_lines.push_back(ChatLine(L"Profiler enabled"));
+ }
+ else if(input->wasKeyDown(getKeySetting("keymap_toggle_force_fog_off")))
+ {
+ force_fog_off = !force_fog_off;
+ if(force_fog_off)
+ chat_lines.push_back(ChatLine(L"Fog disabled"));
+ else
+ chat_lines.push_back(ChatLine(L"Fog enabled"));
+ }
+ else if(input->wasKeyDown(getKeySetting("keymap_toggle_update_camera")))
+ {
+ disable_camera_update = !disable_camera_update;
+ if(disable_camera_update)
+ chat_lines.push_back(ChatLine(L"Camera update disabled"));
+ else
+ chat_lines.push_back(ChatLine(L"Camera update enabled"));
}
// Item selection with mouse wheel
v3f camera_direction = camera.getDirection();
f32 camera_fov = camera.getFovMax();
- if(FIELD_OF_VIEW_TEST)
- client.updateCamera(v3f(0,0,0), v3f(0,0,1), camera_fov);
- else
+ if(!disable_camera_update){
client.updateCamera(camera_position,
camera_direction, camera_fov);
+ }
//timer2.stop();
//TimeTaker //timer3("//timer3");
menu->setDrawSpec(draw_spec);
menu->drop();
}
- else if(meta && meta->typeId() == CONTENT_SIGN_WALL && !random_input)
+ // If metadata provides text input, activate text input
+ else if(meta && meta->allowsTextInput() && !random_input)
{
- infostream<<"Sign node right-clicked"<<std::endl;
-
- SignNodeMetadata *signmeta = (SignNodeMetadata*)meta;
+ infostream<<"Launching metadata text input"<<std::endl;
// Get a new text for it
- TextDest *dest = new TextDestSignNode(nodepos, &client);
+ TextDest *dest = new TextDestNodeMetadata(nodepos, &client);
- std::wstring wtext =
- narrow_to_wide(signmeta->getText());
+ std::wstring wtext = narrow_to_wide(meta->getText());
(new GUITextInputMenu(guienv, guiroot, -1,
&g_menumgr, dest,
wtext))->drop();
}
+ // Otherwise report right click to server
else
{
client.groundAction(1, nodepos, neighbourpos, g_selected_item);
Fog
*/
- if(g_settings->getBool("enable_fog") == true)
+ if(g_settings->getBool("enable_fog") == true && !force_fog_off)
{
f32 range;
if(farmesh)
else
{
range = draw_control.wanted_range*BS + MAP_BLOCKSIZE*BS*1.5;
+ range *= 0.9;
if(draw_control.range_all)
range = 100000*BS;
- if(range < 50*BS)
- range = range * 0.5 + 25*BS;
+ /*if(range < 50*BS)
+ range = range * 0.5 + 25*BS;*/
}
driver->setFog(