1111#include " WindowTracker.h"
1212#include " ButtonDiagram.h"
1313
14- // #include <iostream>
15- // using std::cout;
16- // using std::endl;
14+ // #include <iostream>
15+ // using std::cout;
16+ // using std::endl;
1717
1818
1919namespace PokemonAutomation {
2020
21+ const char * PRO_CONTROLLER_MAPPING_PATH = " /NintendoSwitch/Layout-ProController.png" ;
22+ const char * JOYCON_VERTICAL_MAPPING_PATH = " /NintendoSwitch/Layout-JoyconVertical.png" ;
23+ const char * JOYCON_HORIZONTAL_MAPPING_PATH = " /NintendoSwitch/Layout-JoyconHorizontal.png" ;
24+
2125
2226ButtonDiagram::ButtonDiagram (QWidget* parent)
2327 : QMainWindow(parent)
@@ -34,25 +38,22 @@ ButtonDiagram::ButtonDiagram(QWidget* parent)
3438 connect (
3539 pro_controller, &QMenu::aboutToShow,
3640 this , [this ](){
37- set_image (" /NintendoSwitch/Layout-ProController.png " );
41+ set_image (PRO_CONTROLLER_MAPPING_PATH );
3842 }
3943 );
4044 connect (
4145 joycon_vertical, &QMenu::aboutToShow,
4246 this , [this ](){
43- set_image (" /NintendoSwitch/Layout-JoyconVertical.png " );
47+ set_image (JOYCON_VERTICAL_MAPPING_PATH );
4448 }
4549 );
4650 connect (
4751 joycon_horizontal, &QMenu::aboutToShow,
4852 this , [this ](){
49- set_image (" /NintendoSwitch/Layout-JoyconHorizontal.png " );
53+ set_image (JOYCON_HORIZONTAL_MAPPING_PATH );
5054 }
5155 );
5256
53-
54- // m_image = QPixmap(QString::fromStdString(RESOURCE_PATH() + "/NintendoSwitch/Layout-ProController.jpg"));
55-
5657 m_image_label = new QLabel (this );
5758 setCentralWidget (m_image_label);
5859 m_image_label->setAlignment (Qt::AlignCenter);
@@ -66,7 +67,7 @@ ButtonDiagram::ButtonDiagram(QWidget* parent)
6667
6768 resize (800 , 600 + menu->sizeHint ().height ());
6869
69- set_image (" /NintendoSwitch/Layout-ProController.jpg " );
70+ set_image (PRO_CONTROLLER_MAPPING_PATH );
7071
7172 add_window (*this );
7273}
@@ -75,7 +76,8 @@ ButtonDiagram::~ButtonDiagram(){
7576}
7677
7778void ButtonDiagram::set_image (const std::string& resource_name){
78- m_image = QPixmap (QString::fromStdString (RESOURCE_PATH () + resource_name));
79+ const std::string image_path = RESOURCE_PATH () + resource_name;
80+ m_image = QPixmap (QString::fromStdString (image_path));
7981 ButtonDiagram::resizeEvent (nullptr );
8082}
8183void ButtonDiagram::resizeEvent (QResizeEvent*){
0 commit comments