1
|
|
|
# coding: utf-8 |
2
|
|
|
|
3
|
1 |
|
import zope.interface |
4
|
|
|
|
5
|
1 |
|
from schematics.models import Model |
6
|
1 |
|
from schematics.types import BooleanType, IntType |
7
|
|
|
|
8
|
1 |
|
from .interfaces import INISerializable, DefaultProvider |
9
|
1 |
|
from .helpers import field_from_ini |
10
|
|
|
|
11
|
|
|
|
12
|
1 |
View Code Duplication |
@zope.interface.implementer(INISerializable) |
|
|
|
|
13
|
1 |
|
@zope.interface.implementer(DefaultProvider) |
14
|
1 |
|
class Other(Model): |
15
|
1 |
|
difficulty = IntType( |
16
|
|
|
min_value=0, |
17
|
|
|
default=193791, |
18
|
|
|
required=True, |
19
|
|
|
) |
20
|
1 |
|
display_custom_skins = BooleanType( |
21
|
|
|
default=True, |
22
|
|
|
required=True, |
23
|
|
|
) |
24
|
1 |
|
allow_custom_sounds = BooleanType( |
25
|
|
|
default=True, |
26
|
|
|
required=True, |
27
|
|
|
) |
28
|
1 |
|
filter_user_names = BooleanType( |
29
|
|
|
default=False, |
30
|
|
|
required=True, |
31
|
|
|
) |
32
|
1 |
|
small_way_point_labels = BooleanType( |
33
|
|
|
default=True, |
34
|
|
|
required=True, |
35
|
|
|
) |
36
|
1 |
|
skip_paratrooper_views = BooleanType( |
37
|
|
|
default=False, |
38
|
|
|
required=True, |
39
|
|
|
) |
40
|
1 |
|
new_clouds = BooleanType( |
41
|
|
|
default=True, |
42
|
|
|
required=True, |
43
|
|
|
) |
44
|
|
|
|
45
|
1 |
|
@classmethod |
46
|
|
|
def from_ini(cls, ini): |
47
|
|
|
return cls({ |
48
|
|
|
'difficulty': field_from_ini( |
49
|
|
|
cls.difficulty, ini, |
50
|
|
|
'NET', 'difficulty', |
51
|
|
|
), |
52
|
|
|
'display_custom_skins': field_from_ini( |
53
|
|
|
cls.display_custom_skins, ini, |
54
|
|
|
'NET', 'SkinDownload', |
55
|
|
|
), |
56
|
|
|
'allow_custom_sounds': field_from_ini( |
57
|
|
|
cls.allow_custom_sounds, ini, |
58
|
|
|
'NET', 'allowCustomSounds', |
59
|
|
|
), |
60
|
|
|
'filter_user_names': field_from_ini( |
61
|
|
|
cls.filter_user_names, ini, |
62
|
|
|
'NET', 'filterUserNames', |
63
|
|
|
), |
64
|
|
|
'small_way_point_labels': field_from_ini( |
65
|
|
|
cls.small_way_point_labels, ini, |
66
|
|
|
'game', 'SmallMapWPLabels', |
67
|
|
|
), |
68
|
|
|
'skip_paratrooper_views': field_from_ini( |
69
|
|
|
cls.skip_paratrooper_views, ini, |
70
|
|
|
'game', 'SkipParatrooperViews', |
71
|
|
|
), |
72
|
|
|
'new_clouds': field_from_ini( |
73
|
|
|
cls.new_clouds, ini, |
74
|
|
|
'game', 'TypeClouds', |
75
|
|
|
), |
76
|
|
|
}) |
77
|
|
|
|
78
|
1 |
|
@classmethod |
79
|
|
|
def default(cls): |
80
|
|
|
return cls({ |
81
|
|
|
field_name: field.default |
82
|
|
|
for field_name, field in cls.fields.items() |
83
|
|
|
}) |
84
|
|
|
|