mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 04:19:19 +02:00
refactoring: application mode code split
This commit is contained in:
55
editormouseinput.cpp
Normal file
55
editormouseinput.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "editormouseinput.h"
|
||||
|
||||
bool
|
||||
editormouse_input::init() {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
editormouse_input::position( double Horizontal, double Vertical ) {
|
||||
|
||||
if( false == m_pickmodepanning ) {
|
||||
// even if the view panning isn't active we capture the cursor position in case it does get activated
|
||||
m_cursorposition.x = Horizontal;
|
||||
m_cursorposition.y = Vertical;
|
||||
return;
|
||||
}
|
||||
glm::dvec2 cursorposition { Horizontal, Vertical };
|
||||
auto const viewoffset = cursorposition - m_cursorposition;
|
||||
m_relay.post(
|
||||
user_command::viewturn,
|
||||
viewoffset.x,
|
||||
viewoffset.y,
|
||||
GLFW_PRESS,
|
||||
// as we haven't yet implemented either item id system or multiplayer, the 'local' controlled vehicle and entity have temporary ids of 0
|
||||
// TODO: pass correct entity id once the missing systems are in place
|
||||
0 );
|
||||
m_cursorposition = cursorposition;
|
||||
}
|
||||
|
||||
void
|
||||
editormouse_input::button( int const Button, int const Action ) {
|
||||
|
||||
// store key state
|
||||
if( Button >= 0 ) {
|
||||
m_buttons[ Button ] = Action;
|
||||
}
|
||||
|
||||
// right button controls panning
|
||||
if( Button == GLFW_MOUSE_BUTTON_RIGHT ) {
|
||||
m_pickmodepanning = ( Action == GLFW_PRESS );
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
Reference in New Issue
Block a user