1 |
|
/* |
2 |
|
* main_x.h - Main program, Unix specific stuff |
3 |
|
* |
4 |
< |
* Frodo (C) 1994-1997,2002-2003 Christian Bauer |
4 |
> |
* Frodo Copyright (C) Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
20 |
|
|
21 |
|
#include "Version.h" |
22 |
|
|
23 |
+ |
#ifdef HAVE_GLADE |
24 |
+ |
#include <gnome.h> |
25 |
+ |
#endif |
26 |
+ |
|
27 |
+ |
// Qtopia Windowing System |
28 |
+ |
#ifdef QTOPIA |
29 |
+ |
extern "C" int main(int argc, char *argv[]); |
30 |
+ |
#include <SDL.h> |
31 |
+ |
#endif |
32 |
|
|
33 |
|
extern int init_graphics(void); |
34 |
|
|
35 |
|
|
36 |
|
// Global variables |
37 |
+ |
Frodo *TheApp = NULL; |
38 |
|
char Frodo::prefs_path[256] = ""; |
39 |
|
|
40 |
|
|
44 |
|
|
45 |
|
int main(int argc, char **argv) |
46 |
|
{ |
47 |
< |
Frodo *the_app; |
47 |
> |
#ifdef HAVE_GLADE |
48 |
> |
gnome_program_init(PACKAGE_NAME, PACKAGE_VERSION, LIBGNOMEUI_MODULE, argc, argv, |
49 |
> |
GNOME_PARAM_APP_DATADIR, DATADIR, NULL); |
50 |
> |
#endif |
51 |
|
|
52 |
|
timeval tv; |
53 |
|
gettimeofday(&tv, NULL); |
54 |
|
srand(tv.tv_usec); |
55 |
|
|
56 |
< |
printf("%s by Christian Bauer\n", VERSION_STRING); |
56 |
> |
#ifndef HAVE_GLADE |
57 |
> |
printf( |
58 |
> |
"%s Copyright (C) Christian Bauer\n" |
59 |
> |
"This is free software with ABSOLUTELY NO WARRANTY.\n" |
60 |
> |
, VERSION_STRING |
61 |
> |
); |
62 |
> |
#endif |
63 |
|
if (!init_graphics()) |
64 |
< |
return 0; |
64 |
> |
return 1; |
65 |
|
fflush(stdout); |
66 |
|
|
67 |
< |
the_app = new Frodo(); |
68 |
< |
the_app->ArgvReceived(argc, argv); |
69 |
< |
the_app->ReadyToRun(); |
70 |
< |
delete the_app; |
67 |
> |
TheApp = new Frodo(); |
68 |
> |
TheApp->ArgvReceived(argc, argv); |
69 |
> |
TheApp->ReadyToRun(); |
70 |
> |
delete TheApp; |
71 |
|
|
72 |
|
return 0; |
73 |
|
} |
98 |
|
* Arguments processed, run emulation |
99 |
|
*/ |
100 |
|
|
101 |
< |
void Frodo::ReadyToRun(void) |
101 |
> |
void Frodo::ReadyToRun() |
102 |
|
{ |
103 |
|
getcwd(AppDirPath, 256); |
104 |
|
|
113 |
|
} |
114 |
|
ThePrefs.Load(prefs_path); |
115 |
|
|
116 |
+ |
// Show preferences editor |
117 |
+ |
#ifdef HAVE_GLADE |
118 |
+ |
if (!ThePrefs.ShowEditor(true, prefs_path)) |
119 |
+ |
return; // "Quit" clicked |
120 |
+ |
#endif |
121 |
+ |
|
122 |
|
// Create and start C64 |
123 |
|
TheC64 = new C64; |
124 |
< |
if (load_rom_files()) |
125 |
< |
TheC64->Run(); |
124 |
> |
load_rom_files(); |
125 |
> |
TheC64->Run(); |
126 |
|
delete TheC64; |
127 |
|
} |
128 |
|
|
129 |
|
|
130 |
< |
Prefs *Frodo::reload_prefs(void) |
130 |
> |
/* |
131 |
> |
* Run preferences editor |
132 |
> |
*/ |
133 |
> |
|
134 |
> |
bool Frodo::RunPrefsEditor(void) |
135 |
> |
{ |
136 |
> |
Prefs *prefs = new Prefs(ThePrefs); |
137 |
> |
bool result = prefs->ShowEditor(false, prefs_path); |
138 |
> |
if (result) { |
139 |
> |
TheC64->NewPrefs(prefs); |
140 |
> |
ThePrefs = *prefs; |
141 |
> |
} |
142 |
> |
delete prefs; |
143 |
> |
return result; |
144 |
> |
} |
145 |
> |
|
146 |
> |
|
147 |
> |
/* |
148 |
> |
* Determine whether path name refers to a directory |
149 |
> |
*/ |
150 |
> |
|
151 |
> |
bool IsDirectory(const char *path) |
152 |
|
{ |
153 |
< |
static Prefs newprefs; |
154 |
< |
newprefs.Load(prefs_path); |
109 |
< |
return &newprefs; |
153 |
> |
struct stat st; |
154 |
> |
return stat(path, &st) == 0 && S_ISDIR(st.st_mode); |
155 |
|
} |