Skip to content

Commit e659201

Browse files
authored
Merge pull request #2 from counter185/linux-wine-compat
merge the `linux-wine-compat` branch...
2 parents 4ffccd2 + 6d0196b commit e659201

File tree

12 files changed

+212
-46
lines changed

12 files changed

+212
-46
lines changed

DeCraftLauncher/App.xaml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,85 @@
334334
</Trigger>
335335
</Style.Triggers>
336336
</Style>
337+
338+
<LinearGradientBrush x:Key="LBoxSelectedItemGradient" EndPoint="0.5,1" StartPoint="0.5,0">
339+
<GradientStop Color="#0378c7ff"/>
340+
<GradientStop Color="#3078c7ff" Offset="1"/>
341+
</LinearGradientBrush>
342+
343+
<LinearGradientBrush x:Key="LBoxHoveredItemGradient" EndPoint="0.5,1" StartPoint="0.5,0">
344+
<GradientStop Color="#0321cfff"/>
345+
<GradientStop Color="#10ffffff" Offset="1"/>
346+
</LinearGradientBrush>
347+
348+
<LinearGradientBrush x:Key="LBoxNoBorderHoveredItemGradient" EndPoint="0.5,1" StartPoint="0.5,0">
349+
<GradientStop Color="#03ffffff"/>
350+
<GradientStop Color="#10ffffff" Offset="1"/>
351+
</LinearGradientBrush>
352+
353+
<SolidColorBrush x:Key="LBoxSelectedItemBorder" Color="#FF78c7ff"/>
354+
355+
<Style x:Key="MainListBoxItemStyle" TargetType="ListBoxItem">
356+
<Setter Property="Template">
357+
<Setter.Value>
358+
<ControlTemplate TargetType="ListBoxItem">
359+
<Border Name="_Border"
360+
Padding="2"
361+
SnapsToDevicePixels="true">
362+
<ContentPresenter />
363+
</Border>
364+
<ControlTemplate.Triggers>
365+
<Trigger Property="IsSelected" Value="true">
366+
<Setter TargetName="_Border" Property="Background" Value="{StaticResource LBoxSelectedItemGradient}"/>
367+
<Setter TargetName="_Border" Property="BorderBrush" Value="{StaticResource LBoxSelectedItemBorder}"/>
368+
<Setter TargetName="_Border" Property="BorderThickness" Value="0.4"/>
369+
<Setter Property="Foreground" Value="White"/>
370+
</Trigger>
371+
<MultiTrigger>
372+
<MultiTrigger.Conditions>
373+
<Condition Property="IsMouseOver" Value="true" />
374+
<Condition Property="IsSelected" Value="false" />
375+
</MultiTrigger.Conditions>
376+
<Setter TargetName="_Border" Property="Background" Value="{StaticResource LBoxHoveredItemGradient}"/>
377+
<Setter TargetName="_Border" Property="BorderBrush" Value="White"/>
378+
<Setter TargetName="_Border" Property="BorderThickness" Value="0.2"/>
379+
<Setter Property="Foreground" Value="White"/>
380+
</MultiTrigger>
381+
</ControlTemplate.Triggers>
382+
</ControlTemplate>
383+
</Setter.Value>
384+
</Setter>
385+
</Style>
386+
387+
<Style x:Key="MainListBoxItemStyleNoSelectBorder" TargetType="ListBoxItem">
388+
<Setter Property="Template">
389+
<Setter.Value>
390+
<ControlTemplate TargetType="ListBoxItem">
391+
<Border Name="_Border"
392+
Padding="2"
393+
SnapsToDevicePixels="true">
394+
<ContentPresenter />
395+
</Border>
396+
<ControlTemplate.Triggers>
397+
<Trigger Property="IsSelected" Value="true">
398+
<Setter TargetName="_Border" Property="Background" Value="{StaticResource LBoxSelectedItemGradient}"/>
399+
<Setter TargetName="_Border" Property="BorderBrush" Value="{StaticResource LBoxSelectedItemBorder}"/>
400+
<Setter TargetName="_Border" Property="BorderThickness" Value="0.4"/>
401+
<Setter Property="Foreground" Value="White"/>
402+
</Trigger>
403+
<MultiTrigger>
404+
<MultiTrigger.Conditions>
405+
<Condition Property="IsMouseOver" Value="true" />
406+
<Condition Property="IsSelected" Value="false" />
407+
</MultiTrigger.Conditions>
408+
<Setter TargetName="_Border" Property="Background" Value="{StaticResource LBoxNoBorderHoveredItemGradient}"/>
409+
<Setter Property="Foreground" Value="White"/>
410+
</MultiTrigger>
411+
</ControlTemplate.Triggers>
412+
</ControlTemplate>
413+
</Setter.Value>
414+
</Setter>
415+
</Style>
337416
</ResourceDictionary>
338417

339418
</Application.Resources>

DeCraftLauncher/Configs/JarConfig.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public class JarConfig
4040
public bool jarHasLWJGLClasses = false;
4141
public string jarBuiltInLWJGLDLLs = "";
4242
public bool appletLogHTTPRequests = false;
43+
public bool appletIsOnePointSixHereYet = false;
4344

4445
public JarConfig(string jarFileName)
4546
{
@@ -81,6 +82,7 @@ public void SaveToXML(string path)
8182
rootElement.AppendChild(Util.GenElementChild(newXml, "AppletRedirectToLocalSkins", appletRedirectSkins.ToString()));
8283
rootElement.AppendChild(Util.GenElementChild(newXml, "AppletSkinRedirectLocalPath", appletSkinRedirectPath));
8384
rootElement.AppendChild(Util.GenElementChild(newXml, "AppletLogHTTPUrls", appletLogHTTPRequests.ToString()));
85+
rootElement.AppendChild(Util.GenElementChild(newXml, "AppletIsOnePointSixHereYet", appletIsOnePointSixHereYet.ToString()));
8486

8587
//generated by jar scanner
8688
XmlNode nodeValsAutogenerated = rootElement.AppendChild(Util.GenElementChild(newXml, "AutoGenerated"));
@@ -135,6 +137,7 @@ public static JarConfig LoadFromXML(string path, string jarName)
135137
newJarConf.appletRedirectSkins = bool.Parse(Util.GetInnerOrDefault(rootNode, "AppletRedirectToLocalSkins", "true", "bool"));
136138
newJarConf.appletSkinRedirectPath = Util.GetInnerOrDefault(rootNode, "AppletSkinRedirectLocalPath", "C:\\skincache");
137139
newJarConf.appletLogHTTPRequests = bool.Parse(Util.GetInnerOrDefault(rootNode, "AppletLogHTTPUrls", "false", "bool"));
140+
newJarConf.appletIsOnePointSixHereYet = bool.Parse(Util.GetInnerOrDefault(rootNode, "AppletIsOnePointSixHereYet", "false", "bool"));
138141

139142
//generated by jar scanner
140143
XmlNode nodeValsAutogenerated = rootNode.SelectSingleNode("AutoGenerated");

DeCraftLauncher/Configs/UI/WindowJavaFinder.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
TintOpacity="0.6"
1212
fw:AcrylicWindow.Enabled="False" Title="DECRAFT: Find Java" Height="350" Width="520" MinWidth="450" MinHeight="250" Background="#FA000000" AcrylicWindowStyle="Normal">
1313
<Grid>
14-
<ListBox x:Name="listbox_javaversions" Background="Transparent" ScrollViewer.CanContentScroll="False" Foreground="White" BorderBrush="#FF272727" Margin="10,54,10,10"/>
14+
<ListBox x:Name="listbox_javaversions" ItemContainerStyle="{StaticResource MainListBoxItemStyleNoSelectBorder}" Background="Transparent" ScrollViewer.CanContentScroll="False" Foreground="White" BorderBrush="#FF272727" Margin="10,54,10,10"/>
1515
<Label Content="Select Java version" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="39" Width="314" Foreground="White" FontSize="18" FontWeight="Bold"/>
1616

1717
</Grid>

DeCraftLauncher/Configs/UI/WindowRuntimeConfig.xaml.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,16 @@ private void jre_path_KeyDown(object sender, KeyEventArgs e)
8787

8888
private void AcrylicWindow_Closed(object sender, EventArgs e)
8989
{
90-
FixJavaHomeString();
91-
MainWindow.mainRTConfig.javaHome = jre_path.Text;
92-
MainWindow.mainRTConfig.isJava9 = checkbox_isjava9.IsChecked == true;
93-
parent.SaveRuntimeConfig();
90+
try
91+
{
92+
FixJavaHomeString();
93+
MainWindow.mainRTConfig.javaHome = jre_path.Text;
94+
MainWindow.mainRTConfig.isJava9 = checkbox_isjava9.IsChecked == true;
95+
parent.SaveRuntimeConfig();
96+
} catch (Exception ex)
97+
{
98+
MessageBox.Show(ex.ToString(), "DECRAFT");
99+
}
94100
}
95101

96102
private void Button_Click(object sender, RoutedEventArgs e)

DeCraftLauncher/MainWindow.xaml

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,27 @@
66
xmlns:fw="clr-namespace:SourceChord.FluentWPF;assembly=FluentWPF"
77
xmlns:local="clr-namespace:DeCraftLauncher"
88
mc:Ignorable="d"
9-
NoiseOpacity="0.0001"
10-
TintColor="#30000000"
11-
TintOpacity="0.3"
12-
AcrylicWindowStyle="Normal"
13-
MinWidth="770"
14-
MinHeight="400"
9+
Height="508" Width="800"
10+
MinWidth="800" MinHeight="400"
11+
NoiseOpacity="0.001"
12+
TintColor="#000000"
13+
TintOpacity="0.6"
1514
fw:AcrylicWindow.Enabled="False"
16-
Title="DECRAFT Launcher" Height="508" Width="800" Background="#FA000000" ClipToBounds="False" Opacity="0.985">
15+
Title="DECRAFT Launcher" Background="#FF000000">
1716
<Grid>
1817
<Grid.ColumnDefinitions>
19-
<ColumnDefinition Width="235"/>
20-
<ColumnDefinition/>
18+
<ColumnDefinition Width="4*"/>
19+
<ColumnDefinition Width="9*"/>
2120
</Grid.ColumnDefinitions>
22-
<Rectangle HorizontalAlignment="Left" Width="232" Margin="0,157,0,0">
23-
<Rectangle.Fill>
21+
<Label Content=".jar files" Margin="10,115,10,0" VerticalAlignment="Top" Foreground="White" FontSize="20" FontWeight="Bold"/>
22+
<ListBox x:Name="jarlist" TextSearch.TextPath="InnerText" ItemContainerStyle="{StaticResource MainListBoxItemStyleNoSelectBorder}" IsTextSearchEnabled="True" AllowDrop="True" Margin="0,157,0,0" Foreground="White" FontSize="16" BorderBrush="{x:Null}" SelectionChanged="jarlist_SelectionChanged" Drop="jarlist_Drop" HorizontalContentAlignment="Stretch" ScrollViewer.CanContentScroll="False">
23+
<ListBox.Background>
2424
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
2525
<GradientStop Color="#50000000"/>
2626
<GradientStop Color="#A0171717" Offset="1"/>
2727
</LinearGradientBrush>
28-
</Rectangle.Fill>
29-
</Rectangle>
30-
<Label Content=".jar files" Margin="10,115,0,0" VerticalAlignment="Top" Foreground="White" FontSize="20" FontWeight="Bold" HorizontalAlignment="Left" Width="84"/>
31-
<ListBox x:Name="jarlist" TextSearch.TextPath="InnerText" IsTextSearchEnabled="True" AllowDrop="True" Margin="0,157,0,0" Background="{x:Null}" Foreground="White" FontSize="16" BorderBrush="{x:Null}" SelectionChanged="jarlist_SelectionChanged" Drop="jarlist_Drop" HorizontalContentAlignment="Stretch" ScrollViewer.CanContentScroll="False"/>
28+
</ListBox.Background>
29+
</ListBox>
3230
<Grid x:Name="segment_launch_options" Margin="0,10,10,10" Grid.Column="1" >
3331
<Grid.ColumnDefinitions>
3432
<ColumnDefinition Width="102*"/>
@@ -40,7 +38,7 @@
4038

4139
<TextBox Style="{DynamicResource TextBoxMainStyle}" x:Name="tbox_playername" Margin="124,97,9,0" TextWrapping="NoWrap" Text="DECRAFT_Player" VerticalAlignment="Top"/>
4240
<Label Content="Player name" Margin="10,93,0,0" VerticalAlignment="Top" Background="{x:Null}" Foreground="White" HorizontalAlignment="Left" Width="109"/>
43-
<ListBox x:Name="entrypointlist" Foreground="White" Margin="0,209,0,-10" BorderBrush="{x:Null}" HorizontalContentAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.CanContentScroll="False" Grid.ColumnSpan="2">
41+
<ListBox x:Name="entrypointlist" Foreground="White" Margin="0,209,0,-10" ItemContainerStyle="{StaticResource MainListBoxItemStyle}" BorderBrush="{x:Null}" HorizontalContentAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.CanContentScroll="False" Grid.ColumnSpan="2">
4442
<ListBox.Background>
4543
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
4644
<GradientStop Color="#50000000"/>
@@ -67,7 +65,7 @@
6765
</Grid>
6866
<Image HorizontalAlignment="Left" Height="128" Margin="-12,0,0,0" VerticalAlignment="Top" Width="128" Source="/ImageRes/decraft_logo.png"/>
6967
<Label Content="DECRAFT" HorizontalAlignment="Left" Margin="71,2,0,0" VerticalAlignment="Top" Foreground="White" FontSize="36"/>
70-
<Label x:Name="versionString" Content="1.0-dev" Margin="0,84,48,0" VerticalAlignment="Top" Foreground="#FF505050" HorizontalAlignment="Right" Width="107" FontStyle="Italic"/>
68+
<Label x:Name="versionString" Content="1.0-dev" Margin="80,84,0,0" VerticalAlignment="Top" Foreground="#FF505050" FontStyle="Italic" HorizontalAlignment="Left" Width="107"/>
7169
<Button Content="Runtime settings" Margin="0,26,20,0" VerticalAlignment="Top" Height="26" Foreground="White" Background="{x:Null}" BorderBrush="#FF313131" Click="Button_Click" HorizontalAlignment="Right" Width="106" Grid.Column="1"/>
7270

7371
</Grid>

DeCraftLauncher/MainWindow.xaml.cs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using System.Windows.Media;
1818
using System.Windows.Shapes;
1919
using static DeCraftLauncher.Utils.JarUtils;
20+
using System.Windows.Input;
2021

2122
namespace DeCraftLauncher
2223
{
@@ -249,6 +250,11 @@ public MainWindow()
249250
tbox_instance_dir,
250251
tbox_proxyhost
251252
};
253+
254+
if (Util.RunningOnWine())
255+
{
256+
MessageBox.Show("You may be running DECRAFT on the Wine compatibility layer.\nIf the launcher crashes after this popup, open \"winecfg\" and set your Windows version to Windows 7.\nDECRAFT can only use Windows versions of Java, so be sure to install one into your Wine prefix.\n\nGood luck, and expect bugs.", "DECRAFT");
257+
}
252258
}
253259

254260
private void Button_Click(object sender, RoutedEventArgs e)
@@ -438,5 +444,63 @@ public void SaveRuntimeConfig()
438444
{
439445
mainRTConfig.SaveToXML(this);
440446
}
447+
448+
public static IEnumerable<T> FindLogicalChildren<T>(DependencyObject depObj) where T : DependencyObject
449+
{
450+
if (depObj != null)
451+
{
452+
foreach (object rawChild in LogicalTreeHelper.GetChildren(depObj))
453+
{
454+
if (rawChild is DependencyObject)
455+
{
456+
DependencyObject child = (DependencyObject)rawChild;
457+
if (child is T)
458+
{
459+
yield return (T)child;
460+
}
461+
462+
foreach (T childOfChild in FindLogicalChildren<T>(child))
463+
{
464+
yield return childOfChild;
465+
}
466+
}
467+
}
468+
}
469+
}
470+
471+
int pauseBreakEECount = 0;
472+
473+
protected override void OnKeyDown(KeyEventArgs e)
474+
{
475+
//comic sans easter egg
476+
if (e.Key == Key.Pause)
477+
{
478+
if (pauseBreakEECount++ == 5)
479+
{
480+
if (!Util.RunningOnWine()) //the font isn't installed there by default so it will crash
481+
{ //sorry linux people no comic sans
482+
FontFamily targetFontFamily = new FontFamily("Comic Sans MS");
483+
foreach (TextBlock a in FindLogicalChildren<TextBlock>(this))
484+
{
485+
a.FontFamily = targetFontFamily;
486+
}
487+
foreach (Label a in FindLogicalChildren<Label>(this))
488+
{
489+
a.FontFamily = targetFontFamily;
490+
}
491+
foreach (TextBox a in FindLogicalChildren<TextBox>(this))
492+
{
493+
a.FontFamily = targetFontFamily;
494+
}
495+
foreach (Button a in FindLogicalChildren<Button>(this))
496+
{
497+
a.FontFamily = targetFontFamily;
498+
}
499+
pauseBreakEECount = 0;
500+
}
501+
}
502+
}
503+
base.OnKeyDown(e);
504+
}
441505
}
442506
}

DeCraftLauncher/Utils/JarUtils.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ select drive.Name.Replace('\\', '/')).ToList().ForEach((driveLabel) => {
150150
"Eclipse Adoptium",
151151
"AdoptOpenJDK",
152152
"Android/Android Studio",
153+
"BellSoft", //Liberica
154+
"Semeru", //IBM
153155
"Microsoft"
154156
};
155157
foreach (string vendorPath in vendorPaths)

DeCraftLauncher/Utils/JavaCode.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class InjectedURLConnection extends HttpURLConnection {{
3333
int connectionType = 0; //0: login
3434
//1: skin server
3535
//2: resource server
36+
//3: 1_6_has_been_released.flag
3637
String strippedConnUrl = """";
3738
3839
protected InjectedURLConnection(URL url, int connectionType) {{
@@ -64,6 +65,9 @@ protected InjectedURLConnection(URL url, int connectionType) {{
6465
break;
6566
case 2:
6667
break;
68+
case 3:
69+
injectedDataStream = new ByteArrayInputStream(""https://github.com/counter185/DECRAFT_Launcher"".getBytes());
70+
break;
6771
}}
6872
thisUrl = url;
6973
}}
@@ -106,6 +110,7 @@ public boolean usingProxy() {{
106110
class InjectedURLStreamHandler extends URLStreamHandler {{
107111
108112
final boolean LOG_ALL_HTTP_CONNECTIONS = {(jar.appletLogHTTPRequests ? "true" : "false")};
113+
final boolean IS_ONEPOINTSIX_HERE_YET = {(jar.appletIsOnePointSixHereYet ? "true" : "false")};
109114
final boolean INJECT_SKIN_REQUESTS = {(jar.appletRedirectSkins ? "true" : "false")};
110115
String protocol;
111116
@@ -116,12 +121,18 @@ public InjectedURLStreamHandler(String protocol){{
116121
protected URLConnection openConnection(URL u) throws IOException {{
117122
//System.out.println(""[InjectedURLStreamHandler] url:"" + u);
118123
//System.out.println(""[InjectedURLStreamHandler] path:"" + u.getPath());
119-
if (u.toString().contains(""?n="")){{
124+
if (u.toString().contains(""?n=""))
125+
{{
120126
return new InjectedURLConnection(u, 0);
121127
}} else if ((u.toString().contains(""minecraft.net/skin/"")
122128
|| u.toString().contains(""skins.minecraft.net/MinecraftSkins/""))
123-
&& INJECT_SKIN_REQUESTS) {{
129+
&& INJECT_SKIN_REQUESTS)
130+
{{
124131
return new InjectedURLConnection(u, 1);
132+
}} else if (u.toString().contains(""assets.minecraft.net/1_6_has_been_released.flag"")
133+
&& IS_ONEPOINTSIX_HERE_YET)
134+
{{
135+
return new InjectedURLConnection(u, 3);
125136
}} else {{
126137
if (LOG_ALL_HTTP_CONNECTIONS) {{
127138
System.out.println(""[InjectedURLStreamHandler] url: "" + u + "" , path: "" + u.getPath());

0 commit comments

Comments
 (0)