void network_init (void) { GGZMod *mod; GIOChannel *channel; int ret, ggzmodfd; if (!ggzmod_is_ggz_mode ()) return; mod = ggzmod_new (GGZMOD_GAME); ggzmod_set_handler (mod, GGZMOD_EVENT_SERVER, handle_ggzmod_server); ret = ggzmod_connect (mod); if (ret != 0) { /* Error: GGZ core client error (e.g. faked GGZMODE env variable) */ return; } ggzmodfd = ggzmod_get_fd (mod); channel = g_io_channel_unix_new (ggzmodfd); g_io_add_watch (channel, G_IO_IN, handle_ggzmod, mod); ggzcomm_set_notifier_callback (network_message_cb); ggzcomm_set_error_callback (network_error_cb); init_chat (mod); init_player_list (mod); ggz_network_mode = TRUE; }
void ttent::pre_show(CVideo& /*video*/, twindow& window) { rpg_mode_ = campaign_config_["mode"].str() == "rpg"; tlistbox* list = find_widget<tlistbox>(&window, "player_list", false, false); if (list) { init_player_list(*list, window); VALIDATE(list->get_item_count(), _("ttent::pre_show, there is no item in player_list!")); } list = find_widget<tlistbox>(&window, "faction_list", false, false); if (list) { init_faction_list(*list, window); } // card table size_t card_size = cards_.size(); if (!card_size) { return; } std::stringstream strstr; card_table_ = find_widget<tlistbox>(&window, "card_table", false, true); int card_index = 0; for (card_map::iterator c = cards_.begin(); c != cards_.end(); ++ c, card_index ++) { if (!card_valid(c->mode()) || c->bomb()) { checked_card_.insert(std::make_pair(card_index, false)); continue; } /*** Add list item ***/ string_map list_item; std::map<std::string, string_map> list_item_item; list_item["label"] = c->name(); list_item_item.insert(std::make_pair("name", list_item)); strstr.str(""); strstr << c->points(); list_item["label"] = strstr.str(); list_item_item.insert(std::make_pair("points", list_item)); list_item["label"] = c->desc(); list_item_item.insert(std::make_pair("desc", list_item)); card_table_->add_row(list_item_item); tgrid* grid_ptr = card_table_->get_row_grid(card_table_->get_item_count() - 1); ttoggle_button* toggle = dynamic_cast<ttoggle_button*>(grid_ptr->find("prefix", true)); toggle->set_callback_state_change(boost::bind(&ttent::card_toggled, this, _1)); toggle->set_data(card_index); toggle->set_value(true); checked_card_.insert(std::make_pair(card_index, true)); } }