Skip to content

Commit 684eeb4

Browse files
Add support dialog (#1221)
* Add support dialog * Fix variable used before defined * Add support button to the home page * Reformat
1 parent e8a83ce commit 684eeb4

File tree

4 files changed

+181
-1
lines changed

4 files changed

+181
-1
lines changed

amulet_map_editor/api/framework/app.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
import sys
44
import locale
55
import logging
6+
import time
67

78
from amulet_map_editor.api import config
89
from amulet_map_editor import __version__
910
from .warning_dialog import WarningDialog
11+
from .support_dialog import SupportDialog
1012

1113
log = logging.getLogger(__name__)
1214

@@ -27,6 +29,18 @@ def OnInit(self):
2729
self._amulet_ui.Show()
2830

2931
meta_config = config.get("amulet_meta", {})
32+
33+
support_dialog_show_time = meta_config.get("support_dialog_show_time", 0)
34+
if support_dialog_show_time < time.time() - 3600 * 24 * 7:
35+
# Last shown more than a week ago
36+
support_dialog = SupportDialog(
37+
self._amulet_ui, 60, support_dialog_show_time == 0
38+
)
39+
support_dialog.Centre()
40+
if support_dialog.ShowModal() == wx.ID_OK:
41+
meta_config["support_dialog_show_time"] = time.time()
42+
config.put("amulet_meta", meta_config)
43+
3044
if not meta_config.get("do_not_show_warning_dialog", False):
3145
warning_dialog = WarningDialog(self._amulet_ui)
3246
warning_dialog.Centre()

amulet_map_editor/api/framework/pages/main_menu.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from amulet_map_editor.api import image, lang
1010
from .base_page import BasePageUI
11+
from ..support_dialog import SupportDialog
1112
from amulet_map_editor.api.wx.ui.select_world import open_level_from_dialog
1213

1314

@@ -49,6 +50,11 @@ def __init__(self, parent: wx.Window):
4950
)
5051
sizer.Add(self._open_world_button, 0, wx.ALL | wx.CENTER, 5)
5152

53+
self._support_button = wx.Button(self, size=(400, 70))
54+
self._support_button.SetFont(button_font)
55+
self._support_button.Bind(wx.EVT_BUTTON, self._support)
56+
sizer.Add(self._support_button, 0, wx.ALL | wx.CENTER, 5)
57+
5258
self._user_manual_button = wx.Button(self, size=(400, 70))
5359
self._user_manual_button.SetFont(button_font)
5460
self._user_manual_button.Bind(wx.EVT_BUTTON, self._documentation)
@@ -109,6 +115,7 @@ def __init__(self, parent: wx.Window):
109115
def _load_strings(self):
110116
self._amulet_name.SetLabel(lang.get("meta.amulet"))
111117
self._open_world_button.SetLabel(lang.get("main_menu.open_world"))
118+
self._support_button.SetLabel(lang.get("main_menu.support"))
112119
self._user_manual_button.SetLabel(lang.get("main_menu.user_manual"))
113120
self._user_manual_button.SetToolTip(lang.get("app.browser_open_tooltip"))
114121
self._bug_tracker_button.SetLabel(lang.get("main_menu.bug_tracker"))
@@ -118,6 +125,11 @@ def _load_strings(self):
118125
self._sponsor_label.SetLabel(lang.get("main_menu.our_sponsors"))
119126
self._sponsor_link.SetLabel(lang.get("main_menu.sponsor_link"))
120127

128+
def _support(self, _):
129+
support_dialog = SupportDialog(self, 0, False)
130+
support_dialog.Centre()
131+
support_dialog.ShowModal()
132+
121133
@staticmethod
122134
def _documentation(_):
123135
webbrowser.open(
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
import wx
2+
import wx.lib.agw.hyperlink
3+
4+
from amulet_map_editor import lang
5+
6+
7+
class SupportDialog(wx.Dialog):
8+
def __init__(self, parent: wx.Window, wait_time: int, is_first: bool):
9+
super().__init__(parent, style=wx.CAPTION)
10+
self.SetTitle(lang.get("support_dialog.title"))
11+
12+
self._wait_time = wait_time
13+
14+
main_sizer = wx.BoxSizer(wx.VERTICAL)
15+
16+
title = wx.StaticText(
17+
self,
18+
wx.ID_ANY,
19+
lang.get("support_dialog.title"),
20+
style=wx.ALIGN_CENTER_HORIZONTAL,
21+
)
22+
font = title.GetFont()
23+
font.SetPointSize(50)
24+
title.SetFont(font)
25+
main_sizer.Add(title, 0, wx.ALL | wx.EXPAND, 5)
26+
27+
content_1 = wx.StaticText(
28+
self,
29+
wx.ID_ANY,
30+
lang.get("support_dialog.content_1"),
31+
style=wx.ALIGN_CENTER_HORIZONTAL,
32+
)
33+
font = content_1.GetFont()
34+
font.SetPointSize(12)
35+
content_1.SetFont(font)
36+
content_1.Wrap(750)
37+
main_sizer.Add(content_1, 0, wx.EXPAND)
38+
39+
main_sizer.AddSpacer(20)
40+
41+
content_2 = wx.StaticText(
42+
self,
43+
wx.ID_ANY,
44+
lang.get("support_dialog.content_2"),
45+
style=wx.ALIGN_CENTER_HORIZONTAL,
46+
)
47+
font = content_2.GetFont()
48+
font.SetPointSize(12)
49+
content_2.SetFont(font)
50+
content_2.Wrap(750)
51+
main_sizer.Add(content_2, 0, wx.EXPAND)
52+
53+
main_sizer.AddSpacer(20)
54+
55+
github_sponsor_link = wx.lib.agw.hyperlink.HyperLinkCtrl(
56+
self,
57+
wx.ID_ANY,
58+
lang.get("support_dialog.github_sponsor"),
59+
URL="https://github.com/sponsors/Amulet-Team",
60+
)
61+
font = github_sponsor_link.GetFont()
62+
font.SetPointSize(12)
63+
github_sponsor_link.SetFont(font)
64+
main_sizer.Add(github_sponsor_link, 0, wx.ALIGN_CENTER)
65+
66+
main_sizer.AddSpacer(10)
67+
68+
paypal_sponsor_link = wx.lib.agw.hyperlink.HyperLinkCtrl(
69+
self,
70+
wx.ID_ANY,
71+
lang.get("support_dialog.paypal_sponsor"),
72+
URL="https://www.paypal.com/donate/?hosted_button_id=6G7P8K36W7TX2",
73+
)
74+
font = paypal_sponsor_link.GetFont()
75+
font.SetPointSize(12)
76+
paypal_sponsor_link.SetFont(font)
77+
main_sizer.Add(paypal_sponsor_link, 0, wx.ALIGN_CENTER)
78+
79+
main_sizer.AddSpacer(20)
80+
81+
content_3 = wx.StaticText(
82+
self,
83+
wx.ID_ANY,
84+
lang.get("support_dialog.content_3"),
85+
style=wx.ALIGN_CENTER_HORIZONTAL,
86+
)
87+
font = content_3.GetFont()
88+
font.SetPointSize(12)
89+
content_3.SetFont(font)
90+
content_3.Wrap(750)
91+
main_sizer.Add(content_3, 0, wx.EXPAND)
92+
93+
main_sizer.AddSpacer(10)
94+
95+
button_sizer = wx.StdDialogButtonSizer()
96+
main_sizer.Add(button_sizer, 0, wx.ALIGN_RIGHT | wx.ALL, 4)
97+
98+
self._ignore_button = wx.Button(self, wx.ID_CANCEL)
99+
self._ignore_button.SetDefault()
100+
self.SetEscapeId(self._ignore_button.GetId())
101+
button_sizer.Add(self._ignore_button)
102+
103+
self._support_button = wx.Button(
104+
self, wx.ID_OK, lang.get("support_dialog.support_button")
105+
)
106+
if is_first:
107+
self._support_button.Disable()
108+
button_sizer.Add(self._support_button)
109+
self.SetAffirmativeId(self._support_button.GetId())
110+
111+
self._set_ignore_text()
112+
113+
button_sizer.Realize()
114+
115+
self.SetSizer(main_sizer)
116+
main_sizer.Fit(self)
117+
118+
self._timer = wx.Timer(self)
119+
if 0 < self._wait_time:
120+
self.Bind(wx.EVT_TIMER, self._on_timer, self._timer)
121+
self._timer.Start(1000)
122+
123+
self.Layout()
124+
125+
def _set_ignore_text(self) -> None:
126+
if 0 < self._wait_time:
127+
self._ignore_button.Disable()
128+
self._ignore_button.SetLabel(
129+
lang.get("support_dialog.ignore_button_wait").format(t=self._wait_time)
130+
)
131+
else:
132+
self._support_button.Enable()
133+
self._ignore_button.Enable()
134+
self._ignore_button.SetLabel(lang.get("support_dialog.ignore_button"))
135+
self.Layout()
136+
137+
def _on_timer(self, evt) -> None:
138+
if 0 < self._wait_time:
139+
self._wait_time -= 1
140+
if self._wait_time <= 0:
141+
self._timer.Stop()
142+
self._set_ignore_text()

amulet_map_editor/lang/en.lang

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,29 @@ menu_bar.help.menu_name=&Help
8383
## The start screen
8484
main_menu.tab_name=Main Menu
8585
main_menu.open_world=Open World
86+
main_menu.support=Support Amulet
8687
main_menu.user_manual=User Manual
8788
main_menu.bug_tracker=Bug Tracker
8889
main_menu.discord=Amulet Discord
8990
main_menu.our_sponsors=Our Sponsors
90-
main_menu.sponsor_link=(Sponsor us to get your name here)
91+
main_menu.sponsor_link=(Click here to support us on Github and get your name here)
9192

9293
# Language Select
9394
language_select.title=Language Select
9495
language_select.help=Select the language to use in Amulet from the list below.
9596
language_select.contribute=If you want to fix or add translations click here.
9697

98+
# Support Dialog
99+
support_dialog.title=I Need Your Support!
100+
support_dialog.support_button=I am contributing to Amulet.
101+
support_dialog.ignore_button_wait=Continue without contributing. Wait {t} seconds
102+
support_dialog.ignore_button=Continue without contributing.
103+
support_dialog.content_1=Pathway Studios have been funding the development of Amulet for the past 6 years but have decided to stop funding development from 2026.
104+
support_dialog.content_2=Who am I?\nI am James. You may know me as gentlegiantJGC.\nAmulet has been my job since 2019 but to continue I need financial support.\nAny contribution, no matter how small, is greatly appreciated.\nWithout your support, development and maintenance of Amulet will stop and Amulet will not be able to open worlds from new versions.
105+
support_dialog.github_sponsor=Support Amulet on Github
106+
support_dialog.paypal_sponsor=Support Amulet on Paypal
107+
support_dialog.content_3=The future of Amulet\nFor the past two years I have been rewriting Amulet from the ground up.\nMost of the libraries are now written in C++ for improved speed and parallelisation and the new application uses Qt to allow more control over the user interface.\nI still have a way to go until the rewrite can replace this version of Amulet but experimental versions of the rewrite should be out soon.
108+
97109
# Warning Dialog
98110
warning_dialog.title=Welcome to Amulet
99111
warning_dialog.content=Hello and welcome to Amulet.\n\nWe suggest creating backups of your worlds before opening them in Amulet.\n\nWe try to make sure that Amulet does not corrupt worlds but the save format is undocumented and constantly changing and sometimes we just get things wrong.\n\nFor these reasons we only officially support full releases we have tested against.\nJava snapshots, Bedrock betas and experimental features may work but are untested so not officially supported.\n\nCurrently entities are not supported and items are only supported within the same platform.\nIf you find a feature you want added or a bug that needs fixing report it on our bug tracker.\nPlease use the search tool to see if it has been reported before creating a new ticket.\n\nIf you are new we suggest reading the user manual to familiarise yourself with the program.\n\n- The Amulet Team

0 commit comments

Comments
 (0)