1
1
mirror of https://github.com/tstellar/bygfoot.git synced 2025-01-31 07:54:50 +01:00

Country file sorting.

This commit is contained in:
gyboth 2009-01-11 10:23:55 +00:00
parent a92decf763
commit 760bd79239
9 changed files with 92 additions and 20 deletions

View File

@ -112,10 +112,20 @@ debug_action(const gchar *text)
sett_set_int("int_opt_goto_mode", 1);
if(value < 100)
while(week < value)
{
on_button_new_week_clicked(NULL, NULL);
game_gui_set_main_window_header();
while (gtk_events_pending ())
gtk_main_iteration ();
}
else
while(season < value - 100)
{
on_button_new_week_clicked(NULL, NULL);
game_gui_set_main_window_header();
while (gtk_events_pending ())
gtk_main_iteration ();
}
sett_set_int("int_opt_goto_mode", 0);
}
else if(g_str_has_prefix(text, "testcom") ||

View File

@ -85,7 +85,10 @@ gui_show_progress(gfloat value, const gchar *text, gint pictype)
GtkProgressBar *progressbar = NULL;
if(sett_int("int_opt_goto_mode"))
return;
{
window_destroy(&window.progress);
return;
}
if(value == 1 || value < 0)
{

View File

@ -123,6 +123,56 @@ language_get_code_index(const gchar *code)
return return_value;
}
/** Compare country file names based on a preferred one (which
should get moved to the start). */
gint
language_compare_country_files(gconstpointer a, gconstpointer b, gpointer data)
{
gint i, j;
const gchar *prefdef = (const gchar*)data;
const gchar *def1 = *(const gchar**)a;
const gchar *def2 = *(const gchar**)b;
gint len1 = strlen(def1),
len2 = strlen(def2), lenmin = MIN(len1, len2);
gchar alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
gint return_value = 0;
if(strcmp(def1, def2) == 0)
return_value = 0;
else if(prefdef != NULL && strcmp(prefdef, def1) == 0)
return_value = -1;
else if(prefdef != NULL && strcmp(prefdef, def2) == 0)
return_value = 1;
else
{
for(i=0;i<lenmin;i++)
if(def1[i] != def2[i])
break;
if(i == lenmin)
return_value = (len2 < len1);
else
{
for(j=0;j<26;j++)
if(def1[i] == alphabet[j] ||
def2[i] == alphabet[j])
break;
if(j == 26)
{
g_warning("language_compare_country_files: chars %c and %c not comparable",
def1[i], def2[i]);
return_value = 0;
}
else
return_value = (def1[i] == alphabet[j]) ? -1 : 1;
}
}
return return_value;
}
/** Put the country matching the local language to the
beginning of the array if possible. */
void
@ -158,14 +208,17 @@ language_pick_country(GPtrArray *country_files)
(gchar*)g_ptr_array_index(defs, i)))
{
prefdef = g_ptr_array_index(country_files, j);
g_ptr_array_remove_index(country_files, j);
g_ptr_array_add(country_files, prefdef);
break;
}
break;
}
}
g_ptr_array_sort_with_data(
country_files,
(GCompareDataFunc)language_compare_country_files,
prefdef);
free_gchar_array(&codes);
free_gchar_array(&defs);
}

View File

@ -45,6 +45,9 @@ language_pick_country(GPtrArray *country_files);
void
language_get_code(gchar *buf);
gint
language_compare_country_files(gconstpointer a, gconstpointer b, gpointer data);
/* #ifndef G_OS_UNIX */
/* extern int _nl_msg_cat_cntr; */
/* #endif */

View File

@ -59,8 +59,6 @@ typedef void(*WeekFunc)(void);
/** Array of functions called when a week round
is ended. */
WeekFunc end_week_round_funcs[] =
/* {end_week_round_results, end_week_round_sort_tables, */
/* end_week_round_update_fixtures, NULL}; */
{end_week_round_results, end_week_round_sort_tables,
end_week_round_generate_news, end_week_round_update_fixtures, NULL};
@ -579,7 +577,8 @@ start_week_round(void)
((week_round == 1 &&
!query_user_games_in_week_round(week - 1, fixture_get_last_week_round(week - 1))) ||
(week_round > 1 &&
!query_user_games_in_week_round(week, week_round - 1)))) {
!query_user_games_in_week_round(week, week_round - 1))))
{
user_event_show_next();
end_week_round();
}

View File

@ -92,10 +92,8 @@ xml_load_league(const gchar *dirname, const gchar *basename)
sprintf(buf, _("Loading league: %s"),
lig(ligs->len - 1).name);
gui_show_progress(
gtk_progress_bar_get_fraction(
GTK_PROGRESS_BAR(lookup_widget(window.progress, "progressbar"))), buf,
PIC_TYPE_LOAD);
gui_show_progress(gui_get_progress_bar_fraction(), buf,
PIC_TYPE_LOAD);
if(debug > 80)
g_print("%s\n", buf);
@ -124,10 +122,8 @@ xml_load_cup(Cup *cup, const gchar *dirname, const gchar *basename)
sprintf(buf, _("Loading cup: %s"),
cup->name);
gui_show_progress(
gtk_progress_bar_get_fraction(
GTK_PROGRESS_BAR(lookup_widget(window.progress, "progressbar"))), buf,
PIC_TYPE_LOAD);
gui_show_progress(gui_get_progress_bar_fraction(), buf,
PIC_TYPE_LOAD);
if(debug > 80)
g_print("%s\n", buf);

View File

@ -210,7 +210,7 @@ xml_loadsave_leagues_cups_write(const gchar *prefix)
void
xml_loadsave_leagues_cups_adjust_team_ptrs(void)
{
gint i, j, k;
gint i, j, k, l;
GPtrArray *team_ptrs;
for(i = 0; i < ligs->len; i++)
@ -218,8 +218,14 @@ xml_loadsave_leagues_cups_adjust_team_ptrs(void)
for(j = 0; j < lig(i).fixtures->len; j++)
{
for(k = 0; k < 2; k++)
g_array_index(lig(i).fixtures, Fixture, j).teams[k] = team_of_id(g_array_index(lig(i).fixtures, Fixture, j).team_ids[k]);
g_array_index(lig(i).fixtures, Fixture, j).teams[k] =
team_of_id(g_array_index(lig(i).fixtures, Fixture, j).team_ids[k]);
}
for(j = 0; j < lig(i).tables->len; j++)
for(k = 0; k < g_array_index(lig(i).tables, Table, j).elements->len; k++)
g_array_index(g_array_index(lig(i).tables, Table, j).elements, TableElement, k).team =
team_of_id(g_array_index(g_array_index(lig(i).tables, Table, j).elements, TableElement, k).team_id);
}
for(i = 0; i < cps->len; i++)
@ -232,6 +238,11 @@ xml_loadsave_leagues_cups_adjust_team_ptrs(void)
g_ptr_array_free(g_array_index(cp(i).rounds, CupRound, j).team_ptrs, TRUE);
g_array_index(cp(i).rounds, CupRound, j).team_ptrs = team_ptrs;
for(k = 0; k < g_array_index(cp(i).rounds, CupRound, j).tables->len; k++)
for(l = 0; l < g_array_index(g_array_index(cp(i).rounds, CupRound, j).tables, Table, k).elements->len; l++)
g_array_index(g_array_index(g_array_index(cp(i).rounds, CupRound, j).tables, Table, k).elements, TableElement, l).team =
team_of_id(g_array_index(g_array_index(g_array_index(cp(i).rounds, CupRound, j).tables, Table, k).elements, TableElement, l).team_id);
}
for(j = 0; j < cp(i).fixtures->len; j++)

View File

@ -140,10 +140,7 @@ xml_loadsave_table_text (GMarkupParseContext *context,
else if(state == TAG_ROUND)
new_table->round = int_value;
else if(state == TAG_TEAM_ID)
{
new_element.team = team_of_id(int_value);
new_element.team_id = int_value;
}
else if(state == TAG_TABLE_ELEMENT_VALUE)
new_element.values[valueidx] = int_value;
else if(state == TAG_TABLE_ELEMENT_OLD_RANK)

View File

@ -11,7 +11,7 @@
</leagues>
<cups>
<cup>armenia</cup>
<cup>armenia_cup</cup>
<cup>europe_uefa</cup>
<cup>europe_champ_league</cup>
<cup>supercup_league_vs_cup</cup>