2 #include "mainwidget.h"
3 #include "commonclasses.h"
4 #include "menu_bubble.h"
6 #include "qt_dialogs.h"
8 #include "agar_logger.h"
10 #if defined(USE_BUBBLE1)
13 #ifndef UPDATE_B77_LIST
14 #define UPDATE_B77_LIST(__d, lst) { \
17 for(int iii = 0; iii < MAX_B77_BANKS; iii++) { \
18 __tmps = QString::fromUtf8(""); \
19 if(iii < emu->b77_file[__d].bank_num) { \
20 __tmps = QString::fromUtf8(emu->b77_file[__d].bubble_name[iii]); \
27 int Ui_MainWindow::set_b77_slot(int drive, int num)
30 if((num < 0) || (num >= using_flags->get_max_b77_banks())) return -1;
31 path = QString::fromUtf8(emu->b77_file[drive].path);
32 menu_bubbles[drive]->do_select_inner_media(num);
34 if(emu && emu->b77_file[drive].cur_bank != num) {
35 emit sig_open_bubble(drive, path, num);
36 if(emu->is_bubble_casette_protected(drive)) {
37 menu_bubbles[drive]->do_set_write_protect(true);
39 menu_bubbles[drive]->do_set_write_protect(false);
45 void Ui_MainWindow::do_update_recent_bubble(int drv)
48 if(emu == NULL) return;
49 menu_bubbles[drv]->do_update_histories(listBubbles[drv]);
50 menu_bubbles[drv]->do_set_initialize_directory(p_config->initial_bubble_casette_dir);
51 if(emu->is_bubble_casette_protected(drv)) {
52 menu_bubbles[drv]->do_write_protect_media();
54 menu_bubbles[drv]->do_write_unprotect_media();
59 int Ui_MainWindow::set_recent_bubble(int drv, int num)
62 char path_shadow[PATH_MAX];
64 if((num < 0) || (num >= MAX_HISTORY)) return -1;
65 s_path = QString::fromLocal8Bit(p_config->recent_bubble_casette_path[drv][num]);
66 strncpy(path_shadow, s_path.toLocal8Bit().constData(), PATH_MAX);
67 UPDATE_HISTORY(path_shadow, p_config->recent_bubble_casette_path[drv], listBubbles[drv]);
68 strncpy(path_shadow, s_path.toLocal8Bit().constData(), PATH_MAX);
70 get_parent_dir(path_shadow);
71 strcpy(p_config->initial_bubble_casette_dir, path_shadow);
72 strncpy(path_shadow, s_path.toLocal8Bit().constData(), PATH_MAX);
75 emit sig_close_bubble(drv);
76 emit sig_open_bubble(drv, s_path, 0);
77 menu_bubbles[drv]->do_update_histories(listBubbles[drv]);
78 menu_bubbles[drv]->do_set_initialize_directory(p_config->initial_bubble_casette_dir);
79 if(check_file_extension(path_shadow, ".b77")) {
80 UPDATE_B77_LIST(drv, listB77[drv]);
81 menu_bubbles[drv]->do_update_inner_media_bubble(listB77[drv], 0);
83 menu_bubbles[drv]->do_clear_inner_media();
89 void Ui_MainWindow::_open_bubble(int drv, const QString fname)
91 char path_shadow[PATH_MAX];
94 if(fname.length() <= 0) return;
96 strncpy(path_shadow, fname.toLocal8Bit().constData(), PATH_MAX);
97 UPDATE_HISTORY(path_shadow, p_config->recent_bubble_casette_path[drv], listBubbles[drv]);
98 get_parent_dir(path_shadow);
99 strcpy(p_config->initial_bubble_casette_dir, path_shadow);
101 strncpy(path_shadow, fname.toLocal8Bit().constData(), PATH_MAX);
103 emit sig_close_bubble(drv);
105 emit sig_open_bubble(drv, fname, 0);
106 menu_bubbles[drv]->do_update_histories(listBubbles[drv]);
107 menu_bubbles[drv]->do_set_initialize_directory(p_config->initial_bubble_casette_dir);
108 if(check_file_extension(path_shadow, ".b77")) {
109 UPDATE_B77_LIST(drv, listB77[drv]);
110 menu_bubbles[drv]->do_update_inner_media_bubble(listB77[drv], 0);
112 menu_bubbles[drv]->do_clear_inner_media();
117 void Ui_MainWindow::eject_bubble(int drv)
120 emit sig_close_bubble(drv);
121 menu_bubbles[drv]->do_clear_inner_media();