|
| 1 | +import webbrowser |
| 2 | + |
| 3 | +import wx |
| 4 | +import wx.lib.agw.hyperlink |
| 5 | + |
| 6 | +from amulet_map_editor import lang |
| 7 | + |
| 8 | + |
| 9 | +_padding = 20 |
| 10 | + |
| 11 | + |
| 12 | +class LicenceDialog(wx.Dialog): |
| 13 | + def __init__(self, parent: wx.Window): |
| 14 | + super().__init__(parent, style=wx.CAPTION) |
| 15 | + self.SetTitle(lang.get("licence_dialog.title")) |
| 16 | + |
| 17 | + root_sizer = wx.BoxSizer(wx.VERTICAL) |
| 18 | + root_sizer.AddSpacer(_padding) |
| 19 | + |
| 20 | + root_sizer_2 = wx.BoxSizer(wx.HORIZONTAL) |
| 21 | + root_sizer.Add(root_sizer_2) |
| 22 | + |
| 23 | + root_sizer_2.AddSpacer(_padding) |
| 24 | + self._main_sizer = wx.BoxSizer(wx.VERTICAL) |
| 25 | + root_sizer_2.Add(self._main_sizer) |
| 26 | + root_sizer_2.AddSpacer(_padding) |
| 27 | + |
| 28 | + root_sizer.AddSpacer(_padding) |
| 29 | + |
| 30 | + title = wx.StaticText( |
| 31 | + self, |
| 32 | + wx.ID_ANY, |
| 33 | + lang.get("licence_dialog.header"), |
| 34 | + style=wx.ALIGN_CENTER_HORIZONTAL, |
| 35 | + ) |
| 36 | + font = title.GetFont() |
| 37 | + font.SetPointSize(25) |
| 38 | + title.SetFont(font) |
| 39 | + self._main_sizer.Add(title, 0, wx.ALL | wx.EXPAND, 5) |
| 40 | + |
| 41 | + self._add_line(lang.get("licence_dialog.content_1")) |
| 42 | + self._main_sizer.AddSpacer(20) |
| 43 | + self._add_line(lang.get("licence_dialog.content_2")) |
| 44 | + self._main_sizer.AddSpacer(20) |
| 45 | + self._add_line(lang.get("licence_dialog.content_3")) |
| 46 | + self._main_sizer.AddSpacer(20) |
| 47 | + self._add_line(lang.get("licence_dialog.content_4")) |
| 48 | + |
| 49 | + self._main_sizer.AddSpacer(10) |
| 50 | + |
| 51 | + button_sizer = wx.StdDialogButtonSizer() |
| 52 | + root_sizer.Add(button_sizer, 0, wx.ALIGN_RIGHT | wx.ALL, 4) |
| 53 | + |
| 54 | + self._quit_button = wx.Button( |
| 55 | + self, wx.ID_CANCEL, lang.get("licence_dialog.quit_button") |
| 56 | + ) |
| 57 | + self.SetEscapeId(self._quit_button.GetId()) |
| 58 | + button_sizer.Add(self._quit_button) |
| 59 | + |
| 60 | + self._buy_button = wx.Button( |
| 61 | + self, wx.ID_ANY, lang.get("licence_dialog.buy_button") |
| 62 | + ) |
| 63 | + self._buy_button.SetDefault() |
| 64 | + self._buy_button.Bind(wx.EVT_BUTTON, self._buy) |
| 65 | + button_sizer.Add(self._buy_button) |
| 66 | + |
| 67 | + self._continue_button = wx.Button( |
| 68 | + self, wx.ID_OK, lang.get("licence_dialog.continue_button") |
| 69 | + ) |
| 70 | + button_sizer.Add(self._continue_button) |
| 71 | + self.SetAffirmativeId(self._continue_button.GetId()) |
| 72 | + |
| 73 | + button_sizer.Realize() |
| 74 | + |
| 75 | + self.SetSizer(root_sizer) |
| 76 | + root_sizer.Fit(self) |
| 77 | + |
| 78 | + self.Layout() |
| 79 | + |
| 80 | + def _add_line(self, text: str) -> None: |
| 81 | + content = wx.StaticText( |
| 82 | + self, |
| 83 | + wx.ID_ANY, |
| 84 | + text, |
| 85 | + style=wx.ALIGN_CENTER_HORIZONTAL, |
| 86 | + ) |
| 87 | + font = content.GetFont() |
| 88 | + font.SetPointSize(12) |
| 89 | + content.SetFont(font) |
| 90 | + content.Wrap(750) |
| 91 | + self._main_sizer.Add(content, 0, wx.EXPAND) |
| 92 | + |
| 93 | + @staticmethod |
| 94 | + def _buy(_) -> None: |
| 95 | + webbrowser.open("https://www.amuletmc.com/") |
0 commit comments