Skip to content

Commit

Permalink
Update to 6/11/20 - Build 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Tran-Foxxo committed Jun 12, 2020
1 parent 815e2b9 commit 27cbcf5
Show file tree
Hide file tree
Showing 16 changed files with 169 additions and 79 deletions.
6 changes: 6 additions & 0 deletions Changelogs/6-11-20 - Build 1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Changelog for 6/11/20 - Build 1

* Crashes due to invalid settings files are now resolved!
* `BG Color` triggers now work as intended, blending into the new color for the duration of the trigger.
* Added in `Line Color` triggers!
* They act the same as `BG Color` triggers but for line colors!
2 changes: 1 addition & 1 deletion Changelogs/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Changelogs folder

Read old changelogs here
This folder contains the previous changelogs for LRTran!
67 changes: 59 additions & 8 deletions src/Game/GameTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using linerider.Utils;
using OpenTK.Graphics;
using System;
using System.Drawing;

namespace linerider.Game
{
Expand Down Expand Up @@ -70,7 +71,7 @@ public bool ActivateZoom(int hitdelta, ref float currentzoom)
}
return handled;
}
public bool ActivateBG(int hitdelta, ref Color4 staticCurrentColor, ref Color4 changingCurrentColor, int currentFrame)
public bool ActivateBG(int hitdelta, int currentFrame, ref Color4 staticCurrentColor, ref Color4 currentColorChanging, ref Color4 frameInfoColor)
{
bool handled = false;
if (TriggerType == TriggerType.BGChange)
Expand All @@ -82,26 +83,76 @@ public bool ActivateBG(int hitdelta, ref Color4 staticCurrentColor, ref Color4 c
{
if (frame < fadeframes)
{
float diffR = this.backgroundRed - staticCurrentColor.R;
float diffG = this.backgroundGreen - staticCurrentColor.G;
float diffB = this.backgroundBlue - staticCurrentColor.B;
float diffR = this.backgroundRed - staticCurrentColor.R * 255;
float diffG = this.backgroundGreen - staticCurrentColor.G * 255;
float diffB = this.backgroundBlue - staticCurrentColor.B * 255;
float newR = ((staticCurrentColor.R * 255) + (diffR * (frame / fadeframes))) / 255;
float newG = ((staticCurrentColor.G * 255) + (diffG * (frame / fadeframes))) / 255;
float newB = ((staticCurrentColor.B * 255) + (diffB * (frame / fadeframes))) / 255;

if (newR > 1) { newR = newR / 255; }
if (newG > 1) { newG = newG / 255; }
if (newB > 1) { newB = newB / 255; }

frameInfoColor = new Color4((float)newR, (float)newG, (float)newB, 255);
currentColorChanging = new Color4((float)newR, (float)newG, (float)newB, 255);

//Console.WriteLine("R: " + newR);
//Console.WriteLine("G: " + newG);
//Console.WriteLine("B: " + newB);

handled = true;
}
else
{
staticCurrentColor = new Color4((float)this.backgroundRed / 255, (float)this.backgroundGreen / 255, (float)this.backgroundBlue / 255, 255);
frameInfoColor = new Color4((float)this.backgroundRed / 255, (float)this.backgroundGreen / 255, (float)this.backgroundBlue / 255, 255);
currentColorChanging = new Color4((float)this.backgroundRed / 255, (float)this.backgroundGreen / 255, (float)this.backgroundBlue / 255, 255);
}
}
}
return handled;
}

public bool ActivateLine(int hitdelta, ref Color staticCurrentColor, ref Color notStaticCurrentColor, int currentFrame, ref Color frameLineColor)
{
bool handled = false;
if (TriggerType == TriggerType.LineColor)
{
float fadeframes = End - Start;
float frame = (currentFrame - Start);

if (!staticCurrentColor.Equals(Color.FromArgb(255, this.lineRed, this.lineGreen, this.lineBlue)))
{
if (frame < fadeframes)
{
float diffR = this.lineRed - staticCurrentColor.R;
float diffG = this.lineGreen - staticCurrentColor.G;
float diffB = this.lineBlue - staticCurrentColor.B;
float newR = (staticCurrentColor.R + (diffR * (frame / fadeframes)));
float newG = (staticCurrentColor.G + (diffG * (frame / fadeframes)));
float newB = (staticCurrentColor.B + (diffB * (frame / fadeframes)));

changingCurrentColor = new Color4((float)newR, (float)newG, (float)newB, 255);

frameLineColor = Color.FromArgb(255, (int)newR, (int)newG, (int)newB);
notStaticCurrentColor = Color.FromArgb(255, (int)newR, (int)newG, (int)newB);

//Console.WriteLine(newR);
//Console.WriteLine(newG);
//Console.WriteLine(newB);

handled = true;
}
else
{
changingCurrentColor = new Color4((float)this.backgroundRed, (float)this.backgroundGreen, (float)this.backgroundBlue, 255);
staticCurrentColor = new Color4((float)this.backgroundRed, (float)this.backgroundGreen, (float)this.backgroundBlue, 255);
staticCurrentColor = Color.FromArgb(255, this.lineRed, this.lineGreen, this.lineBlue);
frameLineColor = Color.FromArgb(255, this.lineRed, this.lineGreen, this.lineBlue);
notStaticCurrentColor = Color.FromArgb(255, this.lineRed, this.lineGreen, this.lineBlue);
}
}
}
return handled;
}

public GameTrigger Clone()
{
return new GameTrigger()
Expand Down
40 changes: 31 additions & 9 deletions src/Game/Timeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ struct frameinfo
{
public Rider Rider;
public float Zoom;
public Color4 Color;
public Color4 BGColor;
public Color LineColor;
}
private HitTestManager _hittest = new HitTestManager();
private ResourceSync _framesync = new ResourceSync();
Expand Down Expand Up @@ -95,14 +96,26 @@ public void Restart(Rider state, float zoom)
{
_hittest.Reset();
_frames.Clear();
_frames.Add(new frameinfo() { Rider = state, Zoom = zoom, Color = Constants.TriggerBGColor });
_frames.Add(new frameinfo() {
Rider = state,
Zoom = zoom,
BGColor = Constants.ColorWhite,
LineColor = Constants.DefaultLineColor,
});
using (changesync.AcquireWrite())
{
_first_invalid_frame = _frames.Count;
}
}
}
/// <summary>
/// Clears out the frame info
/// </summary>
public void ClearFrameInfo()
{
_frames.Clear();
}
/// <summary>
/// Extracts the rider and death details of the specified frame.
/// </summary>
public RiderFrame ExtractFrame(int frame, int iteration = 6)
Expand Down Expand Up @@ -181,7 +194,15 @@ public Color4 GetFrameBackgroundColor(int frame)
using (_framesync.AcquireWrite())
{
UnsafeEnsureFrameValid(frame);
return _frames[frame].Color;
return _frames[frame].BGColor;
}
}
public Color GetLineColor(int frame)
{
using (_framesync.AcquireWrite())
{
UnsafeEnsureFrameValid(frame);
return _frames[frame].LineColor;
}
}
/// <summary>
Expand Down Expand Up @@ -293,22 +314,23 @@ private void ThreadUnsafeRunFrames(int start, int count)
var zoomtrigger = triggers[(int)TriggerType.Zoom];
if (zoomtrigger != null)
{
Console.WriteLine("There's a Zoom Trigger on this frame! Add code here DEV!");
var delta = currentframe - zoomtrigger.Start;
zoomtrigger.ActivateZoom(delta, ref current.Zoom);
}

var bgtrigger = triggers[(int)TriggerType.BGChange];
if (bgtrigger != null)
{
Console.WriteLine("There's a BG Trigger on this frame! Add code here DEV!");
var delta = currentframe - bgtrigger.Start;
bgtrigger.ActivateBG(delta, ref Constants.NonTriggerBGColor, ref Constants.TriggerBGColor, currentframe);
current.Color = Constants.TriggerBGColor;
bgtrigger.ActivateBG(delta, currentframe, ref Constants.NonTriggerBGColor, ref Constants.TriggerBGColor, ref current.BGColor);
}
else

var linetrigger = triggers[(int)TriggerType.LineColor];
if (linetrigger != null)
{
Constants.TriggerBGColor = (Settings.NightMode ? Constants.ColorNightMode : (Settings.WhiteBG ? Constants.ColorWhite : Constants.ColorOffwhite));
var delta = currentframe - linetrigger.Start;
linetrigger.ActivateLine(delta, ref Constants.NonTriggerLineColorChange, ref Constants.TriggerLineColorChange, currentframe, ref current.LineColor);
//Constants.TriggerLineColorChange = current.LineColor;
}
}
steps[i] = current;
Expand Down
12 changes: 4 additions & 8 deletions src/GameCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,10 @@ public void ShowChangelog()
else
{
var changelogText = "" +
"* The `/Examples` folder will be bundled with future downloads so you no longer need to download the source code to get those files\n" +
"* Added a new Background trigger! \n" +
" * It does nothing right now but is currently saved and loaded by .trk and .json files.\n" +
"* The `Save` option has been renamed to `Save as...`\n" +
"* Added keybinds for the `Trigger Menu` (P) and `Save as...` (Crtl+Shift+S) \n" +
"* Default save format settings are now available in `Settings -> Other`\n" +
"* Default window sizing options are now available in `Settings -> Other`\n" +
"* Quicksaves now follow the format `quicksave_month.day.year_hours.minutes.filetype`\n" +
"* Crashes due to invalid settings files are now resolved!\n" +
"* `BG Color` triggers now work as intended, blending into the new color for the duration of the trigger.\n" +
"*Added in `Line Color` triggers!\n" +
" * They act the same as `BG Color` triggers but for line colors!\n" +
"\n" +
"NOTE: Discord is *still* auto disabled on startup for now until I implement it in a more stable way.";

Expand Down
2 changes: 1 addition & 1 deletion src/IO/TRKLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private static void ParseMetadata(Track ret, BinaryReader br)
{
Start = start,
End = end,
TriggerType = TriggerType.BGChange,
TriggerType = TriggerType.LineColor,
lineRed = linered,
lineGreen = linegreen,
lineBlue = lineblue,
Expand Down
12 changes: 11 additions & 1 deletion src/IO/TrackRecorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,20 @@ public static void RecordTrack(MainWindow game, bool is1080P, bool smooth, bool
var invalid = false;
using (var trk = game.Track.CreateTrackReader())
{
game.Track.Reset();
Recording = true;
game.Track.Reset();
Recording1080p = is1080P;

//Set colors back to default for triggers
//linerider.Utils.Constants.TriggerBGColor = (Settings.NightMode ? linerider.Utils.Constants.ColorNightMode : (Settings.WhiteBG ? linerider.Utils.Constants.ColorWhite : linerider.Utils.Constants.ColorOffwhite));
//linerider.Utils.Constants.NonTriggerBGColor = (Settings.NightMode ? linerider.Utils.Constants.ColorNightMode : (Settings.WhiteBG ? linerider.Utils.Constants.ColorWhite : linerider.Utils.Constants.ColorOffwhite));
//linerider.Utils.Constants.NonTriggerLineColorChange = (Settings.NightMode ? linerider.Utils.Constants.DefaultNightLineColor : linerider.Utils.Constants.DefaultLineColor);
//linerider.Utils.Constants.TriggerLineColorChange = (Settings.NightMode ? linerider.Utils.Constants.DefaultNightLineColor : linerider.Utils.Constants.DefaultLineColor);
linerider.Utils.Constants.TriggerBGColor = linerider.Utils.Constants.ColorOffwhite;
linerider.Utils.Constants.NonTriggerBGColor = linerider.Utils.Constants.ColorOffwhite;
linerider.Utils.Constants.NonTriggerLineColorChange = linerider.Utils.Constants.DefaultLineColor;
linerider.Utils.Constants.TriggerLineColorChange = linerider.Utils.Constants.DefaultLineColor;

var state = game.Track.GetStart();
var frame = flag.FrameID;
game.Canvas.SetCanvasSize(game.RenderSize.Width, game.RenderSize.Height);
Expand Down
24 changes: 15 additions & 9 deletions src/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,25 @@ public void Render(float blend = 1)
{
CurrentTools.PencilTool.OnMouseMoved(InputUtils.GetMouse());
}

if (Track.Playing || Settings.PreviewMode )
if (Settings.PreviewMode || TrackRecorder.Recording)
{
/* BG triggers and Line trigger updates */
GL.ClearColor(Track.Timeline.GetFrameBackgroundColor(Track.Offset));

Constants.TriggerBGColor = Track.Timeline.GetFrameBackgroundColor(Track.Offset);
GL.ClearColor(Constants.TriggerBGColor);
Constants.TriggerLineColorChange = Track.Timeline.GetLineColor(Track.Offset);
}
else
{
GL.ClearColor(Settings.NightMode ? Constants.ColorNightMode : (Settings.WhiteBG ? Constants.ColorWhite : Constants.ColorOffwhite));
if (Settings.NightMode)
{
Constants.TriggerLineColorChange = Constants.DefaultNightLineColor;
}
else
{
Constants.TriggerLineColorChange = Constants.DefaultLineColor;
}
}


MSAABuffer.Use(RenderSize.Width, RenderSize.Height);
GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
GL.Clear(ClearBufferMask.ColorBufferBit);
Expand Down Expand Up @@ -360,7 +366,7 @@ public void reloadRiderModel()

try
{
if (Settings.customScarfOnPng)
if (Settings.customScarfOnPng && !Settings.SelectedBoshSkin.Equals("*default*"))
{
bodyPNG = new Bitmap(Program.UserDirectory + "/Riders/" + Settings.SelectedBoshSkin + "/body.png");
bodyDeadPNG = new Bitmap(Program.UserDirectory + "/Riders/" + Settings.SelectedBoshSkin + "/bodydead.png");
Expand Down Expand Up @@ -397,7 +403,7 @@ public void reloadRiderModel()
}
catch (Exception e) { Debug.WriteLine(e); Models.LoadModels(); }

if (Settings.SelectedBoshSkin == "default") { Models.LoadModels(); return; }
if (Settings.SelectedBoshSkin == "*default*") { Models.LoadModels(); return; }

try
{
Expand All @@ -420,7 +426,7 @@ public void updateScarf()
string scarfLocation = Program.UserDirectory + "/Scarves/" + Settings.SelectedScarf;
try
{
if ((Settings.SelectedScarf != "default") && (File.ReadLines(scarfLocation).First() == "#LRTran Scarf File"))
if ((Settings.SelectedScarf != "*default*") && (File.ReadLines(scarfLocation).First() == "#LRTran Scarf File"))
{
string[] lines = File.ReadAllLines(scarfLocation);
for (int i = 1; i < lines.Length; i++)
Expand Down
7 changes: 6 additions & 1 deletion src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static class Program
#endif
public static string BinariesFolder = "bin";
public readonly static CultureInfo Culture = new CultureInfo("en-US");
public static string Version = "6/10/20 - Build 1";
public static string Version = "6/11/20 - Build 1";
public static string TestVersion = "";
public static string NewVersion = null;
public static readonly string WindowTitle = "Line Rider: Advanced (Tran\'s fork) " + Version + TestVersion;
Expand Down Expand Up @@ -140,6 +140,11 @@ public static void Run()
System.Windows.Forms.MessageBox.Show("LRA User directory created at:\r\n" + UserDirectory);
}
Settings.Load();
//Create critical settings if needed
if (Settings.DefaultSaveFormat == null) { Settings.DefaultSaveFormat = ".trk"; }
if (Settings.DefaultQuicksaveFormat == null) { Settings.DefaultSaveFormat = ".trk"; }
if (Settings.DefaultAutosaveFormat == null) { Settings.DefaultSaveFormat = ".trk"; }
Settings.Save();

if (!Directory.Exists(UserDirectory + "Songs"))
Directory.CreateDirectory(UserDirectory + "Songs");
Expand Down
14 changes: 4 additions & 10 deletions src/Rendering/TrackRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
using linerider.Utils;
using linerider.Drawing;
using linerider.Game;
using linerider.IO.json;

namespace linerider.Rendering
{
Expand Down Expand Up @@ -95,16 +96,9 @@ public void Render(DrawOptions options)
else
_sceneryvbo.KnobState = KnobState.Hidden;

if (options.NightMode)
{
_sceneryvbo.OverrideColor = Constants.DefaultNightLineColor;
_physvbo.OverrideColor = Constants.DefaultNightLineColor;
}
else
{
_sceneryvbo.OverrideColor = Constants.DefaultLineColor;
_physvbo.OverrideColor = Constants.DefaultLineColor;
}
_sceneryvbo.OverrideColor = Constants.TriggerLineColorChange;
_physvbo.OverrideColor = Constants.TriggerLineColorChange;

if (options.LineColors)
{
_sceneryvbo.OverrideColor = Constants.SceneryLineColor;
Expand Down
2 changes: 1 addition & 1 deletion src/UI/Dialogs/ExportWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private void Setup()
Button ok = new Button(bottomrow)
{
Dock = Dock.Right,
Text = "Save"
Text = "Export"
};
if (!SafeFrameBuffer.CanRecord || !CheckRecord())
{
Expand Down
Loading

0 comments on commit 27cbcf5

Please sign in to comment.