mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
on-screen log
This commit is contained in:
@@ -622,6 +622,10 @@ global_settings::ConfigParse(cParser &Parser) {
|
||||
Parser.getTokens( 1 );
|
||||
Parser >> uart_conf.debug;
|
||||
}
|
||||
else if (token == "loadinglog") {
|
||||
Parser.getTokens( 1 );
|
||||
Parser >> loading_log;
|
||||
}
|
||||
} while ((token != "") && (token != "endconfig")); //(!Parser->EndOfFile)
|
||||
// na koniec trochę zależności
|
||||
if (!bLoadTraction) // wczytywanie drutów i słupów
|
||||
|
||||
@@ -166,6 +166,7 @@ struct global_settings {
|
||||
std::string asVersion{ "UNKNOWN" }; // z opisem
|
||||
motiontelemetry::conf_t motiontelemetry_conf;
|
||||
std::string screenshot_dir;
|
||||
bool loading_log = true;
|
||||
|
||||
// methods
|
||||
void LoadIniFile( std::string asFileName );
|
||||
|
||||
9
Logs.cpp
9
Logs.cpp
@@ -13,6 +13,9 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "Globals.h"
|
||||
#include "winheaders.h"
|
||||
#include "utilities.h"
|
||||
#include "uilayer.h"
|
||||
|
||||
std::shared_ptr<ui_panel> ui_log = std::make_shared<ui_panel>( 20, 140 );
|
||||
|
||||
std::ofstream output; // standardowy "log.txt", można go wyłączyć
|
||||
std::ofstream errors; // lista błędów "errors.txt", zawsze działa
|
||||
@@ -82,6 +85,10 @@ void WriteLog( const char *str, logtype const Type ) {
|
||||
output.flush();
|
||||
}
|
||||
|
||||
ui_log->text_lines.emplace_back(std::string(str), Global.UITextColor);
|
||||
if (ui_log->text_lines.size() > 20)
|
||||
ui_log->text_lines.pop_front();
|
||||
|
||||
#ifdef _WIN32
|
||||
if( Global.iWriteLogEnabled & 2 ) {
|
||||
// hunter-271211: pisanie do konsoli tylko, gdy nie jest ukrywana
|
||||
@@ -90,6 +97,8 @@ void WriteLog( const char *str, logtype const Type ) {
|
||||
WriteConsole( GetStdHandle( STD_OUTPUT_HANDLE ), str, (DWORD)strlen( str ), &wr, NULL );
|
||||
WriteConsole( GetStdHandle( STD_OUTPUT_HANDLE ), endstring, (DWORD)strlen( endstring ), &wr, NULL );
|
||||
}
|
||||
#else
|
||||
printf("%s\n", str);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
4
Logs.h
4
Logs.h
@@ -9,7 +9,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "uilayer.h"
|
||||
|
||||
enum logtype : unsigned int {
|
||||
|
||||
@@ -26,3 +26,5 @@ void ErrorLog( const std::string &str, logtype const Type = logtype::generic );
|
||||
void WriteLog( const std::string &str, logtype const Type = logtype::generic );
|
||||
void CommLog( const char *str );
|
||||
void CommLog( const std::string &str );
|
||||
|
||||
extern std::shared_ptr<ui_panel> ui_log;
|
||||
|
||||
@@ -245,6 +245,8 @@ bool TWorld::Init( GLFWwindow *Window ) {
|
||||
WriteLog( "\nStarting MaSzyna rail vehicle simulator (release: " + Global.asVersion + ")" );
|
||||
WriteLog( "For online documentation and additional files refer to: http://eu07.pl");
|
||||
|
||||
if (Global.loading_log)
|
||||
UILayer.push_back( ui_log );
|
||||
UILayer.set_background( "logo" );
|
||||
glfwSetWindowTitle( window, ( Global.AppName + " (" + Global.SceneryFile + ")" ).c_str() ); // nazwa scenerii
|
||||
UILayer.set_progress(0.01);
|
||||
@@ -342,6 +344,8 @@ bool TWorld::Init( GLFWwindow *Window ) {
|
||||
UILayer.push_back( UIHeader );
|
||||
UILayer.push_back( UITable );
|
||||
UILayer.push_back( UITranscripts );
|
||||
UILayer.push_back( ui_log );
|
||||
ui_log->enabled = false;
|
||||
|
||||
return true;
|
||||
};
|
||||
@@ -596,6 +600,10 @@ void TWorld::OnKeyDown(int cKey) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GLFW_KEY_F11: {
|
||||
ui_log->enabled = !ui_log->enabled;
|
||||
break;
|
||||
}
|
||||
case GLFW_KEY_F12: {
|
||||
// coś tam jeszcze
|
||||
if( Global.ctrlState
|
||||
|
||||
@@ -193,6 +193,8 @@ ui_layer::render_panels() {
|
||||
float const height = Global.iWindowHeight / 768.f;
|
||||
|
||||
for( auto const &panel : m_panels ) {
|
||||
if (!panel->enabled)
|
||||
continue;
|
||||
|
||||
int lineidx = 0;
|
||||
for( auto const &line : panel->text_lines ) {
|
||||
|
||||
Reference in New Issue
Block a user