Skyscraper 2.0
hal.h
Go to the documentation of this file.
1/*
2 Skyscraper 2.0 - Hardware Abstraction Layer
3 Copyright (C)2004-2024 Ryan Thoryk
4 https://www.skyscrapersim.net
5 https://sourceforge.net/projects/skyscraper/
6 Contact - ryan@skyscrapersim.net
7
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21*/
22
23#ifndef HAL_H
24#define HAL_H
25
26#include <OgrePrerequisites.h>
27#include <OgreCommon.h>
28#include <Ogre.h>
29#include <OgreLog.h>
30#include <OgreTrays.h>
31#ifndef DISABLE_SOUND
32 #include <fmod.hpp>
33#endif
34#include "vm.h"
35
36namespace Ogre {
37 class SceneNode;
38 class Rectangle2D;
39 class ConfigFile;
40 class OverlaySystem;
41}
42
43namespace FMOD {
44 class System;
45 class Sound;
46 class Channel;
47}
48
49namespace Skyscraper {
50
51class VMIMPEXP HAL : public Ogre::LogListener
52{
53public:
54 HAL(VM *vm);
55 ~HAL();
56 bool Initialize(const std::string &data_path, Ogre::Root *root = 0, Ogre::OverlaySystem *overlay = 0);
57 bool Render();
58 void ClickedObject(bool left, bool shift, bool ctrl, bool alt, bool right, Real scale, bool center_only);
59 void UnclickedObject();
60 int GetConfigInt(Ogre::ConfigFile *file, const std::string &key, int default_value);
61 std::string GetConfigString(Ogre::ConfigFile *file, const std::string &key, const std::string &default_value);
62 bool GetConfigBool(Ogre::ConfigFile *file, const std::string &key, bool default_value);
63 Real GetConfigFloat(Ogre::ConfigFile *file, const std::string &key, Real default_value);
64 bool PlaySound(const std::string &filename, Real volume = 1.0);
65 void StopSound();
66 void ClearScene();
67 void ToggleStats();
68 void EnableStats(bool value);
69 FMOD::System* GetSoundSystem();
70 Ogre::RenderWindow* GetRenderWindow();
71 void Clear();
72 Ogre::SceneManager* GetSceneManager();
73 Ogre::RenderWindow* CreateRenderWindow(const std::string &name, int width, int height, const Ogre::NameValuePairList &params);
74 void DestroyRenderWindow();
75 void RefreshViewport();
76 void UpdateOpenXR();
77 void ReInit();
78 void Report(const std::string &message, const std::string &prompt);
79 bool ReportError(const std::string &message, const std::string &prompt);
80 bool ReportFatalError(const std::string &message, const std::string &prompt);
81 void LoadConfiguration(const std::string data_path, bool show_console);
82 bool LoadSystem(const std::string &data_path, Ogre::RenderWindow *renderwindow);
83 void ConsoleOut(const std::string &message, const std::string &color = "white");
84 std::string GetColors(const std::string &color);
85 unsigned long GetCurrentTime();
86
87 bool RTSS;
88 std::string Renderer;
90 std::vector<Ogre::Camera*> mCameras;
91 Ogre::Root* mRoot;
92 Ogre::RenderWindow* mRenderWindow;
93 std::vector<Ogre::Viewport*> mViewports;
94 bool DX11;
95
96 //config files
97 Ogre::ConfigFile *configfile;
98 Ogre::ConfigFile *keyconfigfile;
99 Ogre::ConfigFile *joyconfigfile;
100
101private:
102
103 //OGRE engine data
104 Ogre::SceneManager* mSceneMgr;
105 Ogre::OverlaySystem* mOverlaySystem;
106
107 //OGRE log manager
108 Ogre::LogManager* logger;
109 Ogre::Log* log;
110
111 //sound data
112 FMOD::System *soundsys;
113 FMOD::Sound *sound;
114 FMOD::Channel *channel;
115
116 //reporting functions
117 void Report(const std::string &message);
118 bool ReportError(const std::string &message);
119 bool ReportFatalError(const std::string &message);
120 Ogre::ConfigFile* ConfigLoad(const std::string &filename, bool delete_after_use = false);
121 void messageLogged(const std::string &message, Ogre::LogMessageLevel lml, bool maskDebug, const std::string &logName, bool &skipThisMessage);
122
123 //stats
124 OgreBites::TrayManager* mTrayMgr;
126
127 //Ogre timer
128 Ogre::Timer *timer;
129
131};
132
133}
134
135#endif
136
OgreBites::TrayManager * mTrayMgr
Definition hal.h:124
bool DX11
Definition hal.h:94
bool DisableSound
Definition hal.h:89
Ogre::LogManager * logger
Definition hal.h:108
Ogre::ConfigFile * joyconfigfile
Definition hal.h:99
Ogre::ConfigFile * keyconfigfile
Definition hal.h:98
std::string Renderer
Definition hal.h:88
bool RTSS
Definition hal.h:87
FMOD::Sound * sound
Definition hal.h:113
std::vector< Ogre::Viewport * > mViewports
Definition hal.h:93
Ogre::RenderWindow * mRenderWindow
Definition hal.h:92
Ogre::Timer * timer
Definition hal.h:128
FMOD::Channel * channel
Definition hal.h:114
std::vector< Ogre::Camera * > mCameras
Definition hal.h:90
Ogre::SceneManager * mSceneMgr
Definition hal.h:104
int show_stats
Definition hal.h:125
FMOD::System * soundsys
Definition hal.h:112
Ogre::Root * mRoot
Definition hal.h:91
Ogre::OverlaySystem * mOverlaySystem
Definition hal.h:105
Ogre::Log * log
Definition hal.h:109
Ogre::ConfigFile * configfile
Definition hal.h:97
Ogre::Real Real
Definition globals.h:57
std::string GetColors(const std::string &color)
std::string prompt
Definition vmconsole.cpp:44
#define VMIMPEXP
Definition vm.h:49