Jump to content
  • Advertisement
  • entries
  • comments
  • views


Sign in to follow this  


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 variables
DebugConsole 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);

// 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)
case WM_CHAR:
Console.OnChar((char)wParam, (long)lParam);
return 1;

// rendering
RECT 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 structure
class Entity
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 things
TestEntity.Name = "Donny";
TestEntity.Register(&Console, "Donny");

Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!