Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1829 in orxonox.OLD for orxonox


Ignore:
Timestamp:
Apr 15, 2004, 2:14:40 AM (21 years ago)
Author:
bensch
Message:

orxonox/branches/bensch: added save/load ability

Location:
orxonox/branches/bensch
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/bensch/Makefile.am

    r1817 r1829  
    22AM_LDFLAGS=`pkg-config --libs  gtk+-2.0`
    33
    4 bin_PROGRAMS=orxonox
    5 orxonox_SOURCES=orxonox_gui.c orxonox_gui_video.c orxonox_gui_audio.c orxonox_gui_exec.c orxonox_gui_file.c\
     4bin_PROGRAMS=orxonox_gui
     5orxonox_gui_SOURCES=orxonox_gui.c orxonox_gui_video.c orxonox_gui_audio.c orxonox_gui_exec.c orxonox_gui_file.c\
    66        aclocal.m4
    77
  • orxonox/branches/bensch/Makefile.in

    r1817 r1829  
    1515@SET_MAKE@
    1616
    17 SOURCES = $(orxonox_SOURCES)
     17SOURCES = $(orxonox_gui_SOURCES)
    1818
    1919srcdir = @srcdir@
     
    3838POST_UNINSTALL = :
    3939host_triplet = @host@
    40 bin_PROGRAMS = orxonox$(EXEEXT)
     40bin_PROGRAMS = orxonox_gui$(EXEEXT)
    4141DIST_COMMON = README $(am__configure_deps) $(orxonox_TEXINFOS) \
    4242        $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
     
    5959binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
    6060PROGRAMS = $(bin_PROGRAMS)
    61 am_orxonox_OBJECTS = orxonox_gui.$(OBJEXT) orxonox_gui_video.$(OBJEXT) \
    62         orxonox_gui_audio.$(OBJEXT) orxonox_gui_exec.$(OBJEXT) \
    63         orxonox_gui_file.$(OBJEXT)
    64 orxonox_OBJECTS = $(am_orxonox_OBJECTS)
    65 orxonox_LDADD = $(LDADD)
     61am_orxonox_gui_OBJECTS = orxonox_gui.$(OBJEXT) \
     62        orxonox_gui_video.$(OBJEXT) orxonox_gui_audio.$(OBJEXT) \
     63        orxonox_gui_exec.$(OBJEXT) orxonox_gui_file.$(OBJEXT)
     64orxonox_gui_OBJECTS = $(am_orxonox_gui_OBJECTS)
     65orxonox_gui_LDADD = $(LDADD)
    6666DEFAULT_INCLUDES = -I. -I$(srcdir) -I.
    6767depcomp = $(SHELL) $(top_srcdir)/depcomp
     
    7676CCLD = $(CC)
    7777LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
    78 SOURCES = $(orxonox_SOURCES)
    79 DIST_SOURCES = $(orxonox_SOURCES)
     78SOURCES = $(orxonox_gui_SOURCES)
     79DIST_SOURCES = $(orxonox_gui_SOURCES)
    8080INFO_DEPS = $(srcdir)/orxonox.info
    8181am__TEXINFO_TEX_DIR = $(srcdir)
     
    187187AM_CFLAGS = `pkg-config --cflags gtk+-2.0`
    188188AM_LDFLAGS = `pkg-config --libs  gtk+-2.0`
    189 orxonox_SOURCES = orxonox_gui.c orxonox_gui_video.c orxonox_gui_audio.c orxonox_gui_exec.c orxonox_gui_file.c\
     189orxonox_gui_SOURCES = orxonox_gui.c orxonox_gui_video.c orxonox_gui_audio.c orxonox_gui_exec.c orxonox_gui_file.c\
    190190        aclocal.m4
    191191
     
    287287clean-binPROGRAMS:
    288288        -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
    289 orxonox$(EXEEXT): $(orxonox_OBJECTS) $(orxonox_DEPENDENCIES)
    290         @rm -f orxonox$(EXEEXT)
    291         $(LINK) $(orxonox_LDFLAGS) $(orxonox_OBJECTS) $(orxonox_LDADD) $(LIBS)
     289orxonox_gui$(EXEEXT): $(orxonox_gui_OBJECTS) $(orxonox_gui_DEPENDENCIES)
     290        @rm -f orxonox_gui$(EXEEXT)
     291        $(LINK) $(orxonox_gui_LDFLAGS) $(orxonox_gui_OBJECTS) $(orxonox_gui_LDADD) $(LIBS)
    292292
    293293mostlyclean-compile:
  • orxonox/branches/bensch/orxonox_gui.c

    r1820 r1829  
    33#include "orxonox_gui_audio.h"
    44int verbose = 1;
    5 
    6 
    7 gint delete_event ( GtkWidget *widget, GdkEvent *event, gpointer data )
    8 {
    9   return FALSE;
    10 }
    11 
    125
    136int main( int argc, char *argv[] )
     
    1811    GtkWidget *hbox_view_exec;
    1912    struct settings *orxonox_settings;
     13
    2014    int option_count = 7; /* important: look that this is greater than options in 'struct settings' */
    2115
     
    2519
    2620    orxonox_gui_file_default (orxonox_settings);
     21    orxonox_gui_file_load ("~/.orxonox.conf", orxonox_settings);
    2722
    2823
     
    3227    gtk_window_set_title ( GTK_WINDOW (window), "orxonox");
    3328    g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL);
    34     g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL);
     29    g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (orxonox_gui_quit), orxonox_settings);
    3530    gtk_container_set_border_width (GTK_CONTAINER (window), 5);
    3631   
  • orxonox/branches/bensch/orxonox_gui.h

    r1822 r1829  
    88#include <gtk/gtk.h>
    99#include "orxonox_gui_exec.h"
    10 
    11 gint delete_event ( GtkWidget *widget, GdkEvent *event, gpointer data );
    1210
    1311struct settings
  • orxonox/branches/bensch/orxonox_gui_exec.c

    r1823 r1829  
    22GtkWidget *exec_flags_label;
    33struct settings *exec_orxonox_settings;
     4
     5gint orxonox_gui_quit ( GtkWidget *widget, GdkEvent *event, gpointer data)
     6{
     7  if (exec_orxonox_settings->exec_save_settings)
     8    orxonox_gui_file_save("~/.orxonox.conf", exec_orxonox_settings);
     9  gtk_main_quit();
     10  return FALSE;
     11}
     12
    413
    514void exec_check_button_change(GtkWidget *widget, int* data)
     
    8392       
    8493        quit_button = gtk_button_new_with_label ("quit");
    85         g_signal_connect(GTK_BUTTON(quit_button), "clicked", G_CALLBACK(gtk_main_quit), NULL);
     94        g_signal_connect(GTK_BUTTON(quit_button), "clicked", G_CALLBACK(orxonox_gui_quit), NULL);
    8695        gtk_box_pack_start(GTK_BOX (orxonox_gui_exec_vbox), quit_button, FALSE, FALSE, 5);
    8796
  • orxonox/branches/bensch/orxonox_gui_exec.h

    r1822 r1829  
    22#define _ORXONOX_GUI_EXEC_H
    33#include "orxonox_gui.h"
     4
     5gint orxonox_gui_quit ( GtkWidget *widget, GdkEvent *event, gpointer data);
    46
    57void exec_check_button_change(GtkWidget *widget, int* data);
  • orxonox/branches/bensch/orxonox_gui_file.c

    r1817 r1829  
    1 #include <stdio.h>
    2 #include <stdlib.h>
    31#include <sys/stat.h>
    42#include "orxonox_gui_file.h"
     
    2220  return;
    2321}
     22
     23void orxonox_gui_file_save (char *config_file, struct settings *orxonox_settings)
     24{
     25  FILE *IOFILE;
     26  char local_config_file[1000];
     27
     28  sprintf(local_config_file,"%s", config_file);
     29  if (!strncmp (local_config_file,"~/", 2))
     30  {
     31    char buffer[100];
     32    char *homedir = getenv("HOME");
     33    sprintf(buffer, local_config_file);
     34    sprintf (local_config_file,"%s/%s", homedir,buffer+2);
     35  }
     36
     37  IOFILE = fopen( local_config_file, "w");
     38  if (verbose >= 1)
     39    printf ("Saving settings to %s\n", local_config_file);
     40 
     41  fprintf (IOFILE, "%s\n", "Configuration file of orxonox (do not edit if ou do not know what you are doing)");
     42  fprintf (IOFILE, "orxonox_settings->video_fullscreen = %i\n", orxonox_settings->video_fullscreen);
     43  fprintf (IOFILE, "orxonox_settings->video_wireframe = %i\n", orxonox_settings->video_wireframe);
     44
     45  fprintf (IOFILE, "orxonox_settings->audio_enable_sound = %i\n", orxonox_settings->audio_enable_sound);
     46  fprintf (IOFILE, "orxonox_settings->audio_music_volume = %i\n", orxonox_settings->audio_music_volume);
     47  fprintf (IOFILE, "orxonox_settings->audio_effects_volume = %i\n", orxonox_settings->audio_effects_volume);
     48
     49  fprintf (IOFILE, "orxonox_settings->exec_save_settings = %i\n", orxonox_settings->exec_save_settings);
     50  fprintf (IOFILE, "orxonox_settings->exec_show_menu = %i\n", orxonox_settings->exec_show_menu);
     51
     52  fprintf (IOFILE, "orxonox_settings->verbose = %i\n", verbose);
     53 
     54  fclose( IOFILE );
     55  return;
     56}
     57
     58void orxonox_gui_file_load (char *config_file, struct settings *orxonox_settings)
     59{
     60  FILE *IOFILE;
     61  char variable[100];
     62  char equals[5];
     63  char value[100];
     64  char buffer[100];
     65  char local_config_file[1000];
     66 
     67  sprintf(local_config_file,"%s", config_file);
     68  if (!strncmp (config_file, "~/", 2))
     69    {
     70      char *homedir = getenv("HOME");
     71      sprintf(buffer, local_config_file);
     72      sprintf (local_config_file,"%s/%s", homedir, buffer+2);
     73    }
     74 
     75
     76  IOFILE = fopen(local_config_file, "r");
     77  if (verbose >= 1)
     78    printf ("Loading settings from '%s'\n", local_config_file);
     79 
     80  fscanf (IOFILE, "Configuration file of orxonox (do not edit if ou do not know what you are doing)");
     81  while (fscanf (IOFILE,"%s %s %s", variable, equals, value) != EOF)
     82    {
     83      if ( !strcmp (variable, "orxonox_settings->video_fullscreen"))
     84        {
     85          orxonox_settings->video_fullscreen = atoi (value);
     86        }
     87      else if ( !strcmp (variable, "orxonox_settings->video_wireframe"))
     88        {
     89          orxonox_settings->video_wireframe = atoi (value);
     90        }
     91
     92      else if ( !strcmp (variable, "orxonox_settings->audio_enable_sound"))
     93        {
     94          orxonox_settings->audio_enable_sound = atoi (value);
     95        }
     96      else if ( !strcmp (variable, "orxonox_settings->audio_music_volume"))
     97        {
     98          orxonox_settings->audio_music_volume = atoi (value);
     99        }
     100      else if ( !strcmp (variable, "orxonox_settings->audio_effects_volume"))
     101        {
     102          orxonox_settings->audio_effects_volume = atoi (value);
     103        }
     104
     105      else if ( !strcmp (variable, "orxonox_settings->exec_save_settings"))
     106        {
     107          orxonox_settings->exec_save_settings = atoi (value);
     108        }
     109      else if ( !strcmp (variable, "orxonox_settings->exec_show_menu"))
     110        {
     111          orxonox_settings->exec_show_menu = atoi (value);
     112        }
     113
     114      else if ( !strcmp (variable, "orxonox_settings->verbose"))
     115        {
     116          verbose = atoi (value);
     117        }
     118
     119    }
     120  fclose( IOFILE );     
     121  return;
     122}
     123
  • orxonox/branches/bensch/orxonox_gui_file.h

    r1817 r1829  
    44#include "orxonox_gui.h"
    55
    6 struct settings orxonox_gui_file_save (char *filename);
    7 struct settings orxonox_gui_file_load (char *filename);
     6void orxonox_gui_file_save (char *config_file, struct settings *orxonox_settings);
     7void orxonox_gui_file_load (char *config_file, struct settings *orxonox_settings);
    88void orxonox_gui_file_default (struct settings *orxonox_settings);
    99
Note: See TracChangeset for help on using the changeset viewer.