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