Skip to content

Commit 239da85

Browse files
authored
Merge branch 'PokemonAutomation:main' into main
2 parents 15155d0 + 7f43c43 commit 239da85

File tree

5 files changed

+24
-14
lines changed

5 files changed

+24
-14
lines changed

IconResource/icon.icns

44.8 KB
Binary file not shown.

SerialPrograms/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2034,7 +2034,7 @@ source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}../../ FILES ${MAIN_SOURCES})
20342034

20352035
if (APPLE)
20362036
# TODO: set up the correct application icon
2037-
# set(SerialPrograms_ICON ${CMAKE_CURRENT_SOURCE_DIR}/../Resources/icon.icns)
2037+
set(SerialPrograms_ICON ${CMAKE_CURRENT_SOURCE_DIR}/../IconResource/icon.icns)
20382038
# set_source_files_properties(SerialPrograms_ICON PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
20392039

20402040
# Links on how to create a MacOS app bundle with cmake
@@ -2047,9 +2047,10 @@ if (APPLE)
20472047
MACOSX_BUNDLE_BUNDLE_NAME SerialPrograms
20482048
MACOSX_BUNDLE_BUNDLE_VERSION "0.1"
20492049
MACOSX_BUNDLE_SHORT_VERSION_STRING "0.1"
2050-
# MACOSX_BUNDLE_ICON_FILE icon
2050+
MACOSX_BUNDLE_ICON_FILE "icon.icns"
20512051
# MacOSXBundleInfo.plist.in is modified from https://github.com/Kitware/CMake/blob/master/Modules/MacOSXBundleInfo.plist.in
20522052
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/cmake/MacOSXBundleInfo.plist.in
2053+
RESOURCE ${SerialPrograms_ICON}
20532054
)
20542055
else() # WIN and Linux:
20552056
add_executable(SerialPrograms WIN32 ${MAIN_SOURCES})

SerialPrograms/Source/CommonFramework/Globals.cpp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,22 @@ const std::string PROJECT_SOURCE_URL = "https://github.com/PokemonAutomation/Ard
5555

5656
namespace{
5757

58+
QString get_application_base_dir_path(){
59+
QString application_dir_path = qApp->applicationDirPath();
60+
if (application_dir_path.endsWith(".app/Contents/MacOS")){
61+
// a macOS bundle. Change working directory to the folder that hosts the .app folder.
62+
QString app_bundle_path = application_dir_path.chopped(15);
63+
QString base_folder_path = QFileInfo(app_bundle_path).dir().absolutePath();
64+
return base_folder_path;
65+
}
66+
return application_dir_path;
67+
}
5868
std::string get_resource_path(){
5969
// Find the resource directory.
60-
QString path = QCoreApplication::applicationDirPath();
70+
QString path = get_application_base_dir_path();
6171
for (size_t c = 0; c < 5; c++){
6272
QString try_path = path + "/Resources/";
6373
QFile file(try_path);
64-
// cout << path.toUtf8().data() << endl;
6574
if (file.exists()){
6675
return try_path.toStdString();
6776
}
@@ -70,12 +79,11 @@ std::string get_resource_path(){
7079
return (QCoreApplication::applicationDirPath() + "/../Resources/").toStdString();
7180
}
7281
std::string get_training_path(){
73-
// Find the resource directory.
74-
QString path = QCoreApplication::applicationDirPath();
82+
// Find the training data directory.
83+
QString path = get_application_base_dir_path();
7584
for (size_t c = 0; c < 5; c++){
7685
QString try_path = path + "/TrainingData/";
7786
QFile file(try_path);
78-
// cout << path.toUtf8().data() << endl;
7987
if (file.exists()){
8088
return try_path.toStdString();
8189
}
@@ -85,15 +93,13 @@ std::string get_training_path(){
8593
}
8694

8795
std::string get_runtime_base_path(){
88-
QString application_dir_path = qApp->applicationDirPath();
89-
if (application_dir_path.endsWith(".app/Contents/MacOS")){
90-
// a macOS bundle. Change working directory to the folder that hosts the .app folder.
91-
QString app_bundle_path = application_dir_path.chopped(15);
92-
QString base_folder_path = QFileInfo(app_bundle_path).dir().absolutePath();
93-
return base_folder_path.toStdString() + "/";
96+
if (QSysInfo::productType() == "macos" || QSysInfo::productType() == "osx"){
97+
QString application_dir_path = get_application_base_dir_path();
98+
return application_dir_path.toStdString() + "/";
9499
}
95100
return "./";
96101
}
102+
97103
const std::string& RUNTIME_BASE_PATH(){
98104
static std::string path = get_runtime_base_path();
99105
return path;

SerialPrograms/Source/CommonFramework/Logging/FileWindowLogger.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <QCoreApplication>
88
#include <QMenuBar>
99
#include <QDir>
10+
#include <CommonFramework/Globals.h>
1011
#include "CommonFramework/Windows/DpiScaler.h"
1112
#include "CommonFramework/Windows/WindowTracker.h"
1213
#include "FileWindowLogger.h"
@@ -19,7 +20,7 @@ namespace PokemonAutomation{
1920

2021

2122
Logger& global_logger_raw(){
22-
static FileWindowLogger logger((QCoreApplication::applicationName() + ".log").toStdString());
23+
static FileWindowLogger logger(USER_FILE_PATH() + (QCoreApplication::applicationName() + ".log").toStdString());
2324
return logger;
2425
}
2526

SerialPrograms/Source/PokemonSV/Programs/Boxes/PokemonSV_BoxRoutines.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ void change_view_to_judge(
123123
// If less than 4 of the IVs are read, assume we're not on the judge screen.
124124
if (detected < 4){
125125
pbf_press_button(context, BUTTON_PLUS, 20, 230);
126+
}else{
127+
break;
126128
}
127129
}
128130
}

0 commit comments

Comments
 (0)