Extended Celestia Watcher

ver1_5_1
Deon Ramsey 2002-04-02 11:35:27 +00:00
parent 5b75778951
commit 20cc261b38
5 changed files with 95 additions and 13 deletions

View File

@ -490,3 +490,4 @@ Code:
* Removed duplicate entry for Iota Horologii (HR 810) in exoplanet catalog
* Unix Gtk: removed problem preventing ShowClouds from working. (dramsey)
* Unix Gtk: Options Dialog. (dramsey)
* Celestia Watcher extended. (dramsey)

View File

@ -4,7 +4,7 @@ dnl Process this file with autoconf to make a configure script
dnl
AC_INIT(configure.in)
AM_INIT_AUTOMAKE(celestia, 1.2.1)
AM_INIT_AUTOMAKE(celestia, 1.2.4)
AM_CONFIG_HEADER(config.h)
AM_ACLOCAL_INCLUDE(macros)

View File

@ -767,7 +767,10 @@ void CelestiaCore::charEntered(char c)
case '[':
if (sim->getFaintestVisible() > 1.0f)
{
setFaintest(sim->getFaintestVisible() - 0.5f);
notifyWatchers(CelestiaWatcher::Faintest);
}
break;
case '\\':
@ -776,7 +779,10 @@ void CelestiaCore::charEntered(char c)
case ']':
if (sim->getFaintestVisible() < 12.0f)
{
setFaintest(sim->getFaintestVisible() + 0.5f);
notifyWatchers(CelestiaWatcher::Faintest);
}
break;
case '`':
@ -788,6 +794,7 @@ void CelestiaCore::charEntered(char c)
renderer->setAmbientLightLevel(renderer->getAmbientLightLevel() - 0.05f);
else
renderer->setAmbientLightLevel(0.0f);
notifyWatchers(CelestiaWatcher::AmbientLight);
break;
case '}':
@ -795,6 +802,7 @@ void CelestiaCore::charEntered(char c)
renderer->setAmbientLightLevel(renderer->getAmbientLightLevel() + 0.05f);
else
renderer->setAmbientLightLevel(1.0f);
notifyWatchers(CelestiaWatcher::AmbientLight);
break;
case '~':
@ -1803,6 +1811,7 @@ int CelestiaCore::getTextEnterMode() const
void CelestiaCore::setTimeZoneBias(int bias)
{
timeZoneBias = bias;
notifyWatchers(CelestiaWatcher::TimeZone);
}

View File

@ -253,6 +253,9 @@ class CelestiaWatcher
LabelFlags = 1,
RenderFlags = 2,
VerbosityLevel = 4,
TimeZone = 8,
AmbientLight = 16,
Faintest = 32,
};
private:

View File

@ -554,10 +554,10 @@ static int infoChanged(GtkButton *button, int info)
}
extern void resyncMenus();
extern void resyncAll();
GtkWidget *showFrame=NULL, *labelFrame=NULL, *showBox=NULL, *labelBox=NULL;
GtkWidget *optionDialog=NULL;
GtkWidget *optionDialog=NULL, *spinner = NULL;
static void menuOptions()
{
@ -607,7 +607,7 @@ static void menuOptions()
GtkAdjustment *adj = (GtkAdjustment *)
gtk_adjustment_new((float)appSim->getFaintestVisible(),
1.001, 11.999, 0.5, 2.0, 0.0);
GtkWidget *spinner = gtk_spin_button_new (adj, 0.5, 0);
spinner = gtk_spin_button_new (adj, 0.5, 0);
gtk_spin_button_set_numeric(GTK_SPIN_BUTTON (spinner), TRUE);
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinner), FALSE);
gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinner), GTK_SHADOW_IN);
@ -643,7 +643,7 @@ static void menuOptions()
gtk_widget_show(label2);
gtk_widget_show(hbox);
resyncMenus();
resyncAll();
gnome_dialog_close_hides(GNOME_DIALOG(optionDialog), true);
gtk_window_set_modal(GTK_WINDOW(optionDialog), TRUE);
@ -2380,13 +2380,14 @@ void resyncMenus()
gtk_widget_show(GTK_WIDGET(cfunc->optWidget));
}
}
if(optionDialog) // Only modify these if optionsDialog is setup
}
void resyncAmbient()
{
if(optionDialog) // Only modify if optionsDialog is setup
{
int index=appCore->getHudDetail();
if(!(infoGads[index])->active)
gtk_toggle_button_set_active(infoGads[index],1);
float ambient=appRenderer->getAmbientLightLevel();
index=3;
int index=3;
for(int i=3;(ambient<=amLevels[i]) && (i>=0);i--)
index=i;
if(!(ambientGads[index])->active)
@ -2395,8 +2396,39 @@ void resyncMenus()
}
/* Our own watcher. Celestiacore will call notifyChange()
to tell us we need to recheck the check menu items. */
void resyncFaintest()
{
if(optionDialog) // Only modify if optionsDialog is setup
{
float val=appSim->getFaintestVisible();
if(val != gtk_spin_button_get_value_as_float(GTK_SPIN_BUTTON(spinner)))
gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner), (gfloat)val);
}
}
void resyncHudDet()
{
if(optionDialog) // Only modify if optionsDialog is setup
{
int index=appCore->getHudDetail();
if(!(infoGads[index])->active)
gtk_toggle_button_set_active(infoGads[index],1);
}
}
void resyncAll()
{
resyncMenus();
resyncAmbient();
resyncHudDet();
resyncFaintest();
}
/* Our own watcher. Celestiacore will call notifyChange() to tell us
we need to recheck the check menu items and option buttons. */
class GtkWatcher : public CelestiaWatcher
{
@ -2405,6 +2437,11 @@ public:
virtual void notifyChange(int);
void renderFlagsChanged();
void labelFlagsChanged();
void timeZoneChanged();
void ambientLightChanged();
void faintestChanged();
void hudDetailChanged();
};
@ -2419,6 +2456,14 @@ void GtkWatcher::notifyChange(int property)
renderFlagsChanged();
else if (property == LabelFlags)
labelFlagsChanged();
else if (property == TimeZone)
timeZoneChanged();
else if (property == AmbientLight)
ambientLightChanged();
else if (property == Faintest)
faintestChanged();
else if (property == VerbosityLevel)
hudDetailChanged();
}
void GtkWatcher::renderFlagsChanged()
@ -2433,6 +2478,30 @@ void GtkWatcher::labelFlagsChanged()
}
void GtkWatcher::timeZoneChanged()
{
resyncMenus();
}
void GtkWatcher::ambientLightChanged()
{
resyncAmbient();
}
void GtkWatcher::faintestChanged()
{
resyncFaintest();
}
void GtkWatcher::hudDetailChanged()
{
resyncHudDet();
}
GtkWatcher *gtkWatcher=NULL;
int main(int argc, char* argv[])
@ -2552,7 +2621,7 @@ int main(int argc, char* argv[])
g_assert(menuItemFactory);
gtkWatcher = new GtkWatcher(appCore);
resyncMenus();
resyncAll();
gtk_main();
delete captureFilename;