Lots of additions to GTK Version Menus, plus timezones handled, and bugfixes
parent
7a11c67284
commit
4fad18c849
|
@ -370,5 +370,8 @@ Code:
|
|||
* Unix: Integrated a current gnome macros package. (dramsey)
|
||||
* Removed many errors and compiler warnings (dramsey)
|
||||
* Label Galaxies option. (dramsey)
|
||||
* Unix: Added several menu options already present in the windows version to
|
||||
the Gtk version. (dramsey)
|
||||
* Unix Gtk : Added several menu options already present in the windows version.
|
||||
(dramsey)
|
||||
* Unix Gtk : Fixed problem where giving keyboard commands wasn't updating
|
||||
the toggle menu gadgets. (dramsey)
|
||||
* Unix : Handle timezones correctly. (dramsey)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
dosstuff = celestia.mak $(wildcard *.bat) Celestia.dsp
|
||||
noinst_DATA = $(wildcard *.txt) $(dosstuff)
|
||||
pkgdata_DATA = celestia.cfg $(wildcard *.cel)
|
||||
noinst_DATA = devguide.txt $(dosstuff)
|
||||
pkgdata_DATA = celestia.cfg $(wildcard *.cel) controls.txt COPYING
|
||||
|
||||
EXTRA_DIST = $(pkgdata_DATA) $(noinst_DATA)
|
||||
|
||||
|
|
|
@ -93,8 +93,8 @@ cflags_set = @cflags_set@
|
|||
cxxflags_set = @cxxflags_set@
|
||||
|
||||
dosstuff = celestia.mak $(wildcard *.bat) Celestia.dsp
|
||||
noinst_DATA = $(wildcard *.txt) $(dosstuff)
|
||||
pkgdata_DATA = celestia.cfg $(wildcard *.cel)
|
||||
noinst_DATA = devguide.txt $(dosstuff)
|
||||
pkgdata_DATA = celestia.cfg $(wildcard *.cel) controls.txt COPYING
|
||||
|
||||
EXTRA_DIST = $(pkgdata_DATA) $(noinst_DATA)
|
||||
|
||||
|
|
|
@ -6,3 +6,8 @@
|
|||
/* Are we debugging ? */
|
||||
#undef DEBUG
|
||||
|
||||
/* Log Domain for Gnome */
|
||||
#undef G_LOG_DOMAIN
|
||||
|
||||
/* Locale Directory for Gnome (Currently unused) */
|
||||
#undef GNOMELOCALEDIR
|
||||
|
|
|
@ -7,6 +7,11 @@
|
|||
/* Are we debugging ? */
|
||||
#undef DEBUG
|
||||
|
||||
/* Log Domain for Gnome */
|
||||
#undef G_LOG_DOMAIN
|
||||
|
||||
/* Locale Directory for Gnome (Currently unused) */
|
||||
#undef GNOMELOCALEDIR
|
||||
|
||||
/* Define if you have the <byteswap.h> header file. */
|
||||
#undef HAVE_BYTESWAP_H
|
||||
|
|
|
@ -6311,6 +6311,14 @@ cat >>confdefs.h <<EOF
|
|||
#define CONFIG_DATA_DIR "$PKGDATADIR"
|
||||
EOF
|
||||
|
||||
cat >>confdefs.h <<EOF
|
||||
#define G_LOG_DOMAIN "Celestia"
|
||||
EOF
|
||||
|
||||
cat >>confdefs.h <<EOF
|
||||
#define GNOMELOCALEDIR "$PKGDATADIR/locale"
|
||||
EOF
|
||||
|
||||
ac_config_files="$ac_config_files Makefile src/Makefile src/celutil/Makefile src/celmath/Makefile src/cel3ds/Makefile src/celtxf/Makefile src/celengine/Makefile src/celestia/Makefile data/Makefile textures/Makefile models/Makefile shaders/Makefile fonts/Makefile src/celestia/res/Makefile macros/Makefile manual/Makefile"
|
||||
cat >confcache <<\_ACEOF
|
||||
# This file is a shell script that caches the results of configure
|
||||
|
@ -6391,7 +6399,7 @@ DEFS=-DHAVE_CONFIG_H
|
|||
: ${CONFIG_STATUS=./config.status}
|
||||
ac_clean_files_save=$ac_clean_files
|
||||
ac_clean_files="$ac_clean_files $CONFIG_STATUS"
|
||||
{ echo "$as_me:6394: creating $CONFIG_STATUS" >&5
|
||||
{ echo "$as_me:6402: creating $CONFIG_STATUS" >&5
|
||||
echo "$as_me: creating $CONFIG_STATUS" >&6;}
|
||||
cat >$CONFIG_STATUS <<_ACEOF
|
||||
#! $SHELL
|
||||
|
@ -6567,7 +6575,7 @@ cat >>$CONFIG_STATUS <<\EOF
|
|||
echo "$ac_cs_version"; exit 0 ;;
|
||||
--he | --h)
|
||||
# Conflict between --help and --header
|
||||
{ { echo "$as_me:6570: error: ambiguous option: $1
|
||||
{ { echo "$as_me:6578: error: ambiguous option: $1
|
||||
Try \`$0 --help' for more information." >&5
|
||||
echo "$as_me: error: ambiguous option: $1
|
||||
Try \`$0 --help' for more information." >&2;}
|
||||
|
@ -6586,7 +6594,7 @@ Try \`$0 --help' for more information." >&2;}
|
|||
ac_need_defaults=false;;
|
||||
|
||||
# This is an error.
|
||||
-*) { { echo "$as_me:6589: error: unrecognized option: $1
|
||||
-*) { { echo "$as_me:6597: error: unrecognized option: $1
|
||||
Try \`$0 --help' for more information." >&5
|
||||
echo "$as_me: error: unrecognized option: $1
|
||||
Try \`$0 --help' for more information." >&2;}
|
||||
|
@ -6646,7 +6654,7 @@ do
|
|||
"manual/Makefile" ) CONFIG_FILES="$CONFIG_FILES manual/Makefile" ;;
|
||||
"default-1" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;;
|
||||
"config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
|
||||
*) { { echo "$as_me:6649: error: invalid argument: $ac_config_target" >&5
|
||||
*) { { echo "$as_me:6657: error: invalid argument: $ac_config_target" >&5
|
||||
echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
|
||||
{ (exit 1); exit 1; }; };;
|
||||
esac
|
||||
|
@ -6910,7 +6918,7 @@ done; }
|
|||
esac
|
||||
|
||||
if test x"$ac_file" != x-; then
|
||||
{ echo "$as_me:6913: creating $ac_file" >&5
|
||||
{ echo "$as_me:6921: creating $ac_file" >&5
|
||||
echo "$as_me: creating $ac_file" >&6;}
|
||||
rm -f "$ac_file"
|
||||
fi
|
||||
|
@ -6928,7 +6936,7 @@ echo "$as_me: creating $ac_file" >&6;}
|
|||
-) echo $tmp/stdin ;;
|
||||
[\\/$]*)
|
||||
# Absolute (can't be DOS-style, as IFS=:)
|
||||
test -f "$f" || { { echo "$as_me:6931: error: cannot find input file: $f" >&5
|
||||
test -f "$f" || { { echo "$as_me:6939: error: cannot find input file: $f" >&5
|
||||
echo "$as_me: error: cannot find input file: $f" >&2;}
|
||||
{ (exit 1); exit 1; }; }
|
||||
echo $f;;
|
||||
|
@ -6941,7 +6949,7 @@ echo "$as_me: error: cannot find input file: $f" >&2;}
|
|||
echo $srcdir/$f
|
||||
else
|
||||
# /dev/null tree
|
||||
{ { echo "$as_me:6944: error: cannot find input file: $f" >&5
|
||||
{ { echo "$as_me:6952: error: cannot find input file: $f" >&5
|
||||
echo "$as_me: error: cannot find input file: $f" >&2;}
|
||||
{ (exit 1); exit 1; }; }
|
||||
fi;;
|
||||
|
@ -7002,7 +7010,7 @@ for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
|
|||
* ) ac_file_in=$ac_file.in ;;
|
||||
esac
|
||||
|
||||
test x"$ac_file" != x- && { echo "$as_me:7005: creating $ac_file" >&5
|
||||
test x"$ac_file" != x- && { echo "$as_me:7013: creating $ac_file" >&5
|
||||
echo "$as_me: creating $ac_file" >&6;}
|
||||
|
||||
# First look for the input files in the build tree, otherwise in the
|
||||
|
@ -7013,7 +7021,7 @@ echo "$as_me: creating $ac_file" >&6;}
|
|||
-) echo $tmp/stdin ;;
|
||||
[\\/$]*)
|
||||
# Absolute (can't be DOS-style, as IFS=:)
|
||||
test -f "$f" || { { echo "$as_me:7016: error: cannot find input file: $f" >&5
|
||||
test -f "$f" || { { echo "$as_me:7024: error: cannot find input file: $f" >&5
|
||||
echo "$as_me: error: cannot find input file: $f" >&2;}
|
||||
{ (exit 1); exit 1; }; }
|
||||
echo $f;;
|
||||
|
@ -7026,7 +7034,7 @@ echo "$as_me: error: cannot find input file: $f" >&2;}
|
|||
echo $srcdir/$f
|
||||
else
|
||||
# /dev/null tree
|
||||
{ { echo "$as_me:7029: error: cannot find input file: $f" >&5
|
||||
{ { echo "$as_me:7037: error: cannot find input file: $f" >&5
|
||||
echo "$as_me: error: cannot find input file: $f" >&2;}
|
||||
{ (exit 1); exit 1; }; }
|
||||
fi;;
|
||||
|
@ -7143,7 +7151,7 @@ cat >>$CONFIG_STATUS <<\EOF
|
|||
rm -f $tmp/in
|
||||
if test x"$ac_file" != x-; then
|
||||
if cmp -s $ac_file $tmp/config.h 2>/dev/null; then
|
||||
{ echo "$as_me:7146: $ac_file is unchanged" >&5
|
||||
{ echo "$as_me:7154: $ac_file is unchanged" >&5
|
||||
echo "$as_me: $ac_file is unchanged" >&6;}
|
||||
else
|
||||
ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
|
||||
|
@ -7224,19 +7232,19 @@ if test "$no_create" != yes; then
|
|||
$ac_cs_success || { (exit 1); exit 1; }
|
||||
fi
|
||||
|
||||
echo "$as_me:7227: result: " >&5
|
||||
echo "$as_me:7235: result: " >&5
|
||||
echo "${ECHO_T}" >&6
|
||||
echo "$as_me:7229: result: " >&5
|
||||
echo "$as_me:7237: result: " >&5
|
||||
echo "${ECHO_T}" >&6
|
||||
echo "$as_me:7231: result: ********************************************************************" >&5
|
||||
echo "$as_me:7239: result: ********************************************************************" >&5
|
||||
echo "${ECHO_T}********************************************************************" >&6
|
||||
echo "$as_me:7233: result: *** Celestia configuration complete. Now do a 'make' followed ***" >&5
|
||||
echo "$as_me:7241: result: *** Celestia configuration complete. Now do a 'make' followed ***" >&5
|
||||
echo "${ECHO_T}*** Celestia configuration complete. Now do a 'make' followed ***" >&6
|
||||
echo "$as_me:7235: result: *** by 'make install' ***" >&5
|
||||
echo "$as_me:7243: result: *** by 'make install' ***" >&5
|
||||
echo "${ECHO_T}*** by 'make install' ***" >&6
|
||||
echo "$as_me:7237: result: ********************************************************************" >&5
|
||||
echo "$as_me:7245: result: ********************************************************************" >&5
|
||||
echo "${ECHO_T}********************************************************************" >&6
|
||||
echo "$as_me:7239: result: " >&5
|
||||
echo "$as_me:7247: result: " >&5
|
||||
echo "${ECHO_T}" >&6
|
||||
echo "$as_me:7241: result: " >&5
|
||||
echo "$as_me:7249: result: " >&5
|
||||
echo "${ECHO_T}" >&6
|
||||
|
|
|
@ -192,6 +192,8 @@ if test "$prefix" = "NONE" ; then
|
|||
fi
|
||||
PKGDATADIR=`eval echo "${datadir}/$PACKAGE"`
|
||||
AC_DEFINE_UNQUOTED(CONFIG_DATA_DIR, "$PKGDATADIR")
|
||||
AC_DEFINE_UNQUOTED(G_LOG_DOMAIN,"Celestia")
|
||||
AC_DEFINE_UNQUOTED(GNOMELOCALEDIR,"$PKGDATADIR/locale")
|
||||
|
||||
AC_OUTPUT( Makefile \
|
||||
src/Makefile \
|
||||
|
|
|
@ -112,6 +112,7 @@ CelestiaCore::CelestiaCore() :
|
|||
runningScript(NULL),
|
||||
execEnv(NULL),
|
||||
timeZoneBias(0),
|
||||
timeZone(NULL),
|
||||
showFPSCounter(false),
|
||||
nFrames(0),
|
||||
fps(0.0),
|
||||
|
@ -1063,10 +1064,15 @@ void CelestiaCore::renderOverlay()
|
|||
// Time and date
|
||||
glPushMatrix();
|
||||
glColor4f(0.7f, 0.7f, 1.0f, 1.0f);
|
||||
glTranslatef(width - 11 * emWidth, height - fontHeight, 0);
|
||||
glTranslatef(width - (timeZone ? 11 + strlen(timeZone) : 11) * emWidth, height - fontHeight, 0);
|
||||
overlay->beginText();
|
||||
*overlay << astro::Date(sim->getTime() +
|
||||
astro::secondsToJulianDate(timeZoneBias)) << '\n';
|
||||
astro::secondsToJulianDate(timeZoneBias));
|
||||
if(timezone)
|
||||
{
|
||||
*overlay << " " << timeZone;
|
||||
}
|
||||
*overlay << '\n';
|
||||
if (paused)
|
||||
{
|
||||
glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
|
@ -1616,11 +1622,30 @@ int CelestiaCore::getTimeZoneBias() const
|
|||
}
|
||||
|
||||
|
||||
int CelestiaCore::getTextEnterMode() const
|
||||
{
|
||||
return textEnterMode;
|
||||
}
|
||||
|
||||
|
||||
void CelestiaCore::setTimeZoneBias(int bias)
|
||||
{
|
||||
timeZoneBias = bias;
|
||||
}
|
||||
|
||||
|
||||
char *CelestiaCore::getTimeZone() const
|
||||
{
|
||||
return timeZone;
|
||||
}
|
||||
|
||||
|
||||
void CelestiaCore::setTimeZone(char *zone)
|
||||
{
|
||||
timeZone = zone;
|
||||
}
|
||||
|
||||
|
||||
int CelestiaCore::getHudDetail()
|
||||
{
|
||||
return hudDetail;
|
||||
|
|
|
@ -128,6 +128,9 @@ class CelestiaCore
|
|||
|
||||
int getTimeZoneBias() const;
|
||||
void setTimeZoneBias(int);
|
||||
char *getTimeZone() const;
|
||||
void setTimeZone(char *);
|
||||
int getTextEnterMode() const;
|
||||
|
||||
void initMovieCapture(MovieCapture*);
|
||||
void recordBegin();
|
||||
|
@ -190,6 +193,7 @@ class CelestiaCore
|
|||
ExecutionEnvironment* execEnv;
|
||||
|
||||
int timeZoneBias; // diff in seconds between local time and GMT
|
||||
char *timeZone; // Name of the local TimeZone
|
||||
|
||||
// Frame rate counter variables
|
||||
bool showFPSCounter;
|
||||
|
|
|
@ -263,7 +263,11 @@ int main(int argc, char* argv[])
|
|||
appCore->initRenderer();
|
||||
|
||||
// Set the simulation starting time to the current system time
|
||||
appCore->start((double) time(NULL) / 86400.0 + (double) astro::Date(1970, 1, 1));
|
||||
time_t curtime=time(NULL);
|
||||
appCore->start((double) curtime / 86400.0 + (double) astro::Date(1970, 1, 1));
|
||||
localtime(&curtime); // Only doing this to set timezone as a side effect
|
||||
appCore->setTimeZoneBias(-timezone);
|
||||
appCore->setTimeZone(tzname[daylight?0:1]);
|
||||
|
||||
ready = true;
|
||||
glutMainLoop();
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <celengine/gl.h>
|
||||
#include <celengine/glext.h>
|
||||
#include <celengine/celestia.h>
|
||||
|
||||
#ifndef DEBUG
|
||||
|
@ -43,11 +44,24 @@
|
|||
char AppName[] = "Celestia";
|
||||
|
||||
static CelestiaCore* appCore = NULL;
|
||||
static Renderer* appRenderer = NULL;
|
||||
|
||||
// Mouse motion tracking
|
||||
static int lastX = 0;
|
||||
static int lastY = 0;
|
||||
|
||||
typedef struct _checkFunc CheckFunc;
|
||||
typedef int (*Callback)(int);
|
||||
|
||||
struct _checkFunc
|
||||
{
|
||||
GtkCheckMenuItem *widget;
|
||||
char *path;
|
||||
Callback func;
|
||||
int active;
|
||||
int funcdata;
|
||||
};
|
||||
|
||||
static GtkWidget* mainWindow = NULL;
|
||||
static GtkWidget* mainMenu = NULL;
|
||||
static GtkWidget* mainBox = NULL;
|
||||
|
@ -68,13 +82,13 @@ static GtkItemFactory* menuItemFactory = NULL;
|
|||
#if 0
|
||||
static void SetRenderFlag(int flag, bool state)
|
||||
{
|
||||
renderer->setRenderFlags((renderer->getRenderFlags() & ~flag) |
|
||||
appRenderer->setRenderFlags((appRenderer->getRenderFlags() & ~flag) |
|
||||
(state ? flag : 0));
|
||||
}
|
||||
|
||||
static void SetLabelFlag(int flag, bool state)
|
||||
{
|
||||
renderer->setLabelMode((renderer->getLabelMode() & ~flag) |
|
||||
appRenderer->setLabelMode((appRenderer->getLabelMode() & ~flag) |
|
||||
(state ? flag : 0));
|
||||
}
|
||||
#endif
|
||||
|
@ -96,6 +110,7 @@ enum
|
|||
Menu_ConstellationLabels = 2012,
|
||||
Menu_PixelShaders = 2013,
|
||||
Menu_VertexShaders = 2014,
|
||||
Menu_ShowLocTime = 2015,
|
||||
};
|
||||
|
||||
static void menuSelectSol()
|
||||
|
@ -225,6 +240,22 @@ static gint menuShowConstellations(GtkWidget* w, gpointer data)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static gint menuShowLocTime(GtkWidget* w, gpointer data)
|
||||
{
|
||||
bool on = (GTK_CHECK_MENU_ITEM(w)->active != FALSE);
|
||||
if(on)
|
||||
{
|
||||
appCore->setTimeZoneBias(-timezone);
|
||||
appCore->setTimeZone(tzname[daylight?0:1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
appCore->setTimeZoneBias(0);
|
||||
appCore->setTimeZone("UTC");
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gint menuStarLabels(GtkWidget* w, gpointer data)
|
||||
{
|
||||
// bool on = (GTK_CHECK_MENU_ITEM(w)->active == 1);
|
||||
|
@ -309,20 +340,33 @@ static void menuAbout()
|
|||
{
|
||||
const gchar* authors[] = {
|
||||
"Chris Laurel <claurel@shatters.net>",
|
||||
"Deon Ramsey <miavir@furry.de>",
|
||||
NULL
|
||||
};
|
||||
GtkWidget* about;
|
||||
about = gnome_about_new("Celestia",
|
||||
VERSION,
|
||||
"(c) 2001 Chris Laurel",
|
||||
authors,
|
||||
"3D Space Simulation",
|
||||
NULL);
|
||||
if (about == NULL)
|
||||
return;
|
||||
const gchar* logo = gnome_pixmap_file("gnome-hello-logo.png");
|
||||
static GtkWidget* about;
|
||||
if (about != NULL)
|
||||
{
|
||||
// Try to de-iconify and raise the dialog.
|
||||
|
||||
gtk_window_set_modal(GTK_WINDOW(about), TRUE);
|
||||
gtk_widget_show(about);
|
||||
gdk_window_show(about->window);
|
||||
gdk_window_raise(about->window);
|
||||
}
|
||||
else
|
||||
{
|
||||
about = gnome_about_new("Celestia",
|
||||
VERSION,
|
||||
"(c) 2001 Chris Laurel",
|
||||
authors,
|
||||
"3D Space Simulation",
|
||||
logo);
|
||||
if (about == NULL)
|
||||
return;
|
||||
|
||||
gtk_window_set_modal(GTK_WINDOW(about), TRUE);
|
||||
gnome_dialog_set_parent((GnomeDialog*) about, GTK_WINDOW(mainWindow));
|
||||
gtk_widget_show(about);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -426,6 +470,8 @@ static void menuSelectObject()
|
|||
|
||||
gnome_dialog_close_hides(GNOME_DIALOG(dialog), true);
|
||||
// gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
|
||||
gnome_dialog_set_parent((GnomeDialog*) dialog, GTK_WINDOW(mainWindow));
|
||||
gnome_dialog_set_default((GnomeDialog*) dialog, GNOME_YES);
|
||||
gint whichButton = gnome_dialog_run(GNOME_DIALOG(dialog));
|
||||
if (whichButton == 0)
|
||||
{
|
||||
|
@ -536,7 +582,7 @@ GotoObjectDialog::~GotoObjectDialog()
|
|||
bool GotoObjectDialog::init()
|
||||
{
|
||||
dialog = gnome_dialog_new("Goto Object",
|
||||
GNOME_STOCK_BUTTON_CANCEL,
|
||||
GNOME_STOCK_BUTTON_CANCEL,
|
||||
NULL);
|
||||
nameEntry = gtk_entry_new();
|
||||
latEntry = gtk_entry_new();
|
||||
|
@ -622,6 +668,8 @@ bool GotoObjectDialog::init()
|
|||
GTK_SIGNAL_FUNC(GotoObject),
|
||||
this);
|
||||
|
||||
gnome_dialog_set_parent((GnomeDialog*) dialog, GTK_WINDOW(mainWindow));
|
||||
gnome_dialog_set_default((GnomeDialog*) dialog, GNOME_NO);
|
||||
gnome_dialog_run_and_close(GNOME_DIALOG(dialog));
|
||||
|
||||
return true;
|
||||
|
@ -794,6 +842,8 @@ static void menuTourGuide()
|
|||
gtk_widget_show(gotoButton);
|
||||
// gtk_widget_set_usize(descLabel, 250, 150);
|
||||
|
||||
gnome_dialog_set_parent((GnomeDialog*) dialog, GTK_WINDOW(mainWindow));
|
||||
gnome_dialog_set_default((GnomeDialog*) dialog, GNOME_YES);
|
||||
gnome_dialog_run_and_close(GNOME_DIALOG(dialog));
|
||||
|
||||
// gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
|
||||
|
@ -801,6 +851,156 @@ static void menuTourGuide()
|
|||
}
|
||||
|
||||
|
||||
char *readFromFile(char *fname)
|
||||
{
|
||||
ifstream textFile(fname, ios::in);
|
||||
string s("");
|
||||
if(!textFile.is_open())
|
||||
{
|
||||
s="Unable to open file '";
|
||||
s+= fname ;
|
||||
s+= "', probably due to improper installation !\n";
|
||||
}
|
||||
char c;
|
||||
while(textFile.get(c))
|
||||
{
|
||||
if(c=='\t')
|
||||
s+=" "; // 8 spaces
|
||||
else if(c=='\014') // Ctrl+L (form feed)
|
||||
s+="\n\n\n\n";
|
||||
else
|
||||
s+=c;
|
||||
}
|
||||
return g_strdup(s.c_str());
|
||||
}
|
||||
|
||||
|
||||
static void textInfoDialog(GtkWidget** dialog, const char *txt, const char *title)
|
||||
{
|
||||
/* I would use a gnome_message_box dialog for this, except they don't seem
|
||||
to notice that the texts are so big that they create huge windows, and
|
||||
would work better with a scrolled window. Deon */
|
||||
if (*dialog != NULL)
|
||||
{
|
||||
// Try to de-iconify and raise the dialog.
|
||||
gdk_window_show((*dialog)->window);
|
||||
gdk_window_raise((*dialog)->window);
|
||||
gnome_dialog_run_and_close(GNOME_DIALOG(*dialog));
|
||||
}
|
||||
else
|
||||
{
|
||||
*dialog = gnome_dialog_new(title,
|
||||
GNOME_STOCK_BUTTON_OK,
|
||||
NULL);
|
||||
if (*dialog == NULL)
|
||||
{
|
||||
DPRINTF("Unable to open '%s' dialog!\n",title);
|
||||
return;
|
||||
}
|
||||
|
||||
GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
||||
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (*dialog)->vbox), scrolled_window, TRUE, TRUE, 0);
|
||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
||||
GTK_POLICY_AUTOMATIC,
|
||||
GTK_POLICY_AUTOMATIC);
|
||||
gtk_widget_show (scrolled_window);
|
||||
|
||||
GtkWidget *text = gtk_text_new (NULL, NULL);
|
||||
gtk_text_set_editable (GTK_TEXT (text), FALSE);
|
||||
gtk_text_set_word_wrap (GTK_TEXT (text), FALSE);
|
||||
gtk_text_set_line_wrap (GTK_TEXT (text), FALSE);
|
||||
gtk_container_add (GTK_CONTAINER (scrolled_window), text);
|
||||
|
||||
gtk_text_insert (GTK_TEXT (text), NULL, NULL, NULL, txt, -1);
|
||||
|
||||
gtk_widget_show (text);
|
||||
|
||||
gtk_widget_set_usize(*dialog, 500, 400);
|
||||
|
||||
gnome_dialog_set_parent((GnomeDialog*) *dialog, GTK_WINDOW(mainWindow));
|
||||
gnome_dialog_set_default((GnomeDialog*) *dialog, GNOME_YES);
|
||||
gnome_dialog_close_hides((GnomeDialog*) *dialog, TRUE);
|
||||
gtk_window_set_modal(GTK_WINDOW(*dialog), FALSE);
|
||||
gnome_dialog_run_and_close(GNOME_DIALOG(*dialog));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static GtkWidget* controldialog=NULL;
|
||||
|
||||
static void menuControls()
|
||||
{
|
||||
char *txt=readFromFile("controls.txt");
|
||||
textInfoDialog(&controldialog,txt,"Mouse and Keyboard Controls");
|
||||
g_free(txt);
|
||||
}
|
||||
|
||||
|
||||
static GtkWidget* licdialog=NULL;
|
||||
|
||||
static void menuLicense()
|
||||
{
|
||||
char *txt=readFromFile("COPYING");
|
||||
textInfoDialog(&licdialog,txt,"Celestia License");
|
||||
g_free(txt);
|
||||
}
|
||||
|
||||
static GtkWidget* ogldialog=NULL;
|
||||
|
||||
static void menuOpenGL()
|
||||
{
|
||||
// Code grabbed from winmain.gtk
|
||||
char* vendor = (char*) glGetString(GL_VENDOR);
|
||||
char* render = (char*) glGetString(GL_RENDERER);
|
||||
char* version = (char*) glGetString(GL_VERSION);
|
||||
char* ext = (char*) glGetString(GL_EXTENSIONS);
|
||||
string s;
|
||||
s = "Vendor : ";
|
||||
if (vendor != NULL)
|
||||
s += vendor;
|
||||
s += "\n";
|
||||
|
||||
s += "Renderer : ";
|
||||
if (render != NULL)
|
||||
s += render;
|
||||
s += "\n";
|
||||
|
||||
s += "Version : ";
|
||||
if (version != NULL)
|
||||
s += version;
|
||||
s += "\n";
|
||||
|
||||
char buf[100];
|
||||
GLint simTextures = 1;
|
||||
if (ExtensionSupported("GL_ARB_multitexture"))
|
||||
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &simTextures);
|
||||
sprintf(buf, "Max simultaneous textures: %d\n",
|
||||
simTextures);
|
||||
s += buf;
|
||||
|
||||
GLint maxTextureSize = 0;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
||||
sprintf(buf, "Max texture size: %d\n\n",
|
||||
maxTextureSize);
|
||||
s += buf;
|
||||
|
||||
s += "Supported Extensions:\n ";
|
||||
if (ext != NULL)
|
||||
{
|
||||
string extString(ext);
|
||||
unsigned int pos = extString.find(' ', 0);
|
||||
while (pos != string::npos)
|
||||
{
|
||||
extString.replace(pos, 1, "\n ");
|
||||
pos = extString.find(' ', pos+5);
|
||||
}
|
||||
s += extString;
|
||||
}
|
||||
|
||||
textInfoDialog(&ogldialog,s.c_str(),"Open GL Info");
|
||||
}
|
||||
|
||||
|
||||
|
||||
static GtkItemFactoryEntry menuItems[] =
|
||||
{
|
||||
|
@ -824,12 +1024,14 @@ static GtkItemFactoryEntry menuItems[] =
|
|||
{ "/Time/Pause", "space", menuPause, 0, NULL },
|
||||
{ "/Time/Real Time", "backslash", menuRealTime, 0, NULL },
|
||||
{ "/Time/Reverse", "J", menuReverse, 0, NULL },
|
||||
{ "/Time/sep1", NULL, NULL, 0, "<Separator>" },
|
||||
{ "/Time/Show Local Time", "I", NULL, Menu_ShowLocTime, "<ToggleItem>" },
|
||||
{ "/_Render", NULL, NULL, 0, "<Branch>" },
|
||||
{ "/Render/Show Galaxies", "U", NULL, Menu_ShowGalaxies, "<ToggleItem>" },
|
||||
{ "/Render/Show Atmospheres", "<control>A",NULL, Menu_ShowAtmospheres, "<ToggleItem>" },
|
||||
{ "/Render/Show Clouds", "I", NULL, Menu_ShowClouds, "<ToggleItem>" },
|
||||
{ "/Render/Show Orbits", "O", NULL, Menu_ShowOrbits, "<ToggleItem>" },
|
||||
{ "/Render/Show Constellations", "minus",NULL, Menu_ShowConstellations, "<ToggleItem>" },
|
||||
{ "/Render/Show Constellations", "slash",NULL, Menu_ShowConstellations, "<ToggleItem>" },
|
||||
{ "/Render/Show Coordinate Sphere", "semicolon",NULL, Menu_ShowCelestialSphere, "<ToggleItem>" },
|
||||
{ "/Render/Show Night Side Lights", "<control>L",NULL, Menu_ShowNightSideMaps, "<ToggleItem>" },
|
||||
{ "/Render/sep1", NULL, NULL, 0, "<Separator>" },
|
||||
|
@ -840,7 +1042,7 @@ static GtkItemFactoryEntry menuItems[] =
|
|||
{ "/Render/Label Minor Planets", "M", NULL, Menu_MinorPlanetLabels, "<ToggleItem>" },
|
||||
{ "/Render/Label Stars", "B", NULL, Menu_StarLabels, "<ToggleItem>" },
|
||||
{ "/Render/Label Galaxies", "E", NULL, Menu_GalaxyLabels, "<ToggleItem>" },
|
||||
{ "/Render/LabelConstellations", "equal",NULL, Menu_ConstellationLabels, "<ToggleItem>" },
|
||||
{ "/Render/Label Constellations", "equal",NULL, Menu_ConstellationLabels, "<ToggleItem>" },
|
||||
{ "/Render/Show Info Text", "V", menuShowInfo, 0, NULL },
|
||||
{ "/Render/sep3", NULL, NULL, 0, "<Separator>" },
|
||||
{ "/Render/_Ambient", NULL, NULL, 0, "<Branch>" },
|
||||
|
@ -850,15 +1052,78 @@ static GtkItemFactoryEntry menuItems[] =
|
|||
{ "/Render/Ambient/High", NULL, menuHiAmbient, 0, NULL },
|
||||
{ "/_Help", NULL, NULL, 0, "<LastBranch>" },
|
||||
{ "/Help/Run Demo", "D", menuRunDemo, 0, NULL },
|
||||
{ "/Help/sep1", NULL, NULL, 0, "<Separator>" },
|
||||
{ "/Help/Controls", NULL, menuControls, 0, NULL },
|
||||
{ "/Help/OpenGL Info", NULL, menuOpenGL, 0, NULL },
|
||||
{ "/Help/License", NULL, menuLicense, 0, NULL },
|
||||
{ "/Help/sep2", NULL, NULL, 0, "<Separator>" },
|
||||
{ "/Help/About", NULL, menuAbout, 0, NULL },
|
||||
};
|
||||
|
||||
|
||||
static GtkItemFactoryEntry optMenuItems[] =
|
||||
{
|
||||
{ "/Render/Use Pixel Shaders", "<control>P", NULL, Menu_PixelShaders, "<ToggleItem>" },
|
||||
{ "/Render/Use Vertex Shaders", "<control>V", NULL, Menu_PixelShaders, "<ToggleItem>" },
|
||||
};
|
||||
|
||||
|
||||
int checkLocalTime(int dummy)
|
||||
{
|
||||
return(appCore->getTimeZoneBias()!=0);
|
||||
}
|
||||
|
||||
|
||||
int checkPixelShaders(int dummy)
|
||||
{
|
||||
return(appRenderer->getFragmentShaderEnabled());
|
||||
}
|
||||
|
||||
|
||||
int checkVertexShaders(int dummy)
|
||||
{
|
||||
return(appRenderer->getVertexShaderEnabled());
|
||||
}
|
||||
|
||||
|
||||
int checkShowGalaxies(int dummy)
|
||||
{
|
||||
return((appRenderer->getRenderFlags() & Renderer::ShowGalaxies) == Renderer::ShowGalaxies);
|
||||
}
|
||||
|
||||
|
||||
int checkRenderFlag(int flag)
|
||||
{
|
||||
return((appRenderer->getRenderFlags() & flag) == flag);
|
||||
}
|
||||
|
||||
|
||||
int checkLabelFlag(int flag)
|
||||
{
|
||||
return((appRenderer->getLabelMode() & flag) == flag);
|
||||
}
|
||||
|
||||
|
||||
static CheckFunc checks[] =
|
||||
{
|
||||
{ NULL, "/Time/Show Local Time", checkLocalTime, 1, 0 },
|
||||
{ NULL, "/Render/Use Pixel Shaders", checkPixelShaders, 0, 0 },
|
||||
{ NULL, "/Render/Use Vertex Shaders", checkVertexShaders, 0, 0 },
|
||||
{ NULL, "/Render/Show Galaxies", checkRenderFlag, 1, Renderer::ShowGalaxies },
|
||||
{ NULL, "/Render/Show Atmospheres", checkRenderFlag, 1, Renderer::ShowAtmospheres },
|
||||
{ NULL, "/Render/Show Clouds", checkRenderFlag, 1, Renderer::ShowCloudMaps },
|
||||
{ NULL, "/Render/Show Orbits", checkRenderFlag, 1, Renderer::ShowOrbits },
|
||||
{ NULL, "/Render/Show Constellations", checkRenderFlag, 1, Renderer::ShowDiagrams },
|
||||
{ NULL, "/Render/Show Coordinate Sphere",checkRenderFlag, 1, Renderer::ShowCelestialSphere },
|
||||
{ NULL, "/Render/Show Night Side Lights",checkRenderFlag, 1, Renderer::ShowNightMaps },
|
||||
{ NULL, "/Render/Label Major Planets", checkLabelFlag, 1, Renderer::MajorPlanetLabels },
|
||||
{ NULL, "/Render/Label Minor Planets", checkLabelFlag, 1, Renderer::MinorPlanetLabels },
|
||||
{ NULL, "/Render/Label Stars", checkLabelFlag, 1, Renderer::StarLabels },
|
||||
{ NULL, "/Render/Label Galaxies", checkLabelFlag, 1, Renderer::GalaxyLabels },
|
||||
{ NULL, "/Render/Label Constellations", checkRenderFlag, 1, Renderer::ConstellationLabels },
|
||||
};
|
||||
|
||||
|
||||
void setupCheckItem(GtkItemFactory* factory, int action, GtkSignalFunc func)
|
||||
{
|
||||
GtkWidget* w = gtk_item_factory_get_widget_by_action(factory, action);
|
||||
|
@ -879,15 +1144,21 @@ void createMainMenu(GtkWidget* window, GtkWidget** menubar)
|
|||
menuItemFactory = gtk_item_factory_new(GTK_TYPE_MENU_BAR,
|
||||
"<main>",
|
||||
accelGroup);
|
||||
gtk_accel_group_attach (accelGroup, GTK_OBJECT (window));
|
||||
gtk_item_factory_create_items(menuItemFactory, nItems, menuItems, NULL);
|
||||
Renderer *renderer=appCore->getRenderer();
|
||||
g_assert(renderer);
|
||||
if(renderer->fragmentShaderSupported())
|
||||
appRenderer=appCore->getRenderer();
|
||||
g_assert(appRenderer);
|
||||
if(appRenderer->fragmentShaderSupported())
|
||||
{
|
||||
gtk_item_factory_create_item(menuItemFactory, &optMenuItems[0], NULL, 1);
|
||||
if (renderer->vertexShaderSupported())
|
||||
checks[1].active=1;
|
||||
}
|
||||
if (appRenderer->vertexShaderSupported())
|
||||
{
|
||||
gtk_item_factory_create_item(menuItemFactory, &optMenuItems[1], NULL, 1);
|
||||
checks[2].active=1;
|
||||
}
|
||||
|
||||
gtk_window_add_accel_group(GTK_WINDOW(window), accelGroup);
|
||||
if (menubar != NULL)
|
||||
*menubar = gtk_item_factory_get_widget(menuItemFactory, "<main>");
|
||||
|
||||
|
@ -915,10 +1186,12 @@ void createMainMenu(GtkWidget* window, GtkWidget** menubar)
|
|||
GTK_SIGNAL_FUNC(menuConstellationLabels));
|
||||
setupCheckItem(menuItemFactory, Menu_ShowCelestialSphere,
|
||||
GTK_SIGNAL_FUNC(menuShowCelestialSphere));
|
||||
if(renderer->fragmentShaderSupported())
|
||||
setupCheckItem(menuItemFactory, Menu_ShowLocTime,
|
||||
GTK_SIGNAL_FUNC(menuShowLocTime));
|
||||
if(appRenderer->fragmentShaderSupported())
|
||||
setupCheckItem(menuItemFactory, Menu_PixelShaders,
|
||||
GTK_SIGNAL_FUNC(menuPixelShaders));
|
||||
if (renderer->vertexShaderSupported())
|
||||
if (appRenderer->vertexShaderSupported())
|
||||
setupCheckItem(menuItemFactory, Menu_VertexShaders,
|
||||
GTK_SIGNAL_FUNC(menuVertexShaders));
|
||||
}
|
||||
|
@ -954,7 +1227,12 @@ gint initFunc(GtkWidget* widget)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
appCore->start((double) time(NULL) / 86400.0 + (double) astro::Date(1970, 1, 1));
|
||||
time_t curtime=time(NULL);
|
||||
appCore->start((double) curtime / 86400.0 + (double) astro::Date(1970, 1, 1));
|
||||
localtime(&curtime); /* Only doing this to set timezone as a side
|
||||
effect*/
|
||||
appCore->setTimeZoneBias(-timezone);
|
||||
appCore->setTimeZone(tzname[daylight?0:1]);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -1227,8 +1505,7 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
// Create the main window
|
||||
mainWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_set_title(GTK_WINDOW(mainWindow), AppName);
|
||||
mainWindow=gnome_app_new("Celestia",AppName);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(mainWindow), 1);
|
||||
|
||||
mainBox = GTK_WIDGET(gtk_vbox_new(FALSE, 0));
|
||||
|
@ -1274,7 +1551,7 @@ int main(int argc, char* argv[])
|
|||
createMainMenu(mainWindow, &mainMenu);
|
||||
|
||||
// gtk_container_add(GTK_CONTAINER(mainWindow), GTK_WIDGET(oglArea));
|
||||
gtk_container_add(GTK_CONTAINER(mainWindow), GTK_WIDGET(mainBox));
|
||||
gnome_app_set_contents((GnomeApp *)mainWindow, GTK_WIDGET(mainBox));
|
||||
gtk_box_pack_start(GTK_BOX(mainBox), mainMenu, FALSE, TRUE, 0);
|
||||
gtk_box_pack_start(GTK_BOX(mainBox), oglArea, TRUE, TRUE, 0);
|
||||
gtk_widget_show(GTK_WIDGET(oglArea));
|
||||
|
@ -1290,6 +1567,35 @@ int main(int argc, char* argv[])
|
|||
|
||||
bReady = true;
|
||||
|
||||
g_assert(menuItemFactory);
|
||||
// Check all the toggle items that they are set on/off correctly
|
||||
int i = sizeof(checks) / sizeof(checks[0]);
|
||||
for(CheckFunc *cfunc=&checks[--i];i>=0;cfunc=&checks[--i])
|
||||
{
|
||||
if(!cfunc->active)
|
||||
continue;
|
||||
g_assert(cfunc->path);
|
||||
cfunc->widget=GTK_CHECK_MENU_ITEM(gtk_item_factory_get_widget(menuItemFactory, cfunc->path));
|
||||
if(!cfunc->widget)
|
||||
{
|
||||
cfunc->active=0;
|
||||
DPRINTF("Menu item %s status checking deactivated due to being unable to find it!", cfunc->path);
|
||||
continue;
|
||||
}
|
||||
g_assert(cfunc->func);
|
||||
int res=(*cfunc->func)(cfunc->funcdata);
|
||||
if(res)
|
||||
{
|
||||
if(cfunc->widget->active == FALSE)
|
||||
{
|
||||
// Change state of widget *without* causing a message to be
|
||||
// sent (which would change the state again).
|
||||
gtk_widget_hide(GTK_WIDGET(cfunc->widget));
|
||||
cfunc->widget->active=TRUE;
|
||||
gtk_widget_show(GTK_WIDGET(cfunc->widget));
|
||||
}
|
||||
}
|
||||
}
|
||||
gtk_main();
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue