Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Console Server Menu


JeffSventora
 Share

Recommended Posts

I developed a menu system for what is going to soon be my game. It is written in C++ and works right out of the console. Working in the console grants many limitations so I had to find a way to work around that and provide a user friendly interface. Check out what I have so far!

**Yes, I created checkbox, pretty nifty ehh?**
![](http://img580.imageshack.us/img580/3020/serverx.png)

**And if you are interested in changing colors in the console using C++ here is the file I created to do so.**
```
#ifndef FUNCON_H
#define FUNCON_H

#include "Windows.h"
#include "conio.h"

// Written by Jeff Sventora
/*

This file was created to allow the user to change colors within the Console Screen. The SetCursor function will move the cursor to any position on the console and the ClearScreen() is a custom Cls() function because using system("pause") could get you fired ^^

Enjoy!

*/

//***************************************************************//
//******************** FOREGROUND COLORS ************************//
//***************************************************************//

/* Lights */
#define F_RED FOREGROUND_RED | FOREGROUND_INTENSITY
#define F_BLUE FOREGROUND_BLUE | FOREGROUND_INTENSITY
#define F_GREEN FOREGROUND_GREEN | FOREGROUND_INTENSITY
#define F_YELLOW F_RED | F_GREEN
#define F_MAGENTA F_BLUE | F_RED
#define F_CYAN F_GREEN | F_BLUE
#define F_WHITE F_RED | F_GREEN | F_BLUE

/* Darks */
#define F_DRED FOREGROUND_RED
#define F_DBLUE FOREGROUND_BLUE
#define F_DGREEN FOREGROUND_GREEN
#define F_DYELLOW F_DRED | F_DGREEN
#define F_DMAGENTA F_DBLUE | F_DRED
#define F_DCYAN F_DGREEN | F_DBLUE
#define F_DEFAULT F_DRED | F_DGREEN | F_DBLUE

//***************************************************************//
//******************** BACKGROUND COLORS ************************//
//***************************************************************//

/* Lights */
#define B_RED BACKGROUND_RED | BACKGROUND_INTENSITY
#define B_BLUE BACKGROUND_BLUE | BACKGROUND_INTENSITY
#define B_GREEN BACKGROUND_GREEN | BACKGROUND_INTENSITY
#define B_YELLOW B_RED | B_GREEN
#define B_MAGENTA B_BLUE | B_RED
#define B_CYAN B_GREEN | B_BLUE
#define B_WHITE B_RED | B_GREEN | B_BLUE

/* Darks */
#define B_DRED BACKGROUND_RED
#define B_DBLUE BACKGROUND_BLUE
#define B_DGREEN BACKGROUND_GREEN
#define B_DYELLOW B_DRED | B_DGREEN
#define B_DMAGENTA B_DBLUE | B_DRED
#define B_DCYAN B_DGREEN | B_DBLUE
#define B_GRAY B_DRED | B_DGREEN | B_DBLUE

static void ConCol(WORD COLOR = F_DEFAULT)
{
/* Sample Use */
// ConCol(F_RED | B_BLUE);
// ConCol() To set text back to default
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hOut, COLOR);
}

static void SetCursor(short X, short Y)
{
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);

COORD NewPos = {X, Y};
SetConsoleCursorPosition(hOut, NewPos);
}

static void ClearScreen(void)
{
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
COORD CursorDefault = {0, 0};
DWORD CharsWritten;
DWORD ConSize;
CONSOLE_SCREEN_BUFFER_INFO ScreenBufferInfo;

if(!GetConsoleScreenBufferInfo(hOut, &ScreenBufferInfo))
return;

ConSize = ScreenBufferInfo.dwSize.X * ScreenBufferInfo.dwSize.Y;

if(!FillConsoleOutputCharacter(hOut, (TCHAR)' ', ConSize, CursorDefault, &CharsWritten))
return;

if(!FillConsoleOutputAttribute(hOut, ScreenBufferInfo.wAttributes, ConSize, CursorDefault, &CharsWritten))
return;

SetConsoleCursorPosition(hOut, CursorDefault);
}

#endif
```
Link to comment
Share on other sites

Well basically the way it works is, I have ".mnu" files which are layed out like:

```
Name of menu
#of Opts
MENU "Test Menu" "To.mnu"
OPTION "Test Option"

```
So basically the "Menu's" go to other menu's and display the exact same way (unless I customize certain ones) and the options just toggle on/off with the Enter key.
Link to comment
Share on other sites

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
 Share

×
×
  • Create New...