- May 24, 2020
- 160
- 79
Hey there everyone,
A few months ago, I made a cardgame with the provided framework:
Today, I tried to expand the cardgame only to be met with bad news:
Whenever you try to start a doubleclick event, the click event always happens first.
I tried to find solutions online and tinkered 2 hours with it to no avail.
Thanks in advance.
Below is a more detailled explanation of the problem:
To illustrate the problem, I altered the klondike.rpy, by adding a Hello World notification on the click event.
Now, whenever you try to double-click something, you can see, that it still runs the click event first, before the doubleclick event.
The most likely solution would be to alter something in the cardgame.rpy. In the def event(self, ev, x, y, st): section ( especially in the click portion of that event):
But I'm nowhere close to find a functional solution, let alone an elegant one.
Thanks again in advance.
A few months ago, I made a cardgame with the provided framework:
You must be registered to see the links
Today, I tried to expand the cardgame only to be met with bad news:
Whenever you try to start a doubleclick event, the click event always happens first.
I tried to find solutions online and tinkered 2 hours with it to no avail.
Thanks in advance.
Below is a more detailled explanation of the problem:
To illustrate the problem, I altered the klondike.rpy, by adding a Hello World notification on the click event.
Python:
def interact(self):
evt = ui.interact()
rv = False
# Check the various events, and dispatch them to the methods
# that handle them.
if evt.type == "drag":
if evt.drop_stack in self.tableau:
rv = self.tableau_drag(evt)
elif evt.drop_stack in self.foundations:
rv = self.foundation_drag(evt)
elif evt.type == "click":
renpy.notify("HELLO WORLD")
if evt.stack == self.stock:
rv = self.stock_click(evt)
elif evt.type == "doubleclick":
if (evt.stack in self.tableau) or (evt.stack is self.waste):
rv = self.tableau_doubleclick(evt)
# Ensure that the bottom card in each tableau is faceup.
for i in range(0, 7):
if self.tableau[i]:
self.table.set_faceup(self.tableau[i][-1], True)
# Check to see if any of the foundations has less than
# 13 cards in it. If it does, return False. Otherwise,
# return True.
for i in self.foundations:
if len(i) != 13:
return rv
return "win"
Now, whenever you try to double-click something, you can see, that it still runs the click event first, before the doubleclick event.
The most likely solution would be to alter something in the cardgame.rpy. In the def event(self, ev, x, y, st): section ( especially in the click portion of that event):
Python:
if self.dragging:
if dststack is not None and self.drag_cards:
evt = CardEvent()
evt.type = "drag"
evt.table = self
evt.stack = self.click_stack
evt.card = self.click_card.value
evt.drag_cards = [c.value for c in self.drag_cards]
evt.drop_stack = dststack
if dstcard:
evt.drop_card = dstcard.value
evt.time = st
else:#Probably something below here has to be modified
if self.click_stack.click:
evt = CardEvent()
evt.type = "click"
evt.table = self
evt.stack = self.click_stack
if self.click_card:
evt.card = self.click_card.value
else:
evt.card = None
evt.time = st
if (evt.type == self.last_event.type
and evt.stack == self.last_event.stack
and evt.card == self.last_event.card
and evt.time < self.last_event.time + self.doubleclick):
evt.type = "doubleclick"
But I'm nowhere close to find a functional solution, let alone an elegant one.
Thanks again in advance.