0

I want to make a little CLI based game.
This will contain sole menus where you can simply select something using the arrow keys.
So here is an example of how this could look like (only placeholders since I don't have something showable for now):
1) before the menu: enter image description here 2) with the menu: enter image description here So here is my question: Is there a way to read contents (and colors) from the console before showing the menu to rewrite them after the menu is removed? I mean a way that will work even if I don't know what I wrote and it's only in the console?
Thank you,
Nils.

BDevGW
  • 347
  • 3
  • 15
  • It sounds like you need to be able to move the position of the cursor (the input, not the mouse) and redraw lines. Both are possible. – gunr2171 Dec 06 '19 at 16:35
  • Maybe I missunderstand you but what you tell me sounds like "draw the mnenu bellow the "screen" and then remove it again. right? I just want to redraw the parts from image 1 which are hidden in image 2 regardless of there contents or color and without knowing what I printed just by reading it before drawing the menu. – BDevGW Dec 06 '19 at 16:36
  • Take a look at https://stackoverflow.com/questions/888533/how-can-i-update-the-current-line-in-a-c-sharp-windows-console-app and https://stackoverflow.com/questions/22089645/how-to-change-cursor-position-in-console – gunr2171 Dec 06 '19 at 16:37
  • I want to read the cells I overwrite when drawing my menu to redraw them after the menu was used but without keeping track of anything I write in case I may need to redraw it. – BDevGW Dec 06 '19 at 16:40
  • Not sure if i understand. If what you want is to keep track of what you've written down up until the menu part, then you can replicate the output stream while not in the menu. (Create a "SaveAndWriteToConsole" function that will add your text to a stream. || After you're done with the menu, call "PrintSavedStream" – TheSiIence Dec 06 '19 at 16:51
  • No, keeping track is exactply what I want to skip. I want: read the cells from (3, 5) to (15, 10), Draw the menu over this position, let the user select whatever and then rewrite the previously read cells at their position so I don't need to track anything. Like copy and paste something within an image, but with console cells. – BDevGW Dec 06 '19 at 16:55

1 Answers1

0

Well I ded some research and it's not what exactly I had in mind but with Console.MoveBufferArea(int, int, int, int, int, int) can cut something to sore it maybe 100 lines deeper (without moving the cursor) and then you can move it simply back (again without moving the cursor.

BDevGW
  • 347
  • 3
  • 15