Conditions | 1 |
Total Lines | 95 |
Code Lines | 72 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | # |
||
207 | def createUI(self): |
||
208 | w, h = gdata.scrnSize |
||
209 | self.win = ui.Window(self.app, |
||
210 | modal = 1, |
||
211 | movable = 0, |
||
212 | title = _('Select, which galaxy types do you want to play'), |
||
213 | rect = ui.Rect((w - 564) / 2, (h - 404) / 2, 564, 404), |
||
214 | layoutManager = ui.SimpleGridLM(), |
||
215 | tabChange = True |
||
216 | ) |
||
217 | ui.Listbox(self.win, layout = (0, 0, 28, 7), id = 'vBookingPublic', |
||
218 | sortedBy = ('text', 1), |
||
219 | columns = ( |
||
220 | ('', 'tChoice', 1, ui.ALIGN_NONE), |
||
221 | (_('Galaxy type'), 'text', 6, ui.ALIGN_NONE), |
||
222 | (_('Scenario'), 'tScenario', 6, ui.ALIGN_NONE), |
||
223 | (_('Queue'), 'tCur', 3, ui.ALIGN_NONE), |
||
224 | (_('Capacity'), 'tPos', 3, ui.ALIGN_NONE), |
||
225 | (_('Last start'), 'tTime', 8, ui.ALIGN_E) |
||
226 | ), |
||
227 | columnLabels = 1, |
||
228 | action = 'onSelect', |
||
229 | ) |
||
230 | ui.Listbox(self.win, layout = (0, 0, 28, 7), id = 'vBookingPrivate', |
||
231 | sortedBy = ('tOwner', 1), |
||
232 | columns = ( |
||
233 | ('', 'tChoice', 1, ui.ALIGN_NONE), |
||
234 | (_('Galaxy type'), 'text', 6, ui.ALIGN_NONE), |
||
235 | (_('Scenario'), 'tScenario', 6, ui.ALIGN_NONE), |
||
236 | (_('Queue'), 'tCur', 3, ui.ALIGN_NONE), |
||
237 | (_('Capacity'), 'tPos', 3, ui.ALIGN_NONE), |
||
238 | (_('Owner'), 'tOwner', 8, ui.ALIGN_E) |
||
239 | ), |
||
240 | columnLabels = 1, |
||
241 | action = 'onSelect', |
||
242 | ) |
||
243 | self.win.subscribeAction('*', self) |
||
244 | |||
245 | ui.Button(self.win, layout = (0, 7, 8, 1), id = "vPublicToggle", text = _('Show personal bookings'), action = 'onPublicToggle', |
||
246 | tooltipTitle = _("Booking types"), |
||
247 | tooltip = _("Public Bookings\nPublic bookings are recommended way how to jump into new game.\nWhen queue is full, galaxy creation is triggered, and you can start adventure with group of strangers.\n\nPrivate Bookings\nPrivate bookings are the way to start game with group of your friends.\nEvery private booking requires password chosen by the owner.\nSingle player games cannot be privately booked (as they are private by definition).") |
||
248 | ) |
||
249 | ui.Button(self.win, layout = (20, 7, 8, 1), id = "vCreatePrivate", text = _('Create private booking'), action = 'onCreatePrivate', |
||
250 | tooltipTitle = _("Create Private Booking"), |
||
251 | tooltip = _("Private bookings are way how to create games for group of friends.\n\ |
||
252 | Every booking has to be created password protected, so you have to tell others\n\ |
||
253 | what the password is.\n\n\ |
||
254 | Account has limit of {0} private bookings at the time. Created galaxies\n\ |
||
255 | no longers counts into the limit.".format(ige.ospace.Const.BOOKING_PRIVATE_LIMIT)) |
||
256 | ) |
||
257 | |||
258 | ui.Button(self.win, layout = (20, 7, 8, 1), id = "vDeletePrivate", text = _('Delete private booking'), action = 'onDeletePrivate', |
||
259 | tooltipTitle = _("Delete Private Booking"), |
||
260 | tooltip = _("As the author of the booking, you can delete it at any time. No further warning will be issued.") |
||
261 | ) |
||
262 | |||
263 | ui.Button(self.win, layout = (7, 8.5, 14, 1.5), id = "vToggle", text = _('Toggle booking'), action = 'onToggleBooking') |
||
264 | scrollBarInfo = ui.Scrollbar(self.win, layout = (27, 10.3, 1, 4.7)) |
||
265 | textBox = ui.Text(self.win, layout = (9, 10.3, 18, 4.7), id = "vInfo", editable = 0) |
||
266 | textBox.attachVScrollbar(scrollBarInfo) |
||
267 | |||
268 | ui.Button(self.win, layout = (0.5, 10.5, 8, 1), id = "vGoalToggle", text = _('Display Goals'), action = 'onGoalToggle') |
||
269 | ui.Label(self.win, layout = (0, 12, 4, 1), text = _("Planets:"), align = ui.ALIGN_W, |
||
270 | tooltipTitle = _("Planets"), |
||
271 | tooltip = _("Range of number of planets. About half of them is not colonizable at the beginning.") |
||
272 | ) |
||
273 | ui.Label(self.win, layout = (4, 12, 4.5, 1), id = "vPlanets", align = ui.ALIGN_E, |
||
274 | tooltipTitle = _("Planets"), |
||
275 | tooltip = _("Range of number of planets. About half of them is not colonizable at the beginning.") |
||
276 | ) |
||
277 | ui.Label(self.win, layout = (0, 13, 4, 1), text = _("Radius:"), align = ui.ALIGN_W, |
||
278 | tooltipTitle = _("Radius"), |
||
279 | tooltip = _("Galaxy radius, implies speed of game.") |
||
280 | ) |
||
281 | ui.Label(self.win, layout = (4, 13, 4.5, 1), id = "vRadius", align = ui.ALIGN_E, |
||
282 | tooltipTitle = _("Radius"), |
||
283 | tooltip = _("Galaxy radius, implies speed of game.") |
||
284 | ) |
||
285 | ui.Label(self.win, layout = (0, 14, 4, 1), text = _("Grouping:"), align = ui.ALIGN_W, |
||
286 | tooltipTitle = _("Grouping"), |
||
287 | tooltip = _("How many starting positions are grouped together in vicinity.") |
||
288 | ) |
||
289 | ui.Label(self.win, layout = (4, 14, 4.5, 1), id = "vPlayerGroup", align = ui.ALIGN_E, |
||
290 | tooltipTitle = _("Grouping"), |
||
291 | tooltip = _("How many starting positions are grouped together.") |
||
292 | ) |
||
293 | |||
294 | ui.Label(self.win, layout = (0, 15.2, 4, 1), text = _("Resources:"), align = ui.ALIGN_W) |
||
295 | ui.Text (self.win, layout = (4, 15.2, 23, 1.6), id = "vResources", editable = 0) |
||
296 | ui.Label(self.win, layout = (0, 17, 4, 1), text = _("Challenges:"), align = ui.ALIGN_W) |
||
297 | ui.Label(self.win, layout = (4, 17, 24, 1), id = "vChallenges", align = ui.ALIGN_W) |
||
298 | |||
299 | ui.Title(self.win, layout = (0, 18, 24, 1), id = 'vStatusBar', align = ui.ALIGN_W) |
||
300 | ui.TitleButton(self.win, layout = (24, 18, 4, 1), text = _('Exit'), action = 'onCancel') |
||
301 | self.win.statusBar = self.win.vStatusBar |
||
302 |