Poke_Transporter_GB/include/button_menu.h
Philippe Symons 9268cbd42e Reduce binary size by eliminating libstdc++
This commit removes all references to things in the libstdc++ library to remove a decent chunk of bloat.

This means every std::to_string() call, std::string and std::vector. (as well as iostream related stuff).

I replaced those with my own versions ptgb::to_string() and ptgb::vector. Especially the latter is not exactly the same,
but close enough.

I also replaced operator new and delete with my own implementation to avoid pulling in everything related to exceptions
from libstdc++

Another problem was the fact that libtonc uses siscanf, which pulls in everything related to the scanf family of functions
and locale support. The worst part of that was that it included a 13KB "categories" symbol from libc_a-categories.o,
which was pulled in because of the locale support integrated into newlibc's siscanf() function. To fix that, I created a
custom, extremely restricted implementation of siscanf. libtonc only used this function to parse at most 2 integers from a
string anyway.
2025-04-09 20:04:08 +02:00

54 lines
1.2 KiB
C++

#ifndef MAIN_MENU_H
#define MAIN_MENU_H
#include <tonc.h>
#include "libstd_replacements.h"
#include "button_handler.h"
#define BTN_MAIN_MENU 0
#define BTN_TRANSFER 1
#define BTN_POKEDEX 2
#define BTN_EVENTS 3
#define BTN_CREDITS 4
#define BTN_OPENING 5
#define BUTTON_CANCEL -1
class Button_Menu
{
public:
Button_Menu(int nRows, int nColumns, int nButton_width, int nButton_height, bool enable_cancel);
int button_main();
void add_button(Button btn, int return_val);
void hide_buttons();
void show_buttons();
void organize_buttons();
unsigned int get_pos_from_xy(int nX, int nY);
unsigned int get_x_from_pos(int nPos);
unsigned int get_y_from_pos(int nPos);
void set_xy_min_max(int nX_min, int nX_max, int nY_min, int nY_max);
void set_rows_and_columns(int nRows, int nColumns);
void set_bottom_row_offset(int nBottom_offset);
void clear_vector();
private:
ptgb::vector<Button> button_vector;
ptgb::vector<int> return_values;
int columns;
int rows;
int button_height;
int button_width;
unsigned int curr_position;
int x_min;
int x_max;
int y_min;
int y_max;
int offset_value;
int bottom_offset;
bool cancel_enabled;
};
extern Button_Menu yes_no_menu;
#endif