This commit is contained in:
Aria 2025-03-21 22:23:30 +11:00
commit 9c94d113d3
Signed by untrusted user who does not match committer: aria
GPG key ID: 19AB7AA462B8AB3B
10260 changed files with 1237388 additions and 0 deletions

View file

@ -0,0 +1,85 @@
#include "Commands.hpp"
#include <QProcess>
#include <QFileInfo>
#include <QMessageBox>
#if defined Q_OS_WIN
#include <windows.h>
#endif
void startClient(QStringList arguments) {
auto startStarbound = [](QString const& program, QStringList const& arguments, QString const& workingDirectory = QString()) {
if (!QProcess::startDetached(program, arguments, workingDirectory))
QMessageBox::warning(nullptr, "", "Error starting starbound process");
};
#if defined Q_OS_WIN
SYSTEM_INFO systemInfo;
GetNativeSystemInfo(&systemInfo);
if (systemInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
startStarbound("..\\win64\\starbound.exe", arguments, "..\\win64\\");
else
startStarbound(".\\starbound.exe", arguments);
#elif defined Q_OS_MACX
if (!arguments.empty())
arguments.prepend("--args");
arguments.prepend("./Starbound.app");
startStarbound("/usr/bin/open", arguments);
#else
startStarbound("./starbound", arguments);
#endif
}
void startServer() {
auto startStarboundServer = [](QString const& program, QStringList const& arguments = QStringList(), QString const& workingDirectory = QString()) {
if (!QProcess::startDetached(program, arguments, workingDirectory))
QMessageBox::warning(nullptr, "", "Error starting starbound server process");
};
#if defined Q_OS_WIN
startStarboundServer("cmd.exe", {"/C", ".\\starbound_server.exe"});
#elif defined Q_OS_MACX
startStarboundServer("/usr/bin/open", {"-a", "/Applications/Utilities/Terminal.app", "./run-server.sh"});
#else
std::vector<QString> xTermCandidates({
"/usr/bin/x-terminal-emulator",
"/usr/bin/konsole",
"/usr/bin/gnome-terminal.wrapper",
"/usr/bin/xfce4-terminal.wrapper",
"/usr/bin/koi8rxterm",
"/usr/bin/lxterm",
"/usr/bin/uxterm",
"/usr/bin/xterm"});
QString destinationXTerm = "";
for (auto const& candidate : xTermCandidates) {
QFileInfo fileInfo(candidate);
if (fileInfo.exists()) {
if (fileInfo.isSymLink())
fileInfo.setFile(fileInfo.symLinkTarget());
if (fileInfo.isExecutable()) {
destinationXTerm = candidate;
break;
}
}
}
if (destinationXTerm.empty()) {
QMessageBox::warning(nullptr, "",
"Could not find a valid graphical terminal emulator, starting in the background instead, executable name is "
"starbound_server, to shut down the server, use killall starbound_server");
startStarboundServer("./starbound_server");
} else {
startStarboundServer(destinationXTerm, {"-e", "./starbound_server"});
}
#endif
}

View file

@ -0,0 +1,9 @@
#ifndef COMMANDS_HPP
#define COMMANDS_HPP
#include <QStringList>
void startClient(QStringList arguments = {});
void startServer();
#endif

View file

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleGetInfoString</key>
<string>StarboundLauncher</string>
<key>CFBundleExecutable</key>
<string>launcher</string>
<key>CFBundleIdentifier</key>
<string>com.chucklefish</string>
<key>CFBundleName</key>
<string>launcher</string>
<key>CFBundleIconFile</key>
<string>starbound</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>LSEnvironment</key>
<dict>
<key>MinimumSystemVersion</key>
<string>10.7.0</string>
</dict>
</dict>
</plist>

View file

@ -0,0 +1,65 @@
#include <QApplication>
#include <QGridLayout>
#include <QPushButton>
#include <QProcess>
#include <QDesktopServices>
#include <QNetworkRequest>
#include <QMessageBox>
#include <QFileInfo>
#if defined Q_OS_WIN
#include <windows.h>
#endif
#include "Launcher.hpp"
#include "Commands.hpp"
Launcher::Launcher() : QMainWindow() {
setWindowTitle("Starbound Launcher");
setFixedSize(1200, 700);
auto* centralWidget = new QWidget(this);
centralWidget->setObjectName("background");
setCentralWidget(centralWidget);
auto* layout = new QGridLayout(centralWidget);
m_web = new WebView(this);
layout->addWidget(m_web, 0, 0, 1, 5);
auto* launchClient = new QPushButton(this);
launchClient->setObjectName("launchClientButton");
launchClient->setText("Launch Starbound");
layout->addWidget(launchClient, 1, 0);
connect(launchClient, SIGNAL(pressed()), this, SLOT(runClient()));
auto* launchServer = new QPushButton(this);
launchServer->setText("Launch Starbound Server");
launchServer->setObjectName("launchServerButton");
layout->addWidget(launchServer, 1, 4);
connect(launchServer, SIGNAL(pressed()), this, SLOT(runServer()));
m_web->setHtml("<div align=\"center\"><i>Loading, please wait.</i></div>");
m_web->load(QUrl("http://playstarbound.com/launcher/"));
}
void Launcher::runClient() {
startClient();
QApplication::quit();
}
void Launcher::runServer() {
startServer();
QApplication::quit();
}
bool WebPage::acceptNavigationRequest(QUrl const& url, NavigationType, bool) {
QDesktopServices::openUrl(url);
return false;
}
QWebEngineView* WebView::createWindow(QWebEnginePage::WebWindowType) {
auto res = new WebView(this);
auto page = new WebPage(res);
res->setPage(page);
return res;
}

View file

@ -0,0 +1,39 @@
#ifndef STAR_LAUNCHER_HPP
#define STAR_LAUNCHER_HPP
#include <QMainWindow>
#include <QWebEngineView>
class Launcher : public QMainWindow {
Q_OBJECT
public:
Launcher();
private slots:
void runClient();
void runServer();
private:
QWebEngineView* m_web;
};
class WebPage : public QWebEnginePage {
Q_OBJECT
public:
using QWebEnginePage::QWebEnginePage;
bool acceptNavigationRequest(QUrl const& url, NavigationType type, bool isMainFrame);
};
class WebView : public QWebEngineView {
Q_OBJECT
public:
using QWebEngineView::QWebEngineView;
QWebEngineView* createWindow(QWebEnginePage::WebWindowType type);
};
#endif

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--Windows 7-->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!--Windows Vista-->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
</application>
</compatibility>
</assembly>

BIN
attic/launcher/launcher.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 KiB

View file

@ -0,0 +1,6 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>launcher.qss</file>
<file>launcher.ico</file>
</qresource>
</RCC>

View file

@ -0,0 +1,41 @@
QWidget#background {
border: none;
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #a6a6a6, stop: 0.08 #7f7f7f,
stop: 0.39999 #717171, stop: 0.4 #626262,
stop: 0.9 #4c4c4c, stop: 1 #333333);
}
QPushButton {
color: #333;
border: 1px solid #555;
border-radius: 11px;
padding: 5px;
background: qradialgradient(cx: 0.3, cy: -0.4,
fx: 0.3, fy: -0.4,
radius: 1.35, stop: 0 #fff, stop: 1 #888);
}
QPushButton:hover {
background: qradialgradient(cx: 0.3, cy: -0.4,
fx: 0.3, fy: -0.4,
radius: 1.35, stop: 0 #fff, stop: 1 #bbb);
}
QPushButton:pressed {
background: qradialgradient(cx: 0.4, cy: -0.1,
fx: 0.4, fy: -0.1,
radius: 1.35, stop: 0 #fff, stop: 1 #ddd);
}
QPushButton#launchClientButton {
max-width: 140px;
}
QPushButton#launchOglClientButton {
max-width: 180px;
}
QPushButton#launchServerButton {
max-width: 180px;
}

View file

@ -0,0 +1,25 @@
1 VERSIONINFO
FILEVERSION 0,9,0,0
PRODUCTVERSION 0,9,0,0
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "CompanyName", "Chucklefish LTD"
VALUE "FileDescription", "Starbound Launcher"
VALUE "FileVersion", "0.9beta"
VALUE "InternalName", "starbound-launcher"
VALUE "LegalCopyright", "Chucklefish LTD"
VALUE "OriginalFilename", "launcher.exe"
VALUE "ProductName", "Starbound"
VALUE "ProductVersion", "0.9beta"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
icon ICON "starbound-largelogo.ico"

99
attic/launcher/main.cpp Normal file
View file

@ -0,0 +1,99 @@
#include <QApplication>
#include <QFileInfo>
#include <QMessageBox>
#include <QDir>
#include <iostream>
#include "Launcher.hpp"
#include "Commands.hpp"
void fixupDirectoryStructureKoalaToGiraffe(QDir contentDir) {
// First, do a lot of sanity checking heuristics to make sure we are actually
// in a starbound released content directory...
std::cout << "Detecting old starbound directory layout and migrating from Koala to Giraffe..." << std::endl;
if (!contentDir.exists("win32") || !contentDir.exists("win64") || !contentDir.exists("linux32")
|| !contentDir.exists("linux64")
|| !contentDir.exists("osx")
|| !contentDir.exists("assets")) {
std::cout << "Bailing out! It does not appear that we are running in an installed copy of starbound" << std::endl;
return;
}
if (!contentDir.exists("koala_storage")) {
std::cout << "Migrating (old) base directories to koala_storage..." << std::endl;
contentDir.mkdir("koala_storage");
if (contentDir.exists("mods"))
contentDir.rename("mods", QDir::toNativeSeparators("koala_storage/mods"));
if (contentDir.exists("player"))
contentDir.rename("player", QDir::toNativeSeparators("koala_storage/player"));
if (contentDir.exists("universe"))
contentDir.rename("universe", QDir::toNativeSeparators("koala_storage/universe"));
if (contentDir.exists("starbound.config"))
contentDir.rename("starbound.config", QDir::toNativeSeparators("koala_storage/starbound.config"));
if (contentDir.exists("starbound_server.config"))
contentDir.rename("starbound_server.config", QDir::toNativeSeparators("koala_storage/starbound_server.config"));
for (auto entry : contentDir.entryList({"starbound.log*"}, QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot))
contentDir.rename(entry, QDir::toNativeSeparators("koala_storage/" + entry));
for (auto entry : contentDir.entryList({"starbound_server.log*"}, QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot))
contentDir.rename(entry, QDir::toNativeSeparators("koala_storage/" + entry));
} else {
std::cout << "It appears we have already applied the Koala backup migration, continuing..." << std::endl;
}
if (contentDir.exists("storage_unstable")) {
std::cout << "Migrating (old) storage_unstable to giraffe_storage..." << std::endl;
if (!contentDir.exists("giraffe_storage"))
contentDir.mkdir("giraffe_storage");
std::cout << "storage_unstable directory from Giraffe series detected, migrating to giraffe_storage" << std::endl;
QDir storageUnstable = contentDir;
storageUnstable.cd("storage_unstable");
for (auto entry : storageUnstable.entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot))
storageUnstable.rename(entry, QDir::toNativeSeparators(QString("../giraffe_storage/") + entry));
contentDir.rmdir("storage_unstable");
} else {
std::cout << "It appears we do not have a storage_unstable directory, continuing..." << std::endl;
}
}
int main(int argc, char* argv[]) {
QApplication a(argc, argv);
a.setWindowIcon(QIcon(":/launcher.ico"));
QStringList arguments = a.arguments();
arguments.pop_front();
if (!arguments.empty()) {
startClient(arguments);
return 0;
}
QFile styleSheetFile(":/launcher.qss");
styleSheetFile.open(QIODevice::ReadOnly);
a.setStyleSheet(styleSheetFile.readAll());
Launcher l;
l.show();
#if defined Q_OS_MACX
QDir appDir(a.applicationDirPath());
appDir.cdUp();
appDir.cdUp();
appDir.cdUp();
QDir::setCurrent(appDir.canonicalPath());
#elif defined Q_OS_WIN
QDir appDir(a.applicationDirPath());
appDir.cdUp();
QDir::setCurrent(appDir.canonicalPath());
#else
QDir appDir(a.applicationDirPath());
QDir::setCurrent(appDir.canonicalPath());
#endif
appDir.cdUp();
fixupDirectoryStructureKoalaToGiraffe(appDir);
return a.exec();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 361 KiB