Skip to content

Commit

Permalink
req'd changes and testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
multimokia committed Aug 18, 2019
1 parent be59ee9 commit 4becc5f
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 64 deletions.
101 changes: 37 additions & 64 deletions Monika After Story/game/zz_backgrounds.rpy
Expand Up @@ -10,14 +10,7 @@ init -10 python:
PROPERTIES:
background_id - the id which defines this bg
prompt - button label for the bg
image_day - the image tag for the day background image object
image_night - the image tag for the night background image object
image_rain_day - the image tag for the background while raining during the day
image_rain_night - the image tag for the background while it's raining during the night
image_overcast_day - the image tag for the background while it's overcast during the day
image_overcast_night - the image tag for the background while it's overcast during the night
image_snow_day - the image tag for the background while it's snowing during the day
image_snow_night - the image tag for the background while it's snowing during the night
img_map - Dict mapping all images for the bgs, keys are precip types (See MASWeather)
hide_calendar - whether or not we display the calendar with this
hide_masks - whether or not we display the window masks
disable_progressive - weather or not we disable progesssive weather
Expand Down Expand Up @@ -123,38 +116,17 @@ init -10 python:
self.image_day = image_day
self.image_night = image_night

#Handle rain BGs
if image_rain_day:
self.image_rain_day = image_rain_day
else:
self.image_rain_day = image_day

if image_rain_night:
self.image_rain_night = image_rain_night
else:
self.image_rain_night = image_night

#Overcast handling
if image_overcast_day:
self.image_overcast_day = image_overcast_day
else:
self.image_overcast_day = image_day

if image_overcast_night:
self.image_overcast_night = image_overcast_night
else:
self.image_overcast_night = image_night

#Snow handling
if image_snow_day:
self.image_snow_day = image_snow_day
else:
self.image_snow_day = image_day

if image_snow_night:
self.image_snow_night = image_snow_night
else:
self.image_snow_night = image_night
self.image_map = {
#Def
mas_weather.PRECIP_TYPE_DEF: (image_day, image_night),
#Rain
mas_weather.PRECIP_TYPE_RAIN: (image_rain_day if image_rain_day else image_day, image_rain_night if image_rain_night else image_night),
#Overcast
mas_weather.PRECIP_TYPE_OVERCAST: (image_overcast_day if image_overcast_day else image_day, image_overcast_night if image_overcast_night else image_night),
#Snow
mas_weather.PRECIP_TYPE_SNOW: (image_snow_day if image_snow_day else image_day, image_snow_night if image_snow_night else image_night)
}

#Then the other props
self.hide_calendar = hide_calendar
Expand Down Expand Up @@ -230,13 +202,7 @@ init -10 python:
if weather is None:
weather = store.mas_current_weather

if weather.precip_type == mas_weather.PRECIP_TYPE_RAIN:
return self.image_rain_day
elif weather.precip_type == mas_weather.PRECIP_TYPE_OVERCAST:
return self.image_overcast_day
elif weather.precip_type == mas_weather.PRECIP_TYPE_SNOW:
return self.image_snow_day
return self.image_day
return self.image_map[weather.precip_type][0]

def getNightRoom(self, weather=None):
"""
Expand All @@ -245,13 +211,7 @@ init -10 python:
if weather is None:
weather = store.mas_current_weather

if weather.precip_type == mas_weather.PRECIP_TYPE_RAIN:
return self.image_rain_night
elif weather.precip_type == mas_weather.PRECIP_TYPE_OVERCAST:
return self.image_overcast_night
elif weather.precip_type == mas_weather.PRECIP_TYPE_SNOW:
return self.image_snow_night
return self.image_night
return self.image_map[weather.precip_type][1]

def getRoomForTime(self, weather=None):
"""
Expand All @@ -268,12 +228,17 @@ init -10 python:
return self.getNightRoom(weather)

def isChangingRoom(self, old_weather, new_weather):
"""
If the room has a different look for the new weather we're going into, the room is "changing" and we need to flag this to
scene change and dissolve the spaceroom in the spaceroom label
"""
return self.getRoomForTime(old_weather) != self.getRoomForTime(new_weather)



#Helper methods and such
init -20 python in mas_background:
import store
BACKGROUND_MAP = {}
BACKGROUND_RETURN = "Nevermind"

Expand All @@ -298,6 +263,15 @@ init -20 python in mas_background:
for mbg_id, mbg_obj in BACKGROUND_MAP.iteritems():
store.persistent._mas_background_MBGdata[mbg_id] = mbg_obj.toTuple()

def getUnlockedBGCount():
"""
Gets the number of unlocked backgrounds
"""
unlocked_count = 0
for mbg_obj in BACKGROUND_MAP.itervalues():
unlocked_count += int(mbg_obj.unlocked)

return unlocked_count

#START: BG change functions
init 800 python:
Expand Down Expand Up @@ -338,13 +312,8 @@ init 800 python:
mas_current_background = None
mas_setBackground(mas_background_def)

#Make sure the bg selector is only available with the right amount of bgs unlocked
if len([
(mbg_obj.prompt, mbg_obj, False, False)
for mbg_id, mbg_obj in mas_background.BACKGROUND_MAP.iteritems()
if mbg_obj.unlocked
]
) < 2:
#Make sure the bg selector is only available with at least 2 bgs unlocked
if mas_background.getUnlockedBGCount() < 2:
mas_lockEVL("monika_change_background","EVE")

#START: Programming points
Expand Down Expand Up @@ -474,9 +443,11 @@ label monika_change_background_loop:
m "Try again~"
jump monika_change_background_loop

$ skip_outro = False
$ skip_leadin = False
call mas_background_change(sel_background)
return

#Generic background changing label, can be used if we wanted a sort of story related change
label mas_background_change(new_bg, skip_leadin=False, skip_outro=False):
# otherwise, we can change the background now
if not skip_leadin:
m 1eua "Alright!"
Expand All @@ -489,9 +460,10 @@ label monika_change_background_loop:
pause 2.0

# finally change the background
$ mas_changeBackground(sel_background)
$ mas_changeBackground(new_bg)

if sel_background.hide_masks:
#If we've disabled progressive and hidden masks, then we shouldn't allow weather change
if new_bg.disable_progressive and new_bg.hide_masks:
$ mas_weather.temp_weather_storage = mas_current_weather
$ mas_changeWeather(mas_weather_def)
$ mas_lockEVL("monika_change_weather", "EVE")
Expand All @@ -508,6 +480,7 @@ label monika_change_background_loop:
else:
$ mas_changeWeather(mas_weather_def)

#Then we unlock the weather sel here
$ mas_unlockEVL("monika_change_weather", "EVE")

call spaceroom(scene_change=True, dissolve_all=True)
Expand Down
3 changes: 3 additions & 0 deletions Monika After Story/game/zz_weather.rpy
Expand Up @@ -201,6 +201,9 @@ init -20 python in mas_weather:
#Whether or not we should scene change
should_scene_change = False

#Keep a temp store of weather here for if we're changing backgrounds
temp_weather_storage = None

# def canChangeWeather():
# """
# Returns true if the user can change weather
Expand Down
115 changes: 115 additions & 0 deletions testcases/Backgrounds/game/dev/test_bwswap.rpy
@@ -0,0 +1,115 @@
#Allow bg selector for this
init 5 python:
addEvent(
Event(
persistent.event_database,
eventlabel="dev_bgsel",
category=["dev"],
prompt="TEST BGSWAP",
pool=True,
unlocked=True
)
)

label dev_bgsel:

m 1hua "Sure!"

label dev_bgsel_loop:

show monika 1eua at t21

$ renpy.say(m, "What background would you like?", interact=False)

python:
# build menu list
import store.mas_background as mas_background
import store.mas_moods as mas_moods

# we assume that we will always have more than 1
# default should always be at the top
backgrounds = [(mas_background_def.prompt, mas_background_def, False, False)]

# build other backgrounds list
other_backgrounds = [
(mbg_obj.prompt, mbg_obj, False, False)
for mbg_id, mbg_obj in mas_background.BACKGROUND_MAP.iteritems()
if mbg_id != "spaceroom"
]

# sort other backgrounds list
other_backgrounds.sort()

# build full list
backgrounds.extend(other_backgrounds)

# now add final quit item
final_item = (mas_background.BACKGROUND_RETURN, False, False, False, 20)

# call scrollable pane
call screen mas_gen_scrollable_menu(backgrounds, mas_moods.MOOD_AREA, mas_moods.MOOD_XALIGN, final_item)

$ sel_background = _return

show monika at t11

# return value False? then return
if sel_background is False:
m 1eka "Oh, alright."
m "If you want to go somewhere, just ask, okay?"
return

if sel_background == mas_current_background:
m 1hua "We're here right now, silly."
m "Try again~"
jump dev_bgsel_loop

call mas_background_change(sel_background, True, True)
return

init -1 python:
#Default spaceroom
mas_background_test = MASBackground(
#Identification
"test",
"Test",

#Day/Night
image_day="test_bgroom_def",
image_night="test_bgroom_def_night",

#Rain Day/Night
image_rain_day="test_bgroom_rain",
image_rain_night="test_bgroom_rain_night",

#Overcast Day/Night
image_overcast_day="test_bgroom_overcast",
image_overcast_night="test_bgroom_overcast_night",

#Snow Day/Night
image_snow_day="test_bgroom_snow",
image_snow_night="test_bgroom_snow_night",

#These masks don't get windows or calendar
hide_calendar=True,
hide_masks=True,

#For the sake of testing, we do want progressive
disable_progressive=False,

#Test room should always be unlocked
unlocked=True,
)

#START: Image defs
#Day
image test_bgroom_def = "mod_assets/location/test/test-def.png"
image test_bgroom_overcast = "mod_assets/location/test/test-overcast.png"
image test_bgroom_rain = "mod_assets/location/test/test-rain.png"
image test_bgroom_snow = "mod_assets/location/test/test-snow.png"

#Night
image test_bgroom_def_night = "mod_assets/location/test/test-def-n.png"
image test_bgroom_overcast_night = "mod_assets/location/test/test-overcast-n.png"
image test_bgroom_rain_night = "mod_assets/location/test/test-rain-n.png"
image test_bgroom_snow_night = "mod_assets/location/test/test-snow-n.png"
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4becc5f

Please sign in to comment.