-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
222366d
commit 2c47d82
Showing
4 changed files
with
79 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace CompactGraphics | ||
{ | ||
/// <summary> | ||
/// A base for Widget Based Menus | ||
/// </summary> | ||
public class Menu | ||
{ | ||
/// <summary> | ||
/// The graphics object to link to | ||
/// </summary> | ||
protected Graphics g; | ||
/// <summary> | ||
/// The list of widgets on page, in draw order. | ||
/// </summary> | ||
protected List<Widget> onPage; | ||
/// <summary> | ||
/// The numeric status of the menu, used for navigation. | ||
/// </summary> | ||
public int Status { get { return status; } } | ||
protected int status; | ||
public Menu() | ||
{ | ||
g = new Graphics(Console.WindowWidth, Console.WindowHeight); | ||
onPage = new List<Widget>(); | ||
} | ||
public Menu(Graphics g) | ||
{ | ||
this.g = g; | ||
onPage = new List<Widget>(); | ||
} | ||
/// <summary> | ||
/// Steps to the next frame by adding all the widgets to the current frame. | ||
/// DOES NOT PUSH | ||
/// </summary> | ||
public virtual void StepFrame() | ||
{ | ||
foreach (Widget widget in onPage) | ||
{ | ||
widget.Draw(g); | ||
} | ||
} | ||
/// <summary> | ||
/// Steps to the next frame by adding all the widgets to teh current frame, giving them the users input. | ||
/// </summary> | ||
/// <param name="keyinfo">The input to handle</param> | ||
public virtual void StepFrame(ConsoleKeyInfo keyinfo) | ||
{ | ||
foreach (Widget widget in onPage) | ||
{ | ||
widget.Draw(g, keyinfo); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,23 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
|
||
using CompactGraphics; | ||
namespace TestApp | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
Graphics graphics = new Graphics(); | ||
|
||
//Contunually draw frames | ||
while (true) | ||
{ | ||
//draw the frame counter at the top of the screen. | ||
graphics.Draw($"Fps: {graphics.Fps}", ConsoleColor.White, 0, 0); | ||
//now that all drawing is done, push the frame to the buffer. | ||
graphics.pushFrame(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters