Преглед на файлове

Implemented get command

Thomas Buck преди 10 години
родител
ревизия
86066a01ca
променени са 13 файла, в които са добавени 101 реда и са изтрити 22 реда
  1. 3
    0
      ChangeLog.md
  2. 8
    4
      include/Camera.h
  3. 2
    0
      include/Font.h
  4. 1
    1
      include/Log.h
  5. 4
    0
      include/Sound.h
  6. 4
    0
      include/SoundAL.h
  7. 4
    0
      include/SoundNull.h
  8. 2
    0
      include/Window.h
  9. 8
    0
      include/commands/CommandSet.h
  10. 0
    16
      src/Camera.cpp
  11. 2
    1
      src/Log.cpp
  12. 1
    0
      src/commands/Command.cpp
  13. 62
    0
      src/commands/CommandSet.cpp

+ 3
- 0
ChangeLog.md Целия файл

@@ -2,6 +2,9 @@
2 2
 
3 3
 ## OpenRaider (0.1.3) xythobuz <xythobuz@xythobuz.de>
4 4
 
5
+    [ 20141031 ]
6
+    * Added get command
7
+
5 8
     [ 20141018 ]
6 9
     * Added target to auto-indent code using astyle and used it.
7 10
 

+ 8
- 4
include/Camera.h Целия файл

@@ -41,13 +41,13 @@ class Camera {
41 41
      * \brief Get angle/yaw of camera
42 42
      * \returns theta angle/yaw of camera
43 43
      */
44
-    float getRadianYaw();
44
+    float getRadianYaw() { return mTheta; }
45 45
 
46 46
     /*!
47 47
      * \brief Get angle/pitch of camera
48 48
      * \returns phi angle/pitch of camera
49 49
      */
50
-    float getRadianPitch();
50
+    float getRadianPitch() { return mTheta2; }
51 51
 
52 52
     /*!
53 53
      * \brief Set current position
@@ -55,9 +55,13 @@ class Camera {
55 55
      */
56 56
     void setPosition(float pos[3]);
57 57
 
58
-    void setSensitivityX(float sens);
58
+    void setSensitivityX(float sens) { mRotationDeltaX = sens; }
59 59
 
60
-    void setSensitivityY(float sens);
60
+    float getSensitivityX() { return mRotationDeltaX; }
61
+
62
+    void setSensitivityY(float sens) { mRotationDeltaY = sens; }
63
+
64
+    float getSensitivityY() { return mRotationDeltaY; }
61 65
 
62 66
     /*!
63 67
      * \brief Updates view target

+ 2
- 0
include/Font.h Целия файл

@@ -19,6 +19,8 @@ class Font {
19 19
 
20 20
     static int initialize(std::string font = "");
21 21
 
22
+    static std::string getFontName() { return fontName; }
23
+
22 24
     static unsigned int widthText(float scale, std::string s);
23 25
 
24 26
     static unsigned int heightText(float scale, unsigned int maxWidth, std::string s);

+ 1
- 1
include/Log.h Целия файл

@@ -17,7 +17,7 @@ class Log {
17 17
 
18 18
     const static char endl = '\n';
19 19
 
20
-    ~Log();
20
+    Log();
21 21
 
22 22
     unsigned long size();
23 23
     std::string get(unsigned long i);

+ 4
- 0
include/Sound.h Целия файл

@@ -33,12 +33,16 @@ class Sound {
33 33
 
34 34
     virtual void setEnabled(bool on) = 0;
35 35
 
36
+    virtual bool getEnabled() = 0;
37
+
36 38
     /*!
37 39
      * \brief Set the volume
38 40
      * \param vol new source gain
39 41
      */
40 42
     virtual void setVolume(float vol) = 0;
41 43
 
44
+    virtual float getVolume() = 0;
45
+
42 46
     /*!
43 47
      * \brief Get number of registered sources
44 48
      * \returns number of registered sources

+ 4
- 0
include/SoundAL.h Целия файл

@@ -37,12 +37,16 @@ class SoundAL : public Sound {
37 37
 
38 38
     virtual void setEnabled(bool on);
39 39
 
40
+    virtual bool getEnabled() { return mEnabled; }
41
+
40 42
     /*!
41 43
      * \brief Set the volume
42 44
      * \param vol new source gain
43 45
      */
44 46
     virtual void setVolume(float vol);
45 47
 
48
+    virtual float getVolume() { return mVolume; }
49
+
46 50
     /*!
47 51
      * \brief Get number of registered sources
48 52
      * \returns number of registered sources

+ 4
- 0
include/SoundNull.h Целия файл

@@ -34,12 +34,16 @@ class SoundNull : public Sound {
34 34
 
35 35
     virtual void setEnabled(bool on);
36 36
 
37
+    virtual bool getEnabled() { return false; }
38
+
37 39
     /*!
38 40
      * \brief Set the volume
39 41
      * \param vol new source gain
40 42
      */
41 43
     virtual void setVolume(float vol);
42 44
 
45
+    virtual float getVolume() { return 0.0f; }
46
+
43 47
     /*!
44 48
      * \brief Get number of registered sources
45 49
      * \returns number of registered sources

+ 2
- 0
include/Window.h Целия файл

@@ -20,6 +20,8 @@ class Window {
20 20
 
21 21
     virtual void setFullscreen(bool fullscreen) = 0;
22 22
 
23
+    virtual bool getFullscreen() { return mFullscreen; }
24
+
23 25
     virtual void setMousegrab(bool grab) = 0;
24 26
 
25 27
     virtual bool getMousegrab() { return mMousegrab; }

+ 8
- 0
include/commands/CommandSet.h Целия файл

@@ -18,5 +18,13 @@ class CommandSet : public Command {
18 18
     virtual int execute(std::istream& args);
19 19
 };
20 20
 
21
+class CommandGet : public Command {
22
+  public:
23
+    virtual std::string name();
24
+    virtual std::string brief();
25
+    virtual void printHelp();
26
+    virtual int execute(std::istream& args);
27
+};
28
+
21 29
 #endif
22 30
 

+ 0
- 16
src/Camera.cpp Целия файл

@@ -35,28 +35,12 @@ void Camera::getTarget(float target[3]) {
35 35
     target[2] = mTarget[2];
36 36
 }
37 37
 
38
-float Camera::getRadianYaw() {
39
-    return mTheta;
40
-}
41
-
42
-float Camera::getRadianPitch() {
43
-    return mTheta2;
44
-}
45
-
46 38
 void Camera::setPosition(float pos[3]) {
47 39
     mPos[0] = pos[0];
48 40
     mPos[1] = pos[1];
49 41
     mPos[2] = pos[2];
50 42
 }
51 43
 
52
-void Camera::setSensitivityX(float sens) {
53
-    mRotationDeltaX = sens;
54
-}
55
-
56
-void Camera::setSensitivityY(float sens) {
57
-    mRotationDeltaY = sens;
58
-}
59
-
60 44
 void Camera::update() {
61 45
     mTarget[0] = (mViewDistance * std::sin(mTheta)) + mPos[0];
62 46
     mTarget[1] = (mViewDistance * std::sin(mTheta2)) + mPos[1]; // + height_offset;

+ 2
- 1
src/Log.cpp Целия файл

@@ -8,7 +8,8 @@
8 8
 #include "global.h"
9 9
 #include "Log.h"
10 10
 
11
-Log::~Log() {
11
+Log::Log() {
12
+    printBuffer << std::boolalpha;
12 13
 }
13 14
 
14 15
 unsigned long Log::size() {

+ 1
- 0
src/commands/Command.cpp Целия файл

@@ -35,6 +35,7 @@ void Command::fillCommandList() {
35 35
     commands.push_back(std::shared_ptr<Command>(new CommandLoad()));
36 36
     commands.push_back(std::shared_ptr<Command>(new CommandBind()));
37 37
     commands.push_back(std::shared_ptr<Command>(new CommandSet()));
38
+    commands.push_back(std::shared_ptr<Command>(new CommandGet()));
38 39
     commands.push_back(std::shared_ptr<Command>(new CommandScreenshot()));
39 40
     commands.push_back(std::shared_ptr<Command>(new CommandAnimate()));
40 41
     commands.push_back(std::shared_ptr<Command>(new CommandMove()));

+ 62
- 0
src/commands/CommandSet.cpp Целия файл

@@ -148,3 +148,65 @@ int CommandSet::execute(std::istream& args) {
148 148
     return 0;
149 149
 }
150 150
 
151
+std::string CommandGet::name() {
152
+    return "get";
153
+}
154
+
155
+std::string CommandGet::brief() {
156
+    return "get a parameter";
157
+}
158
+
159
+void CommandGet::printHelp() {
160
+    getLog() << "get-Command Usage:" << Log::endl;
161
+    getLog() << "  get VAR" << Log::endl;
162
+    getLog() << "Available Variables:" << Log::endl;
163
+    getLog() << "  basedir" << Log::endl;
164
+    getLog() << "  pakdir" << Log::endl;
165
+    getLog() << "  audiodir" << Log::endl;
166
+    getLog() << "  datadir" << Log::endl;
167
+    getLog() << "  font" << Log::endl;
168
+    getLog() << "  size" << Log::endl;
169
+    getLog() << "  fullscreen" << Log::endl;
170
+    getLog() << "  audio" << Log::endl;
171
+    getLog() << "  volume" << Log::endl;
172
+    getLog() << "  mouse_x" << Log::endl;
173
+    getLog() << "  mouse_y" << Log::endl;
174
+    getLog() << "  fps" << Log::endl;
175
+}
176
+
177
+int CommandGet::execute(std::istream& args) {
178
+    std::string var;
179
+    args >> var;
180
+
181
+    if (var.compare("size") == 0) {
182
+        getLog() << getWindow().getWidth() << " " << getWindow().getHeight() << Log::endl;
183
+    } else if (var.compare("fullscreen") == 0) {
184
+        getLog() << getWindow().getFullscreen() << Log::endl;
185
+    } else if (var.compare("audio") == 0) {
186
+        getLog() << getSound().getEnabled() << Log::endl;
187
+    } else if (var.compare("volume") == 0) {
188
+        getLog() << getSound().getVolume() << Log::endl;
189
+    } else if (var.compare("mouse_x") == 0) {
190
+        getLog() << OR_RAD_TO_DEG(getCamera().getSensitivityX()) << Log::endl;
191
+    } else if (var.compare("mouse_y") == 0) {
192
+        getLog() << OR_RAD_TO_DEG(getCamera().getSensitivityY()) << Log::endl;
193
+    } else if (var.compare("fps") == 0) {
194
+        getLog() << getRunTime().getFPS() << Log::endl;
195
+    } else if (var.compare("basedir") == 0) {
196
+        getLog() << getRunTime().getBaseDir() << Log::endl;
197
+    } else if (var.compare("pakdir") == 0) {
198
+        getLog() << getRunTime().getPakDir() << Log::endl;
199
+    } else if (var.compare("audiodir") == 0) {
200
+        getLog() << getRunTime().getAudioDir() << Log::endl;
201
+    } else if (var.compare("datadir") == 0) {
202
+        getLog() << getRunTime().getDataDir() << Log::endl;
203
+    } else if (var.compare("font") == 0) {
204
+        getLog() << Font::getFontName() << Log::endl;
205
+    } else {
206
+        getLog() << "get-Error: Unknown variable (" << var << ")" << Log::endl;
207
+        return -1;
208
+    }
209
+
210
+    return 0;
211
+}
212
+

Loading…
Отказ
Запис