mirror of https://github.com/tstellar/bygfoot.git
"Startup leaguges."
This commit is contained in:
parent
0d3194bde1
commit
401195ef6e
|
@ -178,7 +178,7 @@
|
||||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||||
<property name="wrap">False</property>
|
<property name="wrap">False</property>
|
||||||
<property name="selectable">False</property>
|
<property name="selectable">False</property>
|
||||||
<property name="xalign">0.05</property>
|
<property name="xalign">0.5</property>
|
||||||
<property name="yalign">0.5</property>
|
<property name="yalign">0.5</property>
|
||||||
<property name="xpad">0</property>
|
<property name="xpad">0</property>
|
||||||
<property name="ypad">0</property>
|
<property name="ypad">0</property>
|
||||||
|
@ -191,23 +191,8 @@
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkHBox" id="hbox2">
|
<widget class="GtkComboBoxEntry" id="comboboxentry_start_league">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="homogeneous">False</property>
|
|
||||||
<property name="spacing">0</property>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkRadioButton" id="team_selection_radio1">
|
|
||||||
<property name="border_width">3</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="label" translatable="yes">Top league</property>
|
|
||||||
<property name="use_underline">True</property>
|
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
|
||||||
<property name="focus_on_click">True</property>
|
|
||||||
<property name="active">False</property>
|
|
||||||
<property name="inconsistent">False</property>
|
|
||||||
<property name="draw_indicator">True</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="padding">0</property>
|
<property name="padding">0</property>
|
||||||
|
@ -216,55 +201,6 @@
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkRadioButton" id="team_selection_radio2">
|
|
||||||
<property name="border_width">3</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="label" translatable="yes">Current league</property>
|
|
||||||
<property name="use_underline">True</property>
|
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
|
||||||
<property name="focus_on_click">True</property>
|
|
||||||
<property name="active">True</property>
|
|
||||||
<property name="inconsistent">False</property>
|
|
||||||
<property name="draw_indicator">True</property>
|
|
||||||
<property name="group">team_selection_radio1</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkRadioButton" id="team_selection_radio3">
|
|
||||||
<property name="border_width">3</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="label" translatable="yes">Bottom league</property>
|
|
||||||
<property name="use_underline">True</property>
|
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
|
||||||
<property name="focus_on_click">True</property>
|
|
||||||
<property name="active">False</property>
|
|
||||||
<property name="inconsistent">False</property>
|
|
||||||
<property name="draw_indicator">True</property>
|
|
||||||
<property name="group">team_selection_radio1</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">0</property>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="padding">5</property>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">True</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkHSeparator" id="hseparator12">
|
<widget class="GtkHSeparator" id="hseparator12">
|
||||||
<property name="width_request">1</property>
|
<property name="width_request">1</property>
|
||||||
|
@ -287,7 +223,7 @@
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkLabel" id="label75">
|
<widget class="GtkLabel" id="label75">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="label" translatable="yes">Player name</property>
|
<property name="label" translatable="yes">Username</property>
|
||||||
<property name="use_underline">False</property>
|
<property name="use_underline">False</property>
|
||||||
<property name="use_markup">False</property>
|
<property name="use_markup">False</property>
|
||||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||||
|
|
|
@ -28,6 +28,8 @@ misc_callback_show_team_list(GtkWidget *widget, const gchar *country_file)
|
||||||
xml_country_read(country_file);
|
xml_country_read(country_file);
|
||||||
|
|
||||||
treeview_show_team_list(GTK_TREE_VIEW(treeview_startup), FALSE, FALSE);
|
treeview_show_team_list(GTK_TREE_VIEW(treeview_startup), FALSE, FALSE);
|
||||||
|
|
||||||
|
treeview_show_leagues_combo();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Start a new game after users and teams are selected. */
|
/** Start a new game after users and teams are selected. */
|
||||||
|
@ -54,41 +56,38 @@ misc_callback_start_game(void)
|
||||||
void
|
void
|
||||||
misc_callback_add_player(void)
|
misc_callback_add_player(void)
|
||||||
{
|
{
|
||||||
GtkToggleButton *team_selection_radio1 =
|
|
||||||
GTK_TOGGLE_BUTTON(lookup_widget(window.startup, "team_selection_radio1"));
|
|
||||||
GtkToggleButton *team_selection_radio2 =
|
|
||||||
GTK_TOGGLE_BUTTON(lookup_widget(window.startup, "team_selection_radio2"));
|
|
||||||
GtkTreeView *treeview_users =
|
GtkTreeView *treeview_users =
|
||||||
GTK_TREE_VIEW(lookup_widget(window.startup, "treeview_users"));
|
GTK_TREE_VIEW(lookup_widget(window.startup, "treeview_users"));
|
||||||
GtkTreeView *treeview_startup =
|
GtkTreeView *treeview_startup =
|
||||||
GTK_TREE_VIEW(lookup_widget(window.startup, "treeview_startup"));
|
GTK_TREE_VIEW(lookup_widget(window.startup, "treeview_startup"));
|
||||||
GtkEntry *entry_player_name =
|
GtkEntry *entry_player_name =
|
||||||
GTK_ENTRY(lookup_widget(window.startup, "entry_player_name"));
|
GTK_ENTRY(lookup_widget(window.startup, "entry_player_name"));
|
||||||
|
GtkComboBox *combo_leagues =
|
||||||
|
GTK_COMBO_BOX(lookup_widget(window.startup, "comboboxentry_start_league"));
|
||||||
const gchar *player_name = gtk_entry_get_text(entry_player_name);
|
const gchar *player_name = gtk_entry_get_text(entry_player_name);
|
||||||
User new_user = user_new();
|
User new_user = user_new();
|
||||||
Team *tm = (Team*)treeview_helper_get_pointer(treeview_startup, 2);
|
Team *tm = (Team*)treeview_helper_get_pointer(treeview_startup, 2);
|
||||||
|
gint start_league =
|
||||||
|
gtk_combo_box_get_active(combo_leagues);
|
||||||
|
|
||||||
if(strlen(player_name) > 0)
|
if(strlen(player_name) > 0)
|
||||||
g_string_printf(new_user.name, "%s", player_name);
|
g_string_printf(new_user.name, "%s", player_name);
|
||||||
|
|
||||||
gtk_entry_set_text(entry_player_name, "");
|
gtk_entry_set_text(entry_player_name, "");
|
||||||
|
|
||||||
if(gtk_toggle_button_get_active(team_selection_radio1))
|
|
||||||
new_user.scout = 1;
|
|
||||||
else if(gtk_toggle_button_get_active(team_selection_radio2))
|
|
||||||
new_user.scout = 0;
|
|
||||||
else
|
|
||||||
new_user.scout = -1;
|
|
||||||
|
|
||||||
new_user.tm = tm;
|
new_user.tm = tm;
|
||||||
new_user.team_id = tm->id;
|
new_user.team_id = tm->id;
|
||||||
|
|
||||||
|
new_user.scout = (start_league == 0 || tm->clid == lig(start_league - 1).id) ? -1 : start_league - 1;
|
||||||
|
|
||||||
g_array_append_val(users, new_user);
|
g_array_append_val(users, new_user);
|
||||||
|
|
||||||
treeview_show_users(treeview_users);
|
treeview_show_users(treeview_users);
|
||||||
|
|
||||||
treeview_show_team_list(treeview_startup, FALSE, FALSE);
|
treeview_show_team_list(treeview_startup, FALSE, FALSE);
|
||||||
|
|
||||||
|
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_leagues), 0);
|
||||||
|
|
||||||
if(users->len == 1)
|
if(users->len == 1)
|
||||||
{
|
{
|
||||||
gtk_widget_set_sensitive(lookup_widget(window.startup, "team_selection_ok"), TRUE);
|
gtk_widget_set_sensitive(lookup_widget(window.startup, "team_selection_ok"), TRUE);
|
||||||
|
|
|
@ -42,11 +42,7 @@ create_window_startup (void)
|
||||||
GtkWidget *combo_country;
|
GtkWidget *combo_country;
|
||||||
GtkWidget *hseparator11;
|
GtkWidget *hseparator11;
|
||||||
GtkWidget *label4;
|
GtkWidget *label4;
|
||||||
GtkWidget *hbox2;
|
GtkWidget *comboboxentry_start_league;
|
||||||
GtkWidget *team_selection_radio1;
|
|
||||||
GSList *team_selection_radio1_group = NULL;
|
|
||||||
GtkWidget *team_selection_radio2;
|
|
||||||
GtkWidget *team_selection_radio3;
|
|
||||||
GtkWidget *hseparator12;
|
GtkWidget *hseparator12;
|
||||||
GtkWidget *hbox54;
|
GtkWidget *hbox54;
|
||||||
GtkWidget *label75;
|
GtkWidget *label75;
|
||||||
|
@ -145,33 +141,10 @@ create_window_startup (void)
|
||||||
label4 = gtk_label_new (_("Start in"));
|
label4 = gtk_label_new (_("Start in"));
|
||||||
gtk_widget_show (label4);
|
gtk_widget_show (label4);
|
||||||
gtk_box_pack_start (GTK_BOX (vbox2), label4, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox2), label4, FALSE, FALSE, 0);
|
||||||
gtk_misc_set_alignment (GTK_MISC (label4), 0.05, 0.5);
|
|
||||||
|
|
||||||
hbox2 = gtk_hbox_new (FALSE, 0);
|
comboboxentry_start_league = gtk_combo_box_entry_new ();
|
||||||
gtk_widget_show (hbox2);
|
gtk_widget_show (comboboxentry_start_league);
|
||||||
gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, TRUE, 5);
|
gtk_box_pack_start (GTK_BOX (vbox2), comboboxentry_start_league, FALSE, FALSE, 0);
|
||||||
|
|
||||||
team_selection_radio1 = gtk_radio_button_new_with_mnemonic (NULL, _("Top league"));
|
|
||||||
gtk_widget_show (team_selection_radio1);
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox2), team_selection_radio1, FALSE, FALSE, 0);
|
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (team_selection_radio1), 3);
|
|
||||||
gtk_radio_button_set_group (GTK_RADIO_BUTTON (team_selection_radio1), team_selection_radio1_group);
|
|
||||||
team_selection_radio1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (team_selection_radio1));
|
|
||||||
|
|
||||||
team_selection_radio2 = gtk_radio_button_new_with_mnemonic (NULL, _("Current league"));
|
|
||||||
gtk_widget_show (team_selection_radio2);
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox2), team_selection_radio2, FALSE, FALSE, 0);
|
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (team_selection_radio2), 3);
|
|
||||||
gtk_radio_button_set_group (GTK_RADIO_BUTTON (team_selection_radio2), team_selection_radio1_group);
|
|
||||||
team_selection_radio1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (team_selection_radio2));
|
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (team_selection_radio2), TRUE);
|
|
||||||
|
|
||||||
team_selection_radio3 = gtk_radio_button_new_with_mnemonic (NULL, _("Bottom league"));
|
|
||||||
gtk_widget_show (team_selection_radio3);
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox2), team_selection_radio3, FALSE, FALSE, 0);
|
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (team_selection_radio3), 3);
|
|
||||||
gtk_radio_button_set_group (GTK_RADIO_BUTTON (team_selection_radio3), team_selection_radio1_group);
|
|
||||||
team_selection_radio1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (team_selection_radio3));
|
|
||||||
|
|
||||||
hseparator12 = gtk_hseparator_new ();
|
hseparator12 = gtk_hseparator_new ();
|
||||||
gtk_widget_show (hseparator12);
|
gtk_widget_show (hseparator12);
|
||||||
|
@ -182,7 +155,7 @@ create_window_startup (void)
|
||||||
gtk_widget_show (hbox54);
|
gtk_widget_show (hbox54);
|
||||||
gtk_box_pack_start (GTK_BOX (vbox2), hbox54, FALSE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox2), hbox54, FALSE, TRUE, 0);
|
||||||
|
|
||||||
label75 = gtk_label_new (_("Player name"));
|
label75 = gtk_label_new (_("Username"));
|
||||||
gtk_widget_show (label75);
|
gtk_widget_show (label75);
|
||||||
gtk_box_pack_start (GTK_BOX (hbox54), label75, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox54), label75, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
@ -347,10 +320,7 @@ create_window_startup (void)
|
||||||
GLADE_HOOKUP_OBJECT (window_startup, combo_country, "combo_country");
|
GLADE_HOOKUP_OBJECT (window_startup, combo_country, "combo_country");
|
||||||
GLADE_HOOKUP_OBJECT (window_startup, hseparator11, "hseparator11");
|
GLADE_HOOKUP_OBJECT (window_startup, hseparator11, "hseparator11");
|
||||||
GLADE_HOOKUP_OBJECT (window_startup, label4, "label4");
|
GLADE_HOOKUP_OBJECT (window_startup, label4, "label4");
|
||||||
GLADE_HOOKUP_OBJECT (window_startup, hbox2, "hbox2");
|
GLADE_HOOKUP_OBJECT (window_startup, comboboxentry_start_league, "comboboxentry_start_league");
|
||||||
GLADE_HOOKUP_OBJECT (window_startup, team_selection_radio1, "team_selection_radio1");
|
|
||||||
GLADE_HOOKUP_OBJECT (window_startup, team_selection_radio2, "team_selection_radio2");
|
|
||||||
GLADE_HOOKUP_OBJECT (window_startup, team_selection_radio3, "team_selection_radio3");
|
|
||||||
GLADE_HOOKUP_OBJECT (window_startup, hseparator12, "hseparator12");
|
GLADE_HOOKUP_OBJECT (window_startup, hseparator12, "hseparator12");
|
||||||
GLADE_HOOKUP_OBJECT (window_startup, hbox54, "hbox54");
|
GLADE_HOOKUP_OBJECT (window_startup, hbox54, "hbox54");
|
||||||
GLADE_HOOKUP_OBJECT (window_startup, label75, "label75");
|
GLADE_HOOKUP_OBJECT (window_startup, label75, "label75");
|
||||||
|
|
|
@ -180,7 +180,8 @@ treeview_show_team_list(GtkTreeView *treeview, gboolean show_cup_teams,
|
||||||
@param max The size of the attribute array.
|
@param max The size of the attribute array.
|
||||||
@param separator Whether we draw a blank line after the 11th player. */
|
@param separator Whether we draw a blank line after the 11th player. */
|
||||||
GtkTreeModel*
|
GtkTreeModel*
|
||||||
treeview_create_player_list(GPtrArray *players, gint *attributes, gint max, gboolean show_separator)
|
treeview_create_player_list(GPtrArray *players, gint *attributes, gint max,
|
||||||
|
gboolean show_separator, gboolean sortable)
|
||||||
{
|
{
|
||||||
gint i, j;
|
gint i, j;
|
||||||
GtkListStore *ls;
|
GtkListStore *ls;
|
||||||
|
@ -212,7 +213,7 @@ treeview_create_player_list(GPtrArray *players, gint *attributes, gint max, gboo
|
||||||
gtk_list_store_set(ls, &iter, j + 1, g_ptr_array_index(players, i), -1);
|
gtk_list_store_set(ls, &iter, j + 1, g_ptr_array_index(players, i), -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!show_separator)
|
if(sortable)
|
||||||
{
|
{
|
||||||
for(i=0;i<max;i++)
|
for(i=0;i<max;i++)
|
||||||
if(attributes[i] == PLAYER_LIST_ATTRIBUTE_POS ||
|
if(attributes[i] == PLAYER_LIST_ATTRIBUTE_POS ||
|
||||||
|
@ -234,7 +235,7 @@ treeview_create_player_list(GPtrArray *players, gint *attributes, gint max, gboo
|
||||||
/** Set up the tree view for a player list */
|
/** Set up the tree view for a player list */
|
||||||
void
|
void
|
||||||
treeview_set_up_player_list (GtkTreeView *treeview, gint *attributes, gint max,
|
treeview_set_up_player_list (GtkTreeView *treeview, gint *attributes, gint max,
|
||||||
gboolean show_separator)
|
gboolean show_separator, gboolean sortable)
|
||||||
{
|
{
|
||||||
gint i;
|
gint i;
|
||||||
GtkTreeViewColumn *col;
|
GtkTreeViewColumn *col;
|
||||||
|
@ -294,7 +295,7 @@ treeview_set_up_player_list (GtkTreeView *treeview, gint *attributes, gint max,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!show_separator &&
|
if(sortable &&
|
||||||
(attributes[i] == PLAYER_LIST_ATTRIBUTE_POS ||
|
(attributes[i] == PLAYER_LIST_ATTRIBUTE_POS ||
|
||||||
attributes[i] == PLAYER_LIST_ATTRIBUTE_SKILL ||
|
attributes[i] == PLAYER_LIST_ATTRIBUTE_SKILL ||
|
||||||
attributes[i] == PLAYER_LIST_ATTRIBUTE_GOALS ||
|
attributes[i] == PLAYER_LIST_ATTRIBUTE_GOALS ||
|
||||||
|
@ -323,6 +324,7 @@ treeview_show_player_list(GtkTreeView *treeview, GPtrArray *players, PlayerListA
|
||||||
gint columns = math_sum_int_array(attribute.on_off, PLAYER_LIST_ATTRIBUTE_END);
|
gint columns = math_sum_int_array(attribute.on_off, PLAYER_LIST_ATTRIBUTE_END);
|
||||||
gint attributes[columns];
|
gint attributes[columns];
|
||||||
GtkTreeModel *model = NULL;
|
GtkTreeModel *model = NULL;
|
||||||
|
gboolean sortable = (treeview != GTK_TREE_VIEW(lookup_widget(window.main, "player_list1")));
|
||||||
|
|
||||||
treeview_helper_clear(treeview);
|
treeview_helper_clear(treeview);
|
||||||
|
|
||||||
|
@ -330,9 +332,9 @@ treeview_show_player_list(GtkTreeView *treeview, GPtrArray *players, PlayerListA
|
||||||
if(attribute.on_off[i])
|
if(attribute.on_off[i])
|
||||||
attributes[cnt++] = i;
|
attributes[cnt++] = i;
|
||||||
|
|
||||||
treeview_set_up_player_list(treeview, attributes, columns, show_separator);
|
treeview_set_up_player_list(treeview, attributes, columns, show_separator, sortable);
|
||||||
|
|
||||||
model = treeview_create_player_list(players, attributes, columns, show_separator);
|
model = treeview_create_player_list(players, attributes, columns, show_separator, sortable);
|
||||||
|
|
||||||
gtk_tree_view_set_model(treeview, model);
|
gtk_tree_view_set_model(treeview, model);
|
||||||
g_object_unref(model);
|
g_object_unref(model);
|
||||||
|
@ -572,14 +574,14 @@ treeview_create_users(void)
|
||||||
2, usr(i).tm->name->str,
|
2, usr(i).tm->name->str,
|
||||||
-1);
|
-1);
|
||||||
|
|
||||||
if(stat0 == STATUS_TEAM_SELECTION && usr(i).scout != 0)
|
if(stat0 == STATUS_TEAM_SELECTION)
|
||||||
{
|
{
|
||||||
if(usr(i).scout == 1)
|
if(usr(i).scout == -1)
|
||||||
gtk_list_store_set(ls, &iter, 3,
|
gtk_list_store_set(ls, &iter, 3,
|
||||||
lig(0).name->str, -1);
|
league_from_clid(usr(i).tm->clid)->name->str, -1);
|
||||||
else
|
else
|
||||||
gtk_list_store_set(ls, &iter, 3,
|
gtk_list_store_set(ls, &iter, 3,
|
||||||
lig(ligs->len - 1).name->str, -1);
|
lig(usr(i).scout).name->str, -1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
gtk_list_store_set(ls, &iter, 3,
|
gtk_list_store_set(ls, &iter, 3,
|
||||||
|
@ -2238,3 +2240,51 @@ treeview_show_contributors(const OptionList *help_list)
|
||||||
gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(ls));
|
gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(ls));
|
||||||
g_object_unref(ls);
|
g_object_unref(ls);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GtkTreeModel*
|
||||||
|
treeview_create_league_list(void)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
GtkListStore *ls = gtk_list_store_new(2, G_TYPE_INT, G_TYPE_STRING);
|
||||||
|
GtkTreeIter iter;
|
||||||
|
|
||||||
|
gtk_list_store_append(ls, &iter);
|
||||||
|
gtk_list_store_set(ls, &iter, 0, 0, 1, _("Current league"), -1);
|
||||||
|
|
||||||
|
for(i=0;i<ligs->len;i++)
|
||||||
|
{
|
||||||
|
gtk_list_store_append(ls, &iter);
|
||||||
|
gtk_list_store_set(ls, &iter, 0, i + 1, 1, lig(i).name->str, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return GTK_TREE_MODEL(ls);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Show the league list in the combo box
|
||||||
|
in the startup window. */
|
||||||
|
void
|
||||||
|
treeview_show_leagues_combo(void)
|
||||||
|
{
|
||||||
|
GtkTreeModel *model = treeview_create_league_list();
|
||||||
|
GtkComboBox *combo_leagues =
|
||||||
|
GTK_COMBO_BOX(lookup_widget(window.startup, "comboboxentry_start_league"));
|
||||||
|
GtkCellRenderer *renderer = NULL;
|
||||||
|
|
||||||
|
gtk_combo_box_set_model(combo_leagues, model);
|
||||||
|
g_object_unref(model);
|
||||||
|
|
||||||
|
if(gtk_combo_box_entry_get_text_column(GTK_COMBO_BOX_ENTRY(combo_leagues)) == -1)
|
||||||
|
gtk_combo_box_entry_set_text_column(GTK_COMBO_BOX_ENTRY(combo_leagues), 1);
|
||||||
|
|
||||||
|
gtk_cell_layout_clear(GTK_CELL_LAYOUT(combo_leagues));
|
||||||
|
|
||||||
|
renderer = treeview_helper_cell_renderer_text_new();
|
||||||
|
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo_leagues), renderer, FALSE);
|
||||||
|
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo_leagues), renderer, "text", 0, NULL);
|
||||||
|
|
||||||
|
renderer = treeview_helper_cell_renderer_text_new();
|
||||||
|
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo_leagues), renderer, TRUE);
|
||||||
|
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo_leagues), renderer, "text", 1, NULL);
|
||||||
|
|
||||||
|
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_leagues), 0);
|
||||||
|
}
|
||||||
|
|
|
@ -20,10 +20,12 @@ treeview_show_team_list(GtkTreeView *treeview, gboolean show_cup_teams,
|
||||||
gboolean show_user_teams);
|
gboolean show_user_teams);
|
||||||
|
|
||||||
GtkTreeModel*
|
GtkTreeModel*
|
||||||
treeview_create_player_list(GPtrArray *players, gint *attributes, gint max, gboolean show_separator);
|
treeview_create_player_list(GPtrArray *players, gint *attributes, gint max,
|
||||||
|
gboolean show_separator, gboolean sortable);
|
||||||
|
|
||||||
void
|
void
|
||||||
treeview_set_up_player_list (GtkTreeView *treeview, gint *attributes, gint max, gboolean show_separator);
|
treeview_set_up_player_list (GtkTreeView *treeview, gint *attributes, gint max,
|
||||||
|
gboolean show_separator, gboolean sortable);
|
||||||
|
|
||||||
void
|
void
|
||||||
treeview_show_player_list(GtkTreeView *treeview, GPtrArray *players, PlayerListAttribute attribute,
|
treeview_show_player_list(GtkTreeView *treeview, GPtrArray *players, PlayerListAttribute attribute,
|
||||||
|
@ -199,4 +201,10 @@ treeview_create_country_list(const GPtrArray *country_list);
|
||||||
void
|
void
|
||||||
treeview_show_contributors(const OptionList *help_list);
|
treeview_show_contributors(const OptionList *help_list);
|
||||||
|
|
||||||
|
GtkTreeModel*
|
||||||
|
treeview_create_league_list(void);
|
||||||
|
|
||||||
|
void
|
||||||
|
treeview_show_leagues_combo(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -361,6 +361,14 @@ treeview_helper_player_compare(GtkTreeModel *model,
|
||||||
gtk_tree_model_get(model, a, 4, &pl1, -1);
|
gtk_tree_model_get(model, a, 4, &pl1, -1);
|
||||||
gtk_tree_model_get(model, b, 4, &pl2, -1);
|
gtk_tree_model_get(model, b, 4, &pl2, -1);
|
||||||
|
|
||||||
|
if(pl1 == NULL && pl2 == NULL)
|
||||||
|
return_value = 0;
|
||||||
|
else if(pl1 == NULL)
|
||||||
|
return_value = 1;
|
||||||
|
else if(pl2 == NULL)
|
||||||
|
return_value = -1;
|
||||||
|
else
|
||||||
|
{
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
|
@ -404,6 +412,7 @@ treeview_helper_player_compare(GtkTreeModel *model,
|
||||||
return_value = misc_int_compare(pl1->wage, pl2->wage);
|
return_value = misc_int_compare(pl1->wage, pl2->wage);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return return_value;
|
return return_value;
|
||||||
|
|
||||||
|
|
22
src/user.c
22
src/user.c
|
@ -41,30 +41,26 @@ void
|
||||||
user_set_up_team_new_game(User *user)
|
user_set_up_team_new_game(User *user)
|
||||||
{
|
{
|
||||||
gchar buf[SMALL];
|
gchar buf[SMALL];
|
||||||
gint rndom, max, lig_idx = -1;
|
gint rndom;
|
||||||
|
|
||||||
if(user->scout == 0)
|
if(user->scout == -1)
|
||||||
{
|
{
|
||||||
user_set_up_team(user);
|
user_set_up_team(user);
|
||||||
user_history_add(user, USER_HISTORY_START_GAME, user->tm->id, user->tm->clid, -1, "");
|
user_history_add(user, USER_HISTORY_START_GAME, user->tm->id, user->tm->clid, -1, "");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(user->scout == 1 &&
|
rndom = math_rndi(0, lig(user->scout).teams->len - 1);
|
||||||
lig(0).id != user->tm->clid)
|
while(team_is_user(&g_array_index(lig(user->scout).teams, Team, rndom)) != -1)
|
||||||
lig_idx = 0;
|
rndom = math_rndi(0, lig(user->scout).teams->len - 1);
|
||||||
else if(lig(ligs->len - 1).id != user->tm->clid)
|
|
||||||
lig_idx = ligs->len - 1;
|
|
||||||
|
|
||||||
max = lig(lig_idx).teams->len - 1;
|
sprintf(buf, "%s", g_array_index(lig(user->scout).teams, Team, rndom).name->str);
|
||||||
rndom = math_rndi(0, max);
|
g_string_printf(g_array_index(lig(user->scout).teams, Team, rndom).name, "%s",
|
||||||
sprintf(buf, "%s", g_array_index(lig(lig_idx).teams, Team, rndom).name->str);
|
|
||||||
g_string_printf(g_array_index(lig(lig_idx).teams, Team, rndom).name, "%s",
|
|
||||||
user->tm->name->str);
|
user->tm->name->str);
|
||||||
g_string_printf(user->tm->name, "%s", buf);
|
g_string_printf(user->tm->name, "%s", buf);
|
||||||
|
|
||||||
user->tm = &g_array_index(lig(lig_idx).teams, Team, rndom);
|
user->tm = &g_array_index(lig(user->scout).teams, Team, rndom);
|
||||||
user->team_id = g_array_index(lig(lig_idx).teams, Team, rndom).id;
|
user->team_id = g_array_index(lig(user->scout).teams, Team, rndom).id;
|
||||||
|
|
||||||
user_history_add(user, USER_HISTORY_START_GAME, user->tm->id, user->tm->clid, -1, "");
|
user_history_add(user, USER_HISTORY_START_GAME, user->tm->id, user->tm->clid, -1, "");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue