Browse Source

Added help command

Thomas Buck 11 years ago
parent
commit
48b09ec110
2 changed files with 72 additions and 10 deletions
  1. 12
    10
      include/OpenRaider.h
  2. 60
    0
      src/OpenRaider.cpp

+ 12
- 10
include/OpenRaider.h View File

54
 
54
 
55
     int command(const char *command);
55
     int command(const char *command);
56
 
56
 
57
-    int command(const char *command, std::vector<char *> *args);
58
-
59
-    char *expandDirectoryNames(const char *s);
60
-
61
-    int set(const char *var, const char *value);
62
-
63
-    int bind(const char *action, const char *key);
64
-
65
-    int bind(ActionEvents action, const char *key);
66
-
67
     int initialize();
57
     int initialize();
68
 
58
 
69
     void run();
59
     void run();
86
 
76
 
87
 private:
77
 private:
88
 
78
 
79
+    int command(const char *command, std::vector<char *> *args);
80
+
81
+    char *expandDirectoryNames(const char *s);
82
+
83
+    int help(const char *cmd);
84
+
85
+    int set(const char *var, const char *value);
86
+
87
+    int bind(const char *action, const char *key);
88
+
89
+    int bind(ActionEvents action, const char *key);
90
+
89
     void loadPakFolderRecursive(const char *dir);
91
     void loadPakFolderRecursive(const char *dir);
90
 
92
 
91
     void fillMapList();
93
     void fillMapList();

+ 60
- 0
src/OpenRaider.cpp View File

150
         }
150
         }
151
     } else if (strcmp(command, "quit") == 0) {
151
     } else if (strcmp(command, "quit") == 0) {
152
         exit(0);
152
         exit(0);
153
+    } else if (strcmp(command, "help") == 0) {
154
+        if (args->size() == 0) {
155
+            mConsole->print("Available commands:");
156
+            mConsole->print("  set");
157
+            mConsole->print("  bind");
158
+            mConsole->print("  help");
159
+            mConsole->print("  quit");
160
+            mConsole->print("Use help COMMAND to get additional info");
161
+        } else if (args->size() == 1) {
162
+            return help(args->at(0));
163
+        } else {
164
+            mConsole->print("Invalid use of help-command ");
165
+            printStringVector(args);
166
+            printf("\n");
167
+            return -4;
168
+        }
153
     } else {
169
     } else {
154
         mConsole->print("Unknown command: %s ", command);
170
         mConsole->print("Unknown command: %s ", command);
155
         printStringVector(args);
171
         printStringVector(args);
156
         printf("\n");
172
         printf("\n");
157
         return -1;
173
         return -1;
158
     }
174
     }
175
+
176
+    return 0;
177
+}
178
+
179
+int OpenRaider::help(const char *cmd) {
180
+    if (strcmp(cmd, "set") == 0) {
181
+        mConsole->print("set-Command Usage:");
182
+        mConsole->print("  set VAR VAL");
183
+        mConsole->print("Available Variables:");
184
+        mConsole->print("  basedir     STRING");
185
+        mConsole->print("  pakdir      STRING");
186
+        mConsole->print("  audiodir    STRING");
187
+        mConsole->print("  datadir     STRING");
188
+        mConsole->print("  font        STRING");
189
+        mConsole->print("  gldriver    STRING");
190
+        mConsole->print("  size        \"INTxINT\"");
191
+        mConsole->print("  fullscreen  BOOL");
192
+        mConsole->print("  audio       BOOL");
193
+        mConsole->print("  volume      BOOL");
194
+        mConsole->print("  mouse_x     FLOAT");
195
+        mConsole->print("  mouse_y     FLOAT");
196
+    } else if (strcmp(cmd, "bind") == 0) {
197
+        mConsole->print("bind-Command Usage:");
198
+        mConsole->print("  bind ACTION KEY");
199
+        mConsole->print("Available Actions:");
200
+        mConsole->print("  menu");
201
+        mConsole->print("  console");
202
+        mConsole->print("  forward");
203
+        mConsole->print("  backward");
204
+        mConsole->print("  left");
205
+        mConsole->print("  right");
206
+        mConsole->print("  jump");
207
+        mConsole->print("  crouch");
208
+        mConsole->print("  use");
209
+        mConsole->print("  holster");
210
+        mConsole->print("Key-Format:");
211
+        mConsole->print("  'a' or '1'    for character/number keys");
212
+        mConsole->print("  \"leftctrl\"  for symbols and special keys");
213
+    } else {
214
+        mConsole->print("No help available for %s", cmd);
215
+        return -1;
216
+    }
217
+
218
+    return 0;
159
 }
219
 }
160
 
220
 
161
 char *OpenRaider::expandDirectoryNames(const char *s) {
221
 char *OpenRaider::expandDirectoryNames(const char *s) {

Loading…
Cancel
Save