• entries
707
1173
• views
436347

# Untitled

77 views

Evidentally I'm not supposed to get help from an employment group since we got all the way over there (about an hour and a half drive due to traffic) to find out that they've moved. We would have went to the new building, but it was already pushing it (it was 4:40pm when we got to the old building and they close at 5pm) so we decided that there would be no way to make it in time (way on the other side of Lansing.)

So, I decided to come back to his house and crash. Thankfully we snagged my computer and wireless router (after a huge hassel from my parents even though I'm the one that bought the damn thing and they barely even use the internet.) Pretty much the same thing happened that always does (we got here, played Diablo 2 for about 2 hours (separately, though he did help me a couple times since I had to start a new character) and then he went and crashed (around midnight.)) So, I've been sitting here working on my console system for the past few hours and I'm glad I did (even though it'd be more comfortable at home. For some reason they don't use heat here or something.) Anyway, I'll show a screeny and then describe some of it's features:

So, as you can see it supports multiple variable types (not scripting style; registered variables via C++). The types that are supported are int, float, bool, std::string, and DebugConsoleFunction (which is defined as void (*DebugConsoleFunction)(const std::vector&).)

I've got the basics done already - variable assignment, add-assign combo, subtract-assign combo, multiply-assign combo, divide-assign combo, and function calling. I almost have variable-function-return assignment done, but I've run into some issues.

Int and float both support all 5 assignment operations while bool supports none and string supports only the assignment and add-assign combo operations.

The C++ code to set it up is plain and simple:
// Our variablesDebugConsole Console;std::string Name;int Health;void dcfPrint(const std::vector& Arguments){	std::string Text = "";	for(std::vector::const_iterator Itor = Arguments.begin(); Itor != Arguments.end(); ++Itor)		Text += (*Itor);	Console->AddString(Text);}// Register some variables. Notice that all variable types (even functions) use the same function. I should probably change the name to just Register().Console.RegisterVariable("Health", &Health);Console.RegisterVariable("Name", &Name);Console.RegisterVariable("Print", dcfPrint);// input handling:LRESULT CALLBACK WindowProc(HWND WndHandle, unsigned int Message, WPARAM wParam, LPARAM lParam){	switch(Message)	{	case WM_CHAR:		{			Console.OnChar((char)wParam, (long)lParam);			break;		}	}	return 1;}// renderingRECT DstRect = {5, 5, GetGameEngine()->GetPresentParams().BackBufferWidth - 5, GetGameEngine()->GetPresentParams().BackBufferHeight};Console.Render(GetGameEngine()->GetFontComPtr(), &DstRect);

That's all my above code uses. The PrintVariable() function is built in and will be removed shortly (after I get function parsing done correctly so that it recognizes variable names.) Print() is built in too, but I decided to include it to show that registering functions uses the same code.

I'll be modifying the system so that somebody can override DebugConsole::Render() (I'll modify it so that it takes a IDirect3DDevice9 pointer and a texture pointer as well) so that it can look nice and neat.

I'll post the code for the system in a couple day for those of you that are interested, I just want to get parsing all finished and make sure I have all of my test code removed.

Anyway, back to my code. I'm not sure if I'm going to go to bed or just stay up until about 11 when I can get a ride home. I'm afraid I'll freeze to death if I lay down[wink].

Update : 5:31am

I just got done implementing variable-variable assignment and variables as arguments to functions. Variables automatically convert (including string) with the exception of functions. Here's a screenshot of me using my entire Donny structure as arguments for the Print() function:

As you can see setting up a format-string system would be nice, but it would be both overkill and not needed.

I've figured out how to setup function-variable assignment (assigning the return value of a function to a variable), but I'm not going to attempt it tonight as I don't want to totally screw my code up (seeing as how I am completely drained due to my less than 4 hours of sleep/day this week.)

Anyway, some built in functions are next on the list as well as cleaning up some of the code. I'll keep you updated!

Edit: The code that I use to setup the Donny structure is like so:
// Test Entity structureclass Entity{public:	std::string	Name;	D3DXVECTOR3	Position;	int		Width, Height;	void Register(DebugConsole* Console, const std::string& VarName)	{		Console->RegisterVariable(VarName + ".Name", &Name);		Console->RegisterVariable(VarName + ".Position.x", &Position.x);		Console->RegisterVariable(VarName + ".Position.y", &Position.y);		Console->RegisterVariable(VarName + ".Width", &Width);		Console->RegisterVariable(VarName + ".Height", &Height);	}};// while registering thingsTestEntity.Name = "Donny";TestEntity.Register(&Console, "Donny");

There are no comments to display.

## Create an account

Register a new account