Skip to content

Commit 43b17d0

Browse files
committed
Initial Commit
1 parent 5f960bd commit 43b17d0

12 files changed

Lines changed: 153 additions & 84 deletions

File tree

Architecture/Path.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace CodeRedLauncher.Architecture
88
// Unnecessary but I like working with it anyway because of the "append" function and divide operator overloads, there is room for improvement in some areas for sure but I don't care.
99
public class Path
1010
{
11-
private string? IndirectPath { get; set; } = null;
11+
private string IndirectPath { get; set; } = "";
1212

1313
private void Initialize(string str)
1414
{
@@ -29,7 +29,7 @@ public Path(string str)
2929
Initialize(str);
3030
}
3131

32-
public string? GetPath()
32+
public string GetPath()
3333
{
3434
return IndirectPath;
3535
}

Architecture/Result.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ namespace CodeRedLauncher
66
public class Result
77
{
88
public bool Succeeded { get; set; }
9-
public string? FailReason { get; set; }
9+
public string FailReason { get; set; }
1010

1111
public Result()
1212
{
1313
Succeeded = false;
1414
FailReason = null;
1515
}
1616

17-
public Result(bool bSucceeded, string? failReason = null)
17+
public Result(bool bSucceeded, string failReason = "")
1818
{
1919
Succeeded = bSucceeded;
2020
FailReason = failReason;

Architecture/Setting.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public T GetEnumValue<T>(bool bDefault = false)
108108

109109
public class PrivateSetting : PublicSetting
110110
{
111-
public PrivateSetting(string? defaultValue = null) : base(defaultValue, null, null, null) { }
111+
public PrivateSetting(string defaultValue = "") : base(defaultValue, null, null, null) { }
112112
}
113113

114114
public class InternalSetting : PublicSetting

Controls/CRNewsPanel.Designer.cs

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Controls/CRNewsPanel.cs

Lines changed: 96 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace CodeRedLauncher.Controls
1010
{
1111
public partial class CRNewsPanel : UserControl
1212
{
13-
private Int32 CurrentIndex = 0;
13+
private Int32 CurrentIndex = -1;
1414
private List<NewsStorage> NewsArticles = new List<NewsStorage>();
1515

1616
private class NewsStorage
@@ -150,12 +150,11 @@ private void ResetArticles()
150150
PublishDate = "Loading...";
151151
PublishAuthor = "Loading...";
152152
NewsCategory = "Loading...";
153+
IndexLbl.Text = ((CurrentIndex + 1).ToString() + "/" + NewsArticles.Count.ToString());
153154
Title = "Loading...";
154155
ThumbnailImg.BackgroundImage = null;
155156
PreviousBtn.Visible = false;
156-
NextBtn.Visible = true;
157-
CurrentIndex = 0;
158-
NewsArticles.Clear();
157+
NextBtn.Visible = false;
159158
}
160159

161160
// The commented out stuff in this function works fine, just the image links it retrieves are super low quality.
@@ -167,6 +166,7 @@ public async void ParseArticles(string url)
167166

168167
if (!String.IsNullOrEmpty(pageBody))
169168
{
169+
NewsArticles.Clear();
170170
ResetArticles();
171171
MatchCollection articleLinks = Regex.Matches(pageBody, "<a class=\"news-tile-wrap\" href=\"(.*)\">");
172172

@@ -180,7 +180,7 @@ public async void ParseArticles(string url)
180180
}
181181
}
182182

183-
LoadCurrentIndex();
183+
LoadNextArticle();
184184
}
185185
else
186186
{
@@ -191,96 +191,134 @@ public async void ParseArticles(string url)
191191

192192
private async void LoadCurrentIndex()
193193
{
194-
if (CurrentIndex < NewsArticles.Count)
194+
if (NewsArticles.Count > 0)
195195
{
196-
NewsStorage article = NewsArticles[CurrentIndex];
197-
198-
if (!article.Parsed)
196+
if ((CurrentIndex > -1) && (CurrentIndex < NewsArticles.Count))
199197
{
200-
NewsArticles[CurrentIndex] = await ParseLink(NewsArticles[CurrentIndex]);
201-
article = NewsArticles[CurrentIndex];
202-
}
198+
ResetArticles();
199+
NewsStorage article = NewsArticles[CurrentIndex];
203200

204-
PublishDate = article.Calendar;
205-
PublishAuthor = article.User;
206-
NewsCategory = article.Category;
207-
Title = article.Title;
201+
if (!article.Parsed)
202+
{
203+
NewsArticles[CurrentIndex] = await ParseLink(NewsArticles[CurrentIndex]);
204+
article = NewsArticles[CurrentIndex];
205+
}
208206

209-
if (article.ThumbnailImage == null)
210-
{
211-
if (!String.IsNullOrEmpty(article.ThumbnailUrl))
207+
PublishDate = article.Calendar;
208+
PublishAuthor = article.User;
209+
NewsCategory = article.Category;
210+
Title = article.Title;
211+
212+
if (article.ThumbnailImage == null)
212213
{
213-
ThumbnailImg.LoadAsync(article.ThumbnailUrl);
214+
if (!String.IsNullOrEmpty(article.ThumbnailUrl))
215+
{
216+
ThumbnailImg.LoadAsync(article.ThumbnailUrl);
217+
}
218+
else
219+
{
220+
ThumbnailImg.BackgroundImageLayout = ImageLayout.Center;
221+
ThumbnailImg.BackgroundImage = Properties.Resources.Warning_White;
222+
}
214223
}
215224
else
216225
{
217-
ThumbnailImg.BackgroundImage = Properties.Resources.Warning_White;
226+
ThumbnailImg.BackgroundImage = article.ThumbnailImage;
227+
ThumbnailImg.BackgroundImageLayout = ImageLayout.Stretch;
228+
}
229+
230+
if (CurrentIndex == 0)
231+
{
232+
PreviousBtn.Visible = false;
233+
NextBtn.Visible = true;
234+
}
235+
else if (CurrentIndex < (NewsArticles.Count - 1))
236+
{
237+
PreviousBtn.Visible = true;
238+
NextBtn.Visible = true;
239+
}
240+
else
241+
{
242+
PreviousBtn.Visible = true;
243+
NextBtn.Visible = false;
218244
}
219-
}
220-
else
221-
{
222-
ThumbnailImg.BackgroundImage = article.ThumbnailImage;
223-
ThumbnailImg.BackgroundImageLayout = ImageLayout.Stretch;
224245
}
225246
}
247+
else
248+
{
249+
ResetArticles();
250+
CurrentIndex = -1;
251+
}
226252
}
227253

228254
public void LoadPreviousArticle()
229255
{
230-
if (CurrentIndex > 0)
256+
if (NewsArticles.Count > 0)
231257
{
232-
CurrentIndex--;
233-
LoadCurrentIndex();
234-
}
258+
if (CurrentIndex > 0)
259+
{
260+
CurrentIndex--;
261+
}
262+
else
263+
{
264+
CurrentIndex = 0;
265+
}
235266

236-
if (CurrentIndex == 0)
237-
{
238-
PreviousBtn.Visible = false;
239-
NextBtn.Visible = true;
267+
LoadCurrentIndex();
240268
}
241-
else if (CurrentIndex != (NewsArticles.Count - 1))
269+
else
242270
{
243-
PreviousBtn.Visible = true;
244-
NextBtn.Visible = true;
271+
ResetArticles();
272+
CurrentIndex = -1;
245273
}
246274
}
247275

248276
public void LoadNextArticle()
249277
{
250-
if (CurrentIndex < NewsArticles.Count)
278+
if (NewsArticles.Count > 0)
251279
{
252-
CurrentIndex++;
253-
LoadCurrentIndex();
254-
}
280+
if (CurrentIndex < NewsArticles.Count)
281+
{
282+
CurrentIndex++;
283+
}
284+
else
285+
{
286+
CurrentIndex = (NewsArticles.Count - 1);
287+
}
255288

256-
if (CurrentIndex == (NewsArticles.Count - 1))
257-
{
258-
PreviousBtn.Visible = true;
259-
NextBtn.Visible = false;
289+
LoadCurrentIndex();
260290
}
261-
else if (CurrentIndex != 0)
291+
else
262292
{
263-
PreviousBtn.Visible = true;
264-
NextBtn.Visible = true;
293+
ResetArticles();
294+
CurrentIndex = -1;
265295
}
266296
}
267297

268298
private void ThumbnailImg_LoadCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
269299
{
270-
if (NewsArticles.Count > 0 && NewsArticles.Count > CurrentIndex)
300+
if (NewsArticles.Count > 0)
271301
{
272-
if (NewsArticles[CurrentIndex].ThumbnailImage == null)
302+
if ((CurrentIndex > -1) && (CurrentIndex < NewsArticles.Count))
273303
{
274-
NewsArticles[CurrentIndex].ThumbnailImage = ThumbnailImg.Image;
275-
}
304+
if (NewsArticles[CurrentIndex].ThumbnailImage == null)
305+
{
306+
NewsArticles[CurrentIndex].ThumbnailImage = ThumbnailImg.Image;
307+
}
276308

277-
if (ThumbnailImg.Image != null)
278-
{
279-
ThumbnailImg.BackgroundImage = ThumbnailImg.Image;
280-
ThumbnailImg.Image = null;
281-
}
309+
if (ThumbnailImg.Image != null)
310+
{
311+
ThumbnailImg.BackgroundImage = ThumbnailImg.Image;
312+
ThumbnailImg.Image = null;
313+
}
282314

283-
ThumbnailImg.BackgroundImageLayout = ImageLayout.Stretch;
315+
ThumbnailImg.BackgroundImageLayout = ImageLayout.Stretch;
316+
}
317+
}
318+
else
319+
{
320+
ResetArticles();
321+
CurrentIndex = -1;
284322
}
285323
}
286324

Controls/CRNewsPanel.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@
6666
<metadata name="DetailsPnl.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
6767
<value>True</value>
6868
</metadata>
69+
<metadata name="IndexLbl.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
70+
<value>True</value>
71+
</metadata>
6972
<metadata name="TitleLbl.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
7073
<value>True</value>
7174
</metadata>

Controls/CRProcessPanel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public StatusTypes Status
5353
break;
5454
case StatusTypes.TYPE_OUTDATED:
5555
TitleLbl.Text = "Rocket League Is Running";
56-
DescriptionLbl.Text = "Version mismatch, prevented injection!";
56+
DescriptionLbl.Text = "Version mismatch, preventing injection!";
5757
break;
5858
default:
5959
TitleLbl.Text = "Loading...";

Forms/MainFrm.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)