[GCI 2018] GCompris: Add keyboard controls support to Memory activities
ClosedPublic

Authored by turx on Dec 7 2018, 2:07 PM.

Diff Detail

Repository
R2 GCompris
Lint
Lint Skipped
Unit
Unit Tests Skipped
turx created this revision.Dec 7 2018, 2:07 PM
Restricted Application added a project: KDE Edu. · View Herald TranscriptDec 7 2018, 2:07 PM
Restricted Application added a subscriber: kde-edu. · View Herald Transcript
turx requested review of this revision.Dec 7 2018, 2:07 PM
turx updated this revision to Diff 47042.Dec 7 2018, 3:28 PM

Removed some unnecessary code.

jjazeix requested changes to this revision.EditedDec 8 2018, 9:30 AM
jjazeix added a subscriber: jjazeix.

Hi, thank you for the patch.
I see 4 issues:

  • there should be more spaces between the cards (and the last ones should not override with the menu bar)
  • when I select 2 cards with the mouse, I have the following error: qrc:/gcompris/src/activities/memory/memory.js:157: Error: Insufficient arguments

And I can't select cards anymore.

  • we should be able to select only 2 cars at same time, don't allow to turn cards when it's the opponent turn (like it's done with the mouse)
  • if you keep on the same card "Return" key pressed, at some point it will self validate the card with itself.
This revision now requires changes to proceed.Dec 8 2018, 9:30 AM
turx updated this revision to Diff 47101.Dec 8 2018, 1:13 PM

Bugs fixed.

  • Spaces between the cards
  • Eliminated possibility of the third selection
  • Eliminated possibility of self-validation

Thank you, the bugs are fixed.
There is still one: if you play a game with Tux (the icons have a 2 between the cards), there is the error: "qrc:/gcompris/src/activities/memory/memory.js:157: Error: Insufficient arguments" after I play (so when it's the computer turn)

jjazeix added inline comments.Dec 8 2018, 5:50 PM
src/activities/memory/MemoryCommon.qml
213

I don't understand this condition, can you help me understand what it does?

turx added inline comments.Dec 8 2018, 5:52 PM
src/activities/memory/MemoryCommon.qml
213

The program would skip the completed blocks in order to prevent selecting void not only applying.

jjazeix added inline comments.Dec 8 2018, 6:02 PM
src/activities/memory/MemoryCommon.qml
213

Thanks, can you add a comment in the code, telling it's to skip the highlight on the already found cards?

turx updated this revision to Diff 47140.Dec 8 2018, 6:18 PM
turx marked 3 inline comments as done.
  • Added a comment in the code, telling it's to skip the highlight on the already found cards
  • Failed to work out by fixing surface issues in memory.js
turx added inline comments.Dec 8 2018, 6:23 PM
src/activities/memory/memory.js
158

I changed the implementation here because there is only itemAt(x, y) in grid objects.
i % columns here represents x, while i / columns represents y.
But the program is failed to work with error qrc:/gcompris/src/activities/memory/memory.js:225: TypeError: Cannot call method 'selected' of undefined qrc:/gcompris/src/activities/memory/memory.js: 225 and I had no idea with it.
Could you please help me to figure it out a little?

jjazeix added inline comments.Dec 8 2018, 6:27 PM
src/activities/memory/memory.js
158

sure, I'll take a look in one hour

jjazeix added inline comments.Dec 8 2018, 7:44 PM
src/activities/memory/memory.js
158

var x = (i % columns) * items.grid.cellWidth + items.grid.anchors.margins
var y = (i / columns) * items.grid.cellHeight + items.grid.anchors.margins
items.grid.itemAt(x, y)

seems to be working (it has to be changed in getShownPair too at least).
However, I'm not sure on the exact culprit, but I've noticed the activity can freeze, if you keep pressing an arrow while you or Tux is winning a level :/. Not sure what can be the cause. Feel free to dig it, but if

turx marked 3 inline comments as done.Dec 9 2018, 2:49 AM
turx updated this revision to Diff 47161.Dec 9 2018, 2:55 AM
  • The activity can no longer freeze if you keep pressing an arrow while you or Tux is winning a level
  • Tux card position issue is fixed
jjazeix accepted this revision.Dec 9 2018, 9:54 AM
This revision is now accepted and ready to land.Dec 9 2018, 9:54 AM