Browse Source

Split Log class from Console

Thomas Buck 10 years ago
parent
commit
f00fb80309

+ 1
- 0
ChangeLog.md View File

7
     * World now using smart pointers
7
     * World now using smart pointers
8
     * Removed atexit handler, now breaking out of main loop on quit
8
     * Removed atexit handler, now breaking out of main loop on quit
9
     * Added calculate and shutdown calls to UI interface, properly shutting down imgui
9
     * Added calculate and shutdown calls to UI interface, properly shutting down imgui
10
+    * Created Log class holding logging infos, used by others instead of Console.
10
 
11
 
11
     [ 20140903 ]
12
     [ 20140903 ]
12
     * Finishing imgui integration, but now as UI layer and not on top of everything
13
     * Finishing imgui integration, but now as UI layer and not on top of everything

+ 0
- 1
TODO.md View File

9
 * Add verbose command line flag for debug output also in release builds
9
 * Add verbose command line flag for debug output also in release builds
10
 * Don’t depend on setup: no data or config files should be necessary
10
 * Don’t depend on setup: no data or config files should be necessary
11
 * Be able to change configuration from within OpenRaider
11
 * Be able to change configuration from within OpenRaider
12
-* Put log functionality outside of Console
13
 
12
 
14
 ## Bugs
13
 ## Bugs
15
 
14
 

+ 0
- 19
include/Console.h View File

9
 #define _CONSOLE_H_
9
 #define _CONSOLE_H_
10
 
10
 
11
 #include <string>
11
 #include <string>
12
-#include <sstream>
13
 #include <vector>
12
 #include <vector>
14
 
13
 
15
 #include "UI.h"
14
 #include "UI.h"
23
     Console();
22
     Console();
24
     ~Console();
23
     ~Console();
25
 
24
 
26
-    template<typename T>
27
-    Console &operator<<(const T t) {
28
-        printBuffer << t;
29
-        if (printBuffer.str().back() == '\n') {
30
-            mHistory.push_back(printBuffer.str().substr(0, printBuffer.str().length() - 1));
31
-#ifdef DEBUG
32
-            std::cout << printBuffer.str().substr(0, printBuffer.str().length() - 1) << std::endl;
33
-#endif
34
-            printBuffer.str("");
35
-        }
36
-        return (*this);
37
-    }
38
-
39
     virtual void moveToTop();
25
     virtual void moveToTop();
40
     virtual void makeInvisible();
26
     virtual void makeInvisible();
41
     virtual void display();
27
     virtual void display();
43
     virtual void handleText(char *text, bool notFinished);
29
     virtual void handleText(char *text, bool notFinished);
44
     virtual void handleMouseScroll(int xrel, int yrel);
30
     virtual void handleMouseScroll(int xrel, int yrel);
45
 
31
 
46
-    const static char endl = '\n';
47
-
48
 private:
32
 private:
49
 
33
 
50
     void moveInHistory(bool up);
34
     void moveInHistory(bool up);
51
 
35
 
52
     std::string mInputBuffer;
36
     std::string mInputBuffer;
53
     std::string mPartialInput;
37
     std::string mPartialInput;
54
-    std::vector<std::string> mHistory;
55
 
38
 
56
     size_t mHistoryPointer;
39
     size_t mHistoryPointer;
57
     std::vector<std::string> mCommandHistory;
40
     std::vector<std::string> mCommandHistory;
58
     std::string mUnfinishedInput;
41
     std::string mUnfinishedInput;
59
 
42
 
60
     unsigned int mLineOffset;
43
     unsigned int mLineOffset;
61
-
62
-    std::ostringstream printBuffer;
63
 };
44
 };
64
 
45
 
65
 Console &getConsole();
46
 Console &getConsole();

+ 45
- 0
include/Log.h View File

1
+/*!
2
+ * \file include/Log.h
3
+ * \brief Log
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#ifndef _LOG_H_
9
+#define _LOG_H_
10
+
11
+#include <string>
12
+#include <sstream>
13
+#include <vector>
14
+
15
+class Log {
16
+public:
17
+
18
+    const static char endl = '\n';
19
+
20
+    ~Log();
21
+
22
+    unsigned long size();
23
+    std::string get(unsigned long i);
24
+
25
+    template<typename T>
26
+    Log& operator<< (const T t) {
27
+        printBuffer << t;
28
+        if (printBuffer.str().back() == endl) {
29
+            mHistory.push_back(printBuffer.str().substr(0, printBuffer.str().length() - 1));
30
+#ifdef DEBUG
31
+            std::cout << printBuffer.str().substr(0, printBuffer.str().length() - 1) << std::endl;
32
+#endif
33
+            printBuffer.str("");
34
+        }
35
+        return (*this);
36
+    }
37
+
38
+private:
39
+    std::vector<std::string> mHistory;
40
+    std::ostringstream printBuffer;
41
+};
42
+
43
+Log &getLog();
44
+
45
+#endif

+ 1
- 0
src/CMakeLists.txt View File

56
 set (SRCS ${SRCS} "FontManager.cpp")
56
 set (SRCS ${SRCS} "FontManager.cpp")
57
 set (SRCS ${SRCS} "FontTRLE.cpp")
57
 set (SRCS ${SRCS} "FontTRLE.cpp")
58
 set (SRCS ${SRCS} "Game.cpp")
58
 set (SRCS ${SRCS} "Game.cpp")
59
+set (SRCS ${SRCS} "Log.cpp")
59
 set (SRCS ${SRCS} "main.cpp")
60
 set (SRCS ${SRCS} "main.cpp")
60
 set (SRCS ${SRCS} "Menu.cpp")
61
 set (SRCS ${SRCS} "Menu.cpp")
61
 set (SRCS ${SRCS} "MenuFolder.cpp")
62
 set (SRCS ${SRCS} "MenuFolder.cpp")

+ 14
- 13
src/Console.cpp View File

10
 #include "global.h"
10
 #include "global.h"
11
 #include "commands/Command.h"
11
 #include "commands/Command.h"
12
 #include "Font.h"
12
 #include "Font.h"
13
+#include "Log.h"
13
 #include "utf8-cpp/utf8.h"
14
 #include "utf8-cpp/utf8.h"
14
 #include "utils/strings.h"
15
 #include "utils/strings.h"
15
 #include "utils/time.h"
16
 #include "utils/time.h"
64
     glEnable(GL_TEXTURE_2D);
65
     glEnable(GL_TEXTURE_2D);
65
 
66
 
66
     unsigned long scrollIndicator;
67
     unsigned long scrollIndicator;
67
-    if (mHistory.size() > lineCount) {
68
-        scrollIndicator = (mHistory.size() - lineCount - mLineOffset) * 100 / (mHistory.size() - lineCount);
68
+    if (getLog().size() > lineCount) {
69
+        scrollIndicator = (getLog().size() - lineCount - mLineOffset) * 100 / (getLog().size() - lineCount);
69
     } else {
70
     } else {
70
         scrollIndicator = 100;
71
         scrollIndicator = 100;
71
         mLineOffset = 0;
72
         mLineOffset = 0;
80
     long end = lineCount;
81
     long end = lineCount;
81
     long drawOffset = 0;
82
     long drawOffset = 0;
82
     long historyOffset = 0;
83
     long historyOffset = 0;
83
-    if (mHistory.size() < lineCount) {
84
-        end = mHistory.size();
85
-        drawOffset = lineCount - mHistory.size();
86
-    } else if (lineCount < mHistory.size()) {
87
-        historyOffset = mHistory.size() - lineCount;
84
+    if (getLog().size() < lineCount) {
85
+        end = getLog().size();
86
+        drawOffset = lineCount - getLog().size();
87
+    } else if (lineCount < getLog().size()) {
88
+        historyOffset = getLog().size() - lineCount;
88
     }
89
     }
89
 
90
 
90
     for (int i = 0; i < end; i++) {
91
     for (int i = 0; i < end; i++) {
91
         getFont().drawText(10, (unsigned int)((i + drawOffset) * lineSteps) + firstLine,
92
         getFont().drawText(10, (unsigned int)((i + drawOffset) * lineSteps) + firstLine,
92
-                0.75f, BLUE, mHistory.at(i + historyOffset - mLineOffset));
93
+                0.75f, BLUE, getLog().get(i + historyOffset - mLineOffset));
93
     }
94
     }
94
 
95
 
95
     // Draw current input
96
     // Draw current input
102
     if (pressed && (key == enterKey)) {
103
     if (pressed && (key == enterKey)) {
103
         // Execute entered command
104
         // Execute entered command
104
         if (mInputBuffer.length() > 0) {
105
         if (mInputBuffer.length() > 0) {
105
-            (*this) << "> " << mInputBuffer.c_str() << endl;
106
+            getLog() << "> " << mInputBuffer.c_str() << Log::endl;
106
             mCommandHistory.push_back(mInputBuffer.c_str());
107
             mCommandHistory.push_back(mInputBuffer.c_str());
107
             int error = Command::command(mInputBuffer);
108
             int error = Command::command(mInputBuffer);
108
             if (error != 0) {
109
             if (error != 0) {
109
-                (*this) << "Error Code: " << error << endl;
110
+                getLog() << "Error Code: " << error << Log::endl;
110
             }
111
             }
111
         } else {
112
         } else {
112
-            (*this) << "> " << endl;
113
+            getLog() << "> " << Log::endl;
113
         }
114
         }
114
 
115
 
115
         // Clear partial and input buffer
116
         // Clear partial and input buffer
200
         lineCount = (lastLine - firstLine + lineSteps) / lineSteps;
201
         lineCount = (lastLine - firstLine + lineSteps) / lineSteps;
201
     }
202
     }
202
 
203
 
203
-    if (mHistory.size() > lineCount) {
204
+    if (getLog().size() > lineCount) {
204
         if (yrel > 0) {
205
         if (yrel > 0) {
205
-            if (mLineOffset < (mHistory.size() - lineCount)) {
206
+            if (mLineOffset < (getLog().size() - lineCount)) {
206
                 mLineOffset++;
207
                 mLineOffset++;
207
             }
208
             }
208
         } else if (yrel < 0) {
209
         } else if (yrel < 0) {

+ 7
- 7
src/Entity.cpp View File

8
 #include <cmath>
8
 #include <cmath>
9
 
9
 
10
 #include "global.h"
10
 #include "global.h"
11
-#include "Console.h"
12
-#include "Entity.h"
11
+#include "Log.h"
13
 #include "Render.h"
12
 #include "Render.h"
14
 #include "World.h"
13
 #include "World.h"
14
+#include "Entity.h"
15
 
15
 
16
 #include "games/TombRaider1.h"
16
 #include "games/TombRaider1.h"
17
 
17
 
117
                 x, y, z);
117
                 x, y, z);
118
 
118
 
119
         if (roomNew > -1)
119
         if (roomNew > -1)
120
-            getConsole() << "Crossing from room " << room << " to " << roomNew << Console::endl;
120
+            getLog() << "Crossing from room " << room << " to " << roomNew << Log::endl;
121
         else
121
         else
122
             //! \fixme mRooms, sectors, ... are now std::vector, but often upper bound checks are missing
122
             //! \fixme mRooms, sectors, ... are now std::vector, but often upper bound checks are missing
123
             return;
123
             return;
213
 }
213
 }
214
 
214
 
215
 void Entity::print() {
215
 void Entity::print() {
216
-    getConsole() << "Entity " << objectId << ":" << Console::endl
216
+    getLog() << "Entity " << objectId << ":" << Log::endl
217
         << "  Room " << room << " (" << getWorld().getRoom(room).getFlags()
217
         << "  Room " << room << " (" << getWorld().getRoom(room).getFlags()
218
-        << ")" << Console::endl
218
+        << ")" << Log::endl
219
         << "  " << pos[0] << "x " << pos[1] << "y " << pos[2] << "z"
219
         << "  " << pos[0] << "x " << pos[1] << "y " << pos[2] << "z"
220
-        << Console::endl
221
-        << "  " << OR_RAD_TO_DEG(angles[1]) << " Yaw" << Console::endl;
220
+        << Log::endl
221
+        << "  " << OR_RAD_TO_DEG(angles[1]) << " Yaw" << Log::endl;
222
 }
222
 }
223
 
223
 
224
 SkeletalModel &Entity::getModel() {
224
 SkeletalModel &Entity::getModel() {

+ 11
- 11
src/Game.cpp View File

12
 
12
 
13
 #include "global.h"
13
 #include "global.h"
14
 #include "Camera.h"
14
 #include "Camera.h"
15
-#include "Console.h"
16
 #include "Game.h"
15
 #include "Game.h"
17
 #include "loader/Loader.h"
16
 #include "loader/Loader.h"
17
+#include "Log.h"
18
 #include "Render.h"
18
 #include "Render.h"
19
 #include "Sound.h"
19
 #include "Sound.h"
20
 #include "StaticMesh.h"
20
 #include "StaticMesh.h"
83
 
83
 
84
     levelName = level;
84
     levelName = level;
85
 
85
 
86
-    getConsole() << "Loading " << levelName << Console::endl;
86
+    getLog() << "Loading " << levelName << Log::endl;
87
 
87
 
88
     int error = 0;
88
     int error = 0;
89
     auto loader = Loader::createLoader(level);
89
     auto loader = Loader::createLoader(level);
96
 
96
 
97
         // And now...?
97
         // And now...?
98
 
98
 
99
-        getConsole() << "Tried Loader..." << Console::endl;
99
+        getLog() << "Tried Loader..." << Log::endl;
100
     }
100
     }
101
 
101
 
102
     if ((!loader) || (error == 0)) {
102
     if ((!loader) || (error == 0)) {
113
             tmp += "MAIN.SFX";
113
             tmp += "MAIN.SFX";
114
             error = mTombRaider.loadSFX(tmp.c_str());
114
             error = mTombRaider.loadSFX(tmp.c_str());
115
             if (error != 0)
115
             if (error != 0)
116
-                getConsole() << "Could not load " << tmp << Console::endl;
116
+                getLog() << "Could not load " << tmp << Log::endl;
117
         }
117
         }
118
 
118
 
119
         // Process data
119
         // Process data
128
 
128
 
129
         if (mLara == -1) {
129
         if (mLara == -1) {
130
             //! \todo Cutscene support
130
             //! \todo Cutscene support
131
-            getConsole() << "Can't find Lara entity in level pak!" << Console::endl;
131
+            getLog() << "Can't find Lara entity in level pak!" << Log::endl;
132
             destroy();
132
             destroy();
133
             return -1;
133
             return -1;
134
         } else {
134
         } else {
204
         }
204
         }
205
     }
205
     }
206
 
206
 
207
-    getConsole() << "Found " << mTombRaider.NumSpriteSequences() << " sprites." << Console::endl;
207
+    getLog() << "Found " << mTombRaider.NumSpriteSequences() << " sprites." << Log::endl;
208
 }
208
 }
209
 
209
 
210
 void Game::processRooms() {
210
 void Game::processRooms() {
211
     for (int index = 0; index < mTombRaider.NumRooms(); index++)
211
     for (int index = 0; index < mTombRaider.NumRooms(); index++)
212
         getWorld().addRoom(*new Room(mTombRaider, index));
212
         getWorld().addRoom(*new Room(mTombRaider, index));
213
 
213
 
214
-    getConsole() << "Found " << mTombRaider.NumRooms() << " rooms." << Console::endl;
214
+    getLog() << "Found " << mTombRaider.NumRooms() << " rooms." << Log::endl;
215
 }
215
 }
216
 
216
 
217
 void Game::processModels() {
217
 void Game::processModels() {
218
     for (int index = 0; index < mTombRaider.getMeshCount(); index++)
218
     for (int index = 0; index < mTombRaider.getMeshCount(); index++)
219
         getWorld().addStaticMesh(*new StaticMesh(mTombRaider, index));
219
         getWorld().addStaticMesh(*new StaticMesh(mTombRaider, index));
220
 
220
 
221
-    getConsole() << "Found " << mTombRaider.getMeshCount() << " meshes." << Console::endl;
221
+    getLog() << "Found " << mTombRaider.getMeshCount() << " meshes." << Log::endl;
222
 }
222
 }
223
 
223
 
224
 void Game::processPakSounds()
224
 void Game::processPakSounds()
260
         //getSound().SourceAt(id, pos);
260
         //getSound().SourceAt(id, pos);
261
     }
261
     }
262
 
262
 
263
-    getConsole() << "Found " << mTombRaider.getSoundSamplesCount() << " sound samples." << Console::endl;
263
+    getLog() << "Found " << mTombRaider.getSoundSamplesCount() << " sound samples." << Log::endl;
264
 }
264
 }
265
 
265
 
266
 void Game::processTextures()
266
 void Game::processTextures()
304
 
304
 
305
     mTextureOffset = (mTextureStart - 1) + mTombRaider.NumTextures();
305
     mTextureOffset = (mTextureStart - 1) + mTombRaider.NumTextures();
306
 
306
 
307
-    getConsole() << "Found " << mTombRaider.NumTextures() << " textures." << Console::endl;
307
+    getLog() << "Found " << mTombRaider.NumTextures() << " textures." << Log::endl;
308
 }
308
 }
309
 
309
 
310
 void Game::processMoveables()
310
 void Game::processMoveables()
389
     }
389
     }
390
     */
390
     */
391
 
391
 
392
-    getConsole() << "Found " << mTombRaider.NumMoveables() + statCount << " moveables." << Console::endl;
392
+    getLog() << "Found " << mTombRaider.NumMoveables() + statCount << " moveables." << Log::endl;
393
 }
393
 }
394
 
394
 
395
 // index moveable, i item, sometimes both moveable
395
 // index moveable, i item, sometimes both moveable

+ 22
- 0
src/Log.cpp View File

1
+/*!
2
+ * \file src/Log.cpp
3
+ * \brief Log
4
+ *
5
+ * \author xythobuz
6
+ */
7
+
8
+#include "global.h"
9
+#include "Log.h"
10
+
11
+Log::~Log() {
12
+}
13
+
14
+unsigned long Log::size() {
15
+    return mHistory.size();
16
+}
17
+
18
+std::string Log::get(unsigned long i) {
19
+    assert(i < mHistory.size());
20
+    return mHistory.at(i);
21
+}
22
+

+ 2
- 2
src/Menu.cpp View File

6
  */
6
  */
7
 
7
 
8
 #include "global.h"
8
 #include "global.h"
9
-#include "Console.h"
10
 #include "Font.h"
9
 #include "Font.h"
10
+#include "Log.h"
11
 #include "Window.h"
11
 #include "Window.h"
12
 #include "Menu.h"
12
 #include "Menu.h"
13
 #include "MenuFolder.h"
13
 #include "MenuFolder.h"
28
     dialogState = false;
28
     dialogState = false;
29
     dialogFunction = callback;
29
     dialogFunction = callback;
30
 
30
 
31
-    getConsole() << dialogText << Console::endl;
31
+    getLog() << dialogText << Log::endl;
32
 }
32
 }
33
 
33
 
34
 void Menu::ackDialog() {
34
 void Menu::ackDialog() {

+ 3
- 3
src/MenuFolder.cpp View File

6
  */
6
  */
7
 
7
 
8
 #include "global.h"
8
 #include "global.h"
9
-#include "Console.h"
10
 #include "Font.h"
9
 #include "Font.h"
11
 #include "Game.h"
10
 #include "Game.h"
12
 #include "loader/Loader.h"
11
 #include "loader/Loader.h"
12
+#include "Log.h"
13
 #include "RunTime.h"
13
 #include "RunTime.h"
14
 #include "Window.h"
14
 #include "Window.h"
15
 #include "MenuFolder.h"
15
 #include "MenuFolder.h"
61
             // Check maps for validity
61
             // Check maps for validity
62
             Loader::LoaderVersion version = Loader::checkFile(f.getPath());
62
             Loader::LoaderVersion version = Loader::checkFile(f.getPath());
63
             if (version == Loader::TR_UNKNOWN) {
63
             if (version == Loader::TR_UNKNOWN) {
64
-                getConsole() << "Error: pak file '" << f.getName().c_str()
65
-                    << "' invalid" << Console::endl;
64
+                getLog() << "Error: pak file '" << f.getName().c_str()
65
+                    << "' invalid" << Log::endl;
66
                 return true; // delete file from list
66
                 return true; // delete file from list
67
             }
67
             }
68
 
68
 

+ 6
- 6
src/Room.cpp View File

8
 #include <algorithm>
8
 #include <algorithm>
9
 
9
 
10
 #include "global.h"
10
 #include "global.h"
11
-#include "Console.h"
12
 #include "Game.h"
11
 #include "Game.h"
12
+#include "Log.h"
13
 #include "Render.h"
13
 #include "Render.h"
14
 #include "Room.h"
14
 #include "Room.h"
15
 #include "TextureManager.h"
15
 #include "TextureManager.h"
24
     Matrix transform;
24
     Matrix transform;
25
 
25
 
26
     if (!tr.isRoomValid(index)) {
26
     if (!tr.isRoomValid(index)) {
27
-        getConsole() << "WARNING: Handling invalid vertex array in room" << Console::endl;
27
+        getLog() << "WARNING: Handling invalid vertex array in room" << Log::endl;
28
         return;
28
         return;
29
     }
29
     }
30
 
30
 
168
 
168
 
169
         if (texture > (int)TextureLimit)
169
         if (texture > (int)TextureLimit)
170
         {
170
         {
171
-            getConsole() << "Handling bad room[" << index << "].tris["
172
-                << t << "].texture = " << texture << Console::endl;
171
+            getLog() << "Handling bad room[" << index << "].tris["
172
+                << t << "].texture = " << texture << Log::endl;
173
             texture = TextureLimit - 1;
173
             texture = TextureLimit - 1;
174
         }
174
         }
175
 
175
 
202
 
202
 
203
         if (texture > (int)TextureLimit)
203
         if (texture > (int)TextureLimit)
204
         {
204
         {
205
-            getConsole() << "Handling bad room[" << index << "].quad["
206
-                << r << "].texture = " << texture << Console::endl;
205
+            getLog() << "Handling bad room[" << index << "].quad["
206
+                << r << "].texture = " << texture << Log::endl;
207
             texture = TextureLimit - 1;
207
             texture = TextureLimit - 1;
208
         }
208
         }
209
 
209
 

+ 6
- 6
src/SkeletalModel.cpp View File

7
  */
7
  */
8
 
8
 
9
 #include "global.h"
9
 #include "global.h"
10
-#include "Console.h"
10
+#include "Log.h"
11
 #include "Render.h"
11
 #include "Render.h"
12
 #include "SkeletalModel.h"
12
 #include "SkeletalModel.h"
13
 #include "World.h"
13
 #include "World.h"
137
         }
137
         }
138
 
138
 
139
         if (*frame_offset > tr.NumFrames()) {
139
         if (*frame_offset > tr.NumFrames()) {
140
-            getConsole() << "WARNING: Bad animation frame " << *frame_offset
140
+            getLog() << "WARNING: Bad animation frame " << *frame_offset
141
                 << " > " << tr.NumFrames() << " (" << index << "." << a << ")"
141
                 << " > " << tr.NumFrames() << " (" << index << "." << a << ")"
142
-                << Console::endl;
142
+                << Log::endl;
143
             return;
143
             return;
144
         }
144
         }
145
 
145
 
201
                 }
201
                 }
202
 
202
 
203
                 getRender().setFlags(Render::fRenderPonytail);
203
                 getRender().setFlags(Render::fRenderPonytail);
204
-                getConsole() << "Found known ponytail" << Console::endl;
204
+                getLog() << "Found known ponytail" << Log::endl;
205
             }
205
             }
206
             break;
206
             break;
207
 
207
 
223
                 ponyOff2 = 0;
223
                 ponyOff2 = 0;
224
 
224
 
225
                 getRender().setFlags(Render::fRenderPonytail);
225
                 getRender().setFlags(Render::fRenderPonytail);
226
-                getConsole() << "Found ponytail?" << Console::endl;
226
+                getLog() << "Found ponytail?" << Log::endl;
227
             }
227
             }
228
             break;
228
             break;
229
     }
229
     }
247
         frame_offset += frame_step * (frame_cycle % a);
247
         frame_offset += frame_step * (frame_cycle % a);
248
 
248
 
249
     if (a < 0) {
249
     if (a < 0) {
250
-        getConsole() << "Invalid animation data for model " << index << ". Skip!" << Console::endl;
250
+        getLog() << "Invalid animation data for model " << index << ". Skip!" << Log::endl;
251
         return;
251
         return;
252
     } else {
252
     } else {
253
         for (; a < tr.getNumAnimsForMoveable(index); a++) {
253
         for (; a < tr.getNumAnimsForMoveable(index); a++) {

+ 3
- 3
src/TextureManager.cpp View File

12
 #include <stdarg.h>
12
 #include <stdarg.h>
13
 
13
 
14
 #include "global.h"
14
 #include "global.h"
15
-#include "Console.h"
15
+#include "Log.h"
16
 #include "RunTime.h"
16
 #include "RunTime.h"
17
 #include "utils/pcx.h"
17
 #include "utils/pcx.h"
18
 #include "utils/pixel.h"
18
 #include "utils/pixel.h"
200
     } else if (stringEndsWith(filename, ".tga") || stringEndsWith(filename, ".TGA")) {
200
     } else if (stringEndsWith(filename, ".tga") || stringEndsWith(filename, ".TGA")) {
201
         return loadTGA(filename);
201
         return loadTGA(filename);
202
     } else {
202
     } else {
203
-        getConsole() << "No known image file type? (" << filename << ")" << Console::endl;
203
+        getLog() << "No known image file type? (" << filename << ")" << Log::endl;
204
     }
204
     }
205
 
205
 
206
     return -1;
206
     return -1;
256
 
256
 
257
     return id;
257
     return id;
258
 #else
258
 #else
259
-    getConsole() << "No PNG support available (" << filename << ")" << Console::endl;
259
+    getLog() << "No PNG support available (" << filename << ")" << Log::endl;
260
     return -1;
260
     return -1;
261
 #endif
261
 #endif
262
 }
262
 }

+ 1
- 3
src/UI.cpp View File

84
                 getConsole().moveToTop();
84
                 getConsole().moveToTop();
85
             }
85
             }
86
         } else if (getRunTime().getKeyBinding(debugAction) == key) {
86
         } else if (getRunTime().getKeyBinding(debugAction) == key) {
87
-            if (getDebug().isOnTop()) {
88
-                getDebug().makeInvisible();
89
-            } else {
87
+            if (!getDebug().isOnTop()) {
90
                 getDebug().moveToTop();
88
                 getDebug().moveToTop();
91
             }
89
             }
92
         }
90
         }

+ 14
- 14
src/commands/Command.cpp View File

9
 #include <iomanip>
9
 #include <iomanip>
10
 
10
 
11
 #include "global.h"
11
 #include "global.h"
12
-#include "Console.h"
12
+#include "Log.h"
13
 #include "utils/strings.h"
13
 #include "utils/strings.h"
14
 #include "commands/Command.h"
14
 #include "commands/Command.h"
15
 #include "commands/CommandAnimate.h"
15
 #include "commands/CommandAnimate.h"
27
 }
27
 }
28
 
28
 
29
 void Command::printHelp() {
29
 void Command::printHelp() {
30
-    getConsole() << "No help available!" << Console::endl;
30
+    getLog() << "No help available!" << Log::endl;
31
 }
31
 }
32
 
32
 
33
 void Command::fillCommandList() {
33
 void Command::fillCommandList() {
71
         command >> arg;
71
         command >> arg;
72
         if (arg.length() == 0) {
72
         if (arg.length() == 0) {
73
             // List all available commands
73
             // List all available commands
74
-            getConsole() << "Available commands:" << Console::endl;
75
-            getConsole() << std::right << std::setw(11);
76
-            getConsole() << "help" << " - print command help" << Console::endl;
74
+            getLog() << "Available commands:" << Log::endl;
75
+            getLog() << std::right << std::setw(11);
76
+            getLog() << "help" << " - print command help" << Log::endl;
77
             for (auto &x : commands) {
77
             for (auto &x : commands) {
78
                 if (x) {
78
                 if (x) {
79
-                    getConsole() << std::right << std::setw(11);
80
-                    getConsole() << x->name() << " - " << x->brief() << Console::endl;
79
+                    getLog() << std::right << std::setw(11);
80
+                    getLog() << x->name() << " - " << x->brief() << Log::endl;
81
                 }
81
                 }
82
             }
82
             }
83
-            getConsole() << "Use help COMMAND to get additional info" << Console::endl;
84
-            getConsole() << "Pass BOOLs as true or false" << Console::endl;
83
+            getLog() << "Use help COMMAND to get additional info" << Log::endl;
84
+            getLog() << "Pass BOOLs as true or false" << Log::endl;
85
             return 0;
85
             return 0;
86
         } else {
86
         } else {
87
             // Show help for a specific command
87
             // Show help for a specific command
93
                     }
93
                     }
94
                 }
94
                 }
95
             }
95
             }
96
-            getConsole() << "Unknown command: \"" << arg << "\"" << Console::endl;
96
+            getLog() << "Unknown command: \"" << arg << "\"" << Log::endl;
97
             return -1;
97
             return -1;
98
         }
98
         }
99
     }
99
     }
107
         }
107
         }
108
     }
108
     }
109
 
109
 
110
-    getConsole() << "Unknown command: \"" << cmd << "\"" << Console::endl;
110
+    getLog() << "Unknown command: \"" << cmd << "\"" << Log::endl;
111
     return -1;
111
     return -1;
112
 }
112
 }
113
 
113
 
114
 int Command::executeFile(std::string file) {
114
 int Command::executeFile(std::string file) {
115
     std::string configFile = expandHomeDirectory(file);
115
     std::string configFile = expandHomeDirectory(file);
116
-    getConsole() << "Loading config from \"" << configFile << "\"..." << Console::endl;
116
+    getLog() << "Loading config from \"" << configFile << "\"..." << Log::endl;
117
 
117
 
118
     std::ifstream f(configFile);
118
     std::ifstream f(configFile);
119
     if (!f) {
119
     if (!f) {
120
-        getConsole() << "Could not open file!" << Console::endl;
120
+        getLog() << "Could not open file!" << Log::endl;
121
         return -1;
121
         return -1;
122
     }
122
     }
123
 
123
 
127
 
127
 
128
         int error = Command::command(line);
128
         int error = Command::command(line);
129
         if (error != 0)
129
         if (error != 0)
130
-            getConsole() << "Error Code: " << error << Console::endl;
130
+            getLog() << "Error Code: " << error << Log::endl;
131
     }
131
     }
132
 
132
 
133
     f.close();
133
     f.close();

+ 12
- 12
src/commands/CommandAnimate.cpp View File

6
  */
6
  */
7
 
7
 
8
 #include "global.h"
8
 #include "global.h"
9
-#include "Console.h"
9
+#include "Log.h"
10
 #include "Game.h"
10
 #include "Game.h"
11
 #include "Render.h"
11
 #include "Render.h"
12
 #include "World.h"
12
 #include "World.h"
21
 }
21
 }
22
 
22
 
23
 void CommandAnimate::printHelp() {
23
 void CommandAnimate::printHelp() {
24
-    getConsole() << "animate-Command Usage:" << Console::endl;
25
-    getConsole() << "  animate [n|p|BOOL]" << Console::endl;
26
-    getConsole() << "Where the commands have the following meaning:" << Console::endl;
27
-    getConsole() << "  BOOL to (de)activate animating all models" << Console::endl;
28
-    getConsole() << "  n to step all models to their next animation" << Console::endl;
29
-    getConsole() << "  p to step all models to their previous animation" << Console::endl;
24
+    getLog() << "animate-Command Usage:" << Log::endl;
25
+    getLog() << "  animate [n|p|BOOL]" << Log::endl;
26
+    getLog() << "Where the commands have the following meaning:" << Log::endl;
27
+    getLog() << "  BOOL to (de)activate animating all models" << Log::endl;
28
+    getLog() << "  n to step all models to their next animation" << Log::endl;
29
+    getLog() << "  p to step all models to their previous animation" << Log::endl;
30
 }
30
 }
31
 
31
 
32
 int CommandAnimate::execute(std::istream& args) {
32
 int CommandAnimate::execute(std::istream& args) {
33
     if (!getGame().isLoaded()) {
33
     if (!getGame().isLoaded()) {
34
-        getConsole() << "Use animate command interactively!" << Console::endl;
34
+        getLog() << "Use animate command interactively!" << Log::endl;
35
         return -1;
35
         return -1;
36
     }
36
     }
37
 
37
 
47
                     e.setAnimation(0);
47
                     e.setAnimation(0);
48
             }
48
             }
49
         } else {
49
         } else {
50
-            getConsole() << "Animations need to be enabled!" << Console::endl;
50
+            getLog() << "Animations need to be enabled!" << Log::endl;
51
         }
51
         }
52
     } else if (args.peek() == 'p') {
52
     } else if (args.peek() == 'p') {
53
         // Step all skeletal models to their previous animation
53
         // Step all skeletal models to their previous animation
62
                         e.setAnimation(m.size() - 1);
62
                         e.setAnimation(m.size() - 1);
63
             }
63
             }
64
         } else {
64
         } else {
65
-            getConsole() << "Animations need to be enabled!" << Console::endl;
65
+            getLog() << "Animations need to be enabled!" << Log::endl;
66
         }
66
         }
67
     } else {
67
     } else {
68
         // Enable or disable animating all skeletal models
68
         // Enable or disable animating all skeletal models
69
         bool b = false;
69
         bool b = false;
70
         if (!(args >> b)) {
70
         if (!(args >> b)) {
71
-            getConsole() << "Pass BOOL to animate command!" << Console::endl;
71
+            getLog() << "Pass BOOL to animate command!" << Log::endl;
72
             return -2;
72
             return -2;
73
         }
73
         }
74
         if (b)
74
         if (b)
75
             getRender().setFlags(Render::fAnimateAllModels);
75
             getRender().setFlags(Render::fAnimateAllModels);
76
         else
76
         else
77
             getRender().clearFlags(Render::fAnimateAllModels);
77
             getRender().clearFlags(Render::fAnimateAllModels);
78
-        getConsole() << (b ? "Animating all models" : "No longer animating all models") << Console::endl;
78
+        getLog() << (b ? "Animating all models" : "No longer animating all models") << Log::endl;
79
     }
79
     }
80
 
80
 
81
     return 0;
81
     return 0;

+ 22
- 22
src/commands/CommandBind.cpp View File

6
  */
6
  */
7
 
7
 
8
 #include "global.h"
8
 #include "global.h"
9
-#include "Console.h"
9
+#include "Log.h"
10
 #include "RunTime.h"
10
 #include "RunTime.h"
11
 #include "commands/CommandBind.h"
11
 #include "commands/CommandBind.h"
12
 
12
 
19
 }
19
 }
20
 
20
 
21
 void CommandBind::printHelp() {
21
 void CommandBind::printHelp() {
22
-    getConsole() << "bind-Command Usage:" << Console::endl;
23
-    getConsole() << "  bind ACTION KEY" << Console::endl;
24
-    getConsole() << "Available Actions:" << Console::endl;
25
-    getConsole() << "  menu" << Console::endl;
26
-    getConsole() << "  console" << Console::endl;
27
-    getConsole() << "  debug" << Console::endl;
28
-    getConsole() << "  forward" << Console::endl;
29
-    getConsole() << "  backward" << Console::endl;
30
-    getConsole() << "  left" << Console::endl;
31
-    getConsole() << "  right" << Console::endl;
32
-    getConsole() << "  jump" << Console::endl;
33
-    getConsole() << "  crouch" << Console::endl;
34
-    getConsole() << "  use" << Console::endl;
35
-    getConsole() << "  holster" << Console::endl;
36
-    getConsole() << "  walk" << Console::endl;
37
-    getConsole() << "Key-Format:" << Console::endl;
38
-    getConsole() << "  'a' or '1'    for character/number keys" << Console::endl;
39
-    getConsole() << "  \"leftctrl\"  for symbols and special keys" << Console::endl;
22
+    getLog() << "bind-Command Usage:" << Log::endl;
23
+    getLog() << "  bind ACTION KEY" << Log::endl;
24
+    getLog() << "Available Actions:" << Log::endl;
25
+    getLog() << "  menu" << Log::endl;
26
+    getLog() << "  console" << Log::endl;
27
+    getLog() << "  debug" << Log::endl;
28
+    getLog() << "  forward" << Log::endl;
29
+    getLog() << "  backward" << Log::endl;
30
+    getLog() << "  left" << Log::endl;
31
+    getLog() << "  right" << Log::endl;
32
+    getLog() << "  jump" << Log::endl;
33
+    getLog() << "  crouch" << Log::endl;
34
+    getLog() << "  use" << Log::endl;
35
+    getLog() << "  holster" << Log::endl;
36
+    getLog() << "  walk" << Log::endl;
37
+    getLog() << "Key-Format:" << Log::endl;
38
+    getLog() << "  'a' or '1'    for character/number keys" << Log::endl;
39
+    getLog() << "  \"leftctrl\"  for symbols and special keys" << Log::endl;
40
 }
40
 }
41
 
41
 
42
 int CommandBind::execute(std::istream& args) {
42
 int CommandBind::execute(std::istream& args) {
43
     std::string a, b;
43
     std::string a, b;
44
     if (!(args >> a >> b)) {
44
     if (!(args >> a >> b)) {
45
-        getConsole() << "Invalid use of bind-command" << Console::endl;
45
+        getLog() << "Invalid use of bind-command" << Log::endl;
46
         return -1;
46
         return -1;
47
     } else {
47
     } else {
48
         ActionEvents e = stringToActionEvent(a);
48
         ActionEvents e = stringToActionEvent(a);
49
         if (e == ActionEventCount) {
49
         if (e == ActionEventCount) {
50
-            getConsole() << "bind-Error: Unknown action (" << a << ")" << Console::endl;
50
+            getLog() << "bind-Error: Unknown action (" << a << ")" << Log::endl;
51
             return -2;
51
             return -2;
52
         }
52
         }
53
 
53
 
54
         KeyboardButton c = stringToKeyboardButton(b);
54
         KeyboardButton c = stringToKeyboardButton(b);
55
         if (c == unknownKey) {
55
         if (c == unknownKey) {
56
-            getConsole() << "bind-Error: Unknown key (" << b << ")" << Console::endl;
56
+            getLog() << "bind-Error: Unknown key (" << b << ")" << Log::endl;
57
             return -3;
57
             return -3;
58
         }
58
         }
59
 
59
 

+ 9
- 9
src/commands/CommandEngine.cpp View File

8
 #include "global.h"
8
 #include "global.h"
9
 #include "Console.h"
9
 #include "Console.h"
10
 #include "Game.h"
10
 #include "Game.h"
11
+#include "Log.h"
11
 #include "Menu.h"
12
 #include "Menu.h"
12
 #include "RunTime.h"
13
 #include "RunTime.h"
13
 #include "Render.h"
14
 #include "Render.h"
22
 }
23
 }
23
 
24
 
24
 void CommandLoad::printHelp() {
25
 void CommandLoad::printHelp() {
25
-    getConsole() << "load-Command Usage:" << Console::endl;
26
-    getConsole() << "  load /path/to/level" << Console::endl;
26
+    getLog() << "load-Command Usage:" << Log::endl;
27
+    getLog() << "  load /path/to/level" << Log::endl;
27
 }
28
 }
28
 
29
 
29
 int CommandLoad::execute(std::istream& args) {
30
 int CommandLoad::execute(std::istream& args) {
30
     if (!getRunTime().isRunning()) {
31
     if (!getRunTime().isRunning()) {
31
-        getConsole() << "Use load command interactively!" << Console::endl;
32
+        getLog() << "Use load command interactively!" << Log::endl;
32
         return -1;
33
         return -1;
33
     }
34
     }
34
 
35
 
49
 }
50
 }
50
 
51
 
51
 void CommandScreenshot::printHelp() {
52
 void CommandScreenshot::printHelp() {
52
-    getConsole() << "sshot-Command Usage:" << Console::endl;
53
-    getConsole() << "  sshot [console|menu] [console|menu]" << Console::endl;
54
-    getConsole() << "Add console/menu to capture them too" << Console::endl;
53
+    getLog() << "sshot-Command Usage:" << Log::endl;
54
+    getLog() << "  sshot [console|menu] [console|menu]" << Log::endl;
55
+    getLog() << "Add console/menu to capture them too" << Log::endl;
55
 }
56
 }
56
 
57
 
57
 int CommandScreenshot::execute(std::istream& args) {
58
 int CommandScreenshot::execute(std::istream& args) {
58
     if (!getRunTime().isRunning()) {
59
     if (!getRunTime().isRunning()) {
59
-        getConsole() << "Use sshot command interactively!" << Console::endl;
60
+        getLog() << "Use sshot command interactively!" << Log::endl;
60
         return -1;
61
         return -1;
61
     }
62
     }
62
 
63
 
64
     filename += "/sshots/";
65
     filename += "/sshots/";
65
     filename += VERSION_SHORT;
66
     filename += VERSION_SHORT;
66
 
67
 
67
-    bool console = false, menu = false;
68
     std::string temp, temp2;
68
     std::string temp, temp2;
69
     args >> temp >> temp2;
69
     args >> temp >> temp2;
70
 
70
 
88
     getMenu().makeInvisible();
88
     getMenu().makeInvisible();
89
     getConsole().moveToTop();
89
     getConsole().moveToTop();
90
 
90
 
91
-    getConsole() << "Screenshot stored..." << Console::endl;
91
+    getLog() << "Screenshot stored..." << Log::endl;
92
     return 0;
92
     return 0;
93
 }
93
 }
94
 
94
 

+ 9
- 9
src/commands/CommandGame.cpp View File

6
  */
6
  */
7
 
7
 
8
 #include "global.h"
8
 #include "global.h"
9
-#include "Console.h"
10
 #include "Game.h"
9
 #include "Game.h"
10
+#include "Log.h"
11
 #include "RunTime.h"
11
 #include "RunTime.h"
12
 #include "World.h"
12
 #include "World.h"
13
 #include "commands/CommandGame.h"
13
 #include "commands/CommandGame.h"
22
 
22
 
23
 int CommandPos::execute(std::istream& args) {
23
 int CommandPos::execute(std::istream& args) {
24
     if ((!getRunTime().isRunning()) || (!getGame().isLoaded())) {
24
     if ((!getRunTime().isRunning()) || (!getGame().isLoaded())) {
25
-        getConsole() << "Use pos command interactively!" << Console::endl;
25
+        getLog() << "Use pos command interactively!" << Log::endl;
26
         return -1;
26
         return -1;
27
     }
27
     }
28
 
28
 
42
 
42
 
43
 int CommandViewmodel::execute(std::istream& args) {
43
 int CommandViewmodel::execute(std::istream& args) {
44
     if ((!getRunTime().isRunning()) || (!getGame().isLoaded())) {
44
     if ((!getRunTime().isRunning()) || (!getGame().isLoaded())) {
45
-        getConsole() << "Use viewmodel command interactively!" << Console::endl;
45
+        getLog() << "Use viewmodel command interactively!" << Log::endl;
46
         return -1;
46
         return -1;
47
     }
47
     }
48
 
48
 
56
         getGame().getLara().setSkeletalModel(n);
56
         getGame().getLara().setSkeletalModel(n);
57
         return 0;
57
         return 0;
58
     } else {
58
     } else {
59
-        getConsole() << "Invalid SkeletalModel index!" << Console::endl;
59
+        getLog() << "Invalid SkeletalModel index!" << Log::endl;
60
         return -2;
60
         return -2;
61
     }
61
     }
62
 }
62
 }
73
 
73
 
74
 int CommandPigtail::execute(std::istream& args) {
74
 int CommandPigtail::execute(std::istream& args) {
75
     if ((!getRunTime().isRunning()) || (!getGame().isLoaded())) {
75
     if ((!getRunTime().isRunning()) || (!getGame().isLoaded())) {
76
-        getConsole() << "Use pigtail command interactively!" << Console::endl;
76
+        getLog() << "Use pigtail command interactively!" << Log::endl;
77
         return -1;
77
         return -1;
78
     }
78
     }
79
 
79
 
80
     bool b;
80
     bool b;
81
     args >> b;
81
     args >> b;
82
     if (!args) {
82
     if (!args) {
83
-        getConsole() << "Pass BOOL to pigtail command!" << Console::endl;
83
+        getLog() << "Pass BOOL to pigtail command!" << Log::endl;
84
         return -2;
84
         return -2;
85
     }
85
     }
86
 
86
 
87
     getGame().getLara().getModel().setPigTail(b);
87
     getGame().getLara().getModel().setPigTail(b);
88
-    getConsole() << "Pigtail is now " << (b ? "on" : "off") << Console::endl;
88
+    getLog() << "Pigtail is now " << (b ? "on" : "off") << Log::endl;
89
     return 0;
89
     return 0;
90
 }
90
 }
91
 
91
 
101
 
101
 
102
 int CommandPonypos::execute(std::istream& args) {
102
 int CommandPonypos::execute(std::istream& args) {
103
     if ((!getRunTime().isRunning()) || (!getGame().isLoaded())) {
103
     if ((!getRunTime().isRunning()) || (!getGame().isLoaded())) {
104
-        getConsole() << "Use ponypos command interactively!" << Console::endl;
104
+        getLog() << "Use ponypos command interactively!" << Log::endl;
105
         return -1;
105
         return -1;
106
     }
106
     }
107
 
107
 
108
     float a, b, c, d;
108
     float a, b, c, d;
109
     args >> a >> b >> c >> d;
109
     args >> a >> b >> c >> d;
110
     if (!args) {
110
     if (!args) {
111
-        getConsole() << "Pass four FLOATs to ponypos command!" << Console::endl;
111
+        getLog() << "Pass four FLOATs to ponypos command!" << Log::endl;
112
         return -2;
112
         return -2;
113
     }
113
     }
114
 
114
 

+ 10
- 10
src/commands/CommandMove.cpp View File

6
  */
6
  */
7
 
7
 
8
 #include "global.h"
8
 #include "global.h"
9
-#include "Console.h"
10
 #include "Game.h"
9
 #include "Game.h"
10
+#include "Log.h"
11
 #include "RunTime.h"
11
 #include "RunTime.h"
12
 #include "commands/CommandMove.h"
12
 #include "commands/CommandMove.h"
13
 
13
 
20
 }
20
 }
21
 
21
 
22
 void CommandMove::printHelp() {
22
 void CommandMove::printHelp() {
23
-    getConsole() << "move-Command Usage:" << Console::endl;
24
-    getConsole() << "  move COMMAND" << Console::endl;
25
-    getConsole() << "Where COMMAND is one of the following:" << Console::endl;
26
-    getConsole() << "  walk" << Console::endl;
27
-    getConsole() << "  fly" << Console::endl;
28
-    getConsole() << "  noclip" << Console::endl;
23
+    getLog() << "move-Command Usage:" << Log::endl;
24
+    getLog() << "  move COMMAND" << Log::endl;
25
+    getLog() << "Where COMMAND is one of the following:" << Log::endl;
26
+    getLog() << "  walk" << Log::endl;
27
+    getLog() << "  fly" << Log::endl;
28
+    getLog() << "  noclip" << Log::endl;
29
 }
29
 }
30
 
30
 
31
 int CommandMove::execute(std::istream& args) {
31
 int CommandMove::execute(std::istream& args) {
32
     if ((!getRunTime().isRunning()) || (!getGame().isLoaded())) {
32
     if ((!getRunTime().isRunning()) || (!getGame().isLoaded())) {
33
-        getConsole() << "Use move command interactively!" << Console::endl;
33
+        getLog() << "Use move command interactively!" << Log::endl;
34
         return -1;
34
         return -1;
35
     }
35
     }
36
 
36
 
43
     } else if (s.compare("noclip") == 0) {
43
     } else if (s.compare("noclip") == 0) {
44
         getGame().getLara().setMoveType(Entity::MoveTypeNoClipping);
44
         getGame().getLara().setMoveType(Entity::MoveTypeNoClipping);
45
     } else {
45
     } else {
46
-        getConsole() << "Invalid use of move command (" << s << ")!" << Console::endl;
46
+        getLog() << "Invalid use of move command (" << s << ")!" << Log::endl;
47
         return -2;
47
         return -2;
48
     }
48
     }
49
 
49
 
50
-    getConsole() << s  << "ing" << Console::endl;
50
+    getLog() << s  << "ing" << Log::endl;
51
     return 0;
51
     return 0;
52
 }
52
 }
53
 
53
 

+ 27
- 27
src/commands/CommandRender.cpp View File

6
  */
6
  */
7
 
7
 
8
 #include "global.h"
8
 #include "global.h"
9
-#include "Console.h"
10
 #include "Game.h"
9
 #include "Game.h"
10
+#include "Log.h"
11
 #include "RunTime.h"
11
 #include "RunTime.h"
12
 #include "Render.h"
12
 #include "Render.h"
13
 #include "commands/CommandRender.h"
13
 #include "commands/CommandRender.h"
21
 }
21
 }
22
 
22
 
23
 void CommandMode::printHelp() {
23
 void CommandMode::printHelp() {
24
-    getConsole() << "mode-Command Usage:" << Console::endl;
25
-    getConsole() << "  mode MODE" << Console::endl;
26
-    getConsole() << "Where MODE is one of the following:" << Console::endl;
27
-    getConsole() << "  wireframe" << Console::endl;
28
-    getConsole() << "  solid" << Console::endl;
29
-    getConsole() << "  texture" << Console::endl;
30
-    getConsole() << "  vertexlight" << Console::endl;
31
-    getConsole() << "  titlescreen" << Console::endl;
24
+    getLog() << "mode-Command Usage:" << Log::endl;
25
+    getLog() << "  mode MODE" << Log::endl;
26
+    getLog() << "Where MODE is one of the following:" << Log::endl;
27
+    getLog() << "  wireframe" << Log::endl;
28
+    getLog() << "  solid" << Log::endl;
29
+    getLog() << "  texture" << Log::endl;
30
+    getLog() << "  vertexlight" << Log::endl;
31
+    getLog() << "  titlescreen" << Log::endl;
32
 
32
 
33
 }
33
 }
34
 
34
 
35
 int CommandMode::execute(std::istream& args) {
35
 int CommandMode::execute(std::istream& args) {
36
     if (!getGame().isLoaded()) {
36
     if (!getGame().isLoaded()) {
37
-        getConsole() << "Load a level to set the mode!" << Console::endl;
37
+        getLog() << "Load a level to set the mode!" << Log::endl;
38
         return -1;
38
         return -1;
39
     }
39
     }
40
 
40
 
43
 
43
 
44
     if (s.compare("wireframe") == 0) {
44
     if (s.compare("wireframe") == 0) {
45
         getRender().setMode(Render::modeWireframe);
45
         getRender().setMode(Render::modeWireframe);
46
-        getConsole() << "Wireframe mode" << Console::endl;
46
+        getLog() << "Wireframe mode" << Log::endl;
47
     } else if (s.compare("solid") == 0) {
47
     } else if (s.compare("solid") == 0) {
48
         getRender().setMode(Render::modeSolid);
48
         getRender().setMode(Render::modeSolid);
49
-        getConsole() << "Solid mode" << Console::endl;
49
+        getLog() << "Solid mode" << Log::endl;
50
     } else if (s.compare("texture") == 0) {
50
     } else if (s.compare("texture") == 0) {
51
         getRender().setMode(Render::modeTexture);
51
         getRender().setMode(Render::modeTexture);
52
-        getConsole() << "Texture mode" << Console::endl;
52
+        getLog() << "Texture mode" << Log::endl;
53
     } else if (s.compare("vertexlight") == 0) {
53
     } else if (s.compare("vertexlight") == 0) {
54
         getRender().setMode(Render::modeVertexLight);
54
         getRender().setMode(Render::modeVertexLight);
55
-        getConsole() << "Vertexlight mode" << Console::endl;
55
+        getLog() << "Vertexlight mode" << Log::endl;
56
     } else if (s.compare("titlescreen") == 0) {
56
     } else if (s.compare("titlescreen") == 0) {
57
         getRender().setMode(Render::modeLoadScreen);
57
         getRender().setMode(Render::modeLoadScreen);
58
-        getConsole() << "Titlescreen mode" << Console::endl;
58
+        getLog() << "Titlescreen mode" << Log::endl;
59
     } else {
59
     } else {
60
-        getConsole() << "Invalid use of mode command (" << s << ")!" << Console::endl;
60
+        getLog() << "Invalid use of mode command (" << s << ")!" << Log::endl;
61
         return -2;
61
         return -2;
62
     }
62
     }
63
 
63
 
75
 }
75
 }
76
 
76
 
77
 void CommandRenderflag::printHelp() {
77
 void CommandRenderflag::printHelp() {
78
-    getConsole() << "renderflag-Command Usage:" << Console::endl;
79
-    getConsole() << "  renderflag STRING BOOL" << Console::endl;
80
-    getConsole() << "Where STRING is one of the following:" << Console::endl;
81
-    getConsole() << "  ralpha" << Console::endl;
82
-    getConsole() << "  entmodel" << Console::endl;
83
-    getConsole() << "  fog" << Console::endl;
84
-    getConsole() << "  light" << Console::endl;
85
-    getConsole() << "  ponytail" << Console::endl;
78
+    getLog() << "renderflag-Command Usage:" << Log::endl;
79
+    getLog() << "  renderflag STRING BOOL" << Log::endl;
80
+    getLog() << "Where STRING is one of the following:" << Log::endl;
81
+    getLog() << "  ralpha" << Log::endl;
82
+    getLog() << "  entmodel" << Log::endl;
83
+    getLog() << "  fog" << Log::endl;
84
+    getLog() << "  light" << Log::endl;
85
+    getLog() << "  ponytail" << Log::endl;
86
 }
86
 }
87
 
87
 
88
 int CommandRenderflag::execute(std::istream& args) {
88
 int CommandRenderflag::execute(std::istream& args) {
89
     if (!getRunTime().isRunning()) {
89
     if (!getRunTime().isRunning()) {
90
-        getConsole() << "Use renderflag-Command interactively!" << Console::endl;
90
+        getLog() << "Use renderflag-Command interactively!" << Log::endl;
91
         return -1;
91
         return -1;
92
     }
92
     }
93
 
93
 
95
     bool b;
95
     bool b;
96
     args >> flag >> b;
96
     args >> flag >> b;
97
     if (!args) {
97
     if (!args) {
98
-        getConsole() << "Pass STRING and BOOL to renderflag command!" << Console::endl;
98
+        getLog() << "Pass STRING and BOOL to renderflag command!" << Log::endl;
99
         return -2;
99
         return -2;
100
     }
100
     }
101
 
101
 
102
     int f = stringToFlag(flag);
102
     int f = stringToFlag(flag);
103
     if (f == -1) {
103
     if (f == -1) {
104
-        getConsole() << "Unknown flag \"" << flag << "\"!" << Console::endl;
104
+        getLog() << "Unknown flag \"" << flag << "\"!" << Log::endl;
105
         return -3;
105
         return -3;
106
     }
106
     }
107
 
107
 

+ 25
- 25
src/commands/CommandSet.cpp View File

7
 
7
 
8
 #include "global.h"
8
 #include "global.h"
9
 #include "Camera.h"
9
 #include "Camera.h"
10
-#include "Console.h"
11
 #include "Font.h"
10
 #include "Font.h"
11
+#include "Log.h"
12
 #include "RunTime.h"
12
 #include "RunTime.h"
13
 #include "Sound.h"
13
 #include "Sound.h"
14
 #include "Window.h"
14
 #include "Window.h"
24
 }
24
 }
25
 
25
 
26
 void CommandSet::printHelp() {
26
 void CommandSet::printHelp() {
27
-    getConsole() << "set-Command Usage:" << Console::endl;
28
-    getConsole() << "  set VAR VAL" << Console::endl;
29
-    getConsole() << "Available Variables:" << Console::endl;
30
-    getConsole() << "  basedir    STRING" << Console::endl;
31
-    getConsole() << "  pakdir     STRING" << Console::endl;
32
-    getConsole() << "  audiodir   STRING" << Console::endl;
33
-    getConsole() << "  datadir    STRING" << Console::endl;
34
-    getConsole() << "  font       STRING" << Console::endl;
35
-    getConsole() << "  size       INT INT" << Console::endl;
36
-    getConsole() << "  fullscreen BOOL" << Console::endl;
37
-    getConsole() << "  audio      BOOL" << Console::endl;
38
-    getConsole() << "  volume     BOOL" << Console::endl;
39
-    getConsole() << "  mouse_x    FLOAT" << Console::endl;
40
-    getConsole() << "  mouse_y    FLOAT" << Console::endl;
41
-    getConsole() << "  fps        BOOL" << Console::endl;
42
-    getConsole() << "Enclose STRINGs with \"\"!" << Console::endl;
27
+    getLog() << "set-Command Usage:" << Log::endl;
28
+    getLog() << "  set VAR VAL" << Log::endl;
29
+    getLog() << "Available Variables:" << Log::endl;
30
+    getLog() << "  basedir    STRING" << Log::endl;
31
+    getLog() << "  pakdir     STRING" << Log::endl;
32
+    getLog() << "  audiodir   STRING" << Log::endl;
33
+    getLog() << "  datadir    STRING" << Log::endl;
34
+    getLog() << "  font       STRING" << Log::endl;
35
+    getLog() << "  size       INT INT" << Log::endl;
36
+    getLog() << "  fullscreen BOOL" << Log::endl;
37
+    getLog() << "  audio      BOOL" << Log::endl;
38
+    getLog() << "  volume     BOOL" << Log::endl;
39
+    getLog() << "  mouse_x    FLOAT" << Log::endl;
40
+    getLog() << "  mouse_y    FLOAT" << Log::endl;
41
+    getLog() << "  fps        BOOL" << Log::endl;
42
+    getLog() << "Enclose STRINGs with \"\"!" << Log::endl;
43
 }
43
 }
44
 
44
 
45
 namespace {
45
 namespace {
72
     if (var.compare("size") == 0) {
72
     if (var.compare("size") == 0) {
73
         unsigned int w = DEFAULT_WIDTH, h = DEFAULT_HEIGHT;
73
         unsigned int w = DEFAULT_WIDTH, h = DEFAULT_HEIGHT;
74
         if (!(args >> w >> h)) {
74
         if (!(args >> w >> h)) {
75
-            getConsole() << "set-size-Error: Invalid value(s)" << Console::endl;
75
+            getLog() << "set-size-Error: Invalid value(s)" << Log::endl;
76
             return -2;
76
             return -2;
77
         }
77
         }
78
         getWindow().setSize(w, h);
78
         getWindow().setSize(w, h);
79
     } else if (var.compare("fullscreen") == 0) {
79
     } else if (var.compare("fullscreen") == 0) {
80
         bool fullscreen = false;
80
         bool fullscreen = false;
81
         if (!(args >> fullscreen)) {
81
         if (!(args >> fullscreen)) {
82
-            getConsole() << "set-fullscreen-Error: Invalid value" << Console::endl;
82
+            getLog() << "set-fullscreen-Error: Invalid value" << Log::endl;
83
             return -3;
83
             return -3;
84
         }
84
         }
85
         getWindow().setFullscreen(fullscreen);
85
         getWindow().setFullscreen(fullscreen);
86
     } else if (var.compare("audio") == 0) {
86
     } else if (var.compare("audio") == 0) {
87
         bool audio = false;
87
         bool audio = false;
88
         if (!(args >> audio)) {
88
         if (!(args >> audio)) {
89
-            getConsole() << "set-audio-Error: Invalid value" << Console::endl;
89
+            getLog() << "set-audio-Error: Invalid value" << Log::endl;
90
             return -4;
90
             return -4;
91
         }
91
         }
92
         getSound().setEnabled(audio);
92
         getSound().setEnabled(audio);
93
     } else if (var.compare("volume") == 0) {
93
     } else if (var.compare("volume") == 0) {
94
         float vol = 1.0f;
94
         float vol = 1.0f;
95
         if (!(args >> vol)) {
95
         if (!(args >> vol)) {
96
-            getConsole() << "set-volume-Error: Invalid value" << Console::endl;
96
+            getLog() << "set-volume-Error: Invalid value" << Log::endl;
97
             return -5;
97
             return -5;
98
         }
98
         }
99
         getSound().setVolume(vol);
99
         getSound().setVolume(vol);
100
     } else if (var.compare("mouse_x") == 0) {
100
     } else if (var.compare("mouse_x") == 0) {
101
         float sense = 1.0f;
101
         float sense = 1.0f;
102
         if (!(args >> sense)) {
102
         if (!(args >> sense)) {
103
-            getConsole() << "set-mouse_x-Error: Invalid value" << Console::endl;
103
+            getLog() << "set-mouse_x-Error: Invalid value" << Log::endl;
104
             return -6;
104
             return -6;
105
         }
105
         }
106
         getCamera().setSensitivityX(OR_DEG_TO_RAD(sense));
106
         getCamera().setSensitivityX(OR_DEG_TO_RAD(sense));
107
     } else if (var.compare("mouse_y") == 0) {
107
     } else if (var.compare("mouse_y") == 0) {
108
         float sense = 1.0f;
108
         float sense = 1.0f;
109
         if (!(args >> sense)) {
109
         if (!(args >> sense)) {
110
-            getConsole() << "set-mouse_y-Error: Invalid value" << Console::endl;
110
+            getLog() << "set-mouse_y-Error: Invalid value" << Log::endl;
111
             return -7;
111
             return -7;
112
         }
112
         }
113
         getCamera().setSensitivityY(OR_DEG_TO_RAD(sense));
113
         getCamera().setSensitivityY(OR_DEG_TO_RAD(sense));
114
     } else if (var.compare("fps") == 0) {
114
     } else if (var.compare("fps") == 0) {
115
         bool fps = false;
115
         bool fps = false;
116
         if (!(args >> fps)) {
116
         if (!(args >> fps)) {
117
-            getConsole() << "set-fps-Error: Invalid value" << Console::endl;
117
+            getLog() << "set-fps-Error: Invalid value" << Log::endl;
118
             return -8;
118
             return -8;
119
         }
119
         }
120
         getRunTime().setFPS(fps);
120
         getRunTime().setFPS(fps);
139
         args >> temp;
139
         args >> temp;
140
         getFont().setFont(expandNames(temp).c_str());
140
         getFont().setFont(expandNames(temp).c_str());
141
     } else {
141
     } else {
142
-        getConsole() << "set-Error: Unknown variable (" << var.c_str() << ")" << Console::endl;
142
+        getLog() << "set-Error: Unknown variable (" << var.c_str() << ")" << Log::endl;
143
         return -1;
143
         return -1;
144
     }
144
     }
145
 
145
 

+ 6
- 6
src/commands/CommandSound.cpp View File

6
  */
6
  */
7
 
7
 
8
 #include "global.h"
8
 #include "global.h"
9
-#include "Console.h"
10
 #include "Game.h"
9
 #include "Game.h"
10
+#include "Log.h"
11
 #include "RunTime.h"
11
 #include "RunTime.h"
12
 #include "Sound.h"
12
 #include "Sound.h"
13
 #include "commands/CommandSound.h"
13
 #include "commands/CommandSound.h"
21
 }
21
 }
22
 
22
 
23
 void CommandSound::printHelp() {
23
 void CommandSound::printHelp() {
24
-    getConsole() << "sound-Command Usage:" << Console::endl;
25
-    getConsole() << "sound-Command Usage:" << Console::endl;
26
-    getConsole() << "  sound INT" << Console::endl;
27
-    getConsole() << "Where INT is a valid sound ID integer" << Console::endl;
24
+    getLog() << "sound-Command Usage:" << Log::endl;
25
+    getLog() << "sound-Command Usage:" << Log::endl;
26
+    getLog() << "  sound INT" << Log::endl;
27
+    getLog() << "Where INT is a valid sound ID integer" << Log::endl;
28
 }
28
 }
29
 
29
 
30
 int CommandSound::execute(std::istream& args) {
30
 int CommandSound::execute(std::istream& args) {
31
     if (!getGame().isLoaded()) {
31
     if (!getGame().isLoaded()) {
32
-        getConsole() << "Use sound command interactively!" << Console::endl;
32
+        getLog() << "Use sound command interactively!" << Log::endl;
33
         return -1;
33
         return -1;
34
     }
34
     }
35
 
35
 

+ 19
- 19
src/loader/LoaderTR2.cpp View File

10
 #include <vector>
10
 #include <vector>
11
 
11
 
12
 #include "global.h"
12
 #include "global.h"
13
-#include "Console.h"
13
+#include "Log.h"
14
 #include "loader/LoaderTR2.h"
14
 #include "loader/LoaderTR2.h"
15
 
15
 
16
 LoaderTR2::LoaderTR2() {
16
 LoaderTR2::LoaderTR2() {
29
     }
29
     }
30
 
30
 
31
     loadPaletteTextiles();
31
     loadPaletteTextiles();
32
-    getConsole() << "->loaded palette" << Console::endl;
32
+    getLog() << "->loaded palette" << Log::endl;
33
 
33
 
34
     file.seek(file.tell() + 4); // Unused value?
34
     file.seek(file.tell() + 4); // Unused value?
35
 
35
 
36
     loadRooms();
36
     loadRooms();
37
-    getConsole() << "->loaded rooms" << Console::endl;
37
+    getLog() << "->loaded rooms" << Log::endl;
38
 
38
 
39
     loadFloorData();
39
     loadFloorData();
40
-    getConsole() << "->loaded floor data" << Console::endl;
40
+    getLog() << "->loaded floor data" << Log::endl;
41
 
41
 
42
     loadMeshes();
42
     loadMeshes();
43
-    getConsole() << "->loaded meshes" << Console::endl;
43
+    getLog() << "->loaded meshes" << Log::endl;
44
 
44
 
45
     loadMoveables();
45
     loadMoveables();
46
-    getConsole() << "->loaded moveables" << Console::endl;
46
+    getLog() << "->loaded moveables" << Log::endl;
47
 
47
 
48
     loadStaticMeshes();
48
     loadStaticMeshes();
49
-    getConsole() << "->loaded static meshes" << Console::endl;
49
+    getLog() << "->loaded static meshes" << Log::endl;
50
 
50
 
51
     loadTextures();
51
     loadTextures();
52
-    getConsole() << "->loaded textures" << Console::endl;
52
+    getLog() << "->loaded textures" << Log::endl;
53
 
53
 
54
     loadSprites();
54
     loadSprites();
55
-    getConsole() << "->loaded sprites" << Console::endl;
55
+    getLog() << "->loaded sprites" << Log::endl;
56
 
56
 
57
     loadCameras();
57
     loadCameras();
58
-    getConsole() << "->loaded cameras" << Console::endl;
58
+    getLog() << "->loaded cameras" << Log::endl;
59
 
59
 
60
     loadSoundSources();
60
     loadSoundSources();
61
-    getConsole() << "->loaded sound sources" << Console::endl;
61
+    getLog() << "->loaded sound sources" << Log::endl;
62
 
62
 
63
     loadBoxesOverlapsZones();
63
     loadBoxesOverlapsZones();
64
-    getConsole() << "->loaded boxes overlaps zones" << Console::endl;
64
+    getLog() << "->loaded boxes overlaps zones" << Log::endl;
65
 
65
 
66
     loadAnimatedTextures();
66
     loadAnimatedTextures();
67
-    getConsole() << "->loaded animated textures" << Console::endl;
67
+    getLog() << "->loaded animated textures" << Log::endl;
68
 
68
 
69
     loadItems();
69
     loadItems();
70
-    getConsole() << "->loaded items" << Console::endl;
70
+    getLog() << "->loaded items" << Log::endl;
71
 
71
 
72
     file.seek(file.tell() + 8192); // Skip Light map, only for 8bit coloring
72
     file.seek(file.tell() + 8192); // Skip Light map, only for 8bit coloring
73
 
73
 
74
     loadCinematicFrames();
74
     loadCinematicFrames();
75
-    getConsole() << "->loaded cinematic frames" << Console::endl;
75
+    getLog() << "->loaded cinematic frames" << Log::endl;
76
 
76
 
77
     loadDemoData();
77
     loadDemoData();
78
-    getConsole() << "->loaded demo data" << Console::endl;
78
+    getLog() << "->loaded demo data" << Log::endl;
79
 
79
 
80
     loadSoundMap();
80
     loadSoundMap();
81
-    getConsole() << "->loaded sound map" << Console::endl;
81
+    getLog() << "->loaded sound map" << Log::endl;
82
 
82
 
83
     loadSoundDetails();
83
     loadSoundDetails();
84
-    getConsole() << "->loaded sound details" << Console::endl;
84
+    getLog() << "->loaded sound details" << Log::endl;
85
 
85
 
86
     loadSampleIndices();
86
     loadSampleIndices();
87
-    getConsole() << "->loaded sample indices" << Console::endl;
87
+    getLog() << "->loaded sample indices" << Log::endl;
88
 
88
 
89
     return 0;
89
     return 0;
90
 }
90
 }

+ 9
- 2
src/main.cpp View File

21
 #include "Debug.h"
21
 #include "Debug.h"
22
 #include "FontManager.h"
22
 #include "FontManager.h"
23
 #include "Game.h"
23
 #include "Game.h"
24
+#include "Log.h"
24
 #include "MenuFolder.h"
25
 #include "MenuFolder.h"
25
 #include "Render.h"
26
 #include "Render.h"
26
 #include "RunTime.h"
27
 #include "RunTime.h"
48
 static std::shared_ptr<Debug> gDebug;
49
 static std::shared_ptr<Debug> gDebug;
49
 static std::shared_ptr<FontManager> gFont;
50
 static std::shared_ptr<FontManager> gFont;
50
 static std::shared_ptr<Game> gGame;
51
 static std::shared_ptr<Game> gGame;
52
+static std::shared_ptr<Log> gLog;
51
 static std::shared_ptr<MenuFolder> gMenu;
53
 static std::shared_ptr<MenuFolder> gMenu;
52
 static std::shared_ptr<Render> gRender;
54
 static std::shared_ptr<Render> gRender;
53
 static std::shared_ptr<RunTime> gRunTime;
55
 static std::shared_ptr<RunTime> gRunTime;
76
     return *gGame;
78
     return *gGame;
77
 }
79
 }
78
 
80
 
81
+Log &getLog() {
82
+    return *gLog;
83
+}
84
+
79
 Menu &getMenu() {
85
 Menu &getMenu() {
80
     return *gMenu;
86
     return *gMenu;
81
 }
87
 }
119
     gDebug.reset(new Debug());
125
     gDebug.reset(new Debug());
120
     gFont.reset(new FontManager());
126
     gFont.reset(new FontManager());
121
     gGame.reset(new Game());
127
     gGame.reset(new Game());
128
+    gLog.reset(new Log());
122
     gMenu.reset(new MenuFolder());
129
     gMenu.reset(new MenuFolder());
123
     gRender.reset(new Render());
130
     gRender.reset(new Render());
124
     gRunTime.reset(new RunTime());
131
     gRunTime.reset(new RunTime());
145
         Command::executeFile(configFileToUse);
152
         Command::executeFile(configFileToUse);
146
     }
153
     }
147
 
154
 
148
-    getConsole() << "Initializing " << VERSION << Console::endl;
155
+    getLog() << "Initializing " << VERSION << Log::endl;
149
 
156
 
150
     // Initialize Windowing
157
     // Initialize Windowing
151
     int error = getWindow().initialize();
158
     int error = getWindow().initialize();
189
         return -6;
196
         return -6;
190
     }
197
     }
191
 
198
 
192
-    getConsole() << "Starting " << VERSION << Console::endl;
199
+    getLog() << "Starting " << VERSION << Log::endl;
193
     getMenu().moveToTop();
200
     getMenu().moveToTop();
194
     systemTimerReset();
201
     systemTimerReset();
195
     getRunTime().setRunning(true);
202
     getRunTime().setRunning(true);

Loading…
Cancel
Save