g-bright / cs-minesweepers

A console-based minesweeper game made purely to learn C#, still has a couple bugs and the code is untidy and poorly written.
1 stars 2 forks source link

Improved dynamic board sizing #4

Closed mohitsaxenaknoldus closed 3 years ago

mohitsaxenaknoldus commented 3 years ago

Fixes #3

I've improved the window sizing.

g-bright commented 3 years ago

This won't work because of this:

image

I want to be able to see the writing along the top of the console at all times, but don't want the console bigger than needed

image

mohitsaxenaknoldus commented 3 years ago

Why you closed the PR? We can push new changes to this PR only without creating a new one. Also, That title you talking about is part of the shell so there is no way we can only shrink the shell and not the actual window. One workaround would be to always run the game in fullscreen but I am not sure if that is something you'd like.

g-bright commented 3 years ago

I want to resize the console to make it big enough that two things are always being fulfilled:

This is possible by doing it all manually.. so each board size has a custom sizing but I made this issue to see if someone else had an idea of doing it differently.

mohitsaxenaknoldus commented 3 years ago

I want to resize the console to make it big enough that two things are always being fulfilled:

  • You can read the text on the title of the console.
  • There is the minimum space needed to show the minefield.

This is possible by doing it all manually.. so each board size has a custom sizing but I made this issue to see if someone else had an idea of doing it differently.

Oh, is this why you've hard-coded 48? I have done some changes but your second block doesn't work for any size beyond 17:

            else
            {
                Console.SetWindowSize((BoardSize * 7) + 4, Convert.ToInt32(Math.Round(BoardSize * 2.2) + 4));
                Console.SetBufferSize((BoardSize * 7) + 4, Convert.ToInt32(Math.Round(BoardSize * 2.2) + 4));
            }

So, does this part need work? Or am I doing something wrong?

g-bright commented 3 years ago

Yeah, 48 was hardcoded to begin with because that allows for enough length for the title of the console to be displayed, after that point it needs to be then scaled up accordingly with how big the minefield will be. I then changed it a bit to what is shown below, but it doesn't work very well.

Those 7's are meant to be a 4s, It seems I forgot to commit and push that in my latest update, my apologies.

image

I will push this change now.

mohitsaxenaknoldus commented 3 years ago

Yeah, 48 was hardcoded to begin with because that allows for enough length for the title of the console to be displayed, after that point it needs to be then scaled up accordingly with how big the minefield will be. I then changed it a bit to what is shown below, but it doesn't work very well.

Those 7's are meant to be a 4s, It seems I forgot to commit and push that in my latest update, my apologies.

image

I will push this change now.

I took the pull but it still doesn't work for levels > 18. Gives this error:

Enter board size: (min 4, max 30)30

Unhandled Exception: System.ArgumentOutOfRangeException: The value must be less than the console's current maximum window size of 44 in that dimension. Note that this value depends on screen resolution and the console font.
Parameter name: height
Actual value was 70.
   at System.Console.SetWindowSize(Int32 width, Int32 height)
   at Minesweeper.Board..ctor() in D:\C# Projects\FinalMinesweeperVersion\Minesweeper\Board.cs:line 127
   at Minesweeper.Program.Main(String[] args) in D:\C# Projects\FinalMinesweeperVersion\Minesweeper\Program.cs:line 14
g-bright commented 3 years ago

This is because of the resolution of the monitor you are using. My monitor I run this on is 1920x1200 and 30 works fine. This is something that could also be checked when the game is run to make sure you can only put in the maximum size of board your monitor can handle.