Skip to content

Commit

Permalink
remember last opened folder for templates
Browse files Browse the repository at this point in the history
filefilter changed to *.*
fix buff record for guild members (not friends)
change translation on region change
  • Loading branch information
fedorovvl committed Aug 6, 2022
1 parent da8a6fd commit 59326d7
Show file tree
Hide file tree
Showing 11 changed files with 220 additions and 41 deletions.
10 changes: 5 additions & 5 deletions client/Main.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="TSO Game Client" Height="401" Icon="files/icon.ico" Width="256" MouseLeftButtonDown="titleBar_MouseLeftButtonDown" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" WindowStyle="None" AllowsTransparency="true">
<Window.Background>
<ImageBrush ImageSource="files/back.png" />
<ImageBrush x:Name="mainback" ImageSource="files/back.png" />
</Window.Background>
<Window.Resources>
<SolidColorBrush x:Key="NormalBrushScrollBar" Color="#ccc"/>
Expand Down Expand Up @@ -244,9 +244,9 @@

</Window.Resources>
<Grid Focusable="false">
<TextBox Height="20" HorizontalAlignment="Left" Margin="38,162,0,0" GotFocus="login_GotFocus" Text="Электронный адрес" TextAlignment="Center" LostFocus="login_LostFocus" PreviewMouseDown="password_MouseDown" Name="login" VerticalAlignment="Top" Width="171" Background="#00000000" BorderBrush="#00000000" Foreground="White" Visibility="Visible" BorderThickness="0" />
<TextBox Height="20" HorizontalAlignment="Left" Margin="38,162,0,0" GotFocus="login_GotFocus" Text="{Binding langLogin, Mode=OneWay}" TextAlignment="Center" LostFocus="login_LostFocus" PreviewMouseDown="password_MouseDown" Name="login" VerticalAlignment="Top" Width="171" Background="#00000000" BorderBrush="#00000000" Foreground="White" Visibility="Visible" BorderThickness="0" />
<PasswordBox Background="#00000000" BorderBrush="#00000000" KeyUp="password_KeyUp" BorderThickness="0" LostFocus="password_LostFocus" GotFocus="password_GotFocus" HorizontalContentAlignment="Center" Foreground="White" Height="20" HorizontalAlignment="Left" Margin="38,209,0,0" Name="password" VerticalAlignment="Top" Visibility="Visible" Width="170" />
<TextBox Background="#00000000" BorderBrush="#00000000" BorderThickness="0" TextAlignment="Center" Text="Пароль" PreviewMouseDown="pwd_PreviewMouseDown" Foreground="White" Height="20" HorizontalAlignment="Left" Margin="38,209,0,0" Name="pwd" VerticalAlignment="Top" Visibility="Visible" Width="170" />
<TextBox Background="#00000000" BorderBrush="#00000000" BorderThickness="0" TextAlignment="Center" Text="{Binding langPass, Mode=OneWay}" PreviewMouseDown="pwd_PreviewMouseDown" Foreground="White" Height="20" HorizontalAlignment="Left" Margin="38,209,0,0" Name="pwd" VerticalAlignment="Top" Visibility="Visible" Width="170" />
<Button Height="44" Focusable="False" BorderBrush="#00000000" Cursor="Hand" Click="butt_Click_1" Name="butt" HorizontalAlignment="Left" Margin="29,272,0,0" VerticalAlignment="Top" Width="196" Background="#00000000" Foreground="White" BorderThickness="0" />
<Button Height="10" HorizontalAlignment="Left" Margin="176,330,0,0" Name="button1" VerticalAlignment="Top" Width="38" Focusable="False" BorderBrush="#00000000" Cursor="Hand" Click="butt_Click" Background="#00000000" Foreground="White" BorderThickness="0" />
<TextBlock Height="23" HorizontalAlignment="Left" Margin="32,326,0,0" Name="error" FontWeight="Bold" Foreground="WhiteSmoke" Text="" VerticalAlignment="Top" Width="139" />
Expand Down Expand Up @@ -297,8 +297,8 @@
<ComboBoxItem Tag="it" Uid="12" Content="Italia"/>
<ComboBoxItem Tag="es" Uid="13" Content="México"/>
<ComboBoxItem Tag="nl" Uid="14" Content="Nederland"/>
<ComboBoxItem Tag="es" Uid="15" Content="Perú"/>
<ComboBoxItem Tag="ru" Uid="16" Content="Российская Федерация" IsSelected="True"/>
<ComboBoxItem Tag="es" Uid="15" Content="Perú" IsSelected="True"/>
<ComboBoxItem Tag="ru" Uid="16" Content="Российская Федерация"/>
<ComboBoxItem Tag="pl" Uid="17" Content="Polska"/>
<ComboBoxItem Tag="ro" Uid="18" Content="România"/>
<ComboBoxItem Tag="us" Uid="19" Content="United States"/>
Expand Down
72 changes: 57 additions & 15 deletions client/Main.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
using System.Threading;
using System.Net;
using System.Web;
using System.Drawing;
using System.Windows.Media.Imaging;
using System.ComponentModel;

namespace client
{
/// <summary>
/// Логика взаимодействия для Window1.xaml
/// </summary>
public partial class Main : Window
public partial class Main : Window, INotifyPropertyChanged
{
public static bool logging = true;
public static bool debug = false;
Expand All @@ -25,16 +28,35 @@ public partial class Main : Window
public static string lang = string.Empty;
public static bool auto = false;
public static CookieCollection _cookies;
private string _region = string.Empty;
public static string _region = string.Empty;
private int _regionUid;
public static Arguments cmd;
private string _langLogin;
private string _langPass;
public string langLogin
{
get { return _langLogin; }
set { _langLogin = value; OnPropertyChanged("langLogin"); }
}
public string langPass
{
get { return _langPass; }
set { _langPass = value; OnPropertyChanged("langPass"); }
}
public event PropertyChangedEventHandler PropertyChanged;

protected void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}

public Main()
{

AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
System.Net.ServicePointManager.Expect100Continue = false;
InitializeComponent();
this.DataContext = this;
ReadSettings();
cmd = new Arguments(Environment.GetCommandLineArgs());
if (cmd["collect"] != null)
Expand Down Expand Up @@ -97,13 +119,13 @@ public void checkVersion()
{
if (skipCheck)
{
Dispatcher.BeginInvoke(new ThreadStart(delegate { error.Text = "можно играть"; butt.IsEnabled = true; }));
Dispatcher.BeginInvoke(new ThreadStart(delegate { error.Text = Servers.getTrans("letsplay"); butt.IsEnabled = true; }));
return;
}
try
{
PostSubmitter post;
Dispatcher.BeginInvoke(new ThreadStart(delegate { error.Text = "Проверяем клиент"; }));
Dispatcher.BeginInvoke(new ThreadStart(delegate { error.Text = Servers.getTrans("checking"); }));
if (!Directory.Exists(ClientDirectory))
{
Directory.CreateDirectory(ClientDirectory);
Expand All @@ -120,7 +142,7 @@ public void checkVersion()
}
}
catch (Exception e) { }
Dispatcher.BeginInvoke(new ThreadStart(delegate { error.Text = "Проверяем клиент"; }));
Dispatcher.BeginInvoke(new ThreadStart(delegate { error.Text = Servers.getTrans("checking"); }));
string chksum = string.Empty;
bool needDownload = false;
if (File.Exists(System.IO.Path.Combine(ClientDirectory, "client.swf")))
Expand All @@ -140,11 +162,11 @@ public void checkVersion()
}
if (needDownload)
{
Dispatcher.BeginInvoke(new ThreadStart(delegate { error.Text = "Скачиваем.."; }));
Dispatcher.BeginInvoke(new ThreadStart(delegate { error.Text = Servers.getTrans("downloading"); }));
byte[] client = DownloadFile("https://sirris.tsomaps.com/client.swf");
File.WriteAllBytes(System.IO.Path.Combine(ClientDirectory, "client.swf"), client);
}
Dispatcher.BeginInvoke(new ThreadStart(delegate { error.Text = "можно играть"; butt.IsEnabled = true; }));
Dispatcher.BeginInvoke(new ThreadStart(delegate { error.Text = Servers.getTrans("letsplay"); butt.IsEnabled = true; }));
return;
} catch (Exception e)
{
Expand Down Expand Up @@ -182,7 +204,7 @@ public byte[] DownloadFile(string remoteFilename)
Buffer.BlockCopy(buffer, 0, Buf, 0, bytesRead);
resultArray.AddRange(Buf);
bytesProcessed += bytesRead;
Dispatcher.BeginInvoke(new ThreadStart(delegate { error.Text = string.Format("Скачиваем.. {0}%", (100 * bytesProcessed / bytesTotal).ToString()); }));
Dispatcher.BeginInvoke(new ThreadStart(delegate { error.Text = string.Format(Servers.getTrans("downloading") + " {0}%", (100 * bytesProcessed / bytesTotal).ToString()); }));
} while (bytesRead > 0);
}
}
Expand Down Expand Up @@ -256,7 +278,7 @@ private void butt_Click(object sender, RoutedEventArgs e)

private void password_MouseDown(object sender, MouseButtonEventArgs e)
{
if((sender as TextBox).Text == "Электронный адрес" || (sender as TextBox).Text == "Пароль")
if((sender as TextBox).Text == Servers.getTrans("login") || (sender as TextBox).Text == Servers.getTrans("password"))
{
(sender as TextBox).Text = "";
}
Expand All @@ -265,16 +287,16 @@ private void password_MouseDown(object sender, MouseButtonEventArgs e)

private void login_LostFocus(object sender, RoutedEventArgs e)
{
if ((sender as TextBox).Text == "") (sender as TextBox).Text = "Электронный адрес";
if ((sender as TextBox).Text == "") (sender as TextBox).Text = Servers.getTrans("login");
}

private void butt_Click_1(object sender, RoutedEventArgs e)
{
string error_msg = string.Empty;
if (string.IsNullOrEmpty(login.Text.Trim()) || login.Text.Trim() == "Электронный адрес") error_msg = "Логин пуст.";
if (string.IsNullOrEmpty(password.Password.Trim()) || password.Password.Trim() == "Пароль")
if (string.IsNullOrEmpty(login.Text.Trim()) || login.Text.Trim() == Servers.getTrans("login")) error_msg = Servers.getTrans("emptylogin");
if (string.IsNullOrEmpty(password.Password.Trim()) || password.Password.Trim() == Servers.getTrans("password"))
{
if (string.IsNullOrEmpty(error_msg)) error_msg = "Пароль пуст.";
if (string.IsNullOrEmpty(error_msg)) error_msg = Servers.getTrans("emptypass");
}
if (!string.IsNullOrEmpty(error_msg))
{
Expand All @@ -295,7 +317,7 @@ private void butt_Click_1(object sender, RoutedEventArgs e)
bool collections = false;
if (!auto)
{
MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show(" Использовать подсветку коллекций?\nНажимайте \"да\" только если у вас запущен UbiCollect.exe!", "Подсветка", System.Windows.MessageBoxButton.YesNo);
MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show(" " + Servers.getTrans("collecttip"), Servers.getTrans("collect"), System.Windows.MessageBoxButton.YesNo);
if (messageBoxResult == MessageBoxResult.Yes)
{
collections = true;
Expand Down Expand Up @@ -357,7 +379,7 @@ private void password_GotFocus(object sender, RoutedEventArgs e)

private void login_GotFocus(object sender, RoutedEventArgs e)
{
if ((sender as TextBox).Text == "Электронный адрес" || (sender as TextBox).Text == "Пароль")
if ((sender as TextBox).Text == Servers.getTrans("login") || (sender as TextBox).Text == Servers.getTrans("password"))
{
(sender as TextBox).Text = "";
}
Expand All @@ -376,6 +398,26 @@ private void Region_list_SelectionChanged(object sender, SelectionChangedEventAr
{
_region = ((sender as ComboBox).SelectedItem as ComboBoxItem).Tag.ToString();
_regionUid = int.Parse(((sender as ComboBox).SelectedItem as ComboBoxItem).Uid);
if (_regionUid != 16)
{
mainback.ImageSource = Convert(Properties.Resources.back_en);
} else
{
mainback.ImageSource = Convert(Properties.Resources.back);
}
langLogin = Servers.getTrans("login");
langPass = Servers.getTrans("password");
}
public static BitmapImage Convert(Bitmap src)
{
MemoryStream ms = new MemoryStream();
((System.Drawing.Bitmap)src).Save(ms, System.Drawing.Imaging.ImageFormat.Png);
BitmapImage image = new BitmapImage();
image.BeginInit();
ms.Seek(0, SeekOrigin.Begin);
image.StreamSource = ms;
image.EndInit();
return image;
}
}
}
40 changes: 40 additions & 0 deletions client/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions client/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,19 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="back" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\files\back.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="back_en" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\files\back_en.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="content" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\files\content.zip;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="login" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\files\login.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="login_en" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\files\login_en.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Loading

0 comments on commit 59326d7

Please sign in to comment.