From 0c3d39357b7006844f5e86baf21704d3fa8a7be7 Mon Sep 17 00:00:00 2001 From: Kahrl Date: Wed, 1 Feb 2012 00:56:30 +0100 Subject: F1 toggles HUD, F2 toggles chat, F5 toggles debug info, F6 toggles profiler pages --- src/defaultsettings.cpp | 14 +- src/game.cpp | 339 ++++++++++++++++++++++++++++++++++-------------- src/profiler.h | 19 +++ src/utility.h | 44 +++++++ 4 files changed, 318 insertions(+), 98 deletions(-) (limited to 'src') diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 4de854dd8..2b604662c 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -43,14 +43,23 @@ void set_default_settings(Settings *settings) settings->setDefault("keymap_rangeselect", "KEY_KEY_R"); settings->setDefault("keymap_freemove", "KEY_KEY_K"); settings->setDefault("keymap_fastmove", "KEY_KEY_J"); - settings->setDefault("keymap_frametime_graph", "KEY_F1"); settings->setDefault("keymap_screenshot", "KEY_F12"); - settings->setDefault("keymap_toggle_profiler", "KEY_F2"); + settings->setDefault("keymap_toggle_hud", "KEY_F1"); + settings->setDefault("keymap_toggle_chat", "KEY_F2"); settings->setDefault("keymap_toggle_force_fog_off", "KEY_F3"); settings->setDefault("keymap_toggle_update_camera", "KEY_F4"); + settings->setDefault("keymap_toggle_debug", "KEY_F5"); + settings->setDefault("keymap_toggle_profiler", "KEY_F6"); // Some (temporary) keys for debugging settings->setDefault("keymap_print_debug_stacks", "KEY_KEY_P"); + // Show debug info by default? + #ifdef NDEBUG + settings->setDefault("show_debug", "false"); + #else + settings->setDefault("show_debug", "true"); + #endif + settings->setDefault("wanted_fps", "30"); settings->setDefault("fps_max", "60"); settings->setDefault("viewing_range_nodes_max", "300"); @@ -66,7 +75,6 @@ void set_default_settings(Settings *settings) settings->setDefault("new_style_water", "false"); settings->setDefault("new_style_leaves", "false"); settings->setDefault("smooth_lighting", "true"); - settings->setDefault("frametime_graph", "false"); settings->setDefault("enable_texture_atlas", "true"); settings->setDefault("texture_path", ""); settings->setDefault("video_driver", "opengl"); diff --git a/src/game.cpp b/src/game.cpp index 47a0e6afe..027de6923 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -634,6 +634,36 @@ void draw_load_screen(const std::wstring &text, //return guitext; } +/* Profiler display */ + +void update_profiler_gui(gui::IGUIStaticText *guitext_profiler, + gui::IGUIFont *font, u32 text_height, + u32 show_profiler, u32 show_profiler_max) +{ + if(show_profiler == 0) + { + guitext_profiler->setVisible(false); + } + else + { + + std::ostringstream os(std::ios_base::binary); + g_profiler->printPage(os, show_profiler, show_profiler_max); + std::wstring text = narrow_to_wide(os.str()); + guitext_profiler->setText(text.c_str()); + guitext_profiler->setVisible(true); + + s32 w = font->getDimension(text.c_str()).Width; + if(w < 400) + w = 400; + core::rect rect(6, 4+(text_height+5)*2, 12+w, + 8+(text_height+5)*2 + + font->getDimension(text.c_str()).Height); + guitext_profiler->setRelativePosition(rect); + guitext_profiler->setVisible(true); + } +} + void the_game( bool &kill, bool random_input, @@ -932,6 +962,16 @@ void the_game( core::rect(0,0,400,text_height+5) + v2s32(100,200), false, false); + // Status text (displays info when showing and hiding GUI stuff, etc.) + gui::IGUIStaticText *guitext_status = guienv->addStaticText( + L"", + core::rect(0,0,0,0), + false, false); + guitext_status->setVisible(false); + + std::wstring statustext; + float statustext_time = 0; + // Chat text gui::IGUIStaticText *guitext_chat = guienv->addStaticText( L"", @@ -944,8 +984,7 @@ void the_game( // Profiler text (size is updated when text is updated) gui::IGUIStaticText *guitext_profiler = guienv->addStaticText( L"", - core::rect(6, 4+(text_height+5)*2, 400, - (text_height+5)*2 + text_height*35), + core::rect(0,0,0,0), false, false); guitext_profiler->setBackgroundColor(video::SColor(80,0,0,0)); guitext_profiler->setVisible(false); @@ -968,11 +1007,6 @@ void the_game( (new GUIPauseMenu(guienv, guiroot, -1, g_gamecallback, &g_menumgr))->drop(); - // Enable texts - /*guitext2->setVisible(true); - guitext_info->setVisible(true); - guitext_chat->setVisible(true);*/ - //s32 guitext_chat_pad_bottom = 70; /* @@ -1008,9 +1042,14 @@ void the_game( bool respawn_menu_active = false; bool update_wielded_item_trigger = false; - bool show_profiler = false; + bool show_hud = true; + bool show_chat = true; bool force_fog_off = false; bool disable_camera_update = false; + bool show_debug = g_settings->getBool("show_debug"); + bool show_debug_frametime = false; + u32 show_profiler = 0; + u32 show_profiler_max = 3; // Number of pages /* Main loop @@ -1247,20 +1286,10 @@ void the_game( g_profiler->print(infostream); } - std::ostringstream os(std::ios_base::binary); - g_profiler->print(os); - std::wstring text = narrow_to_wide(os.str()); - guitext_profiler->setText(text.c_str()); + update_profiler_gui(guitext_profiler, font, text_height, + show_profiler, show_profiler_max); g_profiler->clear(); - - s32 w = font->getDimension(text.c_str()).Width; - if(w < 400) - w = 400; - core::rect rect(6, 4+(text_height+5)*2, 12+w, - 8+(text_height+5)*2 + - font->getDimension(text.c_str()).Height); - guitext_profiler->setRelativePosition(rect); } /* @@ -1349,12 +1378,14 @@ void the_game( if(g_settings->getBool("free_move")) { g_settings->set("free_move","false"); - chat_lines.push_back(ChatLine(L"free_move disabled")); + statustext = L"free_move disabled"; + statustext_time = 0; } else { g_settings->set("free_move","true"); - chat_lines.push_back(ChatLine(L"free_move enabled")); + statustext = L"free_move enabled"; + statustext_time = 0; } } else if(input->wasKeyDown(getKeySetting("keymap_fastmove"))) @@ -1362,25 +1393,14 @@ void the_game( if(g_settings->getBool("fast_move")) { g_settings->set("fast_move","false"); - chat_lines.push_back(ChatLine(L"fast_move disabled")); + statustext = L"fast_move disabled"; + statustext_time = 0; } else { g_settings->set("fast_move","true"); - chat_lines.push_back(ChatLine(L"fast_move enabled")); - } - } - else if(input->wasKeyDown(getKeySetting("keymap_frametime_graph"))) - { - if(g_settings->getBool("frametime_graph")) - { - g_settings->set("frametime_graph","false"); - chat_lines.push_back(ChatLine(L"frametime_graph disabled")); - } - else - { - g_settings->set("frametime_graph","true"); - chat_lines.push_back(ChatLine(L"frametime_graph enabled")); + statustext = L"fast_move enabled"; + statustext_time = 0; } } else if(input->wasKeyDown(getKeySetting("keymap_screenshot"))) @@ -1395,37 +1415,97 @@ void the_game( std::wstringstream sstr; sstr<<"Saved screenshot to '"<drop(); } } - else if(input->wasKeyDown(getKeySetting("keymap_toggle_profiler"))) + else if(input->wasKeyDown(getKeySetting("keymap_toggle_hud"))) { - show_profiler = !show_profiler; - guitext_profiler->setVisible(show_profiler); - if(show_profiler) - chat_lines.push_back(ChatLine(L"Profiler disabled")); + show_hud = !show_hud; + if(show_hud) + statustext = L"HUD shown"; else - chat_lines.push_back(ChatLine(L"Profiler enabled")); + statustext = L"HUD hidden"; + statustext_time = 0; + } + else if(input->wasKeyDown(getKeySetting("keymap_toggle_chat"))) + { + show_chat = !show_chat; + if(show_chat) + statustext = L"Chat shown"; + else + statustext = L"Chat hidden"; + statustext_time = 0; } 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")); + statustext = L"Fog disabled"; else - chat_lines.push_back(ChatLine(L"Fog enabled")); + statustext = L"Fog enabled"; + statustext_time = 0; } 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")); + statustext = L"Camera update disabled"; else - chat_lines.push_back(ChatLine(L"Camera update enabled")); + statustext = L"Camera update enabled"; + statustext_time = 0; + } + else if(input->wasKeyDown(getKeySetting("keymap_toggle_debug"))) + { + // Initial / 3x toggle: Chat only + // 1x toggle: Debug text with chat + // 2x toggle: Debug text with frametime + if(!show_debug) + { + show_debug = true; + show_debug_frametime = false; + statustext = L"Debug info shown"; + statustext_time = 0; + } + else if(show_debug_frametime) + { + show_debug = false; + show_debug_frametime = false; + statustext = L"Debug info and frametime graph hidden"; + statustext_time = 0; + } + else + { + show_debug_frametime = true; + statustext = L"Frametime graph shown"; + statustext_time = 0; + } + } + else if(input->wasKeyDown(getKeySetting("keymap_toggle_profiler"))) + { + show_profiler = (show_profiler + 1) % (show_profiler_max + 1); + + // FIXME: This updates the profiler with incomplete values + update_profiler_gui(guitext_profiler, font, text_height, + show_profiler, show_profiler_max); + + if(show_profiler != 0) + { + std::wstringstream sstr; + sstr<<"Profiler shown (page "<wasKeyDown(getKeySetting("keymap_rangeselect"))) { + draw_control.range_all = !draw_control.range_all; if(draw_control.range_all) { - draw_control.range_all = false; - infostream<<"Disabled full viewing range"<setText(narrow_to_wide(temptext).c_str()); + guitext->setVisible(true); + } + else if(show_hud) + { + guitext->setText(narrow_to_wide(program_name_and_version).c_str()); + guitext->setVisible(true); + } + else + { + guitext->setVisible(false); } + if(show_debug) { char temptext[300]; snprintf(temptext, 300, "(% .1f, % .1f, % .1f)" - " (% .3f < btime_jitter < % .3f" - ", dtime_jitter = % .1f %%" - ", v_range = %.1f, RTT = %.3f)", + " (yaw = %.1f)", player_position.X/BS, player_position.Y/BS, player_position.Z/BS, - busytime_jitter1_min_sample, - busytime_jitter1_max_sample, - dtime_jitter1_max_fraction * 100.0, - draw_control.wanted_range, - client.getRTT() - ); + wrapDegrees_0_360(camera_yaw)); guitext2->setText(narrow_to_wide(temptext).c_str()); + guitext2->setVisible(true); + } + else + { + guitext2->setVisible(false); } { guitext_info->setText(infotext.c_str()); + guitext_info->setVisible(show_hud); + } + + { + float statustext_time_max = 3.0; + if(!statustext.empty()) + { + statustext_time += dtime; + if(statustext_time >= statustext_time_max) + { + statustext = L""; + statustext_time = 0; + } + } + guitext_status->setText(statustext.c_str()); + guitext_status->setVisible(!statustext.empty()); + + if(!statustext.empty()) + { + s32 status_y = screensize.Y - 130; + core::rect rect( + 10, + status_y - guitext_status->getTextHeight(), + screensize.X - 10, + status_y + ); + guitext_status->setRelativePosition(rect); + + // Fade out + video::SColor initial_color(255,0,0,0); + if(guienv->getSkin()) + initial_color = guienv->getSkin()->getColor(gui::EGDC_BUTTON_TEXT); + video::SColor final_color = initial_color; + final_color.setAlpha(0); + video::SColor fade_color = + initial_color.getInterpolated_quadratic( + initial_color, + final_color, + statustext_time / (float) statustext_time_max); + guitext_status->setOverrideColor(fade_color); + guitext_status->enableOverrideColor(true); + } } /* @@ -2224,20 +2362,22 @@ void the_game( screensize.X - 10, screensize.Y - guitext_chat_pad_bottom );*/ + + s32 chat_y = 5+(text_height+5); + if(show_debug) + chat_y += (text_height+5); core::rect rect( 10, - 50, + chat_y, screensize.X - 10, - 50 + guitext_chat->getTextHeight() + chat_y + guitext_chat->getTextHeight() ); guitext_chat->setRelativePosition(rect); - // Don't show chat if empty or profiler is enabled - if(chat_lines.size() == 0 || show_profiler) - guitext_chat->setVisible(false); - else - guitext_chat->setVisible(true); + // Don't show chat if empty or profiler or debug is enabled + guitext_chat->setVisible(chat_lines.size() != 0 + && show_chat && show_profiler == 0); } /* @@ -2275,7 +2415,7 @@ void the_game( { TimeTaker timer("beginScene"); - driver->beginScene(true, true, bgcolor); + driver->beginScene(false, true, bgcolor); //driver->beginScene(false, true, bgcolor); beginscenetime = timer.stop(true); } @@ -2305,20 +2445,24 @@ void the_game( driver->setTransform(video::ETS_WORLD, core::IdentityMatrix); - for(core::list< core::aabbox3d >::Iterator i=hilightboxes.begin(); - i != hilightboxes.end(); i++) + if(show_hud) { - /*infostream<<"hilightbox min=" - <<"("<MinEdge.X<<","<MinEdge.Y<<","<MinEdge.Z<<")" - <<" max=" - <<"("<MaxEdge.X<<","<MaxEdge.Y<<","<MaxEdge.Z<<")" - <draw3DBox(*i, video::SColor(255,0,0,0)); + for(core::list::Iterator i=hilightboxes.begin(); + i != hilightboxes.end(); i++) + { + /*infostream<<"hilightbox min=" + <<"("<MinEdge.X<<","<MinEdge.Y<<","<MinEdge.Z<<")" + <<" max=" + <<"("<MaxEdge.X<<","<MaxEdge.Y<<","<MaxEdge.Z<<")" + <draw3DBox(*i, video::SColor(255,0,0,0)); + } } /* Wielded tool */ + if(show_hud) { // Warning: This clears the Z buffer. camera.drawWieldedTool(); @@ -2334,16 +2478,17 @@ void the_game( /* Frametime log */ - if(g_settings->getBool("frametime_graph") == true) + if(show_debug_frametime) { s32 x = 10; + s32 y = screensize.Y - 10; for(core::list::Iterator i = frametime_log.begin(); i != frametime_log.end(); i++) { - driver->draw2DLine(v2s32(x,50), - v2s32(x,50+(*i)*1000), + driver->draw2DLine(v2s32(x,y), + v2s32(x,y-(*i)*1000), video::SColor(255,255,255,255)); x++; } @@ -2352,12 +2497,15 @@ void the_game( /* Draw crosshair */ - driver->draw2DLine(displaycenter - core::vector2d(10,0), - displaycenter + core::vector2d(10,0), - video::SColor(255,255,255,255)); - driver->draw2DLine(displaycenter - core::vector2d(0,10), - displaycenter + core::vector2d(0,10), - video::SColor(255,255,255,255)); + if(show_hud) + { + driver->draw2DLine(displaycenter - core::vector2d(10,0), + displaycenter + core::vector2d(10,0), + video::SColor(255,255,255,255)); + driver->draw2DLine(displaycenter - core::vector2d(0,10), + displaycenter + core::vector2d(0,10), + video::SColor(255,255,255,255)); + } } // timer @@ -2373,6 +2521,7 @@ void the_game( /* Draw hotbar */ + if(show_hud) { draw_hotbar(driver, font, gamedef, v2s32(displaycenter.X, screensize.Y), diff --git a/src/profiler.h b/src/profiler.h index 129118ef6..7bb3b3750 100644 --- a/src/profiler.h +++ b/src/profiler.h @@ -99,12 +99,31 @@ public: } void print(std::ostream &o) + { + printPage(o, 1, 1); + } + + void printPage(std::ostream &o, u32 page, u32 pagecount) { JMutexAutoLock lock(m_mutex); + + u32 minindex, maxindex; + paging(m_data.size(), page, pagecount, minindex, maxindex); + for(core::map::Iterator i = m_data.getIterator(); i.atEnd() == false; i++) { + if(maxindex == 0) + break; + maxindex--; + + if(minindex != 0) + { + minindex--; + continue; + } + std::string name = i.getNode()->getKey(); int avgcount = 1; core::map::Node *n = m_avgcounts.find(name); diff --git a/src/utility.h b/src/utility.h index 50f27c11b..f4c7c3017 100644 --- a/src/utility.h +++ b/src/utility.h @@ -1757,6 +1757,50 @@ protected: float m_accumulator; }; +/* + Splits a list into "pages". For example, the list [1,2,3,4,5] split + into two pages would be [1,2,3],[4,5]. This function computes the + minimum and maximum indices of a single page. + + length: Length of the list that should be split + page: Page number, 1 <= page <= pagecount + pagecount: The number of pages, >= 1 + minindex: Receives the minimum index (inclusive). + maxindex: Receives the maximum index (exclusive). + + Ensures 0 <= minindex <= maxindex <= length. +*/ +inline void paging(u32 length, u32 page, u32 pagecount, u32 &minindex, u32 &maxindex) +{ + if(length < 1 || pagecount < 1 || page < 1 || page > pagecount) + { + // Special cases or invalid parameters + minindex = maxindex = 0; + } + else if(pagecount <= length) + { + // Less pages than entries in the list: + // Each page contains at least one entry + minindex = (length * (page-1) + (pagecount-1)) / pagecount; + maxindex = (length * page + (pagecount-1)) / pagecount; + } + else + { + // More pages than entries in the list: + // Make sure the empty pages are at the end + if(page < length) + { + minindex = page-1; + maxindex = page; + } + else + { + minindex = 0; + maxindex = 0; + } + } +} + std::string translatePassword(std::string playername, std::wstring password); enum PointedThingType -- cgit v1.2.3 From 78bf92175a81e96545c9bf2f331c344012c71230 Mon Sep 17 00:00:00 2001 From: Kahrl Date: Wed, 1 Feb 2012 01:36:59 +0100 Subject: Show the top line too when only chat, but not HUD is shown --- src/game.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/game.cpp b/src/game.cpp index 027de6923..76fdedcf0 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2219,7 +2219,7 @@ void the_game( guitext->setText(narrow_to_wide(temptext).c_str()); guitext->setVisible(true); } - else if(show_hud) + else if(show_hud || show_chat) { guitext->setText(narrow_to_wide(program_name_and_version).c_str()); guitext->setVisible(true); -- cgit v1.2.3 From 2cb96d9d6800a3fd74bb6264974e8811ff8d4acd Mon Sep 17 00:00:00 2001 From: Kahrl Date: Wed, 1 Feb 2012 02:24:55 +0100 Subject: Page up and down change the minimum viewing range --- src/camera.cpp | 56 +++++++++++++++++++++++-------------------------- src/camera.h | 9 -------- src/defaultsettings.cpp | 2 ++ src/game.cpp | 30 ++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 39 deletions(-) (limited to 'src') diff --git a/src/camera.cpp b/src/camera.cpp index 066208569..b36daf1d7 100644 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -40,8 +40,6 @@ Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control): m_wieldlight(0), m_draw_control(draw_control), - m_viewing_range_min(5.0), - m_viewing_range_max(5.0), m_camera_position(0,0,0), m_camera_direction(0,0,0), @@ -50,7 +48,6 @@ Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control): m_fov_x(1.0), m_fov_y(1.0), - m_wanted_frametime(0.0), m_added_frametime(0), m_added_frames(0), m_range_old(0), @@ -79,8 +76,6 @@ Camera::Camera(scene::ISceneManager* smgr, MapDrawControl& draw_control): m_wieldmgr = smgr->createNewSceneManager(); m_wieldmgr->addCameraSceneNode(); m_wieldnode = m_wieldmgr->addMeshSceneNode(createCubeMesh(v3f(1,1,1)), NULL); // need a dummy mesh - - updateSettings(); } Camera::~Camera() @@ -259,14 +254,17 @@ void Camera::update(LocalPlayer* player, f32 frametime, v2u32 screensize) // *100.0 helps in large map coordinates m_cameranode->setTarget(m_camera_position + 100 * m_camera_direction); - // FOV and and aspect ratio + // Get FOV setting + f32 fov_degrees = g_settings->getFloat("fov"); + fov_degrees = MYMAX(fov_degrees, 10.0); + fov_degrees = MYMIN(fov_degrees, 170.0); + + // FOV and aspect ratio m_aspect = (f32)screensize.X / (f32) screensize.Y; + m_fov_y = fov_degrees * PI / 180.0; m_fov_x = 2 * atan(0.5 * m_aspect * tan(m_fov_y)); m_cameranode->setAspectRatio(m_aspect); m_cameranode->setFOV(m_fov_y); - // Just so big a value that everything rendered is visible - // Some more allowance that m_viewing_range_max * BS because of active objects etc. - m_cameranode->setFarValue(m_viewing_range_max * BS * 10); // Position the wielded item v3f wield_position = v3f(45, -35, 65); @@ -343,7 +341,18 @@ void Camera::updateViewingRange(f32 frametime_in) <getS16("viewing_range_nodes_min"); + viewing_range_min = MYMAX(5.0, viewing_range_min); + + f32 viewing_range_max = g_settings->getS16("viewing_range_nodes_max"); + viewing_range_max = MYMAX(viewing_range_min, viewing_range_max); + + f32 wanted_fps = g_settings->getFloat("wanted_fps"); + wanted_fps = MYMAX(wanted_fps, 1.0); + f32 wanted_frametime = 1.0 / wanted_fps; + + m_draw_control.wanted_min_range = viewing_range_min; m_draw_control.wanted_max_blocks = (2.0*m_draw_control.blocks_would_have_drawn)+1; if (m_draw_control.wanted_max_blocks < 10) m_draw_control.wanted_max_blocks = 10; @@ -362,13 +371,13 @@ void Camera::updateViewingRange(f32 frametime_in) m_added_frametime = 0.0; m_added_frames = 0; - f32 wanted_frametime_change = m_wanted_frametime - frametime; + f32 wanted_frametime_change = wanted_frametime - frametime; //dstream<<"wanted_frametime_change="<getS16("viewing_range_nodes_min"); - m_viewing_range_min = MYMAX(5.0, m_viewing_range_min); - m_viewing_range_max = g_settings->getS16("viewing_range_nodes_max"); - m_viewing_range_max = MYMAX(m_viewing_range_min, m_viewing_range_max); - - f32 fov_degrees = g_settings->getFloat("fov"); - fov_degrees = MYMAX(fov_degrees, 10.0); - fov_degrees = MYMIN(fov_degrees, 170.0); - m_fov_y = fov_degrees * PI / 180.0; + // Just so big a value that everything rendered is visible + // Some more allowance than viewing_range_max * BS because of active objects etc. + m_cameranode->setFarValue(viewing_range_max * BS * 10); - f32 wanted_fps = g_settings->getFloat("wanted_fps"); - wanted_fps = MYMAX(wanted_fps, 1.0); - m_wanted_frametime = 1.0 / wanted_fps; } void Camera::setDigging(s32 button) diff --git a/src/camera.h b/src/camera.h index 56c99d101..7be8162b5 100644 --- a/src/camera.h +++ b/src/camera.h @@ -110,9 +110,6 @@ public: // Render distance feedback loop void updateViewingRange(f32 frametime_in); - // Update settings from g_settings - void updateSettings(); - // Start digging animation // Pass 0 for left click, 1 for right click void setDigging(s32 button); @@ -139,11 +136,6 @@ private: // draw control MapDrawControl& m_draw_control; - // viewing_range_min_nodes setting - f32 m_viewing_range_min; - // viewing_range_max_nodes setting - f32 m_viewing_range_max; - // Absolute camera position v3f m_camera_position; // Absolute camera direction @@ -155,7 +147,6 @@ private: f32 m_fov_y; // Stuff for viewing range calculations - f32 m_wanted_frametime; f32 m_added_frametime; s16 m_added_frames; f32 m_range_old; diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 2b604662c..2b6cb7f53 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -50,6 +50,8 @@ void set_default_settings(Settings *settings) settings->setDefault("keymap_toggle_update_camera", "KEY_F4"); settings->setDefault("keymap_toggle_debug", "KEY_F5"); settings->setDefault("keymap_toggle_profiler", "KEY_F6"); + settings->setDefault("keymap_increase_viewing_range_min", "KEY_PRIOR"); + settings->setDefault("keymap_decrease_viewing_range_min", "KEY_NEXT"); // Some (temporary) keys for debugging settings->setDefault("keymap_print_debug_stacks", "KEY_KEY_P"); diff --git a/src/game.cpp b/src/game.cpp index 76fdedcf0..f35b85cb6 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1507,6 +1507,36 @@ void the_game( statustext_time = 0; } } + else if(input->wasKeyDown(getKeySetting("keymap_increase_viewing_range_min"))) + { + s16 range = g_settings->getS16("viewing_range_nodes_min"); + s16 range_new = range + 10; + g_settings->set("viewing_range_nodes_min", itos(range_new)); + statustext = narrow_to_wide( + "Minimum viewing range changed from " + + itos(range) + " to " + itos(range_new)); + statustext_time = 0; + } + else if(input->wasKeyDown(getKeySetting("keymap_decrease_viewing_range_min"))) + { + s16 range = g_settings->getS16("viewing_range_nodes_min"); + s16 range_new = range - 10; + if(range_new >= 0) + { + g_settings->set("viewing_range_nodes_min", + itos(range_new)); + statustext = narrow_to_wide( + "Minimum viewing range changed from " + + itos(range) + " to " + + itos(range_new)); + statustext_time = 0; + } + else + { + statustext = L"Minimum viewing range already at minimum"; + statustext_time = 0; + } + } // Item selection with mouse wheel u16 new_playeritem = client.getPlayerItem(); -- cgit v1.2.3 From b85b4ede822b9d2d5f82c034e520341e9d86b08a Mon Sep 17 00:00:00 2001 From: Kahrl Date: Wed, 1 Feb 2012 02:37:01 +0100 Subject: Page up/down: don't display the old value, it was a little confusing --- src/game.cpp | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/game.cpp b/src/game.cpp index f35b85cb6..a1f0fe07f 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1513,29 +1513,22 @@ void the_game( s16 range_new = range + 10; g_settings->set("viewing_range_nodes_min", itos(range_new)); statustext = narrow_to_wide( - "Minimum viewing range changed from " - + itos(range) + " to " + itos(range_new)); + "Minimum viewing range changed to " + + itos(range_new)); statustext_time = 0; } else if(input->wasKeyDown(getKeySetting("keymap_decrease_viewing_range_min"))) { s16 range = g_settings->getS16("viewing_range_nodes_min"); s16 range_new = range - 10; - if(range_new >= 0) - { - g_settings->set("viewing_range_nodes_min", - itos(range_new)); - statustext = narrow_to_wide( - "Minimum viewing range changed from " - + itos(range) + " to " - + itos(range_new)); - statustext_time = 0; - } - else - { - statustext = L"Minimum viewing range already at minimum"; - statustext_time = 0; - } + if(range_new < 0) + range_new = range; + g_settings->set("viewing_range_nodes_min", + itos(range_new)); + statustext = narrow_to_wide( + "Minimum viewing range changed to " + + itos(range_new)); + statustext_time = 0; } // Item selection with mouse wheel -- cgit v1.2.3