Skip to content
This repository has been archived by the owner on Sep 30, 2023. It is now read-only.

Commit

Permalink
Rebrand our switcher
Browse files Browse the repository at this point in the history
  • Loading branch information
r33int committed Apr 17, 2021
1 parent 64055fc commit 0205b62
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 35 deletions.
10 changes: 5 additions & 5 deletions KawataSwitcher/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
public class Constants
{
// Use this address if we cannot grab from ips.txt
public const string GatariHardcodedIp = "163.172.255.98";
public const string KawataHardcodedIp = "88.99.222.214";

// Grab address from here when possible
public const string GatariIpApiAddress = "http://osu.gatari.pw/api/v1/ip";
public const string KawataIpApiAddress = "http://old.kawata.pw/ips.txt";

public const string UiInstallCertificate = "Install Certificate";

public const string UiUninstallCertificate = "Delete Certificate";

public const string UiYouArePlayingOnGatari = "You're connected to Gatari!";
public const string UiYouArePlayingOnKawata = "You're connected to Kawata!";

public const string UiYouArePlayingOnOfficial = "You're playing on Bancho";

public const string UiSwitchToGatari = "Connect to Gatari";
public const string UiSwitchToKawata = "Connect to Kawata";

public const string UiSwitchToOfficial = "Disconnect from Gatari";
public const string UiSwitchToOfficial = "Disconnect from Kawata";

public const string UiUpdatingStatus = "Retrieving addresses..";
}
Expand Down
4 changes: 2 additions & 2 deletions KawataSwitcher/Helpers/GeneralHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ namespace KawataSwitcher
{
static class GeneralHelper
{
public async static Task<string> GetGatariAddressAsync()
public async static Task<string> GetKawataAddressAsync()
{
using (var webClient = new WebClient())
{
string result = string.Empty;
try
{
var line = await webClient.DownloadStringTaskAsync(Constants.GatariIpApiAddress);
var line = await webClient.DownloadStringTaskAsync(Constants.KawataIpApiAddress);
result = line;
}
catch { }
Expand Down
2 changes: 1 addition & 1 deletion KawataSwitcher/Logger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static string LogPath
get
{
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"gatari-switcher-log.txt");
"kawata-switcher-log.txt");
}
}
}
Expand Down
24 changes: 12 additions & 12 deletions KawataSwitcher/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Window x:Class="KawataSwitcher.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Gatari Switcher" Height="170" Width="310" WindowStyle="None" ResizeMode="NoResize" AllowsTransparency="True" Background="Transparent"
Title="Kawata Switcher" Height="182.425" Width="332.591" WindowStyle="None" ResizeMode="NoResize" AllowsTransparency="True" Background="Transparent"
WindowStartupLocation="CenterScreen">
<Grid x:Name="mainGrid">
<Grid.Effect>
<DropShadowEffect BlurRadius="10" Opacity=".5" RenderingBias="Performance" ShadowDepth="2"/>
</Grid.Effect>
<Grid x:Name="layoutGrid" Background="White" Margin="10">

<Grid x:Name="layoutGrid" Background="#442d6d" Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
Expand All @@ -17,13 +17,13 @@
<RowDefinition Height="*"/>
</Grid.RowDefinitions>

<Grid x:Name="titleBar" Background="#FFBB005B" MouseLeftButtonDown="titleBar_MouseLeftButtonDown">
<Grid x:Name="titleBar" Background="#310735" MouseLeftButtonDown="titleBar_MouseLeftButtonDown">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="30"/>
</Grid.ColumnDefinitions>
<Label Content="Gatari Switcher" VerticalContentAlignment="Center" FontSize="16" Foreground="White" TextOptions.TextFormattingMode="Display" />
<Button x:Name="closeButton" Grid.Column="1" Style="{StaticResource ResourceKey=flatButton}" Background="#FFBB005B" Click="closeButton_Click">
<Label Content="Kawata Switcher" VerticalContentAlignment="Center" FontSize="16" Foreground="White" TextOptions.TextFormattingMode="Display" />
<Button x:Name="closeButton" Grid.Column="1" Style="{StaticResource ResourceKey=flatButton}" Background="#310735" Click="closeButton_Click">
<Grid>
<Rectangle Height="20" Width="2" Fill="White" RenderTransformOrigin="0.5,0.5" >
<Rectangle.RenderTransform>
Expand All @@ -50,15 +50,15 @@
</Grid>

<Label x:Name="statusLabel" Grid.Row="1" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
FontSize="16" Foreground="#FF424242"/>
FontSize="14" Foreground="white" Background="#442d6d"/>

<Button x:Name="switchButton" Grid.Row="2" Style="{StaticResource ResourceKey=awesomeButton}" Click="switchButton_Click" />
<Button x:Name="switchButton" Grid.Row="2" Style="{StaticResource ResourceKey=awesomeButton}" Click="switchButton_Click" Margin="0,0,0,29" Grid.RowSpan="2" />

<Button x:Name="certButton" Grid.Row="3" Style="{StaticResource ResourceKey=awesomeButton}"
ToolTip="Без этой штуки вы не сможете подключиться к серверу на последних версиях игры" Click="sertButton_Click"/>
<TextBlock x:Name="websiteText" Grid.Row="4" Text="osu.gatari.pw" HorizontalAlignment="Right" VerticalAlignment="Center"
TextDecorations="Underline" Margin="4" Cursor="Hand" MouseLeftButtonDown="websiteText_MouseLeftButtonDown"/>
ToolTip="Without this thing, you will not be able to connect to the server on the latest versions of the game" Click="sertButton_Click" Margin="0,5,0,25" Grid.RowSpan="2"/>

<TextBlock x:Name="websiteText" Grid.Row="4" Text="kawata.pw" HorizontalAlignment="Right" VerticalAlignment="Center"
TextDecorations="Underline" Margin="0,14,4,4" Cursor="Hand" MouseLeftButtonDown="websiteText_MouseLeftButtonDown" Foreground="White"/>

</Grid>
</Grid>
Expand Down
18 changes: 9 additions & 9 deletions KawataSwitcher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ private async void InitSwitcher()
await CheckSertificate();

// load server ip
var serverIp = await GeneralHelper.GetGatariAddressAsync();
var serverIp = await GeneralHelper.GetKawataAddressAsync();
if (serverIp == string.Empty)
{
MessageBox.Show("An error occurred while retrieving Gatari's IP. Maybe check your Internet connection?" + Environment.NewLine +
MessageBox.Show("An error occurred while retrieving Kawata's IP. Maybe check your Internet connection?" + Environment.NewLine +
"Stored IP address will be used");
serverIp = Constants.GatariHardcodedIp;
serverIp = Constants.KawataHardcodedIp;
}
serverSwitcher = new ServerSwitcher(serverIp);

Expand All @@ -55,10 +55,10 @@ private async Task CheckServer()
{
switchButton.IsEnabled = false;
var currentServer = await serverSwitcher.GetCurrentServerAsync();
statusLabel.Content = (currentServer == Server.Gatari)
? Constants.UiYouArePlayingOnGatari : Constants.UiYouArePlayingOnOfficial;
statusLabel.Content = (currentServer == Server.Kawata)
? Constants.UiYouArePlayingOnKawata : Constants.UiYouArePlayingOnOfficial;
switchButton.Content = (currentServer == Server.Official)
? Constants.UiSwitchToGatari : Constants.UiSwitchToOfficial;
? Constants.UiSwitchToKawata : Constants.UiSwitchToOfficial;
switchButton.IsEnabled = true;
}

Expand All @@ -75,7 +75,7 @@ private async void switchButton_Click(object sender, RoutedEventArgs e)
{
if (serv == Server.Official)
{
serverSwitcher.SwitchToGatari();
serverSwitcher.SwitchToKawata();
}
else
{
Expand All @@ -84,7 +84,7 @@ private async void switchButton_Click(object sender, RoutedEventArgs e)
}
catch (Exception ex)
{
MessageBox.Show("An error occurred while connecting to Gatari. If you still can't connect and have tried disabling your antivirus, please ask for help either in our discord or by checking the contact block on VK"
MessageBox.Show("An error occurred while connecting to Kawata. If you still can't connect and have tried disabling your antivirus, please ask for help either in our Discord server or by contacting accounts[at]kawata[dot]pw."
+ string.Format("\r\n\r\nDetails:\r\n{0}", ex.Message));
Logger.Log(ex);
}
Expand Down Expand Up @@ -125,7 +125,7 @@ private void DisableSwitching()

private void websiteText_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
System.Diagnostics.Process.Start("http://osu.gatari.pw");
System.Diagnostics.Process.Start("http://kawata.pw");
}

private void titleBar_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
Expand Down
17 changes: 11 additions & 6 deletions KawataSwitcher/ServerSwitcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ class ServerSwitcher
{
private readonly string serverAddress;

public ServerSwitcher(string gatariIpAddress)
public ServerSwitcher(string kawataIpAddress)
{
this.serverAddress = gatariIpAddress;
this.serverAddress = kawataIpAddress;
}

public void SwitchToGatari()
public void SwitchToKawata()
{
var lines = HostsFile.ReadAllLines();
var result = lines.Where(x => !x.Contains("ppy.sh")).ToList();
Expand All @@ -23,6 +23,11 @@ public void SwitchToGatari()
serverAddress + " osu.ppy.sh",
serverAddress + " c.ppy.sh",
serverAddress + " c1.ppy.sh",
serverAddress + " c2.ppy.sh",
serverAddress + " c3.ppy.sh",
serverAddress + " c4.ppy.sh",
serverAddress + " c5.ppy.sh",
serverAddress + " ce.ppy.sh",
serverAddress + " a.ppy.sh",
serverAddress + " i.ppy.sh"
);
Expand All @@ -41,14 +46,14 @@ public Task<Server> GetCurrentServerAsync()

public Server GetCurrentServer()
{
bool isGatari = HostsFile.ReadAllLines().Any(x => x.Contains("osu.ppy.sh") && !x.Contains("#"));
return isGatari ? Server.Gatari : Server.Official;
bool isKawata = HostsFile.ReadAllLines().Any(x => x.Contains("osu.ppy.sh") && !x.Contains("#"));
return isKawata ? Server.Kawata : Server.Official;
}
}

public enum Server
{
Official,
Gatari
Kawata
}
}
Binary file modified KawataSwitcher/icon.ico
Binary file not shown.

0 comments on commit 0205b62

Please sign in to comment.