1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-20 11:47:46 +00:00

Improved Windows support

Now works out of the box on Windows MSVC,
prevents settings crash because of nonexistent Wine options,
and also further improves use-cases where you might not
have all the libraries required to build.
This commit is contained in:
Joshua Goins 2022-03-27 21:08:27 -04:00
parent c176da0080
commit 5d0e8936ee
7 changed files with 76 additions and 41 deletions

View file

@ -16,7 +16,6 @@ if(ENABLE_WATCHDOG)
pkg_search_module(LEPTONICA REQUIRED lept)
endif()
set(SRC
src/main.cpp
src/launchercore.cpp
@ -37,12 +36,13 @@ set(SRC
src/headline.cpp
include/config.h
include/gameinstaller.h
src/gameinstaller.cpp)
src/gameinstaller.cpp
src/encryptedarg.cpp)
include(FetchContent)
if(NOT USE_OWN_LIBRARIES)
find_package(Qt5Keychain)
find_package(Qt5Keychain QUIET)
endif()
if(TARGET Qt5Keychain::Qt5Keychain)
@ -71,7 +71,7 @@ else()
endif()
if(NOT USE_OWN_LIBRARIES)
find_package(QuaZip-Qt5)
find_package(QuaZip-Qt5 QUIET)
endif()
if(TARGET QuaZip::QuaZip)
@ -86,12 +86,40 @@ else()
GIT_REPOSITORY https://github.com/stachenov/quazip.git
GIT_TAG v1.2
)
set(QUAZIP_USE_QT_ZLIB ON CACHE BOOL "" FORCE)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(quazip)
set(LIBRARIES QuaZip ${LIBRARIES})
set(QUAZIP_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/_deps/quazip-src/quazip)
endif()
if(NOT USE_OWN_LIBRARIES)
find_package(fmt QUIET)
endif()
if(TARGET fmt::fmt)
message("Using system library for fmt")
set(LIBRARIES fmt::fmt ${LIBRARIES})
else()
message("Using built-in fmt")
FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt
GIT_TAG master
)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(fmt)
set(LIBRARIES fmt::fmt ${LIBRARIES})
endif()
add_subdirectory(external)
set(LIBRARIES

2
external/libxiv vendored

@ -1 +1 @@
Subproject commit e9c72230482dd5ef437d5eaefe7907537ead349d
Subproject commit 29d3a1aabf2039cf4521121085f4faad2b5a2457

View file

@ -4,41 +4,17 @@
#include "blowfish.h"
// from xivdev
char ChecksumTable[] = {
static char ChecksumTable[] = {
'f', 'X', '1', 'p', 'G', 't', 'd', 'S',
'5', 'C', 'A', 'P', '4', '_', 'V', 'L'
};
char GetChecksum(unsigned int key) {
inline char GetChecksum(unsigned int key) {
auto value = key & 0x000F0000;
return ChecksumTable[value >> 16];
}
#if defined(Q_OS_MAC)
// this is pretty much what wine does :-0
inline uint32_t TickCount() {
struct mach_timebase_info convfact;
mach_timebase_info(&convfact);
return (mach_absolute_time() * convfact.numer) / (convfact.denom * 1000000);
}
#endif
#if defined(Q_OS_LINUX)
inline uint32_t TickCount() {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (ts.tv_sec * 1000 + ts.tv_nsec / 1000000);
}
#endif
#if defined(Q_OS_WIN)
inline uint32_t TickCount() {
return GetTickCount();
}
#endif
uint32_t TickCount();
inline QString encryptGameArg(QString arg) {
unsigned int rawTicks = TickCount();

View file

@ -1,6 +1,7 @@
#pragma once
#include <QString>
#include <functional>
class LauncherCore;

36
src/encryptedarg.cpp Normal file
View file

@ -0,0 +1,36 @@
#include "encryptedarg.h"
#if defined(Q_OS_MAC)
#include <sys/sysctl.h>
#include <mach/mach_time.h>
#endif
#if defined(Q_OS_WIN)
#include <windows.h>
#endif
#if defined(Q_OS_MAC)
// this is pretty much what wine does :-0
uint32_t TickCount() {
struct mach_timebase_info convfact;
mach_timebase_info(&convfact);
return (mach_absolute_time() * convfact.numer) / (convfact.denom * 1000000);
}
#endif
#if defined(Q_OS_LINUX)
uint32_t TickCount() {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (ts.tv_sec * 1000 + ts.tv_nsec / 1000000);
}
#endif
#if defined(Q_OS_WIN)
uint32_t TickCount() {
return GetTickCount();
}
#endif

View file

@ -17,15 +17,7 @@
#include <QCoreApplication>
#include <QStandardPaths>
#include <QRegularExpressionMatch>
#if defined(Q_OS_MAC)
#include <sys/sysctl.h>
#include <mach/mach_time.h>
#endif
#if defined(Q_OS_WIN)
#include <windows.h>
#endif
#include <algorithm>
#include "launchercore.h"
#include "sapphirelauncher.h"

View file

@ -462,10 +462,12 @@ void SettingsWindow::reloadControls() {
}
// wine
#if defined(Q_OS_LINUX) || defined(Q_OS_MAC)
wineVersionCombo->setCurrentIndex(profile.wineVersion);
selectWineButton->setEnabled(profile.wineVersion == 1);
winePathLabel->setText(profile.winePath);
winePrefixDirectory->setText(profile.winePrefixPath);
#endif
#if defined(Q_OS_LINUX)
useEsync->setChecked(profile.useEsync);