mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
Added ScriptMessage class
This commit is contained in:
parent
ee980cbc5b
commit
f3dbfc468e
2 changed files with 79 additions and 0 deletions
22
libraries/script-engine/src/ScriptMessage.cpp
Normal file
22
libraries/script-engine/src/ScriptMessage.cpp
Normal file
|
@ -0,0 +1,22 @@
|
|||
//
|
||||
// ScriptMessage.h
|
||||
// libraries/script-engine/src/v8/FastScriptValueUtils.cpp
|
||||
//
|
||||
// Created by dr Karol Suprynowicz on 2023/09/24.
|
||||
// Copyright 2023 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "ScriptMessage.h"
|
||||
|
||||
QJsonObject ScriptMessage::toJson() {
|
||||
QJsonObject object;
|
||||
object["message"] = _messageContent;
|
||||
object["lineNumber"] = _lineNumber;
|
||||
object["fileName"] = _fileName;
|
||||
object["type"] = scriptTypeToString(_scriptType);
|
||||
object["severity"] = severityToString(_severity);
|
||||
return object;
|
||||
}
|
57
libraries/script-engine/src/ScriptMessage.h
Normal file
57
libraries/script-engine/src/ScriptMessage.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
//
|
||||
// ScriptMessage.h
|
||||
// libraries/script-engine/src/v8/FastScriptValueUtils.cpp
|
||||
//
|
||||
// Created by dr Karol Suprynowicz on 2023/09/24.
|
||||
// Copyright 2023 Overte e.V.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef OVERTE_SCRIPTMESSAGE_H
|
||||
#define OVERTE_SCRIPTMESSAGE_H
|
||||
|
||||
// Used to store script messages on entity script server before transmitting them to clients who subscribed to them.
|
||||
// EntityServerScriptLog packet type is used.
|
||||
// In the future will also be used for storing assignment client script messages before transmission
|
||||
|
||||
#include <QString>
|
||||
#include <QJsonObject>
|
||||
|
||||
class ScriptMessage {
|
||||
public:
|
||||
enum class ScriptType {
|
||||
TYPE_NONE,
|
||||
TYPE_ENTITY_SCRIPT
|
||||
};
|
||||
enum class Severity {
|
||||
SEVERITY_NONE,
|
||||
SEVERITY_PRINT,
|
||||
SEVERITY_INFO,
|
||||
SEVERITY_DEBUG,
|
||||
SEVERITY_WARNING,
|
||||
SEVERITY_ERROR
|
||||
};
|
||||
|
||||
static QString scriptTypeToString(ScriptType scriptType);
|
||||
static QString severityToString(Severity severity);
|
||||
|
||||
static ScriptType scriptTypeFromString(ScriptType scriptType);
|
||||
static Severity severityFromString(Severity severity);
|
||||
|
||||
ScriptMessage() {};
|
||||
ScriptMessage(QString messageContent, QString fileName, int lineNumber, ScriptType scriptType, Severity severity)
|
||||
: _messageContent(messageContent), _fileName(fileName), _lineNumber(lineNumber), _scriptType(scriptType) {}
|
||||
|
||||
QJsonObject toJson();
|
||||
|
||||
private:
|
||||
QString _messageContent;
|
||||
QString _fileName;
|
||||
int _lineNumber {-1};
|
||||
ScriptType _scriptType {ScriptType::TYPE_NONE};
|
||||
Severity _severity {Severity::SEVERITY_NONE};
|
||||
};
|
||||
|
||||
#endif //OVERTE_SCRIPTMESSAGE_H
|
Loading…
Reference in a new issue