Start Implement inc/dec menu options

This commit is contained in:
Lorenzooone
2024-05-19 03:29:41 +02:00
parent 499e29ae01
commit 0913d6b8c0
15 changed files with 332 additions and 159 deletions

View File

@@ -14,9 +14,9 @@ public:
int selected_index = -1;
protected:
void reset_output_option();
void set_output_option(int index);
void set_output_option(int index, int action);
int get_num_options();
std::string get_string_option(int index);
std::string get_string_option(int index, int action);
void class_setup();
private:
DevicesList *devices_list;

View File

@@ -20,9 +20,9 @@ public:
int selected_index = CROP_MENU_NO_ACTION;
protected:
void reset_output_option();
void set_output_option(int index);
void set_output_option(int index, int action);
int get_num_options();
std::string get_string_option(int index);
std::string get_string_option(int index, int action);
void class_setup();
private:
std::vector<const CropData*>* possible_crops;

View File

@@ -34,9 +34,9 @@ public:
MainMenuOutAction selected_index = MainMenuOutAction::MAIN_MENU_NO_ACTION;
protected:
void reset_output_option();
void set_output_option(int index);
void set_output_option(int index, int action);
int get_num_options();
std::string get_string_option(int index);
std::string get_string_option(int index, int action);
void class_setup();
private:
int *options_indexes;

View File

@@ -7,6 +7,13 @@
#include "TextRectangle.hpp"
#include "sfml_gfx_structs.hpp"
#define BACK_X_OUTPUT_OPTION -1
#define BAD_ACTION -1
#define DEFAULT_ACTION 0
#define DEC_ACTION 1
#define INC_ACTION 2
class OptionSelectionMenu {
public:
OptionSelectionMenu();
@@ -16,7 +23,7 @@ public:
void reset_data();
std::chrono::time_point<std::chrono::high_resolution_clock> last_input_processed_time;
protected:
int num_elements_per_screen;
int num_options_per_screen;
int elements_start_id;
int min_elements_text_scaling_factor;
int width_factor_menu;
@@ -31,12 +38,15 @@ protected:
bool show_x;
bool show_title;
virtual bool is_option_inc_dec(int index);
virtual void reset_output_option();
virtual void set_output_option(int index);
virtual void set_output_option(int index, int action);
virtual int get_num_options();
virtual std::string get_string_option(int index);
virtual std::string get_string_option(int index, int action);
virtual void class_setup();
int single_option_multiplier;
int get_num_pages();
void initialize(bool font_load_success, sf::Font &text_font);
void prepare_options();
@@ -54,6 +64,7 @@ protected:
TextRectangle **labels;
bool *future_enabled_labels;
private:
int num_elements_per_screen;
int num_title_back_x_elements;
int num_page_elements;
int num_elements_displayed_per_screen;
@@ -78,12 +89,14 @@ private:
void after_class_setup_connected_values();
void prepare_text_slices(int x_multiplier, int x_divisor, int y_multiplier, int y_divisor, int index, float text_scaling_factor, bool center = false);
bool can_execute_action();
void up_code();
void down_code();
void up_code(bool is_simple);
void down_code(bool is_simple);
void left_code();
void right_code();
void option_selection_handling();
void decrement_selected_option();
void increment_selected_option();
bool is_curr_option_location_left();
bool is_curr_option_location_multichoice();
void decrement_selected_option(bool is_simple);
void increment_selected_option(bool is_simple);
};
#endif

View File

@@ -21,9 +21,9 @@ public:
int selected_index = PAR_MENU_NO_ACTION;
protected:
void reset_output_option();
void set_output_option(int index);
void set_output_option(int index, int action);
int get_num_options();
std::string get_string_option(int index);
std::string get_string_option(int index, int action);
void class_setup();
private:
const std::string base_name = "PAR Settings";

View File

@@ -24,10 +24,13 @@ enum VideoMenuOutAction{
VIDEO_MENU_SMALL_SCREEN_DISTANCE,
VIDEO_MENU_SCREENS_X_POS,
VIDEO_MENU_SCREENS_Y_POS,
VIDEO_MENU_WINDOW_SCALING,
VIDEO_MENU_FULLSCREEN_SCALING,
VIDEO_MENU_WINDOW_SCALING_DEC,
VIDEO_MENU_WINDOW_SCALING_INC,
VIDEO_MENU_FULLSCREEN_SCALING_TOP,
VIDEO_MENU_FULLSCREEN_SCALING_BOTTOM,
VIDEO_MENU_BFI_SETTINGS,
VIDEO_MENU_MENU_SCALING,
VIDEO_MENU_MENU_SCALING_DEC,
VIDEO_MENU_MENU_SCALING_INC,
VIDEO_MENU_RESOLUTION_SETTINGS,
VIDEO_MENU_TOP_ROTATION,
VIDEO_MENU_BOTTOM_ROTATION,
@@ -41,10 +44,11 @@ public:
void insert_data(ScreenType s_type, bool is_fullscreen);
VideoMenuOutAction selected_index = VideoMenuOutAction::VIDEO_MENU_NO_ACTION;
protected:
bool is_option_inc_dec(int index);
void reset_output_option();
void set_output_option(int index);
void set_output_option(int index, int action);
int get_num_options();
std::string get_string_option(int index);
std::string get_string_option(int index, int action);
void class_setup();
private:
int *options_indexes;

View File

@@ -132,6 +132,8 @@ private:
void crop_value_change(int new_crop_value);
void par_value_change(int new_par_value, bool is_top);
void offset_change(float &value, float change);
void menu_scaling_change(bool positive);
void window_scaling_change(bool positive);
bool common_poll(SFEvent &event_data);
bool main_poll(SFEvent &event_data);
bool no_menu_poll(SFEvent &event_data);

View File

@@ -8,8 +8,8 @@ ConnectionMenu::~ConnectionMenu() {
}
void ConnectionMenu::class_setup() {
this->num_elements_per_screen = 4;
this->min_elements_text_scaling_factor = num_elements_per_screen;
this->num_options_per_screen = 4;
this->min_elements_text_scaling_factor = num_options_per_screen;
this->width_factor_menu = 16;
this->width_divisor_menu = 9;
this->base_height_factor_menu = 10;
@@ -32,7 +32,7 @@ void ConnectionMenu::reset_output_option() {
this->selected_index = -1;
}
void ConnectionMenu::set_output_option(int index) {
void ConnectionMenu::set_output_option(int index, int action) {
this->selected_index = index;
}
@@ -40,7 +40,7 @@ int ConnectionMenu::get_num_options() {
return this->devices_list->numValidDevices;
}
std::string ConnectionMenu::get_string_option(int index) {
std::string ConnectionMenu::get_string_option(int index, int action) {
return std::string(&this->devices_list->serialNumbers[SERIAL_NUMBER_SIZE * index]);
}

View File

@@ -8,8 +8,8 @@ CropMenu::~CropMenu() {
}
void CropMenu::class_setup() {
this->num_elements_per_screen = 5;
this->min_elements_text_scaling_factor = num_elements_per_screen + 2;
this->num_options_per_screen = 5;
this->min_elements_text_scaling_factor = num_options_per_screen + 2;
this->width_factor_menu = 16;
this->width_divisor_menu = 9;
this->base_height_factor_menu = 12;
@@ -32,8 +32,8 @@ void CropMenu::reset_output_option() {
this->selected_index = CROP_MENU_NO_ACTION;
}
void CropMenu::set_output_option(int index) {
if(index == -1)
void CropMenu::set_output_option(int index, int action) {
if(index == BACK_X_OUTPUT_OPTION)
this->selected_index = CROP_MENU_BACK;
else
this->selected_index = index;
@@ -43,7 +43,7 @@ int CropMenu::get_num_options() {
return (*this->possible_crops).size();
}
std::string CropMenu::get_string_option(int index) {
std::string CropMenu::get_string_option(int index, int action) {
return (*this->possible_crops)[index]->name;
}
@@ -51,9 +51,9 @@ void CropMenu::prepare(float menu_scaling_factor, int view_size_x, int view_size
int num_pages = this->get_num_pages();
if(this->future_data.page >= num_pages)
this->future_data.page = num_pages - 1;
int start = this->future_data.page * this->num_elements_per_screen;
for(int i = 0; i < this->num_elements_per_screen; i++) {
int index = i + this->elements_start_id;
int start = this->future_data.page * this->num_options_per_screen;
for(int i = 0; i < this->num_options_per_screen + 1; i++) {
int index = (i * this->single_option_multiplier) + this->elements_start_id;
if(!this->future_enabled_labels[index])
continue;
int crop_index = start + i;

View File

@@ -133,8 +133,8 @@ MainMenu::~MainMenu() {
}
void MainMenu::class_setup() {
this->num_elements_per_screen = 5;
this->min_elements_text_scaling_factor = num_elements_per_screen + 2;
this->num_options_per_screen = 5;
this->min_elements_text_scaling_factor = num_options_per_screen + 2;
this->width_factor_menu = 16;
this->width_divisor_menu = 9;
this->base_height_factor_menu = 12;
@@ -174,8 +174,8 @@ void MainMenu::reset_output_option() {
this->selected_index = MainMenuOutAction::MAIN_MENU_NO_ACTION;
}
void MainMenu::set_output_option(int index) {
if(index == -1)
void MainMenu::set_output_option(int index, int action) {
if(index == BACK_X_OUTPUT_OPTION)
this->selected_index = MAIN_MENU_CLOSE_MENU;
else
this->selected_index = pollable_options[this->options_indexes[index]]->out_action;
@@ -185,7 +185,7 @@ int MainMenu::get_num_options() {
return this->num_enabled_options;
}
std::string MainMenu::get_string_option(int index) {
std::string MainMenu::get_string_option(int index, int action) {
return pollable_options[this->options_indexes[index]]->base_name;
}
@@ -199,9 +199,9 @@ void MainMenu::prepare(float menu_scaling_factor, int view_size_x, int view_size
int num_pages = this->get_num_pages();
if(this->future_data.page >= num_pages)
this->future_data.page = num_pages - 1;
int start = this->future_data.page * this->num_elements_per_screen;
for(int i = 0; i < this->num_elements_per_screen; i++) {
int index = i + this->elements_start_id;
int start = this->future_data.page * this->num_options_per_screen;
for(int i = 0; i < this->num_options_per_screen + 1; i++) {
int index = (i * this->single_option_multiplier) + this->elements_start_id;
if(!this->future_enabled_labels[index])
continue;
int option_index = this->options_indexes[start + i];

View File

@@ -43,7 +43,7 @@ void OptionSelectionMenu::initialize(bool font_load_success, sf::Font &text_font
}
void OptionSelectionMenu::class_setup() {
this->num_elements_per_screen = 1;
this->num_options_per_screen = 1;
this->min_elements_text_scaling_factor = 3;
this->width_factor_menu = 1;
this->width_divisor_menu = 1;
@@ -61,15 +61,17 @@ void OptionSelectionMenu::class_setup() {
void OptionSelectionMenu::after_class_setup_connected_values() {
this->num_title_back_x_elements = 2;
this->num_page_elements = 3;
this->num_elements_displayed_per_screen = num_title_back_x_elements + num_elements_per_screen + 1 + num_page_elements;
this->num_vertical_slices = num_elements_per_screen + 1;
this->single_option_multiplier = 3;
this->num_elements_per_screen = single_option_multiplier * (this->num_options_per_screen + 1);
this->num_elements_displayed_per_screen = num_title_back_x_elements + num_elements_per_screen + num_page_elements;
this->num_vertical_slices = num_options_per_screen + 1;
if(show_back_x || show_title)
this->num_vertical_slices += 1;
this->title_back_x_start_id = 0;
this->elements_start_id = num_title_back_x_elements + title_back_x_start_id;
this->page_elements_start_id = num_elements_per_screen + elements_start_id + 1;
this->back_x_id = title_back_x_start_id + 1;
this->title_id = title_back_x_start_id;
this->page_elements_start_id = elements_start_id + num_elements_per_screen;
this->back_x_id = title_back_x_start_id;
this->title_id = title_back_x_start_id + 1;
this->prev_page_id = page_elements_start_id;
this->info_page_id = page_elements_start_id + 1;
this->next_page_id = page_elements_start_id + 2;
@@ -91,13 +93,45 @@ void OptionSelectionMenu::reset_data() {
this->future_data.page = 0;
}
void OptionSelectionMenu::decrement_selected_option() {
bool OptionSelectionMenu::is_curr_option_location_left() {
bool location_left = true;
if(this->future_data.option_selected == this->next_page_id)
location_left = false;
else if((this->future_data.option_selected >= this->elements_start_id) && (this->future_data.option_selected <= (this->elements_start_id + this->num_elements_per_screen)) && (((this->future_data.option_selected - this->elements_start_id) % this->single_option_multiplier) == 2))
location_left = false;
return location_left;
}
bool OptionSelectionMenu::is_curr_option_location_multichoice() {
bool location_left = true;
if((this->future_data.option_selected == this->next_page_id) || (this->future_data.option_selected == this->prev_page_id))
return true;
if((this->future_data.option_selected >= this->elements_start_id) && (this->future_data.option_selected <= (this->elements_start_id + this->num_elements_per_screen)) && (((this->future_data.option_selected - this->elements_start_id) % this->single_option_multiplier) != 0))
return true;
return false;
}
void OptionSelectionMenu::decrement_selected_option(bool is_simple) {
if(this->future_data.option_selected < 0) {
this->future_data.option_selected = this->elements_start_id;
return;
}
if(this->future_data.option_selected >= this->page_elements_start_id)
this->future_data.option_selected = this->page_elements_start_id;
bool location_left = this->is_curr_option_location_left();
bool multichoice = this->is_curr_option_location_multichoice();
if(!is_simple) {
if(this->future_data.option_selected == this->next_page_id)
this->future_data.option_selected = this->prev_page_id;
else {
if(multichoice && location_left)
this->future_data.option_selected -= this->single_option_multiplier - 1;
else
this->future_data.option_selected -= 1;
}
}
do {
this->future_data.option_selected -= 1;
if(this->future_data.option_selected < 0)
@@ -105,35 +139,61 @@ void OptionSelectionMenu::decrement_selected_option() {
} while(!(this->selectable_labels[this->future_data.option_selected] && this->future_enabled_labels[this->future_data.option_selected]));
}
void OptionSelectionMenu::increment_selected_option() {
void OptionSelectionMenu::increment_selected_option(bool is_simple) {
if(this->future_data.option_selected < 0){
this->future_data.option_selected = this->elements_start_id;
return;
}
do {
this->future_data.option_selected += 1;
if(this->future_data.option_selected >= this->num_elements_displayed_per_screen)
this->future_data.option_selected = 0;
} while(!(this->selectable_labels[this->future_data.option_selected] && this->future_enabled_labels[this->future_data.option_selected]));
}
bool location_left = this->is_curr_option_location_left();
if(is_simple || location_left) {
if((!is_simple) && (this->future_data.option_selected != this->prev_page_id))
this->future_data.option_selected += 1;
do {
this->future_data.option_selected += 1;
if(this->future_data.option_selected >= this->num_elements_displayed_per_screen)
this->future_data.option_selected = 0;
} while(!(this->selectable_labels[this->future_data.option_selected] && this->future_enabled_labels[this->future_data.option_selected]));
}
else {
bool success = false;
do {
this->future_data.option_selected += this->single_option_multiplier;
if(this->future_data.option_selected >= this->num_elements_displayed_per_screen) {
this->future_data.option_selected = 0;
break;
}
for(int i = 0; i < this->single_option_multiplier; i++) {
if(this->selectable_labels[this->future_data.option_selected - i] && this->future_enabled_labels[this->future_data.option_selected - i]) {
this->future_data.option_selected -= i;
success = true;
break;
}
}
} while(!success);
}
}
void OptionSelectionMenu::reset_output_option() {
}
void OptionSelectionMenu::set_output_option(int index) {
void OptionSelectionMenu::set_output_option(int index, int action) {
}
int OptionSelectionMenu::get_num_options() {
return this->num_elements_per_screen;
return this->num_options_per_screen;
}
std::string OptionSelectionMenu::get_string_option(int index) {
bool OptionSelectionMenu::is_option_inc_dec(int index) {
return false;
}
std::string OptionSelectionMenu::get_string_option(int index, int action) {
return "Sample Text";
}
int OptionSelectionMenu::get_num_pages() {
int num_pages = 1 + ((this->get_num_options() - 1) / this->num_elements_per_screen);
if(this->get_num_options() == (this->num_elements_per_screen + 1))
int num_pages = 1 + ((this->get_num_options() - 1) / this->num_options_per_screen);
if(this->get_num_options() == (this->num_options_per_screen + 1))
num_pages = 1;
return num_pages;
}
@@ -142,10 +202,10 @@ void OptionSelectionMenu::prepare_options() {
int num_pages = this->get_num_pages();
if(this->future_data.page >= num_pages)
this->future_data.page = num_pages - 1;
int start = this->future_data.page * this->num_elements_per_screen;
int start = this->future_data.page * this->num_options_per_screen;
int total_elements = this->get_num_options() - start;
if((num_pages > 1) && (total_elements > this->num_elements_per_screen))
total_elements = this->num_elements_per_screen;
if((num_pages > 1) && (total_elements > this->num_options_per_screen))
total_elements = this->num_options_per_screen;
for(int i = 0; i < this->num_elements_displayed_per_screen; i++) {
this->future_enabled_labels[i] = false;
this->labels[i]->setShowText(false);
@@ -164,9 +224,24 @@ void OptionSelectionMenu::prepare_options() {
this->labels[this->title_id]->setShowText(true);
}
for(int i = 0; i < total_elements; i++) {
this->future_enabled_labels[i + this->elements_start_id] = true;
this->labels[i + this->elements_start_id]->setText(this->get_string_option(i + start));
this->labels[i + this->elements_start_id]->setShowText(true);
int label_start_index = (i * this->single_option_multiplier) + this->elements_start_id;
for(int j = 0; j < this->single_option_multiplier; j++)
this->selectable_labels[label_start_index + j] = false;
this->future_enabled_labels[label_start_index] = true;
this->labels[label_start_index]->setText(this->get_string_option(start + i, DEFAULT_ACTION));
this->labels[label_start_index]->setShowText(true);
if(!is_option_inc_dec(start + i))
this->selectable_labels[label_start_index] = true;
else {
this->labels[label_start_index + 1]->setText(this->get_string_option(start + i, DEC_ACTION));
this->labels[label_start_index + 1]->setShowText(true);
this->future_enabled_labels[label_start_index + 1] = true;
this->selectable_labels[label_start_index + 1] = true;
this->labels[label_start_index + 2]->setText(this->get_string_option(start + i, INC_ACTION));
this->labels[label_start_index + 2]->setShowText(true);
this->future_enabled_labels[label_start_index + 2] = true;
this->selectable_labels[label_start_index + 2] = true;
}
}
if(num_pages > 1) {
this->future_enabled_labels[this->info_page_id] = true;
@@ -197,16 +272,18 @@ void OptionSelectionMenu::option_selection_handling() {
if(!this->can_execute_action())
return;
if(this->future_data.option_selected == this->back_x_id) {
this->set_output_option(-1);
this->set_output_option(BACK_X_OUTPUT_OPTION, BAD_ACTION);
this->last_action_time = std::chrono::high_resolution_clock::now();
}
else if(this->future_data.option_selected < (this->num_elements_per_screen + this->elements_start_id + 1)) {
this->set_output_option(this->future_data.option_selected - this->elements_start_id + (this->num_elements_per_screen * this->future_data.page));
else if(this->future_data.option_selected < (this->elements_start_id + this->num_elements_per_screen)) {
int elem_index = this->future_data.option_selected - this->elements_start_id;
int start = this->num_options_per_screen * this->future_data.page;
this->set_output_option((elem_index / this->single_option_multiplier) + start, elem_index % this->single_option_multiplier);
this->last_action_time = std::chrono::high_resolution_clock::now();
}
else if((this->future_data.option_selected == this->prev_page_id) && this->future_data.page > 0)
this->future_data.page--;
else if((this->future_data.option_selected == this->next_page_id) && this->future_data.page < ((this->get_num_options() - 1) / this->num_elements_per_screen))
else if((this->future_data.option_selected == this->next_page_id) && this->future_data.page < ((this->get_num_options() - 1) / this->num_options_per_screen))
this->future_data.page++;
if(old_loaded_page != this->future_data.page) {
this->prepare_options();
@@ -214,43 +291,51 @@ void OptionSelectionMenu::option_selection_handling() {
}
}
void OptionSelectionMenu::up_code() {
void OptionSelectionMenu::up_code(bool is_simple) {
if(!this->can_execute_action())
return;
this->decrement_selected_option();
this->decrement_selected_option(is_simple);
this->last_action_time = std::chrono::high_resolution_clock::now();
}
void OptionSelectionMenu::down_code() {
void OptionSelectionMenu::down_code(bool is_simple) {
if(!this->can_execute_action())
return;
this->increment_selected_option();
this->increment_selected_option(is_simple);
this->last_action_time = std::chrono::high_resolution_clock::now();
}
void OptionSelectionMenu::left_code() {
if(!this->can_execute_action())
return;
if(this->selectable_labels[this->prev_page_id] && this->future_enabled_labels[this->prev_page_id]) {
if(this->future_data.option_selected == this->prev_page_id)
this->option_selection_handling();
else {
this->future_data.option_selected = this->prev_page_id;
this->last_action_time = std::chrono::high_resolution_clock::now();
}
bool location_left = this->is_curr_option_location_left();
bool multichoice = this->is_curr_option_location_multichoice();
if(multichoice && location_left)
this->option_selection_handling();
else if(multichoice && (this->future_data.option_selected != this->next_page_id)) {
this->future_data.option_selected -= 1;
this->last_action_time = std::chrono::high_resolution_clock::now();
}
else if(this->selectable_labels[this->prev_page_id] && this->future_enabled_labels[this->prev_page_id]) {
this->future_data.option_selected = this->prev_page_id;
this->last_action_time = std::chrono::high_resolution_clock::now();
}
}
void OptionSelectionMenu::right_code() {
if(!this->can_execute_action())
return;
if(this->selectable_labels[this->next_page_id] && this->future_enabled_labels[this->next_page_id]) {
if(this->future_data.option_selected == this->next_page_id)
this->option_selection_handling();
else {
this->future_data.option_selected = this->next_page_id;
this->last_action_time = std::chrono::high_resolution_clock::now();
}
bool location_left = this->is_curr_option_location_left();
bool multichoice = this->is_curr_option_location_multichoice();
if(multichoice && (!location_left))
this->option_selection_handling();
else if(multichoice && (this->future_data.option_selected != this->prev_page_id)) {
this->future_data.option_selected += 1;
this->last_action_time = std::chrono::high_resolution_clock::now();
}
else if(this->selectable_labels[this->next_page_id] && this->future_enabled_labels[this->next_page_id]) {
this->future_data.option_selected = this->next_page_id;
this->last_action_time = std::chrono::high_resolution_clock::now();
}
}
@@ -269,16 +354,16 @@ bool OptionSelectionMenu::poll(SFEvent &event_data) {
case sf::Event::KeyPressed:
switch (event_data.code) {
case sf::Keyboard::Up:
this->up_code();
this->up_code(false);
break;
case sf::Keyboard::Down:
this->down_code();
this->down_code(false);
break;
case sf::Keyboard::PageUp:
this->up_code();
this->up_code(true);
break;
case sf::Keyboard::PageDown:
this->down_code();
this->down_code(true);
break;
case sf::Keyboard::Left:
this->left_code();
@@ -338,10 +423,10 @@ bool OptionSelectionMenu::poll(SFEvent &event_data) {
case sf::Event::JoystickMoved:
switch(get_joystick_direction(event_data.joystickId, event_data.axis, event_data.position)) {
case JOY_DIR_UP:
this->up_code();
this->up_code(false);
break;
case JOY_DIR_DOWN:
this->down_code();
this->down_code(false);
break;
case JOY_DIR_LEFT:
this->left_code();
@@ -393,7 +478,7 @@ void OptionSelectionMenu::prepare_text_slices(int x_multiplier, int x_divisor, i
else {
if((index == this->back_x_id) && this->show_x)
this->labels[index]->setRectangleKind(TEXT_KIND_OPAQUE_ERROR);
else if(index == this->title_id)
else if(!this->selectable_labels[index])
this->labels[index]->setRectangleKind(TEXT_KIND_TITLE);
else
this->labels[index]->setRectangleKind(TEXT_KIND_NORMAL);
@@ -406,8 +491,8 @@ void OptionSelectionMenu::base_prepare(float menu_scaling_factor, int view_size_
bool has_top = this->future_enabled_labels[this->back_x_id] || this->future_enabled_labels[this->title_id];
if(has_top)
num_elements += 1;
for(int i = 0; i < (this->num_elements_per_screen + 1); i++)
if(this->future_enabled_labels[i + this->elements_start_id])
for(int i = 0; i < (this->num_options_per_screen + 1); i++)
if(this->future_enabled_labels[(i * this->single_option_multiplier) + this->elements_start_id])
num_elements++;
bool has_bottom = false;
for(int i = 0; i < this->num_page_elements; i++)
@@ -415,7 +500,7 @@ void OptionSelectionMenu::base_prepare(float menu_scaling_factor, int view_size_
has_bottom = true;
if(has_bottom)
num_elements += 1;
const float base_height = (this->num_vertical_slices * BASE_PIXEL_FONT_HEIGHT * 10) / 9;
const float base_height = (this->num_vertical_slices * BASE_PIXEL_FONT_HEIGHT * 11) / 9;
int max_width = (view_size_x * 9) / 10;
int max_height = (view_size_y * 9) / 10;
float max_width_corresponding_height = (max_width * this->width_divisor_menu * this->max_width_slack) / this->width_factor_menu;
@@ -455,10 +540,17 @@ void OptionSelectionMenu::base_prepare(float menu_scaling_factor, int view_size_
}
if(has_top)
++num_rendered_y;
for(int i = 0; i < (this->num_elements_per_screen + 1); i++) {
int index = i + this->elements_start_id;
for(int i = 0; i < (this->num_options_per_screen + 1); i++) {
int index = (i * this->single_option_multiplier) + this->elements_start_id;
if(this->future_enabled_labels[index]) {
int elem_divisor = 1;
if(this->future_enabled_labels[index + 1] || this->future_enabled_labels[index + 2])
elem_divisor = 6;
this->prepare_text_slices(0, 1, num_rendered_y, num_elements, index, text_scaling_factor);
if(this->future_enabled_labels[index + 1])
this->prepare_text_slices(0, elem_divisor, num_rendered_y, num_elements, index + 1, text_scaling_factor);
if(this->future_enabled_labels[index + 2])
this->prepare_text_slices(elem_divisor - 1, elem_divisor, num_rendered_y, num_elements, index + 2, text_scaling_factor);
++num_rendered_y;
}
}

View File

@@ -8,8 +8,8 @@ PARMenu::~PARMenu() {
}
void PARMenu::class_setup() {
this->num_elements_per_screen = 5;
this->min_elements_text_scaling_factor = num_elements_per_screen + 2;
this->num_options_per_screen = 5;
this->min_elements_text_scaling_factor = num_options_per_screen + 2;
this->width_factor_menu = 16;
this->width_divisor_menu = 9;
this->base_height_factor_menu = 12;
@@ -36,8 +36,8 @@ void PARMenu::reset_output_option() {
this->selected_index = PAR_MENU_NO_ACTION;
}
void PARMenu::set_output_option(int index) {
if(index == -1)
void PARMenu::set_output_option(int index, int action) {
if(index == BACK_X_OUTPUT_OPTION)
this->selected_index = PAR_MENU_BACK;
else
this->selected_index = index;
@@ -47,7 +47,7 @@ int PARMenu::get_num_options() {
return (*this->possible_pars).size();
}
std::string PARMenu::get_string_option(int index) {
std::string PARMenu::get_string_option(int index, int action) {
return (*this->possible_pars)[index]->name;
}
@@ -55,9 +55,9 @@ void PARMenu::prepare(float menu_scaling_factor, int view_size_x, int view_size_
int num_pages = this->get_num_pages();
if(this->future_data.page >= num_pages)
this->future_data.page = num_pages - 1;
int start = this->future_data.page * this->num_elements_per_screen;
for(int i = 0; i < this->num_elements_per_screen; i++) {
int index = i + this->elements_start_id;
int start = this->future_data.page * this->num_options_per_screen;
for(int i = 0; i < this->num_options_per_screen + 1; i++) {
int index = (i * this->single_option_multiplier) + this->elements_start_id;
if(!this->future_enabled_labels[index])
continue;
int par_index = start + i;

View File

@@ -10,6 +10,10 @@ struct VideoMenuOptionInfo {
const bool active_joint_screen;
const bool active_top_screen;
const bool active_bottom_screen;
const bool is_inc;
const std::string dec_str;
const std::string inc_str;
const VideoMenuOutAction inc_out_action;
const VideoMenuOutAction out_action;
};
@@ -17,132 +21,154 @@ static const VideoMenuOptionInfo vsync_option = {
.base_name = "Turn VSync Off", .false_name = "Turn VSync On",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION,
.out_action = VIDEO_MENU_VSYNC};
static const VideoMenuOptionInfo async_option = {
.base_name = "Turn Async Off", .false_name = "Turn Async On",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION,
.out_action = VIDEO_MENU_ASYNC};
static const VideoMenuOptionInfo blur_option = {
.base_name = "Turn Blur Off", .false_name = "Turn Blur On",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION,
.out_action = VIDEO_MENU_BLUR};
static const VideoMenuOptionInfo padding_option = {
.base_name = "Turn Padding Off", .false_name = "Turn Padding On",
.active_fullscreen = false, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION,
.out_action = VIDEO_MENU_PADDING};
static const VideoMenuOptionInfo crop_option = {
.base_name = "Crop Settings", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION,
.out_action = VIDEO_MENU_CROPPING};
static const VideoMenuOptionInfo top_par_option = {
.base_name = "Top Screen PAR", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION,
.out_action = VIDEO_MENU_TOP_PAR};
static const VideoMenuOptionInfo bot_par_option = {
.base_name = "Bottom Screen PAR", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION,
.out_action = VIDEO_MENU_BOT_PAR};
static const VideoMenuOptionInfo one_par_option = {
.base_name = "Screen PAR", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = false, .active_top_screen = true, .active_bottom_screen = true,
.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION,
.out_action = VIDEO_MENU_ONE_PAR};
static const VideoMenuOptionInfo bottom_screen_pos_option = {
.base_name = "Bottom Screen Pos.", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION,
.out_action = VIDEO_MENU_BOTTOM_SCREEN_POS};
static const VideoMenuOptionInfo small_screen_offset_option = {
.base_name = "Smaller Screen Offset", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION,
.out_action = VIDEO_MENU_SMALL_SCREEN_OFFSET};
static const VideoMenuOptionInfo subscreen_distance_option = {
.base_name = "Sub-Screen Distance", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = false,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION,
.out_action = VIDEO_MENU_SMALL_SCREEN_DISTANCE};
static const VideoMenuOptionInfo canvas_x_pos_option = {
.base_name = "Canvas X Position", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = false,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION,
.out_action = VIDEO_MENU_SCREENS_X_POS};
static const VideoMenuOptionInfo canvas_y_pos_option = {
.base_name = "Canvas Y Position", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = false,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION,
.out_action = VIDEO_MENU_SCREENS_Y_POS};
static const VideoMenuOptionInfo window_scaling_option = {
.base_name = "Scaling Factor", .false_name = "",
.active_fullscreen = false, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.out_action = VIDEO_MENU_WINDOW_SCALING};
.is_inc = true, .dec_str = "-0.5", .inc_str = "+0.5", .inc_out_action = VIDEO_MENU_WINDOW_SCALING_INC,
.out_action = VIDEO_MENU_WINDOW_SCALING_DEC};
static const VideoMenuOptionInfo fullscreen_scaling_option = {
.base_name = "Screens Scaling", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = false,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.out_action = VIDEO_MENU_FULLSCREEN_SCALING};
.is_inc = true, .dec_str = "+ Top", .inc_str = "+ Bot.", .inc_out_action = VIDEO_MENU_FULLSCREEN_SCALING_BOTTOM,
.out_action = VIDEO_MENU_FULLSCREEN_SCALING_TOP};
static const VideoMenuOptionInfo bfi_settings_option = {
.base_name = "BFI Settings", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION,
.out_action = VIDEO_MENU_BFI_SETTINGS};
static const VideoMenuOptionInfo menu_scaling_option = {
.base_name = "Menu Scaling", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.out_action = VIDEO_MENU_MENU_SCALING};
.is_inc = true, .dec_str = "-0.1", .inc_str = "+0.1", .inc_out_action = VIDEO_MENU_MENU_SCALING_INC,
.out_action = VIDEO_MENU_MENU_SCALING_DEC};
static const VideoMenuOptionInfo resolution_settings_option = {
.base_name = "Resolution Settings", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = false,
.active_joint_screen = true, .active_top_screen = true, .active_bottom_screen = true,
.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION,
.out_action = VIDEO_MENU_RESOLUTION_SETTINGS};
static const VideoMenuOptionInfo top_rotation_option = {
.base_name = "Top Screen Rot.", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION,
.out_action = VIDEO_MENU_TOP_ROTATION};
static const VideoMenuOptionInfo bottom_rotation_option = {
.base_name = "Bottom Screen Rot.", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = true, .active_top_screen = false, .active_bottom_screen = false,
.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION,
.out_action = VIDEO_MENU_BOTTOM_ROTATION};
static const VideoMenuOptionInfo top_one_rotation_option = {
.base_name = "Screen Rotation", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = false, .active_top_screen = true, .active_bottom_screen = false,
.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION,
.out_action = VIDEO_MENU_TOP_ROTATION};
static const VideoMenuOptionInfo bottom_one_rotation_option = {
.base_name = "Screen Rotation", .false_name = "",
.active_fullscreen = true, .active_windowed_screen = true,
.active_joint_screen = false, .active_top_screen = false, .active_bottom_screen = true,
.is_inc = false, .dec_str = "", .inc_str = "", .inc_out_action = VIDEO_MENU_NO_ACTION,
.out_action = VIDEO_MENU_BOTTOM_ROTATION};
static const VideoMenuOptionInfo* pollable_options[] = {
@@ -181,8 +207,8 @@ VideoMenu::~VideoMenu() {
}
void VideoMenu::class_setup() {
this->num_elements_per_screen = 5;
this->min_elements_text_scaling_factor = num_elements_per_screen + 2;
this->num_options_per_screen = 5;
this->min_elements_text_scaling_factor = num_options_per_screen + 2;
this->width_factor_menu = 16;
this->width_divisor_menu = 9;
this->base_height_factor_menu = 12;
@@ -222,9 +248,11 @@ void VideoMenu::reset_output_option() {
this->selected_index = VideoMenuOutAction::VIDEO_MENU_NO_ACTION;
}
void VideoMenu::set_output_option(int index) {
if(index == -1)
void VideoMenu::set_output_option(int index, int action) {
if(index == BACK_X_OUTPUT_OPTION)
this->selected_index = VIDEO_MENU_BACK;
else if((action == INC_ACTION) && this->is_option_inc_dec(index))
this->selected_index = pollable_options[this->options_indexes[index]]->inc_out_action;
else
this->selected_index = pollable_options[this->options_indexes[index]]->out_action;
}
@@ -233,10 +261,18 @@ int VideoMenu::get_num_options() {
return this->num_enabled_options;
}
std::string VideoMenu::get_string_option(int index) {
std::string VideoMenu::get_string_option(int index, int action) {
if((action == INC_ACTION) && this->is_option_inc_dec(index))
return pollable_options[this->options_indexes[index]]->inc_str;
if((action == DEC_ACTION) && this->is_option_inc_dec(index))
return pollable_options[this->options_indexes[index]]->dec_str;
return pollable_options[this->options_indexes[index]]->base_name;
}
bool VideoMenu::is_option_inc_dec(int index) {
return pollable_options[this->options_indexes[index]]->is_inc;
}
static std::string setTextOptionBool(int option_index, bool value) {
if(value)
return pollable_options[option_index]->base_name;
@@ -263,9 +299,9 @@ void VideoMenu::prepare(float menu_scaling_factor, int view_size_x, int view_siz
int num_pages = this->get_num_pages();
if(this->future_data.page >= num_pages)
this->future_data.page = num_pages - 1;
int start = this->future_data.page * this->num_elements_per_screen;
for(int i = 0; i < this->num_elements_per_screen; i++) {
int index = i + this->elements_start_id;
int start = this->future_data.page * this->num_options_per_screen;
for(int i = 0; i < this->num_options_per_screen + 1; i++) {
int index = (i * this->single_option_multiplier) + this->elements_start_id;
if(!this->future_enabled_labels[index])
continue;
int option_index = this->options_indexes[start + i];
@@ -282,13 +318,13 @@ void VideoMenu::prepare(float menu_scaling_factor, int view_size_x, int view_siz
case VIDEO_MENU_PADDING:
this->labels[index]->setText(setTextOptionBool(option_index, info->rounded_corners_fix));
break;
case VIDEO_MENU_WINDOW_SCALING:
case VIDEO_MENU_WINDOW_SCALING_DEC:
this->labels[index]->setText(setTextOptionFloat(option_index, info->scaling));
break;
case VIDEO_MENU_MENU_SCALING:
case VIDEO_MENU_MENU_SCALING_DEC:
this->labels[index]->setText(setTextOptionFloat(option_index, info->menu_scaling_factor));
break;
case VIDEO_MENU_FULLSCREEN_SCALING:
case VIDEO_MENU_FULLSCREEN_SCALING_TOP:
this->labels[index]->setText(setTextOptionDualPercentage(option_index, info->top_scaling, info->bot_scaling));
break;
case VIDEO_MENU_TOP_ROTATION:

View File

@@ -186,8 +186,40 @@ void WindowScreen::offset_change(float &value, float change) {
this->future_operations.call_screen_settings_update = true;
}
void WindowScreen::menu_scaling_change(bool positive) {
double old_scaling = this->m_info.menu_scaling_factor;
if(positive)
this->m_info.menu_scaling_factor += 0.1;
else
this->m_info.menu_scaling_factor -= 0.1;
if(this->m_info.menu_scaling_factor < 0.35)
this->m_info.menu_scaling_factor = 0.3;
if(this->m_info.menu_scaling_factor > 9.95)
this->m_info.menu_scaling_factor = 10.0;
if(old_scaling != this->m_info.menu_scaling_factor) {
this->print_notification_float("Menu Scaling", this->m_info.menu_scaling_factor, 1);
}
}
void WindowScreen::window_scaling_change(bool positive) {
if(this->m_info.is_fullscreen)
return;
double old_scaling = this->m_info.scaling;
if(positive)
this->m_info.scaling += 0.5;
else
this->m_info.scaling -= 0.5;
if (this->m_info.scaling < 1.25)
this->m_info.scaling = 1.0;
if (this->m_info.scaling > 44.75)
this->m_info.scaling = 45.0;
if(old_scaling != this->m_info.scaling) {
this->print_notification_float("Scaling", this->m_info.scaling, 1);
this->future_operations.call_screen_settings_update = true;
}
}
bool WindowScreen::common_poll(SFEvent &event_data) {
double old_scaling = 0.0;
bool consumed = true;
switch(event_data.type) {
case sf::Event::Closed:
@@ -213,51 +245,21 @@ bool WindowScreen::common_poll(SFEvent &event_data) {
break;
case 'z':
old_scaling = this->m_info.menu_scaling_factor;
this->m_info.menu_scaling_factor -= 0.1;
if(this->m_info.menu_scaling_factor < 0.35)
this->m_info.menu_scaling_factor = 0.3;
if(old_scaling != this->m_info.menu_scaling_factor) {
this->print_notification_float("Menu Scaling", this->m_info.menu_scaling_factor, 1);
}
this->menu_scaling_change(false);
break;
case 'x':
old_scaling = this->m_info.menu_scaling_factor;
this->m_info.menu_scaling_factor += 0.1;
if(this->m_info.menu_scaling_factor > 9.95)
this->m_info.menu_scaling_factor = 10.0;
if(old_scaling != this->m_info.menu_scaling_factor) {
this->print_notification_float("Menu Scaling", this->m_info.menu_scaling_factor, 1);
}
this->menu_scaling_change(true);
break;
case '-':
if(this->m_info.is_fullscreen)
break;
old_scaling = this->m_info.scaling;
this->m_info.scaling -= 0.5;
if (this->m_info.scaling < 1.25)
this->m_info.scaling = 1.0;
if(old_scaling != this->m_info.scaling) {
this->print_notification_float("Scaling", this->m_info.scaling, 1);
this->future_operations.call_screen_settings_update = true;
}
this->window_scaling_change(false);
break;
case '0':
if(this->m_info.is_fullscreen)
break;
old_scaling = this->m_info.scaling;
this->m_info.scaling += 0.5;
if (this->m_info.scaling > 44.75)
this->m_info.scaling = 45.0;
if(old_scaling != this->m_info.scaling) {
this->print_notification_float("Scaling", this->m_info.scaling, 1);
this->future_operations.call_screen_settings_update = true;
}
this->window_scaling_change(true);
break;
default:
consumed = false;
break;
@@ -672,6 +674,18 @@ void WindowScreen::poll() {
case VIDEO_MENU_ONE_PAR:
this->setup_par_menu(this->m_stype == ScreenType::TOP);
return;
case VIDEO_MENU_MENU_SCALING_DEC:
this->menu_scaling_change(false);
break;
case VIDEO_MENU_MENU_SCALING_INC:
this->menu_scaling_change(true);
break;
case VIDEO_MENU_WINDOW_SCALING_DEC:
this->window_scaling_change(false);
break;
case VIDEO_MENU_WINDOW_SCALING_INC:
this->window_scaling_change(true);
break;
default:
break;
}

View File

@@ -118,10 +118,22 @@ const PARData snes_vertical_par = {
.is_width_main = false,
.name = "SNES Vertical"};
const PARData special_3ds_horizontal_par = {
.width_multiplier = 1.0, .width_divisor = 2.0,
.is_width_main = true,
.name = "3DS 800x240 Horizontal"};
const PARData special_3ds_vertical_par = {
.width_multiplier = 1.0, .width_divisor = 2.0,
.is_width_main = false,
.name = "3DS 800x240 Vertical"};
static const PARData* basic_possible_pars[] = {
&base_par,
&snes_horizontal_par,
&snes_vertical_par,
//&special_3ds_horizontal_par,
//&special_3ds_vertical_par,
};
bool is_allowed_crop(const CropData* crop_data, ScreenType s_type) {