Merge branch 'tmj-dev' into milek-dev

This commit is contained in:
milek7
2018-10-01 21:00:27 +02:00
47 changed files with 1674 additions and 972 deletions

View File

@@ -19,7 +19,6 @@ http://mozilla.org/MPL/2.0/.
#include "gamepadinput.h"
#include "Console.h"
#include "simulation.h"
#include "PyInt.h"
#include "sceneeditor.h"
#include "renderer.h"
#include "uilayer.h"
@@ -138,6 +137,7 @@ eu07_application::init( int Argc, char *Argv[] ) {
if( ( result = init_audio() ) != 0 ) {
return result;
}
m_taskqueue.init();
if( ( result = init_modes() ) != 0 ) {
return result;
}
@@ -149,7 +149,7 @@ int
eu07_application::run() {
// main application loop
while( ( false == glfwWindowShouldClose( m_window ) )
while( ( false == glfwWindowShouldClose( m_windows.front() ) )
&& ( false == m_modestack.empty() )
&& ( true == m_modes[ m_modestack.top() ]->update() )
&& ( true == GfxRenderer.Render() ) ) {
@@ -167,6 +167,12 @@ eu07_application::run() {
return 0;
}
bool
eu07_application::request( python_taskqueue::task_request const &Task ) {
return m_taskqueue.insert( Task );
}
void
eu07_application::exit() {
@@ -175,10 +181,11 @@ eu07_application::exit() {
ui_layer::shutdown();
glfwDestroyWindow( m_window );
for( auto *window : m_windows ) {
glfwDestroyWindow( window );
}
glfwTerminate();
TPythonInterpreter::killInstance();
m_taskqueue.exit();
}
void
@@ -213,7 +220,7 @@ eu07_application::push_mode( eu07_application::mode const Mode ) {
void
eu07_application::set_title( std::string const &Title ) {
glfwSetWindowTitle( m_window, Title.c_str() );
glfwSetWindowTitle( m_windows.front(), Title.c_str() );
}
void
@@ -233,17 +240,13 @@ eu07_application::set_cursor( int const Mode ) {
void
eu07_application::set_cursor_pos( double const Horizontal, double const Vertical ) {
if( m_window != nullptr ) {
glfwSetCursorPos( m_window, Horizontal, Vertical );
}
glfwSetCursorPos( m_windows.front(), Horizontal, Vertical );
}
void
eu07_application::get_cursor_pos( double &Horizontal, double &Vertical ) const {
if( m_window != nullptr ) {
glfwGetCursorPos( m_window, &Horizontal, &Vertical );
}
glfwGetCursorPos( m_windows.front(), &Horizontal, &Vertical );
}
void
@@ -297,6 +300,24 @@ void eu07_application::on_char(unsigned int c) {
return;
}
GLFWwindow *
eu07_application::window( int const Windowindex ) {
if( Windowindex >= 0 ) {
return (
Windowindex < m_windows.size() ?
m_windows[ Windowindex ] :
nullptr );
}
// for index -1 create a new child window
glfwWindowHint( GLFW_VISIBLE, GL_FALSE );
auto *childwindow = glfwCreateWindow( 1, 1, "eu07helper", nullptr, m_windows.front() );
if( childwindow != nullptr ) {
m_windows.emplace_back( childwindow );
}
return childwindow;
}
// private:
void
@@ -427,7 +448,7 @@ eu07_application::init_glfw() {
// switch off the topmost flag
::SetWindowPos( Hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE );
#endif
m_window = window;
m_windows.emplace_back( window );
return 0;
}
@@ -435,17 +456,18 @@ eu07_application::init_glfw() {
void
eu07_application::init_callbacks() {
glfwSetFramebufferSizeCallback( m_window, window_resize_callback );
glfwSetCursorPosCallback( m_window, cursor_pos_callback );
glfwSetMouseButtonCallback( m_window, mouse_button_callback );
glfwSetKeyCallback( m_window, key_callback );
glfwSetScrollCallback( m_window, scroll_callback );
glfwSetCharCallback(m_window, char_callback);
glfwSetWindowFocusCallback( m_window, focus_callback );
auto *window { m_windows.front() };
glfwSetFramebufferSizeCallback( window, window_resize_callback );
glfwSetCursorPosCallback( window, cursor_pos_callback );
glfwSetMouseButtonCallback( window, mouse_button_callback );
glfwSetKeyCallback( window, key_callback );
glfwSetScrollCallback( window, scroll_callback );
glfwSetCharCallback(window, char_callback);
glfwSetWindowFocusCallback( window, focus_callback );
{
int width, height;
glfwGetFramebufferSize( m_window, &width, &height );
window_resize_callback( m_window, width, height );
glfwGetFramebufferSize( window, &width, &height );
window_resize_callback( window, width, height );
}
}
@@ -457,10 +479,10 @@ eu07_application::init_gfx() {
return -1;
}
if (!ui_layer::init(m_window))
if (!ui_layer::init(m_windows.front()))
return -1;
if (!GfxRenderer.Init(m_window))
if (!GfxRenderer.Init(m_windows.front()))
return -1;
return 0;