MiniGame-Madness
Public Member Functions | Static Public Attributes | List of all members
ScreenBuffer Class Reference

A class that represents the screen buffer. More...

#include <screenBuffer.h>

Public Member Functions

 ScreenBuffer ()
 Constructor for the screenBuffer class.
 
 ScreenBuffer (int width, int height)
 Constructor for the screenBuffer class. More...
 
 ~ScreenBuffer ()
 Destructor for the screenBuffer class.
 
HANDLE getScreenHandle () const
 Get the screen buffer handle. More...
 
bool isActive () const
 Check if the screen buffer is active. More...
 
void setActive ()
 Set the screen buffer to active.
 
CONSOLE_SCREEN_BUFFER_INFO getScreenBufferInfo () const
 Get screen buffer info. More...
 
void clearScreen ()
 Clears the screen buffer.
 
int getScreenWidth () const
 Get the screen buffer width. More...
 
int getScreenHeight () const
 Get the screen buffer height. More...
 
void setScreenSize (int width, int height)
 Set the size of the screen buffer and window. More...
 
std::pair< WORD, WORD > getScreenColours (int x, int y, int length) const
 Get the screen text and background colors. More...
 
void setCursorVisibility (bool isVisible)
 Set cursor visibility. More...
 
void setCursorPosition (int x, int y)
 Move the cursor to the specified location. More...
 
std::pair< int, int > getCursorPosition () const
 Get the current location of the cursor. More...
 
std::wstring readScreenText (int x, int y, int length) const
 Get part of text in the screen buffer. More...
 
std::wstring readAllScreenText () const
 Get all of the text in the screen buffer. More...
 
void writeToScreen (int x, int y, const std::wstring &text)
 Write text to the screen at a specific location. More...
 
void writeToScreen (int x, int y, const std::wstring &text, WORD textColour, WORD backgroundColour)
 Write text to the screen at a specific location with a specific color. More...
 
std::string getBlockingInput ()
 get blocking input from the user More...
 
std::string getNonBlockingInput ()
 get non-blocking input from the user More...
 

Static Public Attributes

static const WORD FOREGROUND_NORMAL = -3
 
static const WORD BACKGROUND_NORMAL = -13
 
static const WORD BLACK = 0
 
static const WORD RED = 1
 
static const WORD GREEN = 2
 
static const WORD YELLOW = 3
 
static const WORD BLUE = 4
 
static const WORD MAGENTA = 5
 
static const WORD CYAN = 6
 
static const WORD WHITE = 7
 

Detailed Description

A class that represents the screen buffer.

This class provides methods to interact with the screen buffer, such as writing text to the screen, changing the cursor position, and setting text and background colors.

Constructor & Destructor Documentation

◆ ScreenBuffer()

ScreenBuffer::ScreenBuffer ( int  width,
int  height 
)

Constructor for the screenBuffer class.

Parameters
widthThe width of the screen buffer
heightThe height of the screen buffer

Member Function Documentation

◆ getBlockingInput()

std::string ScreenBuffer::getBlockingInput ( )

get blocking input from the user

Returns
std::wstring The input from the user

◆ getCursorPosition()

std::pair< int, int > ScreenBuffer::getCursorPosition ( ) const

Get the current location of the cursor.

Returns
std::pair<int, int> The x and y coordinates of the cursor

◆ getNonBlockingInput()

std::string ScreenBuffer::getNonBlockingInput ( )

get non-blocking input from the user

Returns
std::wstring The input from the user

◆ getScreenBufferInfo()

CONSOLE_SCREEN_BUFFER_INFO ScreenBuffer::getScreenBufferInfo ( ) const

Get screen buffer info.

Returns
CONSOLE_SCREEN_BUFFER_INFO The screen buffer info

◆ getScreenColours()

std::pair< WORD, WORD > ScreenBuffer::getScreenColours ( int  x,
int  y,
int  length 
) const

Get the screen text and background colors.

Parameters
xThe x coordinate
yThe y coordinate
lengthThe length of the text
Returns
std::pair<WORD, WORD> The text and background colors

◆ getScreenHandle()

HANDLE ScreenBuffer::getScreenHandle ( ) const

Get the screen buffer handle.

Returns
HANDLE The handle of the screen buffer

◆ getScreenHeight()

int ScreenBuffer::getScreenHeight ( ) const

Get the screen buffer height.

Returns
int The height of the screen buffer

◆ getScreenWidth()

int ScreenBuffer::getScreenWidth ( ) const

Get the screen buffer width.

Returns
int The width of the screen buffer

◆ isActive()

bool ScreenBuffer::isActive ( ) const

Check if the screen buffer is active.

Returns
bool True if the screen buffer is active

◆ readAllScreenText()

std::wstring ScreenBuffer::readAllScreenText ( ) const

Get all of the text in the screen buffer.

Returns
std::string The text in the screen buffer

◆ readScreenText()

std::wstring ScreenBuffer::readScreenText ( int  x,
int  y,
int  length 
) const

Get part of text in the screen buffer.

Parameters
xThe x coordinate
yThe y coordinate
lengthThe length of the text
Returns
std::string The text at the specified location

◆ setCursorPosition()

void ScreenBuffer::setCursorPosition ( int  x,
int  y 
)

Move the cursor to the specified location.

Parameters
xThe x coordinate
yThe y coordinate

◆ setCursorVisibility()

void ScreenBuffer::setCursorVisibility ( bool  isVisible)

Set cursor visibility.

Parameters
isVisibleTrue to show the cursor, false to hide it

◆ setScreenSize()

void ScreenBuffer::setScreenSize ( int  width,
int  height 
)

Set the size of the screen buffer and window.

Parameters
widthThe width of the screen
heightThe height of the screen

◆ writeToScreen() [1/2]

void ScreenBuffer::writeToScreen ( int  x,
int  y,
const std::wstring &  text 
)

Write text to the screen at a specific location.

Parameters
xThe x coordinate
yThe y coordinate
textThe text to write

◆ writeToScreen() [2/2]

void ScreenBuffer::writeToScreen ( int  x,
int  y,
const std::wstring &  text,
WORD  textColour,
WORD  backgroundColour 
)

Write text to the screen at a specific location with a specific color.

Parameters
xThe x coordinate
yThe y coordinate
textThe text to write
textColourThe color of the text
backgroundColourThe color of the background

The documentation for this class was generated from the following files: