Skip to content

Commit

Permalink
THATS RIGHT BAYBE MULTI WINDOW SUPPORT
Browse files Browse the repository at this point in the history
YOU CAN NOW CONTROL MULTIPLE WINDOWS HAHAHAHA FUCK YOU
  • Loading branch information
Reaxt committed Dec 2, 2020
1 parent 74c8ed1 commit 2ee8ad2
Show file tree
Hide file tree
Showing 9 changed files with 630 additions and 10 deletions.
77 changes: 77 additions & 0 deletions RhythmThing/Objects/Test Objects/MultiWindowTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using RhythmThing.System_Stuff;
using System;
using System.Collections.Generic;
using System.Text;
using RhythmThing.Components;
namespace RhythmThing.Objects.Test_Objects
{

class MultiWindowTest : GameObject
{
SlaveManager manager;
SlaveManager manager2;
SlaveManager manager3;
private Visual visualTest;
public override void End()
{

}

public override void Start(Game game)
{
manager = new SlaveManager("A", 50, 50);
manager2 = new SlaveManager("B", 30, 30);
manager3 = new SlaveManager("C", 20, 50);

Input.focusInput = false;
visualTest = new Visual();
visualTest.LoadBMP("RightReceiver.bmp");
manager.visuals.Add(visualTest);
manager2.visuals.Add(visualTest);
manager3.visuals.Add(visualTest);
}

public override void Update(double time, Game game)
{
if(game.input.ButtonStates[Input.ButtonKind.Right] == Input.ButtonState.Press)
{
manager.MoveWindowEase(-100, -100, 100, 100, 5, "easeInOutExpo");


visualTest.x++;
}
if (game.input.ButtonStates[Input.ButtonKind.Left] == Input.ButtonState.Press)
{
manager.MoveWindow(100, 0);
manager2.MoveWindow(100, 0);

visualTest.x--;
}
if (game.input.ButtonStates[Input.ButtonKind.Up] == Input.ButtonState.Press)
{
manager.MoveWindow(0, 100);
manager2.MoveWindow(0, 100);

visualTest.y++;
}
if (game.input.ButtonStates[Input.ButtonKind.Down] == Input.ButtonState.Press)
{
manager.MoveWindow(100, 100);
manager2.MoveWindow(100, 100);

visualTest.y--;
}
if (manager.alive)
{
manager.UpdateVisuals();

}
manager2.UpdateVisuals();
manager3.UpdateVisuals();
if(game.input.ButtonStates[Input.ButtonKind.Cancel] == Input.ButtonState.Press)
{
manager.CloseWindow();
}
}
}
}
17 changes: 13 additions & 4 deletions RhythmThing/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using RhythmThing.Utils;
using System.IO;
using System.Security.Cryptography;
using System.Diagnostics;

namespace RhythmThing
{
Expand Down Expand Up @@ -37,6 +38,13 @@ class Program

static void Main(string[] args)
{
if(args.Length > 0)
{
SlaveWindow slave = new SlaveWindow(args);

} else
{

contentPath = Path.Combine(Directory.GetCurrentDirectory(), "!Content");
//backup last log
Logger.NewLog();
Expand All @@ -56,10 +64,11 @@ static void Main(string[] args)
PlayerSettings.Instance.ReadSettings();

Game main = new Game(ScreenX, ScreenY);
//testOUTPUT test = new testOUTPUT();
// test.Setup();
//put in test object
// main.addGameObject(new LeftArrow());
//testOUTPUT test = new testOUTPUT();
// test.Setup();
//put in test object
// main.addGameObject(new LeftArrow());
}
}
}
}
4 changes: 2 additions & 2 deletions RhythmThing/Scenes/TestScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ class TestScene : Scene
{
public TestScene()
{
this.name = "BMP Testing";
this.name = "Testing";
this.index = 5;
}
public override void Start()
{

initialObjs = new List<GameObject>();
initialObjs.Add(new RotationTest());
initialObjs.Add(new MultiWindowTest());

}

Expand Down
7 changes: 5 additions & 2 deletions RhythmThing/System Stuff/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public class Game
//private List<GameObject> toRemove;
//for our good ol friend deltatime
Stopwatch stopwatch = new Stopwatch();



public Game(int screenX, int screenY)
{
this.screenX = screenX;
Expand All @@ -74,10 +77,10 @@ public Game(int screenX, int screenY)
sceneManager = new SceneManager(this);
//entry point

sceneManager.loadScene(0);
//sceneManager.loadScene(0);

//debug scene
//sceneManager.loadScene(5);
sceneManager.loadScene(5);

while (gameLoopLives)
{
Expand Down
4 changes: 2 additions & 2 deletions RhythmThing/System Stuff/Input.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class Input
private int _escCode = 1;
*/


public static bool focusInput = true;
private static Input _instance;
public static Input Instance {
get {
Expand Down Expand Up @@ -196,7 +196,7 @@ public void UpdateInput()



if (!WindowManager.isFocused())
if (!WindowManager.isFocused() && focusInput)
{
return;
}
Expand Down
218 changes: 218 additions & 0 deletions RhythmThing/System Stuff/SlaveDisplay.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
using System;
using System.Collections.Generic;
using System.Text;
using RhythmThing.Components;

namespace RhythmThing.System_Stuff
{
class SlaveDisplay
{
ushort None = 0x0000;
ushort FOREGROUND_BLUE = 0x0001;
ushort FOREGROUND_GREEN = 0x0002;
ushort FOREGROUND_RED = 0x0004;
ushort FOREGROUND_INTENSITY = 0x0008;
ushort BACKGROUND_BLUE = 0x0010;
ushort BACKGROUND_GREEN = 0x0020;
ushort BACKGROUND_RED = 0x0040;
ushort BACKGROUND_INTENSITY = 0x0080;
ushort COMMON_LVB_LEADING_BYTE = 0x0100;
ushort COMMON_LVB_TRAILING_BYTE = 0x0200;
ushort COMMON_LVB_GRID_HORIZONTAL = 0x0400;
ushort COMMON_LVB_GRID_LVERTICAL = 0x0800;
ushort COMMON_LVB_GRID_RVERTICAL = 0x1000;
ushort COMMON_LVB_REVERSE_VIDEO = 0x4000;
ushort COMMON_LVB_UNDERSCORE = 0x8000;

ConsoleColor[,] currentForeColors;
ConsoleColor[,] currentBackColors;
char[,] currentFinalChars;
public WindowManager windowManager;
//consoleb
//private ConsoleColor[,] finalPixels; //ech terminology consistency what is that
public SlaveDisplay()
{


currentForeColors = new ConsoleColor[Program.ScreenX, Program.ScreenY];
currentBackColors = new ConsoleColor[Program.ScreenX, Program.ScreenY];
currentFinalChars = new char[Program.ScreenX, Program.ScreenY];
windowManager = new WindowManager();
windowManager.InitWindow();
windowManager.CenterWindow();
//windowManager.moveWindow(0.75f, 0.75f);
}



public void DrawFrame(SlaveManager.SlaveData data)
{

//remove objects from main list that need to be

//add objects to main list that need to be

ConsoleColor[,] finalForeColors = new ConsoleColor[Program.ScreenX, Program.ScreenY];
ConsoleColor[,] finalBackColors = new ConsoleColor[Program.ScreenX, Program.ScreenY];
char[,] finalChars = new char[Program.ScreenX, Program.ScreenY];
//sosorry


//DisplayData newData = screenFilter.RunFilt(finalForeColors, finalBackColors, finalChars);
finalForeColors = data.foreColors;
finalBackColors = data.backColors;
finalChars = data.characters;

//not gonna try drawing this way anymore...
/*
Console.SetCursorPosition(0, 0);
for (int y = 0; y < Program.ScreenY; y++)
{
for (int x = 0; x < Program.ScreenX; x++)
{
//only draw changes
if(currentBackColors[x, y] != finalBackColors[x,y] || currentForeColors[x,y] != finalForeColors[x,y] || currentFinalChars[x,y] != finalChars[x,y])
{
Console.SetCursorPosition(x, Program.ScreenY - y);
Console.ForegroundColor = finalForeColors[x, y];
Console.BackgroundColor = finalBackColors[x, y];
Console.Write(finalChars[x, y]);
}
}
}
*/
//here we go oh boy.
WindowManager.CHAR_INFO[] buffer = new WindowManager.CHAR_INFO[Program.ScreenX * Program.ScreenY];

for (int y = 0; y < Program.ScreenY; y++)
{
for (int x = 0; x < Program.ScreenX; x++)
{
ushort attributes = None;
switch (finalForeColors[x, Program.ScreenY - (y + 1)])
{
case ConsoleColor.Black:
attributes = None;
break;
case ConsoleColor.DarkBlue:
attributes = FOREGROUND_BLUE;
break;
case ConsoleColor.DarkGreen:
attributes = FOREGROUND_GREEN;
break;
case ConsoleColor.DarkCyan:
attributes = (ushort)(FOREGROUND_GREEN | FOREGROUND_BLUE);
break;
case ConsoleColor.DarkRed:
attributes = FOREGROUND_RED;
break;
case ConsoleColor.DarkMagenta:
attributes = (ushort)(FOREGROUND_RED | FOREGROUND_BLUE);
break;
case ConsoleColor.DarkYellow:
attributes = (ushort)(FOREGROUND_RED | FOREGROUND_GREEN);
break;
case ConsoleColor.Gray:
attributes = (ushort)(FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
break;
case ConsoleColor.DarkGray:
attributes = FOREGROUND_INTENSITY;
break;
case ConsoleColor.Blue:
attributes = (ushort)(FOREGROUND_BLUE | FOREGROUND_INTENSITY);
break;
case ConsoleColor.Green:
attributes = (ushort)(FOREGROUND_GREEN | FOREGROUND_INTENSITY);
break;
case ConsoleColor.Cyan:
attributes = (ushort)(FOREGROUND_BLUE | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
break;
case ConsoleColor.Red:
attributes = (ushort)(FOREGROUND_RED | FOREGROUND_INTENSITY);
break;
case ConsoleColor.Magenta:
attributes = (ushort)(FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
break;
case ConsoleColor.Yellow:
attributes = (ushort)(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
break;
case ConsoleColor.White:
attributes = (ushort)(FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
break;
default:
break;
}

ushort backattribute = None;
switch (finalBackColors[x, Program.ScreenY - (y + 1)])
{
case ConsoleColor.Black:
backattribute = None;
break;
case ConsoleColor.DarkBlue:
backattribute = BACKGROUND_BLUE;
break;
case ConsoleColor.DarkGreen:
backattribute = BACKGROUND_GREEN;
break;
case ConsoleColor.DarkCyan:
backattribute = (ushort)(BACKGROUND_GREEN | BACKGROUND_BLUE);
break;
case ConsoleColor.DarkRed:
backattribute = BACKGROUND_RED;
break;
case ConsoleColor.DarkMagenta:
backattribute = (ushort)(BACKGROUND_RED | BACKGROUND_BLUE);
break;
case ConsoleColor.DarkYellow:
backattribute = (ushort)(BACKGROUND_RED | BACKGROUND_GREEN);
break;
case ConsoleColor.Gray:
backattribute = (ushort)(BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED);
break;
case ConsoleColor.DarkGray:
backattribute = BACKGROUND_INTENSITY;
break;
case ConsoleColor.Blue:
backattribute = (ushort)(BACKGROUND_BLUE | BACKGROUND_INTENSITY);
break;
case ConsoleColor.Green:
backattribute = (ushort)(BACKGROUND_GREEN | BACKGROUND_INTENSITY);
break;
case ConsoleColor.Cyan:
backattribute = (ushort)(BACKGROUND_BLUE | BACKGROUND_BLUE | BACKGROUND_INTENSITY);
break;
case ConsoleColor.Red:
backattribute = (ushort)(BACKGROUND_RED | BACKGROUND_INTENSITY);
break;
case ConsoleColor.Magenta:
backattribute = (ushort)(BACKGROUND_BLUE | BACKGROUND_RED | BACKGROUND_INTENSITY);
break;
case ConsoleColor.Yellow:
backattribute = (ushort)(BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY);
break;
case ConsoleColor.White:
backattribute = (ushort)(BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY);
break;
default:
break;
}

//im so sorry for these switch cases interop is not nice
attributes = (ushort)(backattribute | attributes);

buffer[y * Program.ScreenX + x] = new WindowManager.CHAR_INFO { UnicodeChar = finalChars[x, Program.ScreenY - (y + 1)], Attributes = attributes };
}
}
//buffer[1 + 1] = new WindowManager.CHAR_INFO { UnicodeChar = 'h', Attributes = (ushort)(BACKGROUND_BLUE | FOREGROUND_GREEN ) };
windowManager.RenderBuffer(buffer);
//save changes
currentBackColors = finalBackColors;
currentForeColors = finalForeColors;
currentFinalChars = finalChars;

}
}
}

Loading

0 comments on commit 2ee8ad2

Please sign in to comment.