Skip to content

Commit cc579e5

Browse files
committed
Version 1.3.0. Fixed a bug in island required challenges and added a new version checker
1 parent 17483b7 commit cc579e5

File tree

6 files changed

+90
-17
lines changed

6 files changed

+90
-17
lines changed

MainWindow.xaml.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ public partial class MainWindow : Window
2020
public static FontFamily MC_Italic = new FontFamily(new Uri("pack://application:,,,/"), "./Fonts/MC_Italic/#Minecraft");
2121
public static FontFamily MC_Bold_Italic = new FontFamily(new Uri("pack://application:,,,/"), "./Fonts/MC_Bold_Italic/#Minecraft");
2222
private static string LastIPFile = "config";
23-
public static Version v = new Version(1, 2, 1);
23+
public static Version v = new Version(1, 3, 0);
2424
public MainWindow()
2525
{
2626
Ressource.initTypes();
2727
InitializeComponent();
28+
2829
//true uniquement lorsque l'application doit être débug (se passe de l'étape de connexion au serveur. Permet d'importer des items, challenges, etc.. localement.
2930
//(Suppression désactivée mais possibilité d'importer le meme challenge en le glissant dans la boxes + ecraser)
3031
init(false);
@@ -80,5 +81,6 @@ public void updateLastIP(string lastip)
8081
fs.Write(info, 0, info.Length);
8182
}
8283
}
84+
8385
}
8486
}

Pages/Connect.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
<TextBox x:Name="tbxAddrIP" Visibility="Hidden" HorizontalAlignment="Left" Style="{StaticResource lblFont1}" FontSize="23" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Margin="10,141,0,0" TextWrapping="Wrap" Text="localhost:25575" VerticalAlignment="Top" Width="200" Height="30"/>
2525
<Label x:Name="lblAddrIP" Visibility="Hidden" ToolTip="Modifier l'adresse IP du serveur (P.ex: localhost:25575)" Content="Adresse IP" Style="{StaticResource lblFont1}" HorizontalContentAlignment="Center" FontSize="25" HorizontalAlignment="Left" VerticalAlignment="Top" Width="108" Height="32" Margin="56,104,0,0"/>
2626
</Grid>
27-
<Label x:Name="lblInfo" Content="© 2024 - Version {V} by Luca008" Style="{StaticResource lblFont1}" HorizontalContentAlignment="Right" FontSize="18" HorizontalAlignment="Right" Margin="0,378,10,0" VerticalContentAlignment="Center" VerticalAlignment="Top" Width="266" Height="32"/>
27+
<Label x:Name="lblNewVersion" Content="Vérification de la version du client..." Style="{StaticResource lblFont1}" FontSize="18" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,55"></Label>
28+
<Label x:Name="lblInfo" Content="© 2025 - Version {V} by Luca008" Style="{StaticResource lblFont1}" HorizontalContentAlignment="Right" FontSize="18" HorizontalAlignment="Right" Margin="0,378,10,0" VerticalContentAlignment="Center" VerticalAlignment="Top" Width="266" Height="32"/>
2829
<Label x:Name="lblSplash" Content="Challenges 1.20.4" Foreground="#FFFDFF00" Style="{StaticResource Minecraft}" FontSize="22" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="520,84,0,0" HorizontalContentAlignment="Center" VerticalContentAlignment="Center">
2930
<Label.RenderTransform>
3031
<TransformGroup>

Pages/Connect.xaml.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
using System;
22
using System.Diagnostics;
3+
using System.Threading;
34
using System.Threading.Tasks;
45
using System.Windows;
56
using System.Windows.Controls;
67
using System.Windows.Input;
8+
using System.Windows.Media;
79
using Challenges_App.Packet;
810
using Challenges_App.Packet.Packets;
911

@@ -15,6 +17,7 @@ namespace Challenges_App.Pages
1517
public partial class Connect : Page
1618
{
1719
private Boolean animate = true;
20+
private Version lastVersion = new Version(1,0,0);
1821
public Connect(string? lastIp)
1922
{
2023
InitializeComponent();
@@ -74,6 +77,7 @@ public Connect(string? lastIp)
7477
});
7578
btnAccess.addMouseEnter(c => btnAccess.Animation = true);
7679
btnAccess.addMouseLeave(c => btnAccess.Animation = false);
80+
new Thread(() => checkVersion()).Start();
7781
}
7882

7983
private String? getIP()
@@ -168,5 +172,52 @@ private async void lblAnimation()
168172
await Task.Delay(10);
169173
}
170174
}
175+
176+
private void lblNewVersion_MouseUp(object sender, MouseButtonEventArgs e)
177+
{
178+
String url = "https://github.com/Lucaa8/Challenges_App/releases/tag/csharp_app_" + lastVersion.ToString();
179+
Ressource.OpenBrowser(url);
180+
}
181+
182+
private void checkVersion()
183+
{
184+
String? strLastVersion = Ressource.getLastVersion();
185+
if (strLastVersion == null)
186+
{
187+
Ressource.synchronize(() =>
188+
{
189+
lblNewVersion.Content = "Impossible de vérifier si l'application est à jour...";
190+
lblNewVersion.Foreground = Brushes.DarkRed;
191+
});
192+
return;
193+
}
194+
String[] versionValues = strLastVersion.Split('.');
195+
if (versionValues.Length != 3)
196+
{
197+
Ressource.synchronize(() =>
198+
{
199+
lblNewVersion.Content = "Impossible de vérifier si l'application est à jour...";
200+
lblNewVersion.Foreground = Brushes.DarkRed;
201+
});
202+
return;
203+
}
204+
Action sync = () => { };
205+
lastVersion = new Version(Int32.Parse(versionValues[0]), Int32.Parse(versionValues[1]), Int32.Parse(versionValues[2]));
206+
if (!lastVersion.Equals(MainWindow.v))
207+
{
208+
sync = () =>
209+
{
210+
lblNewVersion.Content = "La nouvelle version " + lastVersion.ToString() + " est disponible! Clique-moi pour t'y rendre";
211+
lblNewVersion.Cursor = Cursors.Hand;
212+
lblNewVersion.MouseUp += lblNewVersion_MouseUp;
213+
};
214+
}
215+
else
216+
{
217+
sync = () => lblNewVersion.Content = "Le client est à jour!";
218+
}
219+
Ressource.synchronize(sync);
220+
}
221+
171222
}
172223
}

Pages/Required/Island.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private void add()
123123
if (item != null)
124124
{
125125
uuid = item.Tag.ToString().Split(":")[0];
126-
int value = Int32.Parse(item.Tag.ToString().Split(":")[1]);
126+
int value = Int32.Parse(item.Tag.ToString().Split(":")[2]);
127127
if (MessageBox.Show("Ce type existe déjà (Valeur="+value+").\nEn faisant ça tu vas écraser son contenu.\nContinuer?", "Error type already exists", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No) == MessageBoxResult.Yes)
128128
{
129129
getBox(item.Content.ToString()).Items.Remove(item);

Properties/PublishProfiles/FolderProfile.pubxml.user

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
44
-->
55
<Project>
66
<PropertyGroup>
7-
<History>True|2025-02-02T23:16:23.8815363Z||;True|2025-02-03T00:15:00.3025328+01:00||;True|2023-10-14T15:02:18.7626300+02:00||;True|2023-10-14T13:52:30.4135204+02:00||;True|2023-10-13T22:55:47.4867070+02:00||;True|2023-10-13T22:55:27.6407595+02:00||;True|2023-10-13T22:54:59.5717476+02:00||;True|2023-10-13T22:53:20.5445468+02:00||;True|2022-08-21T17:07:33.5385272+02:00||;True|2022-07-23T22:23:59.7845278+02:00||;True|2022-01-17T20:51:22.3444736+01:00||;True|2022-01-17T15:24:11.0506125+01:00||;True|2022-01-17T15:22:51.3003623+01:00||;True|2022-01-17T15:22:04.6797333+01:00||;False|2022-01-17T15:20:15.9710703+01:00||;False|2022-01-17T15:19:50.4001956+01:00||;True|2022-01-17T15:18:44.5443997+01:00||;True|2022-01-17T15:16:58.3305098+01:00||;True|2022-01-17T15:16:03.5282079+01:00||;</History>
7+
<History>True|2025-02-20T18:33:04.0664270Z||;True|2025-02-03T00:16:23.8815363+01:00||;True|2025-02-03T00:15:00.3025328+01:00||;True|2023-10-14T15:02:18.7626300+02:00||;True|2023-10-14T13:52:30.4135204+02:00||;True|2023-10-13T22:55:47.4867070+02:00||;True|2023-10-13T22:55:27.6407595+02:00||;True|2023-10-13T22:54:59.5717476+02:00||;True|2023-10-13T22:53:20.5445468+02:00||;True|2022-08-21T17:07:33.5385272+02:00||;True|2022-07-23T22:23:59.7845278+02:00||;True|2022-01-17T20:51:22.3444736+01:00||;True|2022-01-17T15:24:11.0506125+01:00||;True|2022-01-17T15:22:51.3003623+01:00||;True|2022-01-17T15:22:04.6797333+01:00||;False|2022-01-17T15:20:15.9710703+01:00||;False|2022-01-17T15:19:50.4001956+01:00||;True|2022-01-17T15:18:44.5443997+01:00||;True|2022-01-17T15:16:58.3305098+01:00||;True|2022-01-17T15:16:03.5282079+01:00||;</History>
88
<LastFailureDetails />
99
</PropertyGroup>
1010
</Project>

Ressource.cs

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics;
34
using System.IO;
45
using System.Net;
6+
using System.Net.Http;
57
using System.Net.NetworkInformation;
68
using System.Net.Sockets;
79
using System.Windows;
@@ -83,20 +85,37 @@ public static long getPing(String ip)
8385
return null;
8486
}
8587
//Récupère l'ip externe d'un utilisateur
86-
public static String getExternIP()
88+
public static String? getExternIP()
8789
{
88-
//Prépare une connexion au site distant
89-
Uri url = new Uri("https://ipecho.net/plain");
90-
//Demande la connexion au site distant
91-
WebRequest request = WebRequest.Create(url);
92-
//Essaye de récupèrer une réponse (peut être null si le site est down je suppose)
93-
WebResponse response = request.GetResponse();
94-
//Permet de lire le contenu du site (Ce site contient uniquement l'ip, pas besoin de gerer le string)
95-
StreamReader sr = new StreamReader(response.GetResponseStream());
96-
String ip = sr.ReadToEnd();
97-
//Ferme le Reader
98-
sr.Close();
99-
return ip;
90+
return getTextAtUrl("https://ipecho.net/plain");
91+
}
92+
//Récupère la dernière version de l'application dans le fichier version.txt du main du repository github
93+
public static String? getLastVersion()
94+
{
95+
return getTextAtUrl("https://raw.githubusercontent.com/Lucaa8/Challenges_App/refs/heads/main/version.md");
96+
}
97+
private static String? getTextAtUrl(String url)
98+
{
99+
String? result = null;
100+
using (HttpClient client = new HttpClient())
101+
{
102+
try
103+
{
104+
HttpResponseMessage response = client.GetAsync(url).GetAwaiter().GetResult();
105+
response.EnsureSuccessStatusCode();
106+
result = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
107+
}
108+
catch (Exception) { }
109+
}
110+
return result;
111+
}
112+
public static void OpenBrowser(String url)
113+
{
114+
try
115+
{
116+
Process.Start(new ProcessStartInfo{ FileName = url, UseShellExecute = true });
117+
}
118+
catch (Exception) { }
100119
}
101120
public static String getTimeNow()
102121
{

0 commit comments

Comments
 (0)