Python:
default current_galaxy = 1
screen MapButton():
imagebutton:
xalign 0.98
yalign 0.03
idle "images/mapbutton.png"
action Show("galaxymap{}".format(current_galaxy)), Hide("MapButton")
screen galaxymap1():
modal True
imagebutton:
idle "images/maps/galaxymap1.jpg"
action [ Hide("galaxymap1"), Show("MapButton") ]
screen galaxymap2():
modal True
imagebutton:
idle "images/maps/galaxymap2.jpg"
action [ Hide("galaxymap2"), Show("MapButton") ]
# etc, etc.
Good thinking, but you stuck to the question and then missed a better approach.
You tried to link "MapButton" to one of the many galaxy screens, what correspond to the question. But you could have put the dynamism directly in the galaxy screen, and so have only one screen for all of them :
Code:
default current_galaxy = 1
screen MapButton():
imagebutton:
xalign 0.98
yalign 0.03
idle "images/mapbutton.png"
action Show("galaxymap"), Hide("MapButton")
screen galaxymap():
modal True
imagebutton:
idle "images/maps/galaxymap{}.jpg".format(current_galaxy)
action [ Hide("galaxymap"), Show("MapButton") ]
and I would like to be able to use only one map button to display each map if I can.
From what I get, the only change is the blue squares, then why not add them instead of changing the whole map each time ?
You can have a screen with only those blue squares, and everything else at 100% transparency. Then your galaxy screen would looks like :
Python:
screen galaxymap1():
modal True
# Display the actual map, without blue squares, as background
add "images/maps/galaxymap1.jpg"
# Then display the blue squares on top of it, according
# to the actual context of the game.
if some condition:
add "images/maps/path/thisPath.jpg"
elif some other condition:
add "images/maps/path/thatPath.jpg"
[...]
# Button to close the map
imagebutton:
xalign 0.9
yalign 0.0
idle "images/maps/closeButton.jpg"
action [ Hide("galaxymap1"), Show("MapButton") ]
The same can works if the "influence zone" (the redish ovals) can change. Just have an image, the size of the oval, where the red oval is at 50% transparency and everything else at 100% :
Python:
screen galaxymap1():
modal True
# Display the actual map, without blue squares, as background
add "images/maps/galaxymap1.jpg"
# Display the "influence zones".
if kortexPrime:
add "images/maps/influenceZones.jpg" pos( 356, 852 )
if newEarthII:
add "images/maps/influenceZones.jpg" pos( 0, 810 )
[...]
# Then display the blue squares on top of it, according
# to the actual context of the game.
if some condition:
add "images/maps/path/thisPath.jpg"
elif some other condition:
add "images/maps/path/thatPath.jpg"
[...]
# Button to close the map
imagebutton:
xalign 0.9
yalign 0.0
idle "images/maps/closeButton.jpg"
action [ Hide("galaxymap1"), Show("MapButton") ]
And this way you can even add new planets and all ; once again with an image the size of the planets, and everything that isn't the planet at 100% transparency.
If you fear that the code for the screen become too big and hard to maintain, you can split it :
Python:
screen galaxymap1():
modal True
# Display the actual map, without blue squares, as background
add "images/maps/galaxymap1.jpg"
# Add the screen for the planets
use galaxyMap1Planets
# Add the screen for the "influence zones"
use galaxyMap1Zones
# Add the screen for the blue squares
use galaxyMap1Path
# Button to close the map
imagebutton:
xalign 0.9
yalign 0.0
idle "images/maps/closeButton.jpg"
action [ Hide("galaxymap1"), Show("MapButton") ]
screen galaxyMap1Planets():
if kortexPrimeKnown is True:
add "images/maps/planets/kortexPrime.jpg" pos( 480, 980 )
if newEarthIIKnown is True:
add "images/maps/planets/newEarthII.jpg" pos( 70, 940 )
[...]
screen galaxyMap1Zones():
# Display the "influence zones".
if kortexPrimeInfluence is True:
add "images/maps/influenceZones.jpg" pos( 356, 852 )
if newEarthIIInfluence is True:
add "images/maps/influenceZones.jpg" pos( 0, 810 )
[...]
screen galaxyMap1Path():
# Then display the blue squares on top of it, according
# to the actual context of the game.
if some condition:
add "images/maps/path/thisPath.jpg"
elif some other condition:
add "images/maps/path/thatPath.jpg"
[...]
And finally because of this, you can filter what's shown on the screen:
Python:
screen galaxymap1():
modal True
# Display the actual map, without blue squares, as background
add "images/maps/galaxymap1.jpg"
# Add the screen for the planets, only if asked to
showif showPlanets is True:
use galaxyMap1Planets
# Add the screen for the "influence zones", only if asked to
showif showZones is True:
use galaxyMap1Zones
# Add the screen for the blue squares, only if asked to
showif showPath is True:
use galaxyMap1Path
# Button to close the map
imagebutton:
xalign 0.9
yalign 0.0
idle "images/maps/closeButton.jpg"
action [ Hide("galaxymap1"), Show("MapButton") ]
Finally, but it demand more works on the coding part, you don't necessarily need to effectively have an image for each path. You can just have a single image that is just one of those blue square:
Python:
# Position of the blue squares
define pathKortexPrime2Grarth = [ ( 512, 952 ), ( 538, 900 ), (560, 846), [...] ]
screen galaxyMap1Path():
if some condition:
for p in pathKortexPrime2Grath:
add "images/maps/blueSquare.jpg" pos p
if some other condition:
for p in pathSomewhere2SomewhereElse:
add "images/maps/blueSquare.jpg" pos p
[...]
In your example it's apparently the path from Kortex Prime to Grath that is continued, so you can have :
Python:
# Position of the blue squares
# first half
define pathKortexPrime2Grarth1 = [ ( 512, 952 ), ( 538, 900 ), (560, 846), [...] ]
# second half
define pathKortexPrime2Grarth2 = [ ( 696, 478 ), ( 708, 426 ), (728, 372 ), [...] ]
screen galaxyMap1Path():
if some condition:
for p in pathKortexPrime2Grath1:
add "images/maps/blueSquare.jpg" pos p
if some condition and some other:
for p in pathKortexPrime2Grath2:
add "images/maps/blueSquare.jpg" pos p
if some other condition:
for p in pathSomewhere2SomewhereElse:
add "images/maps/blueSquare.jpg" pos p
[...]