1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
|
#include <glib.h>
#include <gtk/gtk.h>
#include <iostream>
using namespace std;
#ifndef CONNECT4MENU_H
#define CONNECT4MENU_H
static gboolean deleteEvent( GtkWidget *widget, GdkEvent *event, gpointer data);
static int startGame(GtkWidget *widget, GdkEvent *event, gpointer data);
static int gui();
GtkWidget *window;
GtkWidget *button;
GtkWidget *button2;
GtkWidget *button3;
GtkWidget *button4;
GtkWidget *button5;
GtkWidget *button6;
GtkWidget *box1;
GtkWidget *box2;
GtkWidget *box3;
GtkWidget *box4;
GtkWidget *box5;
GtkWidget *box6;
GSList *group;
GSList *group2;
int gamet = 0;
static int gui()
{
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(deleteEvent), NULL);
box3 = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(window), box3);
gtk_widget_show(box3);
box1 = gtk_hbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(box3), box1);
gtk_widget_show(box1);
button = gtk_radio_button_new_with_label(NULL, "1 Player");
gtk_box_pack_start(GTK_BOX(box1), button, TRUE, TRUE, 0);
gtk_widget_show(button);
group = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button));
button2 = gtk_radio_button_new_with_label(group, "2 Player");
gtk_box_pack_start(GTK_BOX(box1), button2, TRUE, TRUE, 0);
gtk_widget_show(button2);
box4 = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(box3), box4);
gtk_widget_show(box4);
box2 = gtk_hbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(box4), box2);
gtk_widget_show(box2);
button3 = gtk_radio_button_new_with_label(NULL, "Easy");
gtk_box_pack_start(GTK_BOX(box2), button3, TRUE, TRUE, 0);
gtk_widget_show(button3);
group2 = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button3));
button4 = gtk_radio_button_new_with_label(group2, "Medium");
gtk_box_pack_start(GTK_BOX(box2), button4, TRUE, TRUE, 0);
gtk_widget_show(button4);
group2 = gtk_radio_button_get_group(GTK_RADIO_BUTTON(button4));
button5 = gtk_radio_button_new_with_label(group2, "Expert");
gtk_box_pack_start(GTK_BOX(box2), button5, TRUE, TRUE, 0);
gtk_widget_show(button5);
box5 = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(box4), box5);
gtk_widget_show(box5);
button6 = gtk_button_new_with_label ("Start Game");
g_signal_connect (G_OBJECT (button6), "clicked", G_CALLBACK (startGame), NULL);
gtk_box_pack_start(GTK_BOX (box5), button6, TRUE, TRUE, 0);
gtk_widget_show(button6);
gtk_widget_show(window);
gtk_main();
}
static gboolean deleteEvent(GtkWidget *widget, GdkEvent *event, gpointer data)
{
gtk_main_quit();
return FALSE;
}
static int startGame(GtkWidget *widget, GdkEvent *event, gpointer data)
{
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button)))
{
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button3)))
{
gamet = 1;
gtk_main_quit();
}
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button4)))
{
gamet = 2;
gtk_main_quit();
}
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button5)))
{
gamet = 3;
gtk_main_quit();
}
}
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button2)))
{
gamet = 4;
gtk_main_quit();
}
}
#endif
|