Skip to content

Commit

Permalink
More visuals for combined play windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
kellyelton committed May 22, 2014
1 parent e8a5842 commit 92b3bfe
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 17 deletions.
43 changes: 41 additions & 2 deletions octgnFX/Octgn/Tabs/Matchmaking/ChooseGameType.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,49 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:matchmaking="clr-namespace:Octgn.Tabs.Matchmaking"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300" x:Name="Me">
<Grid Background="#33333333">

<Grid.RowDefinitions>
<RowDefinition Height="0"/>
<RowDefinition Height="100*"/>
</Grid.RowDefinitions>
<ListBox
Grid.Row="1"
ItemsSource="{Binding Path=GameTypeList}"
Style="{StaticResource WrapListBoxStyle}"
x:Name="GameModesListBox"
Background="Transparent" HorizontalAlignment="Center" VerticalAlignment="Center"
>
<ListBox.Resources>
<Style TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItemNoMarginStyle}">
<!--<Setter Property="Visibility" Value="{Binding IsVisible,Converter={StaticResource BooleanToVisibilityConverter}}"/>-->
<Setter Property="Focusable" Value="True"/>
<Setter Property="Margin" Value="5"/>
</Style>
</ListBox.Resources>
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type matchmaking:GameType}">
<Border Padding="10" Cursor="Hand" PreviewMouseUp="OnGameTypeMouseUp">
<Grid DataContext="{Binding}" x:Name="ItemGrid" Width="200" VerticalAlignment="Stretch" Height="200" HorizontalAlignment="Left" Background="#01000000">
<Grid.RowDefinitions>
<RowDefinition x:Name="row1" Height="1*"/>
<RowDefinition Height="Auto"/>
<RowDefinition x:Name="row3" Height="0"/>
</Grid.RowDefinitions>
<Border Grid.Row="1" Style="{StaticResource DarkPanel}">
<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding Path=Name}">
</TextBlock>
</Border>
<Image Source="{Binding Icon}" HorizontalAlignment="Center" Grid.RowSpan="3" IsHitTestVisible="False" Focusable="False" Canvas.ZIndex="-1" Stretch="Fill"/>
</Grid >
</Border>
</DataTemplate>
</ListBox.ItemTemplate>

</ListBox>
</Grid>

</UserControl>
35 changes: 20 additions & 15 deletions octgnFX/Octgn/Tabs/Matchmaking/ChooseGameType.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Reflection;
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.Navigation;
using System.Windows.Shapes;
using log4net;

namespace Octgn.Tabs.Matchmaking
{
/// <summary>
/// Interaction logic for ChooseGameType.xaml
/// </summary>
public partial class ChooseGameType : UserControl
public partial class ChooseGameType
{
internal static ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public List<GameType> GameTypeList { get; set; }

public ChooseGameType()
{
InitializeComponent();
}

private void OnGameTypeMouseUp(object sender, MouseButtonEventArgs e)
{
Log.Info("Clicked on game type");
var fe = sender as FrameworkElement;
if (fe == null)
return;
var gameType = fe.DataContext as GameType;
if (gameType == null)
return;
var vm = DataContext as MatchmakingTabViewModel;
vm.PickGameType(gameType);
}
}
}
31 changes: 31 additions & 0 deletions octgnFX/Octgn/Tabs/Matchmaking/MatchmakingTabViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net;
Expand Down Expand Up @@ -131,9 +132,25 @@ public Game Game

public ObservableCollection<GameMode> GameModes { get; set; }

public List<GameType> GameTypeList { get; set; }

public MatchmakingTabViewModel(Dispatcher dispatcher)
{
Log.Info("Creating matchmaking view.");
GameTypeList = new List<GameType>();
var g1 = new GameType();
var g2 = new GameType();
var g3 = new GameType();
g1.Name = "Matchmaking";
g1.Icon = "pack://application:,,,/OCTGN;component/Resources/matchmaking-icon.png";
g2.Name = "Custom Games";
g2.Icon = "pack://application:,,,/OCTGN;component/Resources/custom-games-icon.png";
g3.Name = "Spectating";
g3.Icon = "pack://application:,,,/OCTGN;component/Resources/spectator-icon.png";

GameTypeList.Add(g1);
GameTypeList.Add(g2);
GameTypeList.Add(g3);
GameModes = new ObservableCollection<GameMode>();
_dispatcher = dispatcher;
_timer = new Timer(1000);
Expand Down Expand Up @@ -207,6 +224,15 @@ public void PickGameMode(GameMode g)
}
}

public void PickGameType(GameType g)
{
if (g == null)
{
Log.Warn("Tried to pick null game type?");
return;
}
}

public void DoStartMatchmaking()
{
Log.Info("Starting matchmaking...");
Expand Down Expand Up @@ -391,4 +417,9 @@ public void Dispose()
_timer.Dispose();
}
}
public class GameType
{
public string Name { get; set; }
public string Icon { get; set; }
}
}

0 comments on commit 92b3bfe

Please sign in to comment.