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:
parent
a92decf763
commit
760bd79239
10
src/debug.c
10
src/debug.c
@ -112,10 +112,20 @@ debug_action(const gchar *text)
|
|||||||
sett_set_int("int_opt_goto_mode", 1);
|
sett_set_int("int_opt_goto_mode", 1);
|
||||||
if(value < 100)
|
if(value < 100)
|
||||||
while(week < value)
|
while(week < value)
|
||||||
|
{
|
||||||
on_button_new_week_clicked(NULL, NULL);
|
on_button_new_week_clicked(NULL, NULL);
|
||||||
|
game_gui_set_main_window_header();
|
||||||
|
while (gtk_events_pending ())
|
||||||
|
gtk_main_iteration ();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
while(season < value - 100)
|
while(season < value - 100)
|
||||||
|
{
|
||||||
on_button_new_week_clicked(NULL, NULL);
|
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);
|
sett_set_int("int_opt_goto_mode", 0);
|
||||||
}
|
}
|
||||||
else if(g_str_has_prefix(text, "testcom") ||
|
else if(g_str_has_prefix(text, "testcom") ||
|
||||||
|
@ -85,7 +85,10 @@ gui_show_progress(gfloat value, const gchar *text, gint pictype)
|
|||||||
GtkProgressBar *progressbar = NULL;
|
GtkProgressBar *progressbar = NULL;
|
||||||
|
|
||||||
if(sett_int("int_opt_goto_mode"))
|
if(sett_int("int_opt_goto_mode"))
|
||||||
return;
|
{
|
||||||
|
window_destroy(&window.progress);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(value == 1 || value < 0)
|
if(value == 1 || value < 0)
|
||||||
{
|
{
|
||||||
|
@ -123,6 +123,56 @@ language_get_code_index(const gchar *code)
|
|||||||
return return_value;
|
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
|
/** Put the country matching the local language to the
|
||||||
beginning of the array if possible. */
|
beginning of the array if possible. */
|
||||||
void
|
void
|
||||||
@ -158,14 +208,17 @@ language_pick_country(GPtrArray *country_files)
|
|||||||
(gchar*)g_ptr_array_index(defs, i)))
|
(gchar*)g_ptr_array_index(defs, i)))
|
||||||
{
|
{
|
||||||
prefdef = g_ptr_array_index(country_files, j);
|
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;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_ptr_array_sort_with_data(
|
||||||
|
country_files,
|
||||||
|
(GCompareDataFunc)language_compare_country_files,
|
||||||
|
prefdef);
|
||||||
|
|
||||||
free_gchar_array(&codes);
|
free_gchar_array(&codes);
|
||||||
free_gchar_array(&defs);
|
free_gchar_array(&defs);
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,9 @@ language_pick_country(GPtrArray *country_files);
|
|||||||
void
|
void
|
||||||
language_get_code(gchar *buf);
|
language_get_code(gchar *buf);
|
||||||
|
|
||||||
|
gint
|
||||||
|
language_compare_country_files(gconstpointer a, gconstpointer b, gpointer data);
|
||||||
|
|
||||||
/* #ifndef G_OS_UNIX */
|
/* #ifndef G_OS_UNIX */
|
||||||
/* extern int _nl_msg_cat_cntr; */
|
/* extern int _nl_msg_cat_cntr; */
|
||||||
/* #endif */
|
/* #endif */
|
||||||
|
@ -59,8 +59,6 @@ typedef void(*WeekFunc)(void);
|
|||||||
/** Array of functions called when a week round
|
/** Array of functions called when a week round
|
||||||
is ended. */
|
is ended. */
|
||||||
WeekFunc end_week_round_funcs[] =
|
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_results, end_week_round_sort_tables,
|
||||||
end_week_round_generate_news, end_week_round_update_fixtures, NULL};
|
end_week_round_generate_news, end_week_round_update_fixtures, NULL};
|
||||||
|
|
||||||
@ -579,7 +577,8 @@ start_week_round(void)
|
|||||||
((week_round == 1 &&
|
((week_round == 1 &&
|
||||||
!query_user_games_in_week_round(week - 1, fixture_get_last_week_round(week - 1))) ||
|
!query_user_games_in_week_round(week - 1, fixture_get_last_week_round(week - 1))) ||
|
||||||
(week_round > 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();
|
user_event_show_next();
|
||||||
end_week_round();
|
end_week_round();
|
||||||
}
|
}
|
||||||
|
12
src/xml.c
12
src/xml.c
@ -92,10 +92,8 @@ xml_load_league(const gchar *dirname, const gchar *basename)
|
|||||||
sprintf(buf, _("Loading league: %s"),
|
sprintf(buf, _("Loading league: %s"),
|
||||||
lig(ligs->len - 1).name);
|
lig(ligs->len - 1).name);
|
||||||
|
|
||||||
gui_show_progress(
|
gui_show_progress(gui_get_progress_bar_fraction(), buf,
|
||||||
gtk_progress_bar_get_fraction(
|
PIC_TYPE_LOAD);
|
||||||
GTK_PROGRESS_BAR(lookup_widget(window.progress, "progressbar"))), buf,
|
|
||||||
PIC_TYPE_LOAD);
|
|
||||||
|
|
||||||
if(debug > 80)
|
if(debug > 80)
|
||||||
g_print("%s\n", buf);
|
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"),
|
sprintf(buf, _("Loading cup: %s"),
|
||||||
cup->name);
|
cup->name);
|
||||||
gui_show_progress(
|
gui_show_progress(gui_get_progress_bar_fraction(), buf,
|
||||||
gtk_progress_bar_get_fraction(
|
PIC_TYPE_LOAD);
|
||||||
GTK_PROGRESS_BAR(lookup_widget(window.progress, "progressbar"))), buf,
|
|
||||||
PIC_TYPE_LOAD);
|
|
||||||
|
|
||||||
if(debug > 80)
|
if(debug > 80)
|
||||||
g_print("%s\n", buf);
|
g_print("%s\n", buf);
|
||||||
|
@ -210,7 +210,7 @@ xml_loadsave_leagues_cups_write(const gchar *prefix)
|
|||||||
void
|
void
|
||||||
xml_loadsave_leagues_cups_adjust_team_ptrs(void)
|
xml_loadsave_leagues_cups_adjust_team_ptrs(void)
|
||||||
{
|
{
|
||||||
gint i, j, k;
|
gint i, j, k, l;
|
||||||
GPtrArray *team_ptrs;
|
GPtrArray *team_ptrs;
|
||||||
|
|
||||||
for(i = 0; i < ligs->len; i++)
|
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(j = 0; j < lig(i).fixtures->len; j++)
|
||||||
{
|
{
|
||||||
for(k = 0; k < 2; k++)
|
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++)
|
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_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;
|
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++)
|
for(j = 0; j < cp(i).fixtures->len; j++)
|
||||||
|
@ -140,10 +140,7 @@ xml_loadsave_table_text (GMarkupParseContext *context,
|
|||||||
else if(state == TAG_ROUND)
|
else if(state == TAG_ROUND)
|
||||||
new_table->round = int_value;
|
new_table->round = int_value;
|
||||||
else if(state == TAG_TEAM_ID)
|
else if(state == TAG_TEAM_ID)
|
||||||
{
|
|
||||||
new_element.team = team_of_id(int_value);
|
|
||||||
new_element.team_id = int_value;
|
new_element.team_id = int_value;
|
||||||
}
|
|
||||||
else if(state == TAG_TABLE_ELEMENT_VALUE)
|
else if(state == TAG_TABLE_ELEMENT_VALUE)
|
||||||
new_element.values[valueidx] = int_value;
|
new_element.values[valueidx] = int_value;
|
||||||
else if(state == TAG_TABLE_ELEMENT_OLD_RANK)
|
else if(state == TAG_TABLE_ELEMENT_OLD_RANK)
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
</leagues>
|
</leagues>
|
||||||
|
|
||||||
<cups>
|
<cups>
|
||||||
<cup>armenia</cup>
|
<cup>armenia_cup</cup>
|
||||||
<cup>europe_uefa</cup>
|
<cup>europe_uefa</cup>
|
||||||
<cup>europe_champ_league</cup>
|
<cup>europe_champ_league</cup>
|
||||||
<cup>supercup_league_vs_cup</cup>
|
<cup>supercup_league_vs_cup</cup>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user