Calendar help?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Message
Author
User avatar
Cherubunny
Regular
Posts: 26
Joined: Sat Feb 24, 2018 6:52 am
Tumblr: cherubunny
Deviantart: cherubunny
Contact:

Calendar help?

#1 Post by Cherubunny »

Hello, hello! Sorry for the trouble, but I've been working on figuring out a calendar for my game. So far, it looks like this:
Image
(As a test, the current date in the game is set to February 5)
What I'm trying to figure out is how to click the arrows to display the next month depending on the current month, how to get it to show its proper, corresponding date image (e.g. January showing its 31 days image instead of showing the 28 days image), and how to go backwards and show the correct screen (e.g. If our date is February 5, and we click forward to look at March, but then go back to February, it goes to the screen February and gets rid of the highlighted 05 day, so is there a way to go back to that screen and keep the current highlighted day shown?)
Sorry this is such a messy ask, I'm very amateur :(
Last edited by Cherubunny on Tue Apr 17, 2018 1:57 am, edited 2 times in total.

User avatar
Enchant00
Regular
Posts: 136
Joined: Tue Jan 12, 2016 1:17 am
Contact:

Re: Calendar help?

#2 Post by Enchant00 »

Hello, btw you have a nice calendar XD Do you already have any screen language code and if so can you post it here?

Here is a general gist of how you want your calendar to work:

Q: What I'm trying to figure out is how to click the arrows to display the next month depending on the current month, how to get it to show its proper, corresponding date image

- (PART A) Let's first solve your problem with the buttons. The way to go about this is to either use an image button or imagemaps. What would probably work best for you would be to use imagemaps instead of imagebuttons. Since your calendar highlights the current day red, it would be faster and more effecient to use imagemaps else if the dates didn't change then image buttons would go.

- (PART B) The next thing tackled would be how to display the proper month. The way to to this would be to use screens! Once you made the button you can assign the button an action, in your case that action would display the screen.
There are multiple ways to do this:
1. You can have 12 screens, each representing each month. The would mean you would have 12 images of calendars for each month.
2. You can have a single master screen, and deoending on certain conditions that screen will be altered depending on the month.
The first is a lot easier to code but time consuming; the second would require a more complex kind of code but in the sense it's more efficient.

Q: How to go backwards and show the correct screen
- This really depends on how your game's programed date or time system functions. But generally, all you have to do is store the current date into a default variable like default date = 5; Afterwards, you would add a conditional in your screen to check the current date and then it would modify your master screen to strike red the current date.

Ok, now here is the thing everything I just stated are in the general sense and more or less how I'd approach it. The problem why I cant give you more detailed code atm is I'm uncertain if you have created any of your screens or such. I'll come back to you once you post some code if any or none and I'll see if I can create a placeholder code framework where all you have to do if just plug it the necessary things. However, first post any screen code if you have any :lol:

User avatar
Cherubunny
Regular
Posts: 26
Joined: Sat Feb 24, 2018 6:52 am
Tumblr: cherubunny
Deviantart: cherubunny
Contact:

Re: Calendar help?

#3 Post by Cherubunny »

Oh gosh, thank you so much for the reply!! I actually am using imagemaps for this, and each date is a hotspot. Here's what I have currently (I also added comments for things that are just minor and image related):

Code: Select all

screen calendar_base():
    window:
        style "mm_root" # Gradient background
        
    add "bg fly" # Seamless Moving Circle Pattern Background
    
    python:
        if calendar.day < 10:
            day_img = "".join([calendar.month , " cal 0", str(calendar.day), ".png"])
        else:
            day_img = "".join([calendar.month , " cal ", str(calendar.day), ".png"])
        month_img = "".join(["cal ", calendar.month, ".png"])
    
    imagemap:
        add "sweetly.png"
        ground "images/calendar_ground.png"
        idle "images/calendar_idle.png"
        hover "images/calendar_hover.png"
        selected_hover "images/calendar_selectedhover.png"
        selected_idle "images/calendar_selected.png"
        alpha False
        
        hotspot (190,457,109,112) action Return()
        if calendar.month == 'February':
            hotspot (247,159,59,73) action ShowMenu("January")
            hotspot (1063,159,59,73) action ShowMenu("March") #Aside from the fact I haven't completed the screens yet, the proper screen does show up, for both Jan and March, but I have no idea... where to continue from here and also how to get it to get back and still show the highlighted 05 if it's February
        ##
        hotspot (327,149,96,79) #These are all the dates for February, I haven't gotten too far on the other months because it's a lot of images so far.
        hotspot (430,149,96,79) 
        hotspot (533,149,96,79)
        hotspot (636,149,96,79)
        hotspot (739,149,96,79) action NullAction
        hotspot (842,149,96,79) action NullAction 
        hotspot (945,149,96,79) action NullAction 
        ##
        hotspot (327,234,96,79) action NullAction 
        hotspot (430,234,96,79) action NullAction 
        hotspot (533,234,96,79) action NullAction 
        hotspot (636,234,96,79) action NullAction 
        hotspot (739,234,96,79) action NullAction 
        hotspot (842,234,96,79) action NullAction 
        hotspot (945,234,96,79) action NullAction 
        ##
        hotspot (327,319,96,79) action NullAction 
        hotspot (430,319,96,79) action NullAction 
        hotspot (533,319,96,79) action NullAction 
        hotspot (636,319,96,79) action NullAction 
        hotspot (739,319,96,79) action NullAction 
        hotspot (842,319,96,79) action NullAction 
        hotspot (945,319,96,79) action NullAction 
        ##
        hotspot (327,404,96,79) action NullAction 
        hotspot (430,404,96,79) action NullAction 
        hotspot (533,404,96,79) action NullAction 
        hotspot (636,404,96,79) action NullAction 
        hotspot (739,404,96,79) action NullAction 
        hotspot (842,404,96,79) action NullAction 
        hotspot (945,404,96,79) action NullAction 
        ##
        hotspot (327,489,96,79) action NullAction 
        hotspot (430,489,96,79) action NullAction 
        hotspot (533,489,96,79) action NullAction 
        hotspot (636,489,96,79) action NullAction 
        hotspot (739,489,96,79) 
        hotspot (842,489,96,79) 
        hotspot (945,489,96,79) 
        
    vbox:
        add month_img #This is the title e.g. February
        add day_img #This is the entire date image, but it will show 05 as highlighted
Thank you again for the willingness to help <3 I'm very new to coding, but I think I am learning fast, and it is very fun! I just don't know the ins and outs yet haha. If you need anything else, feel free to let me know!

philat
Eileen-Class Veteran
Posts: 1910
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Calendar help?

#4 Post by philat »

I wouldn't use an imagemap; simpler to use buttons. (Specifically, you don't have to do 365 hotspots...) I was bored at work and wanted to waste some time, so I made the following standalone calendar. (Does not allow for years, but it's rare that that's really relevant in a VN.) Obviously you have your own system going on for keeping track of the dates; feel free to modify as needed. The following is just meant to illustrate the basic concept. You can change it to imagebuttons or just have the background as an image and use textbuttons (active buttons with a white background, nonactive with purple, highlighted 'today' with red text, etc.) with much less fuss than doing it in image editing software by hand.

Code: Select all

default month_dict = {
    1:("January", 31),
    2:("February", 28),
    3:("March", 31),
    4:("April", 30),
    5:("May", 31),
    6:("June", 30),
    7:("July", 31),
    8:("August", 31),
    9:("September", 30),
    10:("October", 31),
    11:("November", 30),
    12:("December", 31),
}

screen calendar(month, starting_day): 
    # month is the month shown
    # starting_day is the first weekday of the month expressed as an integer (0 for Sunday, 6 for Saturday)

    default name = month_dict[month][0]
    default days = month_dict[month][1]
    default prev_month = month-1 if month > 1 else 12
    default next_month = month+1 if month < 12 else 1

    vbox:
        hbox:
            textbutton "<" action Show("calendar", month=prev_month, starting_day=(starting_day + 7 - (month_dict[prev_month][1] % 7)) % 7) # involves back of the napkin math, feel free to replace if you figure out a simpler method
            textbutton name action None xsize 200
            textbutton ">" action Show("calendar", month=next_month, starting_day=(starting_day+days) % 7)

        grid 7 6:
            style_prefix "calendar"
            for i in range(starting_day):
                textbutton "" action None
            for i in range(1, days+1):
                textbutton str(i) action NullAction():
                    if month == curr_month and i == curr_day: # to highlight
                        style "today"
            for i in range(42 - (starting_day+days)):
                textbutton "" action None

style button_text:
    xalign 0.5
    
style calendar_button is button
style calendar_button_text is button_text

style calendar_button:
    background Solid("#6666")
    insensitive_background None
    xsize 35
    ysize 35
    
style today is calendar_button
style today_text is calendar_button_text
   
style today_text:
    color "F00"

# starts with January 1 as "today"
default curr_month = 1
default curr_day = 1

label start:
    
    scene black
    show screen calendar(1, 1) # this means the calendar shows the first day of January as Monday

    "testing 1" 

    $ curr_month = 2
    $ curr_day = 3 # sets today to February 3 to show changed highlight

    "testing 2"

User avatar
Cherubunny
Regular
Posts: 26
Joined: Sat Feb 24, 2018 6:52 am
Tumblr: cherubunny
Deviantart: cherubunny
Contact:

Re: Calendar help?

#5 Post by Cherubunny »

Oh gosh, thank you a bunch; this looks so much cleaner already lol I will test this out when I can, but for now, I have one more question; do you know how I can hover over a certain date and display text about what holiday it is (In my image example, there's room at the bottom... So for example, I wanna know how I can get "Valentine's day" to show up in that spot when I hover over February 14)

User avatar
Cherubunny
Regular
Posts: 26
Joined: Sat Feb 24, 2018 6:52 am
Tumblr: cherubunny
Deviantart: cherubunny
Contact:

Re: Calendar help?

#6 Post by Cherubunny »

Image
THANK YOU SO MUCH!!! The calendar is functioning better than I could ever have hoped for! (24 is hovered by the way) (also ignore the fact I forgot to place in my SMTWTFS image lmao)
Now, I only have two small questions that I'm not sure how to go about...
1. Is it possible to hover over a date and display centered text on the bottom about what holiday it is? Also, is it possible to make holiday date squares be a different colour? (Ex. The Feb 14th, January 1st, etc. squares being yellow to signify they're a holiday)
2. Is it also possible to add a border to the textbuttons like in my first image? I think it had a cute aesthetic but if not I understand!
Thank you both so much again for your help! Here is what the code currently looks like for reference:

Code: Select all

default month_dict = {
    1:("January", 31),
    2:("February", 28),
    3:("March", 31),
    4:("April", 30),
    5:("May", 31),
    6:("June", 30),
    7:("July", 31),
    8:("August", 31),
    9:("September", 30),
    10:("October", 31),
    11:("November", 30),
    12:("December", 31),
}

screen calendar(month, starting_day): 
    # month is the month shown
    # starting_day is the first weekday of the month expressed as an integer (0 for Sunday, 6 for Saturday)
    default name = month_dict[month][0] 
    default days = month_dict[month][1]
    default prev_month = month-1 if month > 1 else 12
    default next_month = month+1 if month < 12 else 1
    
    window:
        style "mm_root"
        
    add "bg fly"
    
    imagemap:
        add "sweetly.png"
        ground "calendar_ground.png"
        idle "calendar_idle.png"
        hover "calendar_hover.png"
        selected_hover "calendar_selected.png"
        selected_idle "calendar_selectedhover.png"
        alpha True
        
        hotspot (190,457,109,112) action Return()
        hotspot (247,159,59,73) action Show("calendar", month=prev_month, starting_day=(starting_day + 7 - (month_dict[prev_month][1] % 7)) % 7) # involves back of the napkin math, feel free to replace if you figure out a simpler method
        hotspot (1063,159,59,73) action Show("calendar", month=next_month, starting_day=(starting_day+days) % 7)

    vbox:
        hbox:
            textbutton name action None xsize 893 ysize 89 xoffset 239 yoffset 9:
                style "name"

        grid 7 6:
            style_prefix "calendar"
            spacing 8
            xoffset 345
            yoffset 61
            for i in range(starting_day):
                textbutton "" action None
            for i in range(1, days+1):
                textbutton str(i) action NullAction():
                    if month == curr_month and i == curr_day: # to highlight
                        style "today"
            for i in range(42 - (starting_day+days)):
                textbutton "" action None

style button_text:
    xalign 0.5
    
style calendar_button is button
style calendar_button_text is button_text

style calendar_button:
    insensitive_background "#FD8A9D"
    background Solid("#FFFFFF")
    hover_background "#FFDCE2"
    xsize 90
    ysize 63
    
style calendar_button_text:
    size 40
    color "#843D69"  
    hover_outlines [ (2, "#FFFFFF", 0, 0) ]
    
style today is calendar_button
style today_text is calendar_button_text
   
style today_text:
    color "#FFDCE2"
    outlines [ (2, "#843D69", 0, 0) ]
    hover_color "#FFFFFF"
    
style name is today_button
style name_text is today_button_text

style name:
    bottom_padding 5
    background Solid("#FFDCE2")

style name_text:
    font "impact.ttf"
    size 80
    outlines [ (3, "#843D69", 0, 0) ]

# starts with January 1 as "today"
default curr_month = 1
default curr_day = 1

label start:
    
    scene black
    show screen calendar(1, 1) # this means the calendar shows the first day of January as Monday

    "testing 1" 

    $ curr_month = 2
    $ curr_day = 3 # sets today to February 3 to show changed highlight

    "testing 2"

    return

philat
Eileen-Class Veteran
Posts: 1910
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Calendar help?

#7 Post by philat »

1. Set hovered/unhovered actions to Show/Hide a screen with the relevant data as needed. https://www.renpy.org/doc/html/screens.html#textbutton

For holidays, it's basically the same concept as highlighting today. Something like, make a list of holidays (e..g, holidays = [(1, 1), (2, 14)]) and use that to apply a different style.

Code: Select all

if (month, i) in holidays:
    style "holiday"
2. You could have the larger border color squares on the background and make the textbuttons smaller. Or you could make an image (border+square) and replace your backgrounds with the images.

User avatar
Cherubunny
Regular
Posts: 26
Joined: Sat Feb 24, 2018 6:52 am
Tumblr: cherubunny
Deviantart: cherubunny
Contact:

Re: Calendar help?

#8 Post by Cherubunny »

Thank you so much! But now that I have integrated my calendar in with the rest of my code, I get this error?

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/00gamemenu.rpy", line 173, in <module>
    $ ui.interact()
Exception: Required parameter month has no value.

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "lib/windows-i686/00gamemenu.rpyc", line 173, in script
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\ast.py", line 814, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\python.py", line 1719, in py_exec_bytecode
    exec bytecode in globals, locals
  File "renpy/common/00gamemenu.rpy", line 173, in <module>
    $ ui.interact()
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\ui.py", line 285, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\display\core.py", line 2526, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\display\core.py", line 2793, in interact_core
    root_widget.visit_all(lambda i : i.per_interact())
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\display\core.py", line 495, in visit_all
    d.visit_all(callback)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\display\core.py", line 495, in visit_all
    d.visit_all(callback)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\display\core.py", line 495, in visit_all
    d.visit_all(callback)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\display\core.py", line 495, in visit_all
    d.visit_all(callback)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\display\screen.py", line 399, in visit_all
    callback(self)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\display\core.py", line 2793, in <lambda>
    root_widget.visit_all(lambda i : i.per_interact())
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\display\screen.py", line 409, in per_interact
    self.update()
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\display\screen.py", line 578, in update
    self.screen.function(**self.scope)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\ast.py", line 152, in apply_arguments
    return parameters.apply(args, kwargs, ignore_errors)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\ast.py", line 120, in apply
    raise Exception("Required parameter %s has no value." % name)
Exception: Required parameter month has no value.

Windows-8-6.2.9200
Ren'Py 6.99.12.4.2187
Sweet Heaven 0.0
I know that it has something to do with this

Code: Select all

screen quick_menu():
    
    imagemap:
        ground "qm_ground.png"
        idle "qm_idle.png"
        hover "qm_hover.png"
        selected_idle "auto_selected.png"
        selected_hover "auto_selected.png"
        alpha False
        
        hotspot (892,692,114,71) action Skip()
        hotspot (1006,689,79,74) action QuickSave(message=u'Save complete!', newest=True)
        hotspot (1095,687,90,74) action ShowMenu("calendar")
        hotspot (1188,683,74,80) action ShowMenu("preferences")
        hotspot (1271,689,80,70) action ShowMenu("preferences")
But I'm... not really sure how to fix it? My other code is still the same as above, I'm not quite sure what to fix?

User avatar
Cherubunny
Regular
Posts: 26
Joined: Sat Feb 24, 2018 6:52 am
Tumblr: cherubunny
Deviantart: cherubunny
Contact:

Re: Calendar help?

#9 Post by Cherubunny »

bonus update:
Image
Image
Works perfectly, I even added an extra style called holitoday that makes the outline dark to show that it's today and also a holiday! Gonna do the hover/unhovered show/hide thing next! (I actually figured that's how I would do it, but I wasn't too sure with how to define the holidays and such! Things make sense now!)

User avatar
Cherubunny
Regular
Posts: 26
Joined: Sat Feb 24, 2018 6:52 am
Tumblr: cherubunny
Deviantart: cherubunny
Contact:

Re: Calendar help?

#10 Post by Cherubunny »

I'm still really unsure why the code won't work when I try to access it from its calendar icon... Here's the error message:

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/00action_control.rpy", line 108, in __call__
    renpy.show_screen(self.screen, *self.args, **self.kwargs)
Exception: Screen calendar(month, is not known.


-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "lib/windows-i686/script.rpyc", line 179, in script
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\ast.py", line 613, in execute
    renpy.exports.say(who, what, interact=self.interact)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\exports.py", line 1147, in say
    who(what, interact=interact)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\character.py", line 877, in __call__
    self.do_display(who, what, cb_args=self.cb_args, **display_args)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\character.py", line 716, in do_display
    **display_args)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\character.py", line 508, in display_say
    rv = renpy.ui.interact(mouse='say', type=type, roll_forward=roll_forward)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\ui.py", line 285, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\display\core.py", line 2526, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\display\core.py", line 3204, in interact_core
    rv = root_widget.event(ev, x, y, 0)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\display\layout.py", line 960, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\display\layout.py", line 960, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\display\layout.py", line 960, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\display\screen.py", line 651, in event
    rv = self.child.event(ev, x, y, st)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\display\layout.py", line 960, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\display\layout.py", line 960, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\display\layout.py", line 960, in event
    rv = i.event(ev, x - xo, y - yo, cst)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\display\behavior.py", line 889, in event
    return handle_click(self.clicked)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\display\behavior.py", line 824, in handle_click
    rv = run(action)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\display\behavior.py", line 306, in run
    return action(*args, **kwargs)
  File "renpy/common/00action_control.rpy", line 108, in __call__
    renpy.show_screen(self.screen, *self.args, **self.kwargs)
  File "C:\Users\Stein\Downloads\renpy-6.99.12.4-sdk\renpy\display\screen.py", line 1012, in show_screen
    raise Exception("Screen %s is not known.\n" % (name[0],))
Exception: Screen calendar(month, is not known.


Windows-8-6.2.9200
Ren'Py 6.99.12.4.2187
Sweet Heaven 0.0
Here's the code:

Code: Select all

default month_dict = {
    1:("January", 31),
    2:("February", 28),
    3:("March", 31),
    4:("April", 30),
    5:("May", 31),
    6:("June", 30),
    7:("July", 31),
    8:("August", 31),
    9:("September", 30),
    10:("October", 31),
    11:("November", 30),
    12:("December", 31),
}

default holidays = [(1, 1), (2, 14)]

screen calendar(month, starting_day): 
    # month is the month shown
    # starting_day is the first weekday of the month expressed as an integer (0 for Sunday, 6 for Saturday)
    # starts with January 1 as "today"
    default curr_month = 1
    default curr_day = 1
    default name = month_dict[month][0] 
    default days = month_dict[month][1]
    default prev_month = month-1 if month > 1 else 12
    default next_month = month+1 if month < 12 else 1
    
    window:
        style "mm_root"
        
    add "bg fly"
    
    imagemap:
        add "smtwtfs.png"
        ground "calendar_ground.png"
        idle "calendar_idle.png"
        hover "calendar_hover.png"
        selected_hover "calendar_selected.png"
        selected_idle "calendar_selectedhover.png"
        alpha True
        
        hotspot (190,457,109,112) action Return()
        hotspot (247,159,59,73) action Show("calendar", month=prev_month, starting_day=(starting_day + 7 - (month_dict[prev_month][1] % 7)) % 7) # involves back of the napkin math, feel free to replace if you figure out a simpler method
        hotspot (1063,159,59,73) action Show("calendar", month=next_month, starting_day=(starting_day+days) % 7)

    vbox:
        hbox:
            textbutton name action None xsize 893 ysize 89 xoffset 239 yoffset 9:
                style "name"

        grid 7 6:
            style_prefix "calendar"
            spacing 8
            xoffset 345
            yoffset 61
            for i in range(starting_day):
                textbutton "" action None
            for i in range(1, days+1):
                textbutton str(i) action NullAction():
                    if month == curr_month and i == curr_day: # to highlight
                        style "today"
                    if (month, i) in holidays:
                        style "holiday"
                    if (month, i) in holidays and month == curr_month and i == curr_day:
                        style "holitoday"                        
            for i in range(42 - (starting_day+days)):
                textbutton "" action None

style button_text:
    xalign 0.5
    
style calendar_button is button
style calendar_button_text is button_text

style calendar_button:
    insensitive_background "#FD8A9D"
    background Solid("#FFFFFF")
    hover_background "#FFDCE2"
    xsize 90
    ysize 63
    
style calendar_button_text:
    size 40
    color "#843D69"  
    hover_outlines [ (3, "#FFFFFF", 0, 0) ]
    
style today is calendar_button
style today_text is calendar_button_text
   
style today_text:
    color "#FFDCE2"
    outlines [ (3, "#843D69", 0, 0) ]
    hover_color "#FFFFFF"
    
style name is today_button
style name_text is today_button_text

style name:
    bottom_padding 5
    background Solid("#FFDCE2")

style name_text:
    font "impact.ttf"
    size 80
    outlines [ (3, "#843D69", 0, 0) ]
    
style holiday is calendar_button
style holiday_text is calendar_button_text

define val = "valday.png"

style holiday:
    background Solid("#FFFACD")
    hover_background Solid("#FFDCE2")
        if (1,1) in holidays:
            hovered action show val
            unhovered action hide val
            
style holiday_text:
    color "#FD8A9D"
    outlines [ (3, "#FFFFFF", 0, 0) ]
    hover_color "#FD8A9D"
    
style holitoday is calendar_button
style holitoday_text is calendar_button_text

style holitoday:
    background Solid("#FFFACD")
    hover_background Solid("#FFDCE2")

style holitoday_text:
    color "#FD8A9D"
    outlines [ (3, "#843D69", 0, 0) ]
    hover_color "#FD8A9D"

label calendar(month, starting_day): 
    call screen calendar(1,1)

Code: Select all

screen quick_menu():
    
    imagemap:
        ground "qm_ground.png"
        idle "qm_idle.png"
        hover "qm_hover.png"
        selected_idle "auto_selected.png"
        selected_hover "auto_selected.png"
        alpha False
        
        hotspot (892,692,114,71) action Skip()
        hotspot (1006,689,79,74) action QuickSave(message=u'Save complete!', newest=True)
        hotspot (1095,687,90,74) action Show("calendar(month, starting_day)")
        hotspot (1188,683,74,80) action ShowMenu("preferences")
        hotspot (1271,689,80,70) action ShowMenu("preferences")

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Calendar help?

#11 Post by trooper6 »

At a quick glance, you can't have two different things with the same name. You have a screen called calendar and you have a label called calendar. Try renaming one of them something else.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

philat
Eileen-Class Veteran
Posts: 1910
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Calendar help?

#12 Post by philat »

Cherubunny wrote: Sun Apr 15, 2018 11:10 pm

Code: Select all

        hotspot (1095,687,90,74) action Show("calendar(month, starting_day)")

Code: Select all

    hotspot (1095,687,90,74) action Show("calendar", month=somevariable, starting_day=somevariable)

User avatar
Cherubunny
Regular
Posts: 26
Joined: Sat Feb 24, 2018 6:52 am
Tumblr: cherubunny
Deviantart: cherubunny
Contact:

Re: Calendar help?

#13 Post by Cherubunny »

Making it just screen helped as well as defining month and starting_day with a variable, but my problem with that solution is that I want the calendar to change what month/day are shown when clicked depending on what the ingame day is and I don't know how to do that? For example, I can set it to:
month=1, starting_day=1
But what about when the month is February? Is there a way I can have it display the month depending on what month it is?

EDIT: NVM I GOT THAT FIXED!! I had to set it to:
month=curr_month, starting_day=curr_day
I'm so silly lmao

philat
Eileen-Class Veteran
Posts: 1910
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Calendar help? [SOLVED]

#14 Post by philat »

starting_day is the first day of the month (i.e., it decides how many empty boxes on the top row before the first day of the month). If the current day is larger than 6, the whole thing will throw an error. I don't know how you want to go about this, but for example, you could use the dictionary to set the starting_day for a given month.

User avatar
Cherubunny
Regular
Posts: 26
Joined: Sat Feb 24, 2018 6:52 am
Tumblr: cherubunny
Deviantart: cherubunny
Contact:

Re: Calendar help? [SOLVED]

#15 Post by Cherubunny »

I'm not sure how I'd go about using a dictionary for that? Cause I assume it'd be similar to the month_dict but I'm not sure how I'd be able to do that and maybe even take in to account leapyears?

Post Reply

Who is online

Users browsing this forum: Sugar_and_rice