1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Move KeyList & InputHandler from game.h to client/inputhandler.h (#5752)

* Move KeyList & InputHandler from game.h to client/inputhandler.h

We have a header for inputs, move inputhandler class & related keylist object to it

Also introduce a cpp file for MyEventReceiver::OnEvent function in inputhandler.h because a so huge function doesn't needs to be inlined

* Pass clang-format on inputhandler.{cpp,h} (compatible)
This commit is contained in:
Loïc Blot 2017-05-13 11:05:16 +02:00 committed by GitHub
parent 5cb7f6a9b7
commit 9b8ca3a746
9 changed files with 284 additions and 365 deletions

View file

@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <iomanip>
#include "camera.h"
#include "client.h"
#include "client/inputhandler.h"
#include "client/tile.h" // For TextureSource
#include "client/keys.h"
#include "client/joystick_controller.h"
@ -50,7 +51,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "quicktune_shortcutter.h"
#include "server.h"
#include "settings.h"
#include "shader.h" // For ShaderSource
#include "sky.h"
#include "subgame.h"
#include "tool.h"
@ -59,20 +59,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/pointedthing.h"
#include "irrlicht_changes/static_text.h"
#include "version.h"
#include "minimap.h"
#include "mapblock_mesh.h"
#include "script/scripting_client.h"
#include "sound.h"
#if USE_SOUND
#include "sound_openal.h"
#endif
#ifdef HAVE_TOUCHSCREENGUI
#include "touchscreengui.h"
#endif
extern Settings *g_settings;
extern Profiler *g_profiler;
@ -2434,7 +2426,7 @@ void Game::updateStats(RunStats *stats, const FpsControl &draw_times,
void Game::processUserInput(f32 dtime)
{
// Reset input if window not active or some menu is active
if (!device->isWindowActive() || !noMenuActive() || guienv->hasFocus(gui_chat_console)) {
if (!device->isWindowActive() || isMenuActive() || guienv->hasFocus(gui_chat_console)) {
input->clear();
#ifdef HAVE_TOUCHSCREENGUI
g_touchscreengui->hide();
@ -2964,7 +2956,7 @@ void Game::toggleFullViewRange()
void Game::updateCameraDirection(CameraOrientation *cam, float dtime)
{
if ((device->isWindowActive() && noMenuActive()) || random_input) {
if ((device->isWindowActive() && !isMenuActive()) || random_input) {
#ifndef __ANDROID__
if (!random_input) {
@ -3709,12 +3701,9 @@ PointedThing Game::updatePointedThing(
float sin_r = 0.08 * sin(timerf);
float sin_g = 0.08 * sin(timerf + irr::core::PI * 0.5);
float sin_b = 0.08 * sin(timerf + irr::core::PI);
c.setRed(
core::clamp(core::round32(c.getRed() * (0.8 + sin_r)), 0, 255));
c.setGreen(
core::clamp(core::round32(c.getGreen() * (0.8 + sin_g)), 0, 255));
c.setBlue(
core::clamp(core::round32(c.getBlue() * (0.8 + sin_b)), 0, 255));
c.setRed(core::clamp(core::round32(c.getRed() * (0.8 + sin_r)), 0, 255));
c.setGreen(core::clamp(core::round32(c.getGreen() * (0.8 + sin_g)), 0, 255));
c.setBlue(core::clamp(core::round32(c.getBlue() * (0.8 + sin_b)), 0, 255));
// Set mesh final color
hud->setSelectionMeshColor(c);
@ -4183,7 +4172,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
if (current_formspec->getReferenceCount() == 1) {
current_formspec->drop();
current_formspec = NULL;
} else if (!noMenuActive()) {
} else if (isMenuActive()) {
guiroot->bringToFront(current_formspec);
}
}