1 #include "emu_thread_tmpl.h"
2 #include "mainwidget_base.h"
3 #include "commonclasses.h"
5 #include "qt_dialogs.h"
7 #include "menu_flags.h"
9 //#if defined(USE_FLOPPY_DISK)
11 #ifndef UPDATE_D88_LIST
12 #define UPDATE_D88_LIST(__d, lst) { \
15 for(int iii = 0; iii < 64; iii++) { \
16 __tmps = QString::fromUtf8(""); \
17 if(iii < hRunEmu->get_d88_file_bank_num(__d)) { \
18 __tmps = hRunEmu->get_d88_file_disk_name(__d, iii); \
26 //extern DLL_PREFIX_I EMU *emu;
27 int Ui_MainWindowBase::set_d88_slot(int drive, int num)
30 if((num < 0) || (num >= 64)) return -1;
31 //path = QString::fromUtf8(emu->d88_file[drive].path);
32 path = hRunEmu->get_d88_file_path(drive);
33 menu_fds[drive]->do_select_inner_media(num);
34 if(hRunEmu->get_d88_file_cur_bank(drive) != num) {
35 emit sig_open_disk(drive, path, num);
36 if(hRunEmu->is_floppy_disk_protected(drive)) {
37 menu_fds[drive]->do_set_write_protect(true);
39 menu_fds[drive]->do_set_write_protect(false);
45 void Ui_MainWindowBase::do_update_recent_disk(int drv)
47 if(hRunEmu == NULL) return;
48 menu_fds[drv]->do_update_histories(listFDs[drv]);
49 menu_fds[drv]->do_set_initialize_directory(p_config->initial_floppy_disk_dir);
51 // if(hRunEmu->get_d88_file_cur_bank(drv) != num) {
52 if(hRunEmu->is_floppy_disk_protected(drv)) {
53 menu_fds[drv]->do_set_write_protect(true);
55 menu_fds[drv]->do_set_write_protect(false);
62 extern const _TCHAR* DLL_PREFIX_I get_parent_dir(const _TCHAR* file);
64 int Ui_MainWindowBase::set_recent_disk(int drv, int num)
67 char path_shadow[PATH_MAX];
68 if((num < 0) || (num >= MAX_HISTORY)) return -1;
69 s_path = QString::fromLocal8Bit(p_config->recent_floppy_disk_path[drv][num]);
70 strncpy(path_shadow, s_path.toLocal8Bit().constData(), PATH_MAX - 1);
71 UPDATE_HISTORY(path_shadow, p_config->recent_floppy_disk_path[drv], listFDs[drv]);
73 strncpy(p_config->initial_floppy_disk_dir, get_parent_dir((const _TCHAR *)path_shadow), _MAX_PATH - 1);
74 strncpy(path_shadow, s_path.toLocal8Bit().constData(), PATH_MAX - 1);
77 emit sig_close_disk(drv);
78 emit sig_open_disk(drv, s_path, 0);
79 menu_fds[drv]->do_update_histories(listFDs[drv]);
80 menu_fds[drv]->do_set_initialize_directory(p_config->initial_floppy_disk_dir);
81 if(check_file_extension(path_shadow, ".d88") || check_file_extension(path_shadow, ".d77")) {
82 UPDATE_D88_LIST(drv, listD88[drv]);
83 menu_fds[drv]->do_update_inner_media(listD88[drv], 0);
85 menu_fds[drv]->do_clear_inner_media();
87 if(using_flags->get_max_drive() >= 2) {
88 strncpy(path_shadow, s_path.toLocal8Bit().constData(), PATH_MAX - 1);
89 if(check_file_extension(path_shadow, ".d88") || check_file_extension(path_shadow, ".d77")) {
90 if(((drv & 1) == 0) && ((drv + 1) < using_flags->get_max_drive()) && (1 < hRunEmu->get_d88_file_bank_num(drv))) {
93 emit sig_close_disk(drv2);
94 emit sig_open_disk(drv2, s_path, 1);
95 menu_fds[drv2]->do_update_histories(listFDs[drv2]);
96 menu_fds[drv2]->do_set_initialize_directory(p_config->initial_floppy_disk_dir);
97 UPDATE_D88_LIST(drv2, listD88[drv2]);
98 menu_fds[drv2]->do_update_inner_media(listD88[drv2], 1);
106 void Ui_MainWindowBase::_open_disk(int drv, const QString fname)
108 char path_shadow[PATH_MAX];
110 if(fname.length() <= 0) return;
112 strncpy(path_shadow, fname.toLocal8Bit().constData(), PATH_MAX - 1);
113 UPDATE_HISTORY(path_shadow, p_config->recent_floppy_disk_path[drv], listFDs[drv]);
114 strcpy(p_config->initial_floppy_disk_dir, get_parent_dir((const _TCHAR *)path_shadow));
116 strncpy(path_shadow, fname.toLocal8Bit().constData(), PATH_MAX - 1);
118 emit sig_close_disk(drv);
119 emit sig_open_disk(drv, fname, 0);
120 menu_fds[drv]->do_update_histories(listFDs[drv]);
121 menu_fds[drv]->do_set_initialize_directory(p_config->initial_floppy_disk_dir);
122 if(check_file_extension(path_shadow, ".d88") || check_file_extension(path_shadow, ".d77")) {
123 UPDATE_D88_LIST(drv, listD88[drv]);
124 menu_fds[drv]->do_update_inner_media(listD88[drv], 0);
126 menu_fds[drv]->do_clear_inner_media();
129 if(using_flags->get_max_drive() >= 2) {
130 if(check_file_extension(path_shadow, ".d88") || check_file_extension(path_shadow, ".d77")) {
131 if(((drv & 1) == 0) && (drv + 1 < using_flags->get_max_drive()) && (1 < hRunEmu->get_d88_file_bank_num(drv))) {
133 emit sig_close_disk(drv2);
134 strncpy(path_shadow, fname.toLocal8Bit().constData(), PATH_MAX - 1);
135 emit sig_open_disk(drv2, fname, 1);
136 menu_fds[drv2]->do_update_histories(listFDs[drv2]);
137 menu_fds[drv2]->do_set_initialize_directory(p_config->initial_floppy_disk_dir);
138 UPDATE_D88_LIST(drv2, listD88[drv2]);
139 menu_fds[drv2]->do_update_inner_media(listD88[drv2], 1);