485 lines
10 KiB
C++
Executable File
485 lines
10 KiB
C++
Executable File
#pragma once
|
|
|
|
#if defined(_MSC_VER)
|
|
#include <winsock2.h>
|
|
#endif
|
|
#include <vector>
|
|
#include <map>
|
|
#include <string>
|
|
#include <QJsonValue>
|
|
#include <QList>
|
|
#include <QString>
|
|
#include <exccommands.h>
|
|
|
|
class QWidget;
|
|
|
|
namespace VCtrl
|
|
{
|
|
|
|
|
|
#if defined(_MSC_VER)
|
|
using Timer_t = __int64;
|
|
#else
|
|
using Timer_t = unsigned long long;
|
|
#endif
|
|
|
|
|
|
|
|
struct Vec2
|
|
{
|
|
Vec2() = default;
|
|
Vec2(float _x, float _y) : x(_x) , y(_y) { }
|
|
|
|
float x = 0;
|
|
float y = 0;
|
|
};
|
|
|
|
|
|
|
|
struct Vec3
|
|
{
|
|
Vec3() = default;
|
|
Vec3(float _x, float _y, float _z) : x(_x) , y(_y) , z(_z) { }
|
|
|
|
float x = 0;
|
|
float y = 0;
|
|
float z = 0;
|
|
};
|
|
|
|
|
|
|
|
struct Vec3d
|
|
{
|
|
Vec3d() = default;
|
|
Vec3d(double _x, double _y, double _z) : x(_x) , y(_y) , z(_z) { }
|
|
|
|
double x = 0;
|
|
double y = 0;
|
|
double z = 0;
|
|
};
|
|
|
|
|
|
|
|
|
|
struct Color
|
|
{
|
|
Color() = default;
|
|
Color(float _x, float _y, float _z, float _w) : x(_x) , y(_y) , z(_z) , w(_w) { }
|
|
|
|
float x = 0;
|
|
float y = 0;
|
|
float z = 0;
|
|
float w = 0;
|
|
};
|
|
|
|
|
|
|
|
struct Quat
|
|
{
|
|
Quat() = default;
|
|
Quat(double _x, double _y, double _z, double _w) : x(_x) , y(_y) , z(_z) , w(_w) { }
|
|
|
|
double x = 0;
|
|
double y = 0;
|
|
double z = 0;
|
|
double w = 1;
|
|
};
|
|
|
|
|
|
|
|
enum class ZValue
|
|
{
|
|
AboveMsl,
|
|
RelativeBuildings,
|
|
};
|
|
|
|
|
|
|
|
enum class ViewMode
|
|
{
|
|
ISOMETRIC,
|
|
ORTHOGRAPHIC
|
|
};
|
|
|
|
|
|
|
|
enum class PlayerDisplayMode
|
|
{
|
|
Icons,
|
|
Dots
|
|
};
|
|
|
|
|
|
|
|
class ViewerCallback
|
|
{
|
|
public:
|
|
|
|
virtual ~ViewerCallback() = default;
|
|
|
|
|
|
|
|
virtual void SystemReady() = 0;
|
|
|
|
|
|
|
|
virtual void TransformChanged(const std::string &id, const Vec3d &pos, const Quat &attitude) = 0;
|
|
|
|
|
|
|
|
virtual void NavMeshGroupChanged(const std::string &id, const std::string &grpname) = 0;
|
|
|
|
|
|
|
|
virtual void PlayerPicked(const std::string &id) = 0;
|
|
|
|
|
|
|
|
virtual void DisplayNamePicked(const std::string& buildingid, const std::string& roomname) = 0;
|
|
|
|
|
|
|
|
virtual void ViewCreated(unsigned int contextId, ViewMode viewmode) = 0;
|
|
|
|
|
|
|
|
virtual void ViewModeChanged(unsigned int contextId, ViewMode viewmode) = 0;
|
|
|
|
|
|
|
|
virtual void ViewLineModeChanged(unsigned int contextId, bool line) = 0;
|
|
|
|
|
|
|
|
virtual void ViewNameModeChanged(unsigned int contextId, bool name) = 0;
|
|
|
|
|
|
|
|
virtual void ViewTransparencyChanged() = 0;
|
|
|
|
|
|
|
|
virtual void ViewLockRotationChanged(unsigned int contextId, bool lock) = 0;
|
|
|
|
|
|
|
|
virtual void PlayerDisplayModeChanged(unsigned int contextId, PlayerDisplayMode mode) = 0;
|
|
|
|
|
|
|
|
virtual void ViewClosed(unsigned int contextId) = 0;
|
|
|
|
virtual void HandleViewerEvent(BuildingViewer::BgViewerEvents event,
|
|
const std::vector<std::string> &args) = 0;
|
|
virtual void ViewZoomChanged(const std::string &buildingId,
|
|
double top, double left, double bottom, double right) = 0;
|
|
|
|
enum class Severity
|
|
{
|
|
Always,
|
|
Debug,
|
|
Info,
|
|
Warning,
|
|
Error,
|
|
Fatal
|
|
};
|
|
|
|
|
|
virtual void LogMessage(Severity &severity, const std::string &filename,
|
|
const std::string &methodname,
|
|
int linenumber, const std::string &msg) = 0;
|
|
|
|
};
|
|
|
|
class ViewerInterface
|
|
{
|
|
public:
|
|
|
|
virtual ~ViewerInterface() = default;
|
|
|
|
|
|
|
|
virtual void SetViewerCallback(ViewerCallback *) = 0;
|
|
virtual void RemoveViewerCallback() = 0;
|
|
|
|
|
|
|
|
virtual void SetProjectDataPaths(const std::vector<std::string> &paths) = 0;
|
|
|
|
|
|
|
|
virtual void OpenOverview() = 0;
|
|
|
|
virtual QWidget* getMainWindow() = 0;
|
|
virtual quintptr requestMainWindowHandle() = 0;
|
|
|
|
virtual void reloadPlayerIcons() = 0;
|
|
virtual void UpdatePlayerPartyColors(const std::map<std::string, VCtrl::Color>& mapPlayerColors) = 0;
|
|
|
|
|
|
|
|
|
|
virtual void UseExactPositioning(bool exactPos) = 0;
|
|
|
|
|
|
|
|
virtual bool OpenView(const std::string &buildingid, const std::string &windowtitle, const Color &bgcolor, ViewMode viewmode,
|
|
int screennum, bool fullscreen, int x, int y, int width, int height,
|
|
unsigned int &contextId, bool exactPos = true) = 0;
|
|
virtual void openViews(const std::vector<std::string> &bldIds, bool exactPos) = 0;
|
|
|
|
|
|
|
|
virtual bool isViewOpen(const std::string &bldId) const = 0;
|
|
|
|
|
|
|
|
|
|
virtual void CloseView(unsigned int contextid) = 0;
|
|
virtual void closeViews(const std::vector<std::string> &bldIds) = 0;
|
|
|
|
|
|
|
|
virtual void ChangeViewMode(unsigned int contextId, ViewMode viewmode) = 0;
|
|
virtual void setViewMode(ViewMode m) = 0;
|
|
|
|
|
|
|
|
virtual void ChangeLineMode(unsigned int contextId, bool line) = 0;
|
|
|
|
|
|
|
|
virtual void ChangeNameMode(unsigned int contextId, bool name) = 0;
|
|
|
|
|
|
|
|
|
|
virtual void LockViewRotationToMapRotation(unsigned int contextId, bool lock) = 0;
|
|
|
|
|
|
|
|
virtual void SetPlayerDisplayMode(unsigned int contextId, PlayerDisplayMode mode) = 0;
|
|
virtual void setDisplayMode(PlayerDisplayMode m) = 0;
|
|
|
|
|
|
|
|
virtual void SetWallTransparency(unsigned int contextId, float transparency) = 0;
|
|
virtual void setTransparency(double percent) = 0;
|
|
|
|
|
|
|
|
virtual float GetMapRotation() const = 0;
|
|
|
|
|
|
|
|
virtual void SetMapRotation(float angle) = 0;
|
|
|
|
|
|
|
|
virtual bool LoadBuildingPositionMap(const std::string &path, bool loadAllAvailableBuildings) = 0;
|
|
|
|
|
|
|
|
virtual void CreatePlayer(const std::string &id, const std::string &iconpath, const Color &color) = 0;
|
|
|
|
|
|
|
|
virtual void DeletePlayer(const std::string &id, float seconds = 0) = 0;
|
|
|
|
|
|
|
|
virtual void SetPlayerColor(const std::string &id, const Color &color) = 0;
|
|
|
|
|
|
|
|
virtual void SetPlayerIcon(const std::string &id, const std::string &path) = 0;
|
|
|
|
|
|
|
|
virtual size_t GetNumPlayers() const = 0;
|
|
|
|
|
|
|
|
virtual void GetPlayerIds(std::vector<std::string> &toFill) = 0;
|
|
|
|
|
|
|
|
virtual void SetPlayerShown(const std::string &id, bool show, double when = -1) = 0;
|
|
|
|
|
|
|
|
virtual size_t GetNumBuildings() const = 0;
|
|
|
|
|
|
|
|
virtual void GetBuildingIds(std::vector<std::string> &toFill) const = 0;
|
|
|
|
|
|
|
|
virtual void SetShowSelectionBox(const std::string &id,
|
|
bool show,
|
|
float duration = -1) = 0;
|
|
|
|
|
|
|
|
virtual void Shoot(const int id,
|
|
const std::string &shooterId,
|
|
const std::string &targetId,
|
|
const Vec3d &shooterPos,
|
|
const Vec3d &targetPos,
|
|
int buildingIdSrc,
|
|
int roomNumberSrc,
|
|
int buildingIdDst,
|
|
int roomNumberDst,
|
|
int lineType,
|
|
double when) = 0;
|
|
|
|
|
|
|
|
virtual void Shoot(const int id,
|
|
const std::string &shooterId,
|
|
const std::string &targetBuildingId,
|
|
const std::string &targetRoomId,
|
|
const Vec3d &shooterPos,
|
|
int lineType,
|
|
double when) = 0;
|
|
|
|
|
|
|
|
virtual void removeShoot(const int id) = 0;
|
|
|
|
|
|
|
|
|
|
virtual void Teleport(const std::string &id,
|
|
double when,
|
|
const Vec3d &target,
|
|
const std::string &bldgname,
|
|
int roomNumber,
|
|
const std::string &roomname,
|
|
ZValue zval) = 0;
|
|
|
|
|
|
virtual void GetRoomNames(const std::string &id, std::vector<std::string> &names) = 0;
|
|
|
|
|
|
|
|
virtual bool SetRoomDestructionValue(const std::string &id,
|
|
const std::string &roomname,
|
|
float value) = 0;
|
|
|
|
|
|
|
|
virtual bool SetBuildingDestructionValue(const std::string &id, float value) = 0;
|
|
|
|
|
|
|
|
virtual void GetDeviceNames(const std::string &buildingid, std::vector<std::string> &names) = 0;
|
|
|
|
|
|
|
|
virtual bool ShowDeviceIcon(const std::string &id, const std::string &buildingid,
|
|
const std::string &devicename, const std::string &iconpath) = 0;
|
|
|
|
|
|
|
|
virtual bool ShowDeviceIcon(const std::string &id, const std::string &buildingid,
|
|
const Vec3d &position, const std::string &iconpath) = 0;
|
|
|
|
|
|
|
|
|
|
virtual bool HideDeviceIcon(const std::string &id) = 0;
|
|
|
|
|
|
|
|
virtual bool SetDisplayName(const std::string& buildingid, const std::string& roomname,
|
|
const std::string& strDisplayName) = 0;
|
|
|
|
|
|
|
|
virtual void ShowDisplayNames(const std::string& buildingid, bool show) = 0;
|
|
|
|
|
|
|
|
virtual void SetShowDisplayNamesSelectionBox(const std::string& buildingid,
|
|
const std::string& id,
|
|
bool show,
|
|
float duration = -1) = 0;
|
|
|
|
|
|
|
|
virtual float GetTimeScale() const = 0;
|
|
|
|
|
|
|
|
virtual void SetTimeScale(float scale) = 0;
|
|
|
|
|
|
|
|
virtual void SetSimulationTime(double t) = 0;
|
|
|
|
|
|
|
|
virtual double GetSimulationTime() const = 0;
|
|
|
|
|
|
|
|
virtual void SetPaused(bool) = 0;
|
|
virtual bool GetPaused() const = 0;
|
|
|
|
|
|
|
|
virtual void SetNonRealtimeMode(bool on) = 0;
|
|
|
|
|
|
|
|
virtual bool GetNonRealtimeMode() const = 0;
|
|
|
|
|
|
|
|
virtual void FastForwardSimulationTo(double t) = 0;
|
|
|
|
|
|
|
|
virtual void DeleteQueuedCommands() = 0;
|
|
|
|
|
|
|
|
virtual bool StartVideoRecording(unsigned int contextid, const std::string &path,
|
|
int w, int h, int framerate, int quality) = 0;
|
|
virtual bool StartVideoRecording(const std::string &buildingId, const std::string &path,
|
|
int w, int h, int framerate, int quality) = 0;
|
|
|
|
|
|
|
|
virtual bool StopVideoRecording(unsigned int contextid) = 0;
|
|
virtual bool StopVideoRecording(const std::string &buildingId) = 0;
|
|
|
|
|
|
virtual QJsonValue getViewState() const = 0;
|
|
virtual void setViewState(const QJsonValue &val) = 0;
|
|
virtual void highlightView(const std::string &buildingId) = 0;
|
|
virtual void setBuildingDisplayName(const std::string &buildingId, const std::string &displayName) = 0;
|
|
|
|
virtual void setHitLineDuration(uint32_t durationSec) = 0;
|
|
struct MountingPointDescription
|
|
{
|
|
std::string buildingId;
|
|
std::string mountingPointId;
|
|
Vec3d position;
|
|
BuildingViewer::AssetTypes assetType;
|
|
};
|
|
virtual void setMountingPointAsset(const MountingPointDescription &asset) = 0;
|
|
|
|
struct BuildingState
|
|
{
|
|
std::string buildingId;
|
|
std::string description;
|
|
int entityId = 0;
|
|
bool isShown = false;
|
|
};
|
|
virtual std::vector<BuildingState> getBuildingState() const = 0;
|
|
};
|
|
}
|