Ejemplo n.º 1
0
        public AnimationLayer(RootWidget rootWidget)
        {
            root = rootWidget;

            animQueue = new Queue<Animation>();
            playingCardWidgets = new Dictionary<int, PlayingCardWidget>();
            playerRoleWidgets = new Dictionary<int, RoleCardWidget>(8);
            playerCharacterWidgets = new Dictionary<int, CharacterCardWidget>(8);

            playingCardZoomWidget = new PlayingCardWidget();
            roleCardZoomWidget = new RoleCardWidget();
            characterCardZoomWidget = new CharacterCardWidget();

            playingCardZoomWidget.OnLClick += (w) => UnsetCardZoomWidget();
            playingCardZoomWidget.OnRClick += (w) => UnsetCardZoomWidget();
            roleCardZoomWidget.OnLClick += (w) => UnsetCardZoomWidget();
            roleCardZoomWidget.OnRClick += (w) => UnsetCardZoomWidget();
            characterCardZoomWidget.OnLClick += (w) => UnsetCardZoomWidget();
            characterCardZoomWidget.OnRClick += (w) => UnsetCardZoomWidget();

            timerThread = new Thread(RunTimer);
            timerThread.IsBackground = true;
            timerThread.Start();

            listener = new EventListener(this);
            ConnectionManager.SessionEventListener.AddListener((IPlayerSessionEventListener)listener);
            ConnectionManager.SessionEventListener.AddListener((ISpectatorSessionEventListener)listener);
            ConnectionManager.OnSessionDisconnected += () => {
                Gdk.Threads.Enter();
                Clear();
                Gdk.Threads.Leave();
            };
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Gets the playing card widget with the specified ID.
 /// </summary>
 /// <returns>
 /// The playing card widget with the specified ID.
 /// </returns>
 /// <param name="cardId">
 /// The card ID.
 /// </param>
 public PlayingCardWidget GetPlayingCardWidget(int cardId)
 {
     try
     {
         return playingCardWidgets[cardId];
     }
     catch(KeyNotFoundException)
     {
         playingCardWidgets[cardId] = new PlayingCardWidget(cardId);
         playingCardWidgets[cardId].OnLClick += (w) => {
             PlayingCardWidget playingCardWidget = (PlayingCardWidget)w;
             System.Threading.ThreadPool.QueueUserWorkItem((state) => {
                 IPlayerControl control = ConnectionManager.PlayerGameControl;
                 if(control == null)
                     return;
                 try
                 {
                     control.RespondCard(cardId);
                     Gdk.Threads.Enter();
                     root.SetResponseType(string.Format(Catalog.GetString("Card #{0}"), playingCardWidget.ID));
                 }
                 catch(GameException e)
                 {
                     Gdk.Threads.Enter();
                     root.SetResponseType(string.Format(Catalog.GetString("Card #{0}"), playingCardWidget.ID), e);
                 }
                 RequestRedraw();
                 Gdk.Threads.Leave();
             });
         };
         playingCardWidgets[cardId].OnRClick += (w) => SetCardZoomWidget((PlayingCardWidget)w);
         return playingCardWidgets[cardId];
     }
 }
Ejemplo n.º 3
0
        public void SetCardZoomWidget(PlayingCardWidget cardWidget)
        {
            lock(animLock)
            {
                if(cardZoomWidgetSet)
                    return;

                playingCardZoomWidget.Update(cardWidget);
                cardZoomWidgetSet = true;

                if(animQueue.Count == 0)
                {
                    Animation anim = new Animation(this, current, new TimeSpan(0, 0, 0, 0, 500));
                    anim.EndAllocManager.SetPlayingCardZoomVisible(true);
                    EnqueueAnimation(anim);
                }
                else
                {
                    bool first = true;
                    foreach(Animation anim in animQueue)
                    {
                        if(first)
                            first = false;
                        else
                            anim.StartAllocManager.SetPlayingCardZoomVisible(true);
                        anim.EndAllocManager.SetPlayingCardZoomVisible(true);
                    }
                }
            }
        }
Ejemplo n.º 4
0
 public void Update(PlayingCardWidget other)
 {
     id = 0;
     type = other.type;
     rank = other.rank;
     suit = other.suit;
     Card = other.Card;
     UpdateMarkup();
 }