JeffSventora Posted August 5, 2011 Author Share Posted August 5, 2011 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_DBLUEstatic 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 More sharing options...
Strafe Posted August 5, 2011 Share Posted August 5, 2011 Looking good mate keep it up Link to comment Share on other sites More sharing options...
shadowdeath Posted August 5, 2011 Share Posted August 5, 2011 Dosen't look bad.I wouldn't say it's completely User Friendly though. Link to comment Share on other sites More sharing options...
JeffSventora Posted August 5, 2011 Author Share Posted August 5, 2011 Thanks, guys!@shadow: Any suggestions for improvement? Link to comment Share on other sites More sharing options...
shadowdeath Posted August 5, 2011 Share Posted August 5, 2011 Well, considering I've only seen the main menu part, not yet. Link to comment Share on other sites More sharing options...
JeffSventora Posted August 5, 2011 Author Share Posted August 5, 2011 Well basically the way it works is, I have ".mnu" files which are layed out like:```Name of menu#of OptsMENU "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 More sharing options...
Displaced Posted August 5, 2011 Share Posted August 5, 2011 Why are your writing a console "gui"?It would be better if you do a socket base protocoll for remote controlling.So you could do a simple WebGUI or a Remote Admin GUI programm, which would be much more comfortable. Link to comment Share on other sites More sharing options...
Godlord Posted August 5, 2011 Share Posted August 5, 2011 He's learning, I doubt he knows enough about BSD sockets, UDP, ssh, etc. to actually get something like that done, which already exists anyway.Yours faithfully Stephan. Link to comment Share on other sites More sharing options...
Lenton Posted August 5, 2011 Share Posted August 5, 2011 Instead of creating a really complicated menu in the console why don't you just let the user make commands. Just have a help command that lists all of the commands the user can make. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now