Skip to content

Commit

Permalink
v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorvents committed Jan 16, 2023
1 parent 97235c1 commit ae24ec6
Show file tree
Hide file tree
Showing 147 changed files with 2,411 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/.idea/.idea.Packing.dir/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/.idea/.idea.Packing.dir/.idea/discord.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/.idea/.idea.Packing.dir/.idea/indexLayout.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions src/.idea/.idea.Packing/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/.idea/.idea.Packing/.idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/.idea/.idea.Packing/.idea/discord.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/.idea/.idea.Packing/.idea/indexLayout.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/.idea/.idea.Packing/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions src/Button.cs
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);
}
}
}
139 changes: 139 additions & 0 deletions src/Controller.cs
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);
}
}
26 changes: 26 additions & 0 deletions src/Lesson.cs
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;
}
}
22 changes: 22 additions & 0 deletions src/Packing.csproj
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>
25 changes: 25 additions & 0 deletions src/Packing.sln
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
47 changes: 47 additions & 0 deletions src/Program.cs
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();
}
}
}
Loading

0 comments on commit ae24ec6

Please sign in to comment.