@@ 12-91 (lines=80) @@ | ||
9 | from .helpers import field_from_ini, field_to_ini |
|
10 | ||
11 | ||
12 | @zope.interface.implementer(INISerializable) |
|
13 | @zope.interface.implementer(DefaultProvider) |
|
14 | class Miscellaneous(Model): |
|
15 | difficulty = IntType( |
|
16 | min_value=0, |
|
17 | default=193791, |
|
18 | required=True, |
|
19 | ) |
|
20 | display_custom_skins = BooleanType( |
|
21 | default=True, |
|
22 | required=True, |
|
23 | ) |
|
24 | allow_custom_sounds = BooleanType( |
|
25 | default=True, |
|
26 | required=True, |
|
27 | ) |
|
28 | filter_user_names = BooleanType( |
|
29 | default=False, |
|
30 | required=True, |
|
31 | ) |
|
32 | display_small_way_point_labels = BooleanType( |
|
33 | default=True, |
|
34 | required=True, |
|
35 | ) |
|
36 | skip_paratrooper_views = BooleanType( |
|
37 | default=False, |
|
38 | required=True, |
|
39 | ) |
|
40 | use_new_clouds_rendering = BooleanType( |
|
41 | default=True, |
|
42 | required=True, |
|
43 | ) |
|
44 | ||
45 | @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 | 'display_small_way_point_labels': field_from_ini( |
|
65 | cls.display_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 | 'use_new_clouds_rendering': field_from_ini( |
|
73 | cls.use_new_clouds_rendering, ini, |
|
74 | 'game', 'TypeClouds', |
|
75 | ), |
|
76 | }) |
|
77 | ||
78 | def to_ini(self, ini): |
|
79 | field_to_ini(self.difficulty, ini, 'NET', 'difficulty') |
|
80 | field_to_ini(self.display_custom_skins, ini, 'NET', 'SkinDownload') |
|
81 | field_to_ini(self.allow_custom_sounds, ini, 'NET', 'allowCustomSounds') |
|
82 | field_to_ini(self.filter_user_names, ini, 'NET', 'filterUserNames') |
|
83 | field_to_ini(self.display_small_way_point_labels, ini, 'game', 'SmallMapWPLabels') |
|
84 | field_to_ini(self.skip_paratrooper_views, ini, 'game', 'SkipParatrooperViews') |
|
85 | field_to_ini(self.use_new_clouds_rendering, ini, 'game', 'TypeClouds') |
|
86 | ||
87 | @classmethod |
|
88 | def default(cls): |
|
89 | return cls({ |
|
90 | field_name: field.default |
|
91 | for field_name, field in cls.fields.items() |
|
92 | }) |
|
93 |
@@ 13-91 (lines=79) @@ | ||
10 | from .helpers import field_from_ini, field_to_ini |
|
11 | ||
12 | ||
13 | @zope.interface.implementer(INISerializable) |
|
14 | @zope.interface.implementer(DefaultProvider) |
|
15 | class Users(Model): |
|
16 | show_tail_number = BooleanType( |
|
17 | default=True, |
|
18 | required=True, |
|
19 | ) |
|
20 | show_ping = BooleanType( |
|
21 | default=True, |
|
22 | required=True, |
|
23 | ) |
|
24 | show_callsign = BooleanType( |
|
25 | default=True, |
|
26 | required=True, |
|
27 | ) |
|
28 | show_belligerent = BooleanType( |
|
29 | default=True, |
|
30 | required=True, |
|
31 | ) |
|
32 | show_aircraft_designation = BooleanType( |
|
33 | default=True, |
|
34 | required=True, |
|
35 | ) |
|
36 | show_aircraft_type = BooleanType( |
|
37 | default=True, |
|
38 | required=True, |
|
39 | ) |
|
40 | show_score = BooleanType( |
|
41 | default=True, |
|
42 | required=True, |
|
43 | ) |
|
44 | ||
45 | @classmethod |
|
46 | def from_ini(cls, ini): |
|
47 | return cls({ |
|
48 | 'show_tail_number': field_from_ini( |
|
49 | cls.show_tail_number, ini, |
|
50 | 'NET', 'showPilotNumber', |
|
51 | ), |
|
52 | 'show_ping': field_from_ini( |
|
53 | cls.show_ping, ini, |
|
54 | 'NET', 'showPilotPing', |
|
55 | ), |
|
56 | 'show_callsign': field_from_ini( |
|
57 | cls.show_callsign, ini, |
|
58 | 'NET', 'showPilotName', |
|
59 | ), |
|
60 | 'show_belligerent': field_from_ini( |
|
61 | cls.show_belligerent, ini, |
|
62 | 'NET', 'showPilotArmy', |
|
63 | ), |
|
64 | 'show_aircraft_designation': field_from_ini( |
|
65 | cls.show_aircraft_designation, ini, |
|
66 | 'NET', 'showPilotACDesignation', |
|
67 | ), |
|
68 | 'show_aircraft_type': field_from_ini( |
|
69 | cls.show_aircraft_type, ini, |
|
70 | 'NET', 'showPilotACType', |
|
71 | ), |
|
72 | 'show_score': field_from_ini( |
|
73 | cls.show_score, ini, |
|
74 | 'NET', 'showPilotScore', |
|
75 | ), |
|
76 | }) |
|
77 | ||
78 | def to_ini(self, ini): |
|
79 | field_to_ini(self.show_tail_number, ini, 'NET', 'showPilotNumber') |
|
80 | field_to_ini(self.show_ping, ini, 'NET', 'showPilotPing') |
|
81 | field_to_ini(self.show_callsign, ini, 'NET', 'showPilotName') |
|
82 | field_to_ini(self.show_belligerent, ini, 'NET', 'showPilotArmy') |
|
83 | field_to_ini(self.show_aircraft_designation, ini, 'NET', 'showPilotACDesignation') |
|
84 | field_to_ini(self.show_aircraft_type, ini, 'NET', 'showPilotACType') |
|
85 | field_to_ini(self.show_score, ini, 'NET', 'showPilotScore') |
|
86 | ||
87 | @classmethod |
|
88 | def default(cls): |
|
89 | return cls({ |
|
90 | field_name: field.default |
|
91 | for field_name, field in cls.fields.items() |
|
92 | }) |
|
93 | ||
94 |