public void Initialize() { try { double aspectRatio = Math.Round((double)ClientGameEngine.Get().ClientDimensions.Width / (double)ClientGameEngine.Get().ClientDimensions.Height, 2, MidpointRounding.AwayFromZero); string UIComponentPath = "resources\\UI\\PreGameLobby\\"; string ratioPath = string.Empty; if (aspectRatio == 1.33) ratioPath = "4x3\\"; else ratioPath = "16x9\\"; //background BitmapImage bitmapImage = new BitmapImage(); bitmapImage = new BitmapImage(new Uri(UIComponentPath + ratioPath + "Background.png", UriKind.RelativeOrAbsolute)); m_BackgroundBrush = new ImageBrush(bitmapImage); ClientGameEngine.Get().AllPlayersReady.ValueChanged += (from, to) => { if (to) { Action action = () => { m_StartEnabledImage.Visibility = Visibility.Visible; m_StartEnabledImage.IsEnabled = true; m_StartDisabledImage.Visibility = Visibility.Hidden; }; ClientGameEngine.Get().ExecuteOnUIThread(action); } else { Action action = () => { m_StartDisabledImage.Visibility = Visibility.Visible; m_StartEnabledImage.IsEnabled = false; m_StartEnabledImage.Visibility = Visibility.Hidden; }; ClientGameEngine.Get().ExecuteOnUIThread(action); } }; //Chat Text Box m_ChatMessageBox = new TextBox(); m_ChatMessageBox.Opacity = 0.75; m_ChatMessageBox.FontFamily = new FontFamily("Papyrus"); m_ChatMessageBox.FontSize = 18; m_ChatMessageBox.KeyDown += (s, ev) => { if (ev.Key == Key.Enter) { if (m_ChatMessageBox.Text.Trim() != string.Empty) { GameChatMessage chat = new GameChatMessage() { Contents = m_ChatMessageBox.Text.Trim() }; m_ChatMessageBox.Text = ""; ClientGameEngine.Get().SendMessageToServer(chat); } } }; //Chat Message OK m_SendButton = new Button(); m_SendButton.FontFamily = new FontFamily("Papyrus"); m_SendButton.FontSize = 18; m_SendButton.Content = "Send"; m_SendButton.Click += (s, ev) => { if (m_ChatMessageBox.Text.Trim() != string.Empty) { GameChatMessage chat = new GameChatMessage() { Contents = m_ChatMessageBox.Text.Trim() }; m_ChatMessageBox.Text = ""; ClientGameEngine.Get().SendMessageToServer(chat); } }; //Chat messages m_ChatMessagesListBox = new ListBox(); m_ChatMessagesListBox.ItemsSource = ClientGameEngine.Get().ChatMessageCollection; m_ChatMessagesListBox.Opacity = 0.75; m_ChatMessagesListBox.FontFamily = new FontFamily("Papyrus"); m_ChatMessagesListBox.FontSize = 14; ClientGameEngine.Get().ChatMessageCollection.CollectionChanged += (s, ev) => { if (ev.NewItems != null) { m_ChatMessagesListBox.ScrollIntoView(ev.NewItems[0]); } }; //StartEnabled bitmapImage = new BitmapImage(new Uri(UIComponentPath + "Start.png", UriKind.RelativeOrAbsolute)); m_StartEnabledImage = new Image(); m_StartEnabledImage.Source = bitmapImage; m_StartEnabledImage.Width = bitmapImage.PixelWidth; m_StartEnabledImage.Height = bitmapImage.PixelHeight; m_StartEnabledImage.Visibility = Visibility.Hidden; m_StartEnabledImage.IsEnabled = false; m_StartEnabledImage.Name = "StartEnabled"; m_StartEnabledImage.MouseEnter += MenuOptionHover; m_StartEnabledImage.MouseLeave += MenuOptionHoverLost; m_StartEnabledImage.MouseDown += MenuOptionMouseDown; m_StartEnabledImage.MouseUp += MenuOptionMouseUp; //StartDisabled bitmapImage = new BitmapImage(new Uri(UIComponentPath + "StartFade.png", UriKind.RelativeOrAbsolute)); m_StartDisabledImage = new Image(); m_StartDisabledImage.Source = bitmapImage; m_StartDisabledImage.Width = bitmapImage.PixelWidth; m_StartDisabledImage.Height = bitmapImage.PixelHeight; m_StartDisabledImage.Visibility = Visibility.Visible; m_StartDisabledImage.Name = "StartDisabled"; //m_StartDisabledImage.MouseEnter += MenuOptionHover; //m_StartDisabledImage.MouseLeave += MenuOptionHoverLost; //m_StartDisabledImage.MouseDown += MenuOptionMouseDown; //m_StartDisabledImage.MouseUp += MenuOptionMouseUp; //LeaveEnabled bitmapImage = new BitmapImage(new Uri(UIComponentPath + "Leave.png", UriKind.RelativeOrAbsolute)); m_LeaveEnabledImage = new Image(); m_LeaveEnabledImage.Source = bitmapImage; m_LeaveEnabledImage.Width = bitmapImage.PixelWidth; m_LeaveEnabledImage.Height = bitmapImage.PixelHeight; m_LeaveEnabledImage.Visibility = System.Windows.Visibility.Visible; m_LeaveEnabledImage.Name = "LeaveEnabled"; m_LeaveEnabledImage.MouseEnter += MenuOptionHover; m_LeaveEnabledImage.MouseLeave += MenuOptionHoverLost; m_LeaveEnabledImage.MouseDown += MenuOptionMouseDown; m_LeaveEnabledImage.MouseUp += MenuOptionMouseUp; //LeaveDisabled bitmapImage = new BitmapImage(new Uri(UIComponentPath + "LeaveFade.png", UriKind.RelativeOrAbsolute)); m_LeaveDisabledImage = new Image(); m_LeaveDisabledImage.Source = bitmapImage; m_LeaveDisabledImage.Width = bitmapImage.PixelWidth; m_LeaveDisabledImage.Height = bitmapImage.PixelHeight; m_LeaveDisabledImage.Visibility = System.Windows.Visibility.Hidden; m_LeaveDisabledImage.Name = "LeaveDisabled"; //m_LeaveDisabledImage.MouseEnter += MenuOptionHover; //m_LeaveDisabledImage.MouseLeave += MenuOptionHoverLost; //m_LeaveDisabledImage.MouseDown += MenuOptionMouseDown; //m_LeaveDisabledImage.MouseUp += MenuOptionMouseUp; //Ready bitmapImage = new BitmapImage(new Uri(UIComponentPath + "Ready.png", UriKind.RelativeOrAbsolute)); m_ReadyImage = new Image(); m_ReadyImage.Source = bitmapImage; m_ReadyImage.Width = bitmapImage.PixelWidth; m_ReadyImage.Height = bitmapImage.PixelHeight; m_ReadyImage.Visibility = System.Windows.Visibility.Hidden; m_ReadyImage.Name = "Ready"; m_ReadyImage.MouseEnter += MenuOptionHover; m_ReadyImage.MouseLeave += MenuOptionHoverLost; m_ReadyImage.MouseDown += MenuOptionMouseDown; m_ReadyImage.MouseUp += MenuOptionMouseUp; //NotReady bitmapImage = new BitmapImage(new Uri(UIComponentPath + "NotReady.png", UriKind.RelativeOrAbsolute)); m_NotReadyImage = new Image(); m_NotReadyImage.Source = bitmapImage; m_NotReadyImage.Width = bitmapImage.PixelWidth; m_NotReadyImage.Height = bitmapImage.PixelHeight; m_NotReadyImage.Visibility = System.Windows.Visibility.Hidden; m_NotReadyImage.Name = "NotReady"; m_NotReadyImage.MouseEnter += MenuOptionHover; m_NotReadyImage.MouseLeave += MenuOptionHoverLost; m_NotReadyImage.MouseDown += MenuOptionMouseDown; m_NotReadyImage.MouseUp += MenuOptionMouseUp; //Player list m_PlayerListView = new ListView(); m_PlayerListView.Opacity = 0.75; m_PlayerGridView = new GridView(); m_PlayerGridView.AllowsColumnReorder = false; m_ReadyColumn = new GridViewColumn(); m_ReadyColumn.DisplayMemberBinding = new Binding("IsReady"); m_ReadyColumn.Header = "Ready"; m_PlayerGridView.Columns.Add(m_ReadyColumn); m_NameColumn = new GridViewColumn(); m_NameColumn.DisplayMemberBinding = new Binding("Name"); m_NameColumn.Header = "Name"; m_PlayerGridView.Columns.Add(m_NameColumn); m_PlayerListView.View = m_PlayerGridView; m_PlayerListView.ItemsSource = ClientGameEngine.Get().PlayerCollection; // Chat messages m_ChatMessagesListBox.Opacity = 0.75; m_ChatMessagesListBox.FontFamily = new FontFamily("Papyrus"); m_ChatMessagesListBox.FontSize = 14; //Army selection buttons //Undead Army m_UndeadArmyButton = new Button(); m_UndeadArmyButton.FontFamily = new FontFamily("Papyrus"); m_UndeadArmyButton.FontSize = 18; m_UndeadArmyButton.Content = "Undead Army"; m_UndeadArmyButton.Click += (s, ev) => { m_CurrentArmyLabel.Content = "Undead Selected"; if (!m_NotReadyImage.IsVisible) { m_NotReadyImage.Visibility = Visibility.Hidden; m_ReadyImage.Visibility = Visibility.Visible; } m_PlayerReadyMessage.ArmyType = Framework.Unit.Army.ArmyTypeEnum.Undead; }; //Alliance Army m_AllianceArmyButton = new Button(); m_AllianceArmyButton.FontFamily = new FontFamily("Papyrus"); m_AllianceArmyButton.FontSize = 18; m_AllianceArmyButton.Content = "Alliance Army"; m_AllianceArmyButton.Click += (s, ev) => { m_CurrentArmyLabel.Content = "Alliance Selected"; if (!m_NotReadyImage.IsVisible) { m_NotReadyImage.Visibility = Visibility.Hidden; m_ReadyImage.Visibility = Visibility.Visible; } m_PlayerReadyMessage.ArmyType = Framework.Unit.Army.ArmyTypeEnum.Alliance; }; //Beast Army m_BeastArmyButton = new Button(); m_BeastArmyButton.FontFamily = new FontFamily("Papyrus"); m_BeastArmyButton.FontSize = 18; m_BeastArmyButton.Content = "Beast Army"; m_BeastArmyButton.Click += (s, ev) => { m_CurrentArmyLabel.Content = "Beasts Selected"; if (!m_NotReadyImage.IsVisible) { m_NotReadyImage.Visibility = Visibility.Hidden; m_ReadyImage.Visibility = Visibility.Visible; } m_PlayerReadyMessage.ArmyType = Framework.Unit.Army.ArmyTypeEnum.Beast; }; //Placeholder Army selected label m_CurrentArmyLabel = new Label(); m_CurrentArmyLabel.Content = "No Army Selected"; m_PlayerReadyMessage = new PlayerReadyMessage(); } catch (Exception ex) { throw ex; } }
public void Initialize() { InGameEngine.InGameEngine.Get(); //Chat Text Box m_ChatMessageBox = new TextBox(); m_ChatMessageBox.Opacity = 0.75; m_ChatMessageBox.FontFamily = new FontFamily("Papyrus"); m_ChatMessageBox.FontSize = 12; m_ChatMessageBox.KeyDown += (s, ev) => { if (ev.Key == Key.Enter) { if (m_ChatMessageBox.Text.Trim() != string.Empty) { GameChatMessage chat = new GameChatMessage() { Contents = m_ChatMessageBox.Text.Trim() }; m_ChatMessageBox.Text = ""; ClientGameEngine.Get().SendMessageToServer(chat); } } }; m_EndTurnButton = new Button { FontFamily = new FontFamily("Papyrus"), FontSize = 18, Content = "End Turn" }; m_EndTurnButton.Click += (s, ev) => { if (InGameEngine.InGameEngine.Get().MoveList.Count > 0) { ClientGameEngine.Get().SendMessageToServer((new EndMoveTurnMessage() { Moves = InGameEngine.InGameEngine.Get().MoveList })); } }; m_UITopImage = new Image(); BitmapImage bimg = new BitmapImage(new Uri(@"resources\UI\Game\TopBar.png", UriKind.RelativeOrAbsolute)); m_UITopImage.Source = bimg; m_UITopImage.Width = bimg.PixelWidth; m_UITopImage.Height = bimg.PixelHeight; m_UILeftImage = new Image(); bimg = new BitmapImage(new Uri(@"resources\UI\Game\LeftBar.png", UriKind.RelativeOrAbsolute)); m_UILeftImage.Source = bimg; m_UILeftImage.Width = bimg.PixelWidth; m_UILeftImage.Height = bimg.PixelHeight; m_UIRightImage = new Image(); bimg = new BitmapImage(new Uri(@"resources\UI\Game\RightBar.png", UriKind.RelativeOrAbsolute)); m_UIRightImage.Source = bimg; m_UIRightImage.Width = bimg.PixelWidth; m_UIRightImage.Height = bimg.PixelHeight; m_UIBottomImage = new Image(); bimg = new BitmapImage(new Uri(@"resources\UI\Game\BottomBar.png", UriKind.RelativeOrAbsolute)); m_UIBottomImage.Source = bimg; m_UIBottomImage.Width = bimg.PixelWidth; m_UIBottomImage.Height = bimg.PixelHeight; //Menu Button m_MenuButton = new Button(); m_MenuButton.FontFamily = new FontFamily("Papyrus"); m_MenuButton.FontSize = 18; m_MenuButton.Content = "Menu"; m_MenuButton.Click += (s, ev) => { }; //Chat messages m_ChatMessagesListBox = new ListBox(); m_ChatMessagesListBox.ItemsSource = ClientGameEngine.Get().ChatMessageCollection; m_ChatMessagesListBox.Opacity = 0.75; m_ChatMessagesListBox.FontFamily = new FontFamily("Papyrus"); m_ChatMessagesListBox.FontSize = 12; ClientGameEngine.Get().ChatMessageCollection.CollectionChanged += (s, ev) => { if (ev.NewItems != null) { m_ChatMessagesListBox.ScrollIntoView(ev.NewItems[0]); } }; //unit stats m_UnitStatsGroupBox = new GroupBox(); m_UnitStatsGroupBox.Opacity = 0.75; m_UnitStatsGroupBox.FontFamily = new FontFamily("Papyrus"); m_UnitStatsGroupBox.FontSize = 12; }