~lgb/x-emulators/dev

« back to all changes in this revision

Viewing changes to targets/c65/ui.c

  • Committer: GitHub
  • Author(s): LGB
  • Date: 2020-01-18 01:19:08 UTC
  • mfrom: (265.1.63)
  • Revision ID: git-v1:1dd7619788b3c1f5896dd056cc1af0d4ba0daa86
Merge pull request #83 from lgblgblgb/dev

Refresh master from dev ...

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Part of the Xemu project, please visit: https://github.com/lgblgblgb/xemu
 
2
   Copyright (C)2016-2019 LGB (Gábor Lénárt) <lgblgblgb@gmail.com>
 
3
 
 
4
This program is free software; you can redistribute it and/or modify
 
5
it under the terms of the GNU General Public License as published by
 
6
the Free Software Foundation; either version 2 of the License, or
 
7
(at your option) any later version.
 
8
 
 
9
This program is distributed in the hope that it will be useful,
 
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
GNU General Public License for more details.
 
13
 
 
14
You should have received a copy of the GNU General Public License
 
15
along with this program; if not, write to the Free Software
 
16
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
17
 
 
18
 
 
19
#include "xemu/emutools.h"
 
20
#include "ui.h"
 
21
#include "xemu/emutools_gui.h"
 
22
#include "xemu/emutools_files.h"
 
23
#include "xemu/d81access.h"
 
24
#include "commodore_65.h"
 
25
 
 
26
 
 
27
//#if defined(CONFIG_DROPFILE_CALLBACK) || defined(XEMU_GUI)
 
28
 
 
29
#if 0
 
30
static int attach_d81 ( const char *fn )
 
31
{
 
32
        if (fd_mounted) {
 
33
                if (mount_external_d81(fn, 0)) {
 
34
                        ERROR_WINDOW("Mount failed for some reason.");
 
35
                        return 1;
 
36
                } else {
 
37
                        DEBUGPRINT("UI: file seems to be mounted successfully as D81: %s" NL, fn);
 
38
                        return 0;
 
39
                }
 
40
        } else {
 
41
                ERROR_WINDOW("Cannot mount external D81, since Mega65 was not instructed to mount any FD access yet.");
 
42
                return 1;
 
43
        }
 
44
}
 
45
#endif
 
46
 
 
47
 
 
48
static int attach_d81 ( const char *fn )
 
49
{
 
50
        if (fn && *fn)
 
51
                return d81access_attach_fsobj(fn, D81ACCESS_IMG | D81ACCESS_PRG | D81ACCESS_DIR | D81ACCESS_AUTOCLOSE);
 
52
        return -1;
 
53
}
 
54
 
 
55
 
 
56
// end of #if defined(CONFIG_DROPFILE_CALLBACK) || defined(XEMU_GUI_C)
 
57
//#endif
 
58
 
 
59
 
 
60
#ifdef CONFIG_DROPFILE_CALLBACK
 
61
void emu_dropfile_callback ( const char *fn )
 
62
{
 
63
        DEBUGGUI("UI: drop event, file: %s" NL, fn);
 
64
        if (ARE_YOU_SURE("Shall I try to mount the dropped file as D81 for you?"))
 
65
                attach_d81(fn);
 
66
}
 
67
#endif
 
68
 
 
69
 
 
70
#if 1
 
71
static void ui_attach_d81_by_browsing ( void )
 
72
{
 
73
        char fnbuf[PATH_MAX + 1];
 
74
        static char dir[PATH_MAX + 1] = "";
 
75
        if (!xemugui_file_selector(
 
76
                XEMUGUI_FSEL_OPEN | XEMUGUI_FSEL_FLAG_STORE_DIR,
 
77
                "Select D81 to attach",
 
78
                dir,
 
79
                fnbuf,
 
80
                sizeof fnbuf
 
81
        ))
 
82
                attach_d81(fnbuf);
 
83
        else
 
84
                DEBUGPRINT("UI: file selection for D81 mount was cancalled." NL);
 
85
}
 
86
#endif
 
87
 
 
88
 
 
89
#if 0
 
90
static void ui_native_os_file_browser ( void )
 
91
{
 
92
        xemuexec_open_native_file_browser(sdl_pref_dir);
 
93
}
 
94
#endif
 
95
 
 
96
 
 
97
static const struct menu_st menu_display[] = {
 
98
        { "Fullscreen",    XEMUGUI_MENUID_CALLABLE, xemugui_cb_windowsize, (void*)0 },
 
99
        { "Window - 100%", XEMUGUI_MENUID_CALLABLE, xemugui_cb_windowsize, (void*)1 },
 
100
        { "Window - 200%", XEMUGUI_MENUID_CALLABLE, xemugui_cb_windowsize, (void*)2 },
 
101
        { NULL }
 
102
};
 
103
 
 
104
 
 
105
static const struct menu_st menu_main[] = {
 
106
        { "Display",                    XEMUGUI_MENUID_SUBMENU,         menu_display, NULL },
 
107
        { "Reset C65",                  XEMUGUI_MENUID_CALLABLE,        xemugui_cb_call_user_data, c65_reset },
 
108
        { "Attach D81",                 XEMUGUI_MENUID_CALLABLE,        xemugui_cb_call_user_data, ui_attach_d81_by_browsing },
 
109
//      { "Browse system folder",       XEMUGUI_MENUID_CALLABLE,        xemugui_cb_call_user_data, ui_native_os_file_browser },
 
110
#ifdef _WIN32
 
111
        { "System console", XEMUGUI_MENUID_CALLABLE | XEMUGUI_MENUFLAG_QUERYBACK, xemugui_cb_sysconsole, NULL },
 
112
#endif
 
113
        { "Quit", XEMUGUI_MENUID_CALLABLE, xemugui_cb_call_quit_if_sure, NULL },
 
114
        { NULL }
 
115
};
 
116
 
 
117
 
 
118
void ui_enter ( void )
 
119
{
 
120
        DEBUGGUI("UI: handler has been called." NL);
 
121
        if (xemugui_popup(menu_main)) {
 
122
                DEBUGPRINT("UI: oops, POPUP does not worked :(" NL);
 
123
        }
 
124
}