~vbkaisetsu/+junk/renpy-vertical-text

« back to all changes in this revision

Viewing changes to extras/dse/day_planner.rpy

  • Committer: tom
  • Date: 2006-10-01 14:09:56 UTC
  • Revision ID: svn-v3-trunk1:a20cb6e2-ff0c-0410-a951-e6c088e16c52:renpy%2Ftrunk:148

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# This contains code for the new day planner. You probably
2
 
# don't want to change this file, but it might make sense to
3
 
# change many of the variables or styles defined here from
4
 
# other files.
5
 
 
6
 
init -100:
7
 
 
8
 
    python:
9
 
 
10
 
        # A window placed behind the day planner (empty).
11
 
        style.create('dp_window', 'window')
12
 
        style.dp_window.ypos = 120
13
 
        style.dp_window.yanchor = 'top'
14
 
 
15
 
        # The grid containing the three choices in the day planner.
16
 
        style.create('dp_grid', 'default')
17
 
        style.dp_grid.xfill = True
18
 
        
19
 
        # Windows containing the groups of choices in the day planner.
20
 
        style.create('dp_choice', 'default')
21
 
        style.dp_choice.xpos = 0.5
22
 
        style.dp_choice.xanchor = 'center'
23
 
 
24
 
        # Action buttons.
25
 
        style.create('dp_button', 'button')
26
 
        style.create('dp_button_text', 'button_text')
27
 
 
28
 
        style.create('dp_done_button', 'button')
29
 
        style.create('dp_done_button_text', 'button_text')
30
 
 
31
 
        style.dp_done_button.ypos = 0.95
32
 
        style.dp_done_button.yanchor = 'bottom'
33
 
        
34
 
        # Labels.
35
 
        style.create('dp_label', 'default')
36
 
        style.dp_label.xpos = 0.5
37
 
        style.dp_label.xanchor = 'center'
38
 
 
39
 
        # The amount of padding between the label and the action
40
 
        # in a choice.
41
 
        dp_padding = 12 
42
 
 
43
 
        # The amount of padding between the choices and done.
44
 
        dp_done_padding = 32
45
 
 
46
 
        # The title of the done button.
47
 
        dp_done_title = "Done Planning Day"
48
 
 
49
 
    python:
50
 
 
51
 
        # A list of the periods of the day that are present in the
52
 
        # day planner. This can be changed at runtime.
53
 
        dp_period_names = [ "Morning", "Afternoon", "Evening" ]
54
 
 
55
 
        # A list of variables that will take the selected choices
56
 
        # for each of the periods named above.
57
 
        dp_period_vars = [ "morning_act",
58
 
                           "afternoon_act",
59
 
                           "evening_act", ]
60
 
 
61
 
        # A map from the period names to a list of the activities
62
 
        # available for that period. This may be conputed before
63
 
        # each call to day_planner. Each entry is a tuple, where
64
 
        # the first element is the name shown to the user, and the
65
 
        # second is the name assigned to the variable for that
66
 
        # period.
67
 
        dp_period_acts = {        
68
 
            'Morning': [
69
 
            ( 'Attend Class', "class" ),
70
 
            ( 'Cut Class', "cut"),
71
 
            ],
72
 
            
73
 
            'Afternoon': [
74
 
            ( 'Study', "study" ),
75
 
            ( 'Hang Out', "hang" ),
76
 
            ],
77
 
            
78
 
            'Evening' : [
79
 
            ( 'Exercise', "exercise" ),
80
 
            ( 'Play Games', "play" ),
81
 
            ],
82
 
            }
83
 
 
84
 
        
85
 
 
86
 
# We assume that the various period variables have been assigned
87
 
# default values by this point.
88
 
label day_planner:
89
 
 
90
 
    call dp_callback from _call_dp_callback_1
91
 
 
92
 
    python hide:
93
 
 
94
 
        renpy.choice_for_skipping()
95
 
 
96
 
        ui.window(style='dp_window')
97
 
        ui.vbox(dp_done_padding)
98
 
 
99
 
        ui.grid(len(dp_period_names), 1, xfill=True, style='dp_grid')
100
 
 
101
 
        # True iff every period has a valid value.
102
 
        can_continue = True
103
 
 
104
 
        for period, var in zip(dp_period_names, dp_period_vars):
105
 
 
106
 
            ui.window(style='dp_choice')
107
 
            ui.vbox()
108
 
 
109
 
            _label_factory(period, "dp")
110
 
            ui.null(height=dp_padding)
111
 
 
112
 
            valid_value = False
113
 
 
114
 
            for label, value in dp_period_acts[period]:
115
 
 
116
 
                def clicked(var=var, value=value):
117
 
                    setattr(store, var, value)
118
 
                    return True
119
 
 
120
 
                valid_value |= getattr(store, var) == value
121
 
 
122
 
                _button_factory(label, "dp",
123
 
                                selected = getattr(store, var) == value,
124
 
                                clicked=clicked)
125
 
 
126
 
            can_continue &= valid_value
127
 
 
128
 
            ui.close()
129
 
 
130
 
        ui.close()
131
 
 
132
 
        if can_continue:
133
 
            clicked = lambda : False
134
 
        else:
135
 
            clicked = None
136
 
            
137
 
        _button_factory(dp_done_title, "dp_done",
138
 
                        clicked = clicked )
139
 
 
140
 
        ui.close()
141
 
 
142
 
        
143
 
    if ui.interact():
144
 
        jump day_planner
145
 
 
146
 
    return 
147