1 | #include "orxonox_gui_exec.h" |
---|
2 | GtkWidget *exec_flags_label; |
---|
3 | struct settings *exec_orxonox_settings; |
---|
4 | |
---|
5 | void exec_check_button_change(GtkWidget *widget, int* data) |
---|
6 | { |
---|
7 | *data = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (widget)); |
---|
8 | orxonox_flags_update (); |
---|
9 | if (verbose >=1) |
---|
10 | printf ("%s changed to %i.\n", gtk_button_get_label(GTK_BUTTON(widget)), *data); |
---|
11 | return; |
---|
12 | } |
---|
13 | |
---|
14 | void exec_verbose_mode_change(GtkWidget *widget, gpointer data) |
---|
15 | { |
---|
16 | verbose = GPOINTER_TO_INT(data); |
---|
17 | orxonox_flags_update (); |
---|
18 | if (verbose >= 1) |
---|
19 | printf ("Verbose-mode changed to %i.\n", verbose); |
---|
20 | return; |
---|
21 | } |
---|
22 | |
---|
23 | |
---|
24 | GtkWidget *orxonox_gui_exec_frame (struct settings *orxonox_settings) |
---|
25 | { |
---|
26 | GtkWidget *frame; |
---|
27 | GtkWidget *save_settings_button; |
---|
28 | GtkWidget *show_menu_button; |
---|
29 | GtkWidget *start_button; |
---|
30 | GtkWidget *quit_button; |
---|
31 | GtkWidget *flags_frame; |
---|
32 | GtkWidget *setting_box; |
---|
33 | GtkWidget *verbose_button; |
---|
34 | |
---|
35 | |
---|
36 | frame = gtk_frame_new ( "Execute-Tags:"); |
---|
37 | gtk_container_set_border_width (GTK_CONTAINER (frame), 5); |
---|
38 | { |
---|
39 | GtkWidget *orxonox_gui_exec_vbox; |
---|
40 | orxonox_gui_exec_vbox = gtk_vbox_new (FALSE, 5); |
---|
41 | { |
---|
42 | |
---|
43 | start_button = gtk_button_new_with_label ("Start"); |
---|
44 | gtk_box_pack_start(GTK_BOX (orxonox_gui_exec_vbox), start_button, TRUE, TRUE, 5); |
---|
45 | setting_box = gtk_hbox_new(FALSE, 5); |
---|
46 | { |
---|
47 | save_settings_button = gtk_check_button_new_with_label ("Save Settings"); |
---|
48 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (save_settings_button), orxonox_settings->exec_save_settings); |
---|
49 | g_signal_connect(GTK_TOGGLE_BUTTON(save_settings_button), "clicked", G_CALLBACK(exec_check_button_change), &(orxonox_settings->exec_save_settings)); |
---|
50 | gtk_box_pack_start(GTK_BOX (setting_box), save_settings_button, TRUE, TRUE, 0); |
---|
51 | |
---|
52 | { |
---|
53 | GtkWidget *opt; |
---|
54 | GtkWidget *menu; |
---|
55 | GtkWidget *item; |
---|
56 | |
---|
57 | opt = gtk_option_menu_new (); |
---|
58 | menu = gtk_menu_new (); |
---|
59 | |
---|
60 | item = gtk_menu_item_new_with_label ("no verbose"); |
---|
61 | g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (exec_verbose_mode_change), GINT_TO_POINTER(0)); |
---|
62 | gtk_menu_shell_append(GTK_MENU_SHELL (menu), item); |
---|
63 | |
---|
64 | item = gtk_menu_item_new_with_label ("verbose"); |
---|
65 | g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (exec_verbose_mode_change), GINT_TO_POINTER(1)); |
---|
66 | gtk_menu_shell_append(GTK_MENU_SHELL (menu), item); |
---|
67 | |
---|
68 | item = gtk_menu_item_new_with_label ("debug"); |
---|
69 | g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (exec_verbose_mode_change), GINT_TO_POINTER(2)); |
---|
70 | gtk_menu_shell_append(GTK_MENU_SHELL (menu), item); |
---|
71 | |
---|
72 | gtk_option_menu_set_menu (GTK_OPTION_MENU (opt), menu); |
---|
73 | gtk_option_menu_set_history (GTK_OPTION_MENU (opt), verbose); |
---|
74 | gtk_box_pack_start (GTK_BOX (setting_box), opt, TRUE, TRUE, 0); |
---|
75 | |
---|
76 | } |
---|
77 | } |
---|
78 | gtk_box_pack_start(GTK_BOX(orxonox_gui_exec_vbox), setting_box, TRUE, TRUE, 0); |
---|
79 | show_menu_button = gtk_check_button_new_with_label ("Always show this Menu"); |
---|
80 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (show_menu_button), orxonox_settings->exec_show_menu); |
---|
81 | g_signal_connect(GTK_TOGGLE_BUTTON(show_menu_button), "clicked", G_CALLBACK(exec_check_button_change), &(orxonox_settings->exec_show_menu)); |
---|
82 | gtk_box_pack_start(GTK_BOX (orxonox_gui_exec_vbox), show_menu_button, TRUE, TRUE, 0); |
---|
83 | |
---|
84 | quit_button = gtk_button_new_with_label ("quit"); |
---|
85 | g_signal_connect(GTK_BUTTON(quit_button), "clicked", G_CALLBACK(gtk_main_quit), NULL); |
---|
86 | gtk_box_pack_start(GTK_BOX (orxonox_gui_exec_vbox), quit_button, FALSE, FALSE, 5); |
---|
87 | |
---|
88 | |
---|
89 | flags_frame = gtk_frame_new("Orxonox's starting Flags"); |
---|
90 | { |
---|
91 | exec_flags_label = gtk_label_new("test"); |
---|
92 | exec_orxonox_settings = orxonox_settings; |
---|
93 | orxonox_flags_update(); |
---|
94 | gtk_container_add (GTK_CONTAINER(flags_frame), exec_flags_label); |
---|
95 | |
---|
96 | } |
---|
97 | gtk_box_pack_start(GTK_BOX (orxonox_gui_exec_vbox), flags_frame, FALSE, FALSE, 5); |
---|
98 | } |
---|
99 | gtk_container_add(GTK_CONTAINER(frame), orxonox_gui_exec_vbox); |
---|
100 | } |
---|
101 | |
---|
102 | return frame; |
---|
103 | |
---|
104 | } |
---|
105 | |
---|
106 | |
---|
107 | char * orxonox_flags_text (struct settings *orxonox_settings, char *exec_flags_text) |
---|
108 | { |
---|
109 | char temp [50]; |
---|
110 | bzero(exec_flags_text, 1); |
---|
111 | strcat(exec_flags_text, "orxonox "); |
---|
112 | |
---|
113 | if(!orxonox_settings->video_fullscreen) |
---|
114 | strcat(exec_flags_text, "--windowed "); |
---|
115 | if(orxonox_settings->video_wireframe) |
---|
116 | strcat(exec_flags_text, "--wireframe "); |
---|
117 | |
---|
118 | if(!orxonox_settings->audio_enable_sound) |
---|
119 | strcat(exec_flags_text, "--disable_audio "); |
---|
120 | if(orxonox_settings->audio_music_volume != 80) |
---|
121 | { |
---|
122 | strcat(exec_flags_text, "--music_volume="); |
---|
123 | sprintf(temp, "%i ", (int) orxonox_settings->audio_music_volume); |
---|
124 | strcat(exec_flags_text, temp); |
---|
125 | } |
---|
126 | if(orxonox_settings->audio_effects_volume != 80) |
---|
127 | { |
---|
128 | strcat(exec_flags_text, "--effects_volume= "); |
---|
129 | sprintf(temp, "%i ", (int) orxonox_settings->audio_effects_volume); |
---|
130 | strcat(exec_flags_text, temp); |
---|
131 | } |
---|
132 | return (exec_flags_text); |
---|
133 | } |
---|
134 | |
---|
135 | void orxonox_flags_update (void) |
---|
136 | { |
---|
137 | char exec_flags_text[1024]; |
---|
138 | gtk_label_set_text (GTK_LABEL(exec_flags_label), orxonox_flags_text (exec_orxonox_settings, exec_flags_text)); |
---|
139 | return; |
---|
140 | } |
---|