├── .gitignore
├── pygame
├── Scene.pyc
├── Ubuntu-M.ttf
├── refinery.png
├── ControlsScreen.pyc
├── Scene.py
├── Start.py
├── ubuntu-font-licence-1.0.txt
├── gray.svg
├── ControlsScreen.py
└── onyx.svg
├── renpy-p4
├── calendar.zip
├── img
│ ├── bg.png
│ ├── rain.png
│ ├── sun.png
│ ├── 21 Wed.png
│ ├── break.png
│ ├── cloud.png
│ ├── sun_cloud.png
│ ├── sun_focus.png
│ ├── x75
│ │ ├── cloud.png
│ │ ├── rain.png
│ │ ├── sun.png
│ │ ├── rain_cloud.png
│ │ ├── rain_focus.png
│ │ ├── sun_cloud.png
│ │ ├── sun_focus.png
│ │ ├── cloud_focus.png
│ │ ├── sun_cloud_focus.png
│ │ └── rain_cloud_focus.png
│ ├── cloud_focus.png
│ ├── rain_cloud.png
│ ├── rain_focus.png
│ ├── Background Monat.png
│ ├── rain_cloud_focus.png
│ └── sun_cloud_focus.png
├── lastunif.ttf
├── calendar.rpyc
└── calendar.rpy
├── renpy
├── 1280x960
│ ├── gray.png
│ ├── onyx.png
│ └── HomeStreet_01.png
├── 800x600
│ ├── gray.png
│ ├── onyx.png
│ └── HomeStreet_01.png
└── calendar.rpy
├── renpy-6.99
├── 1280x720
│ ├── bg.png
│ └── gray.png
└── calendar.rpy
├── renpy-atl
├── 1280x720
│ ├── bg.png
│ ├── bg.xcf
│ ├── gray.png
│ └── gray2.png
└── calendar.rpy
├── resource-licenses.md
├── LICENSE
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | *.rpyc
2 |
--------------------------------------------------------------------------------
/pygame/Scene.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/pygame/Scene.pyc
--------------------------------------------------------------------------------
/pygame/Ubuntu-M.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/pygame/Ubuntu-M.ttf
--------------------------------------------------------------------------------
/pygame/refinery.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/pygame/refinery.png
--------------------------------------------------------------------------------
/renpy-p4/calendar.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-p4/calendar.zip
--------------------------------------------------------------------------------
/renpy-p4/img/bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-p4/img/bg.png
--------------------------------------------------------------------------------
/renpy-p4/img/rain.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-p4/img/rain.png
--------------------------------------------------------------------------------
/renpy-p4/img/sun.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-p4/img/sun.png
--------------------------------------------------------------------------------
/renpy-p4/lastunif.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-p4/lastunif.ttf
--------------------------------------------------------------------------------
/renpy-p4/calendar.rpyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-p4/calendar.rpyc
--------------------------------------------------------------------------------
/renpy-p4/img/21 Wed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-p4/img/21 Wed.png
--------------------------------------------------------------------------------
/renpy-p4/img/break.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-p4/img/break.png
--------------------------------------------------------------------------------
/renpy-p4/img/cloud.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-p4/img/cloud.png
--------------------------------------------------------------------------------
/renpy/1280x960/gray.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy/1280x960/gray.png
--------------------------------------------------------------------------------
/renpy/1280x960/onyx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy/1280x960/onyx.png
--------------------------------------------------------------------------------
/renpy/800x600/gray.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy/800x600/gray.png
--------------------------------------------------------------------------------
/renpy/800x600/onyx.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy/800x600/onyx.png
--------------------------------------------------------------------------------
/pygame/ControlsScreen.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/pygame/ControlsScreen.pyc
--------------------------------------------------------------------------------
/renpy-6.99/1280x720/bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-6.99/1280x720/bg.png
--------------------------------------------------------------------------------
/renpy-atl/1280x720/bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-atl/1280x720/bg.png
--------------------------------------------------------------------------------
/renpy-atl/1280x720/bg.xcf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-atl/1280x720/bg.xcf
--------------------------------------------------------------------------------
/renpy-p4/img/sun_cloud.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-p4/img/sun_cloud.png
--------------------------------------------------------------------------------
/renpy-p4/img/sun_focus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-p4/img/sun_focus.png
--------------------------------------------------------------------------------
/renpy-p4/img/x75/cloud.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-p4/img/x75/cloud.png
--------------------------------------------------------------------------------
/renpy-p4/img/x75/rain.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-p4/img/x75/rain.png
--------------------------------------------------------------------------------
/renpy-p4/img/x75/sun.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-p4/img/x75/sun.png
--------------------------------------------------------------------------------
/renpy-6.99/1280x720/gray.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-6.99/1280x720/gray.png
--------------------------------------------------------------------------------
/renpy-atl/1280x720/gray.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-atl/1280x720/gray.png
--------------------------------------------------------------------------------
/renpy-atl/1280x720/gray2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-atl/1280x720/gray2.png
--------------------------------------------------------------------------------
/renpy-p4/img/cloud_focus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-p4/img/cloud_focus.png
--------------------------------------------------------------------------------
/renpy-p4/img/rain_cloud.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-p4/img/rain_cloud.png
--------------------------------------------------------------------------------
/renpy-p4/img/rain_focus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-p4/img/rain_focus.png
--------------------------------------------------------------------------------
/renpy-p4/img/x75/rain_cloud.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-p4/img/x75/rain_cloud.png
--------------------------------------------------------------------------------
/renpy-p4/img/x75/rain_focus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-p4/img/x75/rain_focus.png
--------------------------------------------------------------------------------
/renpy-p4/img/x75/sun_cloud.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-p4/img/x75/sun_cloud.png
--------------------------------------------------------------------------------
/renpy-p4/img/x75/sun_focus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-p4/img/x75/sun_focus.png
--------------------------------------------------------------------------------
/renpy/800x600/HomeStreet_01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy/800x600/HomeStreet_01.png
--------------------------------------------------------------------------------
/renpy-p4/img/Background Monat.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-p4/img/Background Monat.png
--------------------------------------------------------------------------------
/renpy-p4/img/rain_cloud_focus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-p4/img/rain_cloud_focus.png
--------------------------------------------------------------------------------
/renpy-p4/img/sun_cloud_focus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-p4/img/sun_cloud_focus.png
--------------------------------------------------------------------------------
/renpy-p4/img/x75/cloud_focus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-p4/img/x75/cloud_focus.png
--------------------------------------------------------------------------------
/renpy/1280x960/HomeStreet_01.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy/1280x960/HomeStreet_01.png
--------------------------------------------------------------------------------
/renpy-p4/img/x75/sun_cloud_focus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-p4/img/x75/sun_cloud_focus.png
--------------------------------------------------------------------------------
/renpy-p4/img/x75/rain_cloud_focus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/koroshiya/python-calendar/HEAD/renpy-p4/img/x75/rain_cloud_focus.png
--------------------------------------------------------------------------------
/pygame/Scene.py:
--------------------------------------------------------------------------------
1 | class Scene(object):
2 | def __init__(self):
3 | pass
4 |
5 | def render(self, screen):
6 | raise NotImplementedError
7 |
8 | def update(self):
9 | raise NotImplementedError
10 |
11 | def handle_event(self, event):
12 | raise NotImplementedError
13 |
14 | def processEvent(self, arg):
15 | raise NotImplementedError
--------------------------------------------------------------------------------
/resource-licenses.md:
--------------------------------------------------------------------------------
1 | This project itself (specifically the code) is licensed under MIT, but the individual resources vary.
2 |
3 | Within the pygame folder there is an included font (Ubuntu-M.ttf) with its own license (ubuntu-font-licence-1.0.txt). The font is currently in use, but can be removed very easily if you do not wish to include the font and its license.
4 |
5 | The gray.svg, onyx.svg and refinery.png files are all public domain image files.
6 | You can use them freely anywhere for anything, commercial or free, without restriction.
7 | The same applies to the gray.png and onyx.png files within the renpy directory.
8 | All of the above image files (except gray.svg) have been modified and are thus technically derivative works, but I am releasing them back into the public domain anyway.
9 |
10 | HomeStreet_01.png is a photo I took myself and then filtered/resized. As with the others, I'm licensing it under the public domain.
--------------------------------------------------------------------------------
/pygame/Start.py:
--------------------------------------------------------------------------------
1 | import pygame
2 | from pygame.locals import Color
3 | from pygame import key
4 | import ControlsScreen
5 |
6 | pygame.init()
7 | pygame.font.init()
8 |
9 | size = (800, 600)
10 | screen = pygame.display.set_mode(size)
11 | pygame.display.set_caption("Persona 4 Calendar")
12 |
13 | done = False
14 | clock = pygame.time.Clock()
15 | print pygame.display.list_modes()
16 | print pygame.version
17 |
18 | scene = ControlsScreen.ControlsScreen(size)
19 | # -------- Main Program Loop -----------
20 | while not done:
21 | # ALL EVENT PROCESSING SHOULD GO BELOW THIS COMMENT
22 | for event in pygame.event.get(): # User did something
23 | if event.type == pygame.QUIT:
24 | done = True
25 | elif event.type == pygame.KEYDOWN:
26 | #evt = scene.handle_event(event)
27 | #TODO: next day, lock until done
28 | if event.key == pygame.K_RIGHT:
29 | scene.moveRight()
30 | elif event.key == pygame.K_LEFT:
31 | scene.moveLeft()
32 | pass
33 | scene.update()
34 | scene.render(screen)
35 | clock.tick(60)
36 |
37 | pygame.quit()
38 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 koroshiya
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | python-calendar
2 | ===============
3 | Game transition calendar written in python.
4 |
5 | The aim of this project is to provide a day to day calendar to show
6 | time transitions using basic animation.
7 | By adding the relevant resources to a project, a developer can add
8 | the calendar's functionality to their own game.
9 | eg. Someone writing a Ren'Py Visual Novel could easily integrate the
10 | resources in the renpy-atl folder, then call the required function to graphically
11 | express the transition from one day to the next between scenes/labels.
12 |
13 | There are currently 2 supported engines: Ren'Py and PyGame.
14 | The differences between the two are as follows.
15 |
16 | The PyGame module includes support for:
17 |
18 |
repeating backgrounds
19 |
SVG graphics
20 |
multiple, non-standard resolutions
21 |
keystroke control to change days
22 |
23 | You should also note that, in its current state, the PyGame module is more
24 | of a demo than a resource to be included directly into a project. It would need
25 | to be modified to work the same as the Ren'Py module.
26 |
27 | The Ren'Py module is:
28 |
29 |
more portable
30 |
well-documented
31 |
more up to date (ie. contains more features & settings)
32 |
33 | The main advantage of the Ren'Py game module is how simple it is to use.
34 | Simply copy the included files into the main folder of the "game" folder of your project and follow the instructions in the documentation.
35 |
36 | Also worthy of note is the fact that the code for the PyGame module is currently much cleaner, and has been tested far more, but isn't documented.
37 |
38 |
How to use
39 |
Ren'Py
40 | Thorough instructions are included in the calendar.rpy file, but basically:
41 |
42 |
Copy the files from the renpy directory into your project's game folder
43 |
44 | When you want to invoke the calendar for the first time, set the relevant variables.
45 | In old versions, these are: dayofweek, dayofmonth, month, direction and label_cont.
46 | In 6.99, there's just the one variable: calDate.
47 |
48 |
Call or Jump to "calendar", depending on the version used
49 |
50 | and that's it. For a more in-depth explanation, as well as a list of the different settings available, please read the comments within the relevant calendar.rpy file.
51 |
PyGame
52 | At this point in time, PyGame can't just be dragged and dropped into a project.
53 | Instead, the PyGame module is currently a standalone demo.
54 | Simply run the Start.py file and use the left and right arrows to back and forward between days. You can change the values in self.move(int) within moveLeft() and moveRight() to change how many days forward or backward keystrokes will take you.
55 |
56 |
Which Renpy calendar version to use
57 |
58 | In general, you should use whatever version is the newest.
59 | At the time of writing, renpy-6.99 is the most recent version, and is compatible with Renpy version 6.99 and later. If you are running an older version of Renpy, you should update and use this version.
--------------------------------------------------------------------------------
/pygame/ubuntu-font-licence-1.0.txt:
--------------------------------------------------------------------------------
1 | -------------------------------
2 | UBUNTU FONT LICENCE Version 1.0
3 | -------------------------------
4 |
5 | PREAMBLE
6 | This licence allows the licensed fonts to be used, studied, modified and
7 | redistributed freely. The fonts, including any derivative works, can be
8 | bundled, embedded, and redistributed provided the terms of this licence
9 | are met. The fonts and derivatives, however, cannot be released under
10 | any other licence. The requirement for fonts to remain under this
11 | licence does not require any document created using the fonts or their
12 | derivatives to be published under this licence, as long as the primary
13 | purpose of the document is not to be a vehicle for the distribution of
14 | the fonts.
15 |
16 | DEFINITIONS
17 | "Font Software" refers to the set of files released by the Copyright
18 | Holder(s) under this licence and clearly marked as such. This may
19 | include source files, build scripts and documentation.
20 |
21 | "Original Version" refers to the collection of Font Software components
22 | as received under this licence.
23 |
24 | "Modified Version" refers to any derivative made by adding to, deleting,
25 | or substituting -- in part or in whole -- any of the components of the
26 | Original Version, by changing formats or by porting the Font Software to
27 | a new environment.
28 |
29 | "Copyright Holder(s)" refers to all individuals and companies who have a
30 | copyright ownership of the Font Software.
31 |
32 | "Substantially Changed" refers to Modified Versions which can be easily
33 | identified as dissimilar to the Font Software by users of the Font
34 | Software comparing the Original Version with the Modified Version.
35 |
36 | To "Propagate" a work means to do anything with it that, without
37 | permission, would make you directly or secondarily liable for
38 | infringement under applicable copyright law, except executing it on a
39 | computer or modifying a private copy. Propagation includes copying,
40 | distribution (with or without modification and with or without charging
41 | a redistribution fee), making available to the public, and in some
42 | countries other activities as well.
43 |
44 | PERMISSION & CONDITIONS
45 | This licence does not grant any rights under trademark law and all such
46 | rights are reserved.
47 |
48 | Permission is hereby granted, free of charge, to any person obtaining a
49 | copy of the Font Software, to propagate the Font Software, subject to
50 | the below conditions:
51 |
52 | 1) Each copy of the Font Software must contain the above copyright
53 | notice and this licence. These can be included either as stand-alone
54 | text files, human-readable headers or in the appropriate machine-
55 | readable metadata fields within text or binary files as long as those
56 | fields can be easily viewed by the user.
57 |
58 | 2) The font name complies with the following:
59 | (a) The Original Version must retain its name, unmodified.
60 | (b) Modified Versions which are Substantially Changed must be renamed to
61 | avoid use of the name of the Original Version or similar names entirely.
62 | (c) Modified Versions which are not Substantially Changed must be
63 | renamed to both (i) retain the name of the Original Version and (ii) add
64 | additional naming elements to distinguish the Modified Version from the
65 | Original Version. The name of such Modified Versions must be the name of
66 | the Original Version, with "derivative X" where X represents the name of
67 | the new work, appended to that name.
68 |
69 | 3) The name(s) of the Copyright Holder(s) and any contributor to the
70 | Font Software shall not be used to promote, endorse or advertise any
71 | Modified Version, except (i) as required by this licence, (ii) to
72 | acknowledge the contribution(s) of the Copyright Holder(s) or (iii) with
73 | their explicit written permission.
74 |
75 | 4) The Font Software, modified or unmodified, in part or in whole, must
76 | be distributed entirely under this licence, and must not be distributed
77 | under any other licence. The requirement for fonts to remain under this
78 | licence does not affect any document created using the Font Software,
79 | except any version of the Font Software extracted from a document
80 | created using the Font Software may only be distributed under this
81 | licence.
82 |
83 | TERMINATION
84 | This licence becomes null and void if any of the above conditions are
85 | not met.
86 |
87 | DISCLAIMER
88 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
89 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
90 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
91 | COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
92 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
93 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
94 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
95 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER
96 | DEALINGS IN THE FONT SOFTWARE.
97 |
--------------------------------------------------------------------------------
/pygame/gray.svg:
--------------------------------------------------------------------------------
1 |
2 |
158 |
--------------------------------------------------------------------------------
/pygame/ControlsScreen.py:
--------------------------------------------------------------------------------
1 | from __future__ import division
2 | import pygame
3 | from pygame.locals import Color
4 | from pygame import key
5 | import Scene
6 | import math
7 | import cairo
8 | import rsvg
9 | import array
10 |
11 | class ControlsScreen(Scene.Scene):
12 |
13 | def __init__(self, size):
14 | super(ControlsScreen, self).__init__()
15 |
16 | screen = pygame.display.set_mode(size, pygame.HWSURFACE|pygame.DOUBLEBUF)
17 |
18 | #screen.fill(white)
19 | self.bg = pygame.image.load('./refinery.png').convert() #repeating bg
20 | for x in range(0, screen.get_width(), self.bg.get_width()):
21 | for y in range(0, screen.get_height(), self.bg.get_height()):
22 | screen.blit(self.bg, (x,y))
23 | self.bgcache = screen.copy()
24 | pygame.display.flip()
25 |
26 | self.months = [
27 | ["January", 31],
28 | ["February", 28],
29 | ["March", 31],
30 | ["April", 30],
31 | ["May", 31],
32 | ["June", 30],
33 | ["July", 31],
34 | ["August", 31],
35 | ["September", 30],
36 | ["October", 31],
37 | ["November", 30],
38 | ["December", 31]
39 | ]
40 | self.month = 5
41 | self.oldmonth = 5
42 |
43 | self.loadText(screen, 48, self.months[self.month][0], (50, 25), 100, 100)
44 |
45 | newsize = screen.get_height() / 4
46 | self.scalesize = newsize * 2 / 3
47 | self.scalesize = int(math.floor(self.scalesize))
48 | self.btn = self.loadsvg('./gray.svg', screen, self.scalesize)
49 |
50 | self.imgSize = newsize #width of button; should be same as height
51 | self.baseX = screen.get_width() / 2 - 9 * self.imgSize / 2
52 | posX = self.baseX
53 | self.posY = screen.get_height() / 2 - 96 / 2
54 |
55 | self.dayofmonth = 29
56 | self.direction = 1
57 |
58 | for i in xrange(-3, 7):
59 | screen.blit(self.btn, (posX, self.posY))
60 | self.loadText(screen, 24, self.getRelativeDay(i, True), (posX, self.posY), self.scalesize, self.scalesize)
61 | posX += self.imgSize
62 |
63 | self.frame = self.loadsvg('./onyx.svg', screen, self.scalesize + self.scalesize / 10)
64 | self.framepos = (screen.get_width() / 2 - self.imgSize / 2 - self.imgSize / 25, self.posY - 3)
65 | screen.blit(self.frame, self.framepos)
66 |
67 | pygame.display.update()
68 | self.curmove = self.imgSize
69 | self.moved = 0
70 | self.moving = False
71 | self.lastMove = False
72 | self.nextMonth = False
73 | self.monthPos = 25
74 | self.monthHalf = False
75 | self.speed = self.imgSize / 30
76 | self.curmonth = "June"
77 |
78 | def getRelativeDay(self, mv, boolStart):
79 | if boolStart:
80 | start = self.dayofmonth - 1
81 | else:
82 | start = self.dayofmonth - 2 if self.direction > 0 else self.dayofmonth
83 | newVal = start + mv
84 | if newVal < 1:
85 | if self.month == 0:
86 | newVal = self.months[11][1] + newVal
87 | else:
88 | newVal = self.months[self.month - 1][1] + newVal
89 | elif newVal > self.months[self.month][1]:
90 | newVal -= self.months[self.month][1]
91 |
92 | return str(newVal)
93 |
94 | def render(self, screen):
95 | if self.moving:
96 | screen.blit(self.bgcache, (0, 0))
97 | #start animation
98 | #screen.blit(self.getTextAsImage(self.months[self.month][0]), (50, self.monthPos))
99 | month = self.oldmonth if not self.monthHalf else self.month
100 | self.loadText(screen, 48, self.months[month][0], (50, self.monthPos), 200, 100) #TODO month
101 |
102 | posX = self.baseX - self.curmove
103 | for i in xrange(-3, 7):
104 | screen.blit(self.btn, (posX, self.posY))
105 | self.loadText(screen, 24, self.getRelativeDay(i, False), (posX, self.posY), self.scalesize, self.scalesize)
106 | posX += self.imgSize
107 | screen.blit(self.frame, self.framepos)
108 | if self.lastMove:
109 | self.moving = False
110 | self.lastMove = False
111 | if not math.fabs(self.curmove) >= self.imgSize * math.fabs(self.direction):
112 | if self.direction > 0:
113 | self.direction -= 1
114 | elif self.direction < 0:
115 | self.direction += 1
116 | self.move(self.direction)
117 | if self.nextMonth:
118 | self.monthHalf = False
119 | self.nextMonth = False
120 | self.oldmonth = self.month
121 |
122 | pygame.display.update()
123 |
124 | def loadText(self, screen, size, text, pos, targetWidth, targetHeight):
125 | font_path = "./Ubuntu-M.ttf"
126 | fontObj = pygame.font.Font(font_path, size)
127 |
128 | txt = fontObj.render(text, 1, (255,255,255))
129 | fSize = fontObj.size(text)
130 | fPos = (pos[0] + ((targetWidth - fSize[0]) / 2), pos[1] + ((targetHeight - fSize[1]) / 2))
131 | screen.blit(txt, fPos)
132 |
133 | def update(self):
134 | if self.moving:
135 | self.curmove += self.speed * self.direction
136 | if math.fabs(self.curmove) >= self.imgSize:
137 | self.lastMove = True
138 |
139 | def moveRight(self):
140 | self.move(25)
141 |
142 | def moveLeft(self):
143 | self.move(-25)
144 |
145 | def move(self, direction):
146 | if not self.moving:
147 | self.direction = direction
148 | self.curmove = 0
149 | self.moving = True
150 | if direction > 0:
151 | if self.dayofmonth < self.months[self.month][1]:
152 | self.dayofmonth += 1
153 | else:
154 | self.dayofmonth = 1
155 | self.nextMonth = True
156 | self.oldmonth = self.month
157 | if self.month == 11:
158 | self.month = 0
159 | else:
160 | self.month += 1
161 | else:
162 | if self.dayofmonth == 1:
163 | self.nextMonth = True
164 | self.oldmonth = self.month
165 | if self.month == 0:
166 | self.month = 11
167 | else:
168 | self.month -= 1
169 | if self.oldmonth == 0:
170 | self.dayofmonth = self.months[11][1]
171 | else:
172 | self.dayofmonth = self.months[self.month][1]
173 | else:
174 | self.dayofmonth -= 1
175 |
176 | def handle_event(self, event):
177 | pass
178 |
179 | def processEvent(self, arg):
180 | pass
181 |
182 | def processKey(self, arg):
183 | return self.processEvent(arg)
184 |
185 | def loadsvg(self, filename, surface, targetWidth):
186 | WIDTH = surface.get_width()
187 | HEIGHT = surface.get_height()
188 | data = array.array('c', chr(0) * WIDTH * HEIGHT * 4)
189 | cairosurface = cairo.ImageSurface.create_for_data(data, cairo.FORMAT_ARGB32, WIDTH, HEIGHT, WIDTH * 4)
190 | svg = rsvg.Handle(filename)
191 |
192 | dimens = svg.get_dimension_data()
193 | scale = targetWidth / dimens[0]
194 | targetHeight = scale * dimens[1]
195 | ctx = cairo.Context(cairosurface)
196 | if scale != 1:
197 | ctx.scale(scale, scale)
198 | svg.render_cairo(ctx)
199 | image = pygame.image.frombuffer(data.tostring(), (WIDTH, HEIGHT),"RGBA")
200 | print "displaying image at", WIDTH, HEIGHT
201 | return image
202 |
--------------------------------------------------------------------------------
/renpy-6.99/calendar.rpy:
--------------------------------------------------------------------------------
1 | ########
2 | #calendar.rpy
3 | #
4 | #Purpose: To provide a Persona 4-like day to day transition screen.
5 | #
6 | #How to include: Simply place this file in the "game" folder of your
7 | #RenPy game. This is the folder with options.rpy, script.rpy, etc.
8 | #You should also include relevant images, as defined in this script.
9 | #
10 | #How to use: Before running this script, you should set the default time.
11 | #This is done like so: calDate.replace(second=0, hour=5, minute=0, day=1, month=1, year=2014)
12 | #The arguments passed in are self-explanatory.
13 | #
14 | #There are several other settings you can tweak as well. For example,
15 | #the intDelay variable. This determines how long in seconds the calendar
16 | #will display for after finishing the animation.
17 | #
18 | #After you've overridden the desired variables and set the start time/date,
19 | #you're ready to show the calendar. Simply use the call command
20 | #to invoke the calendar label. The animation will run, it will wait intDelay
21 | #seconds, then continue with the game.
22 | #
23 | #A full example of the calendar being used is shown below.
24 | #This entails a very basic script.rpy file.
25 | #We start at the start label and set the date to Monday January 1st.
26 | #We then call calendar, which moves us forward 2 days to Wednesday
27 | #January 3rd.
28 | #
29 | #label start:
30 | # $ calDate = calDate.replace(second=10, hour=12, minute=30, day=1, month=1, year=2014)
31 | #
32 | # call calendar(2)
33 | #
34 | ########
35 |
36 | ###
37 | #Time variables
38 | #
39 | #These variables are used to depict dates and show transitions
40 | #from one day to the next. They should be set manually once,
41 | #after which the calendar will automatically update the values
42 | #as it is used.
43 | #
44 | #These variables can be set again if you wish to change the date
45 | #between instances of the calendar being shown.
46 | #eg. The date could be set to Jan 1st, the calendar is called and
47 | #moves the date forward 2 days. Then, in-game, the date variables
48 | #are changed to March 5th, and the next time the calendar is shown
49 | #it will start at March 5th instead. Like so:
50 | #
51 | #Example:
52 | #
53 | # $ calDate.replace(day=1, month=1)
54 | # call calendar(2) #Moves from Jan 1st to Jan 3rd
55 | #
56 | # $ calDate.replace(day=5, month=3)
57 | # call calendar(2) #Moves from Mar 5th to Mar 7th
58 | ###
59 |
60 | default calDate = datetime.datetime(2001, 8, 20, 12, 0, 0) #20th August 2001, midday
61 |
62 | #The date to display, or the starting date of a time lapse.
63 | #Current month. 1 = January, 12 = December
64 | default displayYear = False
65 | default displayFullName = True #True = full name (Monday), False = abbreviation (Mon)
66 | default displayTime = False
67 | default displayWeather = False #If False, don't display. Otherwise display value.
68 | default startDelay = 2.0 #Time to wait before beginning the calendar animation.
69 | default intDelay = 2.0 #Time for which to keep showing calendar after animation.
70 |
71 | init python:
72 |
73 | import calendar
74 | import datetime
75 | import math
76 |
77 | ###
78 | #getRDay(int mv) #getRelativeDay
79 | #
80 | #Gets date mv days away.
81 | #eg. Starting at 21st, mv of 2 would return 23rd.
82 | #Starting at 31st, mv of 2 would return 2nd.
83 | ###
84 | def getRDay(mv):
85 | newVal = calDate + datetime.timedelta(days=mv)
86 | newVal = newVal.day
87 |
88 | if 4 <= newVal <= 20 or 24 <= newVal <= 30:
89 | return str(newVal) + "th"
90 | else:
91 | return str(newVal) + ["st", "nd", "rd"][newVal % 10 - 1]
92 |
93 | ###
94 | #getRWDay(int mv) #getRelativeWeekDay
95 | #
96 | #Gets name of day mv days away.
97 | #eg. If the day is monday, and mv is -2, the day returned is saturday.
98 | ###
99 | def getRWDay(mv):
100 | global calDate
101 | global displayFullName
102 |
103 | day = calDate + datetime.timedelta(days=mv)
104 | day = day.weekday()
105 | return calendar.day_name[day] if displayFullName else calendar.day_abbr[day]
106 |
107 | ###
108 | #move(int direction)
109 | #@param direction Number of days forward or back to move.
110 | #
111 | #This method checks whether we're moving forward or back in
112 | #time (eg. yesterday or tomorrow) and changes the date appropriately.
113 | ###
114 | def move(direction):
115 | global calDate
116 |
117 | month = calDate.month
118 | year = calDate.year
119 | calDate += datetime.timedelta(days=direction)
120 | monthChanged = month != calDate.month
121 | yearChanged = year != calDate.year
122 | return (monthChanged, yearChanged)
123 |
124 | ###
125 | #Image resources
126 | ###
127 | image calendar_bg = "calendar/1280x720/bg.png" #Background image
128 | image dayButton = "calendar/1280x720/gray.png" #Image representing each week day
129 |
130 | label calendar(direction):
131 |
132 | scene black
133 | show calendar_bg at fade_in(0,0)
134 |
135 | python:
136 | startOriginalDelay = startDelay #Preserve startDelay
137 | imgWidth = 220 #Width of buttons; change if image changes
138 | posY = 475
139 | posX = 10
140 | dDir = 1 if direction > 0 else -1
141 | if direction < 1:
142 | mvDir = mini = -1
143 | else:
144 | mini = 0 #TODO: if not moving, don't show 8
145 | mvDir = 0 if direction == 0 else 1
146 |
147 | show screen CalendarMonth(calendar.month_name[calDate.month])
148 | if displayYear:
149 | show screen CalendarYear(str(calDate.year))
150 |
151 | while direction != 0:
152 |
153 | $ speed = 1.0 #/ math.fabs(direction) #Uncomment to speed up multi-day transitions
154 |
155 | call hideButtons
156 | show screen CBtn1((getRWDay(mini-1), getRDay(mini-1)), mvDir, imgWidth, posX+imgWidth*(mini+0), posY, startDelay, speed)
157 | show screen CBtn2((getRWDay(mini+0), getRDay(mini+0)), mvDir, imgWidth, posX+imgWidth*(mini+1), posY, startDelay, speed)
158 | show screen CBtn3((getRWDay(mini+1), getRDay(mini+1)), mvDir, imgWidth, posX+imgWidth*(mini+2), posY, startDelay, speed)
159 | show screen CBtn4((getRWDay(mini+2), getRDay(mini+2)), mvDir, imgWidth, posX+imgWidth*(mini+3), posY, startDelay, speed)
160 | show screen CBtn5((getRWDay(mini+3), getRDay(mini+3)), mvDir, imgWidth, posX+imgWidth*(mini+4), posY, startDelay, speed)
161 | show screen CBtn6((getRWDay(mini+4), getRDay(mini+4)), mvDir, imgWidth, posX+imgWidth*(mini+5), posY, startDelay, speed)
162 | show screen CBtn7((getRWDay(mini+5), getRDay(mini+5)), mvDir, imgWidth, posX+imgWidth*(mini+6), posY, startDelay, speed)
163 | show screen CBtn8((getRWDay(mini+6), getRDay(mini+6)), mvDir, imgWidth, posX+imgWidth*(mini+7), posY, startDelay, speed)
164 |
165 | if startDelay != 0:
166 | pause startDelay
167 | $ startDelay = 0
168 | $ print "mvdir"
169 |
170 | $ monthChanged, yearChanged = move(dDir)
171 | $ print "moved"
172 |
173 | if monthChanged:
174 | hide screen CalendarMonth
175 | show screen CalendarMonth(calendar.month_name[calDate.month])
176 | if displayYear and yearChanged:
177 | hide screen CalendarYear
178 | show screen CalendarYear(str(calDate.year))
179 |
180 | pause speed
181 |
182 | $ direction -= dDir
183 |
184 | if displayTime:
185 | show screen CalendarTime(calDate.hour, calDate.minute, calDate.second)
186 | if displayWeather:
187 | show screen CalendarWeather(displayWeather)
188 |
189 | pause intDelay
190 | $ print "hiding showCurrentDays"
191 | hide screen CalendarTime
192 | hide screen CalendarWeather
193 | hide screen CalendarMonth
194 | hide screen CalendarYear
195 | call hideButtons
196 |
197 | scene black with dissolve
198 |
199 | pause intDelay
200 |
201 | $ startDelay = startOriginalDelay
202 |
203 | return
204 |
205 | label hideButtons:
206 | hide screen CBtn1
207 | hide screen CBtn2
208 | hide screen CBtn3
209 | hide screen CBtn4
210 | hide screen CBtn5
211 | hide screen CBtn6
212 | hide screen CBtn7
213 | hide screen CBtn8
214 | return
215 |
216 | ###
217 | #Screens
218 | ###
219 |
220 | screen CBtn1(day, direction, distance, posX, posY, startDelay, speed):
221 | use CalendarButton(day, direction, distance, posX, posY, startDelay, speed)
222 |
223 | screen CBtn2(day, direction, distance, posX, posY, startDelay, speed):
224 | use CalendarButton(day, direction, distance, posX, posY, startDelay, speed)
225 |
226 | screen CBtn3(day, direction, distance, posX, posY, startDelay, speed):
227 | use CalendarButton(day, direction, distance, posX, posY, startDelay, speed)
228 |
229 | screen CBtn4(day, direction, distance, posX, posY, startDelay, speed):
230 | use CalendarButton(day, direction, distance, posX, posY, startDelay, speed)
231 |
232 | screen CBtn5(day, direction, distance, posX, posY, startDelay, speed):
233 | use CalendarButton(day, direction, distance, posX, posY, startDelay, speed)
234 |
235 | screen CBtn6(day, direction, distance, posX, posY, startDelay, speed):
236 | use CalendarButton(day, direction, distance, posX, posY, startDelay, speed)
237 |
238 | screen CBtn7(day, direction, distance, posX, posY, startDelay, speed):
239 | use CalendarButton(day, direction, distance, posX, posY, startDelay, speed)
240 |
241 | screen CBtn8(day, direction, distance, posX, posY, startDelay, speed):
242 | use CalendarButton(day, direction, distance, posX, posY, startDelay, speed)
243 |
244 | screen CalendarButton(day, direction, distance, posX, posY, startDelay, speed):
245 | frame:
246 | background None
247 | xsize distance
248 | ysize distance + 35
249 | xpos posX
250 | ypos posY - 35
251 |
252 | if startDelay > 0:
253 | at move_align_wait(direction, distance, posX, startDelay, speed)
254 | else:
255 | at move_align(direction, distance, posX, speed)
256 |
257 | text day[0] size 24 xcenter 0.375
258 | add "dayButton" ypos 30
259 | text day[1] size 28 ypos 90 xcenter 0.375
260 |
261 | screen CalendarMonth(mon):
262 | text mon size 72 color "#545454CC" xalign 0.5 at swipe_in(0, 62)
263 |
264 | screen CalendarYear(yr):
265 | text yr size 48 color "#545454CC" at fade_in(1050, 20)
266 |
267 | screen CalendarTime(hour, minute, second):
268 | text format(hour, '02')+":"+format(minute, '02') size 48 color "#545454CC" at fade_in(700, 30)
269 |
270 | screen CalendarWeather(weather):
271 | text weather size 42 color "#545454CC" at fade_in(700, 76)
272 |
273 | ###
274 | #Transforms
275 | ###
276 |
277 | transform move_align(direction, distance, xPos, speed=1.0):
278 | on show:
279 | xpos xPos
280 | linear speed xpos (xPos - direction * distance)
281 | on hide:
282 | ease .5 alpha 0
283 |
284 | transform move_align_wait(direction, distance, xPos, startDelay, speed=1.0):
285 | on show:
286 | alpha 0
287 | ease 1 alpha 1
288 | time startDelay
289 | linear speed xpos (xPos - direction * distance)
290 | on hide:
291 | ease .5 alpha 0
292 |
293 | transform fade_in(xPos, yPos): #Fade in a displayable over 1 second at xPos yPos
294 | on show:
295 | alpha 0 pos (xPos, yPos)
296 | ease 1.0 alpha 1.0
297 | on hide:
298 | ease .5 alpha 0
299 |
300 | transform swipe_in(xPos, yPos):
301 | on show:
302 | alpha 0 pos (1050 + xPos, yPos - 35)
303 | easein 1.0 alpha 1.0 ypos yPos
304 | on hide:
305 | alpha 1.0 pos (1050 + xPos, yPos)
306 | easeout 1.0 alpha 0 ypos (yPos - 35)
307 |
--------------------------------------------------------------------------------
/renpy-atl/calendar.rpy:
--------------------------------------------------------------------------------
1 | ########
2 | #calendar.rpy
3 | #
4 | #Purpose: To provide a Persona 4-like day to day transition screen.
5 | #
6 | #How to include: Simply place this file in the "game" folder of your
7 | #RenPy game. This is the folder with options.rpy, script.rpy, etc.
8 | #
9 | #How to use: Before running this script, there are a few variables
10 | #you should set up. They are:
11 | #
12 | # dayofweek
13 | # dayofmonth
14 | # month
15 | #
16 | #The first three variables specify the day of the week (eg. Sunday),
17 | #the day of the month (eg. the 1st) and the current month (eg. January).
18 | #
19 | #There are several other settings you can tweak as well. For example,
20 | #the intDelay variable. This determines how long in seconds the calendar
21 | #will display for after finishing the animation.
22 | #
23 | #After you've overridden the desired variables and set the start time/date,
24 | #you're ready to show the calendar. Simply use the call command
25 | #to invoke the calendar label. The animation will run, it will wait intDelay
26 | #seconds, then continue with the game.
27 | #
28 | #A full example of the calendar being used is shown below.
29 | #This entails a very basic script.rpy file.
30 | #We start at the start label and set the date to Monday January 1st.
31 | #We then call calendar, which moves us forward 2 days to Wednesday
32 | #January 3rd, then display a message before ending.
33 | #
34 | #label start:
35 | # $ dayofweek = 1
36 | # $ dayofmonth = 1
37 | # $ month = 1
38 | #
39 | # call calendar(2)
40 | #
41 | # "The day transition has just ended."
42 | #
43 | ########
44 |
45 | init python:
46 |
47 | ###
48 | #Time variables
49 | #
50 | #These variables are used to depict dates and show transitions
51 | #from one day to the next. Ideally they should be set manually
52 | #once, then modified using move().
53 | #
54 | #Typical usage entails setting default dayofmonth, dayofweek
55 | #and month variables, then going from day to day with move().
56 | #
57 | #Example:
58 | #
59 | # dayofmonth = 1
60 | # dayofweek = 0
61 | # month = 1
62 | #
63 | # move(5)
64 | #
65 | #This would set the date to Sunday the 1st of January, then
66 | #move forward 5 days to Friday the 6th of January.
67 | ###
68 |
69 | months = [
70 | ["January", 31],
71 | ["February", 28],
72 | ["March", 31],
73 | ["April", 30],
74 | ["May", 31],
75 | ["June", 30],
76 | ["July", 31],
77 | ["August", 31],
78 | ["September", 30],
79 | ["October", 31],
80 | ["November", 30],
81 | ["December", 31]
82 | ]
83 |
84 | days = [
85 | "Sunday",
86 | "Monday",
87 | "Tuesday",
88 | "Wednesday",
89 | "Thursday",
90 | "Friday",
91 | "Saturday"
92 | ]
93 |
94 | dayofmonth = 20 #01-31
95 | #Set this to the current date if you're just showing the date,
96 | #or the starting date if you're showing a time lapse.
97 | dayofweek = 0 #Keeps track of Sun-Sat. 0 = Sunday, 6 = Saturday.
98 | month = 8 #Current month. 1 = January, 12 = December
99 | oldmonth = 8 #Previous month.
100 | #Only useful when going from one month to the next.
101 | year = False #Set to either false or a numeric value. eg. 2012.
102 | #If not False, the year will be displayed below the current month.
103 | #The year will also increment/decrement accordingly.
104 | oldyear = False #Will be set automatically as year is changed
105 |
106 | displayFullName = True #If True, display the full name of a week day
107 | #rather than the abbreviation. eg. Tuesday rather than Tue
108 | displayTime = False #If False, don't display. Otherwise display value.
109 | displayWeather = False #If False, don't display. Otherwise display value.
110 |
111 | ###
112 | #Movement Variables
113 | ###
114 |
115 | direction = 0
116 | #Reflects how many days forward or back to move.
117 | #eg. A direction of -2 goes back 2 days, a direction of 1
118 | #goes to the next day, etc.
119 |
120 | ###
121 | #Time Variables
122 | #
123 | #These variables can be edited manually.
124 | #The values express time delays in seconds.
125 | #eg. 1.5 equals a one and a half second delay.
126 | ###
127 |
128 | startDelay = 1.0 #Time to wait before beginning the animation.
129 | intDelay = 2.0 #Time for which to keep showing calendar after movement.
130 |
131 | ###
132 | #getRelativeDay(int mv)
133 | #@param mv How many days forward or back from the current date
134 | # to get the day of. eg. -1 = yesterday.
135 | #
136 | #This function gets a day of the month relative to the
137 | #current day, then returns the number as a string.
138 | #eg. If the current date is 21, and mv is -1, then the
139 | #method will return "20".
140 | ###
141 | def getRelativeDay(mv):
142 | global dayofmonth
143 | global direction
144 | global month
145 | global months
146 |
147 | newVal = dayofmonth + mv
148 |
149 | if newVal < 1:
150 | newVal = months[11][1] + newVal if month == 0 else months[month - 1][1] + newVal
151 | elif newVal > months[month][1]:
152 | newVal -= months[month][1]
153 |
154 | if newVal == 1 or newVal == 21 or newVal == 31:
155 | strday = str(newVal) + "st"
156 | elif newVal == 2 or newVal == 22:
157 | strday = str(newVal) + "nd"
158 | elif newVal == 3 or newVal == 23:
159 | strday = str(newVal) + "rd"
160 | else:
161 | strday = str(newVal) + "th"
162 |
163 | return strday
164 |
165 | ###
166 | #getRelativeWeekDay(int mv, boolean displayFullName)
167 | #
168 | #See getRelativeDay(int).
169 | #Does the same, except returns name of the week day
170 | #instead of the number of the day in the month.
171 | ###
172 | def getRelativeWeekDay(mv, displayFullName):
173 | global dayofweek
174 | global days
175 | global direction
176 |
177 | newDay = dayofweek + mv - 1
178 |
179 | if newDay > 6:
180 | while newDay > 6:
181 | newDay -= 7
182 | elif newDay < 0:
183 | while newDay < 0:
184 | newDay += 7
185 |
186 | return days[newDay] if displayFullName else days[newDay][0:3]
187 |
188 | ###
189 | #move(int direction)
190 | #@param direction Number of days forward or back to move.
191 | #
192 | #This method checks whether we're moving forward or back in
193 | #time (eg. yesterday or tomorrow), checks if it'll be a different
194 | #month, sets the dayofmonth, oldmonth, etc.
195 | ###
196 | def move(direction):
197 | global months
198 | global month
199 | global dayofmonth
200 | global oldmonth
201 | global oldyear
202 | global dayofweek
203 | global year
204 |
205 | if direction > 0:
206 | dayofweek += 1
207 | if dayofmonth < months[month][1]:
208 | dayofmonth += 1
209 | else:
210 | dayofmonth = 1
211 | oldmonth = month
212 | oldyear = year
213 | if month == 11:
214 | if year:
215 | year += 1
216 | month = 0
217 | else:
218 | month += 1
219 | else:
220 | dayofweek -= 1
221 | if dayofmonth == 1:
222 | oldmonth = month
223 | oldyear = year
224 | month = 11 if month == 0 else month - 1
225 | if oldmonth == 0:
226 | dayofmonth = months[11][1]
227 | year -= 1
228 | else:
229 | dayofmonth = months[month][1]
230 | else:
231 | dayofmonth -= 1
232 |
233 | def showCurrentDays(direction, imgSize, posX, posY, displayFullName, startDelay=0):
234 | direction = 1 if direction > 0 else -1
235 | posX -= imgSize
236 | for i in xrange(-2, 6):
237 | relDay = "{size=28}"+getRelativeDay(i)+"{/size}"
238 | cDay = "{size=24}"+getRelativeWeekDay(i, displayFullName)+"{/size}"
239 |
240 | if startDelay > 0:
241 | ui.add(At('dayButton', move_left_align_wait(direction, imgSize, posX, posY, startDelay)))
242 | ui.add(At(Text(relDay), move_left_align_wait(direction, imgSize, posX, posY, startDelay)))
243 | ui.add(At(Text(cDay), move_left_align_wait(direction, imgSize, posX-3, posY-98, startDelay)))
244 | else:
245 | ui.add(At('dayButton', move_left_align(direction, imgSize, posX, posY)))
246 | ui.add(At(Text(relDay), move_left_align(direction, imgSize, posX, posY)))
247 | ui.add(At(Text(cDay), move_left_align(direction, imgSize, posX-3, posY-98)))
248 |
249 | posX += imgSize
250 |
251 | transform move_left_align(direction, distance, xPos, yPos):
252 | yalign (yPos + 80) xcenter (xPos + 80) ycenter (yPos + 80)
253 | linear 1.0 xcenter (xPos + 80 - direction * distance)
254 |
255 | transform move_left_align_wait(direction, distance, xPos, yPos, startDelay):
256 | alpha 0 yalign (yPos + 80) xcenter (xPos + 80) ycenter (yPos + 80)
257 | ease 1 alpha 1
258 | time startDelay + 1
259 |
260 | transform fade_in(xPos, yPos): #Fade in a displayable over 1 second at xPos yPos
261 | alpha 0 pos (xPos, yPos)
262 | ease 1.0 alpha 1.0
263 |
264 | transform fade_in_immediately(xPos, yPos): #Over 1 second, then begin to fade in a displayable over 1 second at xPos yPos
265 | xalign (xPos + 80) yalign (yPos + 80) xcenter (xPos + 80) ycenter (yPos + 80)
266 |
267 | transform swipe_out(xPos, yPos):
268 | alpha 1.0 pos (xPos, yPos)
269 | easeout 1.0 alpha 0 ypos (yPos - 100)
270 |
271 | transform swipe_in(xPos, yPos):
272 | alpha 0 pos (xPos, yPos - 100)
273 | easein 1.0 alpha 1.0 ypos yPos
274 |
275 | ###
276 | #Image resources
277 | ###
278 | image calendar_bg = "calendar/1280x720/bg.png" #Background image
279 | image dayButton = "calendar/1280x720/gray.png" #Image representing each week day
280 |
281 | label calendar(toMove):
282 |
283 | scene black
284 | show calendar_bg at fade_in(0,0)
285 |
286 | python:
287 | startOriginalDelay = startDelay
288 |
289 | direction = toMove
290 | monthPos = 65 #Y position (in px) of month label to display
291 | monthPosX = 1050
292 | month -= 1 #So users can set month as 1-12 instead of 0-11
293 | oldmonth = month
294 | oldyear = year
295 | newsize = 220
296 | scalesize = 213
297 |
298 | imgSize = newsize
299 | baseX = 10 #TODO: move 62px right; 478y 154h
300 | posY = 475
301 | posX = baseX
302 |
303 | dDir = 1 if direction > 0 else -1
304 |
305 | show text "{size=72}{color=#545454CC}"+str(months[month][0])+"{/color}{/size}" as new_month at fade_in(monthPosX, monthPos+62)
306 | if year:
307 | show text "{size=48}{color=#545454CC}[year]{/color}{/size}" as new_year at fade_in(monthPosX+70, monthPos)
308 |
309 | if startDelay != 0:
310 | $ showCurrentDays(direction, imgSize, posX, posY, displayFullName, startDelay)
311 | pause startDelay
312 | $ startDelay = 0
313 |
314 | while direction != 0:
315 |
316 | $ showCurrentDays(direction, imgSize, posX, posY, displayFullName, startDelay)
317 | $ move(dDir)
318 |
319 | if oldmonth != month:
320 | show text "{size=72}{color=#545454CC}"+str(months[oldmonth][0])+"{/color}{/size}" as old_month at swipe_out(monthPosX, monthPos+62)
321 | show text "{size=72}{color=#545454CC}"+str(months[month][0])+"{/color}{/size}" as new_month at swipe_in(monthPosX, monthPos+62)
322 | $ oldmonth = month
323 | if year and oldyear != year:
324 | show text "{size=48}{color=#545454CC}[oldyear]{/color}{/size}" as old_year at swipe_out(monthPosX+70, monthPos)
325 | show text "{size=48}{color=#545454CC}[year]{/color}{/size}" as new_year at swipe_in(monthPosX+70, monthPos)
326 | $ oldyear = year
327 |
328 | pause 1.0
329 |
330 | $ direction -= dDir
331 |
332 | if displayTime:
333 | show text "{size=48}{color=#545454CC}[displayTime]{/color}{/size}" as calendar_time at fade_in(700, monthPos + 6)
334 | if displayWeather:
335 | show text "{size=42}{color=#545454CC}[displayWeather]{/color}{/size}" as calendar_weather at fade_in(700, monthPos + 52)
336 |
337 | show dayButton as db_1 at fade_in_immediately(posX, posY)
338 | show text ("{size=28}"+getRelativeDay(-1)+"{/size}") as dr_1 at fade_in_immediately(posX, posY)
339 | show text ("{size=24}"+getRelativeWeekDay(-1, displayFullName)+"{/size}") as dc_1 at fade_in_immediately(posX-3, posY-98)
340 | $ posX += imgSize
341 |
342 | show dayButton as db_2 at fade_in_immediately(posX, posY)
343 | show text ("{size=28}"+getRelativeDay(0)+"{/size}") as dr_2 at fade_in_immediately(posX, posY)
344 | show text ("{size=24}"+getRelativeWeekDay(0, displayFullName)+"{/size}") as dc_2 at fade_in_immediately(posX-3, posY-98)
345 | $ posX += imgSize
346 |
347 | show dayButton as db_3 at fade_in_immediately(posX, posY)
348 | show text ("{size=28}"+getRelativeDay(1)+"{/size}") as dr_3 at fade_in_immediately(posX, posY)
349 | show text ("{size=24}"+getRelativeWeekDay(1, displayFullName)+"{/size}") as dc_3 at fade_in_immediately(posX-3, posY-98)
350 | $ posX += imgSize
351 |
352 | show dayButton as db_4 at fade_in_immediately(posX, posY)
353 | show text ("{size=28}"+getRelativeDay(2)+"{/size}") as dr_4 at fade_in_immediately(posX, posY)
354 | show text ("{size=24}"+getRelativeWeekDay(2, displayFullName)+"{/size}") as dc_4 at fade_in_immediately(posX-3, posY-98)
355 | $ posX += imgSize
356 |
357 | show dayButton as db_5 at fade_in_immediately(posX, posY)
358 | show text ("{size=28}"+getRelativeDay(3)+"{/size}") as dr_5 at fade_in_immediately(posX, posY)
359 | show text ("{size=24}"+getRelativeWeekDay(3, displayFullName)+"{/size}") as dc_5 at fade_in_immediately(posX-3, posY-98)
360 | $ posX += imgSize
361 |
362 | show dayButton as db_6 at fade_in_immediately(posX, posY)
363 | show text ("{size=28}"+getRelativeDay(4)+"{/size}") as dr_6 at fade_in_immediately(posX, posY)
364 | show text ("{size=24}"+getRelativeWeekDay(4, displayFullName)+"{/size}") as dc_6 at fade_in_immediately(posX-3, posY-98)
365 | $ posX += imgSize
366 |
367 | show dayButton as db_7 at fade_in_immediately(posX, posY)
368 | show text ("{size=28}"+getRelativeDay(5)+"{/size}") as dr_7 at fade_in_immediately(posX, posY)
369 | show text ("{size=24}"+getRelativeWeekDay(5, displayFullName)+"{/size}") as dc_7 at fade_in_immediately(posX-3, posY-98)
370 |
371 | pause intDelay
372 | scene black with dissolve
373 |
374 | python:
375 | startDelay = startOriginalDelay
376 | month += 1
377 |
378 | return
--------------------------------------------------------------------------------
/renpy/calendar.rpy:
--------------------------------------------------------------------------------
1 | ########
2 | #calendar.rpy
3 | #
4 | #Purpose: To provide a Persona 4-like day to day transition screen.
5 | #
6 | #How to include: Simply place this file in the "game" folder of your
7 | #RenPy game. This is the folder with options.rpy, script.rpy, etc.
8 | #
9 | #How to use: Before running this script, there are a few variables
10 | #you should set up. They are:
11 | #
12 | # dayofweek
13 | # dayofmonth
14 | # month
15 | # direction
16 | # label_cont
17 | #
18 | #The first three variables specify the day of the week (eg. Sunday),
19 | #the day of the month (eg. the 1st) and the current month (eg. January).
20 | #
21 | #direction specifies the number of days forward or backward you want
22 | #to move. eg. A direction of 1 = move to the next day, a direction of -1
23 | #goes to the previous day, a direction of 7 will go forward one week, etc.
24 | #
25 | #label_cont specifies the label you want to move to after showing the
26 | #day transition. eg. If I set label_cont to "chapter_01", I would move to
27 | #that label after the transition ended.
28 | #
29 | #There are several other settings you can tweak as well. For example,
30 | #the default resolution is 800x600; if you want to change that, override
31 | #the size variable.
32 | #Another example is the intDelay variable. This determines how long in
33 | #seconds the calendar will display for after finishing the animation.
34 | #
35 | #After you've overridden the desired variables, and set the time, label &
36 | #direction, you're ready to show the calendar. Simply use the jump command
37 | #to jump to the calendar label. The animation will run, it will wait intDelay
38 | #seconds, then jump to the label_cont label.
39 | #
40 | #A full example of the calendar being used is shown below.
41 | #This entails a very basic script.rpy file.
42 | #We start at the start label, set the date to Monday January 1st,
43 | #set direction and label_cont. We then jump to calendar, which
44 | #moves us forward 2 days to Wednesday January 3rd, which then
45 | #jumps to chapter_01 and displays a message before ending.
46 | #
47 | #label start:
48 | # $ dayofweek = 1
49 | # $ dayofmonth = 1
50 | # $ month = 1
51 | # $ direction = 2
52 | # $ label_cont = "chapter_01"
53 | # jump calendar
54 | #
55 | #label chapter_01
56 | # "The day transition has just ended."
57 | #
58 | ########
59 |
60 | init python:
61 |
62 | import math
63 |
64 | ###
65 | #Time variables
66 | #
67 | #These variables are used to depict dates and show transitions
68 | #from one day to the next. Ideally they should be set manually
69 | #once, then modified using move().
70 | #
71 | #Typical usage entails setting default dayofmonth, dayofweek
72 | #and month variables, then going from day to day with move().
73 | #
74 | #Example:
75 | #
76 | # dayofmonth = 1
77 | # dayofweek = 0
78 | # month = 1
79 | #
80 | # move(5)
81 | #
82 | #This would set the date to Sunday the 1st of January, then
83 | #move forward 5 days to Friday the 6th of January.
84 | ###
85 |
86 | months = [
87 | ["January", 31],
88 | ["February", 28],
89 | ["March", 31],
90 | ["April", 30],
91 | ["May", 31],
92 | ["June", 30],
93 | ["July", 31],
94 | ["August", 31],
95 | ["September", 30],
96 | ["October", 31],
97 | ["November", 30],
98 | ["December", 31]
99 | ]
100 |
101 | days = [
102 | "Sunday",
103 | "Monday",
104 | "Tuesday",
105 | "Wednesday",
106 | "Thursday",
107 | "Friday",
108 | "Saturday"
109 | ]
110 |
111 | dayofmonth = 20 #01-31
112 | #Set this to the current date if you're just showing the date,
113 | #or the starting date if you're showing a time lapse.
114 | dayofweek = 0 #Keeps track of Sun-Sat. 0 = Sunday, 6 = Saturday.
115 | month = 8 #Current month. 1 = January, 12 = December
116 | oldmonth = 8 #Previous month.
117 | #Only useful when going from one month to the next.
118 | year = False #Set to either false or a numeric value. eg. 2012.
119 | #If not False, the year will be displayed below the current month.
120 | #The year will also increment/decrement accordingly.
121 | oldyear = False #Will be set automatically as year is changed
122 |
123 | ###
124 | #Boolean variables
125 | #
126 | #nextMonth should NOT be modified manually.
127 | #The others can all be set manually.
128 | ###
129 | nextMonth = False #True when we're about to change months.
130 | nextYear = False #True when we're about to change years
131 | displayFullName = True #If True, display the full name of a week day
132 | #rather than the abbreviation.
133 | #eg. Tuesday rather than Tue
134 | displayTime = "9:00 PM" #If False, don't display. Otherwise display value.
135 | displayWeather = "Sunny" #If False, don't display. Otherwise display value.
136 |
137 | ###
138 | #Size Variables
139 | #
140 | #This shouldn't be changed. It currently maps to the renpy size setting.
141 | ###
142 | size = (config.screen_width, config.screen_height)
143 |
144 | ###
145 | #Movement Variables
146 | #
147 | #Only direction should be edited manually.
148 | ###
149 |
150 | curmove = 0 #Used to keep track of movement.
151 | direction = 0
152 | #Reflects how many days forward or back to move.
153 | #eg. A direction of -2 goes back 2 days, a direction of 1
154 | #goes to the next day, etc.
155 |
156 | ###
157 | #Time Variables
158 | #
159 | #These variables can be edited manually.
160 | #The values express time delays in seconds.
161 | #eg. 1.5 equals a one and a half second delay.
162 | ###
163 |
164 | startDelay = 2.0 #Time to wait before beginning the animation.
165 | intDelay = 1.5 #Time to keep showing calendar for after movement
166 |
167 | ###
168 | #Image resources
169 | #
170 | #Both of these values can be changed
171 | ###
172 |
173 | dayButton = str(size[0])+"x"+str(size[1])+"/gray.png"
174 | dayFrame = str(size[0])+"x"+str(size[1])+"/onyx.png"
175 |
176 | ###
177 | #getRelativeDay(int mv, boolean boolStart)
178 | #@param mv How many days forward or back from the current date
179 | # to get the day of. eg. -1 = yesterday.
180 | #@param boolStart True if being run for the first time.
181 | # Not tested if necessary outside of pygame.
182 | #
183 | #This function gets a day of the month relative to the
184 | #current day, then returns the number as a string.
185 | #eg. If the current date is 21, and mv is -1, then the
186 | #method will return "20".
187 | ###
188 | def getRelativeDay(mv, boolStart):
189 | global dayofmonth
190 | global direction
191 | global month
192 | global months
193 |
194 | if boolStart:
195 | start = dayofmonth
196 | else:
197 | start = dayofmonth - 1 if direction > 0 else dayofmonth + 1
198 | newVal = start + mv
199 |
200 | if newVal < 1:
201 | newVal = months[11][1] + newVal if month == 0 else months[month - 1][1] + newVal
202 | elif newVal > months[month][1]:
203 | newVal -= months[month][1]
204 |
205 | return newVal
206 |
207 | ###
208 | #getRelativeWeekDay(int mv)
209 | #
210 | #See getRelativeDay(int, boolean).
211 | #Does the same, except returns name of the week day
212 | #instead of the number of the day in the month.
213 | ###
214 | def getRelativeWeekDay(mv, boolStart):
215 | global dayofweek
216 | global days
217 | global direction
218 |
219 | if boolStart:
220 | newDay = dayofweek + mv -1
221 | else:
222 | newDay = dayofweek + mv - (2 if direction > 0 else 0)
223 |
224 | if newDay > 6:
225 | while newDay > 6:
226 | newDay -= 7
227 | elif newDay < 0:
228 | while newDay < 0:
229 | newDay += 7
230 |
231 | return days[newDay]
232 |
233 | ###
234 | #move(int direction)
235 | #@param direction Number of days forward or back to move.
236 | #
237 | #This method checks whether we're moving forward or back in
238 | #time (eg. yesterday or tomorrow), checks if it'll be a different
239 | #month, sets the dayofmonth, oldmonth, etc.
240 | ###
241 | def move(direction):
242 | global curmove
243 | global months
244 | global month
245 | global dayofmonth
246 | global nextMonth
247 | global nextYear
248 | global oldmonth
249 | global oldyear
250 | global dayofweek
251 | global year
252 |
253 | nextMonth = False
254 | nextYear = False
255 | curmove = 0
256 |
257 | if direction > 0:
258 | dayofweek += 1
259 | if dayofmonth < months[month][1] - 1:
260 | dayofmonth += 1
261 | else:
262 | dayofmonth = 0
263 | nextMonth = True
264 | oldmonth = month
265 | oldyear = year
266 | if month == 11:
267 | if year:
268 | year += 1
269 | nextYear = True
270 | month = 0
271 | else:
272 | month += 1
273 | else:
274 | dayofweek -= 1
275 | if dayofmonth == 0:
276 | nextMonth = True
277 | oldmonth = month
278 | oldyear = year
279 | month = 11 if month == 0 else month - 1
280 | if oldmonth == 0:
281 | dayofmonth = months[11][1]
282 | year -= 1
283 | nextYear = True
284 | else:
285 | dayofmonth = months[month][1]
286 |
287 | dayofmonth -= 1
288 |
289 | def displayDays(posX, posY, scalesize, imgSize, size, monthPos, months, month, boolStart, boolEnd=False):
290 | global dayButton
291 | global dayFrame
292 | global dayofmonth
293 | global year
294 | global nextMonth
295 | global nextYear
296 | global oldmonth
297 | global oldyear
298 |
299 | if boolStart:
300 | dayofmonth -= 1
301 |
302 | wScale = 1
303 | if config.screen_width != 800:
304 | wScale = float(config.screen_width) / float(800)
305 | #if config.screen_height != 600:
306 | # pass
307 | if nextMonth:
308 | curX = ((imgSize + (baseX - posX if direction < 0 else posX - baseX))) / 5 - 15
309 | print "curX", str(curX)
310 | if curX > 0:
311 | cmonth = oldmonth
312 | cyear = oldyear
313 | else:
314 | cmonth = month
315 | cyear = year
316 | curX = math.fabs(curX)
317 | if curX > 15:
318 | curX = 15
319 | curX = "%x" % curX
320 | ui.text("{color=#fff"+curX+"}"+months[cmonth][0]+"{/color}", xpos=50, ypos=monthPos, size=math.floor(42*wScale))
321 | if year:
322 | if nextYear:
323 | ui.text("{color=#fff"+curX+"}"+str(cyear)+"{/color}", xpos=50, ypos=(monthPos + 42 * wScale), size=math.floor(36*wScale))
324 | else:
325 | ui.text(str(year), xpos=50, ypos=(monthPos + 42 * wScale), size=math.floor(36*wScale))
326 | else:
327 | ui.text(months[month][0], xpos=50, ypos=monthPos, size=math.floor(42*wScale))
328 | if year:
329 | ui.text(str(year), xpos=50, ypos=(monthPos + 42 * wScale), size=math.floor(36*wScale))
330 | if boolEnd:
331 | if displayTime:
332 | ui.text(displayTime, xpos=(size[0] - imgSize*wScale), ypos=(monthPos + 6 * wScale), size=math.floor(36*wScale))
333 | if displayWeather:
334 | ui.text(displayWeather, xpos=(size[0] - imgSize*wScale), ypos=(monthPos + 42 * wScale), size=math.floor(24*wScale))
335 | elif math.fabs(direction) == 1:
336 | curX = (150 - (imgSize + (baseX - posX if direction == -1 else posX - baseX))) / 10
337 | if curX > 15:
338 | curX = 15
339 | curX = "%x" % curX
340 | if displayTime:
341 | ui.text("{color=#fff"+curX+"}"+displayTime+"{/color}", xpos=(size[0] - imgSize*wScale), ypos=(monthPos + 6 * wScale), size=math.floor(36*wScale))
342 | if displayWeather:
343 | ui.text("{color=#fff"+curX+"}"+displayWeather+"{/color}", xpos=(size[0] - imgSize*wScale), ypos=(monthPos + 42 * wScale), size=math.floor(24*wScale))
344 | for i in xrange(-3, 7): #Display 7 days, starting 3 days ago
345 | relDay = getRelativeDay(i, boolStart)
346 | fWidth = 7 if relDay < 10 else 3
347 | nxPos = (int)(posX + (scalesize / 3) + math.floor(wScale * fWidth))
348 | nyPos = (int)(posY + (scalesize / 3))
349 | ui.image(dayButton, xpos=posX, ypos=posY)
350 | ui.text(str(relDay), xpos=nxPos, ypos=nyPos, size=math.floor(28*wScale))
351 | nxPos -= (int)(wScale * 40)
352 | nyPos -= (int)(wScale * 60)
353 | cDay = getRelativeWeekDay(i, boolStart)
354 | if not displayFullName:
355 | cDay = cDay[0:3]
356 | ui.text(cDay, xpos=nxPos, ypos=nyPos, size=math.floor(wScale * 18))
357 | posX += imgSize
358 | framepos = (size[0] / 2 - imgSize / 2 - imgSize / 25, posY - 3)
359 | ui.image(dayFrame, xpos=framepos[0], ypos=framepos[1])
360 |
361 | ###
362 | #Background Image
363 | ###
364 | #image bg Calendar = "bg/Personal/HomeStreet_01.png"
365 | image bg Calendar = str(size[0])+"x"+str(size[1])+"/HomeStreet_01.png"
366 |
367 | label calendar:
368 |
369 | $ hide_window() #Hide the text window. There's no point having it here.
370 | scene bg Calendar
371 |
372 | python:
373 | size = (config.screen_width, config.screen_height)
374 | monthPos = 25 #Y position (in px) of month label to display
375 | month -= 1 #So users can set month as 1-12 instead of 0-11
376 | oldmonth = month
377 | oldyear = year
378 | newsize = size[1] / 4 #One quarter of window width
379 | scalesize = int(math.floor(newsize * 2 / 3)) #One sixth of window width
380 |
381 | imgSize = newsize
382 | baseX = size[0] / 2 - 9 * imgSize / 2
383 | posX = baseX
384 | posY = size[1] / 2 - 96 / 2
385 |
386 | displayDays(posX, posY, scalesize, imgSize, size, monthPos, months, month, True)
387 |
388 | if direction == 0:
389 | #If we aren't moving forward or back,
390 | #just show the calendar for intDelay seconds
391 | pause(intDelay)
392 | scene black with dissolve
393 | python:
394 | renpy.jump(label_cont)
395 |
396 | python:
397 | move(direction)
398 |
399 | curmove = 0
400 | moved = 0
401 | speed = imgSize / 30
402 | curmonth = months[month][0]
403 | lastMove = False
404 |
405 | renpy.pause(startDelay)
406 |
407 | done = False
408 | while not done:
409 | curmove += speed * direction
410 | if math.fabs(curmove) >= imgSize:
411 | lastMove = True
412 | #TODO: add animation?
413 |
414 | posX = baseX - curmove
415 |
416 | displayDays(posX, posY, scalesize, imgSize, size, monthPos, months, month, False)
417 |
418 | if lastMove:
419 | lastMove = False
420 | if not math.fabs(curmove) >= imgSize * math.fabs(direction):
421 | direction = direction - 1 if direction > 0 else direction + 1
422 | move(direction)
423 | else:
424 | done = True
425 |
426 | renpy.pause(1/60)
427 |
428 | #Finished looping. Display end result for intDelay seconds.
429 | displayDays(posX, posY, scalesize, imgSize, size, monthPos, months, month, False, boolEnd=True)
430 |
431 | renpy.pause(intDelay)
432 |
433 | scene black with dissolve
434 | python:
435 | renpy.jump(label_cont)
--------------------------------------------------------------------------------
/pygame/onyx.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
490 |
--------------------------------------------------------------------------------
/renpy-p4/calendar.rpy:
--------------------------------------------------------------------------------
1 | ########
2 | #calendar.rpy
3 | #
4 | #Purpose: To provide a Persona 4-like day to day transition screen.
5 | #
6 | #How to include: Simply place this file in the "game" folder of your
7 | #RenPy game. This is the folder with options.rpy, script.rpy, etc.
8 | #
9 | #How to use: Before running this script, there are a few variables
10 | #you should set up. They are:
11 | #
12 | # dayofweek
13 | # dayofmonth
14 | # month
15 | # direction
16 | # label_cont
17 | #
18 | #The first three variables specify the day of the week (eg. Sunday),
19 | #the day of the month (eg. the 1st) and the current month (eg. January).
20 | #
21 | #direction specifies the number of days forward or backward you want
22 | #to move. eg. A direction of 1 = move to the next day, a direction of -1
23 | #goes to the previous day, a direction of 7 will go forward one week, etc.
24 | #
25 | #label_cont specifies the label you want to move to after showing the
26 | #day transition. eg. If I set label_cont to "chapter_01", I would move to
27 | #that label after the transition ended.
28 | #
29 | #There are several other settings you can tweak as well. For example,
30 | #the default resolution is 800x600; if you want to change that, override
31 | #the size variable.
32 | #Another example is the intDelay variable. This determines how long in
33 | #seconds the calendar will display for after finishing the animation.
34 | #
35 | #After you've overridden the desired variables, and set the time, label &
36 | #direction, you're ready to show the calendar. Simply use the jump command
37 | #to jump to the calendar label. The animation will run, it will wait intDelay
38 | #seconds, then jump to the label_cont label.
39 | #
40 | #A full example of the calendar being used is shown below.
41 | #This entails a very basic script.rpy file.
42 | #We start at the start label, set the date to Monday January 1st,
43 | #set direction and label_cont. We then jump to calendar, which
44 | #moves us forward 2 days to Wednesday January 3rd, which then
45 | #jumps to chapter_01 and displays a message before ending.
46 | #
47 | #label start:
48 | # $ dayofweek = 1
49 | # $ dayofmonth = 1
50 | # $ month = 1
51 | # $ direction = 2
52 | # $ label_cont = "chapter_01"
53 | # jump calendar
54 | #
55 | #label chapter_01
56 | # "The day transition has just ended."
57 | #
58 | ########
59 |
60 | init python:
61 |
62 | import math
63 |
64 | ###
65 | #Time variables
66 | #
67 | #These variables are used to depict dates and show transitions
68 | #from one day to the next. Ideally they should be set manually
69 | #once, then modified using move().
70 | #
71 | #Typical usage entails setting default dayofmonth, dayofweek
72 | #and month variables, then going from day to day with move().
73 | #
74 | #Example:
75 | #
76 | # dayofmonth = 1
77 | # dayofweek = 0
78 | # month = 1
79 | #
80 | # move(5)
81 | #
82 | #This would set the date to Sunday the 1st of January, then
83 | #move forward 5 days to Friday the 6th of January.
84 | ###
85 |
86 | months = [
87 | ["January", 31],
88 | ["February", 28],
89 | ["March", 31],
90 | ["April", 30],
91 | ["May", 31],
92 | ["June", 30],
93 | ["July", 31],
94 | ["August", 31],
95 | ["September", 30],
96 | ["October", 31],
97 | ["November", 30],
98 | ["December", 31]
99 | ]
100 |
101 | days = [
102 | "Sunday",
103 | "Monday",
104 | "Tuesday",
105 | "Wednesday",
106 | "Thursday",
107 | "Friday",
108 | "Saturday"
109 | ]
110 |
111 | dayofmonth = 29 #01-31
112 | #Set this to the current date if you're just showing the date,
113 | #or the starting date if you're showing a time lapse.
114 | dayofweek = 0 #Keeps track of Sun-Sat. 0 = Sunday, 6 = Saturday.
115 | month = 1 #Current month. 1 = January, 12 = December
116 | oldmonth = 8 #Previous month.
117 | #Only useful when going from one month to the next.
118 | year = 2011 #Set to either false or a numeric value. eg. 2012.
119 | #If not False, the year will be displayed below the current month.
120 | #The year will also increment/decrement accordingly.
121 | oldyear = False #Will be set automatically as year is changed
122 |
123 | ###
124 | #Boolean variables
125 | #
126 | #nextMonth should NOT be modified manually.
127 | #The others can all be set manually.
128 | ###
129 | nextMonth = False #True when we're about to change months.
130 | nextYear = False #True when we're about to change years
131 |
132 | ###
133 | #Size Variables
134 | #
135 | #This shouldn't be changed. It currently maps to the renpy size setting.
136 | ###
137 | size = (config.screen_width, config.screen_height)
138 |
139 | ###
140 | #Movement Variables
141 | #
142 | #Only direction should be edited manually.
143 | ###
144 |
145 | curmove = 0 #Used to keep track of movement.
146 | direction = 0
147 | #Reflects how many days forward or back to move.
148 | #eg. A direction of -2 goes back 2 days, a direction of 1
149 | #goes to the next day, etc.
150 |
151 | ###
152 | #Time Variables
153 | #
154 | #These variables can be edited manually.
155 | #The values express time delays in seconds.
156 | #eg. 1.5 equals a one and a half second delay.
157 | ###
158 |
159 | startDelay = 1.0 #Time to wait before beginning the animation.
160 | intDelay = 1.0 #Time to keep showing calendar for after movement
161 |
162 | ###
163 | #Image resources
164 | ###
165 |
166 | dayButtons = {
167 | 2011: {
168 | 0: { #January
169 | 1: 'sun',
170 | 3: 'cloud'
171 | },
172 | 2: { #March
173 | 12: 'rain_cloud'
174 | },
175 | 7: { #August
176 | 20: 'rain',
177 | 21: 'sun',
178 | 22: 'cloud'
179 | },
180 | 8: { #September
181 | 2: 'rain'
182 | }
183 | },
184 | 'default': 'sun'
185 | } #Format: year, month, date, val
186 |
187 | ###
188 | #getRelativeDay(int mv, boolean boolStart)
189 | #@param mv How many days forward or back from the current date
190 | # to get the day of. eg. -1 = yesterday.
191 | #@param boolStart True if being run for the first time.
192 | # Not tested if necessary outside of pygame.
193 | #
194 | #This function gets a day of the month relative to the
195 | #current day, then returns the number as a string.
196 | #eg. If the current date is 21, and mv is -1, then the
197 | #method will return "20".
198 | ###
199 | def getRelativeDay(mv, boolStart):
200 | global dayofmonth
201 | global direction
202 | global month
203 | global months
204 |
205 | if boolStart:
206 | start = dayofmonth
207 | else:
208 | start = dayofmonth - 1 if direction > 0 else dayofmonth + 1
209 | newVal = start + mv
210 |
211 | if newVal < 1:
212 | newVal = months[11][1] + newVal if month == 0 else months[month - 1][1] + newVal
213 | elif newVal > months[month][1]:
214 | newVal -= months[month][1]
215 |
216 | return newVal
217 |
218 | ###
219 | #getRelativeWeekDay(int mv)
220 | #
221 | #See getRelativeDay(int, boolean).
222 | #Does the same, except returns name of the week day
223 | #instead of the number of the day in the month.
224 | ###
225 | def getRelativeWeekDay(mv, boolStart):
226 | global dayofweek
227 | global days
228 | global direction
229 |
230 | if boolStart:
231 | newDay = dayofweek + mv -1
232 | else:
233 | newDay = dayofweek + mv - (2 if direction > 0 else 0)
234 |
235 | if newDay > 6:
236 | while newDay > 6:
237 | newDay -= 7
238 | elif newDay < 0:
239 | while newDay < 0:
240 | newDay += 7
241 |
242 | return days[newDay]
243 |
244 | ###
245 | #move(int direction)
246 | #@param direction Number of days forward or back to move.
247 | #
248 | #This method checks whether we're moving forward or back in
249 | #time (eg. yesterday or tomorrow), checks if it'll be a different
250 | #month, sets the dayofmonth, oldmonth, etc.
251 | ###
252 | def move(direction):
253 | global curmove
254 | global months
255 | global month
256 | global dayofmonth
257 | global nextMonth
258 | global nextYear
259 | global oldmonth
260 | global oldyear
261 | global dayofweek
262 | global year
263 |
264 | nextMonth = False
265 | nextYear = False
266 | curmove = 0
267 |
268 | if direction > 0:
269 | dayofweek += 1
270 | if dayofmonth < months[month][1] - 1:
271 | dayofmonth += 1
272 | else:
273 | dayofmonth = 0
274 | nextMonth = True
275 | oldmonth = month
276 | oldyear = year
277 | if month == 11:
278 | if year:
279 | year += 1
280 | nextYear = True
281 | month = 0
282 | else:
283 | month += 1
284 | else:
285 | dayofweek -= 1
286 | if dayofmonth == 0:
287 | nextMonth = True
288 | oldmonth = month
289 | oldyear = year
290 | month = 11 if month == 0 else month - 1
291 | if oldmonth == 0:
292 | dayofmonth = months[11][1]
293 | year -= 1
294 | nextYear = True
295 | else:
296 | dayofmonth = months[month][1]
297 |
298 | dayofmonth -= 1
299 |
300 | def getHexFade(max, fade):
301 | newFade = int(max * fade)
302 | newFade2 = newFade % 16
303 | newFade1 = (newFade - newFade2) / 16
304 | newFade1 = str(newFade1) if newFade1 < 10 else '{:x}'.format(newFade1)
305 | newFade2 = str(newFade2) if newFade2 < 10 else '{:x}'.format(newFade2)
306 | return [newFade1, newFade2]
307 |
308 | def displayDaysStatic(posX, posY, scalesize, imgSize, size, monthPos, months, month, fade):
309 | global dayButtons
310 | global dayofmonth
311 | global year
312 | global nextMonth
313 | global nextYear
314 | global oldmonth
315 | global oldyear
316 |
317 | ui.image(im.MatrixColor("calendar/img/bg.png", im.matrix.opacity(fade)), xpos=0, ypos=0)
318 |
319 | #dayofmonth -= 1
320 |
321 | wScale = 1
322 | if config.screen_width != 800:
323 | wScale = float(config.screen_width) / float(800)
324 | #if config.screen_height != 600:
325 | # pass
326 |
327 | mfade = getHexFade(119, fade)
328 |
329 | ui.text("{color=#545454"+mfade[0]+mfade[1]+"}"+str(month + 1)+"{/color}", xpos=550, ypos=60, size=math.floor(240*wScale))
330 | if year:
331 | yfade = getHexFade(170, fade)
332 | ui.text("{color=#545454"+yfade[0]+yfade[1]+"}"+str(year)+"{/color}", xpos=510, ypos=130, size=math.floor(30*wScale))
333 |
334 | displayDaysData(True, dayButtons, posX, posY, wScale, imgSize, fade, oldmonth + 1)
335 |
336 | def displayDays(posX, posY, scalesize, imgSize, size, monthPos, months, month, boolStart, boolEnd=False):
337 | global dayButtons
338 | global dayofmonth
339 | global year
340 | global nextMonth
341 | global nextYear
342 | global oldmonth
343 | global oldyear
344 |
345 | if boolStart:
346 | dayofmonth -= 1
347 |
348 | wScale = 1
349 | if config.screen_width != 800:
350 | wScale = float(config.screen_width) / float(800)
351 | #if config.screen_height != 600:
352 | # pass
353 | if nextMonth:
354 | curX = ((imgSize + (baseX - posX if direction < 0 else posX - baseX))) / 5 - 15
355 | if curX > 0:
356 | cmonth = oldmonth
357 | cyear = oldyear
358 | else:
359 | cmonth = month
360 | cyear = year
361 | curX = math.fabs(curX)
362 | if curX > 7:
363 | curX = 7
364 | curX = "%x" % curX
365 | ui.text("{color=#545454"+curX+curX+"}"+str(cmonth + 1)+"{/color}", xpos=550, ypos=60, size=math.floor(240*wScale))
366 | if year:
367 | if nextYear:
368 | ui.text("{color=#545454"+curX+curX+"}"+str(cyear)+"{/color}", xpos=510, ypos=130, size=math.floor(30*wScale))
369 | else:
370 | ui.text("{color=#545454AA}"+str(year)+"{/color}", xpos=510, ypos=130, size=math.floor(30*wScale))
371 | else:
372 | ui.text("{color=#54545477}"+str(month + 1)+"{/color}", xpos=550, ypos=60, size=math.floor(240*wScale))
373 | if year:
374 | ui.text("{color=#545454AA}"+str(year)+"{/color}", xpos=510, ypos=130, size=math.floor(30*wScale))
375 |
376 | displayDaysData(boolStart, dayButtons, posX, posY, wScale, imgSize, 1, oldmonth + 1)
377 |
378 | def displayDaysData(boolStart, dayButtons, posX, posY, wScale, imgSize, fade, nmonth):
379 |
380 | dfade = getHexFade(255, fade)
381 |
382 | for i in xrange(-1, 8): #Display 8 days, starting 1 day ago
383 | relDay = getRelativeDay(i, boolStart)
384 | pDay = getRelativeDay(i-1, boolStart)
385 | fWidth = 16 if relDay < 10 else 0
386 | nxPos = (int)(posX + (scalesize / 12) + math.floor(wScale * fWidth))
387 | nyPos = (int)(posY - (scalesize / 8 * 7))
388 |
389 | focus = "_focus" if i == direction + 1 else ""
390 |
391 | try:
392 | dImg = "calendar/img/x75/"+dayButtons[year][nmonth if pDay < relDay else oldmonth][relDay]
393 | except KeyError, e:
394 | dImg = "calendar/img/x75/"+dayButtons['default']
395 | finally:
396 | dImg = im.MatrixColor(dImg+focus+".png", im.matrix.opacity(fade), xpos=posX, ypos=posY)
397 | ui.image(dImg)
398 |
399 | ui.text("{font=calendar/lastunif.ttf}{color=#545454"+dfade[0]+dfade[1]+"}"+str(relDay)+"{/color}{/font}", xpos=nxPos, ypos=nyPos, size=math.floor(48*wScale))
400 | nxPos = (int)(posX + (scalesize / 12) + math.floor(wScale * 3)) + int(wScale * 6)
401 | nyPos -= (int)(wScale * 12)
402 | cDay = getRelativeWeekDay(i, boolStart)[0:3]
403 | ui.text("{font=calendar/lastunif.ttf}{color=#545454"+dfade[0]+dfade[1]+"}"+cDay+"{/color}{/font}", xpos=nxPos, ypos=nyPos, size=math.floor(wScale * 21))
404 | posX += imgSize
405 |
406 | ###
407 | #Background Image
408 | ###
409 | #image bg Calendar = "bg/Personal/HomeStreet_01.png"
410 | image bg Calendar = "calendar/img/bg.png"
411 |
412 | label calendar:
413 |
414 | #$ hide_window() #Hide the text window. There's no point having it here.
415 | scene black
416 |
417 | python:
418 | size = (config.screen_width, config.screen_height)
419 | monthPos = 25 #Y position (in px) of month label to display
420 | month -= 1 #So users can set month as 1-12 instead of 0-11
421 | oldmonth = month
422 | oldyear = year
423 | newsize = size[1] / 5 #One quarter of window width
424 | scalesize = int(math.floor(newsize * 2 / 3)) #One sixth of window width
425 |
426 | imgSize = 112
427 | baseX = (int)(size[0] / 2 - 8.73 * imgSize / 2)
428 | posX = baseX
429 | posY = size[1] * 3 / 4 - 75 / 2
430 |
431 | initStartDelay = startDelay
432 |
433 | while startDelay > 0:
434 | fade = (initStartDelay - startDelay) / initStartDelay
435 | displayDaysStatic(posX, posY, scalesize, imgSize, size, monthPos, months, month, fade)
436 | startDelay -= 0.015
437 | renpy.pause(0.015)
438 |
439 | startDelay = 0.5
440 | while startDelay > 0:
441 | displayDaysStatic(posX, posY, scalesize, imgSize, size, monthPos, months, month, 1)
442 | startDelay -= 0.015
443 | renpy.pause(0.015)
444 |
445 | scene bg Calendar
446 |
447 | python:
448 | move(direction)
449 |
450 | curmove = 0
451 | moved = 0
452 | speed = imgSize / 30
453 | curmonth = months[month][0]
454 | lastMove = False
455 |
456 | done = direction == 0
457 | while not done:
458 | curmove += speed * (direction if direction < 3 else 3)
459 | if math.fabs(curmove) >= imgSize:
460 | lastMove = True
461 | posX = baseX - imgSize
462 | else:
463 | posX = baseX - curmove
464 | #TODO: add animation?
465 |
466 | displayDays(posX, posY, scalesize, imgSize, size, monthPos, months, month, False)
467 |
468 | if lastMove:
469 | lastMove = False
470 | if not math.fabs(curmove) >= imgSize * math.fabs(direction):
471 | direction = direction - 1 if direction > 0 else direction + 1
472 | move(direction)
473 | else:
474 | done = True
475 |
476 | renpy.pause(1/60)
477 |
478 | #Finished looping. Display end result for intDelay seconds.
479 | displayDays(posX, posY, scalesize, imgSize, size, monthPos, months, month, False, boolEnd=True)
480 |
481 | renpy.pause(intDelay)
482 |
483 | startDelay = 0
484 | initStartDelay = intDelay
485 | if direction != 0:
486 | dayofmonth -= 1
487 | dayofweek -= 1
488 | direction = 1
489 | else:
490 | dayofmonth += 1
491 | dayofweek += 1
492 |
493 | while startDelay < initStartDelay:
494 | fade = (initStartDelay - startDelay) / initStartDelay
495 | displayDaysStatic(posX, posY, scalesize, imgSize, size, monthPos, months, month, fade)
496 | startDelay += 0.015
497 | renpy.pause(0.015)
498 |
499 | scene black
500 |
501 | python:
502 | renpy.jump(label_cont)
503 |
--------------------------------------------------------------------------------