Merge remote-tracking branch 'origin/setupBranch' into setupBranch
This commit is contained in:
@@ -18,7 +18,7 @@ namespace Client.Views
|
||||
/// </summary>
|
||||
public partial class GameWindow : Window
|
||||
{
|
||||
|
||||
ClientData data = ClientData.Instance;
|
||||
public GameWindow()
|
||||
{
|
||||
DataContext = new ViewModelGame();
|
||||
@@ -110,7 +110,7 @@ namespace Client.Views
|
||||
*/
|
||||
private void WriteToChat(string message)
|
||||
{
|
||||
string user = "Monkey";
|
||||
string user = data.User.Username;
|
||||
SentMessage.AppendText($"{user}: {message}\n");
|
||||
}
|
||||
}
|
||||
|
||||
29
Client/Views/LoginScreen.xaml
Normal file
29
Client/Views/LoginScreen.xaml
Normal file
@@ -0,0 +1,29 @@
|
||||
<Window x:Class="Client.Views.LoginScreen"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Client.Views"
|
||||
mc:Ignorable="d"
|
||||
Title="LoginScreen" Height="450" Width="800">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="60"/>
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition Height="30"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Label Grid.Row="0" FontSize="40" Content="Welcome to Scrubl.io"/>
|
||||
<Label Grid.Row="1" FontSize="30" Content="Enter a username:"/>
|
||||
<Label Grid.Row="2" FontSize="15" Content="(max amount of characters for the username is 10)"/>
|
||||
|
||||
<TextBox Name="usernameTextbox" Grid.Row="1" Grid.Column="1" MaxLength="10" FontSize="30" VerticalAlignment="Center" HorizontalAlignment="Left" Width="250"/>
|
||||
<Button Content="ENTER" Grid.Column="1" Grid.Row="1" VerticalAlignment="Center" HorizontalAlignment="Right" Width="100" Height="40" Click="Button_EnterUsername"/>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
45
Client/Views/LoginScreen.xaml.cs
Normal file
45
Client/Views/LoginScreen.xaml.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using SharedClientServer;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Client.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for LoginScreen.xaml
|
||||
/// </summary>
|
||||
public partial class LoginScreen : Window
|
||||
{
|
||||
ClientData data = ClientData.Instance;
|
||||
public LoginScreen()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Button_EnterUsername(object sender, RoutedEventArgs e)
|
||||
{
|
||||
User user = new User(usernameTextbox.Text);
|
||||
Client client = new Client(user.Username);
|
||||
client.OnSuccessfullConnect = () =>
|
||||
{
|
||||
// because we need to start the main window on a UI thread, we need to let the dispatcher handle it, which will execute the code on the ui thread
|
||||
Application.Current.Dispatcher.Invoke(delegate {
|
||||
data.User = user;
|
||||
data.Client = client;
|
||||
MainWindow startWindow = new MainWindow();
|
||||
startWindow.Show();
|
||||
this.Close();
|
||||
});
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition/>
|
||||
@@ -34,9 +34,8 @@
|
||||
<Label Grid.Row="0" Content="This client information:" FontSize="17"/>
|
||||
|
||||
<Label Grid.Row="1" Grid.Column="0" Content="Your username:" FontSize="15" VerticalAlignment="Center"/>
|
||||
<TextBox Name="usernameTextbox" Grid.Row="1" Grid.Column="1" MaxLength="10" FontSize="15" VerticalAlignment="Center"/>
|
||||
|
||||
<Label Grid.Row="2" Grid.Column="0" Content="Which color you want to be:" FontSize="15" VerticalAlignment="Center"/>
|
||||
<Label Grid.Row="2" Grid.Column="0" Content="Select your color:" FontSize="15" VerticalAlignment="Center"/>
|
||||
<ComboBox Name="colorSelection" Grid.Row="2" Grid.Column="1" VerticalAlignment="Center" FontSize="15">
|
||||
<ComboBoxItem Content="BLUE"/>
|
||||
<ComboBoxItem Content="RED"/>
|
||||
@@ -48,11 +47,12 @@
|
||||
</ComboBox>
|
||||
|
||||
<Label Grid.Row="3" Name="testLabel" FontSize="15" VerticalAlignment="Center"/>
|
||||
<Label Name="usernameLabel" Content="place username here" Grid.Column="1" HorizontalAlignment="Center" Margin="0,12,0,0" VerticalAlignment="Top" Grid.Row="1"/>
|
||||
|
||||
</Grid>
|
||||
|
||||
|
||||
<ListView Name="LobbyList" Grid.Row="1" Grid.Column="0" Margin="10, 10, 10, 10" ItemsSource="{Binding Path=Lobbies}">
|
||||
<ListView Name="LobbyList" Grid.Row="1" Grid.Column="0" SelectedItem="{Binding SelectedLobby}" Margin="10, 10, 10, 10" ItemsSource="{Binding Path=Lobbies}">
|
||||
<ListView.View>
|
||||
<GridView x:Name="grdList">
|
||||
<GridViewColumn Header="Lobby ID" DisplayMemberBinding="{Binding ID}" Width="70"/>
|
||||
@@ -67,8 +67,8 @@
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition Height="50"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Button Name="joinButton" Grid.Row="0" Content="join a selected lobby" Click="Button_Click" Width="200" Height="40" HorizontalAlignment="Left" Margin="10, 0, 0, 0"/>
|
||||
<Button Name="hostButton" Grid.Row="1" Content="host a new lobby" Command="{Binding ...}" Width="200" Height="40" HorizontalAlignment="left" Margin="10, 0, 0, 0"/>
|
||||
<Button Name="joinButton" Grid.Row="0" Content="join a selected lobby" Command="{Binding JoinSelectedLobby}" IsEnabled="{Binding Model.CanStartGame}" Width="200" Height="40" HorizontalAlignment="Left" Margin="10, 0, 0, 0"/>
|
||||
<Button Name="hostButton" Grid.Row="1" Content="host a new lobby" Command="{Binding OnHostButtonClick}" IsEnabled="{Binding Model.CanStartGame}" Width="200" Height="40" HorizontalAlignment="left" Margin="10, 0, 0, 0"/>
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
|
||||
@@ -21,9 +21,13 @@ namespace Client
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
ClientData data = ClientData.Instance;
|
||||
public MainWindow()
|
||||
{
|
||||
this.DataContext = new ViewModel();
|
||||
InitializeComponent();
|
||||
|
||||
usernameLabel.Content = data.User.Username;
|
||||
}
|
||||
|
||||
private void Button_Click(object sender, RoutedEventArgs e)
|
||||
@@ -33,13 +37,13 @@ namespace Client
|
||||
if(lobbySelected != null)
|
||||
{
|
||||
testLabel.Content = lobbySelected.ID;
|
||||
usernameTextbox.IsEnabled = false;
|
||||
colorSelection.IsEnabled = false;
|
||||
joinButton.IsEnabled = false;
|
||||
hostButton.IsEnabled = false;
|
||||
|
||||
GameWindow window = new GameWindow();
|
||||
window.Show();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user