Skip to content

Commit 785b065

Browse files
committed
Comments + UI tweaks.
1 parent aad88d0 commit 785b065

File tree

5 files changed

+46
-17
lines changed

5 files changed

+46
-17
lines changed

SerialPrograms/Source/CommonFramework/AudioPipeline/UI/AudioSelectorWidget.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,9 @@ AudioSelectorWidget::AudioSelectorWidget(QWidget& parent, AudioSession& session)
4848
QHBoxLayout* input_layout = new QHBoxLayout();
4949
row0->addLayout(input_layout, 10);
5050

51-
// if (PreloadSettings::instance().DEVELOPER_MODE){
52-
// m_audio_input_box = new NoWheelComboBox(this);
53-
// input_layout->addWidget(m_audio_input_box, 7);
54-
// m_load_file_button = new QPushButton("Load File", this);
55-
// input_layout->addWidget(m_load_file_button, 3);
56-
// }else{
57-
m_audio_input_box = new NoWheelComboBox(this);
58-
input_layout->addWidget(m_audio_input_box, 10);
59-
// }
51+
m_audio_input_box = new NoWheelComboBox(this);
52+
m_audio_input_box->setMaxVisibleItems(20);
53+
input_layout->addWidget(m_audio_input_box, 10);
6054
row0->addSpacing(5);
6155

6256
m_audio_format_box = new NoWheelComboBox(this);
@@ -77,13 +71,13 @@ AudioSelectorWidget::AudioSelectorWidget(QWidget& parent, AudioSession& session)
7771

7872
QHBoxLayout* output_layout = new QHBoxLayout();
7973
row1->addLayout(output_layout, 10);
74+
m_audio_output_box = new NoWheelComboBox(this);
75+
m_audio_output_box->setMaxVisibleItems(20);
8076
if (GlobalSettings::instance().AUDIO_PIPELINE->SHOW_RECORD_FREQUENCIES){
81-
m_audio_output_box = new NoWheelComboBox(this);
8277
output_layout->addWidget(m_audio_output_box, 7);
8378
m_record_button = new QPushButton("Record Frequencies", this);
8479
output_layout->addWidget(m_record_button, 3);
8580
}else{
86-
m_audio_output_box = new NoWheelComboBox(this);
8781
output_layout->addWidget(m_audio_output_box, 10);
8882
}
8983
row1->addSpacing(5);

SerialPrograms/Source/CommonFramework/VideoPipeline/UI/CameraSelectorWidget.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ CameraSelectorWidget::CameraSelectorWidget(
4444
camera_row->addSpacing(5);
4545

4646
m_camera_box = new NoWheelComboBox(this);
47+
m_camera_box->setMaxVisibleItems(20);
4748
camera_row->addWidget(m_camera_box, 5);
4849
camera_row->addSpacing(5);
4950

5051
m_resolution_box = new NoWheelComboBox(this);
52+
m_resolution_box->setMaxVisibleItems(20);
5153
camera_row->addWidget(m_resolution_box, 3);
5254
camera_row->addSpacing(5);
5355

SerialPrograms/Source/Controllers/ControllerTypes.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@
1010
namespace PokemonAutomation{
1111

1212

13+
// This is used only for the UI to indicate if a program may be faster on
14+
// tick-precise controllers. There is no functional effect.
1315
enum class FasterIfTickPrecise{
1416
NOT_FASTER,
1517
FASTER,
1618
MUCH_FASTER,
1719
};
1820

1921

20-
2122
enum class ControllerInterface{
2223
None,
2324
SerialPABotBase,
@@ -28,7 +29,12 @@ enum class ControllerInterface{
2829

2930
enum class ControllerType{
3031
None,
32+
33+
// There's a difference between the generic 3rd party wired controllers and
34+
// a pro controller connected over USB. If/when we support the latter, we
35+
// will need to split this controller type.
3136
NintendoSwitch_WiredProController,
37+
3238
NintendoSwitch_WirelessProController,
3339
NintendoSwitch_LeftJoycon,
3440
NintendoSwitch_RightJoycon,
@@ -38,9 +44,16 @@ enum class ControllerType{
3844
enum class ControllerFeature{
3945
TickPrecise,
4046
TimingFlexibleMilliseconds,
47+
48+
// If we add support gyro or rumble, we will need to split this feature
49+
// since the Pokken controller doesn't support those.
4150
NintendoSwitch_ProController,
51+
4252
NintendoSwitch_LeftJoycon,
4353
NintendoSwitch_RightJoycon,
54+
55+
// This is leftover from the days of RPCs. But we keep it here as a hack to
56+
// lock ESP32 out of the day skippers since it's too unstable to run those.
4457
NintendoSwitch_DateSkip,
4558
};
4659

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*
55
*/
66

7+
#include "Common/Cpp/Exceptions.h"
78
#include "Common/SerialPABotBase/SerialPABotBase_Protocol_IDs.h"
89
#include "SerialPABotBase.h"
910

@@ -57,12 +58,16 @@ ControllerType id_to_controller_type(uint32_t id){
5758
return ControllerType::NintendoSwitch_LeftJoycon;
5859
case PABB_CID_NINTENDO_SWITCH_RIGHT_JOYCON:
5960
return ControllerType::NintendoSwitch_RightJoycon;
60-
default:
61-
return ControllerType::None;
6261
}
62+
throw InternalProgramError(
63+
nullptr, PA_CURRENT_FUNCTION,
64+
"Invalid Controller ID: " + std::to_string(id)
65+
);
6366
}
6467
uint32_t controller_type_to_id(ControllerType controller_type){
6568
switch (controller_type){
69+
case ControllerType::None:
70+
return PABB_CID_NONE;
6671
case ControllerType::NintendoSwitch_WiredProController:
6772
return PABB_CID_NINTENDO_SWITCH_WIRED_PRO_CONTROLLER;
6873
case ControllerType::NintendoSwitch_WirelessProController:
@@ -71,9 +76,11 @@ uint32_t controller_type_to_id(ControllerType controller_type){
7176
return PABB_CID_NINTENDO_SWITCH_LEFT_JOYCON;
7277
case ControllerType::NintendoSwitch_RightJoycon:
7378
return PABB_CID_NINTENDO_SWITCH_RIGHT_JOYCON;
74-
default:
75-
return PABB_CID_NONE;
7679
}
80+
throw InternalProgramError(
81+
nullptr, PA_CURRENT_FUNCTION,
82+
"Invalid Controller Enum: " + std::to_string((int)controller_type)
83+
);
7784
}
7885

7986

SerialPrograms/Source/Controllers/SerialPABotBase/SerialPABotBase_SelectorWidget.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class SerialPABotBase_SelectorWidget : public NoWheelComboBox{
3333
, m_parent(parent)
3434
{
3535
// cout << "SerialPABotBase(): " << current << endl;
36+
this->setMaxVisibleItems(32);
3637

3738
if (current == nullptr || (
3839
current->interface_type != ControllerInterface::None &&
@@ -70,11 +71,16 @@ class SerialPABotBase_SelectorWidget : public NoWheelComboBox{
7071
}
7172

7273
void refresh_devices(){
74+
// cout << "Current = " << width() << " x " << height() << endl;
75+
// cout << "sizeHint = " << sizeHint().width() << " x " << sizeHint().height() << endl;
76+
// cout << "minimumContentsLength = " << this->minimumContentsLength() << endl;
77+
7378
m_ports.clear();
7479
this->clear();
7580

7681
// cout << "SerialPABotBase_SelectorWidget::refresh_devices()" << endl;
7782

83+
7884
m_ports.emplace_back(new NullControllerDescriptor());
7985
for (QSerialPortInfo& port : QSerialPortInfo::availablePorts()){
8086
#ifdef _WIN32
@@ -86,16 +92,23 @@ class SerialPABotBase_SelectorWidget : public NoWheelComboBox{
8692
m_ports.emplace_back(new SerialPABotBase_Descriptor(port));
8793
}
8894

95+
size_t width = 6;
8996
int index = 0;
9097
int c = 0;
9198
for (const auto& port : m_ports){
92-
this->addItem(QString::fromStdString(port->display_name()));
99+
QString display_name = QString::fromStdString(port->display_name());
100+
width = std::max<size_t>(width, display_name.size());
101+
this->addItem(display_name);
93102
if (*m_parent.session().descriptor() == *m_ports[c]){
94103
index = c;
95104
}
96105
c++;
97106
}
98107

108+
if (this->count() > this->maxVisibleItems()){
109+
width++;
110+
}
111+
setMinimumContentsLength((int)width);
99112
setCurrentIndex(index);
100113
}
101114

0 commit comments

Comments
 (0)