Skip to content

Commit 4aeccaa

Browse files
committed
Lots of fixes for Tera Multi-Farmer.
1 parent dd6c20d commit 4aeccaa

File tree

4 files changed

+109
-17
lines changed

4 files changed

+109
-17
lines changed

SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.cpp

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,7 @@ TestProgram::TestProgram()
195195
)
196196
, IMAGE_PATH(false, "Path to image for testing", LockMode::UNLOCK_WHILE_RUNNING, "default.png", "default.png")
197197
, STATIC_TEXT("Test text...")
198-
, BOX("Test box", LockMode::UNLOCK_WHILE_RUNNING, 0.0, 0.0, 0.0, 0.0)
199-
// , PLAYER_LIST("Test Table", LockMode::UNLOCK_WHILE_RUNNING, "Notes")
198+
, BOX("Box", LockMode::UNLOCK_WHILE_RUNNING, 0, 0, 1, 1)
200199
, NOTIFICATION_TEST("Test", true, true, ImageAttachmentMode::JPG)
201200
, NOTIFICATIONS({
202201
&NOTIFICATION_TEST,
@@ -210,7 +209,7 @@ TestProgram::TestProgram()
210209
// PA_ADD_OPTION(CONSOLE_MODEL);
211210
PA_ADD_OPTION(IMAGE_PATH);
212211
PA_ADD_OPTION(STATIC_TEXT);
213-
// PA_ADD_OPTION(PLAYER_LIST);
212+
PA_ADD_OPTION(BOX);
214213
// PA_ADD_OPTION(battle_AI);
215214
PA_ADD_OPTION(NOTIFICATIONS);
216215
BUTTON0.add_listener(*this);
@@ -255,10 +254,31 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
255254
ProControllerContext context(scope, console.pro_controller());
256255
VideoOverlaySet overlays(overlay);
257256

257+
258258
auto screenshot = feed.snapshot();
259259

260-
PokemonSwSh::MaxLairInternal::PathSelectDetector detector;
261-
detector.detect(screenshot);
260+
261+
DateReader reader(console);
262+
reader.make_overlays(overlays);
263+
reader.read_date(logger, screenshot);
264+
265+
266+
#if 0
267+
BinarySliderDetector detector(COLOR_BLUE, {0.836431, 0.097521, 0.069703, 0.796694});
268+
auto result = detector.detect(screenshot);
269+
270+
for (auto& item : result){
271+
cout << item.first << " : " << item.second.center_y() << endl;
272+
}
273+
#endif
274+
275+
// LetsGoKillWatcher menu(logger, COLOR_RED, true, {0.23, 0.23, 0.04, 0.20});
276+
// cout << menu.detect(screenshot) << endl;
277+
278+
279+
280+
// PokemonSwSh::MaxLairInternal::PathSelectDetector detector;
281+
// detector.detect(screenshot);
262282

263283
// int ret = PokemonSwSh::MaxLairInternal::read_side(screenshot);
264284
// cout << "ret = " << ret << endl;

SerialPrograms/Source/NintendoSwitch/Programs/DateManip/NintendoSwitch_DateManipTools.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace DateReaderTools{
2424

2525
ImageRGB32 filter_image(const ImageViewRGB32& image){
2626
double brightness = image_stats(image).average.sum();
27-
bool white_theme = brightness > 600;
27+
bool white_theme = brightness > 500;
2828

2929
ImageRGB32 filtered = to_blackwhite_rgb32_range(
3030
image,
@@ -39,8 +39,12 @@ int read_box(
3939
const ImageViewRGB32& screen, const ImageFloatBox& box
4040
){
4141
ImageViewRGB32 cropped = extract_box_reference(screen, box);
42+
43+
// static int c = 0;
44+
// cropped.save("image-" + std::to_string(c++) + ".png");
45+
4246
double brightness = image_stats(cropped).average.sum();
43-
bool white_theme = brightness > 600;
47+
bool white_theme = brightness > 500;
4448

4549
int value;
4650
if (white_theme){

SerialPrograms/Source/NintendoSwitch/Programs/DateManip/NintendoSwitch_DateManip_24h.cpp

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

77
#include "CommonFramework/Exceptions/OperationFailedException.h"
8+
#include "CommonFramework/ErrorReports/ErrorReports.h"
89
#include "CommonFramework/ImageTypes/ImageRGB32.h"
910
#include "CommonFramework/VideoPipeline/VideoFeed.h"
1011
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h"
@@ -38,6 +39,20 @@ DateTime DateReader_24h::read_date(Logger& logger, std::shared_ptr<const ImageRG
3839
date.hour = (int8_t)DateReaderTools::read_box(logger, 0, 23, *screen, m_hour);
3940
date.minute = (int8_t)DateReaderTools::read_box(logger, 0, 59, *screen, m_minute);
4041

42+
if (date.day < 0 ||
43+
date.month < 0 ||
44+
date.year < 0 ||
45+
date.hour < 0 ||
46+
date.minute < 0
47+
){
48+
report_error(
49+
&logger, ProgramInfo(),
50+
"Failed to read date.",
51+
{},
52+
*screen
53+
);
54+
}
55+
4156
return date;
4257
}
4358

@@ -71,19 +86,39 @@ void DateReader_EU::set_date(
7186
}
7287

7388
move_horizontal(context, cursor_position, 0);
74-
adjust_no_wrap(context, current.day, date.day);
89+
if (current.day < 0){
90+
stream.log("Failed to read day. Will not adjust.", COLOR_RED);
91+
}else{
92+
adjust_no_wrap(context, current.day, date.day);
93+
}
7594

7695
move_horizontal(context, cursor_position, 1);
77-
adjust_wrap(context, 1, 12, current.month, date.month);
96+
if (current.month < 0){
97+
stream.log("Failed to read month. Will not adjust.", COLOR_RED);
98+
}else{
99+
adjust_wrap(context, 1, 12, current.month, date.month);
100+
}
78101

79102
move_horizontal(context, cursor_position, 2);
80-
adjust_no_wrap(context, current.year, date.year);
103+
if (current.year < 0){
104+
stream.log("Failed to read year. Will not adjust.", COLOR_RED);
105+
}else{
106+
adjust_no_wrap(context, current.year, date.year);
107+
}
81108

82109
move_horizontal(context, cursor_position, 3);
83-
adjust_wrap(context, 0, 23, current.hour, date.hour);
110+
if (current.hour < 0){
111+
stream.log("Failed to read hour. Will not adjust.", COLOR_RED);
112+
}else{
113+
adjust_wrap(context, 0, 23, current.hour, date.hour);
114+
}
84115

85116
move_horizontal(context, cursor_position, 4);
86-
adjust_wrap(context, 0, 59, current.minute, date.minute);
117+
if (current.minute < 0){
118+
stream.log("Failed to read minutes. Will not adjust.", COLOR_RED);
119+
}else{
120+
adjust_wrap(context, 0, 59, current.minute, date.minute);
121+
}
87122

88123
move_horizontal(context, cursor_position, 5);
89124
}

SerialPrograms/Source/NintendoSwitch/Programs/DateManip/NintendoSwitch_DateManip_US.cpp

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "Common/Qt/StringToolsQt.h"
88
#include "CommonFramework/Exceptions/OperationFailedException.h"
9+
#include "CommonFramework/ErrorReports/ErrorReports.h"
910
#include "CommonFramework/ImageTypes/ImageRGB32.h"
1011
#include "CommonFramework/VideoPipeline/VideoFeed.h"
1112
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h"
@@ -77,6 +78,20 @@ DateTime DateReader_US::read_date(Logger& logger, std::shared_ptr<const ImageRGB
7778
date.hour = (int8_t)hour;
7879
}
7980

81+
if (date.day < 0 ||
82+
date.month < 0 ||
83+
date.year < 0 ||
84+
date.hour < 0 ||
85+
date.minute < 0
86+
){
87+
report_error(
88+
&logger, ProgramInfo(),
89+
"Failed to read date.",
90+
{},
91+
*screen
92+
);
93+
}
94+
8095
return date;
8196
}
8297
void DateReader_US::set_date(
@@ -104,16 +119,30 @@ void DateReader_US::set_date(
104119
}
105120

106121
move_horizontal(context, cursor_position, 0);
107-
adjust_wrap(context, 1, 12, current.month, date.month);
122+
if (current.month < 0){
123+
stream.log("Failed to read month. Will not adjust.", COLOR_RED);
124+
}else{
125+
adjust_wrap(context, 1, 12, current.month, date.month);
126+
}
108127

109128
move_horizontal(context, cursor_position, 1);
110-
adjust_no_wrap(context, current.day, date.day);
129+
if (current.day < 0){
130+
stream.log("Failed to read day. Will not adjust.", COLOR_RED);
131+
}else{
132+
adjust_no_wrap(context, current.day, date.day);
133+
}
111134

112135
move_horizontal(context, cursor_position, 2);
113-
adjust_no_wrap(context, current.year, date.year);
136+
if (current.year < 0){
137+
stream.log("Failed to read year. Will not adjust.", COLOR_RED);
138+
}else{
139+
adjust_no_wrap(context, current.year, date.year);
140+
}
114141

115142
move_horizontal(context, cursor_position, 3);
116-
{
143+
if (current.hour < 0){
144+
stream.log("Failed to read hour. Will not adjust.", COLOR_RED);
145+
}else{
117146
int8_t c = current.hour;
118147
int8_t t = date.hour;
119148
if (c >= 12) c -= 12;
@@ -122,7 +151,11 @@ void DateReader_US::set_date(
122151
}
123152

124153
move_horizontal(context, cursor_position, 4);
125-
adjust_wrap(context, 0, 59, current.minute, date.minute);
154+
if (current.minute < 0){
155+
stream.log("Failed to read minutes. Will not adjust.", COLOR_RED);
156+
}else{
157+
adjust_wrap(context, 0, 59, current.minute, date.minute);
158+
}
126159

127160
move_horizontal(context, cursor_position, 5);
128161
if ((date.hour < 12) != (current.hour < 12)){

0 commit comments

Comments
 (0)