d
This commit is contained in:
@@ -49,6 +49,16 @@ def desktop_createSelectedTiles(p):
|
|||||||
#}
|
#}
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
def desktop_createSplash(p):
|
||||||
|
p.splash = arcade.Sprite()
|
||||||
|
p.splashSprites.append(p.splash)
|
||||||
|
p.splash.texture = p.splashTextures[0]
|
||||||
|
# Position.
|
||||||
|
pos = gui_aux_cellScreenPosition(p.c, [0, 0])
|
||||||
|
p.splash.left = pos[0]
|
||||||
|
p.splash.top = pos[1]
|
||||||
|
#}
|
||||||
|
|
||||||
def desktop_createTitle(p):
|
def desktop_createTitle(p):
|
||||||
p.title = arcade.Sprite()
|
p.title = arcade.Sprite()
|
||||||
p.titleSprites.append(p.title)
|
p.titleSprites.append(p.title)
|
||||||
@@ -126,6 +136,18 @@ def desktop_displayTitle(p):
|
|||||||
#}
|
#}
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
# Hide beginning splash screen
|
||||||
|
#
|
||||||
|
# Conditions:
|
||||||
|
# 1. Time to hide
|
||||||
|
def desktop_hideBeginningSplashScreen(p):
|
||||||
|
if (
|
||||||
|
p.c.recentField == "hideBeginningSplashScreen"
|
||||||
|
):
|
||||||
|
p.splash.visible = False
|
||||||
|
#}
|
||||||
|
#}
|
||||||
|
|
||||||
# Hide description
|
# Hide description
|
||||||
#
|
#
|
||||||
# Conditions:
|
# Conditions:
|
||||||
@@ -183,6 +205,23 @@ def desktop_loadDescTextures(p):
|
|||||||
p.descTextures = texs
|
p.descTextures = texs
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
# Load beginning and ending textures
|
||||||
|
def desktop_loadSplashTextures(p):
|
||||||
|
texs = []
|
||||||
|
for (id, td) in enumerate(p.c.splashTextureDescriptions):
|
||||||
|
tex = arcade.load_texture(
|
||||||
|
td.fileName,
|
||||||
|
x = td.x,
|
||||||
|
y = td.y,
|
||||||
|
width = td.width,
|
||||||
|
height = td.height
|
||||||
|
)
|
||||||
|
texs.append(tex)
|
||||||
|
print(f"desktop_loadST: '{tex}'")
|
||||||
|
#}
|
||||||
|
p.splashTextures = texs
|
||||||
|
#}
|
||||||
|
|
||||||
# Load tile textures
|
# Load tile textures
|
||||||
def desktop_loadTextures(p):
|
def desktop_loadTextures(p):
|
||||||
texs = []
|
texs = []
|
||||||
@@ -238,3 +277,16 @@ def desktop_scheduleHidingOfMatchingTiles(p):
|
|||||||
p.sequentialTimer.schedule("hideMatchingTiles", True, p.c.hideMatchingTilesDelay)
|
p.sequentialTimer.schedule("hideMatchingTiles", True, p.c.hideMatchingTilesDelay)
|
||||||
#}
|
#}
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
# Postpone hiding of the beginning splash screen
|
||||||
|
#
|
||||||
|
# Conditions:
|
||||||
|
# 1. just launched the game
|
||||||
|
def desktop_scheduleHidingOfBeginningSplashScreen(p):
|
||||||
|
if (
|
||||||
|
p.c.recentField == "didLaunch"
|
||||||
|
):
|
||||||
|
p.sequentialTimer.schedule("hideBeginningSplashScreen", True, p.c.splashBeginTimeout)
|
||||||
|
#}
|
||||||
|
#}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ class desktop_Platform:
|
|||||||
self.selectedTiles = []
|
self.selectedTiles = []
|
||||||
self.sequentialTimer = None
|
self.sequentialTimer = None
|
||||||
self.selectedSprites = arcade.SpriteList()
|
self.selectedSprites = arcade.SpriteList()
|
||||||
|
self.splash = None
|
||||||
|
self.splashSprites = arcade.SpriteList()
|
||||||
|
self.splashTextures = []
|
||||||
self.textures = []
|
self.textures = []
|
||||||
self.title = None
|
self.title = None
|
||||||
self.titleSprites = arcade.SpriteList()
|
self.titleSprites = arcade.SpriteList()
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ class desktop_Window(arcade.Window):
|
|||||||
self.p.descSprites.draw()
|
self.p.descSprites.draw()
|
||||||
self.p.deselectedSprites.draw()
|
self.p.deselectedSprites.draw()
|
||||||
self.p.selectedSprites.draw()
|
self.p.selectedSprites.draw()
|
||||||
|
self.p.splashSprites.draw()
|
||||||
self.p.titleSprites.draw()
|
self.p.titleSprites.draw()
|
||||||
|
|
||||||
def on_mouse_press(self, x, y, button, key_modifiers):
|
def on_mouse_press(self, x, y, button, key_modifiers):
|
||||||
|
|||||||
33
v5/gui.py
33
v5/gui.py
@@ -36,6 +36,39 @@ def gui_generateDescTextureDescriptions(
|
|||||||
return c
|
return c
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
# Generate texture descriptions for splash screens
|
||||||
|
#
|
||||||
|
# Conditions:
|
||||||
|
# 1.splashImage, splashImageCount, splashImageHeight, or splashImageWidth has just changed
|
||||||
|
@llm_by_value
|
||||||
|
def gui_generateSplashTextureDescriptions(
|
||||||
|
c: memory_Context
|
||||||
|
) -> memory_Context:
|
||||||
|
if (
|
||||||
|
c.recentField == "splashImage" or
|
||||||
|
c.recentField == "splashImageCount" or
|
||||||
|
c.recentField == "splashImageHeight" or
|
||||||
|
c.recentField == "splashImageWidth"
|
||||||
|
):
|
||||||
|
tds: list[gui_TextureDescription] = []
|
||||||
|
for id in range(0, c.splashImageCount):
|
||||||
|
td = gui_createTextureDescription()
|
||||||
|
td.fileName = c.splashImage
|
||||||
|
td.height = c.splashImageHeight
|
||||||
|
td.width = c.splashImageWidth
|
||||||
|
td.x = id * c.splashImageWidth
|
||||||
|
td.y = 0
|
||||||
|
tds.append(td)
|
||||||
|
#}
|
||||||
|
c.splashTextureDescriptions = tds
|
||||||
|
c.recentField = "splashTextureDescriptions"
|
||||||
|
return c
|
||||||
|
#}
|
||||||
|
|
||||||
|
c.recentField = "none"
|
||||||
|
return c
|
||||||
|
#}
|
||||||
|
|
||||||
# Generate texture descriptions for tiles
|
# Generate texture descriptions for tiles
|
||||||
#
|
#
|
||||||
# Conditions:
|
# Conditions:
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ ctrl.registerFunctions([
|
|||||||
# cli_selectItem,
|
# cli_selectItem,
|
||||||
# cli_showHelp,
|
# cli_showHelp,
|
||||||
gui_generateDescTextureDescriptions,
|
gui_generateDescTextureDescriptions,
|
||||||
|
gui_generateSplashTextureDescriptions,
|
||||||
gui_generateTextureDescriptions,
|
gui_generateTextureDescriptions,
|
||||||
gui_generateTilePositions,
|
gui_generateTilePositions,
|
||||||
gui_generateTitleTextureDescriptions,
|
gui_generateTitleTextureDescriptions,
|
||||||
@@ -80,7 +81,7 @@ ctrl.registerFunctions([
|
|||||||
|
|
||||||
def printDbg(c):
|
def printDbg(c):
|
||||||
print(f"Dbg key/value: '{c.recentField}'/'{c.field(c.recentField)}'")
|
print(f"Dbg key/value: '{c.recentField}'/'{c.field(c.recentField)}'")
|
||||||
#ctrl.registerCallback(printDbg)
|
ctrl.registerCallback(printDbg)
|
||||||
ctrl.registerFieldCallback("exit", lambda c: sys.exit(0))
|
ctrl.registerFieldCallback("exit", lambda c: sys.exit(0))
|
||||||
|
|
||||||
p = desktop_Platform()
|
p = desktop_Platform()
|
||||||
@@ -98,9 +99,11 @@ def process(c):
|
|||||||
desktop_displayDesc(p)
|
desktop_displayDesc(p)
|
||||||
desktop_displaySelectedTile(p)
|
desktop_displaySelectedTile(p)
|
||||||
desktop_displayTitle(p)
|
desktop_displayTitle(p)
|
||||||
|
desktop_hideBeginningSplashScreen(p)
|
||||||
desktop_hideDesc(p)
|
desktop_hideDesc(p)
|
||||||
desktop_hideMatchingTiles(p)
|
desktop_hideMatchingTiles(p)
|
||||||
desktop_hideTitle(p)
|
desktop_hideTitle(p)
|
||||||
|
desktop_scheduleHidingOfBeginningSplashScreen(p)
|
||||||
desktop_scheduleHidingOfMatchingTiles(p)
|
desktop_scheduleHidingOfMatchingTiles(p)
|
||||||
desktop_scheduleDeselectionOfMismatchedTiles(p)
|
desktop_scheduleDeselectionOfMismatchedTiles(p)
|
||||||
ctrl.registerCallback(process)
|
ctrl.registerCallback(process)
|
||||||
@@ -117,6 +120,10 @@ ctrl.set("descImageHeight", 250)
|
|||||||
ctrl.set("descImageWidth", 375)
|
ctrl.set("descImageWidth", 375)
|
||||||
ctrl.set("descPosition", [19, 12])
|
ctrl.set("descPosition", [19, 12])
|
||||||
ctrl.set("hideMatchingTilesDelay", 500)
|
ctrl.set("hideMatchingTilesDelay", 500)
|
||||||
|
ctrl.set("splashImage", "res/splash.png")
|
||||||
|
ctrl.set("splashImageCount", 2)
|
||||||
|
ctrl.set("splashImageHeight", 600)
|
||||||
|
ctrl.set("splashImageWidth", 900)
|
||||||
ctrl.set("tileImage", "res/harmful-tiles.png")
|
ctrl.set("tileImage", "res/harmful-tiles.png")
|
||||||
ctrl.set("tileImageCount", 8)
|
ctrl.set("tileImageCount", 8)
|
||||||
ctrl.set("tileImageHeight", 100)
|
ctrl.set("tileImageHeight", 100)
|
||||||
|
|||||||
@@ -29,6 +29,11 @@ class memory_Context:
|
|||||||
self.recentField = "none"
|
self.recentField = "none"
|
||||||
self.selectedId = -1
|
self.selectedId = -1
|
||||||
self.selectedItems = []
|
self.selectedItems = []
|
||||||
|
self.splashBeginTimeout = 2000
|
||||||
|
self.splashImage = ""
|
||||||
|
self.splashImageCount = 0
|
||||||
|
self.splashImageHeight = 0
|
||||||
|
self.splashImageWidth = 0
|
||||||
self.textureDescriptions = []
|
self.textureDescriptions = []
|
||||||
self.tileImage = ""
|
self.tileImage = ""
|
||||||
self.tileImageCount = 0
|
self.tileImageCount = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user