-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Numerics; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.Intrinsics; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Raylib_cs; | ||
|
||
namespace Packing | ||
{ | ||
public class Button | ||
{ | ||
public Rectangle box; | ||
public bool isPressed = false; | ||
public bool isHovered = false; | ||
|
||
int size; | ||
Texture2D icon; | ||
Vector2 iconsize; | ||
float rotation; | ||
|
||
private Sound presssound; | ||
|
||
public Button(Rectangle box, Texture2D icon, Vector2 iconsize, float rotation) | ||
{ | ||
this.box = box; | ||
this.icon = icon; | ||
this.iconsize = iconsize; | ||
this.rotation = rotation; | ||
presssound = Raylib.LoadSound("assets/button.wav"); | ||
} | ||
public void Play() | ||
{ | ||
isPressed = Raylib.CheckCollisionPointRec(Raylib.GetMousePosition(), box) && Raylib.IsMouseButtonPressed(MouseButton.MOUSE_BUTTON_LEFT); | ||
isHovered = Raylib.CheckCollisionPointRec(Raylib.GetMousePosition(), box); | ||
if (isPressed) | ||
{ | ||
Raylib.PlaySound(presssound); | ||
} | ||
} | ||
public void Draw(Color colour,Color iconcolour,float thick) | ||
{ | ||
Raylib.DrawRectangleRoundedLines(box, 0.07f,2,thick, colour); | ||
|
||
Raylib.DrawTexturePro(icon, new Rectangle(0,0,iconsize.X,iconsize.Y), new Rectangle(box.x + box.width / 2, box.y + box.height / 2, box.width, box.height), new Vector2(box.width / 2, box.height / 2), rotation, iconcolour); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
using System.Text.Json; | ||
using System.Xml; | ||
using Raylib_cs; | ||
|
||
namespace Packing; | ||
|
||
public class Controller | ||
{ | ||
private int spacing = 15; | ||
private int innerspacing; | ||
|
||
private float thick = 9.0f; | ||
|
||
Color background = new Color(31, 33, 47, 255); //grey | ||
Color foreground = new Color(250, 248, 229,255); //white | ||
|
||
Color goodground = new Color(124, 225, 112, 255); //green | ||
Color badground = new Color(226, 110, 104,255); //red | ||
|
||
private Rectangle border; | ||
|
||
//XmlDocument xdoc = new(); | ||
|
||
private Schedule schedule; | ||
private Show show; | ||
|
||
private enum Scene | ||
{ | ||
scheduling, | ||
showing | ||
|
||
} | ||
|
||
private bool editing; | ||
|
||
Scene scene; | ||
|
||
public Controller() | ||
{ | ||
innerspacing = spacing * 3; | ||
border = new Rectangle(spacing, spacing, Raylib.GetScreenWidth() - spacing * 2, Raylib.GetRenderHeight() - spacing * 2); | ||
|
||
schedule = new Schedule(innerspacing, thick); | ||
show = new Show(schedule.schedule, innerspacing, thick, schedule.lessonsize); | ||
|
||
scene = Scene.scheduling; | ||
try | ||
{ | ||
string savedjsonstring = File.ReadAllText("schedule/info.json"); | ||
ScheduleParse jsonData = JsonSerializer.Deserialize<ScheduleParse>(savedjsonstring); | ||
show.Calculate(jsonData); | ||
scene = Scene.showing; | ||
} | ||
catch (FileNotFoundException e) | ||
{ | ||
scene = Scene.scheduling; | ||
} | ||
catch (ArgumentNullException e) | ||
{ | ||
scene = Scene.scheduling; | ||
} | ||
catch (JsonException e) | ||
{ | ||
scene = Scene.scheduling; | ||
} | ||
} | ||
|
||
public void JustRun() | ||
{ | ||
if (Raylib.IsWindowFocused()) //BORDELESS WINDOW?? | ||
{ | ||
Raylib.SetWindowState(ConfigFlags.FLAG_FULLSCREEN_MODE); | ||
} | ||
else if (Raylib.IsWindowFullscreen()) | ||
{ | ||
Raylib.ToggleFullscreen(); | ||
} | ||
|
||
if (schedule.done) | ||
{ | ||
if (schedule.schedule.Count != 0) | ||
{ | ||
show.Calculate(schedule.schedule); | ||
} | ||
|
||
scene = Scene.showing; | ||
schedule.done = false; | ||
} | ||
if (show.done) | ||
{ | ||
scene = Scene.scheduling; | ||
show.done = false; | ||
} | ||
Play(); | ||
Work(); | ||
Draw(); | ||
} | ||
|
||
private void Play() | ||
{ | ||
switch (scene) | ||
{ | ||
case 0: | ||
schedule.Play(); | ||
break; | ||
case (Scene)1: | ||
show.Play(); | ||
break; | ||
} | ||
} | ||
|
||
private void Work() | ||
{ | ||
switch (scene) | ||
{ | ||
case 0: | ||
schedule.Work(); | ||
break; | ||
case (Scene)1: | ||
show.Work(); | ||
break; | ||
} | ||
} | ||
|
||
private void Draw() | ||
{ | ||
Raylib.DrawRectangleRoundedLines(border, 0.015f,2,thick, foreground); | ||
switch (scene) | ||
{ | ||
case 0: | ||
schedule.Draw(foreground, badground, goodground); | ||
break; | ||
case (Scene)1: | ||
show.Draw(foreground, badground, goodground); | ||
break; | ||
} | ||
Raylib.ClearBackground(background); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System.Numerics; | ||
using Packing; | ||
using Raylib_cs; | ||
|
||
namespace Packing; | ||
|
||
public class Lesson | ||
{ | ||
public string tag; | ||
public string lessonname; | ||
public Color colour; | ||
public Vector2 loc; | ||
|
||
public Lesson(string tag, Color colour) | ||
{ | ||
this.tag = tag; | ||
this.colour = colour; | ||
} | ||
|
||
public Lesson() | ||
{ | ||
tag = ""; | ||
lessonname = ""; | ||
colour = Color.BLANK; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<ApplicationIcon>assets\icon.ico</ApplicationIcon> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="schedule\**" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always" /> | ||
<Folder Include="assets" /> | ||
<Content Include="assets\**" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always" /> | ||
<Folder Include="schedule" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Raylib-cs" Version="4.2.0.1" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.3.32929.385 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Packing", "Packing.csproj", "{247E3C85-551D-4EAB-B4BC-B8F727B6818E}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{247E3C85-551D-4EAB-B4BC-B8F727B6818E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{247E3C85-551D-4EAB-B4BC-B8F727B6818E}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{247E3C85-551D-4EAB-B4BC-B8F727B6818E}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{247E3C85-551D-4EAB-B4BC-B8F727B6818E}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {299B403A-C203-49EA-9977-89DB2B14ACBF} | ||
EndGlobalSection | ||
EndGlobal |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using Raylib_cs; | ||
using System.Xml; | ||
using Packing; | ||
|
||
namespace Packing | ||
{ | ||
static class Program | ||
{ | ||
public static void Main() | ||
{ | ||
Raylib.InitWindow(Raylib.GetScreenWidth(), Raylib.GetScreenHeight(), "Packing"); | ||
Raylib.SetTargetFPS(163); | ||
Raylib.InitAudioDevice(); | ||
|
||
Raylib.SetWindowIcon(Raylib.LoadImage("assets/icon.png")); | ||
|
||
Controller controller = new Controller(); | ||
|
||
/* | ||
XmlDeclaration dec = xdoc.CreateXmlDeclaration("1.1", "utf-8", null); | ||
xdoc.AppendChild(dec); | ||
/* | ||
XmlElement Students = xdoc.CreateElement(null, "Students", null); | ||
xdoc.AppendChild(Students); | ||
XmlElement student = xdoc.CreateElement(null, "student1", null); | ||
XmlText studentName = xdoc.CreateTextNode("Jorvents"); | ||
student.AppendChild(studentName); | ||
Students.AppendChild(student); | ||
*/ | ||
|
||
//xdoc.Save("schedule/info.xml"); | ||
|
||
while (!Raylib.WindowShouldClose()) | ||
{ | ||
Raylib.BeginDrawing(); | ||
|
||
controller.JustRun(); | ||
|
||
Raylib.EndDrawing(); | ||
} | ||
|
||
Raylib.CloseWindow(); | ||
} | ||
} | ||
} |