3#include <initializer_list>
7#include "core/subsystems/screen/screen_controller.h"
9namespace LegacyScreen {
14 LegacyPage(vex::brain::lcd screen, std::initializer_list<Page *> pages);
15 LegacyPage(vex::brain::lcd screen, std::vector<Page *> pages);
16 LegacyPage() =
default;
18 inline std::function<void()> handle() {
20 if(this->pages.empty()) {
21 this->screen.clearScreen(vex::color::red);
25 Page *front_page = this->pages[this->index];
26 std::optional<Point2d> pressing;
28 if((pressing = ScreenController::get_press_pos()).has_value()) {
29 this->x_press = pressing->x();
30 this->y_press = pressing->y();
32 bool just_pressed = pressing.has_value() && !this->was_pressed;
34 if (just_pressed && this->x_press < 40) {
36 if (this->index < 0) {
37 this->index += this->pages.size();
40 if (just_pressed && this->x_press > 440) {
42 this->index %= this->pages.size();
46 for (
auto page : this->pages) {
47 if (page == front_page) {
48 page->update(this->was_pressed, this->x_press, this->y_press);
50 page->update(
false, 0, 0);
55 int frame = ScreenController::get_frame_count();
57 this->screen.clearScreen(vex::color::black);
58 this->screen.setPenColor(
"#FFFFFF");
59 this->screen.setFillColor(
"#000000");
60 front_page->draw(this->screen,
false, frame / 5);
63 this->screen.setPenColor(
"#202020");
64 this->screen.setFillColor(
"#202020");
65 this->screen.drawRectangle(0, 0, 40, 240);
66 this->screen.drawRectangle(440, 0, 40, 240);
67 this->screen.setPenColor(
"#FFFFFF");
69 this->screen.drawLine(30, 100, 15, 120);
70 this->screen.drawLine(30, 140, 15, 120);
72 this->screen.drawLine(450, 100, 465, 120);
73 this->screen.drawLine(450, 140, 465, 120);
76 this->was_pressed = pressing.has_value();
87 std::vector<Page *> pages;
88 vex::brain::lcd screen;
98inline std::function<void()> pre_initialize(vex::brain& brain, Initializer& initializer, LegacyPage* page, std::function<
void()> o =
nullptr) {
99 return [&, o, page]() {
102 std::vector<Page*> pages;
size_t initializations = 0;
105 initializations += 8;
108 *page = LegacyPage(brain.Screen, pages);
109 ScreenController::set(page->handle());
const std::size_t initialization_count() const
Definition initializer.cpp:50
InitializerPage provides a way to Select a desired Initialization on the Screen.
Definition legacy.h:286