Skip to content

Commit

Permalink
Improved the sponsor section on the home page (#1059)
Browse files Browse the repository at this point in the history
The home page now lists github sponsors and Pathway.
Move the language button to the top right.
  • Loading branch information
gentlegiantJGC authored Jun 12, 2024
1 parent 7b2adb6 commit 5e68e5b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 13 deletions.
61 changes: 49 additions & 12 deletions amulet_map_editor/api/framework/pages/main_menu.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import webbrowser
from urllib.request import urlopen
from urllib.error import URLError
import json
import wx
import wx.adv
import wx.lib.inspection
Expand All @@ -13,6 +16,13 @@ def __init__(self, parent: wx.Window):
super(AmuletMainMenu, self).__init__(parent)
sizer = wx.BoxSizer(wx.VERTICAL)
self.SetSizer(sizer)

self._lang_button = wx.BitmapButton(
self, bitmap=image.icon.tablericons.language.bitmap(64, 64)
)
self._lang_button.Bind(wx.EVT_BUTTON, self._select_language)
sizer.Add(self._lang_button, 0, wx.ALIGN_RIGHT)

sizer.AddStretchSpacer(1)
name_sizer = wx.BoxSizer()
sizer.Add(name_sizer, 0, wx.CENTER)
Expand Down Expand Up @@ -54,18 +64,44 @@ def __init__(self, parent: wx.Window):
self._discord_button.Bind(wx.EVT_BUTTON, self._discord)
sizer.Add(self._discord_button, 0, wx.ALL | wx.CENTER, 5)

self._sponsor_button = wx.Button(self, size=(400, 70))
self._sponsor_button.SetFont(button_font)
self._sponsor_button.Bind(wx.EVT_BUTTON, self._sponsor)
sizer.Add(self._sponsor_button, 0, wx.ALL | wx.CENTER, 5)

sizer.AddStretchSpacer(2)

self._lang_button = wx.BitmapButton(
self, bitmap=image.icon.tablericons.language.bitmap(64, 64)
sponsor_header = wx.BoxSizer(wx.HORIZONTAL)
self._sponsor_label = wx.StaticText(self)
self._sponsor_link = wx.adv.HyperlinkCtrl(
self, url="https://github.com/sponsors/Amulet-Team"
)
self._lang_button.Bind(wx.EVT_BUTTON, self._select_language)
sizer.Add(self._lang_button, 0, wx.ALIGN_RIGHT)
sponsor_header.AddStretchSpacer(1)
sponsor_header.Add(self._sponsor_label)
sponsor_header.AddSpacer(10)
sponsor_header.Add(self._sponsor_link)
sponsor_header.AddStretchSpacer(1)
sizer.Add(sponsor_header, 0, wx.EXPAND, 0)

sponsor_sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer.Add(sponsor_sizer, 1, wx.EXPAND, 0)
pathway_bitmap = image.logo.pathway_logo.bitmap(300, 130)
pathway_button = wx.StaticBitmap(
self, wx.ID_ANY, pathway_bitmap, (0, 0), (300, 130)
)
pathway_button.Bind(wx.EVT_LEFT_DOWN, self._pathway)
sponsor_sizer.Add(pathway_button, 0, wx.EXPAND, 0)

try:
with urlopen(
"https://raw.githubusercontent.com/Amulet-Team/sponsors/main/sponsors.json"
) as f:
sponsors = json.load(f)
github_sponsor_text = wx.TextCtrl(
self,
value=" ".join(sponsors),
style=wx.TE_READONLY | wx.TE_MULTILINE | wx.TE_CENTRE | wx.BORDER_NONE,
size=wx.Size(-1, 150),
)
github_sponsor_text.SetBackgroundColour(self.GetBackgroundColour())
sponsor_sizer.Add(github_sponsor_text, 1)
except (URLError, json.JSONDecodeError):
pass

self._load_strings()

Expand All @@ -74,11 +110,12 @@ def _load_strings(self):
self._open_world_button.SetLabel(lang.get("main_menu.open_world"))
self._user_manual_button.SetLabel(lang.get("main_menu.user_manual"))
self._user_manual_button.SetToolTip(lang.get("app.browser_open_tooltip"))
self._sponsor_button.SetLabel(lang.get("main_menu.sponsor"))
self._bug_tracker_button.SetLabel(lang.get("main_menu.bug_tracker"))
self._bug_tracker_button.SetToolTip(lang.get("app.browser_open_tooltip"))
self._discord_button.SetLabel(lang.get("main_menu.discord"))
self._discord_button.SetToolTip(lang.get("app.browser_open_tooltip"))
self._sponsor_label.SetLabel(lang.get("main_menu.our_sponsors"))
self._sponsor_link.SetLabel(lang.get("main_menu.sponsor_link"))

@staticmethod
def _documentation(_):
Expand All @@ -97,8 +134,8 @@ def _discord(_):
webbrowser.open("https://www.amuletmc.com/discord")

@staticmethod
def _sponsor(_):
webbrowser.open("https://github.com/sponsors/Amulet-Team")
def _pathway(_):
webbrowser.open("https://www.pathway.studio/")

def enable(self):
self.GetTopLevelParent().create_menu()
Expand Down
Binary file added amulet_map_editor/api/image/logo/pathway_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion amulet_map_editor/lang/en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,10 @@ menu_bar.help.menu_name=&Help
main_menu.tab_name=Main Menu
main_menu.open_world=Open World
main_menu.user_manual=User Manual
main_menu.sponsor=Support Us
main_menu.bug_tracker=Bug Tracker
main_menu.discord=Amulet Discord
main_menu.our_sponsors=Our Sponsors
main_menu.sponsor_link=(Sponsor us to get your name here)

# Language Select
language_select.title=Language Select
Expand Down

0 comments on commit 5e68e5b

Please sign in to comment.