Browse Source

Implemented get command

Thomas Buck 10 years ago
parent
commit
86066a01ca

+ 3
- 0
ChangeLog.md View File

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

+ 8
- 4
include/Camera.h View File

41
      * \brief Get angle/yaw of camera
41
      * \brief Get angle/yaw of camera
42
      * \returns theta angle/yaw of camera
42
      * \returns theta angle/yaw of camera
43
      */
43
      */
44
-    float getRadianYaw();
44
+    float getRadianYaw() { return mTheta; }
45
 
45
 
46
     /*!
46
     /*!
47
      * \brief Get angle/pitch of camera
47
      * \brief Get angle/pitch of camera
48
      * \returns phi angle/pitch of camera
48
      * \returns phi angle/pitch of camera
49
      */
49
      */
50
-    float getRadianPitch();
50
+    float getRadianPitch() { return mTheta2; }
51
 
51
 
52
     /*!
52
     /*!
53
      * \brief Set current position
53
      * \brief Set current position
55
      */
55
      */
56
     void setPosition(float pos[3]);
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
      * \brief Updates view target
67
      * \brief Updates view target

+ 2
- 0
include/Font.h View File

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

+ 1
- 1
include/Log.h View File

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

+ 4
- 0
include/Sound.h View File

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

+ 4
- 0
include/SoundAL.h View File

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

+ 4
- 0
include/SoundNull.h View File

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

+ 2
- 0
include/Window.h View File

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

+ 8
- 0
include/commands/CommandSet.h View File

18
     virtual int execute(std::istream& args);
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
 #endif
29
 #endif
22
 
30
 

+ 0
- 16
src/Camera.cpp View File

35
     target[2] = mTarget[2];
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
 void Camera::setPosition(float pos[3]) {
38
 void Camera::setPosition(float pos[3]) {
47
     mPos[0] = pos[0];
39
     mPos[0] = pos[0];
48
     mPos[1] = pos[1];
40
     mPos[1] = pos[1];
49
     mPos[2] = pos[2];
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
 void Camera::update() {
44
 void Camera::update() {
61
     mTarget[0] = (mViewDistance * std::sin(mTheta)) + mPos[0];
45
     mTarget[0] = (mViewDistance * std::sin(mTheta)) + mPos[0];
62
     mTarget[1] = (mViewDistance * std::sin(mTheta2)) + mPos[1]; // + height_offset;
46
     mTarget[1] = (mViewDistance * std::sin(mTheta2)) + mPos[1]; // + height_offset;

+ 2
- 1
src/Log.cpp View File

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

+ 1
- 0
src/commands/Command.cpp View File

35
     commands.push_back(std::shared_ptr<Command>(new CommandLoad()));
35
     commands.push_back(std::shared_ptr<Command>(new CommandLoad()));
36
     commands.push_back(std::shared_ptr<Command>(new CommandBind()));
36
     commands.push_back(std::shared_ptr<Command>(new CommandBind()));
37
     commands.push_back(std::shared_ptr<Command>(new CommandSet()));
37
     commands.push_back(std::shared_ptr<Command>(new CommandSet()));
38
+    commands.push_back(std::shared_ptr<Command>(new CommandGet()));
38
     commands.push_back(std::shared_ptr<Command>(new CommandScreenshot()));
39
     commands.push_back(std::shared_ptr<Command>(new CommandScreenshot()));
39
     commands.push_back(std::shared_ptr<Command>(new CommandAnimate()));
40
     commands.push_back(std::shared_ptr<Command>(new CommandAnimate()));
40
     commands.push_back(std::shared_ptr<Command>(new CommandMove()));
41
     commands.push_back(std::shared_ptr<Command>(new CommandMove()));

+ 62
- 0
src/commands/CommandSet.cpp View File

148
     return 0;
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…
Cancel
Save