16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-19 03:09:18 +02:00

cameraview dummy

This commit is contained in:
milek7
2019-04-09 00:00:43 +02:00
parent 4931d6d6f8
commit fe0a4bdf1d
7 changed files with 64 additions and 2 deletions

View File

@@ -131,6 +131,7 @@ set(SOURCES
"widgets/vehicleparams.cpp"
"widgets/trainingcard.cpp"
"widgets/perfgraphs.cpp"
"widgets/cameraview.cpp"
"ref/glad/src/glad.c"

View File

@@ -34,6 +34,7 @@ driver_ui::driver_ui() {
add_external_panel( &m_mappanel );
add_external_panel( &m_logpanel );
add_external_panel( &m_perfgraphpanel );
add_external_panel( &m_cameraviewpanel );
m_logpanel.is_open = false;
m_aidpanel.title = locale::strings[ locale::string::driver_aid_header ];
@@ -62,7 +63,9 @@ void driver_ui::render_menu_contents() {
ImGui::MenuItem(m_mappanel.name().c_str(), "Tab", &m_mappanel.is_open);
ImGui::MenuItem(m_vehiclelist.name().c_str(), nullptr, &m_vehiclelist.is_open);
ImGui::MenuItem(m_trainingcardpanel.name().c_str(), nullptr, &m_trainingcardpanel.is_open);
ImGui::MenuItem(m_perfgraphpanel.name().c_str(), nullptr, &m_perfgraphpanel.is_open);
ImGui::MenuItem(m_cameraviewpanel.name().c_str(), nullptr, &m_cameraviewpanel.is_open);
if (DebugModeFlag)
ImGui::MenuItem(m_perfgraphpanel.name().c_str(), nullptr, &m_perfgraphpanel.is_open);
if (ImGui::MenuItem(m_timepanel.name().c_str()))
m_timepanel.open();

View File

@@ -18,6 +18,7 @@ http://mozilla.org/MPL/2.0/.
#include "widgets/map.h"
#include "widgets/time.h"
#include "widgets/trainingcard.h"
#include "widgets/cameraview.h"
#include "widgets/perfgraphs.h"
class driver_ui : public ui_layer {
@@ -57,7 +58,7 @@ private:
timetable_panel m_timetablepanel { "Timetable", false };
debug_panel m_debugpanel { "Debug Data", false };
transcripts_panel m_transcriptspanel { "Transcripts", true }; // voice transcripts
trainingcard_panel m_trainingcardpanel;
trainingcard_panel m_trainingcardpanel;
perfgraph_panel m_perfgraphpanel;
bool m_paused { false };
bool m_pause_modal_opened { false };
@@ -66,4 +67,5 @@ private:
ui::vehiclelist_panel m_vehiclelist { ui::vehiclelist_panel(*this) };
ui::map_panel m_mappanel;
ui::time_panel m_timepanel;
ui::cameraview_panel m_cameraviewpanel;
};

View File

@@ -123,6 +123,8 @@ init() {
"Move +500m",
"Move -500m",
"Camera preview",
"master controller",
"master controller",
"second controller",
@@ -331,6 +333,8 @@ init() {
u8"Przesuń +500m",
u8"Przesuń -500m",
u8"Podgląd kamery",
u8"nastawnik jazdy",
u8"nastawnik jazdy",
u8"nastawnik dodatkowy",

View File

@@ -112,6 +112,8 @@ enum string {
vehicleparams_move500f,
vehicleparams_move500b,
cameraview_window,
cab_mainctrl,
cab_jointctrl,
cab_scndctrl,

30
widgets/cameraview.cpp Normal file
View File

@@ -0,0 +1,30 @@
#include "widgets/cameraview.h"
ui::cameraview_panel::cameraview_panel()
: ui_panel(LOC_STR(cameraview_window), false)
{
}
void ui::cameraview_panel::render()
{
if (!is_open && !exit_thread)
exit_thread = true;
ui_panel::render();
}
void ui::cameraview_panel::render_contents()
{
if (exit_thread) {
if (workthread.joinable())
workthread.join();
workthread = std::thread(&cameraview_panel::workthread_func, this);
exit_thread = false;
}
}
void ui::cameraview_panel::workthread_func()
{
while (!exit_thread);
std::this_thread::sleep_for(std::chrono::seconds(1));
}

20
widgets/cameraview.h Normal file
View File

@@ -0,0 +1,20 @@
#include "stdafx.h"
#include "uilayer.h"
#include "translation.h"
namespace ui
{
class cameraview_panel : public ui_panel
{
std::atomic_bool exit_thread = true;
std::thread workthread;
void workthread_func();
public:
cameraview_panel();
void render() override;
void render_contents() override;
};
} // namespace ui