Example #1
0
int main(void) {
  char refreshed;

  editor_init(&refreshed);
  editor_refresh();

  set_sleep_mode(SLEEP_MODE_STANDBY);
  sei();


  for (;;) {
    cli();
    if (refreshed) {
      sleep_enable();
      sei();
      sleep_cpu();
      sleep_disable();
    } else {
      refreshed = 1;
      sei();
      editor_refresh();
    }
  }

};
Example #2
0
void interface (gint argc, gchar *argv[])
{
  GtkWidget *MenuBar;
  GtkWidget *VBox;
  GtkWidget *HandleBox;

  gtk_set_locale();  
  gtk_init (&argc, &argv);
  Settings = init_settings ();
  MainWindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW(MainWindow), g_strconcat
			(WELCOME_MSG, " ", APP_NAME, " ",
			 VERSION_NUMBER, NULL));
  gtk_window_set_policy (GTK_WINDOW(MainWindow), TRUE, TRUE, FALSE);
  gtk_widget_set_usize (MainWindow, MAIN_WINDOW_WIDTH, MAIN_WINDOW_HEIGHT);
  gtk_signal_connect (GTK_OBJECT(MainWindow), "delete_event",
		      (GtkSignalFunc) quit, NULL); 
  gtk_signal_connect (GTK_OBJECT(MainWindow), "destroy",
		      (GtkSignalFunc) quit, NULL);
  FileProperties = g_array_new (TRUE, FALSE, sizeof(t_fprops));
  VBox = gtk_vbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER(MainWindow), VBox);
  HandleBox = gtk_handle_box_new();
  gtk_container_set_border_width (GTK_CONTAINER(HandleBox), 2);
  gtk_box_pack_start (GTK_BOX(VBox), HandleBox, FALSE, FALSE, 0);
  init_toolbar (GTK_BOX(VBox));
  MainNotebook = gtk_notebook_new ();
  read_uedit_wordfile (WORDFILE);
  editor_init();
  MenuBar = menubar_new (MainWindow);
  gtk_container_add (GTK_CONTAINER(HandleBox), MenuBar);
  gtk_notebook_popup_enable (GTK_NOTEBOOK(MainNotebook));
  gtk_notebook_set_homogeneous_tabs (GTK_NOTEBOOK(MainNotebook), TRUE);
  gtk_notebook_set_scrollable (GTK_NOTEBOOK(MainNotebook), TRUE);
  gtk_box_pack_start (GTK_BOX(VBox), MainNotebook, TRUE, TRUE, 0);
  gtk_signal_connect (GTK_OBJECT(MainNotebook), "switch_page",
		      (GtkSignalFunc) set_title, NULL);
  init_msgbar (GTK_BOX(VBox));
  print_msg ("You're the welcome...");
  command_line (argc, argv);
  autosave (AUTOSAVE_DELAY);
  gtk_widget_show_all (MainWindow);
  if (!MSGBAR_DISPLAY) hide_msgbar ();
  if (!TOOLBAR_DISPLAY) hide_toolbar ();
  gtk_timeout_add (80, (GtkFunction)display_line_column, NULL);
  gtk_main ();
  set_preferences_to_disk (&Settings, NULL);
  gtk_item_factory_dump_rc (g_strconcat (g_get_home_dir (), PATH_SEP_STRING,
					 CONF_DIR, PATH_SEP_STRING,
					 "AccelRC", NULL), NULL, FALSE);
}
int main(int argc, char* argv[])
{
	if (!editor_init(argc, argv))
	{
		fprintf(stderr, "Basic SDL Map Editor Initialization Failed!\n");
	}

	atexit(SDL_Quit);
	atexit(editor_destroy);

	editor_execute();

	return 0;
}
Example #4
0
int main(void)
{
        setlocale(LC_ALL, "");

        struct editor e;

        term_init(&e);
        editor_init(&e, term_height(), term_width());

        render(&e);

        editor_run(&e);

        return 0;
}
Example #5
0
int main(int argc, char *argv[])
{
    int result = ACTION_NONE;
    int leave = 0;
    char *editor_file = 0;
    char path[512];
    SDL_Surface *loading;
#ifdef __unix__
    gid_t realgid;

    hi_dir_chart_file = fopen(HI_DIR "/" CHART_FILE_NAME, "r+");

    /* This is where we drop our setuid/setgid privileges.
     */
    realgid = getgid();
    if (setresgid(-1, realgid, realgid) != 0) {
        perror("Could not drop setgid privileges.  Aborting.");
        exit(1);
    }
#endif
   
/* i18n */
#ifdef ENABLE_NLS
    setlocale (LC_ALL, "");
    bindtextdomain (PACKAGE, LOCALEDIR);
    textdomain (PACKAGE);
#endif
    
#ifdef _WIN32    
    /* Get Windows to open files in binary mode instead of default text mode */
    _fmode = _O_BINARY;
#endif    
    
    /* lbreakout info */
    printf( "LBreakout2 %s\nCopyright 2001-2010 Michael Speck\nPublished under GNU GPL\n---\n", VERSION );
    printf( "Looking up data in: %s\n", SRC_DIR );
    printf( "Looking up highscores in: %s\n", HI_DIR );
    printf( "Looking up custom levels in: %s/%s/lbreakout2-levels\n", (getenv( "HOME" )?getenv( "HOME" ):"."), CONFIG_DIR_NAME );
#ifndef AUDIO_ENABLED
    printf( "Compiled without sound and music\n" );
#endif

    set_random_seed(); /* set random seed */

    config_load();
    
    stk_init( SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER | SDL_INIT_JOYSTICK );
    if ( config.fullscreen )
        stk_display_open( SDL_SWSURFACE | SDL_FULLSCREEN, 640, 480, 16 );
    else
        stk_display_open( SDL_SWSURFACE, 640, 480, 16 );
    stk_audio_open( 0,0,0,config.audio_buffer_size );
    SDL_WM_SetCaption( "LBreakout2", 0 );
    SDL_SetEventFilter( event_filter );
    stk_audio_enable_sound( config.sound );
    stk_audio_set_sound_volume( config.volume * 16 );
    
    /* load a little loading pic */
    stk_surface_set_path( SRC_DIR "/gfx" );
    loading = stk_surface_load( SDL_SWSURFACE, "loading.png" );
    stk_surface_blit( loading, 0,0,-1,-1, stk_display, 
                      (stk_display->w-loading->w)/2, 
                      (stk_display->h-loading->h)/2 );
    stk_display_update( STK_UPDATE_ALL );
    
    /* load the GUI graphics from SRC_DIR/gui_theme */
    stk_surface_set_path( SRC_DIR );
    stk_audio_set_path( SRC_DIR );
    gui_init( "gui_theme" );

    stk_surface_set_path( SRC_DIR "/gfx" );
    stk_audio_set_path( SRC_DIR "/sounds" );
    
    /* load resources */
    /* for simplicity all functions are kept but anything
     * that is now themeable is loaded in
     * theme_load instead of the original function
     * (deleting resources works analouge)
     */
    theme_get_list();
    if ( config.theme_count != theme_count ) {
        if ( config.theme_id >= theme_count )
            config.theme_id = 0;
        config.theme_count = theme_count;
    }
    theme_load( theme_names[config.theme_id] );
    /* old functions still with initialzations of
     * lists or variables 
     */
    client_game_create();
    hint_load_res();
    chart_load();
    manager_create();
    client_create();
    exp_load();
    editor_create();
	help_create();
    /* run game */
    manager_fade( STK_FADE_IN );
    while( !leave && !stk_quit_request ) {
        result = manager_run();
        switch( result ) {
            case ACTION_QUIT: leave = 1; break;
            case ACTION_RESUME_0:
                manager_fade( STK_FADE_OUT );
		if ( client_game_resume_local( 0 ) )
			client_game_run();
                client_game_finalize();
                manager_fade( STK_FADE_IN );
                break;
            case ACTION_PLAY_LBR:
                manager_fade( STK_FADE_OUT );
                gameSeed = rand(); /* set random seed for next FREAKOUT/BonusLevels */
		if ( client_game_init_local( "LBreakout2" ) )
			client_game_run();
                client_game_finalize();
                manager_fade( STK_FADE_IN );
                break;
            case ACTION_PLAY_CUSTOM:
                manager_fade( STK_FADE_OUT );
                gameSeed = rand(); /* set random seed for next FREAKOUT/BonusLevels */
                if (gameSeed==0) gameSeed=1; /* not allowed because.... A HACK!!! 0 means to have
                                                no bonus levels to save a parameter */
		if ( client_game_init_local( levelset_names_local[config.levelset_id_local] ) )
			client_game_run();
                client_game_finalize();
                manager_fade( STK_FADE_IN );
                break;
            case ACTION_EDIT:
                /* new set? */
                if ( strequal( NEW_SET, edit_set ) ) {
                    editor_file = calloc( 16, sizeof( char ) );
                    snprintf( path, sizeof(path)-1, "%s/%s/lbreakout2-levels", getenv( "HOME" )? getenv("HOME"):".", CONFIG_DIR_NAME );
                    if ( !enter_string( font, _("Set Name:"), editor_file, 12 ) || !file_check( path, editor_file, "w" ) ) {
                        free( editor_file );
                        break;
                    }
                    else
                        manager_update_set_list();
                }
                else
                    editor_file = strdup( edit_set );
                if ( editor_init( editor_file ) ) {
                    manager_fade( STK_FADE_OUT );
                    editor_run();
                    editor_clear();
                    manager_fade( STK_FADE_IN );
                }
                free( editor_file ); editor_file = 0;
                break;
			case ACTION_QUICK_HELP:
				help_run();
				break;
            case ACTION_CLIENT:
                manager_fade( STK_FADE_OUT );
                client_run();
                manager_fade( STK_FADE_IN );
                break;
            default: break;
        }
    }
    manager_fade( STK_FADE_OUT );
    /* delete stuff */
    help_delete();
	manager_delete();
	chart_save();
    chart_delete();
    editor_delete();
    exp_delete();
    client_game_delete();
    hint_delete_res();
    theme_delete();
    theme_delete_list();
    stk_surface_free( &loading );
    
    config_save();
    
    if (hi_dir_chart_file)
        fclose(hi_dir_chart_file);

    return EXIT_SUCCESS;
}