Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#include "Headers/GUIConsoleCommandParser.h"

#include "Core/Headers/ParamHandler.h"
#include "Managers/Headers/AIManager.h"
#include "Managers/Headers/SceneManager.h"
#include "Managers/Headers/ShaderManager.h"
#include "AI/PathFinding/NavMeshes/Headers/NavMesh.h" ///< For NavMesh creation

GUIConsoleCommandParser::GUIConsoleCommandParser() : _sound(NULL)
{
	_commandMap.insert(std::make_pair("say",DELEGATE_BIND(&GUIConsoleCommandParser::handleSayCommand,this,_1)));
	_commandMap.insert(std::make_pair("quit",DELEGATE_BIND(&GUIConsoleCommandParser::handleQuitCommand,this,_1)));
	_commandMap.insert(std::make_pair("help",DELEGATE_BIND(&GUIConsoleCommandParser::handleHelpCommand,this,_1)));
	_commandMap.insert(std::make_pair("editparam",DELEGATE_BIND(&GUIConsoleCommandParser::handleEditParamCommand,this,_1)));
	_commandMap.insert(std::make_pair("playsound",DELEGATE_BIND(&GUIConsoleCommandParser::handlePlaySoundCommand,this,_1)));
    _commandMap.insert(std::make_pair("createnavmesh",DELEGATE_BIND(&GUIConsoleCommandParser::handleNavMeshCommand,this,_1)));
	_commandMap.insert(std::make_pair("recompileshader",DELEGATE_BIND(&GUIConsoleCommandParser::handleShaderRecompileCommand,this,_1)));
	_commandMap.insert(std::make_pair("setfov",DELEGATE_BIND(&GUIConsoleCommandParser::handleFOVCommand,this,_1)));
	_commandMap.insert(std::make_pair("invalidcommand",DELEGATE_BIND(&GUIConsoleCommandParser::handleInvalidCommand,this,_1)));
	
	_commandHelp.insert(std::make_pair("say",Locale::get("CONSOLE_SAY_COMMAND_HELP")));
	_commandHelp.insert(std::make_pair("quit",Locale::get("CONSOLE_QUIT_COMMAND_HELP")));
	_commandHelp.insert(std::make_pair("help",Locale::get("CONSOLE_HELP_COMMAND_HELP")));
	_commandHelp.insert(std::make_pair("editparam",Locale::get("CONSOLE_EDITPARAM_COMMAND_HELP")));
	_commandHelp.insert(std::make_pair("playsound",Locale::get("CONSOLE_PLAYSOUND_COMMAND_HELP")));
    _commandHelp.insert(std::make_pair("createnavmesh",Locale::get("CONSOLE_NAVMESH_COMMAND_HELP")));
	_commandHelp.insert(std::make_pair("recompileshader",Locale::get("CONSOLE_SHADER_RECOMPILE_COMMAND_HELP")));
	_commandHelp.insert(std::make_pair("setfov",Locale::get("CONSOLE_CHANGE_FOV_COMMAND_HELP")));
	_commandHelp.insert(std::make_pair("invalidhelp",Locale::get("CONSOLE_INVALID_HELP_ARGUMENT")));
}

GUIConsoleCommandParser::~GUIConsoleCommandParser()
{
	if(_sound != NULL){
		RemoveResource(_sound);
	}
}

bool GUIConsoleCommandParser::processCommand(const std::string& commandString){
	// Be sure we have a string longer than 0
	if (commandString.length() >= 1) {
		// Check if the first letter is a 'command' operator
		if (commandString.at(0) == '/') 	{
			std::string::size_type commandEnd = commandString.find(" ", 1);
			std::string command = commandString.substr(1, commandEnd - 1);
			std::string commandArgs = commandString.substr(commandEnd + 1, commandString.length() - (commandEnd + 1));
			if(commandString.compare(commandArgs) == 0) commandArgs.clear();
			//convert command to lower case
			for(std::string::size_type i=0; i < command.length(); i++){
				command[i] = tolower(command[i]);
			}
			if(_commandMap.find(command) != _commandMap.end()){
				//we have a valid command
				_commandMap[command](commandArgs);
			}else{
				//invalid command
				_commandMap["invalidcommand"](command);
			}
		} else	{
			PRINT_FN("%s",commandString.c_str()); // no commands, just output what was typed
		}
	}
	return true;
}

void GUIConsoleCommandParser::handleSayCommand(const std::string& args){
	PRINT_FN(Locale::get("CONSOLE_SAY_NAME_TAG"),args.c_str());
}

void GUIConsoleCommandParser::handleQuitCommand(const std::string& args){
	if(!args.empty()){
		//quit command can take an extra argument. A reason, for example
		PRINT_FN(Locale::get("CONSOLE_QUIT_COMMAND_ARGUMENT"), args.c_str());
	}
	Application::getInstance().RequestShutdown();
}

void GUIConsoleCommandParser::handleHelpCommand(const std::string& args){
	if(args.empty()){
		PRINT_FN(Locale::get("HELP_CONSOLE_COMMAND"));
		for_each(CommandMap::value_type& it,_commandMap){
            if(it.first.find("invalid") == std::string::npos){
			    PRINT_FN("/%s - %s",it.first.c_str(),_commandHelp[it.first]);
            }
		}
	}else{
		if(_commandHelp.find(args) != _commandHelp.end()){
			PRINT_FN("%s", _commandHelp[args]);
		}else{
			PRINT_FN("%s",_commandHelp["invalidhelp"]);
		}
	}
}

void GUIConsoleCommandParser::handleEditParamCommand(const std::string& args){
	if(ParamHandler::getInstance().isParam(args)){
		PRINT_FN(Locale::get("CONSOLE_EDITPARAM_FOUND"), args.c_str(), "N/A", "N/A", "N/A");
	}else{
		PRINT_FN(Locale::get("CONSOLE_EDITPARAM_NOT_FOUND"), args.c_str());
	}
}

void GUIConsoleCommandParser::handlePlaySoundCommand(const std::string& args){
	std::string filename = ParamHandler::getInstance().getParam<std::string>("assetsLocation")+"/" + args;
	std::ifstream soundfile(filename.c_str());
	if (soundfile) {
		//Check extensions (not really, musicwav.abc would still be valid, but still ...)
		if(filename.substr(filename.length()-4,filename.length()).compare(".wav") != 0 &&
		   filename.substr(filename.length()-4,filename.length()).compare(".mp3") != 0 &&
		   filename.substr(filename.length()-4,filename.length()).compare(".ogg") != 0){
			   ERROR_FN(Locale::get("CONSOLE_PLAY_SOUND_INVALID_FORMAT"));
			   return;
		}
		if(_sound != NULL) RemoveResource(_sound);

		//The file is valid, so create a descriptor for it
		ResourceDescriptor sound("consoleFilePlayback");
		sound.setResourceLocation(filename);
		sound.setFlag(false);
		_sound = CreateResource<AudioDescriptor>(sound);
		if(filename.find("music") != std::string::npos){
			//play music
			SFXDevice::getInstance().playMusic(_sound);
		}else{
			//play sound but stop music first if it's playing
			SFXDevice::getInstance().stopMusic();
			SFXDevice::getInstance().playSound(_sound);
		}
	}else{
		ERROR_FN(Locale::get("CONSOLE_PLAY_SOUND_INVALID_FILE"),filename.c_str());
	}
}

void GUIConsoleCommandParser::handleNavMeshCommand(const std::string& args){
    SceneGraphNode* sgn = NULL;
    if(!args.empty()){
        sgn = GET_ACTIVE_SCENEGRAPH()->findNode("args");
        if(!sgn){
            ERROR_FN(Locale::get("CONSOLE_NAVMESH_NO_NODE"),args.c_str());
            return;
        }
    }
    Navigation::NavigationMesh* temp = New Navigation::NavigationMesh();
    temp->setFileName(GET_ACTIVE_SCENE()->getName());
    if(!temp->load(sgn)){
        temp->build(sgn,false);
    }
    temp->save();
    AIManager::getInstance().addNavMesh(temp);
}

void GUIConsoleCommandParser::handleShaderRecompileCommand(const std::string& args){
	ShaderManager::getInstance().recompileShaderProgram(args);
}

void GUIConsoleCommandParser::handleFOVCommand(const std::string& args){
	if(!Util::isNumber(args)){
		ERROR_FN(Locale::get("CONSOLE_INVALID_NUMBER"));
		return;
	}
	I32 FoV = (atoi(args.c_str()));
	CLAMP<I32>(FoV,40,140);
	GFX_DEVICE.setHorizontalFoV(FoV);
}

void GUIConsoleCommandParser::handleInvalidCommand(const std::string& args){
	ERROR_FN(Locale::get("CONSOLE_INVALID_COMMAND"),args.c_str());
}

Commits for Divide-Framework/trunk/Source Code/GUI/GUIConsoleCommandParser.cpp

Diff revisions: vs.
Revision Author Commited Message
168 Diff Diff k1ngp1n picture k1ngp1n Sat 26 Oct, 2013 19:03:21 +0000

- Reworked the Camera class[[BR]]
— Now fully quaternion based [[BR]]
— Basic camera types added but not used yet (third person, first person, orbit) [[BR]]
- Cleaned up Material and Texture handling [[BR]]
- Added clipping plane support [[BR]]
— Similar to OpenGL fixed-function clip planes but fully shader driven [[BR]]
— Added a new class, “Plane”, that helps define clip planes [[BR]]
- Optimized the Singleton class to allow faster “getInstance” calls without performance penalties [[BR]]
-- “createInstance” must be called for each singleton class before usage. Or “gerOrCreateInstance” can be used, which is basically the former “getInstance” implementation [[BR]]
- Improved console logging by changing some heap allocations to stack and removing dependencies on the std::string class [[BR]]
- Added a lot of performance optimizations related to coding standards and redundant calculations [[BR]]
— e.g. Frustum AABB check didn’t need to recompute the AABB points as they were calculated already [[BR]]
— e.g. A vector did not need to be set to 0 on initialization as that is already it’s default state on creation [[BR]]
— e.g. Faster Framerate and Timing calculations by using less member variables that are not needed outsied of calling functions [[BR]]
- The SceneState now contains the SceneRenderState and is passed on to the SceneGraph’s update calls [[BR]]
- Better material export/import to/from XML format [[BR]]
- More bug fixes and cleanups [[BR]]

156 Diff Diff k1ngp1n picture k1ngp1n Thu 04 Jul, 2013 21:50:54 +0000

[Ionut] [[BR]]
- More work on Navigation Mesh creation [[BR]]
- IMEmulation primitives were not recycled properly (old, unused primitives were saved, new ones were deleted and recreated – behavior reversed ) [[BR]]

152 Diff Diff k1ngp1n picture k1ngp1n Thu 20 Jun, 2013 14:23:31 +0000

[Ionut] [[BR]]
- New rendering pipeline (experimental and unstable): [[BR]]
— OpenGL 3.x clean context (glLight commands are still used for now, but UBO support is there, but not used yet) [[BR]]
— Custom matrix stacks and UBO based shader data (UBOs cause some link errors on some nVidia cards)[[BR]]
— Multi-threaded texture loading and shader compilation (mt shader compilation disabled for now. needs more tests) [[BR]]
— VAO rendering is self contained (no more enable/disable calls before a draw request) [[BR]]
— Render instance class used for rendering information [[BR]]
[[BR]]
- New unique ID generation base class: GUIDWrapper. Each class that derives from this, gets an application wide unique id on construction [[BR]]
- Added base code for an in-game editor using CEGUI [[BR]]
- Replaced some mutex locks with lockless data structures or atomic data [[BR]]
- CEGUI 0.8.2, FTGL-GL3 and GLIM 0.4 modified to support GLEW_MX if defined [[BR]]
- Dropped VS2008 support [[BR]]
- Networking library, server framework and ReCast files are now projects inside the Divide Framework solution [[BR]]
- New console command “setFov” that modifies the horizontal FoV value in realtime [[BR]]
- New console command “recompileShader” that reparses shader files, recompiles shaders and relinks shader programs who’s names match or contain the argument string [[BR]]
- New debug utility: axis angle drawn in corner of the screen if needed [[BR]]
- More ‘const’-s pasted around the code, more loop performance tweaks (allocations before a loop, tighter loops, etc), more utility member functions added to various classes [[BR]]

151 Diff Diff k1ngp1n picture k1ngp1n Tue 07 May, 2013 00:00:52 +0000

[Ionut] [[BR]]
- Better ReCast integration [[BR]]
— Any entity can be used as an obstacle in the NavMesh if that’s specified in each scene’s assets.xml file for said entity [[BR]]
— New console command, “createNavMesh”, that passes geometry data to ReCast [[BR]]
-— NavMesh generation is not yet complete [[BR]]
- Better PhysX integration [[BR]]
— Each scene passes data to and gets data from the Physics API better and safer[[BR]]
- Multi-threaded support extended: [[BR]]
— Event class replaced with Task [[BR]]
— Kernel uses a threadpool for scene tasks [[BR]]
— Each task can be added to a different threadpool if needed [[BR]]
— Most critical sections use the new boost::atomic wrapper for thread safety [[BR]]
- Rendering system updated [[BR]]
— VBO’s keep track of the geometry type internally [[BR]]
— Rendering by specific element list is internal to the VBO [[BR]]
— VBO’s can draw a “lite” version that doesn’t send Tangent, BiTangent and TexCoord data for depth rendering (disabled) [[BR]]
- Reflectors now offer a preview of the generated reflective texture if needed [[BR]]
- Buttons are now added and rendered by CEGUI [[BR]]
[[BR]]
Deprecation: [[BR]]
- Removed fixed pipeline material system [[BR]]
- Removed BoundingBox late update system [[BR]]
- Shadow references in the material system are now depth references [[BR]]
[[BR]]
Bug fixes: [[BR]]
- Problematic FBO double bind check removed [[BR]]
- Faster terrain rendering via chunk size selection through each scene’s terrain.xml[[BR]]
- Rendering is paused when the window is minimized [[BR]]
- CEGUI and impostors now render properly in deferred rendering mode [[BR]]
- Fixed various level 4 (VS2008) warnings [[BR]]
- Better state management and cleaning [[BR]]
- Better SceneGraph node management and trasformation/AABB update calls [[BR]]
- AITenisScene has proper collisions now [[BR]]

150 k1ngp1n picture k1ngp1n Mon 22 Apr, 2013 21:45:43 +0000

[Ionut] [[BR]]
- Fixed AudioDescriptor class (used ResourceDescriptor’s name instead of location for file lookup) [[BR]]
- Added a GUIConsoleCommandParser that stores a function pointer for each command [[BR]]
- Added console command history navigation with the Up and Down arrow keys [[BR]]
- Added playSound (sounds or music) console command [[BR]]
- Added help command argument support (show help for a specific command) [[BR]]
- Added quit command argument that will print a message before exiting the application [[BR]]
- Initial code for ParamHandler type storage (memorize each param’s type and allow it to be looked up) [[BR]]