int main(int argc, char *argv[]) { g_type_init(); g_thread_init(NULL); /* Set signal handlers */ signal(SIGINT, main_signal_handler); signal(SIGTERM, main_signal_handler); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_ref(mainloop); maxfd = sib_maxfd_new(); rm_handler = nota_rm_handler_new( maxfd ); control = create_control(rm_handler); if(!control) { printf("\n\nCould not create control channel to sib-daemon, daemon running properly?\n"); exit(1); } g_main_loop_run(mainloop); g_main_loop_unref(mainloop); printf("\n\nExiting normally\n\n"); exit (0); }
Control * Runner::control( const std::string & path ) { std::map<std::string, Control*>::iterator it = m_shared->controls.find(path); if (it != m_shared->controls.end()) return it->second; else return create_control( path ); }
static Test * create_test (gboolean fake_remote) { Test *test = g_new0 (Test, 1); create_control (test); create_frame (test, fake_remote); return test; }
/** * Creates the window component - should be one as root of UI Tree * * @param children component's children */ Control* create_window(Link* children_head) { SDL_WM_SetCaption(HEADING, HEADING); SDL_Surface* view = SDL_SetVideoMode(WIN_W, WIN_H, 0, SDL_HWSURFACE | SDL_DOUBLEBUF); if (view == NULL ) { printf("ERROR: Failed to set video mode: %s\n", SDL_GetError()); return NULL ; } return create_control(0, 0, 0, 0, WIN_W, WIN_H, children_head, view, empty_select, draw_children); }
/** * Creates a label control * * @param label_path Path to find pic representing the label. * Loads the pic and draws it. */ Control* create_label(int x, int y, int i, int j, int width, int height, char* label_path) { SDL_Surface *img = load_image(label_path); if (img == NULL ) { img = create_text(label_path, width, height); if (img == NULL) { return 0; } } return create_control(x, y, i, j, width, height, NULL, img, empty_select, draw_leaf); }
/** * Creates a button control * * @param label_path Path to find pic representing the label. * @param children Controls needed when button is selected. * Could be the destination control or controls to be freed. * @param on_select Function to be called when the button is selected */ Control* create_button(int x, int y, int i, int j, int width, int height, char* label_path, int (*on_select)(struct Control*)) { SDL_Surface *img = load_image(label_path); if (img == NULL ) { // Could not load image - assume it is meant to be text img = create_text(label_path, width, height); if (img == NULL) { return 0; } } return create_control(x, y, i, j, width, height, NULL, img, on_select, draw_leaf); }
/** * Create a panel control * * @param children Children controls to appear in the panel * @param x, y Position, relative to parent * @param R, G, B Background colour numbers (RGB) for the parts of the panel shown */ Control* create_panel(int x, int y, int i, int j, int width, int height, char* bg_path, Link* children_head) { Control* panel; SDL_Surface *img; if (children_head == NULL) { return NULL; } img = load_image(bg_path); if (img == NULL ) { printf("ERROR: failed to load image: %s\n", SDL_GetError()); return NULL ; } panel = create_control(x, y, i, j, width, height, children_head, img, empty_select, draw_node); if (panel == NULL) { free_UI_children(children_head); } return panel; }
void NormalGame::init(Log *_log) { STACKTRACE; Game::init(_log); team_table_size = 0; view->window->locate(0,0,0,0,0,0.9,0,1); tw_delete_file(home_ini_full_path("tmp.ini")); tw_delete_file(home_ini_full_path("fleets.tmp")); tw_set_config_file(home_ini_full_path("tmp.ini")); set_config_string (NULL, "Ignorethis", ""); if (!log->playback) init_players(); log_file(home_ini_full_path("tmp.ini")); if (log->playback) { for (int i = 0; true; i += 1) { char buffy[64]; sprintf(buffy, "Player%d", i + 1); log_file(home_ini_full_path("tmp.ini")); const char *type = get_config_string(buffy, "Type", NULL); if (!type) break; const char *name = get_config_string(buffy, "Name", buffy); int channel = get_config_int(buffy, "Channel", -2); int ti = get_config_int(buffy, "Team", 0); add_player(create_control(channel, type), ti, name, buffy); player_fleet[i]->load(NULL, buffy); player_fleet[i]->save("fleets.tmp", buffy); } } prepare(); init_objects(); next_choose_new_ships_time = game_time + 200; // team and health indicators. indteamtoggle = 0; indhealthtoggle = 0; return; }
void MulticastDataLink::syn_received_no_session(MulticastPeer source, ACE_Message_Block* data, bool swap_bytes) { Serializer serializer_read(data, swap_bytes); MulticastPeer local_peer; serializer_read >> local_peer; if (local_peer != local_peer_) { return; } VDBG_LVL((LM_DEBUG, "(%P|%t) MulticastDataLink[%C]::syn_received_no_session " "send_synack local 0x%x remote 0x%x\n", config_->name().c_str(), local_peer, source), 2); ACE_Message_Block* synack_data = new ACE_Message_Block(sizeof(MulticastPeer)); Serializer serializer_write(synack_data); serializer_write << source; DataSampleHeader header; ACE_Message_Block* control = create_control(MULTICAST_SYNACK, header, synack_data); const int error = send_control(header, control); if (error != SEND_CONTROL_OK) { ACE_ERROR((LM_ERROR, "(%P|%t) MulticastDataLink::syn_received_no_session: " "ERROR: send_control failed: %d!\n", error)); return; } transport_->passive_connection(local_peer, source); }
int main(int argc,char ** argv){ if(al_init()<0){ //fonction d'initialisation fprintf(stderr,"Error at the initialisation of Allegro"); return -1; } if(!al_init_image_addon() ) { printf("addon Error"); return 0; } options=create_options(); load_options(options,"Options.txt"); screen=create_screen(options); control=create_control(screen); ALLEGRO_BITMAP * bg_picture=NULL; bg_picture = al_load_bitmap("./Ressources/Pictures/test.png"); ALLEGRO_BITMAP * image_titre_d=NULL; image_titre_d =al_load_bitmap("./Ressources/Pictures/play_d.png"); ALLEGRO_BITMAP * image_titre_s=NULL; image_titre_s=al_load_bitmap("./Ressources/Pictures/play_s.png"); /** DEBUT ALLEGRO_BITMAP * image_credit_d=NULL; image_credit_d =al_load_bitmap("./ressource/image/credit_d.png"); ALLEGRO_BITMAP * image_credit_s=NULL; image_credit_s=al_load_bitmap("./ressource/image/credit_s.png"); ALLEGRO_BITMAP * image_quitter_d=NULL; image_quitter_d =al_load_bitmap("./ressource/image/quitter_d.png"); ALLEGRO_BITMAP * image_quitter_s=NULL; image_quitter_s=al_load_bitmap("./ressource/image/quitter_s.png"); */ if (!bg_picture || !image_titre_d || !image_titre_s){ printf("bug image\n"); } struct Title *titles=malloc(sizeof(struct Title)*1); struct Menu * menu=create_menu(bg_picture,titles,create_column_position(1,200,300,300),1); //struct Control* control=creer_control(ecran); /** DEBUT void (*p)(void); void jouer(){ partie = creer_partie(); lancer_jeu(partie);} void credits(){ ALLEGRO_BITMAP * image_credits=NULL; image_credits = al_load_bitmap("./ressource/image/credits.png"); al_draw_bitmap(image_credits,0,0,0); al_flip_display(); al_rest(5.0); } void quitter(){quitter_jeu(partie);} p=jouer; titres[0]=*creer_titre(image_titre_s,image_titre_d,*p); p=credits; titres[1]=*creer_titre(image_credit_s,image_credit_d,*p); p=quitter; titres[2]=*creer_titre(image_quitter_s,image_quitter_d,*p); */ void (*p)(void); void f(){control_menu(menu,control);}
gint main (gint argc, gchar **argv) { GtkWidget *window; GtkWidget *scrolled_window; GtkWidget *tree_view; GtkWidget *vbox, *hbox, *cntl_vbox; GtkTreeModel *tree_model; GtkCellRenderer *renderer; GtkTreeViewColumn *column; GtkCellArea *area; CallbackData callback[4]; gtk_init (&argc, &argv); if (g_getenv ("RTL")) gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "GtkTreeView editing sample"); g_signal_connect (window, "destroy", gtk_main_quit, NULL); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); gtk_widget_show (vbox); gtk_container_add (GTK_CONTAINER (window), vbox); scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_ETCHED_IN); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0); tree_model = create_model (); tree_view = gtk_tree_view_new_with_model (tree_model); g_signal_connect (tree_view, "button_press_event", G_CALLBACK (button_press_event), NULL); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), TRUE); column = gtk_tree_view_column_new (); gtk_tree_view_column_set_title (column, "String"); area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (column)); renderer = gtk_cell_renderer_pixbuf_new (); gtk_tree_view_column_pack_start (column, renderer, FALSE); gtk_tree_view_column_set_attributes (column, renderer, "icon-name", ICON_NAME_COLUMN, "sensitive", IS_SENSITIVE_COLUMN, NULL); callback[0].area = area; callback[0].renderer = renderer; renderer = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (column, renderer, FALSE); gtk_tree_view_column_set_attributes (column, renderer, "text", STRING_COLUMN, "editable", IS_EDITABLE_COLUMN, "sensitive", IS_SENSITIVE_COLUMN, NULL); callback[1].area = area; callback[1].renderer = renderer; g_signal_connect (renderer, "edited", G_CALLBACK (edited), tree_model); g_object_set (renderer, "placeholder-text", "Type here", NULL); renderer = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (column, renderer, FALSE); gtk_tree_view_column_set_attributes (column, renderer, "text", STRING_COLUMN, "editable", IS_EDITABLE_COLUMN, "sensitive", IS_SENSITIVE_COLUMN, NULL); callback[2].area = area; callback[2].renderer = renderer; g_signal_connect (renderer, "edited", G_CALLBACK (edited), tree_model); g_object_set (renderer, "placeholder-text", "Type here too", NULL); renderer = gtk_cell_renderer_pixbuf_new (); g_object_set (renderer, "xalign", 0.0, NULL); gtk_tree_view_column_pack_start (column, renderer, FALSE); gtk_tree_view_column_set_attributes (column, renderer, "icon-name", LAST_ICON_NAME_COLUMN, "sensitive", IS_SENSITIVE_COLUMN, NULL); callback[3].area = area; callback[3].renderer = renderer; gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); renderer = gtk_cell_renderer_toggle_new (); g_signal_connect (renderer, "toggled", G_CALLBACK (editable_toggled), tree_model); g_object_set (renderer, "xalign", 0.0, NULL); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), -1, "Editable", renderer, "active", IS_EDITABLE_COLUMN, NULL); renderer = gtk_cell_renderer_toggle_new (); g_signal_connect (renderer, "toggled", G_CALLBACK (sensitive_toggled), tree_model); g_object_set (renderer, "xalign", 0.0, NULL); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), -1, "Sensitive", renderer, "active", IS_SENSITIVE_COLUMN, NULL); renderer = gtk_cell_renderer_progress_new (); gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), -1, "Progress", renderer, "value", PROGRESS_COLUMN, NULL); gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view); gtk_window_set_default_size (GTK_WINDOW (window), 800, 250); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_widget_show (hbox); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); /* Alignment controls */ cntl_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); gtk_widget_show (cntl_vbox); gtk_box_pack_start (GTK_BOX (hbox), cntl_vbox, FALSE, FALSE, 0); create_control (cntl_vbox, 1, CNTL_ALIGN, &callback[0]); create_control (cntl_vbox, 2, CNTL_ALIGN, &callback[1]); create_control (cntl_vbox, 3, CNTL_ALIGN, &callback[2]); create_control (cntl_vbox, 4, CNTL_ALIGN, &callback[3]); /* Expand controls */ cntl_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); gtk_widget_show (cntl_vbox); gtk_box_pack_start (GTK_BOX (hbox), cntl_vbox, FALSE, FALSE, 0); create_control (cntl_vbox, 1, CNTL_EXPAND, &callback[0]); create_control (cntl_vbox, 2, CNTL_EXPAND, &callback[1]); create_control (cntl_vbox, 3, CNTL_EXPAND, &callback[2]); create_control (cntl_vbox, 4, CNTL_EXPAND, &callback[3]); /* Fixed controls */ cntl_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); gtk_widget_show (cntl_vbox); gtk_box_pack_start (GTK_BOX (hbox), cntl_vbox, FALSE, FALSE, 0); create_control (cntl_vbox, 1, CNTL_FIXED, &callback[0]); create_control (cntl_vbox, 2, CNTL_FIXED, &callback[1]); create_control (cntl_vbox, 3, CNTL_FIXED, &callback[2]); create_control (cntl_vbox, 4, CNTL_FIXED, &callback[3]); gtk_widget_show_all (window); gtk_main (); return 0; }
void NormalGame::init_players() { STACKTRACE; switch (log->type) { case Log::log_normal: { for (int i = 0; true; i += 1) { char buffy[64]; sprintf(buffy, "Player%d", i + 1); tw_set_config_file("scp.ini"); const char *type = get_config_string(buffy, "Type", NULL); if (!type) break; if (strcmp(type, "none") == 0) continue; const char *name = get_config_string(buffy, "Name", buffy); char config[64]; sprintf(config, "Config%d", get_config_int(buffy, "Config", 0)); //int channel = channel_server; //if (strcmp(type, "WussieBot") == 0) channel = channel_none; //if (strcmp(type, "MoronBot") == 0) channel = channel_none; int ti = get_config_int(buffy, "Team", 0); add_player(create_control(channel_server, type, config), ti, name, buffy); } } break; case Log::log_net1client: case Log::log_net1server: { log_file(home_ini_full_path("server.ini")); //int use_teams_menu = get_config_int("Network", "NetworkMeleeUseTeams", 0); //if (use_teams_menu) { if (1) { int j; for (j = 0; j < 2; j += 1) { int ch; if (j == 0) ch = channel_server; else ch = channel_client; if (is_local(ch)) { //each side determines whether they are using manually specified teams tw_set_config_file("client.ini"); int use_teams_menu = get_config_int("Network", "NetworkMeleeUseTeams", 0); const char *simple_config = "[Player1]\nType=Human\nConfig=0\nTeam=0\n"; for (int i = 0; true; i += 1) { char buffy[64]; sprintf(buffy, "Player%d", i + 1); if (use_teams_menu) tw_set_config_file("scp.ini"); else set_config_data(simple_config, strlen(simple_config)); const char *type = get_config_string(buffy, "Type", NULL); if (!type) { int tmp = 0; log_int(ch, tmp); break; } if (strcmp(type, "none") == 0) continue; const char *name = get_config_string(buffy, "Name", buffy); char config[64]; sprintf(config, "Config%d", get_config_int(buffy, "Config", 0)); //int channel = channel_server; //if (strcmp(type, "WussieBot") == 0) channel = channel_none; //if (strcmp(type, "MoronBot") == 0) channel = channel_none; int ti = get_config_int(buffy, "Team", 0); {int tmp = 1; log_int(ch, tmp);} log_int(ch, ti); int name_length = strlen(name); log_int(ch, name_length); log_data(ch, (char*)name, name_length); add_player(create_control(ch, type, config), ti, name, buffy); } } else { for (int i = 0; true; i += 1) { int tmp; log_int(ch, tmp); if (tmp == 0) break; int team; char *name; log_int(ch, team); int name_length; log_int(ch, name_length); name = (char*)malloc((name_length+1)*sizeof(char)); log_data(ch, name, name_length); name[name_length] = 0; add_player(create_control(ch, "Whatever"), team, name, NULL); } } } } } break; } return; }
void GobGame::init(Log *_log) { STACKTRACE; int i; /* switch(_log->type) { // case Log::log_net1server: // case Log::log_net1client: { // error("unsupported game/log type"); // } // break; default: { } break; }/**/ Game::init(_log); log_file(home_ini_full_path("server.ini")); max_enemies = get_config_int("Gob", "MaxEnemies", 32); int starting_starbucks, starting_buckazoids; starting_starbucks = get_config_int("Gob", "StartingStarbucks", 0); starting_buckazoids = get_config_int("Gob", "StartingBuckazoids", 0); gobenemy = (GobEnemy**) malloc(sizeof(GobEnemy*) * max_enemies); size = Vector2(24000, 24000); enemy_team = new_team(); station_team = new_team(); // set_resolution(videosystem.width, videosystem.height); TW_DATAFILE *tmpdata; tmpdata = tw_load_datafile_object(data_full_path("gob.dat").c_str(), "station0sprite"); if (!tmpdata) tw_error( "couldn't find gob.dat#station0sprite"); stationSprite[0] = new SpaceSprite(tmpdata, 1, SpaceSprite::MASKED | SpaceSprite::MIPMAPED, 64); tw_unload_datafile_object(tmpdata); stationSprite[0]->permanent_phase_shift(8); tmpdata = tw_load_datafile_object(data_full_path("gob.dat").c_str(), "station1sprite"); if (!tmpdata) tw_error ("couldn't find gob.dat#station1sprite"); stationSprite[1] = new SpaceSprite(tmpdata, 1, SpaceSprite::MASKED | SpaceSprite::MIPMAPED, 64); tw_unload_datafile_object(tmpdata); stationSprite[1]->permanent_phase_shift(8); tmpdata = tw_load_datafile_object(data_full_path("gob.dat").c_str(), "station2sprite"); if (!tmpdata) tw_error ("couldn't find gob.dat#station2sprite"); stationSprite[2] = new SpaceSprite(tmpdata, 1, SpaceSprite::MASKED | SpaceSprite::MIPMAPED, 64); tw_unload_datafile_object(tmpdata); stationSprite[2]->permanent_phase_shift(8); tmpdata = tw_load_datafile_object(data_full_path("gob.dat").c_str(), "defender"); if (!tmpdata) tw_error ("couldn't find gob.dat#defender"); defenderSprite = new SpaceSprite(tmpdata, 1, SpaceSprite::MASKED | SpaceSprite::MIPMAPED); tw_unload_datafile_object(tmpdata); station_pic_name[0] = "gob.dat#station0picture.bmp"; station_pic_name[1] = "gob.dat#station1picture.bmp"; station_pic_name[2] = "gob.dat#station2picture.bmp"; station_build_name[0] = "supbl"; station_build_name[1] = "orzne"; station_build_name[2] = "kohma"; prepare(); add(new Stars()); num_planets = 0; i = 0; add_planet_and_station(meleedata.planetSprite, i, stationSprite[i], station_build_name[i], station_pic_name[i]); i = 1; add_planet_and_station(meleedata.planetSprite, i, stationSprite[i], station_build_name[i], station_pic_name[i]); i = 2; add_planet_and_station(meleedata.planetSprite, i, stationSprite[i], station_build_name[i], station_pic_name[i]); i = random() % 3; add_planet_and_station(meleedata.planetSprite, i, stationSprite[i], "utwju", station_pic_name[i]); for (i = 0; i < 42; i += 1) add(new GobAsteroid()); int server_players, client_players; set_config_file("client.ini"); server_players = client_players = get_config_int("Gob", "NumPlayers", 1); if (!lag_frames) client_players = 0; log_int(channel_server, server_players); log_int(channel_client, client_players); for (i = 0; i < server_players; i += 1) { char buffy[256]; sprintf(buffy, "Config%d", i); add_gobplayer(create_control(channel_server, "Human", buffy)); gobplayer[i]->new_ship(shiptype("supbl")); gobplayer[i]->starbucks = starting_starbucks+0; gobplayer[i]->buckazoids = starting_buckazoids+0; Ship *s = gobplayer[i]->ship; s->translate(size/2-s->normal_pos()); double angle = PI2 * i / (client_players + server_players); s->translate(rotate(Vector2(260, 120), angle)); s->accelerate(s, PI2/3 + angle, 0.17, MAX_SPEED); } for (i = server_players; i < client_players + server_players; i += 1) { char buffy[256]; sprintf(buffy, "Config%d", i - server_players); add_gobplayer(create_control(channel_client, "Human", buffy)); gobplayer[i]->new_ship(shiptype("supbl")); gobplayer[i]->starbucks = starting_starbucks; gobplayer[i]->buckazoids = starting_buckazoids; Ship *s = gobplayer[i]->ship; s->translate(size/2-s->normal_pos()); double angle = PI2 * i / (client_players + server_players); s->translate(rotate(Vector2(260, 120), angle)); s->accelerate(s, PI2/3 + angle, 0.17, MAX_SPEED); } for (i = 0; i < gobplayers+0; i += 1) add ( new RainbowRift() ); next_add_new_enemy_time = 1000; this->change_view("Hero"); //view = get_view ( "Hero", NULL ); view_locked = true; view->window->locate( 0,0, 0,0, 0,0.9, 0,1 ); add_new_enemy(); add_new_enemy(); return; }