OSDN Git Service

90360dad80e666a55013a55107021af6614dc30d
[csp-qt/common_source_project-fm7.git] / source / src / qt / gui / mainwidget_base.h
1 /*
2  * MainWidget : Defines
3  * Modified by K.Ohta <whatisthis.sowhat _at_ gmail.com>
4  * Please use this file as templete.
5  */
6
7 #ifndef _CSP_QT_MAINWIDGET_BASE_H
8 #define _CSP_QT_MAINWIDGET_BASE_H
9
10 #include <QVariant>
11 #include <QObject>
12 #include <QApplication>
13 #include <QMainWindow>
14 #include <QIcon>
15 #include <QString>
16 #include <QStringList>
17 #include <QMap>
18 #include <QAction>
19 #include <QVector>
20 //#include <QMenuBar>
21 #include <memory>
22
23 #include "common.h"
24 #include "config.h"
25 #include "menu_flags.h"
26 #include "csp_logger.h"
27
28 class DLL_PREFIX_I MOVIE_SAVER;
29
30 #include "qt_main.h"
31 #define _MAX_DEBUGGER 8
32
33 enum {
34         CSP_MAINWIDGET_SAVE_MOVIE_STOP = 0,
35         CSP_MAINWIDGET_SAVE_MOVIE_15FPS = 1,
36         CSP_MAINWIDGET_SAVE_MOVIE_24FPS,
37         CSP_MAINWIDGET_SAVE_MOVIE_30FPS,
38         CSP_MAINWIDGET_SAVE_MOVIE_60FPS,
39         CSP_MAINWIDGET_SAVE_MOVIE_END,
40 };
41
42 #define MAX_RENDER_PLATFORMS 12
43
44 enum {
45         RENDER_PLATFORMS_OPENGL3_MAIN = 0,
46         RENDER_PLATFORMS_OPENGL2_MAIN,
47         RENDER_PLATFORMS_OPENGL_CORE,
48         RENDER_PLATFORMS_OPENGL_ES_2,
49         RENDER_PLATFORMS_OPENGL_ES_31,
50         RENDER_PLATFORMS_END
51 };
52
53 QT_BEGIN_NAMESPACE
54
55 namespace CSP_Ui_MainWidgets {
56         struct DipSwitchPair { // config.dipswitch
57                 uint32_t data; // DipSwitch data
58                 uint32_t mask; // DipSwitch bit mask 
59         };
60         struct MachineFeaturePair { // config.machine_features[devnum]
61                 int devnum; // Index of device.
62                 uint32_t value; // Feature value.
63         };
64         struct ScreenMultiplyPair { // config.machine_features[devnum]
65                 int index; // Index of device.
66                 double value; // Feature value.
67         };
68         struct ScreenSize { // config.machine_features[devnum]
69                 int index; // Index of device.
70                 int width; //
71                 int height; //
72         };
73 }
74
75 Q_DECLARE_METATYPE(CSP_Ui_MainWidgets::DipSwitchPair)
76 Q_DECLARE_METATYPE(CSP_Ui_MainWidgets::MachineFeaturePair)
77 Q_DECLARE_METATYPE(CSP_Ui_MainWidgets::ScreenMultiplyPair)
78 Q_DECLARE_METATYPE(CSP_Ui_MainWidgets::ScreenSize)
79
80 #define SET_ACTION_SINGLE(__action,__checkable,__enabled,__cfgif) { \
81                 __action = new Action_Control(this, using_flags);                 \
82                 __action->setCheckable(__checkable);                                      \
83                 __action->setEnabled(__enabled);                                                  \
84                 __action->setChecked(__cfgif);                                                    \
85         }
86
87 #define SET_ACTION_SINGLE_CONNECT(__action,__checkable,__enabled,__cfgif,__signal1,__slot1) { \
88                 SET_ACTION_SINGLE(__action,__checkable,__enabled,__cfgif);              \
89                 connect(__action, __signal1, this, __slot1);                                    \
90         }
91
92 #define SET_ACTION_NUMERIC(__action,__num,__condval) {                                  \
93                 SET_ACTION_SINGLE(__action, true, true, (__condval == __num));  \
94                 __action->setData(QVariant((int)__num));                                                \
95         }
96
97 #define SET_ACTION_NUMERIC_CONNECT(__action,__num,__condval,__signal1,__slot1) { \
98                 SET_ACTION_NUMERIC(__action, __num, __condval);                                 \
99                 connect(__action, __signal1, this, __slot1);                                    \
100         }
101
102
103 #define SET_ACTION_DIPSWITCH(__action,__dipsw_val,__dipsw_mask,__condval) {     \
104                 SET_ACTION_SINGLE(__action, true, true, ((__dipsw_val & __dipsw_mask) == (__condval & __dipsw_mask))); \
105                 struct CSP_Ui_MainWidgets::DipSwitchPair __x__vars;                             \
106                 __x__vars.data = __dipsw_val;                                                                   \
107                 __x__vars.mask = __dipsw_mask;                                                                  \
108                 QVariant __v__vars;                                                                                             \
109                 __v__vars.setValue(__x__vars);                                                                  \
110                 __action->setData(__v__vars);                                                                   \
111         }
112
113
114 #define SET_ACTION_DIPSWITCH_CONNECT(__action,__dipsw_val,__dipsw_mask,__condval,__signal1,__slot1) { \
115                 SET_ACTION_DIPSWITCH(__action,__dipsw_val,__dipsw_mask,__condval); \
116                 connect(__action, __signal1, this, __slot1);                                    \
117         }
118
119 #define SET_ACTION_SINGLE_DIPSWITCH(__action,__dipsw_val_mask,__condval) { \
120                 uint32_t __d_mask = __dipsw_val_mask;                                                   \
121                 uint32_t __d_data = __dipsw_val_mask;                                                   \
122                 SET_ACTION_DIPSWITCH(__action,__d_data,__d_mask,__condval);             \
123         }
124
125 #define SET_ACTION_SINGLE_DIPSWITCH_CONNECT(__action,__dipsw_val_mask,__condval,__signal1,__slot1) { \
126                 uint32_t __d_data = __dipsw_val_mask;                                                   \
127                 uint32_t __d_mask = __dipsw_val_mask;                                                   \
128                 SET_ACTION_DIPSWITCH_CONNECT(__action,__d_data,__d_mask,__condval,__signal1,__slot1); \
129         }
130
131 #define SET_ACTION_SINGLE_DIPSWITCH_NEGATIVE(__action,__dipsw_val_mask,__condval) {     \
132                 SET_ACTION_SINGLE(__action, true, true, ((__condval & __dipsw_val_mask) == 0)); \
133                 struct CSP_Ui_MainWidgets::DipSwitchPair __x__vars;                             \
134                 __x__vars.data = __dipsw_val_mask;                                                              \
135                 __x__vars.mask = __dipsw_val_mask;                                                              \
136                 QVariant __v__vars;                                                                                             \
137                 __v__vars.setValue(__x__vars);                                                                  \
138                 __action->setData(__v__vars);                                                                   \
139         }
140 #define SET_ACTION_SINGLE_DIPSWITCH_CONNECT_NEGATIVE(__action,__dipsw_val_mask,__condval,__signal1,__slot1) { \
141                 SET_ACTION_SINGLE_DIPSWITCH_NEGATIVE(__action,__dipsw_val_mask,__condval); \
142                 connect(__action, __signal1, this, __slot1);                                    \
143         }
144         
145 #define SET_ACTION_ANYVALUES(__action,__vars) {                                                 \
146                 __action = new Action_Control(this, using_flags);                               \
147                 __action->setCheckable(true);                                                                   \
148                 __action->setEnabled(true);                                                                             \
149                 __action->setData(QVariant(__vars));                                                    \
150                 __action->setChecked(false);                                                                    \
151         }
152
153 #define SET_ACTION_MACHINE_FEATURE(__action,__devnum,__value,__condval) { \
154                 SET_ACTION_SINGLE(__action, true, true, __condval);                             \
155                 struct CSP_Ui_MainWidgets::MachineFeaturePair __x__vars;                \
156                 __x__vars.devnum = __devnum;                                                                    \
157                 __x__vars.value  = __value;                                                                             \
158                 QVariant __v__vars;                                                                                             \
159                 __v__vars.setValue(__x__vars);                                                                  \
160                 __action->setData(__v__vars);                                                                   \
161         }
162
163 #define SET_ACTION_MACHINE_FEATURE_CONNECT(__action,__devnum,__value,__condval,__signal1,__slot1) { \
164                 SET_ACTION_SINGLE_CONNECT(__action, true, true, __condval, __signal1, __slot1); \
165                 struct CSP_Ui_MainWidgets::MachineFeaturePair __x__vars;                \
166                 __x__vars.devnum = __devnum;                                                                    \
167                 __x__vars.value  = __value;                                                                             \
168                 QVariant __v__vars;                                                                                             \
169                 __v__vars.setValue(__x__vars);                                                                  \
170                 __action->setData(__v__vars);                                                                   \
171         }
172
173 #define SET_ACTION_ANYVALUES_CONNECT(__action,__vars,__signal1,__slot1) { \
174                 SET_ACTION_ANYVALUES(__action,__vars);                                                  \
175                 connect(__action, __signal1, this, __slot1);                                    \
176         }
177
178 #define SET_ACTION_CHECKABLE_SINGLE_CONNECT(__menu,__action,__objname,__cond,__signal1,__slot1) { \
179                 SET_ACTION_SINGLE_CONNECT(__action, true, true, __cond, __signal1, __slot1); \
180                 __action->setObjectName(QString::fromUtf8(__objname));                  \
181                 __menu->addAction(__action);                                                                    \
182         }
183
184 #define SET_ACTION_CHECKABLE_SINGLE_CONNECT_NOMENU(__action,__objname,__cond,__signal1,__slot1) { \
185                 SET_ACTION_SINGLE_CONNECT(__action, true, true, __cond, __signal1, __slot1); \
186                 __action->setObjectName(QString::fromUtf8(__objname));                  \
187         }
188
189 #define SET_ACTION_SCREEN_MULTIPLY(__action,__index,__value,__condval) { \
190                 SET_ACTION_SINGLE(__action, true, true, __condval);                             \
191                 struct CSP_Ui_MainWidgets::ScreenMultiplyPair __x__vars;                \
192                 __x__vars.index = __index;                                                                              \
193                 __x__vars.value  = __value;                                                                             \
194                 QVariant __v__vars;                                                                                             \
195                 __v__vars.setValue(__x__vars);                                                                  \
196                 __action->setData(__v__vars);                                                                   \
197         }
198
199 #define SET_ACTION_SCREEN_MULTIPLY_CONNECT(__action,__index,__value,__condval,__signal1,__slot1) { \
200                 SET_ACTION_SCREEN_MULTIPLY(__action,__index,__value,__condval); \
201                 connect(__action,__signal1, this, __slot1);                                             \
202         }
203
204 #define SET_ACTION_SCREEN_SIZE(__action,__index,__width,__height,__condval) {   \
205                 SET_ACTION_SINGLE(__action, true, true, __condval);                             \
206                 struct CSP_Ui_MainWidgets::ScreenSize __x__vars;                                \
207                 __x__vars.index  = __index;                                                                             \
208                 __x__vars.width  = __width;                                                                             \
209                 __x__vars.height = __height;                                                                    \
210                 QVariant __v__vars;                                                                                             \
211                 __v__vars.setValue(__x__vars);                                                                  \
212                 __action->setData(__v__vars);                                                                   \
213         }
214
215 #define SET_ACTION_SCREEN_SIZE_CONNECT(__action,__index,__width,__height,__condval,__signal1,__slot1) { \
216                 SET_ACTION_SCREEN_SIZE(__action,__index,__width,__height,__condval); \
217                 connect(__action, __signal1, this, __slot1);                                    \
218         }
219
220 #define SET_HELP_MENUENTRY(__menu,__action,__objname,__txtname) {               \
221                 __action = new Action_Control(this, using_flags);                               \
222                 __action->setObjectName(QString::fromUtf8(__objname));                  \
223                 __action->setData(QVariant(QString::fromUtf8(__txtname)));              \
224                 connect(__action, SIGNAL(triggered()), this, SLOT(do_browse_document())); \
225                 __menu->addAction(__action);                                                                    \
226         }
227         
228
229 #define SET_ACTION_CONTROL_ARRAY(__start,__end,                                                 \
230                                                                  __parent,__using_flags,                                \
231                                                                  __menu,__action,                                               \
232                                                                  __checkable,__enabled,__cnf,                   \
233                                                                  __signal1,__slot1                                              \
234         )                                                                                                                                       \
235         {                                                                                                                                       \
236                 for(int _i = __start; _i < __end;  _i++) {                                              \
237                         __action[_i] = new Action_Control(__parent, __using_flags);     \
238                         __action[_i]->setCheckable(__checkable);                                        \
239                         __action[_i]->setEnabled(__enabled);                                            \
240                         __action[_i]->setData(QVariant(_i));                                            \
241                         __menu->addAction(__action[_i]);                                                        \
242                         __action[_i]->setChecked(p_config->__cnf[_i][0]);                       \
243                         /*connect(__action[_i], __signal1, __action[_i], __slot1);*/ \
244                         connect(__action[_i], __signal1, this, __slot1);                        \
245                 }                                                                                                                               \
246         }
247
248 class OSD;
249 class QActionGroup;
250 class QButtonGroup;
251 class QGraphicsView;
252 class QGraphicsScene;
253 class QHeaderView;
254 class QMenu;
255 class QMenuBar;
256 class QApplication;
257
258 class QStatusBar;
259 class QWidget;
260 class QLabel;
261 class QGraphicsEllipseItem;
262 class QClipboard;
263 class QDockWidget;
264 class QHBoxLayout;
265 class QVBoxLayout;
266 class QGridLayout;
267 class Ui_SoundDialog;
268 class GLDrawClass;
269 class Action_Control;
270 class Menu_MetaClass;
271 class Menu_FDClass;
272 class Menu_CMTClass;
273 class Menu_CartClass;
274 class Menu_HDDClass;
275 class Menu_QDClass;
276 class Menu_BinaryClass;
277 class Menu_BubbleClass;
278 class Menu_CompactDiscClass;
279 class Menu_LaserdiscClass;
280 class CSP_DockDisks;
281 class MOVIE_SAVER;
282 class EmuThreadClassBase;
283 class EmuThreadClass;
284 class DLL_PREFIX Ui_MainWindowBase : public QMainWindow
285 {
286         Q_OBJECT
287 private:
288         QIcon WindowIcon;
289         QIcon InsertIcon;
290         QIcon EjectIcon;
291         QIcon StopIcon;
292         QIcon RecordSoundIcon;
293         QIcon ResetIcon;
294         QIcon ExitIcon;
295         QIcon VolumeMutedIcon;
296         QIcon VolumeLowIcon;
297         QIcon VolumeMidIcon;
298         QIcon VolumeHighIcon;
299
300         // File
301         QActionGroup *actionGroup_CpuSpeed;
302         Action_Control *actionSpeed_x1;
303         Action_Control *actionSpeed_x2;
304         Action_Control *actionSpeed_x4;
305         Action_Control *actionSpeed_x8;
306         Action_Control *actionSpeed_x16;
307         Action_Control *actionSpeed_FULL;
308         Action_Control *actionPaste_from_Clipboard;
309         Action_Control *actionStop_Pasting;
310         QMenu *menuSave_State;
311         QMenu *menuLoad_State;
312
313         // Screen
314         QActionGroup *actionGroup_Stretch;
315         QActionGroup *actionGroup_SetRenderPlatform;
316         QActionGroup *actionGroup_RotateType;
317         Action_Control *action_ScreenSeparateThread;
318         Action_Control *action_ScreenUseOSD;
319         Action_Control *actionZoom;
320         Action_Control *actionDisplay_Mode;
321         Action_Control *actionScanLine;
322         Action_Control *actionGLScanLineHoriz;
323         Action_Control *actionGLScanLineVert;
324         
325         Action_Control *actionRotate[4];
326         Action_Control *actionCRT_Filter;
327         Action_Control *actionOpenGL_Filter;
328         Action_Control *actionDot_by_Dot;
329         Action_Control *actionReferToX_Display;
330         Action_Control *actionReferToY_Display;
331         Action_Control *actionFill_Display;
332         QActionGroup *actionGroup_ScreenSize;
333         QActionGroup *actionGroup_RenderMode;
334
335         // Sound
336         QActionGroup   *actionGroup_Sound_Freq;
337         QActionGroup   *actionGroup_Sound_Latency;
338         QActionGroup   *actionGroup_Sound_HostDevices;
339         //Action_Control *actionSoundCMT;
340         Action_Control *action_VolumeDialog;
341         Action_Control *actionSoundTapeSignal;
342         Action_Control *actionSoundTapeVoice;
343         Action_Control *actionSoundStrictRendering;
344         Action_Control *action_SoundFilesFDD;
345         Action_Control *action_SoundFilesRelay;
346         QVector<Action_Control *> action_HostSoundDevice;
347         //QMenu *menuLogToConsole;
348         //QMenu *menuLogToSyslog;
349         QMenu *menuDevLogToConsole;
350         QMenu *menuDevLogToSyslog;
351         QMenu *menu_SetRenderPlatform;
352
353         // Misc
354         QMenu *menu_DispVirtualMedias;
355         QActionGroup *actionGroup_DispVirtualMedias;
356         Action_Control *action_DispVirtualMedias[5];
357         Action_Control *action_FocusWithClick;
358         Action_Control *action_UseRomaKana;
359         Action_Control *action_NumPadEnterAsFullkey;
360         Action_Control *action_UseJoykey;
361         Action_Control *action_Logging_FDC;
362         Action_Control *action_LogToSyslog;
363         Action_Control *action_LogToConsole;
364         Action_Control *action_LogRecord;
365         Action_Control *action_DevLogToSyslog[CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1];
366         Action_Control *action_DevLogToConsole[CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1];
367         Action_Control *action_DevLogRecord[CSP_LOG_TYPE_VM_DEVICE_END - CSP_LOG_TYPE_VM_DEVICE_0 + 1];
368         // Emulator
369         Action_Control *action_SetupMouse;
370         Action_Control *action_SetupJoystick;
371         Action_Control *action_SetupJoykey;
372         Action_Control *action_SetupKeyboard;
373         Action_Control *action_LogView;
374         Action_Control *action_PrintCpuStatistics;
375
376         QMenu *menu_EmulateCursorAs;
377         QActionGroup *actionGroup_EmulateCursorAs;
378         Action_Control *action_EmulateCursorAs[4];
379
380         // Help
381         Action_Control *actionHelp_README_BIOS;
382         Action_Control *actionHelp_README;
383         Action_Control *actionHelp_README_QT;
384         Action_Control *actionHelp_README_MR_TANAM;
385         Action_Control *actionHelp_README_MR_GORRY;
386         Action_Control *actionHelp_README_MR_MEISTER;
387         Action_Control *actionHelp_README_Artane;
388         Action_Control *actionHelp_README_Umaiboux;
389         Action_Control *actionHelp_README_FAQ;
390         Action_Control *actionHelp_README_FAQ_JP;
391         Action_Control *actionHelp_README_FM7;
392         Action_Control *actionHelp_README_FM7_JP;
393         Action_Control *actionHelp_History;
394         Action_Control *actionHelp_History_Relnote;
395         Action_Control *actionHelp_History_ChangeLog;
396         Action_Control *actionHelp_History_MR_TANAM;
397         Action_Control *actionHelp_License;
398         Action_Control *actionHelp_License_JP;
399         
400         // Led: OSD.
401         bool flags_led[32];
402         bool flags_led_bak[32];
403         QGraphicsView *led_graphicsView;
404         QGraphicsScene *led_gScene;
405         QGraphicsEllipseItem *led_leds[32];
406         uint32_t osd_led_data;
407
408         // Inner functions
409         
410         void ConfigCpuSpeed(void);
411         void ConfigControlMenu(void);
412         void connectActions_ControlMenu(void);
413         void ConfigFloppyMenu(void);
414         void ConfigHardDiskMenu(void);
415         void ConfigSoundMenu(void);
416         void CreateSoundMenu(void);
417
418         void CreateEmulatorMenu(void);
419         void ConfigEmulatorMenu(void);
420         
421         void CreateFloppyMenu(int drv, int drv_base);
422         void CreateFloppyPulldownMenu(int drv);
423         void ConfigFloppyMenuSub(int drv);
424
425         void CreateHardDiskMenu(int drv, int drv_base);
426         void CreateHardDiskPulldownMenu(int drv);
427         void ConfigHardDiskMenuSub(int drv);
428 // Bubble
429         void CreateBubbleMenu(int drv, int drv_base);
430         void CreateBubblePulldownMenu(int drv);
431         void ConfigBubbleMenuSub(int drv);
432         void ConfigBubbleMenu(void);
433         virtual int GetBubbleBankNum(int drv) { return 0; }
434         virtual int GetBubbleCurrentBankNum(int drv) { return 0; }
435         virtual bool GetBubbleCasetteIsProtected(int drv) { return false; }
436         virtual QString GetBubbleB77FileName(int drv) { return QString::fromUtf8(""); }
437         virtual QString GetBubbleB77BubbleName(int drv, int num) { return QString::fromUtf8(""); }
438         
439         void CreateCMTMenu(int drive, int drv_base);
440         void ConfigCMTMenu(void);
441    
442         void ConfigQuickDiskMenu(void);
443         void ConfigQuickDiskMenuSub(int drv);
444         void CreateQuickDiskPulldownMenu(int drv);
445         void CreateQuickDiskMenu(int drv, int drv_base);
446
447         void CreateCartMenu(int drv, int drv_base);
448         void CreateCartPulldownMenu(int drv);
449         void ConfigCartMenuSub(int drv);
450         void ConfigCartMenu(void);
451
452         void CreateCDROMMenu(int drv, int drv_base);
453         void ConfigCDROMMenu(void);
454         void ConfigCDROMMenuSub(void);
455         void CreateCDROMPulldownMenu(void);
456         
457         void CreateLaserdiscMenu(int drv, int drv_base);
458         void ConfigLaserdiscMenu(void);
459         void ConfigLaserdiscMenuSub(void);
460         void CreateLaserdiscPulldownMenu(void);
461
462         void ConfigBinaryMenu(void);
463         void ConfigScreenMenu(void);
464         void ConfigScreenMenu_List(void);
465         void CreateScreenMenu(void);
466         void ConfigDeviceType(void);
467         void ConfigKeyboardType(void);
468         void ConfigJoystickType(void);
469         void ConfigMachineFeatures(void);
470         void ConfigMouseType(void);
471         void ConfigDriveType(void);
472         void ConfigSoundDeviceType(void);
473         void ConfigPrinterType(void);
474         void ConfigSerialType(void);
475         void ConfigMonitorType(void);
476
477         // About Status bar
478         int Calc_OSD_Wfactor(void);
479 protected:
480         std::shared_ptr<USING_FLAGS> using_flags;
481         config_t *p_config;
482         std::shared_ptr<CSP_Logger> csp_logger;
483
484         QMainWindow *MainWindow;
485         QApplication *CoreApplication;
486         QMap<uint32_t, QString>phys_key_name_map; // VK, NAME
487         
488         GLDrawClass *graphicsView;
489         CSP_DockDisks *driveData;
490         QWidget *pCentralWidget;
491         QVBoxLayout *pCentralLayout;
492         QStatusBar  *statusbar;
493         QMenuBar    *menubar;
494
495         QTimer *statusUpdateTimer;
496         QTimer *ledUpdateTimer;
497         
498         const float screen_multiply_table[16] = {
499                 0.5, 1.0, 1.5, 2.0,
500                 2.25, 2.5, 3.0, 3.5,
501                 4.0, 5.0, 6.0, 8.0,
502                 0.0, 0.0, 0.0, 0.0
503         };
504         const float screen_multiply_table_mini[16] = {
505                 0.5, 1.0, 1.5, 2.0,
506                 3.0, 4.0, 5.0, 6.0,
507                 7.5, 10.0, 12.0, 15.0,
508                 0.0, 0.0, 0.0, 0.0
509         };
510
511         int screen_mode_count;
512         // Virtual medias.
513         QStringList listCARTs[8];
514         QStringList listQDs[8];
515         QStringList listCMT[8];
516         bool cmt_write_protect[8];
517         QStringList listCDROM[8];
518         QStringList listLaserdisc[8];
519         QStringList listBINs[8];
520         QStringList listFDs[16];
521         QStringList listHDDs[16];
522         
523         QStringList listD88[16];
524         QStringList listBubbles[8];
525         QStringList listB77[8];
526
527         // Some Functions
528         QActionGroup *actionGroup_BootMode;
529         QActionGroup *actionGroup_CpuType;
530         Action_Control *actionReset;
531         Action_Control *actionSpecial_Reset[16];
532         Action_Control *actionExit_Emulator;
533         Action_Control *actionCpuType[8];
534         Action_Control *actionBootMode[8];
535         Action_Control *actionDebugger[_MAX_DEBUGGER];
536         Action_Control *actionSave_State[10];
537         Action_Control *actionLoad_State[10];
538         //Action_Control *actionClose_Debuggers;
539         Action_Control *actionScreenSize[32];
540         Action_Control *actionAbout;
541         Action_Control *actionMouseEnable;
542         Action_Control *actionHelp_AboutQt;
543         Action_Control *action_ResetFixedCpu;
544         Action_Control *action_SetFixedCpu[128];
545
546         Action_Control *action_RAMSize;
547         // Screen
548         Action_Control *actionCapture_Screen;
549         Action_Control *action_SetRenderMode[8];
550         // Sound
551         Action_Control *action_Freq[8];
552         Action_Control *action_Latency[6];
553         Action_Control *actionStart_Record;
554         Action_Control *actionStop_Record;
555
556         // Emulator
557         QActionGroup *actionGroup_DeviceType;
558         QActionGroup *actionGroup_KeyboardType;
559         QActionGroup *actionGroup_JoystickType;
560         QActionGroup *actionGroup_MouseType;
561         QActionGroup *actionGroup_DriveType;
562         QActionGroup *actionGroup_SoundDevice;
563         QActionGroup *actionGroup_PrintDevice;
564         QActionGroup *actionGroup_SerialDevice;
565         QActionGroup *actionGroup_SetFixedCpu;
566         QMenu *menuDeviceType;
567         QMenu *menuKeyboardType;
568         QMenu *menuJoystickType;
569         QMenu *menuMouseType;
570         QMenu *menuDriveType;
571         QMenu *menuSoundDevice;
572         QMenu *menuPrintDevice;
573         QMenu *menuSerialDevice;
574         QMenu *menu_SetFixedCpu;
575         
576         Action_Control *actionDeviceType[16];
577         Action_Control *actionKeyboardType[16];
578         Action_Control *actionJoystickType[16];
579         Action_Control *actionMouseType[8];
580         Action_Control *actionDriveType[8];
581         Action_Control *actionSoundDevice[32]; //
582         Action_Control *actionPrintDevice[16];
583         Action_Control *actionSerialDevice[16];
584         Action_Control *action_SetRenderPlatform[MAX_RENDER_PLATFORMS];
585
586         
587         Action_Control *actionStart_Record_Movie;
588         Action_Control *actionStop_Record_Movie;
589         Action_Control *action_SetupMovie; // 15, 24, 30, 60
590
591         QMenu *menuMonitorType;
592         QActionGroup *actionGroup_MonitorType;
593         Action_Control *actionMonitorType[16];
594         
595         // Menus    
596         QMenu *menuControl;
597         QMenu *menuState;
598         QMenu *menuCopy_Paste;
599         QMenu *menuCpu_Speed;
600         QMenu *menuDebugger;
601         QMenu *menuScreen;
602         QMenu *menuStretch_Mode;
603         QMenu *menuScreenSize;
604         QMenu *menuScreen_Render;
605         QMenu *menuScreen_Rotate;
606         
607         QMenu *menuCpuType;
608         QMenu *menuBootMode;
609         QMenu *menuSound;
610         QMenu *menuOutput_Frequency;
611         QMenu *menuSound_Latency;
612         QMenu *menuSound_HostDevices;
613         QMenu *menuMachine;
614         QMenu *menuRecord;
615         QMenu *menuRecord_sound;
616         QMenu *menuRecord_as_movie;
617         QMenu *menuEmulator;
618         QMenu *menuHELP;
619         QMenu *menuHelp_Readme;
620         QMenu *menuHelp_Histories;
621
622         QMenu *menuMachineFeatures[32];
623         
624         Menu_FDClass *menu_fds[16];
625         Menu_QDClass *menu_QDs[8];
626         Menu_CMTClass *menu_CMT[8];
627         Menu_HDDClass *menu_hdds[16];
628         Menu_CompactDiscClass *menu_CDROM[8];
629         Menu_LaserdiscClass *menu_Laserdisc[8];
630         Menu_CartClass *menu_Cart[8];
631         Menu_BinaryClass *menu_BINs[8];
632         Menu_BubbleClass *menu_bubbles[8];
633         // Status Bar
634         QWidget *dummyStatusArea1;
635         QLabel *messagesStatusBar;
636         QWidget *dummyStatusArea2;
637
638         QLabel *cdrom_StatusBar;
639         QString osd_str_cdrom;
640         
641         QLabel *laserdisc_StatusBar;
642         QString osd_str_laserdisc;
643         QLabel *bubble_StatusBar[8];
644         QString osd_str_bubble[8];
645         QImage *bitmapImage;
646         QClipboard *ClipBoard;
647         // Constructor
648         EmuThreadClassBase *hRunEmu;
649         class DrawThreadClass *hDrawEmu;
650         class JoyThreadClass *hRunJoy;
651         class MOVIE_SAVER *hSaveMovieThread;
652         
653         int max_vm_nodes;
654         bool ui_retranslate_completed;
655         bool about_to_close;
656
657         virtual float getScreenMultiply(int num)
658         {
659                 if(using_flags == nullptr) return 0.0f;
660                 if((num < 0) || (num > 15)) return 0.0f;
661                 if(using_flags->get_screen_width() > 320) {
662                         return screen_multiply_table[num];
663                 } else {
664                         return screen_multiply_table_mini[num];
665                 }
666         }
667         virtual void closeEvent(QCloseEvent *event);
668         // CPU Type
669         void ConfigCPUTypes(int num);
670         void ConfigCPUBootMode(int num);
671         // Translate UIs.
672         void retranslateControlMenu(const char *SpecialResetTitle,  bool WithSpecialReset);
673         void retranslateFloppyMenu(int drv, int basedrv);
674         void retranslateFloppyMenu(int drv, int basedrv, QString specName);
675         void retranslateHardDiskMenu(int drv, int basedrv);
676         void retranslateHardDiskMenu(int drv, int basedrv, QString specName);
677         void retranslateBubbleMenu(int drv, int basedrv);
678         void retranslateCMTMenu(int drive);
679         void retranslateQuickDiskMenu(int drv, int basedrv);
680
681         void retranslateCDROMMenu(void);
682         void retranslateLaserdiscMenu(void);
683         void retranslateScreenMenu(void);
684         void retranslateMachineMenu(void);
685         void retranslateBinaryMenu(int drv, int basedrv);
686         void retranslateSoundMenu(void);
687         QMenu  *createMenuNode(QMenuBar *parent, QString objname = QString::fromUtf8(""));
688         QMenu  *createMenuNode(QMenu *parent, QString objname = QString::fromUtf8(""));
689
690 public:
691         Ui_MainWindowBase(std::shared_ptr<USING_FLAGS> p, std::shared_ptr<CSP_Logger> logger, QWidget *parent = 0);
692         ~Ui_MainWindowBase();
693
694         // Initializer : using from InitContext.
695         void setCoreApplication(QApplication *p);
696         void createContextMenu(void);
697         void setupUi(void);
698         // Belows are able to re-implement.
699         virtual void retranslateUi(void);
700         virtual void retranslateUI_Help(void);
701         virtual void retranslateCartMenu(int drv, int basedrv);
702         virtual void retranslateVolumeLabels(Ui_SoundDialog *);
703         virtual void retranslateEmulatorMenu(void);
704         virtual void retranselateUi_Depended_OSD(void);
705         // About Status bar
706         virtual void initStatusBar(void);
707         // EmuThread
708         void StopEmuThread(void);
709         virtual void LaunchEmuThread(EmuThreadClassBase *m);
710         // JoyThread
711         virtual void StopJoyThread(void);
712         virtual void LaunchJoyThread(void);
713         // Screen
714         virtual void OnWindowMove(void);
715         virtual void OnWindowRedraw(void);
716
717         // GUI Utilities
718         virtual void setTextAndToolTip(QAction *p, QString text, QString tooltip);
719         virtual void setTextAndToolTip(QMenu *p, QString text, QString tooltip);
720
721         // Getting important widgets.
722         QMainWindow *getWindow(void) { return MainWindow; }
723         QMenuBar    *getMenuBar(void) { return menubar;}
724         GLDrawClass *getGraphicsView(void) { return graphicsView; }
725         QStatusBar *getStatusBar(void) { return statusbar;}
726         QImage *getBitmapImage(void) { return bitmapImage; }
727         
728         virtual void OnMainWindowClosed(void);
729         // Basic Action Definition
730         void OnCpuPower(int mode);
731         bool get_wave_shaper(int drive);
732         bool get_direct_load_mzt(int drive);
733         void set_logger(std::shared_ptr<CSP_Logger> logger) { csp_logger = logger; }
734         std::shared_ptr<CSP_Logger> get_logger() { return csp_logger; }
735
736         virtual QString get_system_version();
737         virtual QString get_build_date();
738         QString get_gui_version();
739         void set_screen_size(int w, int h);
740         void set_screen_aspect(int num);
741         void update_screen_size(int num);
742
743         // Basic slots
744 public slots:
745         void delete_emu_thread(void);
746         void doChangeMessage_EmuThread(QString str);
747         void do_emu_update_config(void);
748         virtual void delete_joy_thread(void);
749         virtual void do_set_window_title(QString s);
750         virtual void redraw_status_bar(void);
751         virtual void redraw_leds(void);
752         void do_recv_data_led(quint32 d);
753
754         void do_update_volume(int level);
755         void do_set_screen_aspect(void);
756         void do_set_screen_size(void);
757         void do_set_screen_rotate(void);
758         void OnReset(void);
759
760         virtual void do_set_mouse_enable(bool flag);
761         virtual void do_toggle_mouse(void);
762         void do_set_sound_device(void);
763         void do_emu_update_volume_balance(int num, int level);
764         void do_emu_update_volume_level(int num, int level);
765         void rise_log_viewer(void);
766         void rise_volume_dialog(void);
767         void rise_mouse_dialog(void);
768         void rise_joystick_dialog(void);
769         void rise_joykey_dialog(void);
770         void rise_keyboard_dialog(void);
771         virtual void rise_movie_dialog(void);
772         void do_set_state_saving_movie(bool state);
773         void set_osd_virtual_media(bool f);
774         
775         virtual void OnOpenDebugger(void);
776         virtual void OnCloseDebugger(void);
777         void doBeforeCloseMainWindow(void);     
778         void set_gl_crt_filter(bool);
779         void do_set_cpu_power(void)
780         {
781                 QAction *cp = qobject_cast<QAction*>(QObject::sender());
782                 if(cp == nullptr) return;
783                 int pw = cp->data().value<int>();
784                 
785                 OnCpuPower(pw);
786         }
787         virtual void on_actionExit_triggered();
788         void do_emu_full_speed(bool f);
789         void OnStartAutoKey(void);
790         void OnStopAutoKey(void);
791         void eject_cart(int);
792         void set_recent_cart(int, int);
793
794         int set_recent_cdrom(int drv, int num);
795         void do_eject_cdrom(int drv);
796         void do_open_cdrom(int drv, QString path);
797         void do_swap_cdaudio_byteorder(int drv, bool value);
798
799         int set_recent_laserdisc(int drv, int num); 
800         void do_eject_laserdisc(int drv); 
801         void do_open_laserdisc(int drv, QString path);
802
803         void CreateBinaryMenu(int drv, int drv_base);
804         void CreateBinaryPulldownMenu(int drv);
805         void ConfigBinaryMenuSub(int drv);
806         int set_recent_binary_load(void);
807         int set_recent_binary_save(void);
808         void _open_binary_load(int drive, const QString fname);
809         void _open_binary_save(int drive, const QString fname);
810
811         int set_recent_quick_disk(int drive, int num); 
812         int write_protect_Qd(int drv, bool flag);
813         void _open_quick_disk(int drv, const QString fname);
814         void eject_Qd(int drv);
815
816
817         void _open_cart(int drv, const QString fname);
818         void eject_cmt(int drv);
819         
820         void do_change_boot_mode();
821         void do_change_cpu_type();
822         
823         void do_write_protect_cmt(int drv, bool flag);
824         int  set_recent_cmt(int drv, int num);
825         void set_wave_shaper(int drive, bool f);
826         void set_direct_load_from_mzt(int drive, bool f);
827         void do_open_write_cmt(int drive, QString);
828         void do_open_read_cmt(int drive, QString path);
829
830         void do_push_play_tape(int drive);
831         void do_push_stop_tape(int drive);
832         void do_push_fast_forward_tape(int drive);
833         void do_push_rewind_tape(int drive);
834         void do_push_apss_forward_tape(int drive);
835         void do_push_apss_rewind_tape(int drive);
836         void set_cmt_sound(bool);
837
838         int write_protect_fd(int drv, bool flag);
839         void eject_fd(int drv);
840         void eject_hard_disk(int drv);
841         virtual void do_create_d88_media(int drv, quint8 media_type, QString name) { }
842         virtual void do_create_hard_disk(int drv, int sector_size, int sectors, int surfaces, int cylinders, QString name) { }
843         void do_update_d88_list(int drv, int bank);
844
845         // Bubble Casette
846         int write_protect_bubble(int drv, bool flag);
847
848         virtual int set_b77_slot(int drive, int num) { return 0; }
849         virtual void do_update_recent_bubble(int drv) { }
850         virtual int set_recent_bubble(int drv, int num) { return 0; }
851         virtual void _open_bubble(int drv, const QString fname) { }
852         virtual void eject_bubble(int drv) { }
853         
854         void _open_disk(int drv, const QString fname);
855         void do_update_recent_disk(int);
856         int set_d88_slot(int drive, int num);
857         int set_recent_disk(int, int);
858
859         void _open_hard_disk(int drv, const QString fname);
860         void do_update_recent_hard_disk(int);
861         int set_recent_hard_disk(int, int);
862
863         void start_record_sound(bool rec);
864         void do_set_freq(void);
865         void do_set_latency(void);
866         void do_set_sound_strict_rendering(bool f);
867         void do_set_sound_tape_signal(bool f);
868         void do_set_sound_tape_voice(bool f);
869         void do_set_host_sound_output_device(void);
870         void do_set_host_sound_name(int num, QString sname);    
871         void set_monitor_type(void);
872         void message_status_bar(QString);
873         void resize_statusbar(int w, int h);
874         virtual void do_release_emu_resources(void);
875         virtual void set_window_title();
876         void set_device_type(void);
877         void set_mouse_type(void);
878         void set_keyboard_type(void);
879         void set_joystick_type(void);
880         void set_drive_type();
881         void set_scan_line(bool);
882         void set_gl_scan_line_vert(bool);
883         void set_gl_scan_line_horiz(bool);
884         void set_printer_device();
885         void set_serial_device();
886         void do_show_about(void);
887         void do_browse_document(void);
888
889         void do_set_sound_files_fdd(bool f);
890         void do_set_sound_files_relay(bool f);
891         void do_set_conslog(bool);
892         void do_set_syslog(bool);
893         void do_update_device_node_name(int id, const _TCHAR *name);    
894         void do_set_dev_log_to_console(bool f);
895         void do_set_dev_log_to_syslog(bool f);
896         void do_set_roma_kana(bool f);
897         void do_set_numpad_enter_as_fullkey(bool f);
898         void do_set_render_mode_std(void);
899         void do_set_render_mode_tv(void);
900         void do_select_render_platform(void);
901         void do_set_window_focus_type(bool flag);
902
903         void do_set_visible_virtual_media_none();
904         void do_set_visible_virtual_media_upper();
905         void do_set_visible_virtual_media_lower();
906         void do_set_visible_virtual_media_left();
907         void do_set_visible_virtual_media_right();
908
909         void do_set_emulate_cursor_as(void);
910         void do_set_logging_fdc(bool onoff);    
911         void do_set_separate_thread_draw(bool f);
912         void do_set_print_cpu_statistics(bool flag);
913         // ToDo: GUI
914         void do_set_state_log_to_record(bool f);
915         void do_set_state_log_to_console(bool f);
916         void do_set_state_log_to_syslog(bool f);
917         void do_set_joy_to_key(bool flag);
918         void do_select_fixed_cpu(int num);
919         void do_add_keyname_table(uint32_t vk, QString name);
920         void do_clear_keyname_table();
921         void do_show_ram_size_dialog(void);
922         void do_block_task();
923         void do_unblock_task();
924
925         void do_set_machine_feature();
926
927         void do_set_single_dipswitch(bool f);
928         void do_set_single_dipswitch_negative(bool f);
929         void do_set_multi_dipswitch();
930         
931         void do_clear_sound_output_list();
932         void do_update_sound_output_list();
933         void do_append_sound_output_list(QString _name);
934
935         void do_start_emu_thread();
936         void do_start_draw_thread();
937 signals:
938         int message_changed(QString);
939         int quit_emu_thread();
940         int call_joy_thread(EMU_TEMPLATE *);
941         int quit_joy_thread();
942         int quit_draw_thread();
943         int quit_emulator_all();
944         int sig_quit_movie_thread();
945         int sig_stop_saving_movie(void);
946         int sig_start_saving_movie(void);
947         int on_boot_mode(int);
948         int on_cpu_type(int);
949         int on_open_debugger(int);
950         int on_insert_fd(int);
951         int on_eject_fd(int);
952         int sig_open_disk(int, QString);
953         
954         int closed(void);
955         int sig_notify_power_off(void);
956         int sig_quit_all(void);
957         int sig_vm_reset(void);
958         int sig_vm_specialreset(int);
959         int sig_resize_uibar(int, int);
960         int sig_resize_screen(int, int);
961         int sig_update_screen(void);
962         int sig_emu_update_config(void);
963         int sig_emu_start_rec_sound(void);
964         int sig_emu_stop_rec_sound(void);
965         int sig_emu_set_display_size(int, int, int, int);
966         int sig_emu_update_volume_level(int, int);
967         int sig_emu_update_volume_balance(int, int);
968         int sig_osd_sound_output_device(QString);
969         int sig_resize_osd(int);
970         int sig_screen_multiply(double);
971         int sig_update_master_volume(int);
972         
973         int sig_write_protect_disk(int drv, bool flag);
974         int sig_open_disk(int, QString, int);
975         int sig_close_disk(int);
976         int sig_open_hard_disk(int, QString);
977         int sig_close_hard_disk(int);
978         int sig_play_tape(int ,QString);
979         int sig_rec_tape(int, QString);
980         int sig_close_tape(int);
981         int sig_cmt_push_play(int);
982         int sig_cmt_push_stop(int);
983         int sig_cmt_push_fast_forward(int);
984         int sig_cmt_push_fast_rewind(int);
985         int sig_cmt_push_apss_forward(int);
986         int sig_cmt_push_apss_rewind(int);
987         int sig_write_protect_quickdisk(int drv, bool flag);
988         int sig_close_quickdisk(int drv);
989         int sig_open_quickdisk(int drv, QString path);
990         int sig_close_cart(int drv);
991         int sig_open_cart(int drv, QString path);
992         int sig_open_cdrom(int drv, QString path);
993         int sig_close_cdrom(int drv);
994         int sig_close_laserdisc(int drv);
995         int sig_open_laserdisc(int drv, QString path);
996         int sig_load_binary(int drv, QString path);
997         int sig_save_binary(int drv, QString path);
998         int sig_write_protect_bubble(int, bool);
999         int sig_open_bubble(int, QString , int);
1000         int sig_close_bubble(int);
1001         int sig_led_update(QRectF);
1002         int sig_start_auto_key(QString);
1003         int sig_stop_auto_key(void);
1004         int sig_set_display_osd(bool);
1005         int sig_display_osd_leds(int,bool);
1006         int sig_set_led_width(int);
1007         int sig_set_orientation_osd(int);
1008         int sig_set_roma_kana(bool);
1009         int quit_debugger_thread(void);
1010         int sig_quit_widgets(void);
1011         
1012         int sig_emu_thread_to_fixed_cpu(int);
1013         int sig_add_keyname_table(uint32_t, QString);
1014
1015         int sig_block_task();
1016         int sig_unblock_task();
1017         int sig_start_emu_thread(void);
1018         int sig_start_draw_thread(void);
1019         int sig_emu_launched(void);
1020         int sig_glv_set_fixed_size(int, int);
1021         
1022         int sig_set_device_node_log(int, int, int, bool);
1023         int sig_set_device_node_log(int, int, bool*, int, int);
1024         int sig_set_device_node_log(int, int, int*, int, int);
1025 };
1026
1027 QT_END_NAMESPACE
1028
1029 #endif