|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- import arcade
- from gui_aux import *
- from desktop_Platform import *
-
- def desktop_createDesc(p):
- p.desc = arcade.Sprite()
- p.descSprites.append(p.desc)
- p.desc.texture = p.descTextures[0]
- # Position.
- pos = gui_aux_cellScreenPosition(p.c, p.c.descPosition)
- p.desc.left = pos[0]
- p.desc.top = pos[1]
- # Invisible by default.
- p.desc.visible = False
- #}
-
- def desktop_createDeselectedTiles(p):
- for (id, pos) in enumerate(p.c.tilePositions):
- tile = arcade.AnimatedTimeBasedSprite()
- p.deselectedTiles.append(tile)
- p.deselectedSprites.append(tile)
-
- tile.guid = id
- tile.texture = p.textures[0]
- # Animation between two textures.
- a1 = arcade.sprite.AnimationKeyframe(0, 700, p.textures[0])
- a2 = arcade.sprite.AnimationKeyframe(1, 700, p.textures[1])
- tile.frames.append(a1)
- tile.frames.append(a2)
- # Position.
- tile.left = pos[0]
- tile.top = pos[1]
- #}
- #}
-
- def desktop_createSelectedTiles(p):
- for (id, pos) in enumerate(p.c.tilePositions):
- tile = arcade.Sprite()
- p.selectedTiles.append(tile)
- p.selectedSprites.append(tile)
-
- tile.guid = id
- tile.texture = p.textures[2 + p.c.playfieldItems[id]]
- # Position.
- tile.left = pos[0]
- tile.top = pos[1]
- # Invisible by default.
- tile.visible = False
- #}
- #}
-
- def desktop_createTitle(p):
- p.title = arcade.Sprite()
- p.titleSprites.append(p.title)
- p.title.texture = p.titleTextures[0]
- # Position.
- pos = gui_aux_cellScreenPosition(p.c, p.c.titlePosition)
- p.title.left = pos[0]
- p.title.top = pos[1]
- # Invisible by default.
- p.title.visible = False
- #}
-
- # Deselect mismatched tiles
- #
- # Conditions:
- # 1. Time to deselect mismatched items
- def desktop_deselectMismatchedTiles(p):
- if (
- p.c.recentField == "deselectMismatchedTiles"
- ):
- for id in p.c.mismatchedItems:
- p.deselectedTiles[id].visible = True
- p.selectedTiles[id].visible = False
- #}
- #}
- #}
-
- # Hide deselected tile and show selected one
- #
- # Conditions:
- # 1. tile has just been selected
- def desktop_displaySelectedTile(p):
- if (
- p.c.recentField == "selectedId"
- ):
- id = p.c.selectedId
- p.deselectedTiles[id].visible = False
- p.selectedTiles[id].visible = True
- #}
- #}
-
- # Display title for the first selected tile
- #
- # Conditions:
- # 1. tile has just been selected and it's the first one in pair
- def desktop_displayTitle(p):
- if (
- p.c.recentField == "selectedId" and
- (
- len(p.c.selectedItems) == 0 or
- len(p.c.selectedItems) == 2
- )
- ):
- gid = p.c.playfieldItems[p.c.selectedId]
- p.title.texture = p.titleTextures[gid]
- p.title.visible = True
- #}
- #}
-
- # Hide matching tiles
- #
- # Conditions:
- # 1. Time to hide matching items
- def desktop_hideMatchingTiles(p):
- if (
- p.c.recentField == "hideMatchingTiles"
- ):
- for id in p.c.selectedItems:
- p.deselectedTiles[id].visible = False
- p.selectedTiles[id].visible = False
- #}
- #}
- #}
-
- # Hide title
- #
- # Conditions:
- # 1. tiles has been scheduled to hide after being matched or just mismatched
- def desktop_hideTitle(p):
- if (
- p.c.recentField == "hideMatchingTiles" or
- p.c.recentField == "mismatchedItems"
- ):
- p.title.visible = False
- #}
- #}
-
- # Load description textures
- def desktop_loadDescTextures(p):
- texs = []
- for (id, td) in enumerate(p.c.descTextureDescriptions):
- tex = arcade.load_texture(
- td.fileName,
- x = td.x,
- y = td.y,
- width = td.width,
- height = td.height
- )
- texs.append(tex)
- #}
- p.descTextures = texs
- #}
-
- # Load tile textures
- def desktop_loadTextures(p):
- texs = []
- for (id, td) in enumerate(p.c.textureDescriptions):
- tex = arcade.load_texture(
- td.fileName,
- x = td.x,
- y = td.y,
- width = td.width,
- height = td.height
- )
- texs.append(tex)
- #}
- p.textures = texs
- #}
-
- # Load tiTLe textures
- def desktop_loadTitleTextures(p):
- texs = []
- for (id, td) in enumerate(p.c.titleTextureDescriptions):
- tex = arcade.load_texture(
- td.fileName,
- x = td.x,
- y = td.y,
- width = td.width,
- height = td.height
- )
- texs.append(tex)
- #}
- p.titleTextures = texs
- #}
-
- # Postpone deselection of mismatched tiles for better UX
- #
- # Conditions:
- # 1. a pair of tiles has been mismatched
- def desktop_scheduleDeselectionOfMismatchedTiles(p):
- if (
- p.c.recentField == "mismatchedItems"
- ):
- p.sequentialTimer.schedule("deselectMismatchedTiles", True, p.c.deselectMismatchedTilesDelay)
- #}
- #}
-
- # Postpone hiding of matching tiles for better UX
- #
- # Conditions:
- # 1. a pair of tiles has been matched
- def desktop_scheduleHidingOfMatchingTiles(p):
- if (
- p.c.recentField == "hiddenItems"
- ):
- p.sequentialTimer.schedule("hideMatchingTiles", True, p.c.hideMatchingTilesDelay)
- #}
- #}
|