Page 1 of 2

UI now recieves updates from EventBus

PostPosted: 02 Jul 2013, 23:34
by Max mtg
I have removed MyObservable class: Zones, Players and Cards are no longer expected to notify UI directly.
Instead when card/player state changes, the code in charge of that change must fire a matching GameEvent.
The code in sound system / UI / Log is in charge of processing this event and updating their views if needed.


This enables a unified interface to update observers, independent of the observers' nature, be it UI, remote client or just any special subsystem (like sound)


Please report problems, when these updates don't happen in a right time.

Re: UI now recieves updates from EventBus

PostPosted: 03 Jul 2013, 02:35
by friarsol
Quest pets don't appear until after I play my first land.

After attaching an equipment to a creature the attachment doesn't show until the next UI redraw.

Edit: Pump effects aren't redrawn at EOT when they wear off. And actually, the Pump effects don't redraw immediately on resolution either. And sometimes redraws before static abilities are applied. AI has a 0/0 Kird Ape on the Battlefield right now according to the UI. (It should be 1/2)

Edit2: GainControl effects don't redraw either side of the battlefield.

Re: UI now recieves updates from EventBus

PostPosted: 03 Jul 2013, 10:46
by Max mtg
The first three were fixed.
Expect GainControl in a while
It already works

Re: UI now recieves updates from EventBus

PostPosted: 03 Jul 2013, 11:53
by Agetian
Seems like GameEventZone.java is missing on SVN, not sure if it should go into this thread or not but it seems related to the latest UI updates in r22384/22385...

- Agetian

Re: UI now recieves updates from EventBus

PostPosted: 03 Jul 2013, 12:12
by Max mtg
Yes, that file was from the previous commit.
Added now.

Re: UI now recieves updates from EventBus

PostPosted: 03 Jul 2013, 12:38
by Agetian
r22388: By the way, in addition to my report of the attacker/blocker icon not appearing immediately, it seems like the relevant sound effect does not fire either (e.g. when the blocker is declared, the "blocker declared" sound does not fire and the blocker icon does not appear; when you hover the mouse over the blocker the icon appears).

- Agetian

Re: UI now recieves updates from EventBus

PostPosted: 03 Jul 2013, 16:31
by Agetian
r22388: I got a weird NPE related to match UI updates between matches (after I hit "Continue" in a booster draft match between duels), after which cards stopped updating correctly (e.g. I could tap the card and it won't show as tapped until I move my mouse a bit). Sadly, I missed the NPE copy-and-paste to forum button because I overpushed the Enter key, but here's the starting part of the exception report from the Java console output:

EDT > java.lang.NullPointerException
at forge.gui.match.CMatchUI.updateCards(CMatchUI.java:344)
at forge.control.FControlGameEventHandler$9.run(FControlGameEventHandler.java:247)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)

- Agetian

Re: UI now recieves updates from EventBus

PostPosted: 03 Jul 2013, 18:13
by Max mtg
The output from console is enough to add a null check to a related location.

Events generated by UI classes (that partial blocks) are to be routed by a different event bus, I'll implement it in a while. These event are not intended to be sent outside of client.

Re: UI now recieves updates from EventBus

PostPosted: 03 Jul 2013, 19:01
by Agetian
Max mtg wrote:Events generated by UI classes (that partial blocks) are to be routed by a different event bus, I'll implement it in a while. These event are not intended to be sent outside of client.
Oh, OK, gotcha!

r22390: This seems like a UI update issue. When the AI is using Koth of the Hammer to turn a mountain into a 4/4 creature which is still a land, the land will seem not to change back into a normal land after the turn ends (it still appears among creatures and still shows as 4/4). At first I thought it's a rule-breaking issue but when I hovered the mouse over the land I realized it wasn't a 4/4 creature anymore, it just appeared as one on the battlefield (but the card detail box showed it as a normal mountain after the turn ended). A simple test case:

Code: Select all
AICardsInPlay=Mountain; Mountain; Koth of the Hammer
AICardsInHand=Raging Goblin
ActivePlayer=AI
ActivePhase=Main1
- Agetian

Re: UI now recieves updates from EventBus

PostPosted: 04 Jul 2013, 17:40
by friarsol
Redraw before static abilities is still happening for me. AI has two 1/1 tokens in play and two Intangible Virtues, but the UI shows them as 1/1 instead of 3/3.

Re: UI now recieves updates from EventBus

PostPosted: 04 Jul 2013, 19:02
by Max mtg
Sol, I just wanted to ask how these work. From what I've seen it turns out that every time static abilities are checked, for all cards any continous static effects are removed and then applied again.

Am I right about that?
If so, that would turn into lots of unneccesary updates - tolerable in local game but quite traffic-generating for network mode.

Re: UI now recieves updates from EventBus

PostPosted: 04 Jul 2013, 19:37
by friarsol
Max mtg wrote:Sol, I just wanted to ask how these work. From what I've seen it turns out that every time static abilities are checked, for all cards any continous static effects are removed and then applied again.

Am I right about that?
If so, that would turn into lots of unneccesary updates - tolerable in local game but quite traffic-generating for network mode.
I didn't write static abilities, but as far as I'm aware that's right. Could we record the state of the UI before all static abilites are checked, and then afterwards redraw if it's different?

Another UI redraw issue when undoing/canceling a spell, lands do not untap.

Re: UI now recieves updates from EventBus

PostPosted: 04 Jul 2013, 20:20
by Sloth
Max mtg wrote:Sol, I just wanted to ask how these work. From what I've seen it turns out that every time static abilities are checked, for all cards any continous static effects are removed and then applied again.

Am I right about that?
Yes.

Max mtg wrote:If so, that would turn into lots of unneccesary updates - tolerable in local game but quite traffic-generating for network mode.
What's wrong with updating everything whenever the player gets priority? That's a very safe approach.

Your UI updates from EventBus are way too prone for errors and require lots of calls all over the code. Please discuss changes like these before you commit them.

EDIT: Sorry that i'm a little bit pissed, but I was hoping for a release soon, but now the game is once again full of bugs.

Re: UI now recieves updates from EventBus

PostPosted: 05 Jul 2013, 02:29
by Max mtg
Sloth wrote:
Max mtg wrote:If so, that would turn into lots of unneccesary updates - tolerable in local game but quite traffic-generating for network mode.
What's wrong with updating everything whenever the player gets priority? That's a very safe approach.

Your UI updates from EventBus are way too prone for errors and require lots of calls all over the code. Please discuss changes like these before you commit them.

EDIT: Sorry that i'm a little bit pissed, but I was hoping for a release soon, but now the game is once again full of bugs.
Imagine we have remote observers, or even fully-involved into game players. The current way it works requires server to send client updated state of all cards every time player gets priority... and even more often - as soon as any subability is resolved.
There is no way to detect only the cards whose state has changed as a result of static abilities recalculation and update just theese cards.

Of course the UI updates require more calls because they are intended to be smarter than 'redraw all permanents when priority was gained'. Sure I can fire GameEventZone(mode=ComplexUpdate) to have the whole battlefield redrawn, but that'll be just as simple and resource-consuming as it was before.

Sloth, I appreciate you fix a lot of bugs including the ones remaining after my so called improvements.

The expected release date is in a week. I thought it's OK to implement features that could add bugs in the middle of a sprint.

Re: UI now recieves updates from EventBus

PostPosted: 05 Jul 2013, 03:55
by Agetian
Max mtg wrote:
Sloth wrote:
Max mtg wrote:The expected release date is in a week. I thought it's OK to implement features that could add bugs in the middle of a sprint.
By the way, speaking of bugs, I'd vote at least for the following issues to be fixed prior to the release even if it has to, sadly, push the release time back (otherwise we risk being flooded with reports about these):
- Cards not being redrawn in time (including untapped cards showing as tapped, cards that have changed their type still showing as old type, cards showing wrong P/T after it has changed, etc.)
- Game icons not being redrawn in time (including the attacker/blocker icons not being properly drawn upon declaration - this is especially tricky when combined with the fact that the relevant sound (e.g. blocker declared) does not fire - the block may be missed unless you're careful to go with the mouse over the board and "paint" the icons on blockers that way; with opponent's creatures with vigilance, the attack can also come in as unexpected if you're used to following visual cues whenever the opponent attacks or blocks your creatures).

Just my $0.02. Overall I like the idea with the event bus system though, I believe it's another important step towards network play. Hope the issues that come with it can be resolved within reasonable time frame so that the technology can stay in.

- Agetian