It is currently 22 May 2025, 20:20
   
Text Size

UI now recieves updates from EventBus

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

UI now recieves updates from EventBus

Postby Max mtg » 02 Jul 2013, 23:34

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.
Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times

Re: UI now recieves updates from EventBus

Postby friarsol » 03 Jul 2013, 02:35

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.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: UI now recieves updates from EventBus

Postby Max mtg » 03 Jul 2013, 10:46

The first three were fixed.
Expect GainControl in a while
It already works
Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times

Re: UI now recieves updates from EventBus

Postby Agetian » 03 Jul 2013, 11:53

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
Agetian
Programmer
 
Posts: 3486
Joined: 14 Mar 2011, 05:58
Has thanked: 683 times
Been thanked: 569 times

Re: UI now recieves updates from EventBus

Postby Max mtg » 03 Jul 2013, 12:12

Yes, that file was from the previous commit.
Added now.
Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times

Re: UI now recieves updates from EventBus

Postby Agetian » 03 Jul 2013, 12:38

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
Last edited by Agetian on 03 Jul 2013, 16:31, edited 1 time in total.
Agetian
Programmer
 
Posts: 3486
Joined: 14 Mar 2011, 05:58
Has thanked: 683 times
Been thanked: 569 times

Re: UI now recieves updates from EventBus

Postby Agetian » 03 Jul 2013, 16:31

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
Agetian
Programmer
 
Posts: 3486
Joined: 14 Mar 2011, 05:58
Has thanked: 683 times
Been thanked: 569 times

Re: UI now recieves updates from EventBus

Postby Max mtg » 03 Jul 2013, 18:13

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.
Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times

Re: UI now recieves updates from EventBus

Postby Agetian » 03 Jul 2013, 19:01

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
Agetian
Programmer
 
Posts: 3486
Joined: 14 Mar 2011, 05:58
Has thanked: 683 times
Been thanked: 569 times

Re: UI now recieves updates from EventBus

Postby friarsol » 04 Jul 2013, 17:40

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.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: UI now recieves updates from EventBus

Postby Max mtg » 04 Jul 2013, 19:02

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.
Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times

Re: UI now recieves updates from EventBus

Postby friarsol » 04 Jul 2013, 19:37

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.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: UI now recieves updates from EventBus

Postby Sloth » 04 Jul 2013, 20:20

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.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: UI now recieves updates from EventBus

Postby Max mtg » 05 Jul 2013, 02:29

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.
Single class for single responsibility.
Max mtg
Programmer
 
Posts: 1997
Joined: 02 Jul 2011, 14:26
Has thanked: 173 times
Been thanked: 334 times

Re: UI now recieves updates from EventBus

Postby Agetian » 05 Jul 2013, 03:55

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
Agetian
Programmer
 
Posts: 3486
Joined: 14 Mar 2011, 05:58
Has thanked: 683 times
Been thanked: 569 times

Next

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 19 guests


Who is online

In total there are 19 users online :: 0 registered, 0 hidden and 19 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 19 guests

Login Form