Implemented command line config overrides

You can set the file to read as the config file via the command line, like
this, assuming the program supports it:

  prog -config=file.cfg

You can also override indevidual key-value pairs in the config system
using this syntax:

  prog -Ckey=value

Both commands can be used together, and you can override multiple
key-value pairs at once. To use this feature of the ConfigUtility, it must
receive argc and argv as parameters to the Load() method.
This commit is contained in:
Kayne Ruse
2014-09-28 02:11:26 +10:00
parent 9367bd802f
commit 59e3518dd8
10 changed files with 74 additions and 30 deletions
+2 -2
View File
@@ -45,12 +45,12 @@
//Public access members
//-------------------------
void ClientApplication::Init(int argc, char** argv) {
void ClientApplication::Init(int argc, char* argv[]) {
std::cout << "Beginning " << argv[0] << std::endl;
//load the prerequisites
ConfigUtility& config = ConfigUtility::GetSingleton();
config.Load("rsc\\config.cfg");
config.Load("rsc\\config.cfg", argc, argv);
//-------------------------
//Initialize the APIs
+1 -1
View File
@@ -35,7 +35,7 @@
class ClientApplication: public Singleton<ClientApplication> {
public:
//public methods
void Init(int argc, char** argv);
void Init(int argc, char* argv[]);
void Proc();
void Quit();
+1 -1
View File
@@ -30,7 +30,7 @@
using namespace std;
int main(int argc, char** argv) {
int main(int argc, char* argv[]) {
try {
//create the singletons
ConfigUtility::Create();
+2 -4
View File
@@ -25,7 +25,6 @@
#include "utility.hpp"
#include <stdexcept>
#include <iostream>
//-------------------------
//Public access members
@@ -113,7 +112,7 @@ void LobbyMenu::Render(SDL_Surface* const screen) {
(Uint16)listBox.w, (Uint16)listBox.h
};
r.y += i * listBox.h;
SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 255, 127, 39));
SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 49, 150, 5));
}
//draw the server name
@@ -226,8 +225,7 @@ void LobbyMenu::HandleJoinResponse(ClientPacket* const argPacket) {
}
void LobbyMenu::HandleJoinRejection(TextPacket* const argPacket) {
//TODO: Better output
std::cerr << "Error: " << argPacket->text << std::endl;
//TODO: Better output for join rejection
}
//-------------------------