Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions build_support/osx/Info.plist.in
Original file line number Diff line number Diff line change
@@ -1,37 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleIdentifier</key>
<string>org.gambit-project.gambit</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<string>en</string>
<key>CFBundleExecutable</key>
<string>gambit</string>
<key>CFBundleIconFile</key>
<string>gambit</string>
<key>CFBundleName</key>
<string>Gambit</string>
<key>CFBundleDisplayName</key>
<string>Gambit</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>@GAMBIT_VERSION@</string>
<key>CFBundleShortVersionString</key>
<string>@GAMBIT_VERSION@</string>
<key>CFBundleGetInfoString</key>
<string>Gambit version @GAMBIT_VERSION@, (c) 1994-2025 The Gambit Project</string>
<key>CFBundleLongVersionString</key>
<string>@GAMBIT_VERSION@, (c) 1994-2025 The Gambit Project</string>
<string>Gambit version @GAMBIT_VERSION@, (c) 1994-2026 The Gambit Project</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright 1994-2025 The Gambit Project</string>
<key>LSRequiresCarbon</key>
<true/>
<key>CSResourcesFileMapped</key>
<true/>
<string>Copyright 1994-2026 The Gambit Project</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
Expand Down
Binary file modified build_support/osx/gambit.icns
Binary file not shown.
69 changes: 60 additions & 9 deletions src/gui/app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,55 @@
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif // WX_PRECOMP
#include <wx/display.h>
#include <wx/image.h>
#include <wx/splash.h>

#include "gambit.h"

#include "app.h"
#include "gameframe.h"

#include "bitmaps/gambitbig.xpm"

namespace Gambit::GUI {

bool Application::OnInit()
static wxBitmap MakeScaledSplashBitmap(const wxBitmap &srcBmp, double fracOfShortSide)
{
#include "bitmaps/gambitbig.xpm"
const wxPoint mouse = wxGetMousePosition();
const int dispIdx = wxDisplay::GetFromPoint(mouse);
wxDisplay disp(dispIdx == wxNOT_FOUND ? 0 : dispIdx);

wxRect geom = disp.GetGeometry(); // pixels in that display
const int shortSide = std::min(geom.width, geom.height);
const int targetMax = std::max(200, int(shortSide * fracOfShortSide));

const int w = srcBmp.GetWidth();
const int h = srcBmp.GetHeight();
const double s = double(targetMax) / double(std::max(w, h));

const int newW = std::max(1, int(std::lround(w * s)));
const int newH = std::max(1, int(std::lround(h * s)));

wxImage img = srcBmp.ConvertToImage();
img.Rescale(newW, newH, wxIMAGE_QUALITY_HIGH);

return wxBitmap(img);
}

wxBEGIN_EVENT_TABLE(Application, wxApp) EVT_TIMER(wxID_ANY, Application::OnSplashDismissTimer)
wxEND_EVENT_TABLE()

bool Application::OnInit()
{
wxApp::OnInit();

const wxBitmap bitmap(gambitbig_xpm);
m_splashTimer.Start();
m_splash = new wxSplashScreen(MakeScaledSplashBitmap(bitmap, 0.45),
wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_NO_TIMEOUT, 0, nullptr,
wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE);
m_splash->Show();
m_splash->Update();
wxConfigBase::Set(new wxConfig(_T("Gambit"), _T("Gambit")));
m_fileHistory.Load(*wxConfigBase::Get());
// Immediately saving this back forces the entries to be created at
Expand All @@ -47,12 +83,6 @@ bool Application::OnInit()
// m_fileHistory.Save(config);
wxConfigBase::Get()->Read(_T("/General/CurrentDirectory"), &m_currentDir, _T(""));

const wxBitmap bitmap(gambitbig_xpm);
/*wxSplashScreen *splash =*/
new wxSplashScreen(bitmap, wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_TIMEOUT, 2000, nullptr, -1,
wxDefaultPosition, wxDefaultSize, wxSIMPLE_BORDER | wxSTAY_ON_TOP);
wxYield();

// Process command line arguments, if any.
for (int i = 1; i < wxApp::argc; i++) {
const AppLoadResult result = LoadFile(wxApp::argv[i]);
Expand Down Expand Up @@ -86,9 +116,30 @@ bool Application::OnInit()
// Set up the help system.
wxInitAllImageHandlers();

this->CallAfter(&Application::DismissSplash);

return true;
}

void Application::DismissSplash()
{
if (!m_splash) {
return;
}

const long minDisplay = 1000;
const long elapsed = m_splashTimer.Time();

if (elapsed < minDisplay) {
m_splashDismissTimer.SetOwner(this);
m_splashDismissTimer.StartOnce(minDisplay - elapsed);
return;
}

m_splash->Destroy();
m_splash = nullptr;
}

AppLoadResult Application::LoadFile(const wxString &p_filename)
{
std::ifstream infile((const char *)p_filename.mb_str());
Expand Down
8 changes: 8 additions & 0 deletions src/gui/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <wx/wx.h>
#include <wx/config.h> // for wxConfig
#include <wx/docview.h> // for wxFileHistory
#include <wx/splash.h>

namespace Gambit::GUI {

Expand All @@ -37,8 +38,15 @@ class Application final : public wxApp {
wxString m_currentDir; /* Current position in directory tree. */
wxFileHistory m_fileHistory{10};
std::list<GameDocument *> m_documents;
wxSplashScreen *m_splash{nullptr};
wxStopWatch m_splashTimer;
wxTimer m_splashDismissTimer;

bool OnInit() override;
void DismissSplash();
void OnSplashDismissTimer(wxTimerEvent &) { DismissSplash(); }

wxDECLARE_EVENT_TABLE();

public:
Application() = default;
Expand Down
Loading
Loading