From 7e07d74abd9a92ef51d4c6838beb56a29b99dcfb Mon Sep 17 00:00:00 2001 From: gyboth Date: Thu, 3 Mar 2005 12:46:48 +0000 Subject: [PATCH] Made some progress; removed editor gui. --- Doxyfile | 2 +- Makefile.am | 8 +- bygfoot-update | 793 +++++++++++++++++++++++ bygfoot.glade | 723 +++++++-------------- bygfoot_misc.glade | 446 ++++++------- configure.in | 8 +- src/Makefile.am | 6 +- src/bygfoot.h | 70 ++- src/callback_func.c | 88 +++ src/callback_func.h | 12 + src/callbacks.c | 236 +++---- src/callbacks.h | 99 +-- src/cup.c | 24 +- src/cup.h | 3 + src/editor_callback_func.c | 0 src/editor_callback_func.h | 0 src/editor_callbacks.c | 175 ------ src/editor_callbacks.h | 85 --- src/editor_defs.h | 0 src/editor_interface.c | 1035 ------------------------------- src/editor_interface.h | 5 - src/enums.h | 67 +- src/file.c | 249 +++----- src/file.h | 17 +- src/fixture.c | 362 +++++++++-- src/fixture.h | 37 +- src/fixture_struct.h | 2 + src/free.c | 64 +- src/free.h | 10 + src/game.c | 80 ++- src/game.h | 14 +- src/game_gui.c | 299 +++++++-- src/game_gui.h | 31 +- src/gui.c | 49 ++ src/gui.h | 14 +- src/interface.c | 662 ++++++-------------- src/league.c | 33 +- src/league.h | 3 + src/live_game.c | 546 +++++++--------- src/live_game.h | 2 +- src/live_game_struct.h | 6 +- src/main.c | 45 +- src/maths.c | 8 +- src/maths.h | 2 +- src/misc2_interface.c | 39 -- src/misc_callback_func.c | 105 +++- src/misc_callback_func.h | 11 +- src/misc_callbacks.c | 67 +- src/misc_callbacks.h | 16 +- src/misc_interface.c | 320 +++++----- src/misc_interface.h | 1 + src/option.c | 98 +++ src/option.h | 39 ++ src/options_interface.c | 56 -- src/player.c | 297 ++++++--- src/player.h | 25 +- src/player_struct.h | 24 +- src/start_end.c | 197 +++++- src/start_end.h | 18 + src/support.h | 2 + src/table.c | 182 ++++++ src/table.h | 23 + src/table_struct.h | 2 + src/team.c | 218 +++++-- src/team.h | 20 +- src/transfer.h | 3 - src/treeview.c | 276 ++++++--- src/treeview.h | 21 +- src/treeview_cell.c | 201 +++--- src/treeview_cell.h | 9 +- src/user.c | 113 ++-- src/user.h | 21 +- src/user_struct.h | 33 + src/variables.h | 50 +- src/window.c | 80 +-- src/window.h | 4 +- src/xml_league.c | 16 +- support_files/bygfoot.conf | 95 +-- support_files/bygfoot_constants | 279 +++++++++ support_files/bygfoot_user.conf | 72 +++ 80 files changed, 5124 insertions(+), 4329 deletions(-) create mode 100755 bygfoot-update delete mode 100644 src/editor_callback_func.c delete mode 100644 src/editor_callback_func.h delete mode 100644 src/editor_callbacks.c delete mode 100644 src/editor_callbacks.h delete mode 100644 src/editor_defs.h delete mode 100644 src/editor_interface.c delete mode 100644 src/editor_interface.h create mode 100644 src/table.c create mode 100644 src/table.h create mode 100644 src/user_struct.h create mode 100644 support_files/bygfoot_constants create mode 100644 support_files/bygfoot_user.conf diff --git a/Doxyfile b/Doxyfile index ff55089f..7e3dbe36 100644 --- a/Doxyfile +++ b/Doxyfile @@ -417,7 +417,7 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = /home/gy/progs/bygfoot/1.9/src/ +INPUT = /home/gy/progs/bygfoot/current-unstable/src/ # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp diff --git a/Makefile.am b/Makefile.am index 4c2e69a8..4b140479 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,9 @@ AM_CFLAGS = -Wall -SUBDIRS = src po b-u +SUBDIRS = src po + +bin_SCRIPTS = bygfoot-update EXTRA_DIST = \ autogen.sh \ @@ -11,9 +13,9 @@ EXTRA_DIST = \ dist_man6_MANS = man/bygfoot.6 -SUPPORT_DIRS = support_files support_files/pixmaps support_files/definitions support_files/names +SUPPORT_DIRS = support_files support_files/names support_files/pixmaps support_files/pixmaps/live_game support_files/definitions -SUPPORT_FILES = support_files/pixmaps/flag_ro.png support_files/pixmaps/bygfoot_team_editor_icon.png support_files/pixmaps/bygfoot_icon.png support_files/pixmaps/flag_eng.png support_files/pixmaps/pay_loan.png support_files/pixmaps/inc_cap.png support_files/pixmaps/new_week.png support_files/pixmaps/preview.png support_files/pixmaps/get_loan.png support_files/pixmaps/transfers.png support_files/pixmaps/fire_player.png support_files/pixmaps/inc_saf.png support_files/pixmaps/football.png support_files/pixmaps/flag_br.png support_files/pixmaps/flag_de.png support_files/pixmaps/fin_stad.png support_files/pixmaps/flag_es.png support_files/pixmaps/flag_fr.png support_files/pixmaps/flag_hu.png support_files/pixmaps/flag_it.png support_files/pixmaps/flag_mx.png support_files/pixmaps/flag_pl.png support_files/definitions/country_england.xml support_files/definitions/league_england1.xml support_files/definitions/league_england2.xml support_files/definitions/league_england3.xml support_files/definitions/league_england4.xml support_files/definitions/league_england5.xml support_files/definitions/cup_england_fa.xml support_files/definitions/cup_england_prom_games.xml support_files/definitions/cup_england_league.xml support_files/bygfoot.conf support_files/names/player_names +SUPPORT_FILES = support_files/names/player_names.xml support_files/bygfoot.conf support_files/pixmaps/flag_ro.png support_files/pixmaps/bygfoot_team_editor_icon.png support_files/pixmaps/bygfoot_icon.png support_files/pixmaps/pay_loan.png support_files/pixmaps/inc_cap.png support_files/pixmaps/new_week.png support_files/pixmaps/preview.png support_files/pixmaps/get_loan.png support_files/pixmaps/transfers.png support_files/pixmaps/fire_player.png support_files/pixmaps/inc_saf.png support_files/pixmaps/football.png support_files/pixmaps/flag_br.png support_files/pixmaps/flag_de.png support_files/pixmaps/fin_stad.png support_files/pixmaps/flag_en.png support_files/pixmaps/flag_es.png support_files/pixmaps/flag_fr.png support_files/pixmaps/possession_ball.png support_files/pixmaps/flag_hu.png support_files/pixmaps/live_game/yellow.png support_files/pixmaps/live_game/red.png support_files/pixmaps/live_game/save.png support_files/pixmaps/live_game/goal.png support_files/pixmaps/flag_it.png support_files/pixmaps/flag_mx.png support_files/pixmaps/flag_pl.png support_files/definitions/league_turkey1_short.xml support_files/definitions/league_italy1_short.xml support_files/definitions/league_germany1_short.xml support_files/definitions/country_england.xml support_files/definitions/league_russia1_short.xml support_files/definitions/league_scotland1_short.xml support_files/definitions/league_england1.xml support_files/definitions/league_england2.xml support_files/definitions/league_england3.xml support_files/definitions/league_england4.xml support_files/definitions/league_england5.xml support_files/definitions/league_greece1_short.xml support_files/definitions/league_denmark1_short.xml support_files/definitions/cup_england_fa.xml support_files/definitions/cup_champ_league.xml support_files/definitions/league_ukraine1_short.xml support_files/definitions/league_switzerland1_short.xml support_files/definitions/cup_cwc.xml support_files/definitions/league_netherlands1_short.xml support_files/definitions/league_europe_div.xml support_files/definitions/league_czech1_short.xml support_files/definitions/cup_england_prom_games.xml support_files/definitions/league_portugal1_short.xml support_files/definitions/league_spain1_short.xml support_files/definitions/cup_uefa.xml support_files/definitions/cup_england_league.xml support_files/definitions/league_belgium1_short.xml support_files/definitions/league_france1_short.xml install-data-local: @$(NORMAL_INSTALL) diff --git a/bygfoot-update b/bygfoot-update new file mode 100755 index 00000000..e5d56205 --- /dev/null +++ b/bygfoot-update @@ -0,0 +1,793 @@ +#!/bin/bash + +#################################################### +# Bygfoot Football Manager # +# AUTHOR: Gyozo Both (gyboth@bygfoot.com) # +# http://www.bygfoot.com # +#################################################### + +# Skript that updates src packages of the Bygfoot Football Manager +# using wget to retrieve patches from the homepage + +# version number +version="0.13" +# the bygfoot release version the script is shipped with +relversion=VERSION +# the current release version on the server +packversion= + +# exit codes +EXITOK=0 +EXITNOPROG=1 +EXITNOREV=2 +EXITABORT=3 +EXITWGETFAIL=4 +EXITUSR=6 +EXITNEWSCRIPT=7 +EXITCOUNTRY=8 +EXITPACKFORMAT=9 +EXITDEBIAN=10 + +# variables + +# a variable we sometimes read something into +tempvar= +# the directory containing the Bygfoot src package +packdir= +# a directory we can write to and read from +tmpdir= +# destination for the country files +countrydir= +# the Bygfoot package type, stable or unstable +type_stable=stable +type_unstable=unstable +type= +# the current revision number of the user's package +revnr= +# revision numbers fetched from the homepage +newrevnr= +# number of new revisions found +found=0 +# the arguments for the script +args="$*" +# the package format the user wants to download +format_rpm=.i586.rpm +format_bin=-binary.tar.bz2 +format_src=.tar.bz2 +format_srpm=.src.rpm +format_deb=-1_i386.deb +format= +# which cvs version to get +cvs_version1=bygfoot-unstable +cvs_version2=bygfoot2-unstable +cvs_version= + +# SourceForge.Net username (for cvs checkout) +cvs_user= + +# The file we redirect dialog output to +input_file=$PWD/bygfoot-update-dialog.tmp + +# The file containing all output +log_file=$PWD/bygfoot-update.log + +# options + +# whether all new patches should be applied automatically +apply_all=0 +# whether we should skip some queries and assume standard values +auto=0 +# whether we recompile automatically after patching +recompile=0 +# whether we check for auxiliary programs and +# newer update script versions +check=1 +# whether we just fetch the latest version number from +# the server +get_version=0 + +# whether we show the log file before terminating +# if so, the file doesn't get deleted by cleanup() +show_log=0 + +# operation modes +# source update +mode_src=0 +# country file download +mode_country=1 +# package download +mode_pack=2 +# get cvs version +mode_cvs=3 +mode= + +# print a help text +function print_help() +{ + cat <> $log_file | tee -a $log_file +} + +# show log file before exiting if the option is set +function my_exit() +{ + if [ $show_log -eq 1 ]; then + if [ -r $log_file ]; then + dialog --title "Bygfoot Online Update" --textbox $log_file 22 75 + else + echo "** WARNING: log file $log_file not readable." + fi + fi + + cleanup + exit $1 +} + +# parse arguments +function parse_args() +{ + TEMP=`getopt -o aAbcB:C:f:hlnNp:rRt:T:uU:vV --long apply-all,\ +auto,branch:,country-files,country-dir:,cvs,format:,help,new-package,no-check,\ +package-dir:,recompile,no-recompile,show-log,temp-dir:,type:,update,username:\ +version,get-version -- $*` + + if [ $? != 0 ]; then + my_echo "** b-u: There was an error parsing the arguments." + my_echo "** b-u: The arguments will be ignored." + return + fi + + eval set -- "$TEMP" + + while true; do + case "$1" in + -a|--apply-all) apply_all=1; shift ;; + -A|--auto) auto=1; apply_all=1; shift ;; + -b|--cvs) mode=$mode_cvs; shift ;; + -B|--branch) set_branch $2; shift 2 ;; + -c|--country-files) mode=$mode_country; shift ;; + -C|--country-dir) pushd $2 &> /dev/null; countrydir=$PWD; popd &> /dev/null; shift 2 ;; + -f|--format) set_format $2; shift 2 ;; + -h|--help) print_help; exit $EXITOK ;; + -l|--show-log) show_log=1; shift ;; + -n|--new-package) mode=$mode_pack; shift ;; + -N|--no-check) check=0; shift ;; + -p|--package-dir) pushd $2 &> /dev/null; packdir=$PWD; popd &> /dev/null; shift 2 ;; + -r|--recompile) recompile=1; shift ;; + -R|--no-recompile) recompile=-1; shift ;; + -t|--temp-dir) pushd $2 &> /dev/null; tmpdir=$PWD; popd &> /dev/null; shift 2 ;; + -T|--type) type=$2; shift 2 ;; + -u|--update) mode=$mode_src; shift ;; + -U|--username) cvs_user=$2; shift 2 ;; + -v|--version) print_version; exit $EXITOK ;; + -V|--get-version) mode=$mode_pack; get_version=1; shift ;; + --) shift; break ;; + esac + done +} + +# clean up in the temp dir +function cleanup() +{ + my_echo + my_echo "** b-u: Removing dialog output file $input_file." + rm -rfv $input_file 2>> $log_file | tee -a $log_file + + if [ ! -z $tmpdir -a $mode -neq $mode_pack ];then + my_echo "** b-u: Cleaning up in the temp directory." + rm -rfv 2>> $log_file | tee -a $log_file + fi + + if [ $show_log -eq 0 ]; then + my_echo "** b-u: Removing log file $log_file." + rm -rfv $log_file + fi +} + +# wget something, exit if it doesn't work +function my_wget() +{ + if ! wget -v $1 2>> $log_file | tee -a $log_file; then + my_echo + my_echo "** b-u: wget failure." + my_exit $EXITWGETFAIL + fi +} + +# check for the programs needed +function check_progs() +{ + if [ $check -eq 0 ]; then + return + fi + + my_echo + for i in sed tar bzip2 wget patch cvs; do + my_echo -n "** b-u: checking for $i... " + if which $i &> /dev/null; then + my_echo "ok" + else + my_echo "failed" + my_echo + my_echo "** WARNING: Didn't find working $i, maybe it's not in your PATH." + my_echo "** WARNING: You might not be able to use all bygfoot-update features." + read a + fi + done +} + +function read_input() +{ + if [ $? -eq 1 ];then + my_echo "** b-u: User abort." + my_exit $EXITUSR + fi + + if [ -r $input_file ]; then + tempvar=$(cat $input_file) + else + tempvar= + fi + + my_echo "** b-u: User input: $tempvar" + my_echo +} + +# get country files with official team names +function get_country_files() +{ + my_echo + my_echo "** b-u: Fetching country files with official team names and" + my_echo "** b-u: team definitions file." + + pushd $countrydir &>/dev/null + + my_wget http://bygfoot.sourceforge.net/revisions/bygfoot-countries.tar.bz2 + + for i in country_* teams; do + mv -vf $i $i.old 2>> $log_file | tee -a $log_file + done + + tar xfjv bygfoot-countries.tar.bz2 2>> $log_file | tee -a $log_file + rm -vf bygfoot-countries.tar.bz2 2>> $log_file | tee -a $log_file + + popd + + my_echo "** b-u: done." + my_exit $EXITCOUNTRY +} + +# get the paths for a temp directory and +# the location of the user's bygfoot src package +function get_paths() +{ + if [ $mode -eq $mode_src ]; then + if [ -z $packdir ]; then + if [ $auto -eq 0 ]; then + dialog --title "Bygfoot Online Update" \ + --inputbox "Source package directory" 22 80 $PWD 2> $input_file + read_input + + pushd $tempvar; packdir=$PWD; popd + else + packdir=$PWD + fi + + my_echo + my_echo "** b-u: Package dir set to" + my_echo "** b-u: $packdir" + fi + fi + + if [ $mode -ne $mode_country ]; then + if [ -z $tmpdir ]; then + if [ $auto -eq 0 ]; then + dialog --title "Bygfoot Online Update" --inputbox "Temporary directory\n(you need read/write permissions there)" \ + 22 80 /tmp 2> $input_file + read_input + + if [ ! -z $tempvar ]; then + pushd $tempvar &> /dev/null ; tmpdir=$PWD; popd &> /dev/null + else + tmpdir=/tmp + fi + + else + tmpdir=/tmp + fi + my_echo + my_echo "** b-u: Temp dir set to" + my_echo "** b-u: $tmpdir" + fi + fi + + if [ $mode -eq $mode_country ]; then + if [ -z $countrydir ]; then + if [ $auto -eq 0 ]; then + dialog --title "Bygfoot Online Update" --inputbox "Country files destination directory\n(default destination recommmended)" \ + 22 80 $HOME/.bygfoot/text_files 2> $input_file + read_input + + if [ ! -z $tempvar ]; then + pushd $tempvar; countrydir=$PWD; popd + else + countrydir=$HOME/.bygfoot/text_files + fi + else + countrydir=$HOME/.bygfoot/text_files + fi + my_echo + my_echo "** b-u: Country dir set to" + my_echo "** b-u: $countrydir" + fi + fi +} + +# find out revision number and type +function get_rev_type() +{ + echo + if [ ! -e $packdir/revision_number ]; then + dialog --title "Bygfoot Online Update" --msgbox \ +"I couldn't find the file containing your current revision number and type ($packdir/revision_number).\nFailure." \ + 22 80 2> $input_file + read_input + my_exit $EXITNOREV + fi + + type=$(cat $packdir/revision_number | sed s/[0-9]*//g) + revnr=$(cat $packdir/revision_number | sed s/[a-z]*//g) + + my_echo "** b-u: Your current revision is: $type $revnr." +} + +function apply_rev() +{ + my_echo + my_echo "** b-u: Applying patch revision_$type$newrevnr" + + cd $packdir + + if [ -e $newrevdir/prepatch ]; then + $newrevdir/prepatch 2>> $log_file | tee -a $log_file + fi + + patch -p1 < $newrevdir/patch* 2>> $log_file | tee -a $log_file + + if [ -e $newrevdir/postpatch ]; then + $newrevdir/postpatch 2>> $log_file | tee -a $log_file + fi + + cd $tmpdir/bygfoot-update +} + +# fetch a revision archive from the homepage and +# patch the src package +function get_revision() +{ + local newrevdir=$tmpdir/bygfoot-update/revision_$type$newrevnr + + my_echo + my_echo "** b-u: Retrieving revision_$type$newrevnr.tar.bz2." + my_wget http://bygfoot.sourceforge.net/revisions/$type/revision_$type$newrevnr.tar.bz2 + + mkdir $newrevdir + cd $newrevdir + tar xfjv ../revision_$type$newrevnr.tar.bz2 2>> $log_file | tee -a $log_file + + dialog --title "Bygfoot Online Update" --textbox README 22 75 + + if [ $apply_all -eq 0 ]; then + + dialog --title "Bygfoot Online Update" --menu \ +"Apply patch?\n(You can't apply newer ones if you don't apply this one because they depend on each other.)" \ + 22 80 10 \ + 1 Yes \ + 2 No \ + 3 All 2> $input_file + + read_input + + if [ ! -z $tempvar ]; then + if [ $tempvar -eq 3 ]; then + apply_all=1 + elif [ $tempvar -ne 1 ]; then + my_echo + my_echo "** b-u: User abort." + my_exit $EXITUSR + fi + fi + fi + + apply_rev +} + +# look for new revisions +function get_revs() +{ + my_echo + cd $tmpdir + my_echo "** b-u: Cleaning up old update directories and creating a new one..." + rm -rfv bygfoot-update 2>> $log_file | tee -a $log_file + mkdir -v bygfoot-update 2>> $log_file | tee -a $log_file + cd bygfoot-update + my_echo + my_echo "** b-u: Fetching revision list..." + my_wget http://bygfoot.sourceforge.net/revisions/$type/revisions_$type + + for i in $(cat revisions_$type); do + my_echo + newrevnr=$(echo $i | sed s/'[a-z_]*\([0-9]*\).*'/'\1'/g) + if [ $newrevnr -gt $revnr ]; then + found=$[found + 1] + get_revision + else + my_echo "** b-u: $i is older than your revision..." + fi + done +} + +# clean up etc. +function update_end() +{ + my_echo + + if [ $found -ge 1 ]; then + + dialog --title "Bygfoot Online Update" --msgbox "$found new revisions found.\nYour new revision number should be $[revnr + found].\nHave a look at the files README, ChangeLog and ReleaseNotes to see the changes that were made." 2> $input_file + + if [ $recompile -eq 0 -a $auto -eq 0 ]; then + dialog --title "Bygfoot Online Update" --yesno "Would you like me to execute 'configure && make' ?" 22 80 2> $input_file + + read_input + fi + + if [ $recompile -ne -1 ]; then + cd $packdir + ./configure && make 2>> $log_file | tee -a $log_file + fi + + else + dialog --title "Bygfoot Online Update" --msgbox "No new revisions found.\nYour package seems to be up-to-date." 22 80 2> $input_file + fi + + my_echo + my_echo "** b-u: done." + + my_exit $EXITOK +} + +# set package format from a command line option +function set_format() +{ + if [ $1 = "rpm" ]; then + format=$format_rpm + elif [ $1 = "srpm" ]; then + format=$format_srpm + elif [ $1 = "src" ]; then + format=$format_src + elif [ $1 = "bin" ]; then + format=$format_bin + elif [ $1 = "deb" ]; then + format=$format_deb + else + my_echo "** b-u: Unrecognized package format: $1" + my_echo "** b-u: Failure." + my_exit $EXITPACKFORMAT + fi +} + +# set cvs branch from command line option +function set_branch() +{ + if [ $1 -eq 1 ]; then + cvs_version=$cvs_version1; + else + cvs_version=$cvs_version2; + fi +} + +# ask for the package type (stable/unstable) +function get_type() +{ + if [ ! -z $type ]; then + return + fi + + if [ $auto -ne 1 ];then + + dialog --title "Bygfoot Online Update" --menu "Specify package type" \ + 22 80 10 \ + 1 "Stable" \ + 2 "Unstable" 2> $input_file + + read_input + + if [ $tempvar -eq 2 ]; then + type=$type_unstable + else + type=$type_stable + fi + else + type=$type_stable + fi +} + +# get package format the user wants to download +function get_format() +{ + if [ -z $format ]; then + if [ $auto -ne 1 -a $get_version -ne 1 ]; then + + dialog --title "Bygfoot Online Update" --menu "Specify package format" \ + 22 80 10 \ + 1 "RPM" \ + 2 "Binary" \ + 3 "Source" \ + 4 "Debian" \ + 5 "Source RPM" 2> $input_file + + read_input + + if [ $tempvar -eq 2 ]; then + format=$format_bin + elif [ $tempvar -eq 3 ]; then + format=$format_src + elif [ $tempvar -eq 4 ]; then + format=$format_deb + elif [ $tempvar -eq 5 ]; then + format=$format_srpm + else + format=$format_rpm + fi + else + format=$format_rpm + fi + fi + + if [ "$type" = "$type_unstable" -a "$format" = "$format_deb" ]; then + dialog --title "Bygfoot Online Update" --msgbox \ +"There are no unstable packages for Debian. Sorry.\nFailure." 22 80 2> $input_file + my_exit $EXITDEBIAN + fi +} + +function get_latest_version() +{ + my_echo + my_echo "** b-u: Fetching version number of the latest $type release." + + pushd $tmpdir &> /dev/null + rm -rfv bygfoot-update 2>> $log_file | tee -a $log_file + mkdir bygfoot-update + cd bygfoot-update + my_wget http://bygfoot.sourceforge.net/packages/$type/version + + packversion=$(cat version) + + if [ $get_version -eq 1 ]; then + my_exit $EXITOK + fi + + if [ $auto -eq 1 ]; then + return + fi + + dialog --title "Bygfoot Online Update" --yesno "Latest $type version is $packversion.\nYour version (as far as i know) is $relversion.\nDo you want me to download the package?" 22 80 2> $input_file + + read_input +} + +function get_new_package() +{ + local separator=- + local file= + + if [ $format = $format_rpm -o $format = $format_srpm ]; then + packversion=$(echo $packversion | sed s/'\([0-9]*\.[0-9]*\)\(\.\)\([0-9]*\)'/'\1-\3'/g) + fi + + if [ $format = $format_deb ]; then + separator=_ + fi + + file=bygfoot$separator$packversion$format + + my_wget http://bygfoot.sourceforge.net/packages/$type/$file + + dialog --title "Bygfoot Online Update" --msgbox "You can find the package $file\nin the directory $PWD." \ + 22 80 2> $input_file + my_echo "** b-u: Done." + + my_exit $EXITOK +} + +# download a bygfoot package +function get_package() +{ + get_type + + get_format + + get_latest_version + + get_new_package +} + +function get_mode() +{ + if [ ! -z $mode ]; then + return + fi + + if [ $auto -eq 1 ]; then + mode=$mode_src + return + fi + + dialog --title "Bygfoot Online Update" --menu "Main Menu" 22 80 10 \ + 1 " Update your Bygfoot source package using patches" \ + 2 " Download the latest Bygfoot release" \ + 3 " Get country file package with official team names" \ + 4 " Get CVS version (2+ MB 'cause it's not compressed)" 2> $input_file + + read_input + + if [ -z $tempvar ]; then + mode=$mode_src + return + fi + + if [ $tempvar -eq 2 ]; then + mode=$mode_pack + elif [ $tempvar -eq 3 ]; then + mode=$mode_country + elif [ $tempvar -eq 4 ]; then + mode=$mode_cvs + else + mode=$mode_src + fi +} + +function get_cvs() +{ + if [ -z $cvs_version ];then + dialog --title "Bygfoot Online Update" --menu "Specify CVS version" 22 80 10 \ + 1 " 1.8 branch" \ + 2 " 1.9 branch" 2> $input_file + + read_input + + if [ $tempvar -eq 2 ]; then + cvs_version=$cvs_version2 + else + cvs_version=$cvs_version1 + fi + fi + + if [ -z $cvs_user ];then + dialog --title "Bygfoot Online Update" --inputbox "If you'd like to check out as a developer, enter your\nSourceForge.net username. Press RETURN to download anonymously." 22 80 2> $input_file + + read_input + + if [ -z $tempvar ]; then + cvs_command="cvs -d:pserver:anonymous@cvs.sf.net:/cvsroot/bygfoot" + else + cvs_command="cvs -d:ext:$tempvar@cvs.sf.net:/cvsroot/bygfoot" + fi + else + if [ $cvs_user = "A" ]; then + cvs_command="cvs -d:pserver:anonymous@cvs.sf.net:/cvsroot/bygfoot" + else + cvs_command="cvs -d:ext:$cvs_user@cvs.sf.net:/cvsroot/bygfoot" + fi + fi + + cd $tmpdir + $cvs_command checkout $cvs_version 2>> $log_file | tee -a $log_file + + if [ $recompile -eq 0 -a $auto -eq 0 ]; then + dialog --title "Bygfoot Online Update" \ + --yesno "Would you like me to execute 'autogen.sh && make' ?" 22 80 2> $input_file + + read_input + fi + + if [ $recompile -ne -1 ]; then + cd $cvs_version + ./autogen.sh && make 2>> $log_file | tee -a $log_file + fi + + my_exit $EXITOK +} + +parse_args $* +print_version + +echo "Bygfoot Online Update $version log file" > $log_file +echo "Don't forget to remove this file if you don't need it anymore." >> $log_file + +check_progs +get_mode +get_paths + +# what to do when user presses Ctrl-C +trap 'my_echo; my_echo "** b-u: User abort." & my_exit $EXITABORT' 2 +if [ $mode -eq $mode_country ]; then + get_country_files +elif [ $mode -eq $mode_pack ]; then + get_package +elif [ $mode -eq $mode_cvs ]; then + get_cvs +else + get_rev_type + get_revs + update_end +fi diff --git a/bygfoot.glade b/bygfoot.glade index 5cc16dbc..17b7cfd3 100644 --- a/bygfoot.glade +++ b/bygfoot.glade @@ -15,6 +15,11 @@ True False bygfoot_icon.png + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST @@ -29,13 +34,13 @@ True - + True _File True - + @@ -74,13 +79,13 @@ - + True - + True @@ -93,7 +98,7 @@ - + True gtk-preferences 1 @@ -114,7 +119,7 @@ - + True gtk-refresh 1 @@ -128,7 +133,7 @@ - + True @@ -139,7 +144,6 @@ gtk-quit True - @@ -148,13 +152,13 @@ - + True Options True - + @@ -164,7 +168,7 @@ - + True gtk-preferences 1 @@ -178,7 +182,7 @@ - + True @@ -254,133 +258,6 @@ - - - True - More fixtures - True - - - - - - - True - League 1 - True - - - - - - - True - League 2 - True - - - - - - - True - League 3 - True - - - - - - - True - League 4 - True - - - - - - - True - League 5 - True - - - - - - - True - League 6 - True - - - - - - - True - - - - - - True - Cup 1 - True - - - - - - - True - Cup 2 - True - - - - - - - True - Cup 3 - True - - - - - - - True - Cup 4 - True - - - - - - - True - Cup 5 - True - - - - - - - True - Cup 6 - True - - - - - - - - True @@ -407,15 +284,6 @@ - - - - True - Team history - True - - - @@ -445,7 +313,7 @@ All Out Defend True True - + @@ -456,7 +324,7 @@ True True menu_all_out_defend - + @@ -467,7 +335,7 @@ True True menu_all_out_defend - + @@ -478,7 +346,7 @@ True True menu_all_out_defend - + @@ -489,7 +357,7 @@ True True menu_all_out_defend - + @@ -512,7 +380,7 @@ Best True True - + @@ -523,7 +391,7 @@ True True menu_scout_best - + @@ -534,7 +402,7 @@ True True menu_scout_best - + @@ -545,7 +413,7 @@ True True menu_scout_best - + @@ -568,7 +436,7 @@ Best True True - + @@ -579,7 +447,7 @@ True True menu_physio_best - + @@ -590,7 +458,7 @@ True True menu_physio_best - + @@ -601,7 +469,7 @@ True True menu_physio_best - + @@ -615,7 +483,22 @@ Boost True False - + + + + + + + True + Enter custom structure + True + + + + + + + True @@ -651,15 +534,6 @@ - - - True - Show history - True - - - - True @@ -700,6 +574,85 @@ + + + True + User + True + + + + + + + True + Next user + True + + + + + + True + gtk-go-forward + 1 + 0.5 + 0.5 + 0 + 0 + + + + + + + + True + Previous user + True + + + + + + True + gtk-go-back + 1 + 0.5 + 0.5 + 0 + 0 + + + + + + + + True + Manage users + True + + + + + + True + gtk-justify-fill + 1 + 0.5 + 0.5 + 0 + 0 + + + + + + + + + True @@ -751,13 +704,13 @@ - + True _Help True - + @@ -802,6 +755,7 @@ Load game (L or Ctrl - O) True GTK_RELIEF_NORMAL + True @@ -831,6 +785,7 @@ Save game (S or Ctrl - S) True GTK_RELIEF_NORMAL + True @@ -860,8 +815,9 @@ Quit (Ctrl - Q) True GTK_RELIEF_NORMAL + True - + @@ -915,6 +871,7 @@ Back to main menu (Esc) True GTK_RELIEF_NORMAL + True @@ -944,6 +901,7 @@ Show transferlist (T) True GTK_RELIEF_NORMAL + True @@ -972,6 +930,7 @@ Finances and stadium (F) True GTK_RELIEF_NORMAL + True @@ -1000,6 +959,7 @@ Show my last games and a preview of my next games (P or F1) True GTK_RELIEF_NORMAL + True @@ -1042,6 +1002,7 @@ Begin a new week (Space) True GTK_RELIEF_NORMAL + True @@ -1070,6 +1031,7 @@ Help (H) True GTK_RELIEF_NORMAL + True @@ -1094,7 +1056,7 @@ - + True True False @@ -1102,7 +1064,7 @@ 0 True - * + * False @@ -1135,6 +1097,8 @@ True + True + False @@ -1142,10 +1106,31 @@ False 0 + + + True + user + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + True - Season + Season False False GTK_JUSTIFY_LEFT @@ -1226,6 +1211,48 @@ + + + True + Round + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + 1 + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + 15 @@ -1248,6 +1275,8 @@ True + True + False @@ -1303,6 +1332,8 @@ True + True + False @@ -1433,6 +1464,8 @@ True First value: average current skill of the first 11 players. Second value: average skill of all players. + True + False @@ -1462,7 +1495,7 @@ - + True label70 False @@ -1551,7 +1584,7 @@ False False True - + False @@ -1668,33 +1701,6 @@ False - - - - 2 - Browse teams to find and buy new players - True - GTK_RELIEF_NORMAL - - - - - True - gtk-find - 4 - 0.5 - 0.5 - 0 - 0 - - - - - 0 - False - False - - 0 @@ -1744,6 +1750,7 @@ Next (W) True GTK_RELIEF_NORMAL + True @@ -1808,8 +1815,8 @@ Previous (Q) True GTK_RELIEF_NORMAL + True - @@ -1846,163 +1853,6 @@ - - - True - False - 0 - - - - True - Team Structure - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 4 - - - 0 - False - False - - - - - - True - False - 0 - - - - True - Here you can enter a custom structure like 334 (or 019, for that matter) - True - True - True - 4 - - True - * - False - 4 - - - - 3 - False - False - - - - - - 2 - True - Change or update team structure (C) You can enter custom structures like 334, too. - True - GTK_RELIEF_NORMAL - - - - - - True - gtk-refresh - 4 - 0.5 - 0.5 - 0 - 0 - - - - - 0 - False - False - - - - - - 2 - True - Rearrange team (R) (try to put each player on his prefered position and sort the substitutes) - True - GTK_RELIEF_NORMAL - - - - - - True - gtk-sort-ascending - 4 - 0.5 - 0.5 - 0 - 0 - - - - - 0 - False - False - - - - - - 2 - True - Undo! (Y / Ctrl-Z) - True - GTK_RELIEF_NORMAL - - - - - - - True - gtk-undo - 4 - 0.5 - 0.5 - 0 - 0 - - - - - 0 - False - False - - - - - 0 - True - True - - - - - 0 - True - True - - - False @@ -2034,78 +1884,6 @@ False - - - - 2 - True - Show fixtures (F4) - True - GTK_RELIEF_NORMAL - - - - - - True - 0.5 - 0.5 - 0 - 0 - - - - True - False - 2 - - - - True - preview.png - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - Fixtures - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - - - - 0 - False - False - - 0 @@ -2140,79 +1918,6 @@ False - - - - 2 - True - Show tables (F5) - True - GTK_RELIEF_NORMAL - - - - - - True - 0.5 - 0.5 - 0 - 0 - - - - True - False - 2 - - - - True - gtk-justify-left - 4 - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - Tables - True - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - - - - 0 - False - False - - 0 diff --git a/bygfoot_misc.glade b/bygfoot_misc.glade index 3ea8ce35..6ccda2b0 100644 --- a/bygfoot_misc.glade +++ b/bygfoot_misc.glade @@ -71,124 +71,6 @@ - - - True - Start in - False - False - GTK_JUSTIFY_LEFT - False - False - 0.05 - 0.5 - 0 - 0 - - - 0 - False - False - - - - - - True - Play normal league games and cups - True - False - - - - True - False - 0 - - - - 3 - True - True - Top league - True - GTK_RELIEF_NORMAL - True - False - False - True - - - 0 - False - False - - - - - - 3 - True - True - Current league - True - GTK_RELIEF_NORMAL - True - True - False - True - team_selection_radio1 - - - 0 - False - False - - - - - - 3 - True - True - Bottom league - True - GTK_RELIEF_NORMAL - True - False - False - True - team_selection_radio1 - - - 0 - False - False - - - - - - - 5 - False - True - - - - - - 1 - 10 - True - - - 0 - False - False - - - True @@ -363,6 +245,124 @@ + + + 1 + 10 + True + + + 0 + False + False + + + + + + True + Start in + False + False + GTK_JUSTIFY_LEFT + False + False + 0.05 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + Play normal league games and cups + True + False + + + + True + False + 0 + + + + 3 + True + True + Top league + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + 3 + True + True + Current league + True + GTK_RELIEF_NORMAL + True + True + False + True + team_selection_radio1 + + + 0 + False + False + + + + + + 3 + True + True + Bottom league + True + GTK_RELIEF_NORMAL + True + False + False + True + team_selection_radio1 + + + 0 + False + False + + + + + + + 5 + False + True + + + 1 @@ -377,114 +377,63 @@ - + True False - 0 + 5 - + True - False - 0 - - - - 2 - True - If you check this, the game generates all players randomly and won't read the file with team definitions - True - Don't load team definitions - True - GTK_RELIEF_NORMAL - True - False - False - True - - - - 0 - False - False - - - - - - 2 - True - If you check this, only the player names and the team structures are loaded from the definition file, values like skill or age are generated randomly - True - Load only names from team definition file - True - GTK_RELIEF_NORMAL - True - False - False - True - - - - 0 - False - False - - - - - - 2 - True - Check this if you'd like to have your team loaded from the definitions file no matter what the other checkbuttons say. - True - Load my team from definitions file - True - GTK_RELIEF_NORMAL - True - True - False - True - - - 0 - False - False - - + Player name + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 0 False + False + + + + + + True + True + True + True + 12 + + True + * + False + 12 + + + + 0 + True True - - 10 - 1 + True - - - 0 - False - True - - - - - - 3 - True - You can start the editor from the commandline with 'bygfoot -e' or '--editor' True GTK_RELIEF_NORMAL True - + - + True 0.5 0.5 @@ -496,15 +445,15 @@ 0 - + True False 2 - + True - gtk-preferences + gtk-add 4 0.5 0.5 @@ -519,9 +468,9 @@ - + True - Start Bygfoot Team Editor + Add player True False GTK_JUSTIFY_LEFT @@ -545,8 +494,8 @@ 0 - True - True + False + False @@ -557,6 +506,19 @@ + + + 1 + 10 + True + + + 0 + False + True + + + True @@ -567,15 +529,16 @@ 2 True - Return + False + Space True GTK_RELIEF_NORMAL True - - + + - + True 0.5 0.5 @@ -587,13 +550,13 @@ 0 - + True False 2 - + True gtk-apply 4 @@ -610,9 +573,9 @@ - + True - OK + Start True False GTK_JUSTIFY_LEFT @@ -1936,4 +1899,45 @@ + + True + Players + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + 250 + 200 + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_EAST + + + + True + True + GTK_POLICY_ALWAYS + GTK_POLICY_ALWAYS + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT + + + + True + Click on a player to remove him + True + True + False + False + True + + + + + + + diff --git a/configure.in b/configure.in index fb098c01..944a00dd 100644 --- a/configure.in +++ b/configure.in @@ -12,21 +12,23 @@ AC_HEADER_STDC pkg_modules="gtk+-2.0 >= 2.0.0" PKG_CHECK_MODULES(PACKAGE, [$pkg_modules]) +PKG_CHECK_MODULES(GNET, gnet-2.0 > 2.0.0, + [LIBS="$LIBS $GNET_LIBS" CFLAGS="$CFLAGS $GNET_CFLAGS"], + AC_MSG_ERROR(Cannot find GNet: Is gnet-config in path?)) AC_SUBST(PACKAGE_CFLAGS) AC_SUBST(PACKAGE_LIBS) GETTEXT_PACKAGE=bygfoot AC_SUBST(GETTEXT_PACKAGE) -AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE") +AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package.]) dnl Add the languages which your application supports here. -ALL_LINGUAS="fr de ru ro hu pt_BR" +ALL_LINGUAS="" AM_GLIB_GNU_GETTEXT AC_OUTPUT([ Makefile src/Makefile -b-u/Makefile po/Makefile.in ]) diff --git a/src/Makefile.am b/src/Makefile.am index 280c2a6c..4ae65b7b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -12,9 +12,6 @@ bygfoot_SOURCES = \ callback_func.c callback_func.h \ callbacks.c callbacks.h \ cup.c cup.h free.h maths.h misc.h team.h variables.h xml_league.h \ - editor_callback_func.c editor_callback_func.h \ - editor_callbacks.c editor_callbacks.h \ - editor_interface.c editor_interface.h \ file.c file.h free.h misc.h support.h \ finance.c finance.h \ fixture.c cup.h fixture.h league_struct.h main.h maths.h misc.h team.h variables.h \ @@ -43,11 +40,12 @@ bygfoot_SOURCES = \ player.c free.h league.h maths.h player.h team.h variables.h \ start_end.c cup.h fixture.h league.h maths.h player.h start_end.h team.h transfer.h variables.h xml_name.h \ support.c support.h \ + table.c table.h \ team.c cup.h free.h league.h maths.h player.h team.h variables.h \ transfer.c transfer.h \ treeview.c gui.h league.h support.h team.h treeview.h variables.h \ treeview_cell.c treeview_cell.h \ - user.c team.h user.h \ + user.c team.h user.h user_struct.h \ window.c misc_interface.h file.h free.h support.h window.h \ xml_cup.c cup.h file.h misc.h variables.h xml_cup.h \ xml_country.c file.h free.h league.h misc.h variables.h xml_cup.h xml_country.h xml_league.h \ diff --git a/src/bygfoot.h b/src/bygfoot.h index aadeb9ff..9a88d61a 100644 --- a/src/bygfoot.h +++ b/src/bygfoot.h @@ -24,6 +24,33 @@ #define SMALL 10000 #define BIG 1000000 +/** Starting numbers of league, cup and supercup numerical ids. */ +#define ID_LEAGUE_START 1000 +#define ID_CUP_START 2000 + +/** The player names file. */ +#define PLAYER_NAMES_FILE "player_names.xml" + +/** Convenience abbreviation. */ +#define ligs country.leagues +/** Convenience abbreviation. */ +#define lig(i) g_array_index(country.leagues, League, i) + +/** Convenience abbreviation. */ +#define cps country.cups +/** Convenience abbreviation. */ +#define cp(i) g_array_index(country.cups, Cup, i) + +/** Convenience abbreviation. */ +#define player_name(i) ((GString*)g_ptr_array_index(player_names, i))->str; + +/** Convenience abbrevs. */ +#define stat0 status[0] +#define stat1 status[1] +#define stat2 status[2] +#define stat3 status[3] +#define stat4 status[4] + /** * Exit codes. */ @@ -39,23 +66,6 @@ enum ExitCodes EXIT_END }; -/** Scout and physio qualities. */ -enum Quality -{ - QUALITY_BEST = 1, - QUALITY_GOOD, - QUALITY_AVERAGE, - QUALITY_BAD, - QUALITY_END -}; - -/** Starting numbers of league, cup and supercup numerical ids. */ -#define ID_LEAGUE_START 1000 -#define ID_CUP_START 2000 - -/** The player names file. */ -#define PLAYER_NAMES_FILE "player_names.xml" - /** * A struct representing a country. */ @@ -69,17 +79,21 @@ typedef struct GArray *leagues, *cups; } Country; -/** Convenience abbreviation. */ -#define ligs country.leagues -/** Convenience abbreviation. */ -#define lig(i) g_array_index(country.leagues, League, i) +/** Struct used for having all the windows + in one place. */ +typedef struct +{ + GtkWidget *main, + *startup, + *startup_users, + *live; +} Windows; -/** Convenience abbreviation. */ -#define cps country.cups -/** Convenience abbreviation. */ -#define cp(i) g_array_index(country.cups, Cup, i) - -/** Convenience abbreviation. */ -#define player_name(i) ((GString*)g_ptr_array_index(player_names, i))->str; +/** A struct representing an option or a constant. */ +typedef struct +{ + GString *name, *string_value; + gint value; +} Option; #endif diff --git a/src/callback_func.c b/src/callback_func.c index e69de29b..cf2c53af 100644 --- a/src/callback_func.c +++ b/src/callback_func.c @@ -0,0 +1,88 @@ +#include "callback_func.h" +#include "cup.h" +#include "fixture.h" +#include "game_gui.h" +#include "league.h" +#include "live_game.h" +#include "option.h" +#include "player.h" +#include "start_end.h" +#include "team.h" +#include "treeview.h" +#include "user.h" +#include "variables.h" +#include "window.h" + +/** Show the users' live games. */ +void +callback_show_next_live_game(void) +{ + gint i, j; + + if(week_round == 1) + { + for(i=0;ilen;i++) + for(j=0;jlen;j++) + if(g_array_index(lig(i).fixtures, Fixture, j).week_number == week && + g_array_index(lig(i).fixtures, Fixture, j).week_round_number == week_round && + fixture_user_team_involved(&g_array_index(lig(i).fixtures, Fixture, j)) != -1 && + g_array_index(lig(i).fixtures, Fixture, j).attendance == -1) + { + live_game_calculate_fixture(&g_array_index(lig(i).fixtures, Fixture, j)); + return; + } + } + else + { + for(i=0;ilen;i++) + for(j=0;jlen;j++) + if(g_array_index(cp(i).fixtures, Fixture, j).week_number == week && + g_array_index(cp(i).fixtures, Fixture, j).week_round_number == week_round && + fixture_user_team_involved(&g_array_index(cp(i).fixtures, Fixture, j)) && + g_array_index(cp(i).fixtures, Fixture, j).attendance == -1) + { + live_game_calculate_fixture(&g_array_index(cp(i).fixtures, Fixture, j)); + return; + } + } + + window_destroy(&window.live); + + /* no more user games to show: end round. */ + end_week_round(); + stat0 = STATUS_MAIN; +} + +/** Handle a click on the player list. + @param idx The player number. + @param event The type of button click. */ +void +callback_player_clicked(gint idx, GdkEventButton *event) +{ + /** Only accept single-clicks right now. */ + if(event->type != GDK_BUTTON_PRESS) + return; + + if(event->button == 1) + { + if(selected_row[0] == -1) + { + selected_row[0] = idx; + return; + } + + player_swap(usr(current_user).tm, selected_row[0], + usr(current_user).tm, idx); + if(opt_user_int("int_opt_user_swap_adapts") == 1) + { + team_change_structure(usr(current_user).tm, + team_find_appropriate_structure(usr(current_user).tm)); + team_rearrange(usr(current_user).tm); + } + game_gui_write_av_skills(); + + selected_row[0] = -1; + + treeview_show_user_player_list(&usr(current_user), 1); + } +} diff --git a/src/callback_func.h b/src/callback_func.h index e69de29b..f928c697 100644 --- a/src/callback_func.h +++ b/src/callback_func.h @@ -0,0 +1,12 @@ +#ifndef CALLBACK_FUNC_H +#define CALLBACK_FUNC_H + +#include "bygfoot.h" + +void +callback_show_next_live_game(void); + +void +callback_player_clicked(gint idx, GdkEventButton *event); + +#endif diff --git a/src/callbacks.c b/src/callbacks.c index 0b575da0..6090fb82 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -1,12 +1,7 @@ #include "callbacks.h" -/*d*/ -#include "game.h" -#include "live_game.h" -#include "maths.h" -#include "player.h" -#include "team.h" - -#include "gui.h" +#include "callback_func.h" +#include "enums.h" +#include "game_gui.h" #include "main.h" #include "treeview.h" #include "variables.h" @@ -146,29 +141,8 @@ void on_button_new_week_clicked (GtkButton *button, gpointer user_data) { - /*d*/ - gint i, j, k; - Fixture *fix;/* = &g_array_index(lig(0).fixtures, Fixture, */ -/* math_rndi(0, lig(0).fixtures->len - 1)); */ - - for(k=0;klen;k++) - if(g_array_index(lig(0).fixtures, Fixture, k).week_number == week && - g_array_index(lig(0).fixtures, Fixture, k).week_round_number == 1) - { - fix = &g_array_index(lig(0).fixtures, Fixture, k); - - printf("\n"); - for(j=0;j<2;j++) - { - printf("%s structure %d style %d av. cskill %.1f\n", - fix->teams[j]->name->str, fix->teams[j]->structure, - fix->teams[j]->style, team_average_cskill(fix->teams[j])); - } - - live_game_calculate_fixture(fix); - } - - week++; + stat0 = STATUS_SHOW_LIVE_GAME; + callback_show_next_live_game(); } @@ -179,13 +153,26 @@ on_button_help_clicked (GtkButton *button, } + gboolean -on_player_list_button_press_event (GtkWidget *widget, +on_player_list1_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data) { + gint idx = -1; - return FALSE; + treeview_select_row(GTK_TREE_VIEW(widget), event); + idx = treeview_get_index(GTK_TREE_VIEW(widget), 0); + + if(idx < 0) + { + selected_row[0] = -1; + return FALSE; + } + + callback_player_clicked(idx - 1, event); + + return FALSE; } @@ -325,103 +312,6 @@ on_menu_fixtures_activate (GtkMenuItem *menuitem, } - -void -on_menu_league1_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ - -} - - -void -on_menu_league2_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ - -} - - -void -on_menu_league3_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ - -} - - -void -on_menu_league4_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ - -} - - -void -on_menu_league5_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ - -} - - -void -on_menu_league6_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ - -} - - -void -on_menu_cup_1_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ - -} - - -void -on_menu_cup2_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ - -} - - -void -on_menu_cup3_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ - -} - - -void -on_menu_cup4_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ - -} - - -void -on_menu_cup5_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ - -} - - -void -on_menu_cup6_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ - -} - - void on_menu_tables_activate (GtkMenuItem *menuitem, gpointer user_data) @@ -446,14 +336,6 @@ on_menu_season_history_activate (GtkMenuItem *menuitem, } -void -on_menu_team_history_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ - -} - - void on_menu_player_activate (GtkMenuItem *menuitem, gpointer user_data) @@ -470,14 +352,6 @@ on_menu_show_info_activate (GtkMenuItem *menuitem, } -void -on_menu_show_history_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ - -} - - void on_menu_put_on_transfer_list_activate (GtkMenuItem *menuitem, gpointer user_data) @@ -614,14 +488,6 @@ on_menu_physio_bad_activate (GtkMenuItem *menuitem, } -void -on_menu_boost_activate (GtkMenuItem *menuitem, - gpointer user_data) -{ - -} - - void on_menu_my_league_results_activate (GtkMenuItem *menuitem, gpointer user_data) @@ -635,11 +501,11 @@ on_menu_browse_teams_activate (GtkMenuItem *menuitem, gpointer user_data) { GtkWidget *treeview_right = - lookup_widget(main_window, "treeview_right"); + lookup_widget(window.main, "treeview_right"); - treeview_show_team_list(GTK_TREE_VIEW(treeview_right), TRUE); + treeview_show_team_list(GTK_TREE_VIEW(treeview_right), TRUE, TRUE); - status = STATUS_BROWSE_TEAMS; + stat0 = STATUS_BROWSE_TEAMS; } @@ -692,3 +558,59 @@ on_menu_pay_loan_activate (GtkMenuItem *menuitem, } + +void +on_menu_next_user_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + current_user = (current_user + 1) % users->len; + + stat0 = STATUS_MAIN; + game_gui_show_main(); +} + + +void +on_menu_previous_user_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + current_user = (current_user == 0) ? users->len - 1 : current_user - 1; + + stat0 = STATUS_MAIN; + game_gui_show_main(); +} + + +void +on_menu_show_user_list_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + +} + + +void +on_menu_custom_structure_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + +} + + +gboolean +on_menu_team_button_press_event (GtkWidget *widget, + GdkEventButton *event, + gpointer user_data) +{ + game_gui_read_radio_items(widget); + + return FALSE; +} + +void +on_menu_manage_users_activate (GtkMenuItem *menuitem, + gpointer user_data) +{ + +} + diff --git a/src/callbacks.h b/src/callbacks.h index 5faca6ec..78bb0024 100644 --- a/src/callbacks.h +++ b/src/callbacks.h @@ -2,7 +2,6 @@ #define CALLBACKS_H #include "bygfoot.h" - #include "interface.h" #include "support.h" @@ -79,11 +78,6 @@ void on_button_help_clicked (GtkButton *button, gpointer user_data); -gboolean -on_player_list_button_press_event (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data); - void on_structure_entry_activate (GtkEntry *entry, gpointer user_data); @@ -152,54 +146,6 @@ void on_menu_fixtures_activate (GtkMenuItem *menuitem, gpointer user_data); -void -on_menu_league1_activate (GtkMenuItem *menuitem, - gpointer user_data); - -void -on_menu_league2_activate (GtkMenuItem *menuitem, - gpointer user_data); - -void -on_menu_league3_activate (GtkMenuItem *menuitem, - gpointer user_data); - -void -on_menu_league4_activate (GtkMenuItem *menuitem, - gpointer user_data); - -void -on_menu_league5_activate (GtkMenuItem *menuitem, - gpointer user_data); - -void -on_menu_league6_activate (GtkMenuItem *menuitem, - gpointer user_data); - -void -on_menu_cup_1_activate (GtkMenuItem *menuitem, - gpointer user_data); - -void -on_menu_cup2_activate (GtkMenuItem *menuitem, - gpointer user_data); - -void -on_menu_cup3_activate (GtkMenuItem *menuitem, - gpointer user_data); - -void -on_menu_cup4_activate (GtkMenuItem *menuitem, - gpointer user_data); - -void -on_menu_cup5_activate (GtkMenuItem *menuitem, - gpointer user_data); - -void -on_menu_cup6_activate (GtkMenuItem *menuitem, - gpointer user_data); - void on_menu_tables_activate (GtkMenuItem *menuitem, gpointer user_data); @@ -212,10 +158,6 @@ void on_menu_season_history_activate (GtkMenuItem *menuitem, gpointer user_data); -void -on_menu_team_history_activate (GtkMenuItem *menuitem, - gpointer user_data); - void on_menu_player_activate (GtkMenuItem *menuitem, gpointer user_data); @@ -224,10 +166,6 @@ void on_menu_show_info_activate (GtkMenuItem *menuitem, gpointer user_data); -void -on_menu_show_history_activate (GtkMenuItem *menuitem, - gpointer user_data); - void on_menu_put_on_transfer_list_activate (GtkMenuItem *menuitem, gpointer user_data); @@ -297,10 +235,6 @@ void on_menu_physio_bad_activate (GtkMenuItem *menuitem, gpointer user_data); -void -on_menu_boost_activate (GtkMenuItem *menuitem, - gpointer user_data); - void on_menu_my_league_results_activate (GtkMenuItem *menuitem, gpointer user_data); @@ -314,8 +248,6 @@ gboolean on_treeview_right_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer user_data); -#endif - void on_menu_finances_stadium_activate (GtkMenuItem *menuitem, gpointer user_data); @@ -335,3 +267,34 @@ on_menu_get_loan_activate (GtkMenuItem *menuitem, void on_menu_pay_loan_activate (GtkMenuItem *menuitem, gpointer user_data); + +void +on_menu_next_user_activate (GtkMenuItem *menuitem, + gpointer user_data); + +void +on_menu_previous_user_activate (GtkMenuItem *menuitem, + gpointer user_data); + +void +on_menu_show_user_list_activate (GtkMenuItem *menuitem, + gpointer user_data); + +void +on_menu_custom_structure_activate (GtkMenuItem *menuitem, + gpointer user_data); + +gboolean +on_player_list1_button_press_event (GtkWidget *widget, + GdkEventButton *event, + gpointer user_data); + +gboolean +on_menu_team_button_press_event (GtkWidget *widget, + GdkEventButton *event, + gpointer user_data); +#endif + +void +on_menu_manage_users_activate (GtkMenuItem *menuitem, + gpointer user_data); diff --git a/src/cup.c b/src/cup.c index aaa42f5f..5b8f2463 100644 --- a/src/cup.c +++ b/src/cup.c @@ -230,8 +230,9 @@ cup_load_choose_team_user(Cup *cup) for(i = choose_team->start_idx - 1; i <= choose_team->end_idx - 1; i++) { - if(!query_is_in_international_cups(&g_array_index(lig(number - 1).teams, - Team, permutation[i - choose_team->start_idx + 1]))) + if(!query_is_in_international_cups( + &g_array_index(lig(number - 1).teams, + Team, permutation[i - choose_team->start_idx + 1]))) { g_ptr_array_add(cup->user_teams, (gpointer)&g_array_index(lig(number - 1).teams, @@ -305,7 +306,8 @@ cup_get_matchdays_in_cup_round(const Cup *cup, gint cup_round) { number_of_teams = cup_round_get_number_of_teams(cup, cup_round); number_of_matchdays = - 2 * (number_of_teams / g_array_index(cup->rounds, CupRound, cup_round).round_robin_number_of_groups - 1); + 2 * (number_of_teams / g_array_index(cup->rounds, CupRound, cup_round). + round_robin_number_of_groups); } else if(g_array_index(cup->rounds, CupRound, cup_round).home_away) number_of_matchdays = 2; @@ -353,3 +355,19 @@ cup_get_team_pointers(const Cup *cup) return teams; } + +/** Return the cup pointer belonging to the id. + @param clid The id we look for. + @return The cup pointer or NULL if failed. */ +Cup* +cup_from_clid(gint clid) +{ + gint i; + + for(i=0;ilen;i++) + if(cp(i).id == clid) + return &cp(i); + + g_warning("cup_from_clid: didn't find cup with id %d\n", clid); + return NULL; +} diff --git a/src/cup.h b/src/cup.h index 08cd7e65..acd8d587 100644 --- a/src/cup.h +++ b/src/cup.h @@ -37,4 +37,7 @@ cup_get_matchdays_in_cup_round(const Cup *cup, gint cup_round); gint cup_round_get_number_of_teams(const Cup *cup, gint cup_round); +Cup* +cup_from_clid(gint clid); + #endif diff --git a/src/editor_callback_func.c b/src/editor_callback_func.c deleted file mode 100644 index e69de29b..00000000 diff --git a/src/editor_callback_func.h b/src/editor_callback_func.h deleted file mode 100644 index e69de29b..00000000 diff --git a/src/editor_callbacks.c b/src/editor_callbacks.c deleted file mode 100644 index 2d6af4c2..00000000 --- a/src/editor_callbacks.c +++ /dev/null @@ -1,175 +0,0 @@ -#ifdef HAVE_CONFIG_H -# include -#endif - -#include - -#include "editor_callbacks.h" -#include "editor_interface.h" -#include "support.h" - - -gboolean -on_button_exit_clicked (GtkWidget *widget, - GdkEvent *event, - gpointer user_data) -{ - - return FALSE; -} - - -void -on_button_choose_def_clicked (GtkButton *button, - gpointer user_data) -{ - -} - - -void -on_entry_country_file_changed (GtkEditable *editable, - gpointer user_data) -{ - -} - - -void -on_button_browse_team_files_clicked (GtkButton *button, - gpointer user_data) -{ - -} - - -void -on_entry_team_changed (GtkEditable *editable, - gpointer user_data) -{ - -} - - -void -on_button_change_structures_clicked (GtkEntry *entry, - gpointer user_data) -{ - -} - - -void -on_spinbutton_average_skill_value_changed - (GtkSpinButton *spinbutton, - gpointer user_data) -{ - -} - - -gboolean -on_treeview_players_button_press_event (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data) -{ - - return FALSE; -} - - -void -on_button_update_clicked (GtkEntry *entry, - gpointer user_data) -{ - -} - - -void -on_button_prev_clicked (GtkButton *button, - gpointer user_data) -{ - -} - - -void -on_button_next_clicked (GtkButton *button, - gpointer user_data) -{ - -} - - -void -on_button_swap_clicked (GtkEntry *entry, - gpointer user_data) -{ - -} - - -void -on_button_up_clicked (GtkButton *button, - gpointer user_data) -{ - -} - - -void -on_button_down_clicked (GtkButton *button, - gpointer user_data) -{ - -} - - -void -on_button_editor_help_clicked (GtkButton *button, - gpointer user_data) -{ - -} - - -void -on_button_save_defs_clicked (GtkButton *button, - gpointer user_data) -{ - -} - - -void -on_button_import_clicked (GtkButton *button, - gpointer user_data) -{ - -} - - -void -on_button_export_clicked (GtkButton *button, - gpointer user_data) -{ - -} - - -void -on_button_play_ws_clicked (GtkButton *button, - gpointer user_data) -{ - -} - - -void -on_button_save_play_clicked (GtkButton *button, - gpointer user_data) -{ - -} - diff --git a/src/editor_callbacks.h b/src/editor_callbacks.h deleted file mode 100644 index 327e6976..00000000 --- a/src/editor_callbacks.h +++ /dev/null @@ -1,85 +0,0 @@ -#include - - -gboolean -on_button_exit_clicked (GtkWidget *widget, - GdkEvent *event, - gpointer user_data); - -void -on_button_choose_def_clicked (GtkButton *button, - gpointer user_data); - -void -on_entry_country_file_changed (GtkEditable *editable, - gpointer user_data); - -void -on_button_browse_team_files_clicked (GtkButton *button, - gpointer user_data); - -void -on_entry_team_changed (GtkEditable *editable, - gpointer user_data); - -void -on_button_change_structures_clicked (GtkEntry *entry, - gpointer user_data); - -void -on_spinbutton_average_skill_value_changed - (GtkSpinButton *spinbutton, - gpointer user_data); - -gboolean -on_treeview_players_button_press_event (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data); - -void -on_button_update_clicked (GtkEntry *entry, - gpointer user_data); - -void -on_button_prev_clicked (GtkButton *button, - gpointer user_data); - -void -on_button_next_clicked (GtkButton *button, - gpointer user_data); - -void -on_button_swap_clicked (GtkEntry *entry, - gpointer user_data); - -void -on_button_up_clicked (GtkButton *button, - gpointer user_data); - -void -on_button_down_clicked (GtkButton *button, - gpointer user_data); - -void -on_button_editor_help_clicked (GtkButton *button, - gpointer user_data); - -void -on_button_save_defs_clicked (GtkButton *button, - gpointer user_data); - -void -on_button_import_clicked (GtkButton *button, - gpointer user_data); - -void -on_button_export_clicked (GtkButton *button, - gpointer user_data); - -void -on_button_play_ws_clicked (GtkButton *button, - gpointer user_data); - -void -on_button_save_play_clicked (GtkButton *button, - gpointer user_data); diff --git a/src/editor_defs.h b/src/editor_defs.h deleted file mode 100644 index e69de29b..00000000 diff --git a/src/editor_interface.c b/src/editor_interface.c deleted file mode 100644 index daa1193b..00000000 --- a/src/editor_interface.c +++ /dev/null @@ -1,1035 +0,0 @@ -/* - * DO NOT EDIT THIS FILE - it is generated by Glade. - */ - -#ifdef HAVE_CONFIG_H -# include -#endif - -#include -#include -#include -#include -#include - -#include -#include - -#include "editor_callbacks.h" -#include "editor_interface.h" -#include "support.h" - -#define GLADE_HOOKUP_OBJECT(component,widget,name) \ - g_object_set_data_full (G_OBJECT (component), name, \ - gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref) - -#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \ - g_object_set_data (G_OBJECT (component), name, widget) - -GtkWidget* -create_editor_window (void) -{ - GtkWidget *editor_window; - GdkPixbuf *editor_window_icon_pixbuf; - GtkWidget *vbox36; - GtkWidget *hbox86; - GtkWidget *vbox42; - GtkWidget *label138; - GtkWidget *entry_definitions_file; - GtkWidget *button_choose_def; - GtkWidget *image68; - GtkWidget *hbox50; - GtkWidget *vbox37; - GtkWidget *label73; - GtkWidget *combo_team_file; - GtkWidget *entry_country_file; - GtkWidget *button_browse_team_files; - GtkWidget *image56; - GtkWidget *hseparator16; - GtkWidget *hbox69; - GtkWidget *vbox38; - GtkWidget *label75; - GtkWidget *hbox51; - GtkWidget *combo_team_names; - GtkWidget *entry_team; - GtkWidget *eventbox2; - GtkWidget *hbox98; - GtkWidget *label183; - GtkWidget *entry_team_name; - GtkWidget *vseparator123; - GtkWidget *vbox41; - GtkWidget *label_structures; - GtkWidget *hbox85; - GtkWidget *entry_structure1; - GtkWidget *entry_structure2; - GtkWidget *button_change_structures; - GtkWidget *image63; - GtkWidget *vseparator124; - GtkWidget *vbox49; - GtkWidget *eventbox1; - GtkWidget *vbox50; - GtkWidget *label182; - GtkObject *spinbutton_average_skill_adj; - GtkWidget *spinbutton_average_skill; - GtkWidget *hseparator13; - GtkWidget *scrolledwindow1; - GtkWidget *treeview_players; - GtkWidget *hbox94; - GtkWidget *vbox48; - GtkWidget *label181; - GtkWidget *label_number; - GtkWidget *vbox44; - GtkWidget *label174; - GtkWidget *entry_name; - GtkWidget *vbox45; - GtkWidget *label175; - GtkObject *spinbutton_skill_adj; - GtkWidget *spinbutton_skill; - GtkWidget *vbox46; - GtkWidget *label176; - GtkObject *spinbutton_talent_adj; - GtkWidget *spinbutton_talent; - GtkWidget *vbox47; - GtkWidget *label177; - GtkWidget *hbox97; - GtkObject *spinbutton_birth_year_adj; - GtkWidget *spinbutton_birth_year; - GtkObject *spinbutton_birth_month_adj; - GtkWidget *spinbutton_birth_month; - GtkWidget *button_update; - GtkWidget *image72; - GtkWidget *button_prev; - GtkWidget *image77; - GtkWidget *button_next; - GtkWidget *image78; - GtkWidget *hseparator15; - GtkWidget *hbox87; - GtkWidget *hbox84; - GtkWidget *label137; - GtkObject *spinbutton_swap1_adj; - GtkWidget *spinbutton_swap1; - GtkWidget *button_swap; - GtkWidget *image66; - GtkObject *spinbutton_swap2_adj; - GtkWidget *spinbutton_swap2; - GtkWidget *hbox88; - GtkWidget *label171; - GtkObject *spinbutton_move_adj; - GtkWidget *spinbutton_move; - GtkWidget *button_up; - GtkWidget *alignment22; - GtkWidget *hbox89; - GtkWidget *image70; - GtkWidget *label172; - GtkWidget *button_down; - GtkWidget *alignment23; - GtkWidget *hbox90; - GtkWidget *image71; - GtkWidget *label173; - GtkWidget *hseparator19; - GtkWidget *hbox64; - GtkWidget *button_editor_help; - GtkWidget *alignment25; - GtkWidget *hbox96; - GtkWidget *image74; - GtkWidget *label179; - GtkWidget *button_exit; - GtkWidget *alignment26; - GtkWidget *hbox99; - GtkWidget *image79; - GtkWidget *label184; - GtkWidget *button_save; - GtkWidget *alignment18; - GtkWidget *hbox67; - GtkWidget *image61; - GtkWidget *label94; - GtkWidget *button_import; - GtkWidget *alignment28; - GtkWidget *hbox101; - GtkWidget *image81; - GtkWidget *label186; - GtkWidget *button_export; - GtkWidget *alignment27; - GtkWidget *hbox100; - GtkWidget *image80; - GtkWidget *label185; - GtkWidget *button_play_ws; - GtkWidget *alignment24; - GtkWidget *hbox95; - GtkWidget *image73; - GtkWidget *label178; - GtkWidget *button_save_play; - GtkWidget *alignment21; - GtkWidget *hbox71; - GtkWidget *image65; - GtkWidget *label170; - GtkAccelGroup *accel_group; - GtkTooltips *tooltips; - - tooltips = gtk_tooltips_new (); - - accel_group = gtk_accel_group_new (); - - editor_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_container_set_border_width (GTK_CONTAINER (editor_window), 6); - gtk_window_set_title (GTK_WINDOW (editor_window), _("Bygfoot Team Editor")); - gtk_window_set_position (GTK_WINDOW (editor_window), GTK_WIN_POS_CENTER); - gtk_window_set_default_size (GTK_WINDOW (editor_window), 400, 600); - editor_window_icon_pixbuf = create_pixbuf ("bygfoot_team_editor_icon.png"); - if (editor_window_icon_pixbuf) - { - gtk_window_set_icon (GTK_WINDOW (editor_window), editor_window_icon_pixbuf); - gdk_pixbuf_unref (editor_window_icon_pixbuf); - } - - vbox36 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox36); - gtk_container_add (GTK_CONTAINER (editor_window), vbox36); - - hbox86 = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox86); - gtk_box_pack_start (GTK_BOX (vbox36), hbox86, FALSE, TRUE, 0); - - vbox42 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox42); - gtk_box_pack_start (GTK_BOX (hbox86), vbox42, TRUE, TRUE, 0); - - label138 = gtk_label_new (_("Team definitions file")); - gtk_widget_show (label138); - gtk_box_pack_start (GTK_BOX (vbox42), label138, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label138), GTK_JUSTIFY_LEFT); - - entry_definitions_file = gtk_entry_new (); - gtk_widget_show (entry_definitions_file); - gtk_box_pack_start (GTK_BOX (vbox42), entry_definitions_file, FALSE, FALSE, 3); - gtk_tooltips_set_tip (tooltips, entry_definitions_file, _("The file team definitions are read from and written to. Default is $HOME/.bygfoot/text_files/teams."), NULL); - - button_choose_def = gtk_button_new (); - gtk_widget_show (button_choose_def); - gtk_box_pack_start (GTK_BOX (hbox86), button_choose_def, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (button_choose_def), 3); - gtk_tooltips_set_tip (tooltips, button_choose_def, _("Select file"), NULL); - - image68 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image68); - gtk_container_add (GTK_CONTAINER (button_choose_def), image68); - - hbox50 = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox50); - gtk_box_pack_start (GTK_BOX (vbox36), hbox50, FALSE, TRUE, 5); - - vbox37 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox37); - gtk_box_pack_start (GTK_BOX (hbox50), vbox37, TRUE, TRUE, 0); - - label73 = gtk_label_new (_("Country file")); - gtk_widget_show (label73); - gtk_box_pack_start (GTK_BOX (vbox37), label73, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label73), GTK_JUSTIFY_LEFT); - - combo_team_file = gtk_combo_new (); - g_object_set_data (G_OBJECT (GTK_COMBO (combo_team_file)->popwin), - "GladeParentKey", combo_team_file); - gtk_widget_show (combo_team_file); - gtk_box_pack_start (GTK_BOX (vbox37), combo_team_file, FALSE, FALSE, 3); - - entry_country_file = GTK_COMBO (combo_team_file)->entry; - gtk_widget_show (entry_country_file); - gtk_tooltips_set_tip (tooltips, entry_country_file, _("File with the team names (country-specific, e.g. country_eng for the English teams)"), NULL); - gtk_entry_set_text (GTK_ENTRY (entry_country_file), _("Choose or enter country file")); - - button_browse_team_files = gtk_button_new (); - gtk_widget_show (button_browse_team_files); - gtk_box_pack_start (GTK_BOX (hbox50), button_browse_team_files, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (button_browse_team_files), 3); - gtk_tooltips_set_tip (tooltips, button_browse_team_files, _("Select file"), NULL); - - image56 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image56); - gtk_container_add (GTK_CONTAINER (button_browse_team_files), image56); - - hseparator16 = gtk_hseparator_new (); - gtk_widget_show (hseparator16); - gtk_box_pack_start (GTK_BOX (vbox36), hseparator16, FALSE, FALSE, 0); - gtk_widget_set_size_request (hseparator16, 1, 10); - - hbox69 = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox69); - gtk_box_pack_start (GTK_BOX (vbox36), hbox69, FALSE, TRUE, 0); - - vbox38 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox38); - gtk_box_pack_start (GTK_BOX (hbox69), vbox38, TRUE, TRUE, 0); - - label75 = gtk_label_new (_("Teams in the country file")); - gtk_widget_show (label75); - gtk_box_pack_start (GTK_BOX (vbox38), label75, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label75), GTK_JUSTIFY_LEFT); - gtk_misc_set_alignment (GTK_MISC (label75), 0.46, 0.5); - - hbox51 = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox51); - gtk_box_pack_start (GTK_BOX (vbox38), hbox51, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (hbox51), 2); - - combo_team_names = gtk_combo_new (); - g_object_set_data (G_OBJECT (GTK_COMBO (combo_team_names)->popwin), - "GladeParentKey", combo_team_names); - gtk_widget_show (combo_team_names); - gtk_box_pack_start (GTK_BOX (hbox51), combo_team_names, TRUE, TRUE, 0); - gtk_combo_set_value_in_list (GTK_COMBO (combo_team_names), TRUE, TRUE); - - entry_team = GTK_COMBO (combo_team_names)->entry; - gtk_widget_show (entry_team); - gtk_tooltips_set_tip (tooltips, entry_team, _("Teams found in the country file. Choose one to edit it."), NULL); - gtk_editable_set_editable (GTK_EDITABLE (entry_team), FALSE); - - eventbox2 = gtk_event_box_new (); - gtk_widget_show (eventbox2); - gtk_box_pack_start (GTK_BOX (vbox38), eventbox2, TRUE, TRUE, 0); - - hbox98 = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox98); - gtk_container_add (GTK_CONTAINER (eventbox2), hbox98); - gtk_container_set_border_width (GTK_CONTAINER (hbox98), 2); - - label183 = gtk_label_new (_("Change team name to ")); - gtk_widget_show (label183); - gtk_box_pack_start (GTK_BOX (hbox98), label183, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label183), GTK_JUSTIFY_LEFT); - - entry_team_name = gtk_entry_new (); - gtk_widget_show (entry_team_name); - gtk_box_pack_start (GTK_BOX (hbox98), entry_team_name, TRUE, TRUE, 0); - gtk_entry_set_max_length (GTK_ENTRY (entry_team_name), 49); - - vseparator123 = gtk_vseparator_new (); - gtk_widget_show (vseparator123); - gtk_box_pack_start (GTK_BOX (hbox69), vseparator123, FALSE, TRUE, 0); - gtk_widget_set_size_request (vseparator123, 10, 1); - - vbox41 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox41); - gtk_box_pack_start (GTK_BOX (hbox69), vbox41, FALSE, FALSE, 0); - - label_structures = gtk_label_new (_("Team structures")); - gtk_widget_show (label_structures); - gtk_box_pack_start (GTK_BOX (vbox41), label_structures, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label_structures), GTK_JUSTIFY_LEFT); - - hbox85 = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox85); - gtk_box_pack_start (GTK_BOX (vbox41), hbox85, TRUE, TRUE, 0); - - entry_structure1 = gtk_entry_new (); - gtk_widget_show (entry_structure1); - gtk_box_pack_start (GTK_BOX (hbox85), entry_structure1, TRUE, TRUE, 2); - gtk_tooltips_set_tip (tooltips, entry_structure1, _("These digits must add up to 10."), NULL); - gtk_entry_set_max_length (GTK_ENTRY (entry_structure1), 3); - gtk_entry_set_text (GTK_ENTRY (entry_structure1), _("442")); - gtk_entry_set_width_chars (GTK_ENTRY (entry_structure1), 4); - - entry_structure2 = gtk_entry_new (); - gtk_widget_show (entry_structure2); - gtk_box_pack_start (GTK_BOX (hbox85), entry_structure2, TRUE, TRUE, 2); - gtk_tooltips_set_tip (tooltips, entry_structure2, _("These digits must add up to 8."), NULL); - gtk_entry_set_max_length (GTK_ENTRY (entry_structure2), 3); - gtk_entry_set_text (GTK_ENTRY (entry_structure2), _("332")); - gtk_entry_set_width_chars (GTK_ENTRY (entry_structure2), 4); - - button_change_structures = gtk_button_new (); - gtk_widget_show (button_change_structures); - gtk_box_pack_start (GTK_BOX (hbox85), button_change_structures, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (button_change_structures), 3); - gtk_tooltips_set_tip (tooltips, button_change_structures, _("Apply changes"), NULL); - - image63 = gtk_image_new_from_stock ("gtk-apply", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image63); - gtk_container_add (GTK_CONTAINER (button_change_structures), image63); - - vseparator124 = gtk_vseparator_new (); - gtk_widget_show (vseparator124); - gtk_box_pack_start (GTK_BOX (hbox69), vseparator124, FALSE, FALSE, 0); - gtk_widget_set_size_request (vseparator124, 10, 1); - - vbox49 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox49); - gtk_box_pack_start (GTK_BOX (hbox69), vbox49, FALSE, FALSE, 3); - - eventbox1 = gtk_event_box_new (); - gtk_widget_show (eventbox1); - gtk_box_pack_start (GTK_BOX (vbox49), eventbox1, FALSE, FALSE, 0); - gtk_tooltips_set_tip (tooltips, eventbox1, _("The average skills of the five leagues in the first season are: 8.0, 7.0, 6.0, 5.0 and 4.0."), NULL); - - vbox50 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox50); - gtk_container_add (GTK_CONTAINER (eventbox1), vbox50); - - label182 = gtk_label_new (_("Average skill")); - gtk_widget_show (label182); - gtk_box_pack_start (GTK_BOX (vbox50), label182, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label182), GTK_JUSTIFY_LEFT); - - spinbutton_average_skill_adj = gtk_adjustment_new (1, 1, 9.9, 0.01, 10, 10); - spinbutton_average_skill = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_average_skill_adj), 0.01, 2); - gtk_widget_show (spinbutton_average_skill); - gtk_box_pack_start (GTK_BOX (vbox50), spinbutton_average_skill, FALSE, FALSE, 5); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton_average_skill), TRUE); - gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinbutton_average_skill), TRUE); - - hseparator13 = gtk_hseparator_new (); - gtk_widget_show (hseparator13); - gtk_box_pack_start (GTK_BOX (vbox36), hseparator13, FALSE, FALSE, 0); - gtk_widget_set_size_request (hseparator13, 1, 15); - - scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL); - gtk_widget_show (scrolledwindow1); - gtk_box_pack_start (GTK_BOX (vbox36), scrolledwindow1, TRUE, TRUE, 0); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow1), GTK_SHADOW_IN); - - treeview_players = gtk_tree_view_new (); - gtk_widget_show (treeview_players); - gtk_container_add (GTK_CONTAINER (scrolledwindow1), treeview_players); - gtk_tree_view_set_enable_search (GTK_TREE_VIEW (treeview_players), FALSE); - - hbox94 = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox94); - gtk_box_pack_start (GTK_BOX (vbox36), hbox94, FALSE, FALSE, 5); - - vbox48 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox48); - gtk_box_pack_start (GTK_BOX (hbox94), vbox48, FALSE, FALSE, 0); - - label181 = gtk_label_new (_("Nr")); - gtk_widget_show (label181); - gtk_box_pack_start (GTK_BOX (vbox48), label181, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label181), GTK_JUSTIFY_LEFT); - gtk_misc_set_padding (GTK_MISC (label181), 0, 2); - - label_number = gtk_label_new (_("1")); - gtk_widget_show (label_number); - gtk_box_pack_start (GTK_BOX (vbox48), label_number, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label_number), GTK_JUSTIFY_LEFT); - gtk_misc_set_padding (GTK_MISC (label_number), 4, 3); - - vbox44 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox44); - gtk_box_pack_start (GTK_BOX (hbox94), vbox44, TRUE, TRUE, 0); - - label174 = gtk_label_new (_("Name")); - gtk_widget_show (label174); - gtk_box_pack_start (GTK_BOX (vbox44), label174, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label174), GTK_JUSTIFY_LEFT); - - entry_name = gtk_entry_new (); - gtk_widget_show (entry_name); - gtk_box_pack_start (GTK_BOX (vbox44), entry_name, FALSE, FALSE, 3); - gtk_entry_set_max_length (GTK_ENTRY (entry_name), 18); - gtk_entry_set_width_chars (GTK_ENTRY (entry_name), 18); - - vbox45 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox45); - gtk_box_pack_start (GTK_BOX (hbox94), vbox45, TRUE, TRUE, 0); - - label175 = gtk_label_new (_("Skill")); - gtk_widget_show (label175); - gtk_box_pack_start (GTK_BOX (vbox45), label175, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label175), GTK_JUSTIFY_LEFT); - - spinbutton_skill_adj = gtk_adjustment_new (5, 1, 9.9, 0.1, 10, 10); - spinbutton_skill = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_skill_adj), 0.1, 1); - gtk_widget_show (spinbutton_skill); - gtk_box_pack_start (GTK_BOX (vbox45), spinbutton_skill, FALSE, FALSE, 3); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton_skill), TRUE); - - vbox46 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox46); - gtk_box_pack_start (GTK_BOX (hbox94), vbox46, TRUE, TRUE, 0); - - label176 = gtk_label_new (_("Talent")); - gtk_widget_show (label176); - gtk_box_pack_start (GTK_BOX (vbox46), label176, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label176), GTK_JUSTIFY_LEFT); - - spinbutton_talent_adj = gtk_adjustment_new (5, 1, 9.9, 0.1, 10, 10); - spinbutton_talent = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_talent_adj), 0.1, 1); - gtk_widget_show (spinbutton_talent); - gtk_box_pack_start (GTK_BOX (vbox46), spinbutton_talent, FALSE, FALSE, 3); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton_talent), TRUE); - - vbox47 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox47); - gtk_box_pack_start (GTK_BOX (hbox94), vbox47, TRUE, TRUE, 0); - - label177 = gtk_label_new (_("Birth year and month")); - gtk_widget_show (label177); - gtk_box_pack_start (GTK_BOX (vbox47), label177, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label177), GTK_JUSTIFY_LEFT); - - hbox97 = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox97); - gtk_box_pack_start (GTK_BOX (vbox47), hbox97, FALSE, FALSE, 3); - - spinbutton_birth_year_adj = gtk_adjustment_new (1980, 1930, 2030, 1, 10, 10); - spinbutton_birth_year = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_birth_year_adj), 1, 0); - gtk_widget_show (spinbutton_birth_year); - gtk_box_pack_start (GTK_BOX (hbox97), spinbutton_birth_year, TRUE, TRUE, 0); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton_birth_year), TRUE); - gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (spinbutton_birth_year), TRUE); - - spinbutton_birth_month_adj = gtk_adjustment_new (6, 1, 12, 1, 10, 10); - spinbutton_birth_month = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_birth_month_adj), 1, 0); - gtk_widget_show (spinbutton_birth_month); - gtk_box_pack_start (GTK_BOX (hbox97), spinbutton_birth_month, TRUE, TRUE, 0); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton_birth_month), TRUE); - - button_update = gtk_button_new (); - gtk_widget_show (button_update); - gtk_box_pack_start (GTK_BOX (hbox94), button_update, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (button_update), 3); - gtk_tooltips_set_tip (tooltips, button_update, _("Update player information"), NULL); - gtk_widget_add_accelerator (button_update, "clicked", accel_group, - GDK_Return, GDK_CONTROL_MASK, - GTK_ACCEL_VISIBLE); - - image72 = gtk_image_new_from_stock ("gtk-apply", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image72); - gtk_container_add (GTK_CONTAINER (button_update), image72); - - button_prev = gtk_button_new (); - gtk_widget_show (button_prev); - gtk_box_pack_start (GTK_BOX (hbox94), button_prev, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (button_prev), 3); - gtk_tooltips_set_tip (tooltips, button_prev, _("Select previous player (Ctrl-Left)"), NULL); - gtk_widget_add_accelerator (button_prev, "clicked", accel_group, - GDK_Left, GDK_CONTROL_MASK, - GTK_ACCEL_VISIBLE); - - image77 = gtk_image_new_from_stock ("gtk-go-back", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image77); - gtk_container_add (GTK_CONTAINER (button_prev), image77); - - button_next = gtk_button_new (); - gtk_widget_show (button_next); - gtk_box_pack_start (GTK_BOX (hbox94), button_next, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (button_next), 3); - gtk_tooltips_set_tip (tooltips, button_next, _("Select next player (Ctrl-Right)"), NULL); - gtk_widget_add_accelerator (button_next, "clicked", accel_group, - GDK_Right, GDK_CONTROL_MASK, - GTK_ACCEL_VISIBLE); - - image78 = gtk_image_new_from_stock ("gtk-go-forward", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image78); - gtk_container_add (GTK_CONTAINER (button_next), image78); - - hseparator15 = gtk_hseparator_new (); - gtk_widget_show (hseparator15); - gtk_box_pack_start (GTK_BOX (vbox36), hseparator15, FALSE, FALSE, 0); - gtk_widget_set_size_request (hseparator15, 1, 10); - - hbox87 = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox87); - gtk_box_pack_start (GTK_BOX (vbox36), hbox87, FALSE, FALSE, 0); - - hbox84 = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox84); - gtk_box_pack_start (GTK_BOX (hbox87), hbox84, FALSE, TRUE, 5); - - label137 = gtk_label_new (_("Swap two players ")); - gtk_widget_show (label137); - gtk_box_pack_start (GTK_BOX (hbox84), label137, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label137), GTK_JUSTIFY_LEFT); - - spinbutton_swap1_adj = gtk_adjustment_new (1, 1, 20, 1, 10, 10); - spinbutton_swap1 = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_swap1_adj), 1, 0); - gtk_widget_show (spinbutton_swap1); - gtk_box_pack_start (GTK_BOX (hbox84), spinbutton_swap1, FALSE, TRUE, 0); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton_swap1), TRUE); - - button_swap = gtk_button_new (); - gtk_widget_show (button_swap); - gtk_box_pack_start (GTK_BOX (hbox84), button_swap, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (button_swap), 3); - gtk_tooltips_set_tip (tooltips, button_swap, _("Swap players"), NULL); - - image66 = gtk_image_new_from_stock ("gtk-refresh", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image66); - gtk_container_add (GTK_CONTAINER (button_swap), image66); - - spinbutton_swap2_adj = gtk_adjustment_new (2, 1, 20, 1, 10, 10); - spinbutton_swap2 = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_swap2_adj), 1, 0); - gtk_widget_show (spinbutton_swap2); - gtk_box_pack_start (GTK_BOX (hbox84), spinbutton_swap2, FALSE, TRUE, 0); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton_swap2), TRUE); - - hbox88 = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox88); - gtk_box_pack_start (GTK_BOX (hbox87), hbox88, TRUE, TRUE, 5); - - label171 = gtk_label_new (_(" Move player")); - gtk_widget_show (label171); - gtk_box_pack_start (GTK_BOX (hbox88), label171, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label171), GTK_JUSTIFY_LEFT); - - spinbutton_move_adj = gtk_adjustment_new (1, 1, 20, 1, 10, 10); - spinbutton_move = gtk_spin_button_new (GTK_ADJUSTMENT (spinbutton_move_adj), 1, 0); - gtk_widget_show (spinbutton_move); - gtk_box_pack_start (GTK_BOX (hbox88), spinbutton_move, FALSE, TRUE, 3); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton_move), TRUE); - - button_up = gtk_button_new (); - gtk_widget_show (button_up); - gtk_box_pack_start (GTK_BOX (hbox88), button_up, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (button_up), 3); - gtk_tooltips_set_tip (tooltips, button_up, _("Move player up (Ctrl-Up)"), NULL); - gtk_widget_add_accelerator (button_up, "clicked", accel_group, - GDK_Up, GDK_CONTROL_MASK, - GTK_ACCEL_VISIBLE); - - alignment22 = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_show (alignment22); - gtk_container_add (GTK_CONTAINER (button_up), alignment22); - - hbox89 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox89); - gtk_container_add (GTK_CONTAINER (alignment22), hbox89); - - image70 = gtk_image_new_from_stock ("gtk-go-up", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image70); - gtk_box_pack_start (GTK_BOX (hbox89), image70, FALSE, FALSE, 0); - - label172 = gtk_label_new_with_mnemonic (_("Up")); - gtk_widget_show (label172); - gtk_box_pack_start (GTK_BOX (hbox89), label172, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label172), GTK_JUSTIFY_LEFT); - - button_down = gtk_button_new (); - gtk_widget_show (button_down); - gtk_box_pack_start (GTK_BOX (hbox88), button_down, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (button_down), 3); - gtk_tooltips_set_tip (tooltips, button_down, _("Move player down (Ctrl-Down)"), NULL); - gtk_widget_add_accelerator (button_down, "clicked", accel_group, - GDK_Down, GDK_CONTROL_MASK, - GTK_ACCEL_VISIBLE); - - alignment23 = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_show (alignment23); - gtk_container_add (GTK_CONTAINER (button_down), alignment23); - - hbox90 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox90); - gtk_container_add (GTK_CONTAINER (alignment23), hbox90); - - image71 = gtk_image_new_from_stock ("gtk-go-down", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image71); - gtk_box_pack_start (GTK_BOX (hbox90), image71, FALSE, FALSE, 0); - - label173 = gtk_label_new_with_mnemonic (_("Down")); - gtk_widget_show (label173); - gtk_box_pack_start (GTK_BOX (hbox90), label173, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label173), GTK_JUSTIFY_LEFT); - - hseparator19 = gtk_hseparator_new (); - gtk_widget_show (hseparator19); - gtk_box_pack_start (GTK_BOX (vbox36), hseparator19, FALSE, TRUE, 0); - gtk_widget_set_size_request (hseparator19, 1, 10); - - hbox64 = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox64); - gtk_box_pack_start (GTK_BOX (vbox36), hbox64, FALSE, TRUE, 0); - - button_editor_help = gtk_button_new (); - gtk_widget_show (button_editor_help); - gtk_box_pack_start (GTK_BOX (hbox64), button_editor_help, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (button_editor_help), 3); - gtk_tooltips_set_tip (tooltips, button_editor_help, _("Show editor help (F1)"), NULL); - gtk_widget_add_accelerator (button_editor_help, "clicked", accel_group, - GDK_F1, 0, - GTK_ACCEL_VISIBLE); - - alignment25 = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_show (alignment25); - gtk_container_add (GTK_CONTAINER (button_editor_help), alignment25); - - hbox96 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox96); - gtk_container_add (GTK_CONTAINER (alignment25), hbox96); - - image74 = gtk_image_new_from_stock ("gtk-help", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image74); - gtk_box_pack_start (GTK_BOX (hbox96), image74, FALSE, FALSE, 0); - - label179 = gtk_label_new_with_mnemonic (_("Help")); - gtk_widget_show (label179); - gtk_box_pack_start (GTK_BOX (hbox96), label179, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label179), GTK_JUSTIFY_LEFT); - - button_exit = gtk_button_new (); - gtk_widget_show (button_exit); - gtk_box_pack_start (GTK_BOX (hbox64), button_exit, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (button_exit), 3); - gtk_tooltips_set_tip (tooltips, button_exit, _("Quit (Esc)"), NULL); - gtk_widget_add_accelerator (button_exit, "clicked", accel_group, - GDK_Escape, 0, - GTK_ACCEL_VISIBLE); - - alignment26 = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_show (alignment26); - gtk_container_add (GTK_CONTAINER (button_exit), alignment26); - - hbox99 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox99); - gtk_container_add (GTK_CONTAINER (alignment26), hbox99); - - image79 = gtk_image_new_from_stock ("gtk-quit", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image79); - gtk_box_pack_start (GTK_BOX (hbox99), image79, FALSE, FALSE, 0); - - label184 = gtk_label_new_with_mnemonic (_("Quit")); - gtk_widget_show (label184); - gtk_box_pack_start (GTK_BOX (hbox99), label184, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label184), GTK_JUSTIFY_LEFT); - - button_save = gtk_button_new (); - gtk_widget_show (button_save); - gtk_box_pack_start (GTK_BOX (hbox64), button_save, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (button_save), 3); - gtk_tooltips_set_tip (tooltips, button_save, _("Save current team to file (Ctrl-S)"), NULL); - gtk_widget_add_accelerator (button_save, "clicked", accel_group, - GDK_s, GDK_CONTROL_MASK, - GTK_ACCEL_VISIBLE); - - alignment18 = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_show (alignment18); - gtk_container_add (GTK_CONTAINER (button_save), alignment18); - - hbox67 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox67); - gtk_container_add (GTK_CONTAINER (alignment18), hbox67); - - image61 = gtk_image_new_from_stock ("gtk-save", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image61); - gtk_box_pack_start (GTK_BOX (hbox67), image61, FALSE, FALSE, 0); - - label94 = gtk_label_new_with_mnemonic (_("Save")); - gtk_widget_show (label94); - gtk_box_pack_start (GTK_BOX (hbox67), label94, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label94), GTK_JUSTIFY_LEFT); - - button_import = gtk_button_new (); - gtk_widget_show (button_import); - gtk_box_pack_start (GTK_BOX (hbox64), button_import, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (button_import), 2); - gtk_tooltips_set_tip (tooltips, button_import, _("Import teams from a definition file (the existing definition file will be expanded)"), NULL); - - alignment28 = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_show (alignment28); - gtk_container_add (GTK_CONTAINER (button_import), alignment28); - - hbox101 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox101); - gtk_container_add (GTK_CONTAINER (alignment28), hbox101); - - image81 = gtk_image_new_from_stock ("gtk-open", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image81); - gtk_box_pack_start (GTK_BOX (hbox101), image81, FALSE, FALSE, 0); - - label186 = gtk_label_new_with_mnemonic (_("Import")); - gtk_widget_show (label186); - gtk_box_pack_start (GTK_BOX (hbox101), label186, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label186), GTK_JUSTIFY_LEFT); - - button_export = gtk_button_new (); - gtk_widget_show (button_export); - gtk_box_pack_start (GTK_BOX (hbox64), button_export, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (button_export), 2); - gtk_tooltips_set_tip (tooltips, button_export, _("Export the current team to a file (which will be overwritten if it exists)"), NULL); - - alignment27 = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_show (alignment27); - gtk_container_add (GTK_CONTAINER (button_export), alignment27); - - hbox100 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox100); - gtk_container_add (GTK_CONTAINER (alignment27), hbox100); - - image80 = gtk_image_new_from_stock ("gtk-floppy", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image80); - gtk_box_pack_start (GTK_BOX (hbox100), image80, FALSE, FALSE, 0); - - label185 = gtk_label_new_with_mnemonic (_("Export")); - gtk_widget_show (label185); - gtk_box_pack_start (GTK_BOX (hbox100), label185, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label185), GTK_JUSTIFY_LEFT); - - button_play_ws = gtk_button_new (); - gtk_widget_show (button_play_ws); - gtk_box_pack_start (GTK_BOX (hbox64), button_play_ws, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (button_play_ws), 3); - gtk_tooltips_set_tip (tooltips, button_play_ws, _("Start Bygfoot without saving changes"), NULL); - - alignment24 = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_show (alignment24); - gtk_container_add (GTK_CONTAINER (button_play_ws), alignment24); - - hbox95 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox95); - gtk_container_add (GTK_CONTAINER (alignment24), hbox95); - - image73 = gtk_image_new_from_stock ("gtk-go-forward", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image73); - gtk_box_pack_start (GTK_BOX (hbox95), image73, FALSE, FALSE, 0); - - label178 = gtk_label_new_with_mnemonic (_("Discard / Play")); - gtk_widget_show (label178); - gtk_box_pack_start (GTK_BOX (hbox95), label178, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label178), GTK_JUSTIFY_LEFT); - - button_save_play = gtk_button_new (); - gtk_widget_show (button_save_play); - gtk_box_pack_start (GTK_BOX (hbox64), button_save_play, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (button_save_play), 3); - gtk_tooltips_set_tip (tooltips, button_save_play, _("Save team definition file and start Bygfoot"), NULL); - - alignment21 = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_show (alignment21); - gtk_container_add (GTK_CONTAINER (button_save_play), alignment21); - - hbox71 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox71); - gtk_container_add (GTK_CONTAINER (alignment21), hbox71); - - image65 = gtk_image_new_from_stock ("gtk-go-forward", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image65); - gtk_box_pack_start (GTK_BOX (hbox71), image65, FALSE, FALSE, 0); - - label170 = gtk_label_new_with_mnemonic (_("Save / Play")); - gtk_widget_show (label170); - gtk_box_pack_start (GTK_BOX (hbox71), label170, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label170), GTK_JUSTIFY_LEFT); - - g_signal_connect ((gpointer) editor_window, "delete_event", - G_CALLBACK (on_button_exit_clicked), - NULL); - g_signal_connect ((gpointer) button_choose_def, "clicked", - G_CALLBACK (on_button_choose_def_clicked), - NULL); - g_signal_connect ((gpointer) entry_country_file, "changed", - G_CALLBACK (on_entry_country_file_changed), - NULL); - g_signal_connect ((gpointer) button_browse_team_files, "clicked", - G_CALLBACK (on_button_browse_team_files_clicked), - NULL); - g_signal_connect ((gpointer) entry_team, "changed", - G_CALLBACK (on_entry_team_changed), - NULL); - g_signal_connect ((gpointer) entry_structure1, "activate", - G_CALLBACK (on_button_change_structures_clicked), - NULL); - g_signal_connect ((gpointer) entry_structure2, "activate", - G_CALLBACK (on_button_change_structures_clicked), - NULL); - g_signal_connect ((gpointer) button_change_structures, "clicked", - G_CALLBACK (on_button_change_structures_clicked), - NULL); - g_signal_connect ((gpointer) spinbutton_average_skill, "value_changed", - G_CALLBACK (on_spinbutton_average_skill_value_changed), - NULL); - g_signal_connect ((gpointer) treeview_players, "button_press_event", - G_CALLBACK (on_treeview_players_button_press_event), - NULL); - g_signal_connect ((gpointer) entry_name, "activate", - G_CALLBACK (on_button_update_clicked), - NULL); - g_signal_connect ((gpointer) spinbutton_skill, "activate", - G_CALLBACK (on_button_update_clicked), - NULL); - g_signal_connect ((gpointer) spinbutton_talent, "activate", - G_CALLBACK (on_button_update_clicked), - NULL); - g_signal_connect ((gpointer) spinbutton_birth_year, "activate", - G_CALLBACK (on_button_update_clicked), - NULL); - g_signal_connect ((gpointer) spinbutton_birth_month, "activate", - G_CALLBACK (on_button_update_clicked), - NULL); - g_signal_connect ((gpointer) button_update, "clicked", - G_CALLBACK (on_button_update_clicked), - NULL); - g_signal_connect ((gpointer) button_prev, "clicked", - G_CALLBACK (on_button_prev_clicked), - NULL); - g_signal_connect ((gpointer) button_next, "clicked", - G_CALLBACK (on_button_next_clicked), - NULL); - g_signal_connect ((gpointer) spinbutton_swap1, "activate", - G_CALLBACK (on_button_swap_clicked), - NULL); - g_signal_connect ((gpointer) button_swap, "clicked", - G_CALLBACK (on_button_swap_clicked), - NULL); - g_signal_connect ((gpointer) spinbutton_swap2, "activate", - G_CALLBACK (on_button_swap_clicked), - NULL); - g_signal_connect ((gpointer) button_up, "clicked", - G_CALLBACK (on_button_up_clicked), - NULL); - g_signal_connect ((gpointer) button_down, "clicked", - G_CALLBACK (on_button_down_clicked), - NULL); - g_signal_connect ((gpointer) button_editor_help, "clicked", - G_CALLBACK (on_button_editor_help_clicked), - NULL); - g_signal_connect ((gpointer) button_exit, "clicked", - G_CALLBACK (on_button_exit_clicked), - NULL); - g_signal_connect ((gpointer) button_save, "clicked", - G_CALLBACK (on_button_save_defs_clicked), - NULL); - g_signal_connect ((gpointer) button_import, "clicked", - G_CALLBACK (on_button_import_clicked), - NULL); - g_signal_connect ((gpointer) button_export, "clicked", - G_CALLBACK (on_button_export_clicked), - NULL); - g_signal_connect ((gpointer) button_play_ws, "clicked", - G_CALLBACK (on_button_play_ws_clicked), - NULL); - g_signal_connect ((gpointer) button_save_play, "clicked", - G_CALLBACK (on_button_save_play_clicked), - NULL); - - /* Store pointers to all widgets, for use by lookup_widget(). */ - GLADE_HOOKUP_OBJECT_NO_REF (editor_window, editor_window, "editor_window"); - GLADE_HOOKUP_OBJECT (editor_window, vbox36, "vbox36"); - GLADE_HOOKUP_OBJECT (editor_window, hbox86, "hbox86"); - GLADE_HOOKUP_OBJECT (editor_window, vbox42, "vbox42"); - GLADE_HOOKUP_OBJECT (editor_window, label138, "label138"); - GLADE_HOOKUP_OBJECT (editor_window, entry_definitions_file, "entry_definitions_file"); - GLADE_HOOKUP_OBJECT (editor_window, button_choose_def, "button_choose_def"); - GLADE_HOOKUP_OBJECT (editor_window, image68, "image68"); - GLADE_HOOKUP_OBJECT (editor_window, hbox50, "hbox50"); - GLADE_HOOKUP_OBJECT (editor_window, vbox37, "vbox37"); - GLADE_HOOKUP_OBJECT (editor_window, label73, "label73"); - GLADE_HOOKUP_OBJECT (editor_window, combo_team_file, "combo_team_file"); - GLADE_HOOKUP_OBJECT (editor_window, entry_country_file, "entry_country_file"); - GLADE_HOOKUP_OBJECT (editor_window, button_browse_team_files, "button_browse_team_files"); - GLADE_HOOKUP_OBJECT (editor_window, image56, "image56"); - GLADE_HOOKUP_OBJECT (editor_window, hseparator16, "hseparator16"); - GLADE_HOOKUP_OBJECT (editor_window, hbox69, "hbox69"); - GLADE_HOOKUP_OBJECT (editor_window, vbox38, "vbox38"); - GLADE_HOOKUP_OBJECT (editor_window, label75, "label75"); - GLADE_HOOKUP_OBJECT (editor_window, hbox51, "hbox51"); - GLADE_HOOKUP_OBJECT (editor_window, combo_team_names, "combo_team_names"); - GLADE_HOOKUP_OBJECT (editor_window, entry_team, "entry_team"); - GLADE_HOOKUP_OBJECT (editor_window, eventbox2, "eventbox2"); - GLADE_HOOKUP_OBJECT (editor_window, hbox98, "hbox98"); - GLADE_HOOKUP_OBJECT (editor_window, label183, "label183"); - GLADE_HOOKUP_OBJECT (editor_window, entry_team_name, "entry_team_name"); - GLADE_HOOKUP_OBJECT (editor_window, vseparator123, "vseparator123"); - GLADE_HOOKUP_OBJECT (editor_window, vbox41, "vbox41"); - GLADE_HOOKUP_OBJECT (editor_window, label_structures, "label_structures"); - GLADE_HOOKUP_OBJECT (editor_window, hbox85, "hbox85"); - GLADE_HOOKUP_OBJECT (editor_window, entry_structure1, "entry_structure1"); - GLADE_HOOKUP_OBJECT (editor_window, entry_structure2, "entry_structure2"); - GLADE_HOOKUP_OBJECT (editor_window, button_change_structures, "button_change_structures"); - GLADE_HOOKUP_OBJECT (editor_window, image63, "image63"); - GLADE_HOOKUP_OBJECT (editor_window, vseparator124, "vseparator124"); - GLADE_HOOKUP_OBJECT (editor_window, vbox49, "vbox49"); - GLADE_HOOKUP_OBJECT (editor_window, eventbox1, "eventbox1"); - GLADE_HOOKUP_OBJECT (editor_window, vbox50, "vbox50"); - GLADE_HOOKUP_OBJECT (editor_window, label182, "label182"); - GLADE_HOOKUP_OBJECT (editor_window, spinbutton_average_skill, "spinbutton_average_skill"); - GLADE_HOOKUP_OBJECT (editor_window, hseparator13, "hseparator13"); - GLADE_HOOKUP_OBJECT (editor_window, scrolledwindow1, "scrolledwindow1"); - GLADE_HOOKUP_OBJECT (editor_window, treeview_players, "treeview_players"); - GLADE_HOOKUP_OBJECT (editor_window, hbox94, "hbox94"); - GLADE_HOOKUP_OBJECT (editor_window, vbox48, "vbox48"); - GLADE_HOOKUP_OBJECT (editor_window, label181, "label181"); - GLADE_HOOKUP_OBJECT (editor_window, label_number, "label_number"); - GLADE_HOOKUP_OBJECT (editor_window, vbox44, "vbox44"); - GLADE_HOOKUP_OBJECT (editor_window, label174, "label174"); - GLADE_HOOKUP_OBJECT (editor_window, entry_name, "entry_name"); - GLADE_HOOKUP_OBJECT (editor_window, vbox45, "vbox45"); - GLADE_HOOKUP_OBJECT (editor_window, label175, "label175"); - GLADE_HOOKUP_OBJECT (editor_window, spinbutton_skill, "spinbutton_skill"); - GLADE_HOOKUP_OBJECT (editor_window, vbox46, "vbox46"); - GLADE_HOOKUP_OBJECT (editor_window, label176, "label176"); - GLADE_HOOKUP_OBJECT (editor_window, spinbutton_talent, "spinbutton_talent"); - GLADE_HOOKUP_OBJECT (editor_window, vbox47, "vbox47"); - GLADE_HOOKUP_OBJECT (editor_window, label177, "label177"); - GLADE_HOOKUP_OBJECT (editor_window, hbox97, "hbox97"); - GLADE_HOOKUP_OBJECT (editor_window, spinbutton_birth_year, "spinbutton_birth_year"); - GLADE_HOOKUP_OBJECT (editor_window, spinbutton_birth_month, "spinbutton_birth_month"); - GLADE_HOOKUP_OBJECT (editor_window, button_update, "button_update"); - GLADE_HOOKUP_OBJECT (editor_window, image72, "image72"); - GLADE_HOOKUP_OBJECT (editor_window, button_prev, "button_prev"); - GLADE_HOOKUP_OBJECT (editor_window, image77, "image77"); - GLADE_HOOKUP_OBJECT (editor_window, button_next, "button_next"); - GLADE_HOOKUP_OBJECT (editor_window, image78, "image78"); - GLADE_HOOKUP_OBJECT (editor_window, hseparator15, "hseparator15"); - GLADE_HOOKUP_OBJECT (editor_window, hbox87, "hbox87"); - GLADE_HOOKUP_OBJECT (editor_window, hbox84, "hbox84"); - GLADE_HOOKUP_OBJECT (editor_window, label137, "label137"); - GLADE_HOOKUP_OBJECT (editor_window, spinbutton_swap1, "spinbutton_swap1"); - GLADE_HOOKUP_OBJECT (editor_window, button_swap, "button_swap"); - GLADE_HOOKUP_OBJECT (editor_window, image66, "image66"); - GLADE_HOOKUP_OBJECT (editor_window, spinbutton_swap2, "spinbutton_swap2"); - GLADE_HOOKUP_OBJECT (editor_window, hbox88, "hbox88"); - GLADE_HOOKUP_OBJECT (editor_window, label171, "label171"); - GLADE_HOOKUP_OBJECT (editor_window, spinbutton_move, "spinbutton_move"); - GLADE_HOOKUP_OBJECT (editor_window, button_up, "button_up"); - GLADE_HOOKUP_OBJECT (editor_window, alignment22, "alignment22"); - GLADE_HOOKUP_OBJECT (editor_window, hbox89, "hbox89"); - GLADE_HOOKUP_OBJECT (editor_window, image70, "image70"); - GLADE_HOOKUP_OBJECT (editor_window, label172, "label172"); - GLADE_HOOKUP_OBJECT (editor_window, button_down, "button_down"); - GLADE_HOOKUP_OBJECT (editor_window, alignment23, "alignment23"); - GLADE_HOOKUP_OBJECT (editor_window, hbox90, "hbox90"); - GLADE_HOOKUP_OBJECT (editor_window, image71, "image71"); - GLADE_HOOKUP_OBJECT (editor_window, label173, "label173"); - GLADE_HOOKUP_OBJECT (editor_window, hseparator19, "hseparator19"); - GLADE_HOOKUP_OBJECT (editor_window, hbox64, "hbox64"); - GLADE_HOOKUP_OBJECT (editor_window, button_editor_help, "button_editor_help"); - GLADE_HOOKUP_OBJECT (editor_window, alignment25, "alignment25"); - GLADE_HOOKUP_OBJECT (editor_window, hbox96, "hbox96"); - GLADE_HOOKUP_OBJECT (editor_window, image74, "image74"); - GLADE_HOOKUP_OBJECT (editor_window, label179, "label179"); - GLADE_HOOKUP_OBJECT (editor_window, button_exit, "button_exit"); - GLADE_HOOKUP_OBJECT (editor_window, alignment26, "alignment26"); - GLADE_HOOKUP_OBJECT (editor_window, hbox99, "hbox99"); - GLADE_HOOKUP_OBJECT (editor_window, image79, "image79"); - GLADE_HOOKUP_OBJECT (editor_window, label184, "label184"); - GLADE_HOOKUP_OBJECT (editor_window, button_save, "button_save"); - GLADE_HOOKUP_OBJECT (editor_window, alignment18, "alignment18"); - GLADE_HOOKUP_OBJECT (editor_window, hbox67, "hbox67"); - GLADE_HOOKUP_OBJECT (editor_window, image61, "image61"); - GLADE_HOOKUP_OBJECT (editor_window, label94, "label94"); - GLADE_HOOKUP_OBJECT (editor_window, button_import, "button_import"); - GLADE_HOOKUP_OBJECT (editor_window, alignment28, "alignment28"); - GLADE_HOOKUP_OBJECT (editor_window, hbox101, "hbox101"); - GLADE_HOOKUP_OBJECT (editor_window, image81, "image81"); - GLADE_HOOKUP_OBJECT (editor_window, label186, "label186"); - GLADE_HOOKUP_OBJECT (editor_window, button_export, "button_export"); - GLADE_HOOKUP_OBJECT (editor_window, alignment27, "alignment27"); - GLADE_HOOKUP_OBJECT (editor_window, hbox100, "hbox100"); - GLADE_HOOKUP_OBJECT (editor_window, image80, "image80"); - GLADE_HOOKUP_OBJECT (editor_window, label185, "label185"); - GLADE_HOOKUP_OBJECT (editor_window, button_play_ws, "button_play_ws"); - GLADE_HOOKUP_OBJECT (editor_window, alignment24, "alignment24"); - GLADE_HOOKUP_OBJECT (editor_window, hbox95, "hbox95"); - GLADE_HOOKUP_OBJECT (editor_window, image73, "image73"); - GLADE_HOOKUP_OBJECT (editor_window, label178, "label178"); - GLADE_HOOKUP_OBJECT (editor_window, button_save_play, "button_save_play"); - GLADE_HOOKUP_OBJECT (editor_window, alignment21, "alignment21"); - GLADE_HOOKUP_OBJECT (editor_window, hbox71, "hbox71"); - GLADE_HOOKUP_OBJECT (editor_window, image65, "image65"); - GLADE_HOOKUP_OBJECT (editor_window, label170, "label170"); - GLADE_HOOKUP_OBJECT_NO_REF (editor_window, tooltips, "tooltips"); - - gtk_window_add_accel_group (GTK_WINDOW (editor_window), accel_group); - - return editor_window; -} - diff --git a/src/editor_interface.h b/src/editor_interface.h deleted file mode 100644 index be3e7fe2..00000000 --- a/src/editor_interface.h +++ /dev/null @@ -1,5 +0,0 @@ -/* - * DO NOT EDIT THIS FILE - it is generated by Glade. - */ - -GtkWidget* create_editor_window (void); diff --git a/src/enums.h b/src/enums.h index 8fae0c0c..3e4750be 100644 --- a/src/enums.h +++ b/src/enums.h @@ -1,6 +1,16 @@ #ifndef ENUMS_H #define ENUMS_H +/** Scout and physio qualities. */ +enum Quality +{ + QUALITY_BEST = 0, + QUALITY_GOOD, + QUALITY_AVERAGE, + QUALITY_BAD, + QUALITY_END +}; + /** Indices for the #finances variable. */ enum FinanceValue { @@ -19,7 +29,7 @@ enum FinanceValue FIN_END }; -/** Indices for the #counters variable. */ +/** Indices for the counters variable in #User. */ enum CounterValue { COUNT_LOAN = 0, /** How many weeks until user has to pay back his loan. */ @@ -39,50 +49,19 @@ enum CounterValue COUNT_END }; -/** Indices for the #options variable. */ -enum OptionValue +/** Possible values for a status variable. */ +enum Status0Value { - OPT_BOOL_CONF_NEW_ROUND = 0, /**< Whether beginning of a new week round has to be confirmed. */ - OPT_BOOL_CONF_UNFIT, /**< Unfit player confirmation. */ - OPT_BOOL_CONF_QUIT, /**< Quit confirmation. */ - OPT_BOOL_OVERWRITE, /**< Clicking on save overwrites current save game. */ - OPT_BOOL_SHOW_LIVE, /**< Whether live game is shown. */ - OPT_LIVE_SPEED, /**< Live game speed. */ - OPT_BOOL_LIVE_TENDENCY, /**< Tendency bar. */ - OPT_BOOL_MAXIMIZE, /**< Whether to start maximized. */ - OPT_BOOL_NOTIFY, /**< Whether transfer list notification is on. */ - OPT_NOTIFY_POS, /**< Whether we look for a certain position. */ - OPT_NOTIFY_LEAGUE_UPPER, /**< League with lowest index for notification. */ - OPT_NOTIFY_LEAGUE_LOWER, /**< League with highest index for notification. */ - OPT_BOOL_NOTIFY_CUPS, /**< Notify when player from international cups. */ - OPT_NOTIFY_AGE_UPPER, /**< Upper age bound. */ - OPT_NOTIFY_AGE_LOWER, /**< Lower age bound. */ - OPT_NOTIFY_SKILL_UPPER, /**< Skill bound. */ - OPT_NOTIFY_SKILL_LOWER, /**< Skill bound. */ - OPT_NOTIFY_ETAL_UPPER, /**< Etal bound. */ - OPT_NOTIFY_ETAL_LOWER, /**< Etal bound. */ - OPT_NOTIFY_VALUE, /**< Upper value bound. */ - OPT_BOOL_JOBS, /**< Whether job offers are shown. */ - OPT_MESS, /**< Message style. */ - OPT_BOOL_PREFER_MESS, /**< Messages instead of popups when possible. */ - OPT_BOOL_AUTOSAVE, /**< Whether autosave is on. */ - OPT_AUTOSAVE_INTERVAL, /**< How often to autosave. */ - OPT_BOOL_SORT_TRANSFERS, /**< Whether to sort transfers. */ - OPT_SORT_TRANSFERS_ATTRIBUTE, /**< Which attribute to sort. */ - OPT_BOOL_SORT_TRANSFERS_DESCENDING, /**< Whether we sort descending. */ - OPT_BOOL_REARRANGE, /**< Whether the players get sorted when a new structure is given. */ - OPT_BOOL_SWAP, /**< Whether the players get sorted when two players are swapped. */ - OPT_HISTORY_TEAM_INTERVAL, /**< Interval of team history update. */ - OPT_HISTORY_PLAYER_INTERVAL, /**< Interval of player history update. */ - OPT_HISTORY_TEAM_MAX, /**< Maximum length of team history. */ - OPT_HISTORY_PLAYER_MAX, /**< Maximum length of player history. */ - OPT_BOOL_HISTORY_TEAM_DELETE, /**< Whether team histories get deleted each new season. */ - OPT_BOOL_HISTORY_PLAYER_DELETE, /**< Whether player histories get deleted each new season. */ - OPT_BOOL_BOOST, /**< Whether player boost is on. */ - OPT_BOOL_COMPRESS, /**< Whether to zip-compress savegames. */ - OPT_BOOL_OBJECTIVE, /**< Whether season objective is on. */ - OPT_PENALTY_SHOOTER, /**< The id of the penalty shooter. */ - OPT_END + STATUS_NONE = 0, + STATUS_MAIN, + STATUS_SHOW_LIVE_GAME, + STATUS_LIVE_GAME_PAUSE, + STATUS_BROWSE_TEAMS, + STATUS_TEAM_SELECTION, + /** We set this so that we know that + gui signals have to be ignored for the time being. */ + STATUS_GUI_NO_REACTION, + STATUS_END }; #endif diff --git a/src/file.c b/src/file.c index e4a3ee4b..66716b15 100644 --- a/src/file.c +++ b/src/file.c @@ -2,7 +2,9 @@ #include "free.h" #include "main.h" #include "misc.h" +#include "option.h" #include "support.h" +#include "user.h" #include "variables.h" /** @@ -196,191 +198,118 @@ file_get_definitions_dir(gchar *dir) } /** Read the file until the next line that's not a comment or - a blank line and copy the line into buf. - @param fil The file stream. - @param buf The buffer we fill. - @return TRUE if the file still contains lines to read, FALSE otherwise. */ + a blank line. Split the line into the part before and after + the first white space and copy them into the char arrays. + Trailing and leading white spaces and trailing comments are stripped. + @param fil The file stream. + @param opt_name The first char array (an option name, mostly). + @param opt_value The second array (an option value, mostly). + @return TRUE if the file still contains lines to read, FALSE otherwise. */ gboolean -file_get_next_line(FILE *fil, gchar *buf) +file_get_next_opt_line(FILE *fil, gchar *opt_name, gchar *opt_value) { - gchar local_buf[BIG]; + gint i; + gchar trash[SMALL]; + gchar buf[BIG]; - strcpy(local_buf, ""); + strcpy(buf, ""); - while( (local_buf[0] == '#' || strlen(local_buf) == 0) && + while( (buf[0] == '#' || strlen(buf) == 0) && feof(fil) == 0) { - fscanf(fil, "%[\n \t]*", local_buf); - fscanf(fil, "%[^\n]", local_buf); + fscanf(fil, "%[\n \t]*", buf); + fscanf(fil, "%[^\n]", buf); } - if(local_buf[0] != '#' && strlen(local_buf) != 0) + if(buf[0] != '#' && strlen(buf) != 0) { - if(strlen(local_buf) > 100) + if(strlen(buf) > 100) g_warning("\n the text file I'm reading contains a line longer than 100 chars.\n\n"); - if(buf != NULL) - strcpy(buf, local_buf); + for(i=0;i0;i--) + if(buf[i] == '\t' || buf[i] == ' ') + buf[i] = '\0'; + else + break; + + sscanf(buf, "%[^ ]%[ ]%[^\n]", opt_name, trash, opt_value); } return (feof(fil) == 0); } -/** Supply the strings in the config file that belong to the options. - @param opt_names The array we write the optionstrings into. - @param player_list_att_names The array we write the player list attribute strings into. */ +/** Load a file containing name - value pairs into + the specified array. */ void -file_write_opt_names(gchar opt_names[][50], gchar player_list_att_names[][PLAYER_LIST_ATTRIBUTE_END][50]) +file_load_opt_file(FILE *fil, GArray **option_array) { - gint i, j; + gchar opt_name[SMALL], opt_value[SMALL]; + Option new; - strcpy(opt_names[OPT_BOOL_CONF_NEW_ROUND], "confirm_new_week_round"); - strcpy(opt_names[OPT_BOOL_CONF_UNFIT], "confirm_unfit"); - strcpy(opt_names[OPT_BOOL_CONF_QUIT], "confirm_quit"); - strcpy(opt_names[OPT_BOOL_OVERWRITE], "save_will_ovewrite"); - strcpy(opt_names[OPT_BOOL_SHOW_LIVE], "show_live_game"); - strcpy(opt_names[OPT_LIVE_SPEED], "live_game_speed"); - strcpy(opt_names[OPT_BOOL_LIVE_TENDENCY], "show_tendency_bar"); - strcpy(opt_names[OPT_BOOL_MAXIMIZE], "maximize_main_window"); + free_option_array(option_array, TRUE); - strcpy(opt_names[OPT_BOOL_NOTIFY], "notify_transfer"); - strcpy(opt_names[OPT_NOTIFY_POS], "notify_pos"); - strcpy(opt_names[OPT_NOTIFY_LEAGUE_UPPER], "notify_league_upper"); - strcpy(opt_names[OPT_NOTIFY_LEAGUE_LOWER], "notify_league_lower"); - strcpy(opt_names[OPT_BOOL_NOTIFY_CUPS], "notify_cups"); - strcpy(opt_names[OPT_NOTIFY_AGE_UPPER], "notify_age_upper"); - strcpy(opt_names[OPT_NOTIFY_AGE_LOWER], "notify_age_lower"); - strcpy(opt_names[OPT_NOTIFY_SKILL_UPPER], "notify_skill_upper"); - strcpy(opt_names[OPT_NOTIFY_SKILL_LOWER], "notify_skill_lower"); - strcpy(opt_names[OPT_NOTIFY_ETAL_UPPER], "notify_etal_upper"); - strcpy(opt_names[OPT_NOTIFY_ETAL_LOWER], "notify_etal_lower"); - strcpy(opt_names[OPT_NOTIFY_VALUE], "notify_value"); - - strcpy(opt_names[OPT_BOOL_JOBS], "show_job_offers"); - strcpy(opt_names[OPT_MESS], "message_style"); - strcpy(opt_names[OPT_BOOL_PREFER_MESS], "prefer_messages"); - - strcpy(opt_names[OPT_BOOL_AUTOSAVE], "autosave"); - strcpy(opt_names[OPT_AUTOSAVE_INTERVAL], "autosave_interval"); - - strcpy(opt_names[OPT_BOOL_SORT_TRANSFERS], "sort_transfer_list"); - strcpy(opt_names[OPT_SORT_TRANSFERS_ATTRIBUTE], "sort_transfer_attribute"); - strcpy(opt_names[OPT_BOOL_REARRANGE], "reaarrange_adapts"); - strcpy(opt_names[OPT_BOOL_SWAP], "swap_adapts"); - - strcpy(opt_names[OPT_HISTORY_TEAM_INTERVAL], "history_team_interval"); - strcpy(opt_names[OPT_HISTORY_PLAYER_INTERVAL], "history_player_interval"); - strcpy(opt_names[OPT_HISTORY_TEAM_MAX], "history_team_max"); - strcpy(opt_names[OPT_HISTORY_PLAYER_MAX], "history_player_max"); - strcpy(opt_names[OPT_BOOL_HISTORY_TEAM_DELETE], "history_team_delete"); - strcpy(opt_names[OPT_BOOL_HISTORY_PLAYER_DELETE], "history_player_delete"); - - strcpy(opt_names[OPT_BOOL_BOOST], "boost"); - strcpy(opt_names[OPT_BOOL_COMPRESS], "compress"); - strcpy(opt_names[OPT_BOOL_OBJECTIVE], "objective"); - strcpy(opt_names[OPT_PENALTY_SHOOTER], "penalty_shooter"); - - for(i=0;i<2;i++) + while(file_get_next_opt_line(fil, opt_name, opt_value)) { - for(j=0;jstr); - fprintf(fil, "debug %d\n", debug); fclose(fil); } + +/** Load the options at the beginning of a new game from + the configuration files. */ +void +file_load_conf_files(void) +{ + FILE *fil = NULL; + gchar *conf_file = file_find_support_file("bygfoot.conf"); + + file_my_fopen(conf_file, "r", &fil, TRUE); + g_free(conf_file); + + file_load_opt_file(fil, &options); + + file_my_fopen(opt_str("string_opt_constants_file"), "r", &fil, TRUE); + file_load_opt_file(fil, &constants); +} + +/** Load a user-specific conf file. + @param user The user we load the file for. */ +void +file_load_user_conf_file(User *user) +{ + FILE *fil = NULL; + gchar *conf_file = NULL, buf[SMALL]; + + sprintf(buf, "bygfoot_%s.conf", user->name->str); + conf_file = file_find_support_file(buf); + + if(conf_file == NULL || + !file_my_fopen(conf_file, "r", &fil, FALSE)) + { + g_free(conf_file); + conf_file = file_find_support_file(opt_str("string_opt_default_user_conf_file")); + file_my_fopen(conf_file, "r", &fil, TRUE); + } + + file_load_opt_file(fil, &user->options); +} diff --git a/src/file.h b/src/file.h index 58d45b60..4d1bee0d 100644 --- a/src/file.h +++ b/src/file.h @@ -3,6 +3,7 @@ #include "bygfoot.h" #include "player_struct.h" +#include "user_struct.h" void file_add_support_directory_recursive (const gchar *directory); @@ -11,7 +12,7 @@ gchar* file_find_support_file (const gchar *filename); gboolean -file_get_next_line(FILE *fil, gchar *buf); +file_get_next_opt_line(FILE *fil, gchar *opt_name, gchar *opt_value); GPtrArray* file_dir_get_contents(const gchar *dir_name, const gchar *prefix); @@ -26,12 +27,22 @@ void file_get_definitions_dir(gchar *dir); void -file_write_opt_names(gchar opt_names[][50], gchar player_list_att_names[][PLAYER_LIST_ATTRIBUTE_END][50]); +file_write_opt_names(gchar opt_names[][50], gchar conf_file_names[][100]); void -file_load_conf_file(void); +file_write_user_opt_names(gchar user_opt_names[][50], + gchar player_list_att_names[][PLAYER_LIST_ATTRIBUTE_END][50]); + +void +file_load_conf_files(void); void file_save_conf(void); +void +file_load_user_conf_file(User *user); + +void +file_load_const_file(void); + #endif diff --git a/src/fixture.c b/src/fixture.c index 645c2b3a..a9389d84 100644 --- a/src/fixture.c +++ b/src/fixture.c @@ -5,6 +5,7 @@ #include "main.h" #include "maths.h" #include "misc.h" +#include "table.h" #include "team.h" #include "variables.h" @@ -57,7 +58,7 @@ fixture_write_cup_fixtures(Cup *cup) if(g_array_index(cup->rounds, CupRound, 0). round_robin_number_of_groups > 0) - fixture_write_cup_round_robin(cup, 0); + fixture_write_cup_round_robin(cup, 0, NULL); else { if(cup->type == CUP_TYPE_INTERNATIONAL) @@ -65,7 +66,7 @@ fixture_write_cup_fixtures(Cup *cup) else teams = team_get_pointers_from_choose_teams(cup->choose_teams); - fixture_write_knockout_round(teams, cup, 0); + fixture_write_knockout_round(cup, 0, teams); } /*d*/ @@ -89,25 +90,232 @@ fixture_write_cup_fixtures(Cup *cup) /* } */ } + +/** Update the fixtures for the given cup. + @param cup The cup we update. */ +void +fixture_update(Cup *cup) +{ + gint i; + GArray *fixtures = cup->fixtures; + gint round = g_array_index(fixtures, Fixture, fixtures->len - 1).round; + gint replay = g_array_index(cup->rounds, CupRound, round).replay; + GPtrArray *teams = NULL; + const CupRound *new_round = &g_array_index(cup->rounds, CupRound, round + 1); + + if(replay != 0) + { + if(g_array_index(fixtures, Fixture, fixtures->len - 1).replay_number < replay && + fixture_update_write_replays(cup)) + { + cup->next_fixture_update_week_round++; + return; + } + } + + teams = fixture_get_cup_round_winners(cup); + + if(teams->len < 2) + { + g_warning("fixture_update_cup_fixtures: found less than 2 teams for cup %s\n", + cup->name->str); + return; + } + + if(round == 0 && cup->bye != NULL && cup->bye->len != 0) + { + for(i=0;ibye->len;i++) + g_ptr_array_add(teams, g_ptr_array_index(cup->bye, i)); + + free_g_ptr_array(&cup->bye); + } + + /*d*/ + printf("\n"); + for(i=0;ilen;i++) + printf("%d adv %s\n", i, ((Team*)g_ptr_array_index(teams, i))->name->str); + printf("\n"); + + if(new_round->round_robin_number_of_groups > 0) + fixture_write_cup_round_robin(cup, round + 1, teams); + else + fixture_write_knockout_round(cup, round + 1, teams); + + for(i=0;ifixtures->len;i++) + if(g_array_index(cup->fixtures, Fixture, i).round == round + 1) + printf("%d %d %d %25s - %-25s\n", + g_array_index(cup->fixtures, Fixture, i).week_number, + g_array_index(cup->fixtures, Fixture, i).week_round_number, + g_array_index(cup->fixtures, Fixture, i).clid, + g_array_index(cup->fixtures, Fixture, i).teams[0]->name->str, + g_array_index(cup->fixtures, Fixture, i).teams[1]->name->str); +} + +/** Return the teams that advance to the next cup round. + @param fixtures The fixtures array of the cup. + @return A team pointer array. */ +GPtrArray* +fixture_get_cup_round_winners(const Cup *cup) +{ + gint i; + GPtrArray *array; + GArray *fixtures = cup->fixtures; + gint round = g_array_index(fixtures, Fixture, fixtures->len - 1).round; + const CupRound *cupround = &g_array_index(cup->rounds, CupRound, round); + + if(cupround->round_robin_number_of_groups > 0) + return fixture_get_round_robin_advance(cup); + + array = g_ptr_array_new(); + + if(cupround->replay != 0) + { + for(i=0;ilen;i++) + if(g_array_index(fixtures, Fixture, i).round == round && + (g_array_index(fixtures, Fixture, i).result[0][0] != + g_array_index(fixtures, Fixture, i).result[1][0] || + g_array_index(fixtures, Fixture, i).result[0][1] + + g_array_index(fixtures, Fixture, i).result[0][2] + + g_array_index(fixtures, Fixture, i).result[1][1] + + g_array_index(fixtures, Fixture, i).result[1][2] != 0)) + g_ptr_array_add(array, fixture_winner_of(&g_array_index(fixtures, Fixture, i))); + + return array; + } + + if(!cupround->home_away) + { + for(i=0;ilen;i++) + if(g_array_index(fixtures, Fixture, i).round == round) + g_ptr_array_add(array, fixture_winner_of(&g_array_index(fixtures, Fixture, i))); + + return array; + } + + for(i=0;ilen;i++) + if(g_array_index(fixtures, Fixture, i).round == round && + g_array_index(fixtures, Fixture, i).second_leg) + g_ptr_array_add(array, fixture_winner_of(&g_array_index(fixtures, Fixture, i))); + + return array; +} + +/** Return an array of teams advancing from a round robin + stage of a cup. + @param cup The cup. + @return The pointers to the teams. */ +GPtrArray* +fixture_get_round_robin_advance(const Cup *cup) +{ + gint i, j; + GArray *fixtures = cup->fixtures; + gint round = g_array_index(fixtures, Fixture, fixtures->len - 1).round; + GPtrArray *array = g_ptr_array_new(); + const CupRound *cupround = &g_array_index(cup->rounds, CupRound, round); + GArray *best_advance = g_array_new(FALSE, FALSE, sizeof(TableElement)); + + for(i=0;itables->len;i++) + for(j=0;jtables, Table, i).elements->len;j++) + if(j < cupround->round_robin_number_of_advance) + g_ptr_array_add(array, g_array_index( + g_array_index(cup->tables, Table, i).elements, + TableElement, j).team); + else + g_array_append_val(best_advance, + g_array_index(g_array_index(cup->tables, Table, i).elements, + TableElement, j)); + + g_array_sort_with_data(best_advance, + (GCompareDataFunc)table_element_compare_func, + GINT_TO_POINTER(cup->id)); + + for(i=0;iround_robin_number_of_best_advance;i++) + g_ptr_array_add(array, g_array_index(best_advance, TableElement, i).team); + + return array; +} + +/** Return the pointer of the team that won the encounter. + @param fix The fixture we examine. + @return A team pointer. */ +Team* +fixture_winner_of(const Fixture *fix) +{ + gint i; + const Fixture *first_leg; + const CupRound *cupround = + &g_array_index(cup_from_clid(fix->clid)->rounds, CupRound, fix->round); + + if(cupround->replay != 0 || !cupround->home_away) + return fix->teams[(math_sum_int_array(&(fix->result[0][0]), 3) < + math_sum_int_array(&(fix->result[1][0]), 3))]; + + first_leg = fixture_get_first_leg(fix); + + printf("win_of %s %d - %d %s\n", + fix->teams[0]->name->str, fix->result[0][0], + fix->result[1][0], + fix->teams[1]->name->str); + printf("win_of %s %d - %d %s\n", first_leg->teams[0]->name->str, first_leg->result[0][0], + first_leg->result[1][0], + first_leg->teams[1]->name->str); + printf("\n"); + + if(fix->result[0][0] + first_leg->result[1][0] > + fix->result[1][0] + first_leg->result[0][0]) + return fix->teams[0]; + + if(fix->result[1][0] > first_leg->result[1][0]) + return fix->teams[1]; + + return fix->teams[(fix->result[0][1] + fix->result[0][2] < + fix->result[1][1] + fix->result[1][2])]; +} + +/** Write replay matches for the cup. + @param cup The cup. + @return TRUE if fixtures were written, FALSE otherwise. */ +gboolean +fixture_update_write_replays(Cup *cup) +{ + gint i; + GArray *fixtures = cup->fixtures; + gint replay_number = g_array_index(fixtures, Fixture, fixtures->len - 1).replay_number + 1; + gint round = g_array_index(fixtures, Fixture, fixtures->len - 1).round; + gboolean return_value; + + for(i=0;ilen;i++) + if(g_array_index(fixtures, Fixture, i).round == round && + g_array_index(fixtures, Fixture, i).replay_number == replay_number - 1 && + g_array_index(fixtures, Fixture, i).result[0][0] == + g_array_index(fixtures, Fixture, i).result[1][0]) + fixture_write(fixtures, g_array_index(fixtures, Fixture, i).teams[1], + g_array_index(fixtures, Fixture, i).teams[0], week, week_round + 1, + cup->id, round, replay_number, + !g_array_index(cup->rounds, CupRound, round).neutral, + FALSE, (g_array_index(cup->rounds, CupRound, round).replay == replay_number)); + + return_value = (g_array_index(fixtures, Fixture, fixtures->len - 1).replay_number == replay_number); + + printf("retval %d\n", return_value); + return return_value; +} + /** Write round robins for the given cup and cup round. @param cup The cup the fixtures are for. @param cup_round The cup round. */ void -fixture_write_cup_round_robin(Cup *cup, gint cup_round) +fixture_write_cup_round_robin(Cup *cup, gint cup_round, GPtrArray *teams) { gint i, j; gint number_of_groups = g_array_index(cup->rounds, CupRound, cup_round).round_robin_number_of_groups; - GPtrArray *teams = NULL; GPtrArray *teams_group[number_of_groups]; Table new_table; TableElement new_table_element; - if(cup_round == 0) + if(teams == NULL) teams = misc_randomise_g_pointer_array(cup_get_team_pointers(cup)); - /*todo*/ -/* else */ -/* teams = cup_get_winners_of_round(cup, cup_round - 1); */ if(teams->len % number_of_groups != 0) { @@ -123,6 +331,7 @@ fixture_write_cup_round_robin(Cup *cup, gint cup_round) { new_table.name = g_string_new(cup->name->str); new_table.clid = cup->id; + new_table.round = cup_round; new_table.elements = g_array_new(FALSE, FALSE, sizeof(TableElement)); teams_group[i] = g_ptr_array_new(); @@ -131,7 +340,7 @@ fixture_write_cup_round_robin(Cup *cup, gint cup_round) { g_ptr_array_add(teams_group[i], g_ptr_array_index(teams, j + i * number_of_groups)); new_table_element = - league_table_element_new((Team*)g_ptr_array_index(teams, j + i * number_of_groups)); + table_element_new((Team*)g_ptr_array_index(teams, j + i * number_of_groups)); g_array_append_val(new_table.elements, new_table_element); } @@ -140,10 +349,10 @@ fixture_write_cup_round_robin(Cup *cup, gint cup_round) fixture_write_round_robin((gpointer)cup, cup_round, teams_group[i]); } - cup->next_fixture_update_week = - g_array_index(cup->fixtures, Fixture, cup->fixtures->len - 1).week_number; - cup->next_fixture_update_week_round = - g_array_index(cup->fixtures, Fixture, cup->fixtures->len - 1).week_round_number; + cup->next_fixture_update_week = (cup_round < cup->rounds->len - 1) ? + g_array_index(cup->fixtures, Fixture, cup->fixtures->len - 1).week_number : -1; + cup->next_fixture_update_week_round = (cup_round < cup->rounds->len - 1) ? + g_array_index(cup->fixtures, Fixture, cup->fixtures->len - 1).week_round_number : -1; } /** Write round robin fixtures for the teams in the array. @@ -160,7 +369,7 @@ fixture_write_round_robin(gpointer league_cup, gint cup_round, GPtrArray *teams) { gint i, j; gint first_week, week_gap, clid, first_fixture; - gboolean home_advantage, second_leg, decisive; + gboolean home_advantage; League *league = NULL; Cup *cup = NULL; gint len = teams->len; @@ -187,7 +396,6 @@ fixture_write_round_robin(gpointer league_cup, gint cup_round, GPtrArray *teams) home_advantage = (!g_array_index(cup->rounds, CupRound, cup_round).neutral); } - second_leg = decisive = FALSE; first_fixture = fixtures->len; if(first_week < 1) @@ -205,7 +413,7 @@ fixture_write_round_robin(gpointer league_cup, gint cup_round, GPtrArray *teams) fixture_write_round_robin_matchday(fixtures, cup_round, teams, i, first_week + i * week_gap, fixture_get_free_round(first_week + i * week_gap, clid), - clid, home_advantage, second_leg, decisive); + clid, home_advantage); /* second half of fixtures */ for(i = 0; i < len - 1; i++) @@ -214,7 +422,7 @@ fixture_write_round_robin(gpointer league_cup, gint cup_round, GPtrArray *teams) g_array_index(fixtures, Fixture, first_fixture + i * (len / 2) + j).teams[0], first_week + (len - 1 + i) * week_gap, fixture_get_free_round(first_week + (len - 1 + i) * week_gap, clid), - clid, cup_round, home_advantage, second_leg, decisive); + clid, cup_round, 0, home_advantage, FALSE, FALSE); } /** Write one matchday of round robin games. @@ -227,14 +435,11 @@ fixture_write_round_robin(gpointer league_cup, gint cup_round, GPtrArray *teams) @param week_number The week the matchday takes place. @param week_round_number The week_round the matchday takes place. @param clid The id of the league or cup. - @param home_advantage Whether there's home advantage. - @param second_leg Whether this is the second leg of a round. - @param decisive Whether the match has to have a winner. */ + @param home_advantage Whether there's home advantage. */ void fixture_write_round_robin_matchday(GArray *fixtures, gint cup_round, GPtrArray *teams, gint special, gint week_number, gint week_round_number, - gint clid, gboolean home_advantage, gboolean second_leg, - gboolean decisive) + gint clid, gboolean home_advantage) { gint i; gint len = teams->len / 2; @@ -256,7 +461,7 @@ fixture_write_round_robin_matchday(GArray *fixtures, gint cup_round, GPtrArray * for(i=0;ilen; gint first_week = cup_get_first_week_of_cup_round(cup, cup_round); @@ -290,7 +495,7 @@ fixture_write_knockout_round(GPtrArray *teams, Cup *cup, gint cup_round) for(i=0; i<(len - bye_len) / 2; i++) fixture_write(cup->fixtures, (Team*)g_ptr_array_index(teams, i), (Team*)g_ptr_array_index(teams, i + (len - bye_len) / 2), first_week, - fixture_get_free_round(first_week, cup->id), cup->id, cup_round, + fixture_get_free_round(first_week, cup->id), cup->id, cup_round, 0, !round->neutral, FALSE, (!round->home_away && round->replay == 0));/*todo: adjust round->replay */ if(round->home_away) @@ -298,12 +503,12 @@ fixture_write_knockout_round(GPtrArray *teams, Cup *cup, gint cup_round) fixture_write(cup->fixtures, (Team*)g_ptr_array_index(teams, i + (len - bye_len) / 2), (Team*)g_ptr_array_index(teams, i), first_week + cup->week_gap, fixture_get_free_round(first_week + cup->week_gap, cup->id), cup->id, - cup_round, !round->neutral, TRUE, TRUE); + cup_round, 0, !round->neutral, TRUE, TRUE); - cup->next_fixture_update_week = - g_array_index(cup->fixtures, Fixture, cup->fixtures->len - 1).week_number; - cup->next_fixture_update_week_round = - g_array_index(cup->fixtures, Fixture, cup->fixtures->len - 1).week_round_number; + cup->next_fixture_update_week = (cup_round < cup->rounds->len - 1) ? + g_array_index(cup->fixtures, Fixture, cup->fixtures->len - 1).week_number : -1; + cup->next_fixture_update_week_round = (cup_round < cup->rounds->len - 1) ? + g_array_index(cup->fixtures, Fixture, cup->fixtures->len - 1).week_round_number : -1; } /** Write a fixture and append it to a fixture array. @@ -314,19 +519,21 @@ fixture_write_knockout_round(GPtrArray *teams, Cup *cup, gint cup_round) @param week_round_number The week_round it takes place. @param clid The id of the league or cup. @param cup_round The index of the cup round or -1 if it's a league. + @param replay_number Whether this is a replay match and the how 'manyth' it is. @param home_advantage Whether there's home advantage. @param second_leg Whether this is the second leg of a round. @param decisive Whether the match has to have a winner. */ void fixture_write(GArray *fixtures, Team *home_team, Team *away_team, gint week_number, - gint week_round_number, gint clid, gint cup_round, gboolean home_advantage, - gboolean second_leg, gboolean decisive) + gint week_round_number, gint clid, gint cup_round, gint replay_number, + gboolean home_advantage, gboolean second_leg, gboolean decisive) { gint i; Fixture new; new.clid = clid; new.round = cup_round; + new.replay_number = replay_number; new.week_number = week_number; new.week_round_number = week_round_number; new.teams[0] = (Team*)home_team; @@ -337,7 +544,7 @@ fixture_write(GArray *fixtures, Team *home_team, Team *away_team, gint week_numb new.home_advantage = home_advantage; new.second_leg = second_leg; new.decisive = decisive; - new.attendance = 0; + new.attendance = -1; g_array_append_val(fixtures, new); } @@ -390,14 +597,91 @@ query_fixture_is_earlier(const Fixture *fix1, const Fixture *fix2) gboolean query_fixture_is_draw(const Fixture *fix) { + const Fixture *first_leg; + + if(!fix->decisive) + return FALSE; + + if(!fix->second_leg) + return (fix->result[0][0] + fix->result[0][1] == + fix->result[1][0] + fix->result[1][1]); + + first_leg = fixture_get_first_leg(fix); + + return (fix->result[0][0] + first_leg->result[1][0] == + fix->result[1][0] + first_leg->result[0][0] && + fix->result[0][0] == first_leg->result[0][0] && + fix->result[0][1] == fix->result[1][1]); +} + +/** Check whether a user's team participates. + @param fix The fixture we check. + @return Index of the user or -1. */ +gint +fixture_user_team_involved(const Fixture *fix) +{ + if(team_is_user(fix->teams[0]) != -1) + return team_is_user(fix->teams[0]); + + if(team_is_user(fix->teams[1]) != -1) + return team_is_user(fix->teams[1]); + + return -1; +} + +/** Check whether we have to update a table + after calculating the fixture. + @param fix The fixture that got calculated. + @return TRUE or FALSE. */ +gboolean +query_fixture_has_tables(const Fixture *fix) +{ + return (fix->clid < ID_CUP_START || + g_array_index(cup_from_clid(fix->clid)->rounds, CupRound, fix->round). + round_robin_number_of_groups != 0); +} + +/** Find out whether there were games in the specified league + or cup at the specified time. + @param clid The cup or league id. + @param week_number The week number. + @param week_round_number The week round. + @return TRUE or FALSE. */ +gboolean +query_fixture_in_week_round(gint clid, gint week_number, gint week_round_number) +{ + gint i; + GArray *fixtures = (clid < ID_CUP_START) ? + league_from_clid(clid)->fixtures : cup_from_clid(clid)->fixtures; + + + for(i=0;ilen;i++) + if(g_array_index(fixtures, Fixture, i).week_number == week_number && + g_array_index(fixtures, Fixture, i).week_round_number == week_round_number) + return TRUE; + return FALSE; } -/** Check whether the user's team participates. - @param fix The fixture we check. - @return TRUE or FALSE. */ -gboolean -query_my_team_involved(const Fixture *fix) +/** Return a pointer to the first leg going with + the fixture. + @param fix The second leg fixture. + @return A fixture pointer or NULL if failed. */ +Fixture* +fixture_get_first_leg(const Fixture *fix) { - return (fix->teams[0] == my_team || fix->teams[1] == my_team); + gint i; + Fixture *first_leg = NULL; + + for(i=0;iclid)->fixtures->len;i++) + if(g_array_index(cup_from_clid(fix->clid)->fixtures, Fixture, i).round == fix->round && + g_array_index(cup_from_clid(fix->clid)->fixtures, Fixture, i).teams[0] == fix->teams[1] && + g_array_index(cup_from_clid(fix->clid)->fixtures, Fixture, i).teams[1] == fix->teams[0]) + first_leg = &g_array_index(cup_from_clid(fix->clid)->fixtures, Fixture, i); + + if(first_leg == NULL) + g_warning("fixture_get_first_leg: didn't find first leg match; cup %s round %d\n", + cup_from_clid(fix->clid)->name->str, fix->round); + + return first_leg; } diff --git a/src/fixture.h b/src/fixture.h index 99014d63..c4ef9676 100644 --- a/src/fixture.h +++ b/src/fixture.h @@ -13,7 +13,7 @@ void fixture_write_cup_fixtures(Cup *cup); void -fixture_write_cup_round_robin(Cup *cup, gint cup_round); +fixture_write_cup_round_robin(Cup *cup, gint cup_round, GPtrArray *teams); void fixture_write_round_robin(gpointer league_cup, gint cup_round, GPtrArray *teams); @@ -21,16 +21,30 @@ fixture_write_round_robin(gpointer league_cup, gint cup_round, GPtrArray *teams) void fixture_write_round_robin_matchday(GArray *fixtures, gint cup_round, GPtrArray *teams, gint special, gint week_number, gint week_round_number, - gint clid, gboolean home_advantage, gboolean second_leg, - gboolean decisive); + gint clid, gboolean home_advantage); void -fixture_write_knockout_round(GPtrArray *teams, Cup *cup, gint cup_round); +fixture_write_knockout_round(Cup *cup, gint cup_round, GPtrArray *teams); void fixture_write(GArray *fixtures, Team *home_team, Team *away_team, gint week_number, - gint week_round_number, gint clid, gint cup_round, gboolean home_advantage, - gboolean second_leg, gboolean decisive); + gint week_round_number, gint clid, gint cup_round, gint replay_number, + gboolean home_advantage, gboolean second_leg, gboolean decisive); + +void +fixture_update(Cup *cup); + +gboolean +fixture_update_write_replays(Cup *cup); + +GPtrArray* +fixture_get_cup_round_winners(const Cup *cup); + +GPtrArray* +fixture_get_round_robin_advance(const Cup *cup); + +Team* +fixture_winner_of(const Fixture *fix); gint fixture_get_free_round(gint week_number, gint clid); @@ -41,7 +55,16 @@ query_fixture_is_earlier(const Fixture *fix1, const Fixture *fix2); gboolean query_fixture_is_draw(const Fixture *fix); +gint +fixture_user_team_involved(const Fixture *fix); + gboolean -query_my_team_involved(const Fixture *fix); +query_fixture_has_tables(const Fixture *fix); + +gboolean +query_fixture_in_week_round(gint clid, gint week_number, gint week_round_number); + +Fixture* +fixture_get_first_leg(const Fixture *fix); #endif diff --git a/src/fixture_struct.h b/src/fixture_struct.h index be62df17..4d7462f9 100644 --- a/src/fixture_struct.h +++ b/src/fixture_struct.h @@ -12,6 +12,8 @@ typedef struct gint clid; /** The round (in a cup) the fixture belongs to. */ gint round; + /** The replay number (ie. how often the match was repeated because of a draw). */ + gint replay_number; /** When it takes place. */ gint week_number, week_round_number; /** The teams involved. */ diff --git a/src/free.c b/src/free.c index f6c77dbf..22c2c015 100644 --- a/src/free.c +++ b/src/free.c @@ -3,6 +3,7 @@ #include "free.h" #include "league.h" #include "player.h" +#include "user.h" #include "variables.h" #include "window.h" @@ -15,19 +16,71 @@ free_memory(void) { free_variables(); free_country(); - free_g_string(&font_name); - free_live_game(&live_game); + free_users(); free_live_game(&live_game_temp); } +/** Free the users array. */ +void +free_users(void) +{ + gint i; + + if(users == NULL) + return; + + for(i=0;ilen;i++) + free_user(&usr(i)); + + free_g_array(&users); +} + +/** Free the memory the user occupies. + @param user The user we free. */ +void +free_user(User *user) +{ + free_g_string(&user->name); + free_g_string(&user->font_name); + free_live_game(&user->live_game); + free_option_array(&user->options, FALSE); +} + +/** Free an array of options. + @param array The array we free. + @param reset Whether to create the array anew (empty). + @see #Option */ +void +free_option_array(GArray **array, gboolean reset) +{ + gint i; + + if(*array == NULL) + { + if(reset) + *array = g_array_new(FALSE, FALSE, sizeof(Option)); + + return; + } + + for(i=0;i<(*array)->len;i++) + { + free_g_string(&g_array_index(*array, Option, i).name); + free_g_string(&g_array_index(*array, Option, i).string_value); + } + + free_g_array(array); + + if(reset) + *array = g_array_new(FALSE, FALSE, sizeof(Option)); +} + /** Free a live game variable. */ void free_live_game(LiveGame *match) { gint i; - window_destroy(&match->window); - if(match->units == NULL) return; @@ -250,6 +303,9 @@ free_variables(void) free_g_string_array(&player_names); free_g_array(&transfer_list); + + free_option_array(&options, FALSE); + free_option_array(&constants, FALSE); } /** diff --git a/src/free.h b/src/free.h index 9b847188..e110c0a2 100644 --- a/src/free.h +++ b/src/free.h @@ -7,6 +7,7 @@ #include "live_game_struct.h" #include "player_struct.h" #include "team_struct.h" +#include "user_struct.h" void free_g_array(GArray **array); @@ -20,6 +21,12 @@ free_g_string(GString **string); void free_memory(void); +void +free_users(void); + +void +free_user(User *user); + void free_country(void); @@ -59,4 +66,7 @@ free_player(Player *pl); void free_live_game(LiveGame *match); +void +free_option_array(GArray **array, gboolean reset); + #endif diff --git a/src/game.c b/src/game.c index 3b21d975..f9601d42 100644 --- a/src/game.c +++ b/src/game.c @@ -1,14 +1,12 @@ #include "fixture.h" #include "game.h" #include "maths.h" +#include "option.h" #include "player.h" #include "team.h" +#include "user.h" #include "variables.h" -/** Influence in % of the game style towards more attack. - @see game_get_values() */ -#define CONSTANT_GAME_STYLE_FACTOR 0.075 - /** How the cskill of field players get weighted for the team values in a match. Rows are player position, columns value type. @see game_get_player_contribution() */ @@ -33,18 +31,20 @@ game_get_values(const Fixture *fix, gfloat team_values[][GAME_TEAM_VALUE_END], gfloat style_factor; /*d*/ - printf("\nhome %.2f\n", home_advantage); +/* printf("\nhome %.2f\n", home_advantage); */ for(i=0;i<2;i++) { for(j=0;jstyle * CONSTANT_GAME_STYLE_FACTOR; + style_factor = (gfloat)tm[i]->style * const_float("float_game_style_factor"); team_values[i][GAME_TEAM_VALUE_GOALIE] = game_get_player_contribution(player_of(tm[i], 0), FALSE) * (1 + home_advantage * (i == 0)) * - (1 + CONSTANT_PLAYER_BOOST_SKILL_EFFECT * (tm[i] == my_team && options[OPT_BOOL_BOOST] == 1)); + (1 + const_float("float_player_boost_skill_effect") * + (team_is_user(tm[i]) != -1 && + option_int("int_opt_user_boost", usr(team_is_user(tm[i])).options) == 1)); for(j=1;j<11;j++) { @@ -58,17 +58,14 @@ game_get_values(const Fixture *fix, gfloat team_values[][GAME_TEAM_VALUE_END], team_values[i][GAME_TEAM_VALUE_ATTACK] *= ((1 + style_factor) * (1 + home_advantage * (i == 0)) * - (1 + CONSTANT_PLAYER_BOOST_SKILL_EFFECT * (tm[i] == my_team && options[OPT_BOOL_BOOST] == 1))); + (1 + const_float("float_player_boost_skill_effect") * + (team_is_user(tm[i]) != -1 && + option_int("int_opt_user_boost", usr(team_is_user(tm[i])).options) == 1))); team_values[i][GAME_TEAM_VALUE_DEFEND] *= ((1 - style_factor) * (1 + home_advantage * (i == 0)) * - (1 + CONSTANT_PLAYER_BOOST_SKILL_EFFECT * (tm[i] == my_team && options[OPT_BOOL_BOOST] == 1))); - - /*d*/ - printf("%s attack %.1f midf %.1f defend %.1f\n", - tm[i]->name->str, - team_values[i][GAME_TEAM_VALUE_ATTACK], - team_values[i][GAME_TEAM_VALUE_MIDFIELD], - team_values[i][GAME_TEAM_VALUE_DEFEND]); + (1 + const_float("float_player_boost_skill_effect") * + (team_is_user(tm[i]) != -1 && + option_int("int_opt_user_boost", usr(team_is_user(tm[i])).options) == 1))); } } @@ -81,7 +78,7 @@ gfloat game_get_player_contribution(const Player *pl, gint type) { return (gfloat)(pl->cskill * powf((gfloat)pl->fitness / 100, - CONSTANT_GAME_PLAYER_FITNESS_EXPONENT) * + const_float("float_player_fitness_exponent")) * player_weights[pl->cpos - 1][type - GAME_TEAM_VALUE_DEFEND]); } @@ -90,13 +87,13 @@ game_get_player_contribution(const Player *pl, gint type) @param tm The team we examine. @param player_type Whether we concentrate on attacking or defending players or would like to have a penalty shooting player. - @param number_of_penalty Which penalty has to be taken (1st, 2nd etc.) + @param last_penalty The player that shot the last penalty. @param not_this_one A player to exclude. @param skills Whether to weight with skills, too. @return A player index. */ gint game_get_player(const Team *tm, gint player_type, - gint number_of_penalty, gint not_this_one, + gint last_penalty, gint not_this_one, gboolean skills) { gint i, player = not_this_one; @@ -125,8 +122,7 @@ game_get_player(const Team *tm, gint player_type, else if(player_type == GAME_PLAYER_TYPE_INJURY) weights[0] = -1; else if(player_type == GAME_PLAYER_TYPE_PENALTY) - /*d*/ - return player_of(tm, 10)->id; + return game_get_penalty_taker(tm, last_penalty); game_get_player_probs(tm->players, probs, weights, skills); @@ -164,15 +160,53 @@ game_get_player_probs(GArray *players, gfloat *probs, gfloat *weights, gboolean { probs[0] = (skills) ? (gfloat)g_array_index(players, Player, 1).cskill * powf((gfloat)g_array_index(players, Player, 1).fitness, - CONSTANT_GAME_PLAYER_FITNESS_EXPONENT) * + const_float("float_player_fitness_exponent")) * weights[g_array_index(players, Player, 1).pos - 1] : weights[g_array_index(players, Player, 1).pos - 1]; for(i=1;i<10;i++) probs[i] = probs[i - 1] + ((skills) ? (gfloat)g_array_index(players, Player, i + 1).cskill * powf((gfloat)g_array_index(players, Player, i + 1).fitness, - CONSTANT_GAME_PLAYER_FITNESS_EXPONENT) * + const_float("float_player_fitness_exponent")) * weights[g_array_index(players, Player, i + 1).pos - 1] : weights[g_array_index(players, Player, i + 1).pos - 1]); } } + +/** Return the player who's shooting the following penalty + (at penalty shoot-out). + @param tm The team that has the penalty. + @param last_penalty The player that shot the last penalty. + @return A player id. */ +gint +game_get_penalty_taker(const Team *tm, gint last_penalty) +{ + gint i; + GPtrArray *players = g_ptr_array_new(); + + for(i=0;i<11;i++) + if(player_of(tm, i)->cskill != 0) + g_ptr_array_add(players, player_of(tm, i)); + + g_ptr_array_sort_with_data(players, (GCompareDataFunc)player_compare_func, + GINT_TO_POINTER(PLAYER_COMPARE_ATTRIBUTE_GAME_SKILL)); + + if(last_penalty == -1 || + last_penalty == ((Player*)g_ptr_array_index(players, players->len - 1))->id) + return ((Player*)g_ptr_array_index(players, 0))->id; + + for(i=0;ilen - 1;i++) + if(last_penalty == ((Player*)g_ptr_array_index(players, i))->id) + return ((Player*)g_ptr_array_index(players, i + 1))->id; + + return -1; +} + +/** Calculate the number of spectators. + @param fix The fixture we examine. */ +void +game_calculate_attendance(Fixture *fix) +{ + /*d*/ + fix->attendance = 1000; +} diff --git a/src/game.h b/src/game.h index 1902e513..60ae6479 100644 --- a/src/game.h +++ b/src/game.h @@ -5,14 +5,6 @@ #include "fixture_struct.h" #include "player_struct.h" -/** Influence of the fitness on the player contribution. - The higher the worse. @see game_get_player_contribution() */ -#define CONSTANT_GAME_PLAYER_FITNESS_EXPONENT 0.25 -/* #define CONSTANT_GAME_HOME_ADVANTAGE_LOWER 0.04 */ -/* #define CONSTANT_GAME_HOME_ADVANTAGE_UPPER 0.08 */ -#define CONSTANT_GAME_HOME_ADVANTAGE_LOWER 0.04 -#define CONSTANT_GAME_HOME_ADVANTAGE_UPPER 0.08 - /** Indices for the team_value array. @see game_get_values() */ enum GameTeamValue @@ -50,4 +42,10 @@ game_get_player(const Team *tm, gint player_type, void game_get_player_probs(GArray *players, gfloat *probs, gfloat *weights, gboolean skills); +gint +game_get_penalty_taker(const Team *tm, gint last_penalty); + +void +game_calculate_attendance(Fixture *fix); + #endif diff --git a/src/game_gui.c b/src/game_gui.c index 2418a447..34ce287a 100644 --- a/src/game_gui.c +++ b/src/game_gui.c @@ -1,24 +1,20 @@ #include #include "game_gui.h" +#include "gui.h" +#include "league.h" +#include "live_game.h" +#include "maths.h" +#include "option.h" #include "treeview.h" #include "support.h" -#include "window.h" - -/** Constants determining the live game area scale - behaviour. */ -#define CONSTANT_GAME_GUI_LIVE_GAME_SCALE_ATTACK 0.3 -#define CONSTANT_GAME_GUI_LIVE_GAME_SCALE_CHANCE 0.45 -#define CONSTANT_GAME_GUI_LIVE_GAME_SCALE_RANGE 10.0 -#define CONSTANT_GAME_GUI_LIVE_GAME_SCALE_COLOR_DEFEND "lightblue" -#define CONSTANT_GAME_GUI_LIVE_GAME_SCALE_COLOR_MIDFIELD "khaki" -#define CONSTANT_GAME_GUI_LIVE_GAME_SCALE_COLOR_ATTACK "gold" -#define CONSTANT_GAME_GUI_LIVE_GAME_SCALE_COLOR_CHANCE "orange" -#define CONSTANT_GAME_GUI_LIVE_GAME_SCALE_COLOR_GOAL "red" -#define CONSTANT_GAME_GUI_LIVE_GAME_SCALE_COLOR_MISS "lightgreen" +#include "team.h" +#include "user.h" +#include "variables.h" /** Show the live game in the live game window. - @param unit The current unit we show. */ + @param unit The current unit we show. + @param sleep_factor The factor determining the live game speed. */ void game_gui_live_game_show_unit(const LiveGameUnit *unit) { @@ -26,34 +22,30 @@ game_gui_live_game_show_unit(const LiveGameUnit *unit) gfloat fraction = (gfloat)live_game_unit_get_minute(unit) / 90; GtkProgressBar *progress_bar; - if(live_game.window == NULL) - { - live_game.window = window_create(WINDOW_LIVE); + if(unit->event.type == LIVE_GAME_EVENT_START_MATCH) treeview_live_game_show_initial_commentary(unit); - - gtk_range_set_range( - GTK_RANGE(lookup_widget(live_game.window, "hscale_area")), 0, - CONSTANT_GAME_GUI_LIVE_GAME_SCALE_RANGE); - } else treeview_live_game_show_commentary(unit); treeview_live_game_show_result(unit); game_gui_live_game_set_hscale(unit, - GTK_HSCALE(lookup_widget(live_game.window, "hscale_area"))); + GTK_HSCALE(lookup_widget(window.live, "hscale_area"))); sprintf(buf, "%d.", live_game_unit_get_minute(unit)); - progress_bar = GTK_PROGRESS_BAR(lookup_widget(live_game.window, "progressbar_live")); + progress_bar = GTK_PROGRESS_BAR(lookup_widget(window.live, "progressbar_live")); gtk_progress_bar_set_fraction(progress_bar, (fraction > 1) ? 1 : fraction); gtk_progress_bar_set_text(progress_bar, buf); - usleep(500500 + options[OPT_LIVE_SPEED] * 50000); + usleep(500500 + option_int("int_opt_user_live_game_speed", + usr(stat2).options) * 50000); while(gtk_events_pending()) gtk_main_iteration(); if(unit->event.type == LIVE_GAME_EVENT_END_MATCH) - gtk_widget_set_sensitive(lookup_widget(live_game.window, "button_live_close"), TRUE); - + { + gtk_widget_set_sensitive(lookup_widget(window.live, "button_live_close"), TRUE); + gtk_widget_hide(lookup_widget(window.live, "button_pause")); + } } /** Set the area scale position and color in the live game window. @@ -68,58 +60,271 @@ game_gui_live_game_set_hscale(const LiveGameUnit *unit, GtkHScale *hscale) if(unit->area == LIVE_GAME_UNIT_AREA_MIDFIELD) { - gdk_color_parse(CONSTANT_GAME_GUI_LIVE_GAME_SCALE_COLOR_MIDFIELD, &color); + gdk_color_parse(const_str("string_game_gui_live_game_scale_color_midfield"), &color); gtk_range_set_value(GTK_RANGE(hscale), - CONSTANT_GAME_GUI_LIVE_GAME_SCALE_RANGE / 2); + const_float("float_game_gui_live_game_scale_range") / 2); } else if(unit->event.type == LIVE_GAME_EVENT_GOAL || unit->event.type == LIVE_GAME_EVENT_OWN_GOAL) { - gdk_color_parse(CONSTANT_GAME_GUI_LIVE_GAME_SCALE_COLOR_GOAL, &color); + gdk_color_parse(const_str("string_game_gui_live_game_scale_color_goal"), &color); gtk_range_set_value(GTK_RANGE(hscale), - CONSTANT_GAME_GUI_LIVE_GAME_SCALE_RANGE * (unit->possession == 0)); + const_float("float_game_gui_live_game_scale_range") * + (unit->possession == 0)); } else if(unit->event.type == LIVE_GAME_EVENT_SCORING_CHANCE || unit->event.type == LIVE_GAME_EVENT_PENALTY || unit->event.type == LIVE_GAME_EVENT_FREE_KICK) { - gdk_color_parse(CONSTANT_GAME_GUI_LIVE_GAME_SCALE_COLOR_CHANCE, &color); + gdk_color_parse(const_str("string_game_gui_live_game_scale_color_chance"), &color); gtk_range_set_value(GTK_RANGE(hscale), - CONSTANT_GAME_GUI_LIVE_GAME_SCALE_RANGE / 2 + - (CONSTANT_GAME_GUI_LIVE_GAME_SCALE_RANGE * - CONSTANT_GAME_GUI_LIVE_GAME_SCALE_CHANCE * + const_float("float_game_gui_live_game_scale_range") / 2 + + (const_float("float_game_gui_live_game_scale_range") * + const_float("float_game_gui_live_game_scale_chance") * ((unit->possession == 0) ? 1 : -1))); } else if(unit->event.type == LIVE_GAME_EVENT_POST || unit->event.type == LIVE_GAME_EVENT_MISSED || unit->event.type == LIVE_GAME_EVENT_SAVE || unit->event.type == LIVE_GAME_EVENT_CROSS_BAR) - gdk_color_parse(CONSTANT_GAME_GUI_LIVE_GAME_SCALE_COLOR_MISS, &color); + gdk_color_parse(const_str("string_game_gui_live_game_scale_color_miss"), &color); else if(unit->area == LIVE_GAME_UNIT_AREA_ATTACK) { - gdk_color_parse(CONSTANT_GAME_GUI_LIVE_GAME_SCALE_COLOR_ATTACK, &color); + gdk_color_parse(const_str("string_game_gui_live_game_scale_color_attack"), &color); gtk_range_set_value(GTK_RANGE(hscale), - CONSTANT_GAME_GUI_LIVE_GAME_SCALE_RANGE / 2 + - (CONSTANT_GAME_GUI_LIVE_GAME_SCALE_RANGE * - CONSTANT_GAME_GUI_LIVE_GAME_SCALE_ATTACK * + const_float("float_game_gui_live_game_scale_range") / 2 + + (const_float("float_game_gui_live_game_scale_range") * + const_float("float_game_gui_live_game_scale_attack") * ((unit->possession == 0) ? 1 : -1))); } else if(unit->area == LIVE_GAME_UNIT_AREA_DEFEND) { - gdk_color_parse(CONSTANT_GAME_GUI_LIVE_GAME_SCALE_COLOR_DEFEND, &color); + gdk_color_parse(const_str("string_game_gui_live_game_scale_color_defend"), &color); gtk_range_set_value(GTK_RANGE(hscale), - CONSTANT_GAME_GUI_LIVE_GAME_SCALE_RANGE / 2 + - (CONSTANT_GAME_GUI_LIVE_GAME_SCALE_RANGE * - CONSTANT_GAME_GUI_LIVE_GAME_SCALE_ATTACK * + const_float("float_game_gui_live_game_scale_range") / 2 + + (const_float("float_game_gui_live_game_scale_range") * + const_float("float_game_gui_live_game_scale_attack") * ((unit->possession == 0) ? -1 : 1))); } else g_warning("game_gui_live_game_set_hscale: don't know what to do!\n"); gtk_widget_modify_bg(GTK_WIDGET(hscale), GTK_STATE_NORMAL, &color); - - if(debug) - printf("***** area %d value %.1f\n", unit->area, gtk_range_get_value(GTK_RANGE(hscale))); +} + +/** Look up the widgets in the main window. */ +void +game_gui_get_radio_items(GtkWidget **style, GtkWidget **scout, + GtkWidget **physio) +{ + style[0] = lookup_widget(window.main, "menu_all_out_defend"); + style[1] = lookup_widget(window.main, "menu_defend"); + style[2] = lookup_widget(window.main, "menu_balanced"); + style[3] = lookup_widget(window.main, "menu_attack"); + style[4] = lookup_widget(window.main, "menu_all_out_attack"); + + scout[0] = lookup_widget(window.main, "menu_scout_best"); + scout[1] = lookup_widget(window.main, "menu_scout_good"); + scout[2] = lookup_widget(window.main, "menu_scout_average"); + scout[3] = lookup_widget(window.main, "menu_scout_bad"); + + physio[0] = lookup_widget(window.main, "menu_physio_best"); + physio[1] = lookup_widget(window.main, "menu_physio_good"); + physio[2] = lookup_widget(window.main, "menu_physio_average"); + physio[3] = lookup_widget(window.main, "menu_physio_bad"); +} + +/** Set information like season, user, week etc. into the appropriate labels. */ +void +game_gui_set_main_window_header(void) +{ + GtkLabel *label_user= GTK_LABEL(lookup_widget(window.main, "label_user")); + GtkLabel *label_season= GTK_LABEL(lookup_widget(window.main, "label_season")); + GtkLabel *label_week= GTK_LABEL(lookup_widget(window.main, "label_week")); + GtkLabel *label_round= GTK_LABEL(lookup_widget(window.main, "label_round")); + GtkLabel *label_team= GTK_LABEL(lookup_widget(window.main, "label_team")); + GtkLabel *label_league= GTK_LABEL(lookup_widget(window.main, "label_league")); + GtkLabel *label_rank= GTK_LABEL(lookup_widget(window.main, "label_rank")); + GtkLabel *label_money= GTK_LABEL(lookup_widget(window.main, "label_money")); + + gtk_label_set_text(label_user, usr(current_user).name->str); + gui_label_set_text_from_int(label_season, season, FALSE); + gui_label_set_text_from_int(label_week, week, FALSE); + gui_label_set_text_from_int(label_round, week_round, FALSE); + gui_label_set_text_from_int(label_rank, week_round, FALSE); + gui_label_set_text_from_int(label_money, usr(current_user).finances[FIN_MONEY], FALSE); + gui_label_set_text_from_int(label_rank, team_rank(usr(current_user).tm), FALSE); + + gtk_label_set_text(label_team, usr(current_user).tm->name->str); + gtk_label_set_text(label_league, league_from_clid(usr(current_user).tm->clid)->name->str); + + game_gui_write_av_skills(); + + game_gui_write_radio_items(); +} + +/** Set the average skills of the current team + into the appropriate labels. */ +void +game_gui_write_av_skills(void) +{ + gchar buf[SMALL]; + GtkLabel *label_av_skills= GTK_LABEL(lookup_widget(window.main, "label_av_skills")); + + sprintf(buf, "%.1f %.1f", + team_get_average_skill(usr(current_user).tm, TRUE), + team_get_average_skill(usr(current_user).tm, FALSE)); + gtk_label_set_text(label_av_skills, buf); +} + +/** Activate the appropriate radio items for + playing style etc. according to the user settings. */ +void +game_gui_write_radio_items(void) +{ + GtkCheckMenuItem *boost = GTK_CHECK_MENU_ITEM(lookup_widget(window.main, "menu_boost")); + GtkWidget *style[5], *scout[4], *physio[4]; + + game_gui_get_radio_items(style, scout, physio); + + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(style[usr(current_user).tm->style + 2]), TRUE); + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(scout[usr(current_user).scout]), TRUE); + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(physio[usr(current_user).physio]), TRUE); + gtk_check_menu_item_set_active(boost, opt_user_int("int_opt_user_boost")); +} + +/** Set playing style etc. variables according to + the items. + @param widget The widget that received a click. */ +void +game_gui_read_radio_items(GtkWidget *widget) +{ + gint i; + GtkWidget *boost = lookup_widget(window.main, "menu_boost"); + GtkWidget *style[5], *scout[4], *physio[4]; + gint old_scout = usr(current_user).scout, + old_physio = usr(current_user).physio; + + game_gui_get_radio_items(style, scout, physio); + + if(widget == boost) + opt_user_set_int("int_opt_user_boost", + !opt_user_int("int_opt_user_boost")); + + for(i=0;i<5;i++) + if(widget == style[i]) + usr(current_user).tm->style = i - 2; + + for(i=0;i<4;i++) + if(widget == scout[i]) + usr(current_user).scout = 100 + i * 10 + old_scout % 10; + + for(i=0;i<4;i++) + if(widget == physio[i]) + usr(current_user).physio = 100 + i * 10 + old_physio % 10; + + if(math_get_place(usr(current_user).scout, 2) == old_scout % 10) + usr(current_user).scout = old_scout % 10; + + if(math_get_place(usr(current_user).physio, 2) == old_physio % 10) + usr(current_user).physio = old_physio % 10; + + if(old_scout != usr(current_user).scout || + old_physio != usr(current_user).physio) + game_gui_print_message(_("Next week you'll fire him and hire a new one.")); +} + +/** Show the main menu. */ +void +game_gui_show_main(void) +{ + game_gui_set_main_window_header(); + treeview_show_user_player_list(&usr(current_user), 1); + treeview_show_user_player_list(&usr(current_user), 2); +} + +/** Print a message into the main window entry. */ +void +game_gui_print_message(gchar *text) +{ + gtk_entry_set_text(GTK_ENTRY(lookup_widget(window.main, "entry_message")), text); + + g_timeout_add(const_int("int_game_gui_message_duration") * 1000, + (GSourceFunc)game_gui_clear_entry_message, NULL); +} + +/** Function that gets called from time to time. */ +gboolean +game_gui_clear_entry_message(gpointer data) +{ + gtk_entry_set_text(GTK_ENTRY(lookup_widget(window.main, "entry_message")), ""); + + return FALSE; +} + +/** Which parts of the main window get affected + by a live game pause. */ +enum MainWindowInensitiveItems +{ + INSENSITIVE_ITEM_TOOLBAR = 0, + INSENSITIVE_ITEM_PLAYER_LIST2, + INSENSITIVE_ITEM_MENU_FILE, + INSENSITIVE_ITEM_MENU_OPTIONS, + INSENSITIVE_ITEM_MENU_FIGURES, + INSENSITIVE_ITEM_MENU_SCOUT, + INSENSITIVE_ITEM_MENU_PHYSIO, + INSENSITIVE_ITEM_MENU_BROWSE_TEAMS, + INSENSITIVE_ITEM_MENU_PUT_ON_TRANSFER_LIST, + INSENSITIVE_ITEM_MENU_REMOVE_FROM_TRANSFER_LIST, + INSENSITIVE_ITEM_MENU_FIRE, + INSENSITIVE_ITEM_MENU_MANAGE_USERS, + INSENSITIVE_ITEM_MENU_FINANCES_STADIUM, + INSENSITIVE_ITEM_MENU_HELP, + INSENSITIVE_ITEM_END +}; + +/** Set appropriate parts of the main window insensitive when + the live game is paused or resumed. + @param value Whether we set sensitive or insensitive. */ +void +game_gui_set_main_window_sensitivity(gboolean value) +{ + gint i; + GtkWidget *insensitive_items[INSENSITIVE_ITEM_END]; + + insensitive_items[INSENSITIVE_ITEM_TOOLBAR] = + lookup_widget(window.main, "hbox1"); + insensitive_items[INSENSITIVE_ITEM_PLAYER_LIST2] = + lookup_widget(window.main, "vbox8"); + insensitive_items[INSENSITIVE_ITEM_MENU_FILE] = + lookup_widget(window.main, "menu_file"); + insensitive_items[INSENSITIVE_ITEM_MENU_OPTIONS] = + lookup_widget(window.main, "menu_options"); + insensitive_items[INSENSITIVE_ITEM_MENU_FIGURES] = + lookup_widget(window.main, "menu_figures"); + insensitive_items[INSENSITIVE_ITEM_MENU_SCOUT] = + lookup_widget(window.main, "menu_scout"); + insensitive_items[INSENSITIVE_ITEM_MENU_PHYSIO] = + lookup_widget(window.main, "menu_physio"); + insensitive_items[INSENSITIVE_ITEM_MENU_BROWSE_TEAMS] = + lookup_widget(window.main, "menu_browse_teams"); + insensitive_items[INSENSITIVE_ITEM_MENU_PUT_ON_TRANSFER_LIST] = + lookup_widget(window.main, "menu_put_on_transfer_list"); + insensitive_items[INSENSITIVE_ITEM_MENU_REMOVE_FROM_TRANSFER_LIST] = + lookup_widget(window.main, "menu_remove_from_transfer_list"); + insensitive_items[INSENSITIVE_ITEM_MENU_FIRE] = + lookup_widget(window.main, "menu_fire"); + insensitive_items[INSENSITIVE_ITEM_MENU_MANAGE_USERS] = + lookup_widget(window.main, "menu_manage_users"); + insensitive_items[INSENSITIVE_ITEM_MENU_FINANCES_STADIUM] = + lookup_widget(window.main, "menu_finances_stadium"); + insensitive_items[INSENSITIVE_ITEM_MENU_HELP] = + lookup_widget(window.main, "menu_help"); + + for(i=0;i 1000) + misc_print_grouped_int(number, buf, FALSE); + else + sprintf(buf, "%d", number); + + if(!append) + sprintf(buf2, "%s", buf); + else + sprintf(buf2, "%s%s", current_text, buf); + + gtk_label_set_text(label, buf2); +} + +/* Set into or append an integer into a label. + @param label The label. + @param number The number. + @param append Whether or not to append. + @param precision Float precision to use. */ +void +gui_label_set_text_from_float(GtkLabel *label, gfloat number, + gboolean append, gint precision) +{ + const gchar *current_text = gtk_label_get_text(label); + gchar buf[SMALL]; + + strcpy(buf, ""); + + if(!append) + sprintf(buf, "%.*f", precision, number); + else + sprintf(buf, "%s%.*f", current_text, precision, number); + + gtk_label_set_text(label, buf); +} + diff --git a/src/gui.h b/src/gui.h index 8a84cc28..af563e64 100644 --- a/src/gui.h +++ b/src/gui.h @@ -3,13 +3,11 @@ #include "bygfoot.h" -/** Possible values for the status variable. */ -enum StatusValue -{ - STATUS_NONE = 0, - STATUS_MAIN, - STATUS_BROWSE_TEAMS, - STATUS_END -}; +void +gui_label_set_text_from_int(GtkLabel *label, gint number, gboolean append); + +void +gui_label_set_text_from_float(GtkLabel *label, gfloat number, + gboolean append, gint precision); #endif diff --git a/src/interface.c b/src/interface.c index 725c745d..4a6252ca 100644 --- a/src/interface.c +++ b/src/interface.c @@ -33,8 +33,8 @@ create_main_window (void) GdkPixbuf *main_window_icon_pixbuf; GtkWidget *vbox1; GtkWidget *menubar1; - GtkWidget *menuitem1; - GtkWidget *menuitem1_menu; + GtkWidget *menu_file; + GtkWidget *menu_file_menu; GtkWidget *menu_new; GtkWidget *menu_open; GtkWidget *menu_save; @@ -42,15 +42,15 @@ create_main_window (void) GtkWidget *trennlinie1; GtkWidget *separatormenuitem1; GtkWidget *start_editor; - GtkWidget *image142; + GtkWidget *image174; GtkWidget *start_update; - GtkWidget *image143; + GtkWidget *image175; GtkWidget *trennlinie2; GtkWidget *menu_quit; - GtkWidget *options1; - GtkWidget *options1_menu; + GtkWidget *menu_options; + GtkWidget *menu_options_menu; GtkWidget *menu_preferences; - GtkWidget *image144; + GtkWidget *image176; GtkWidget *trennlinie7; GtkWidget *menu_notify; GtkWidget *menu_job_offers; @@ -60,25 +60,9 @@ create_main_window (void) GtkWidget *menu_figures_menu; GtkWidget *menu_fixtures; GtkWidget *menu_my_league_results; - GtkWidget *more_fixtures1; - GtkWidget *more_fixtures1_menu; - GtkWidget *menu_league1; - GtkWidget *menu_league2; - GtkWidget *menu_league3; - GtkWidget *menu_league4; - GtkWidget *menu_league5; - GtkWidget *menu_league6; - GtkWidget *trennlinie9; - GtkWidget *menu_cup_1; - GtkWidget *menu_cup2; - GtkWidget *menu_cup3; - GtkWidget *menu_cup4; - GtkWidget *menu_cup5; - GtkWidget *menu_cup6; GtkWidget *menu_tables; GtkWidget *players1; GtkWidget *menu_season_history; - GtkWidget *menu_team_history; GtkWidget *menu_team; GtkWidget *menu_team_menu; GtkWidget *menu_playing_style; @@ -104,23 +88,32 @@ create_main_window (void) GtkWidget *menu_physio_average; GtkWidget *menu_physio_bad; GtkWidget *menu_boost; + GtkWidget *menu_custom_structure; + GtkWidget *trennlinie8; GtkWidget *menu_browse_teams; GtkWidget *menu_player; GtkWidget *menu_player_menu; GtkWidget *menu_show_info; - GtkWidget *menu_show_history; GtkWidget *menu_put_on_transfer_list; GtkWidget *menu_remove_from_transfer_list; GtkWidget *menu_fire; GtkWidget *menu_shoots_penalties; + GtkWidget *menu_user; + GtkWidget *menu_user_menu; + GtkWidget *menu_next_user; + GtkWidget *image177; + GtkWidget *menu_previous_user; + GtkWidget *image178; + GtkWidget *menu_manage_users; + GtkWidget *image179; GtkWidget *menu_finances_stadium; GtkWidget *menu_finances_stadium_menu; GtkWidget *menu_increase_capacity; GtkWidget *menu_increase_safety; GtkWidget *menu_get_loan; GtkWidget *menu_pay_loan; - GtkWidget *menuitem4; - GtkWidget *menuitem4_menu; + GtkWidget *menu_help; + GtkWidget *menu_help_menu; GtkWidget *menu_about; GtkWidget *team_editor_help1; GtkWidget *hbox1; @@ -145,14 +138,17 @@ create_main_window (void) GtkWidget *image23; GtkWidget *button_help; GtkWidget *image39; - GtkWidget *message_window; + GtkWidget *entry_message; GtkWidget *hseparator1; GtkWidget *eventbox_main_info; GtkWidget *hbox18; + GtkWidget *label_user; GtkWidget *label23; GtkWidget *label_season; GtkWidget *label25; GtkWidget *label_week; + GtkWidget *label13114; + GtkWidget *label_round; GtkWidget *vseparator14; GtkWidget *hbox48; GtkWidget *eventbox_team_name; @@ -169,7 +165,7 @@ create_main_window (void) GtkWidget *eventbox1; GtkWidget *hbox50; GtkWidget *label69; - GtkWidget *label_av_skill; + GtkWidget *label_av_skills; GtkWidget *hbox7; GtkWidget *hpaned2; GtkWidget *vbox3; @@ -184,8 +180,6 @@ create_main_window (void) GtkWidget *hbox_14; GtkWidget *vbox14; GtkWidget *label31; - GtkWidget *button_browse; - GtkWidget *image17; GtkWidget *hbox15; GtkWidget *vbox15; GtkWidget *label33; @@ -195,31 +189,11 @@ create_main_window (void) GtkWidget *label32; GtkWidget *button_browse_back; GtkWidget *image10; - GtkWidget *vbox5; - GtkWidget *label15; - GtkWidget *hbox11; - GtkWidget *entry_structure; - GtkWidget *button_structure; - GtkWidget *image16; - GtkWidget *button_rearrange; - GtkWidget *image15; - GtkWidget *button_undo; - GtkWidget *image53; GtkWidget *hbox41; GtkWidget *vbox33; GtkWidget *label66; - GtkWidget *button_fixtures; - GtkWidget *alignment13; - GtkWidget *hbox43; - GtkWidget *image42; - GtkWidget *label68; GtkWidget *vbox29; GtkWidget *label62; - GtkWidget *button_tables; - GtkWidget *alignment12; - GtkWidget *hbox42; - GtkWidget *image41; - GtkWidget *label67; GtkWidget *vbox34; GtkWidget *label70; GtkWidget *scrolledwindow3; @@ -250,99 +224,99 @@ create_main_window (void) gtk_widget_show (menubar1); gtk_box_pack_start (GTK_BOX (vbox1), menubar1, FALSE, FALSE, 0); - menuitem1 = gtk_menu_item_new_with_mnemonic (_("_File")); - gtk_widget_show (menuitem1); - gtk_container_add (GTK_CONTAINER (menubar1), menuitem1); + menu_file = gtk_menu_item_new_with_mnemonic (_("_File")); + gtk_widget_show (menu_file); + gtk_container_add (GTK_CONTAINER (menubar1), menu_file); - menuitem1_menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem1), menuitem1_menu); + menu_file_menu = gtk_menu_new (); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_file), menu_file_menu); menu_new = gtk_image_menu_item_new_from_stock ("gtk-new", accel_group); gtk_widget_show (menu_new); - gtk_container_add (GTK_CONTAINER (menuitem1_menu), menu_new); + gtk_container_add (GTK_CONTAINER (menu_file_menu), menu_new); menu_open = gtk_image_menu_item_new_from_stock ("gtk-open", accel_group); gtk_widget_show (menu_open); - gtk_container_add (GTK_CONTAINER (menuitem1_menu), menu_open); + gtk_container_add (GTK_CONTAINER (menu_file_menu), menu_open); menu_save = gtk_image_menu_item_new_from_stock ("gtk-save", accel_group); gtk_widget_show (menu_save); - gtk_container_add (GTK_CONTAINER (menuitem1_menu), menu_save); + gtk_container_add (GTK_CONTAINER (menu_file_menu), menu_save); menu_save_as = gtk_image_menu_item_new_from_stock ("gtk-save-as", accel_group); gtk_widget_show (menu_save_as); - gtk_container_add (GTK_CONTAINER (menuitem1_menu), menu_save_as); + gtk_container_add (GTK_CONTAINER (menu_file_menu), menu_save_as); - trennlinie1 = gtk_menu_item_new (); + trennlinie1 = gtk_separator_menu_item_new (); gtk_widget_show (trennlinie1); - gtk_container_add (GTK_CONTAINER (menuitem1_menu), trennlinie1); + gtk_container_add (GTK_CONTAINER (menu_file_menu), trennlinie1); gtk_widget_set_sensitive (trennlinie1, FALSE); - separatormenuitem1 = gtk_menu_item_new (); + separatormenuitem1 = gtk_separator_menu_item_new (); gtk_widget_show (separatormenuitem1); - gtk_container_add (GTK_CONTAINER (menuitem1_menu), separatormenuitem1); + gtk_container_add (GTK_CONTAINER (menu_file_menu), separatormenuitem1); gtk_widget_set_sensitive (separatormenuitem1, FALSE); start_editor = gtk_image_menu_item_new_with_mnemonic (_("Start Bygfoot Team Editor")); gtk_widget_show (start_editor); - gtk_container_add (GTK_CONTAINER (menuitem1_menu), start_editor); + gtk_container_add (GTK_CONTAINER (menu_file_menu), start_editor); - image142 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU); - gtk_widget_show (image142); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (start_editor), image142); + image174 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU); + gtk_widget_show (image174); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (start_editor), image174); start_update = gtk_image_menu_item_new_with_mnemonic (_("Start Bygfoot Online Update")); gtk_widget_show (start_update); - gtk_container_add (GTK_CONTAINER (menuitem1_menu), start_update); + gtk_container_add (GTK_CONTAINER (menu_file_menu), start_update); - image143 = gtk_image_new_from_stock ("gtk-refresh", GTK_ICON_SIZE_MENU); - gtk_widget_show (image143); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (start_update), image143); + image175 = gtk_image_new_from_stock ("gtk-refresh", GTK_ICON_SIZE_MENU); + gtk_widget_show (image175); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (start_update), image175); - trennlinie2 = gtk_menu_item_new (); + trennlinie2 = gtk_separator_menu_item_new (); gtk_widget_show (trennlinie2); - gtk_container_add (GTK_CONTAINER (menuitem1_menu), trennlinie2); + gtk_container_add (GTK_CONTAINER (menu_file_menu), trennlinie2); gtk_widget_set_sensitive (trennlinie2, FALSE); menu_quit = gtk_image_menu_item_new_from_stock ("gtk-quit", accel_group); gtk_widget_show (menu_quit); - gtk_container_add (GTK_CONTAINER (menuitem1_menu), menu_quit); + gtk_container_add (GTK_CONTAINER (menu_file_menu), menu_quit); - options1 = gtk_menu_item_new_with_mnemonic (_("Options")); - gtk_widget_show (options1); - gtk_container_add (GTK_CONTAINER (menubar1), options1); + menu_options = gtk_menu_item_new_with_mnemonic (_("Options")); + gtk_widget_show (menu_options); + gtk_container_add (GTK_CONTAINER (menubar1), menu_options); - options1_menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (options1), options1_menu); + menu_options_menu = gtk_menu_new (); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_options), menu_options_menu); menu_preferences = gtk_image_menu_item_new_with_mnemonic (_("Preferences")); gtk_widget_show (menu_preferences); - gtk_container_add (GTK_CONTAINER (options1_menu), menu_preferences); + gtk_container_add (GTK_CONTAINER (menu_options_menu), menu_preferences); - image144 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU); - gtk_widget_show (image144); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_preferences), image144); + image176 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_MENU); + gtk_widget_show (image176); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_preferences), image176); - trennlinie7 = gtk_menu_item_new (); + trennlinie7 = gtk_separator_menu_item_new (); gtk_widget_show (trennlinie7); - gtk_container_add (GTK_CONTAINER (options1_menu), trennlinie7); + gtk_container_add (GTK_CONTAINER (menu_options_menu), trennlinie7); gtk_widget_set_sensitive (trennlinie7, FALSE); menu_notify = gtk_check_menu_item_new_with_mnemonic (_("Notify")); gtk_widget_show (menu_notify); - gtk_container_add (GTK_CONTAINER (options1_menu), menu_notify); + gtk_container_add (GTK_CONTAINER (menu_options_menu), menu_notify); menu_job_offers = gtk_check_menu_item_new_with_mnemonic (_("Job offers")); gtk_widget_show (menu_job_offers); - gtk_container_add (GTK_CONTAINER (options1_menu), menu_job_offers); + gtk_container_add (GTK_CONTAINER (menu_options_menu), menu_job_offers); menu_live_game = gtk_check_menu_item_new_with_mnemonic (_("Live game")); gtk_widget_show (menu_live_game); - gtk_container_add (GTK_CONTAINER (options1_menu), menu_live_game); + gtk_container_add (GTK_CONTAINER (menu_options_menu), menu_live_game); menu_overwrite = gtk_check_menu_item_new_with_mnemonic (_("Overwrite")); gtk_widget_show (menu_overwrite); - gtk_container_add (GTK_CONTAINER (options1_menu), menu_overwrite); + gtk_container_add (GTK_CONTAINER (menu_options_menu), menu_overwrite); menu_figures = gtk_menu_item_new_with_mnemonic (_("Figures")); gtk_widget_show (menu_figures); @@ -359,66 +333,6 @@ create_main_window (void) gtk_widget_show (menu_my_league_results); gtk_container_add (GTK_CONTAINER (menu_figures_menu), menu_my_league_results); - more_fixtures1 = gtk_menu_item_new_with_mnemonic (_("More fixtures")); - gtk_widget_show (more_fixtures1); - gtk_container_add (GTK_CONTAINER (menu_figures_menu), more_fixtures1); - - more_fixtures1_menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (more_fixtures1), more_fixtures1_menu); - - menu_league1 = gtk_menu_item_new_with_mnemonic (_("League 1")); - gtk_widget_show (menu_league1); - gtk_container_add (GTK_CONTAINER (more_fixtures1_menu), menu_league1); - - menu_league2 = gtk_menu_item_new_with_mnemonic (_("League 2")); - gtk_widget_show (menu_league2); - gtk_container_add (GTK_CONTAINER (more_fixtures1_menu), menu_league2); - - menu_league3 = gtk_menu_item_new_with_mnemonic (_("League 3")); - gtk_widget_show (menu_league3); - gtk_container_add (GTK_CONTAINER (more_fixtures1_menu), menu_league3); - - menu_league4 = gtk_menu_item_new_with_mnemonic (_("League 4")); - gtk_widget_show (menu_league4); - gtk_container_add (GTK_CONTAINER (more_fixtures1_menu), menu_league4); - - menu_league5 = gtk_menu_item_new_with_mnemonic (_("League 5")); - gtk_widget_show (menu_league5); - gtk_container_add (GTK_CONTAINER (more_fixtures1_menu), menu_league5); - - menu_league6 = gtk_menu_item_new_with_mnemonic (_("League 6")); - gtk_widget_show (menu_league6); - gtk_container_add (GTK_CONTAINER (more_fixtures1_menu), menu_league6); - - trennlinie9 = gtk_menu_item_new (); - gtk_widget_show (trennlinie9); - gtk_container_add (GTK_CONTAINER (more_fixtures1_menu), trennlinie9); - gtk_widget_set_sensitive (trennlinie9, FALSE); - - menu_cup_1 = gtk_menu_item_new_with_mnemonic (_("Cup 1")); - gtk_widget_show (menu_cup_1); - gtk_container_add (GTK_CONTAINER (more_fixtures1_menu), menu_cup_1); - - menu_cup2 = gtk_menu_item_new_with_mnemonic (_("Cup 2")); - gtk_widget_show (menu_cup2); - gtk_container_add (GTK_CONTAINER (more_fixtures1_menu), menu_cup2); - - menu_cup3 = gtk_menu_item_new_with_mnemonic (_("Cup 3")); - gtk_widget_show (menu_cup3); - gtk_container_add (GTK_CONTAINER (more_fixtures1_menu), menu_cup3); - - menu_cup4 = gtk_menu_item_new_with_mnemonic (_("Cup 4")); - gtk_widget_show (menu_cup4); - gtk_container_add (GTK_CONTAINER (more_fixtures1_menu), menu_cup4); - - menu_cup5 = gtk_menu_item_new_with_mnemonic (_("Cup 5")); - gtk_widget_show (menu_cup5); - gtk_container_add (GTK_CONTAINER (more_fixtures1_menu), menu_cup5); - - menu_cup6 = gtk_menu_item_new_with_mnemonic (_("Cup 6")); - gtk_widget_show (menu_cup6); - gtk_container_add (GTK_CONTAINER (more_fixtures1_menu), menu_cup6); - menu_tables = gtk_menu_item_new_with_mnemonic (_("Tables")); gtk_widget_show (menu_tables); gtk_container_add (GTK_CONTAINER (menu_figures_menu), menu_tables); @@ -431,10 +345,6 @@ create_main_window (void) gtk_widget_show (menu_season_history); gtk_container_add (GTK_CONTAINER (menu_figures_menu), menu_season_history); - menu_team_history = gtk_menu_item_new_with_mnemonic (_("Team history")); - gtk_widget_show (menu_team_history); - gtk_container_add (GTK_CONTAINER (menu_figures_menu), menu_team_history); - menu_team = gtk_menu_item_new_with_mnemonic (_("Team")); gtk_widget_show (menu_team); gtk_container_add (GTK_CONTAINER (menubar1), menu_team); @@ -545,6 +455,15 @@ create_main_window (void) gtk_widget_show (menu_boost); gtk_container_add (GTK_CONTAINER (menu_team_menu), menu_boost); + menu_custom_structure = gtk_menu_item_new_with_mnemonic (_("Enter custom structure")); + gtk_widget_show (menu_custom_structure); + gtk_container_add (GTK_CONTAINER (menu_team_menu), menu_custom_structure); + + trennlinie8 = gtk_separator_menu_item_new (); + gtk_widget_show (trennlinie8); + gtk_container_add (GTK_CONTAINER (menu_team_menu), trennlinie8); + gtk_widget_set_sensitive (trennlinie8, FALSE); + menu_browse_teams = gtk_menu_item_new_with_mnemonic (_("Browse teams")); gtk_widget_show (menu_browse_teams); gtk_container_add (GTK_CONTAINER (menu_team_menu), menu_browse_teams); @@ -560,10 +479,6 @@ create_main_window (void) gtk_widget_show (menu_show_info); gtk_container_add (GTK_CONTAINER (menu_player_menu), menu_show_info); - menu_show_history = gtk_menu_item_new_with_mnemonic (_("Show history")); - gtk_widget_show (menu_show_history); - gtk_container_add (GTK_CONTAINER (menu_player_menu), menu_show_history); - menu_put_on_transfer_list = gtk_menu_item_new_with_mnemonic (_("Put on transfer list")); gtk_widget_show (menu_put_on_transfer_list); gtk_container_add (GTK_CONTAINER (menu_player_menu), menu_put_on_transfer_list); @@ -580,6 +495,46 @@ create_main_window (void) gtk_widget_show (menu_shoots_penalties); gtk_container_add (GTK_CONTAINER (menu_player_menu), menu_shoots_penalties); + menu_user = gtk_menu_item_new_with_mnemonic (_("User")); + gtk_widget_show (menu_user); + gtk_container_add (GTK_CONTAINER (menubar1), menu_user); + + menu_user_menu = gtk_menu_new (); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_user), menu_user_menu); + + menu_next_user = gtk_image_menu_item_new_with_mnemonic (_("Next user")); + gtk_widget_show (menu_next_user); + gtk_container_add (GTK_CONTAINER (menu_user_menu), menu_next_user); + gtk_widget_add_accelerator (menu_next_user, "activate", accel_group, + GDK_F9, 0, + GTK_ACCEL_VISIBLE); + + image177 = gtk_image_new_from_stock ("gtk-go-forward", GTK_ICON_SIZE_MENU); + gtk_widget_show (image177); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_next_user), image177); + + menu_previous_user = gtk_image_menu_item_new_with_mnemonic (_("Previous user")); + gtk_widget_show (menu_previous_user); + gtk_container_add (GTK_CONTAINER (menu_user_menu), menu_previous_user); + gtk_widget_add_accelerator (menu_previous_user, "activate", accel_group, + GDK_F8, 0, + GTK_ACCEL_VISIBLE); + + image178 = gtk_image_new_from_stock ("gtk-go-back", GTK_ICON_SIZE_MENU); + gtk_widget_show (image178); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_previous_user), image178); + + menu_manage_users = gtk_image_menu_item_new_with_mnemonic (_("Manage users")); + gtk_widget_show (menu_manage_users); + gtk_container_add (GTK_CONTAINER (menu_user_menu), menu_manage_users); + gtk_widget_add_accelerator (menu_manage_users, "activate", accel_group, + GDK_F12, 0, + GTK_ACCEL_VISIBLE); + + image179 = gtk_image_new_from_stock ("gtk-justify-fill", GTK_ICON_SIZE_MENU); + gtk_widget_show (image179); + gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_manage_users), image179); + menu_finances_stadium = gtk_menu_item_new_with_mnemonic (_("FinStad")); gtk_widget_show (menu_finances_stadium); gtk_container_add (GTK_CONTAINER (menubar1), menu_finances_stadium); @@ -603,20 +558,20 @@ create_main_window (void) gtk_widget_show (menu_pay_loan); gtk_container_add (GTK_CONTAINER (menu_finances_stadium_menu), menu_pay_loan); - menuitem4 = gtk_menu_item_new_with_mnemonic (_("_Help")); - gtk_widget_show (menuitem4); - gtk_container_add (GTK_CONTAINER (menubar1), menuitem4); + menu_help = gtk_menu_item_new_with_mnemonic (_("_Help")); + gtk_widget_show (menu_help); + gtk_container_add (GTK_CONTAINER (menubar1), menu_help); - menuitem4_menu = gtk_menu_new (); - gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem4), menuitem4_menu); + menu_help_menu = gtk_menu_new (); + gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu_help), menu_help_menu); menu_about = gtk_image_menu_item_new_from_stock ("gtk-dialog-info", accel_group); gtk_widget_show (menu_about); - gtk_container_add (GTK_CONTAINER (menuitem4_menu), menu_about); + gtk_container_add (GTK_CONTAINER (menu_help_menu), menu_about); team_editor_help1 = gtk_menu_item_new_with_mnemonic (_("Team Editor Help")); gtk_widget_show (team_editor_help1); - gtk_container_add (GTK_CONTAINER (menuitem4_menu), team_editor_help1); + gtk_container_add (GTK_CONTAINER (menu_help_menu), team_editor_help1); hbox1 = gtk_hbox_new (FALSE, 0); gtk_widget_show (hbox1); @@ -757,10 +712,10 @@ create_main_window (void) gtk_widget_show (image39); gtk_container_add (GTK_CONTAINER (button_help), image39); - message_window = gtk_entry_new (); - gtk_widget_show (message_window); - gtk_box_pack_start (GTK_BOX (hbox1), message_window, TRUE, TRUE, 5); - gtk_editable_set_editable (GTK_EDITABLE (message_window), FALSE); + entry_message = gtk_entry_new (); + gtk_widget_show (entry_message); + gtk_box_pack_start (GTK_BOX (hbox1), entry_message, TRUE, TRUE, 5); + gtk_editable_set_editable (GTK_EDITABLE (entry_message), FALSE); hseparator1 = gtk_hseparator_new (); gtk_widget_show (hseparator1); @@ -775,27 +730,35 @@ create_main_window (void) gtk_widget_show (hbox18); gtk_container_add (GTK_CONTAINER (eventbox_main_info), hbox18); - label23 = gtk_label_new (_("Season ")); + label_user = gtk_label_new (_("user")); + gtk_widget_show (label_user); + gtk_box_pack_start (GTK_BOX (hbox18), label_user, FALSE, FALSE, 0); + + label23 = gtk_label_new (_(" Season ")); gtk_widget_show (label23); gtk_box_pack_start (GTK_BOX (hbox18), label23, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label23), GTK_JUSTIFY_LEFT); gtk_misc_set_padding (GTK_MISC (label23), 5, 0); label_season = gtk_label_new (_("1")); gtk_widget_show (label_season); gtk_box_pack_start (GTK_BOX (hbox18), label_season, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label_season), GTK_JUSTIFY_LEFT); label25 = gtk_label_new (_(" Week ")); gtk_widget_show (label25); gtk_box_pack_start (GTK_BOX (hbox18), label25, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label25), GTK_JUSTIFY_LEFT); gtk_misc_set_padding (GTK_MISC (label25), 5, 0); label_week = gtk_label_new (_("1")); gtk_widget_show (label_week); gtk_box_pack_start (GTK_BOX (hbox18), label_week, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label_week), GTK_JUSTIFY_LEFT); + + label13114 = gtk_label_new (_(" Round ")); + gtk_widget_show (label13114); + gtk_box_pack_start (GTK_BOX (hbox18), label13114, FALSE, FALSE, 0); + + label_round = gtk_label_new (_("1")); + gtk_widget_show (label_round); + gtk_box_pack_start (GTK_BOX (hbox18), label_round, FALSE, FALSE, 0); vseparator14 = gtk_vseparator_new (); gtk_widget_show (vseparator14); @@ -813,13 +776,11 @@ create_main_window (void) label_team = gtk_label_new (_("Arsenal")); gtk_widget_show (label_team); gtk_container_add (GTK_CONTAINER (eventbox_team_name), label_team); - gtk_label_set_justify (GTK_LABEL (label_team), GTK_JUSTIFY_LEFT); gtk_misc_set_padding (GTK_MISC (label_team), 5, 0); label_league = gtk_label_new (_("Premier Division")); gtk_widget_show (label_league); gtk_box_pack_start (GTK_BOX (hbox18), label_league, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label_league), GTK_JUSTIFY_LEFT); gtk_misc_set_padding (GTK_MISC (label_league), 5, 0); eventbox_rank = gtk_event_box_new (); @@ -833,13 +794,11 @@ create_main_window (void) label29 = gtk_label_new (_("Rank ")); gtk_widget_show (label29); gtk_box_pack_start (GTK_BOX (hbox49), label29, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label29), GTK_JUSTIFY_LEFT); gtk_misc_set_padding (GTK_MISC (label29), 5, 0); label_rank = gtk_label_new (_("1")); gtk_widget_show (label_rank); gtk_box_pack_start (GTK_BOX (hbox49), label_rank, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label_rank), GTK_JUSTIFY_LEFT); vseparator15 = gtk_vseparator_new (); gtk_widget_show (vseparator15); @@ -849,13 +808,11 @@ create_main_window (void) label34 = gtk_label_new (_("Money ")); gtk_widget_show (label34); gtk_box_pack_start (GTK_BOX (hbox18), label34, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label34), GTK_JUSTIFY_LEFT); gtk_misc_set_padding (GTK_MISC (label34), 5, 0); label_money = gtk_label_new (_("2000")); gtk_widget_show (label_money); gtk_box_pack_start (GTK_BOX (hbox18), label_money, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label_money), GTK_JUSTIFY_LEFT); vseparator17 = gtk_vseparator_new (); gtk_widget_show (vseparator17); @@ -874,13 +831,11 @@ create_main_window (void) label69 = gtk_label_new (_("Av. skills: ")); gtk_widget_show (label69); gtk_box_pack_start (GTK_BOX (hbox50), label69, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label69), GTK_JUSTIFY_LEFT); - label_av_skill = gtk_label_new (_("label70")); - gtk_widget_show (label_av_skill); - gtk_box_pack_start (GTK_BOX (hbox50), label_av_skill, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label_av_skill), GTK_JUSTIFY_LEFT); - gtk_misc_set_padding (GTK_MISC (label_av_skill), 5, 0); + label_av_skills = gtk_label_new (_("label70")); + gtk_widget_show (label_av_skills); + gtk_box_pack_start (GTK_BOX (hbox50), label_av_skills, FALSE, FALSE, 0); + gtk_misc_set_padding (GTK_MISC (label_av_skills), 5, 0); hbox7 = gtk_hbox_new (FALSE, 0); gtk_widget_show (hbox7); @@ -918,7 +873,6 @@ create_main_window (void) label71 = gtk_label_new (_("Player list 1")); gtk_widget_show (label71); gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook_player), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook_player), 0), label71); - gtk_label_set_justify (GTK_LABEL (label71), GTK_JUSTIFY_LEFT); player_list2 = gtk_tree_view_new (); gtk_widget_show (player_list2); @@ -927,7 +881,6 @@ create_main_window (void) label72 = gtk_label_new (_("Player list 2")); gtk_widget_show (label72); gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook_player), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook_player), 1), label72); - gtk_label_set_justify (GTK_LABEL (label72), GTK_JUSTIFY_LEFT); vbox8 = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox8); @@ -944,16 +897,6 @@ create_main_window (void) label31 = gtk_label_new (_(" ")); gtk_widget_show (label31); gtk_box_pack_start (GTK_BOX (vbox14), label31, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label31), GTK_JUSTIFY_LEFT); - - button_browse = gtk_button_new (); - gtk_box_pack_start (GTK_BOX (vbox14), button_browse, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (button_browse), 2); - gtk_tooltips_set_tip (tooltips, button_browse, _("Browse teams to find and buy new players"), NULL); - - image17 = gtk_image_new_from_stock ("gtk-find", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image17); - gtk_container_add (GTK_CONTAINER (button_browse), image17); hbox15 = gtk_hbox_new (FALSE, 0); gtk_widget_show (hbox15); @@ -966,7 +909,6 @@ create_main_window (void) label33 = gtk_label_new (_(" ")); gtk_widget_show (label33); gtk_box_pack_start (GTK_BOX (vbox15), label33, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label33), GTK_JUSTIFY_LEFT); button_browse_forward = gtk_button_new (); gtk_widget_show (button_browse_forward); @@ -988,7 +930,6 @@ create_main_window (void) label32 = gtk_label_new (_(" ")); gtk_widget_show (label32); gtk_box_pack_start (GTK_BOX (vbox16), label32, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label32), GTK_JUSTIFY_LEFT); button_browse_back = gtk_button_new (); gtk_widget_show (button_browse_back); @@ -1000,69 +941,6 @@ create_main_window (void) gtk_widget_show (image10); gtk_container_add (GTK_CONTAINER (button_browse_back), image10); - vbox5 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox5); - gtk_box_pack_start (GTK_BOX (hbox_14), vbox5, TRUE, TRUE, 0); - - label15 = gtk_label_new (_("Team Structure")); - gtk_widget_show (label15); - gtk_box_pack_start (GTK_BOX (vbox5), label15, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label15), GTK_JUSTIFY_LEFT); - gtk_misc_set_padding (GTK_MISC (label15), 0, 4); - - hbox11 = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox11); - gtk_box_pack_start (GTK_BOX (vbox5), hbox11, TRUE, TRUE, 0); - - entry_structure = gtk_entry_new (); - gtk_widget_show (entry_structure); - gtk_box_pack_start (GTK_BOX (hbox11), entry_structure, FALSE, FALSE, 3); - gtk_tooltips_set_tip (tooltips, entry_structure, _("Here you can enter a custom structure like 334 (or 019, for that matter)"), NULL); - gtk_entry_set_max_length (GTK_ENTRY (entry_structure), 4); - gtk_entry_set_width_chars (GTK_ENTRY (entry_structure), 4); - - button_structure = gtk_button_new (); - gtk_widget_show (button_structure); - gtk_box_pack_start (GTK_BOX (hbox11), button_structure, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (button_structure), 2); - gtk_tooltips_set_tip (tooltips, button_structure, _("Change or update team structure (C) You can enter custom structures like 334, too."), NULL); - gtk_widget_add_accelerator (button_structure, "clicked", accel_group, - GDK_c, 0, - GTK_ACCEL_VISIBLE); - - image16 = gtk_image_new_from_stock ("gtk-refresh", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image16); - gtk_container_add (GTK_CONTAINER (button_structure), image16); - - button_rearrange = gtk_button_new (); - gtk_widget_show (button_rearrange); - gtk_box_pack_start (GTK_BOX (hbox11), button_rearrange, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (button_rearrange), 2); - gtk_tooltips_set_tip (tooltips, button_rearrange, _("Rearrange team (R) (try to put each player on his prefered position and sort the substitutes)"), NULL); - gtk_widget_add_accelerator (button_rearrange, "clicked", accel_group, - GDK_r, 0, - GTK_ACCEL_VISIBLE); - - image15 = gtk_image_new_from_stock ("gtk-sort-ascending", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image15); - gtk_container_add (GTK_CONTAINER (button_rearrange), image15); - - button_undo = gtk_button_new (); - gtk_widget_show (button_undo); - gtk_box_pack_start (GTK_BOX (hbox11), button_undo, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (button_undo), 2); - gtk_tooltips_set_tip (tooltips, button_undo, _("Undo! (Y / Ctrl-Z)"), NULL); - gtk_widget_add_accelerator (button_undo, "clicked", accel_group, - GDK_y, 0, - GTK_ACCEL_VISIBLE); - gtk_widget_add_accelerator (button_undo, "clicked", accel_group, - GDK_z, GDK_CONTROL_MASK, - GTK_ACCEL_VISIBLE); - - image53 = gtk_image_new_from_stock ("gtk-undo", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image53); - gtk_container_add (GTK_CONTAINER (button_undo), image53); - hbox41 = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox_14), hbox41, FALSE, TRUE, 0); @@ -1073,33 +951,6 @@ create_main_window (void) label66 = gtk_label_new (_(" ")); gtk_widget_show (label66); gtk_box_pack_start (GTK_BOX (vbox33), label66, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label66), GTK_JUSTIFY_LEFT); - - button_fixtures = gtk_button_new (); - gtk_widget_show (button_fixtures); - gtk_box_pack_start (GTK_BOX (vbox33), button_fixtures, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (button_fixtures), 2); - gtk_tooltips_set_tip (tooltips, button_fixtures, _("Show fixtures (F4)"), NULL); - gtk_widget_add_accelerator (button_fixtures, "clicked", accel_group, - GDK_F4, 0, - GTK_ACCEL_VISIBLE); - - alignment13 = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_show (alignment13); - gtk_container_add (GTK_CONTAINER (button_fixtures), alignment13); - - hbox43 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox43); - gtk_container_add (GTK_CONTAINER (alignment13), hbox43); - - image42 = create_pixmap (main_window, "preview.png"); - gtk_widget_show (image42); - gtk_box_pack_start (GTK_BOX (hbox43), image42, FALSE, FALSE, 0); - - label68 = gtk_label_new_with_mnemonic (_("Fixtures")); - gtk_widget_show (label68); - gtk_box_pack_start (GTK_BOX (hbox43), label68, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label68), GTK_JUSTIFY_LEFT); vbox29 = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox29); @@ -1108,33 +959,6 @@ create_main_window (void) label62 = gtk_label_new (_(" ")); gtk_widget_show (label62); gtk_box_pack_start (GTK_BOX (vbox29), label62, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label62), GTK_JUSTIFY_LEFT); - - button_tables = gtk_button_new (); - gtk_widget_show (button_tables); - gtk_box_pack_start (GTK_BOX (vbox29), button_tables, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (button_tables), 2); - gtk_tooltips_set_tip (tooltips, button_tables, _("Show tables (F5)"), NULL); - gtk_widget_add_accelerator (button_tables, "clicked", accel_group, - GDK_F5, 0, - GTK_ACCEL_VISIBLE); - - alignment12 = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_show (alignment12); - gtk_container_add (GTK_CONTAINER (button_tables), alignment12); - - hbox42 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox42); - gtk_container_add (GTK_CONTAINER (alignment12), hbox42); - - image41 = gtk_image_new_from_stock ("gtk-justify-left", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image41); - gtk_box_pack_start (GTK_BOX (hbox42), image41, FALSE, FALSE, 0); - - label67 = gtk_label_new_with_mnemonic (_("Tables")); - gtk_widget_show (label67); - gtk_box_pack_start (GTK_BOX (hbox42), label67, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label67), GTK_JUSTIFY_LEFT); vbox34 = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox34); @@ -1143,7 +967,6 @@ create_main_window (void) label70 = gtk_label_new (_(" ")); gtk_widget_show (label70); gtk_box_pack_start (GTK_BOX (vbox34), label70, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label70), GTK_JUSTIFY_LEFT); scrolledwindow3 = gtk_scrolled_window_new (NULL, NULL); gtk_widget_show (scrolledwindow3); @@ -1205,42 +1028,6 @@ create_main_window (void) g_signal_connect ((gpointer) menu_my_league_results, "activate", G_CALLBACK (on_menu_my_league_results_activate), NULL); - g_signal_connect ((gpointer) menu_league1, "activate", - G_CALLBACK (on_menu_league1_activate), - NULL); - g_signal_connect ((gpointer) menu_league2, "activate", - G_CALLBACK (on_menu_league2_activate), - NULL); - g_signal_connect ((gpointer) menu_league3, "activate", - G_CALLBACK (on_menu_league3_activate), - NULL); - g_signal_connect ((gpointer) menu_league4, "activate", - G_CALLBACK (on_menu_league4_activate), - NULL); - g_signal_connect ((gpointer) menu_league5, "activate", - G_CALLBACK (on_menu_league5_activate), - NULL); - g_signal_connect ((gpointer) menu_league6, "activate", - G_CALLBACK (on_menu_league6_activate), - NULL); - g_signal_connect ((gpointer) menu_cup_1, "activate", - G_CALLBACK (on_menu_cup_1_activate), - NULL); - g_signal_connect ((gpointer) menu_cup2, "activate", - G_CALLBACK (on_menu_cup2_activate), - NULL); - g_signal_connect ((gpointer) menu_cup3, "activate", - G_CALLBACK (on_menu_cup3_activate), - NULL); - g_signal_connect ((gpointer) menu_cup4, "activate", - G_CALLBACK (on_menu_cup4_activate), - NULL); - g_signal_connect ((gpointer) menu_cup5, "activate", - G_CALLBACK (on_menu_cup5_activate), - NULL); - g_signal_connect ((gpointer) menu_cup6, "activate", - G_CALLBACK (on_menu_cup6_activate), - NULL); g_signal_connect ((gpointer) menu_tables, "activate", G_CALLBACK (on_menu_tables_activate), NULL); @@ -1250,50 +1037,50 @@ create_main_window (void) g_signal_connect ((gpointer) menu_season_history, "activate", G_CALLBACK (on_menu_season_history_activate), NULL); - g_signal_connect ((gpointer) menu_team_history, "activate", - G_CALLBACK (on_menu_team_history_activate), + g_signal_connect ((gpointer) menu_all_out_defend, "button_press_event", + G_CALLBACK (on_menu_team_button_press_event), NULL); - g_signal_connect ((gpointer) menu_all_out_defend, "activate", - G_CALLBACK (on_menu_all_out_defend_activate), + g_signal_connect ((gpointer) menu_defend, "button_press_event", + G_CALLBACK (on_menu_team_button_press_event), NULL); - g_signal_connect ((gpointer) menu_defend, "activate", - G_CALLBACK (on_menu_defend_activate), + g_signal_connect ((gpointer) menu_balanced, "button_press_event", + G_CALLBACK (on_menu_team_button_press_event), NULL); - g_signal_connect ((gpointer) menu_balanced, "activate", - G_CALLBACK (on_menu_balanced_activate), + g_signal_connect ((gpointer) menu_attack, "button_press_event", + G_CALLBACK (on_menu_team_button_press_event), NULL); - g_signal_connect ((gpointer) menu_attack, "activate", - G_CALLBACK (on_menu_attack_activate), + g_signal_connect ((gpointer) menu_all_out_attack, "button_press_event", + G_CALLBACK (on_menu_team_button_press_event), NULL); - g_signal_connect ((gpointer) menu_all_out_attack, "activate", - G_CALLBACK (on_menu_all_out_attack_activate), + g_signal_connect ((gpointer) menu_scout_best, "button_press_event", + G_CALLBACK (on_menu_team_button_press_event), NULL); - g_signal_connect ((gpointer) menu_scout_best, "activate", - G_CALLBACK (on_menu_scout_best_activate), + g_signal_connect ((gpointer) menu_scout_good, "button_press_event", + G_CALLBACK (on_menu_team_button_press_event), NULL); - g_signal_connect ((gpointer) menu_scout_good, "activate", - G_CALLBACK (on_menu_scout_good_activate), + g_signal_connect ((gpointer) menu_scout_average, "button_press_event", + G_CALLBACK (on_menu_team_button_press_event), NULL); - g_signal_connect ((gpointer) menu_scout_average, "activate", - G_CALLBACK (on_menu_scout_average_activate), + g_signal_connect ((gpointer) menu_scout_bad, "button_press_event", + G_CALLBACK (on_menu_team_button_press_event), NULL); - g_signal_connect ((gpointer) menu_scout_bad, "activate", - G_CALLBACK (on_menu_scout_bad_activate), + g_signal_connect ((gpointer) menu_physio_best, "button_press_event", + G_CALLBACK (on_menu_team_button_press_event), NULL); - g_signal_connect ((gpointer) menu_physio_best, "activate", - G_CALLBACK (on_menu_physio_best_activate), + g_signal_connect ((gpointer) menu_physio_good, "button_press_event", + G_CALLBACK (on_menu_team_button_press_event), NULL); - g_signal_connect ((gpointer) menu_physio_good, "activate", - G_CALLBACK (on_menu_physio_good_activate), + g_signal_connect ((gpointer) menu_physio_average, "button_press_event", + G_CALLBACK (on_menu_team_button_press_event), NULL); - g_signal_connect ((gpointer) menu_physio_average, "activate", - G_CALLBACK (on_menu_physio_average_activate), + g_signal_connect ((gpointer) menu_physio_bad, "button_press_event", + G_CALLBACK (on_menu_team_button_press_event), NULL); - g_signal_connect ((gpointer) menu_physio_bad, "activate", - G_CALLBACK (on_menu_physio_bad_activate), + g_signal_connect ((gpointer) menu_boost, "button_press_event", + G_CALLBACK (on_menu_team_button_press_event), NULL); - g_signal_connect ((gpointer) menu_boost, "activate", - G_CALLBACK (on_menu_boost_activate), + g_signal_connect ((gpointer) menu_custom_structure, "activate", + G_CALLBACK (on_menu_custom_structure_activate), NULL); g_signal_connect ((gpointer) menu_browse_teams, "activate", G_CALLBACK (on_menu_browse_teams_activate), @@ -1304,9 +1091,6 @@ create_main_window (void) g_signal_connect ((gpointer) menu_show_info, "activate", G_CALLBACK (on_menu_show_info_activate), NULL); - g_signal_connect ((gpointer) menu_show_history, "activate", - G_CALLBACK (on_menu_show_history_activate), - NULL); g_signal_connect ((gpointer) menu_put_on_transfer_list, "activate", G_CALLBACK (on_menu_put_on_transfer_list_activate), NULL); @@ -1319,6 +1103,15 @@ create_main_window (void) g_signal_connect ((gpointer) menu_shoots_penalties, "activate", G_CALLBACK (on_menu_shoots_penalties_activate), NULL); + g_signal_connect ((gpointer) menu_next_user, "activate", + G_CALLBACK (on_menu_next_user_activate), + NULL); + g_signal_connect ((gpointer) menu_previous_user, "activate", + G_CALLBACK (on_menu_previous_user_activate), + NULL); + g_signal_connect ((gpointer) menu_manage_users, "activate", + G_CALLBACK (on_menu_manage_users_activate), + NULL); g_signal_connect ((gpointer) menu_finances_stadium, "activate", G_CALLBACK (on_menu_finances_stadium_activate), NULL); @@ -1368,38 +1161,17 @@ create_main_window (void) G_CALLBACK (on_button_help_clicked), NULL); g_signal_connect ((gpointer) player_list1, "button_press_event", - G_CALLBACK (on_player_list_button_press_event), + G_CALLBACK (on_player_list1_button_press_event), NULL); g_signal_connect ((gpointer) player_list2, "button_press_event", G_CALLBACK (on_player_list2_button_press_event), NULL); - g_signal_connect ((gpointer) button_browse, "clicked", - G_CALLBACK (on_button_browse_clicked), - NULL); g_signal_connect ((gpointer) button_browse_forward, "clicked", G_CALLBACK (on_button_browse_forward_clicked), NULL); g_signal_connect ((gpointer) button_browse_back, "clicked", G_CALLBACK (on_button_browse_back_clicked), NULL); - g_signal_connect ((gpointer) entry_structure, "activate", - G_CALLBACK (on_structure_entry_activate), - NULL); - g_signal_connect ((gpointer) button_structure, "clicked", - G_CALLBACK (on_structure_button_clicked), - NULL); - g_signal_connect ((gpointer) button_rearrange, "clicked", - G_CALLBACK (on_button_rearrange_clicked), - NULL); - g_signal_connect ((gpointer) button_undo, "clicked", - G_CALLBACK (on_button_undo_clicked), - NULL); - g_signal_connect ((gpointer) button_fixtures, "clicked", - G_CALLBACK (on_button_fixtures_clicked), - NULL); - g_signal_connect ((gpointer) button_tables, "clicked", - G_CALLBACK (on_button_tables_clicked), - NULL); g_signal_connect ((gpointer) treeview_right, "button_press_event", G_CALLBACK (on_treeview_right_button_press_event), NULL); @@ -1408,8 +1180,8 @@ create_main_window (void) GLADE_HOOKUP_OBJECT_NO_REF (main_window, main_window, "main_window"); GLADE_HOOKUP_OBJECT (main_window, vbox1, "vbox1"); GLADE_HOOKUP_OBJECT (main_window, menubar1, "menubar1"); - GLADE_HOOKUP_OBJECT (main_window, menuitem1, "menuitem1"); - GLADE_HOOKUP_OBJECT (main_window, menuitem1_menu, "menuitem1_menu"); + GLADE_HOOKUP_OBJECT (main_window, menu_file, "menu_file"); + GLADE_HOOKUP_OBJECT (main_window, menu_file_menu, "menu_file_menu"); GLADE_HOOKUP_OBJECT (main_window, menu_new, "menu_new"); GLADE_HOOKUP_OBJECT (main_window, menu_open, "menu_open"); GLADE_HOOKUP_OBJECT (main_window, menu_save, "menu_save"); @@ -1417,15 +1189,15 @@ create_main_window (void) GLADE_HOOKUP_OBJECT (main_window, trennlinie1, "trennlinie1"); GLADE_HOOKUP_OBJECT (main_window, separatormenuitem1, "separatormenuitem1"); GLADE_HOOKUP_OBJECT (main_window, start_editor, "start_editor"); - GLADE_HOOKUP_OBJECT (main_window, image142, "image142"); + GLADE_HOOKUP_OBJECT (main_window, image174, "image174"); GLADE_HOOKUP_OBJECT (main_window, start_update, "start_update"); - GLADE_HOOKUP_OBJECT (main_window, image143, "image143"); + GLADE_HOOKUP_OBJECT (main_window, image175, "image175"); GLADE_HOOKUP_OBJECT (main_window, trennlinie2, "trennlinie2"); GLADE_HOOKUP_OBJECT (main_window, menu_quit, "menu_quit"); - GLADE_HOOKUP_OBJECT (main_window, options1, "options1"); - GLADE_HOOKUP_OBJECT (main_window, options1_menu, "options1_menu"); + GLADE_HOOKUP_OBJECT (main_window, menu_options, "menu_options"); + GLADE_HOOKUP_OBJECT (main_window, menu_options_menu, "menu_options_menu"); GLADE_HOOKUP_OBJECT (main_window, menu_preferences, "menu_preferences"); - GLADE_HOOKUP_OBJECT (main_window, image144, "image144"); + GLADE_HOOKUP_OBJECT (main_window, image176, "image176"); GLADE_HOOKUP_OBJECT (main_window, trennlinie7, "trennlinie7"); GLADE_HOOKUP_OBJECT (main_window, menu_notify, "menu_notify"); GLADE_HOOKUP_OBJECT (main_window, menu_job_offers, "menu_job_offers"); @@ -1435,25 +1207,9 @@ create_main_window (void) GLADE_HOOKUP_OBJECT (main_window, menu_figures_menu, "menu_figures_menu"); GLADE_HOOKUP_OBJECT (main_window, menu_fixtures, "menu_fixtures"); GLADE_HOOKUP_OBJECT (main_window, menu_my_league_results, "menu_my_league_results"); - GLADE_HOOKUP_OBJECT (main_window, more_fixtures1, "more_fixtures1"); - GLADE_HOOKUP_OBJECT (main_window, more_fixtures1_menu, "more_fixtures1_menu"); - GLADE_HOOKUP_OBJECT (main_window, menu_league1, "menu_league1"); - GLADE_HOOKUP_OBJECT (main_window, menu_league2, "menu_league2"); - GLADE_HOOKUP_OBJECT (main_window, menu_league3, "menu_league3"); - GLADE_HOOKUP_OBJECT (main_window, menu_league4, "menu_league4"); - GLADE_HOOKUP_OBJECT (main_window, menu_league5, "menu_league5"); - GLADE_HOOKUP_OBJECT (main_window, menu_league6, "menu_league6"); - GLADE_HOOKUP_OBJECT (main_window, trennlinie9, "trennlinie9"); - GLADE_HOOKUP_OBJECT (main_window, menu_cup_1, "menu_cup_1"); - GLADE_HOOKUP_OBJECT (main_window, menu_cup2, "menu_cup2"); - GLADE_HOOKUP_OBJECT (main_window, menu_cup3, "menu_cup3"); - GLADE_HOOKUP_OBJECT (main_window, menu_cup4, "menu_cup4"); - GLADE_HOOKUP_OBJECT (main_window, menu_cup5, "menu_cup5"); - GLADE_HOOKUP_OBJECT (main_window, menu_cup6, "menu_cup6"); GLADE_HOOKUP_OBJECT (main_window, menu_tables, "menu_tables"); GLADE_HOOKUP_OBJECT (main_window, players1, "players1"); GLADE_HOOKUP_OBJECT (main_window, menu_season_history, "menu_season_history"); - GLADE_HOOKUP_OBJECT (main_window, menu_team_history, "menu_team_history"); GLADE_HOOKUP_OBJECT (main_window, menu_team, "menu_team"); GLADE_HOOKUP_OBJECT (main_window, menu_team_menu, "menu_team_menu"); GLADE_HOOKUP_OBJECT (main_window, menu_playing_style, "menu_playing_style"); @@ -1476,23 +1232,32 @@ create_main_window (void) GLADE_HOOKUP_OBJECT (main_window, menu_physio_average, "menu_physio_average"); GLADE_HOOKUP_OBJECT (main_window, menu_physio_bad, "menu_physio_bad"); GLADE_HOOKUP_OBJECT (main_window, menu_boost, "menu_boost"); + GLADE_HOOKUP_OBJECT (main_window, menu_custom_structure, "menu_custom_structure"); + GLADE_HOOKUP_OBJECT (main_window, trennlinie8, "trennlinie8"); GLADE_HOOKUP_OBJECT (main_window, menu_browse_teams, "menu_browse_teams"); GLADE_HOOKUP_OBJECT (main_window, menu_player, "menu_player"); GLADE_HOOKUP_OBJECT (main_window, menu_player_menu, "menu_player_menu"); GLADE_HOOKUP_OBJECT (main_window, menu_show_info, "menu_show_info"); - GLADE_HOOKUP_OBJECT (main_window, menu_show_history, "menu_show_history"); GLADE_HOOKUP_OBJECT (main_window, menu_put_on_transfer_list, "menu_put_on_transfer_list"); GLADE_HOOKUP_OBJECT (main_window, menu_remove_from_transfer_list, "menu_remove_from_transfer_list"); GLADE_HOOKUP_OBJECT (main_window, menu_fire, "menu_fire"); GLADE_HOOKUP_OBJECT (main_window, menu_shoots_penalties, "menu_shoots_penalties"); + GLADE_HOOKUP_OBJECT (main_window, menu_user, "menu_user"); + GLADE_HOOKUP_OBJECT (main_window, menu_user_menu, "menu_user_menu"); + GLADE_HOOKUP_OBJECT (main_window, menu_next_user, "menu_next_user"); + GLADE_HOOKUP_OBJECT (main_window, image177, "image177"); + GLADE_HOOKUP_OBJECT (main_window, menu_previous_user, "menu_previous_user"); + GLADE_HOOKUP_OBJECT (main_window, image178, "image178"); + GLADE_HOOKUP_OBJECT (main_window, menu_manage_users, "menu_manage_users"); + GLADE_HOOKUP_OBJECT (main_window, image179, "image179"); GLADE_HOOKUP_OBJECT (main_window, menu_finances_stadium, "menu_finances_stadium"); GLADE_HOOKUP_OBJECT (main_window, menu_finances_stadium_menu, "menu_finances_stadium_menu"); GLADE_HOOKUP_OBJECT (main_window, menu_increase_capacity, "menu_increase_capacity"); GLADE_HOOKUP_OBJECT (main_window, menu_increase_safety, "menu_increase_safety"); GLADE_HOOKUP_OBJECT (main_window, menu_get_loan, "menu_get_loan"); GLADE_HOOKUP_OBJECT (main_window, menu_pay_loan, "menu_pay_loan"); - GLADE_HOOKUP_OBJECT (main_window, menuitem4, "menuitem4"); - GLADE_HOOKUP_OBJECT (main_window, menuitem4_menu, "menuitem4_menu"); + GLADE_HOOKUP_OBJECT (main_window, menu_help, "menu_help"); + GLADE_HOOKUP_OBJECT (main_window, menu_help_menu, "menu_help_menu"); GLADE_HOOKUP_OBJECT (main_window, menu_about, "menu_about"); GLADE_HOOKUP_OBJECT (main_window, team_editor_help1, "team_editor_help1"); GLADE_HOOKUP_OBJECT (main_window, hbox1, "hbox1"); @@ -1517,14 +1282,17 @@ create_main_window (void) GLADE_HOOKUP_OBJECT (main_window, image23, "image23"); GLADE_HOOKUP_OBJECT (main_window, button_help, "button_help"); GLADE_HOOKUP_OBJECT (main_window, image39, "image39"); - GLADE_HOOKUP_OBJECT (main_window, message_window, "message_window"); + GLADE_HOOKUP_OBJECT (main_window, entry_message, "entry_message"); GLADE_HOOKUP_OBJECT (main_window, hseparator1, "hseparator1"); GLADE_HOOKUP_OBJECT (main_window, eventbox_main_info, "eventbox_main_info"); GLADE_HOOKUP_OBJECT (main_window, hbox18, "hbox18"); + GLADE_HOOKUP_OBJECT (main_window, label_user, "label_user"); GLADE_HOOKUP_OBJECT (main_window, label23, "label23"); GLADE_HOOKUP_OBJECT (main_window, label_season, "label_season"); GLADE_HOOKUP_OBJECT (main_window, label25, "label25"); GLADE_HOOKUP_OBJECT (main_window, label_week, "label_week"); + GLADE_HOOKUP_OBJECT (main_window, label13114, "label13114"); + GLADE_HOOKUP_OBJECT (main_window, label_round, "label_round"); GLADE_HOOKUP_OBJECT (main_window, vseparator14, "vseparator14"); GLADE_HOOKUP_OBJECT (main_window, hbox48, "hbox48"); GLADE_HOOKUP_OBJECT (main_window, eventbox_team_name, "eventbox_team_name"); @@ -1541,7 +1309,7 @@ create_main_window (void) GLADE_HOOKUP_OBJECT (main_window, eventbox1, "eventbox1"); GLADE_HOOKUP_OBJECT (main_window, hbox50, "hbox50"); GLADE_HOOKUP_OBJECT (main_window, label69, "label69"); - GLADE_HOOKUP_OBJECT (main_window, label_av_skill, "label_av_skill"); + GLADE_HOOKUP_OBJECT (main_window, label_av_skills, "label_av_skills"); GLADE_HOOKUP_OBJECT (main_window, hbox7, "hbox7"); GLADE_HOOKUP_OBJECT (main_window, hpaned2, "hpaned2"); GLADE_HOOKUP_OBJECT (main_window, vbox3, "vbox3"); @@ -1556,8 +1324,6 @@ create_main_window (void) GLADE_HOOKUP_OBJECT (main_window, hbox_14, "hbox_14"); GLADE_HOOKUP_OBJECT (main_window, vbox14, "vbox14"); GLADE_HOOKUP_OBJECT (main_window, label31, "label31"); - GLADE_HOOKUP_OBJECT (main_window, button_browse, "button_browse"); - GLADE_HOOKUP_OBJECT (main_window, image17, "image17"); GLADE_HOOKUP_OBJECT (main_window, hbox15, "hbox15"); GLADE_HOOKUP_OBJECT (main_window, vbox15, "vbox15"); GLADE_HOOKUP_OBJECT (main_window, label33, "label33"); @@ -1567,31 +1333,11 @@ create_main_window (void) GLADE_HOOKUP_OBJECT (main_window, label32, "label32"); GLADE_HOOKUP_OBJECT (main_window, button_browse_back, "button_browse_back"); GLADE_HOOKUP_OBJECT (main_window, image10, "image10"); - GLADE_HOOKUP_OBJECT (main_window, vbox5, "vbox5"); - GLADE_HOOKUP_OBJECT (main_window, label15, "label15"); - GLADE_HOOKUP_OBJECT (main_window, hbox11, "hbox11"); - GLADE_HOOKUP_OBJECT (main_window, entry_structure, "entry_structure"); - GLADE_HOOKUP_OBJECT (main_window, button_structure, "button_structure"); - GLADE_HOOKUP_OBJECT (main_window, image16, "image16"); - GLADE_HOOKUP_OBJECT (main_window, button_rearrange, "button_rearrange"); - GLADE_HOOKUP_OBJECT (main_window, image15, "image15"); - GLADE_HOOKUP_OBJECT (main_window, button_undo, "button_undo"); - GLADE_HOOKUP_OBJECT (main_window, image53, "image53"); GLADE_HOOKUP_OBJECT (main_window, hbox41, "hbox41"); GLADE_HOOKUP_OBJECT (main_window, vbox33, "vbox33"); GLADE_HOOKUP_OBJECT (main_window, label66, "label66"); - GLADE_HOOKUP_OBJECT (main_window, button_fixtures, "button_fixtures"); - GLADE_HOOKUP_OBJECT (main_window, alignment13, "alignment13"); - GLADE_HOOKUP_OBJECT (main_window, hbox43, "hbox43"); - GLADE_HOOKUP_OBJECT (main_window, image42, "image42"); - GLADE_HOOKUP_OBJECT (main_window, label68, "label68"); GLADE_HOOKUP_OBJECT (main_window, vbox29, "vbox29"); GLADE_HOOKUP_OBJECT (main_window, label62, "label62"); - GLADE_HOOKUP_OBJECT (main_window, button_tables, "button_tables"); - GLADE_HOOKUP_OBJECT (main_window, alignment12, "alignment12"); - GLADE_HOOKUP_OBJECT (main_window, hbox42, "hbox42"); - GLADE_HOOKUP_OBJECT (main_window, image41, "image41"); - GLADE_HOOKUP_OBJECT (main_window, label67, "label67"); GLADE_HOOKUP_OBJECT (main_window, vbox34, "vbox34"); GLADE_HOOKUP_OBJECT (main_window, label70, "label70"); GLADE_HOOKUP_OBJECT (main_window, scrolledwindow3, "scrolledwindow3"); diff --git a/src/league.c b/src/league.c index 81e4d76c..953fd4ed 100644 --- a/src/league.c +++ b/src/league.c @@ -33,6 +33,7 @@ league_new(void) new.table.name = g_string_new(""); new.table.clid = new.id; + new.table.round = -1; new.table.elements = g_array_new(FALSE, FALSE, sizeof(TableElement)); new.first_week = new.week_gap = 1; @@ -83,22 +84,6 @@ league_new_id(void) return -1; } -/** Return a nullified table element. - @see #TableElement */ -TableElement -league_table_element_new(Team *team) -{ - gint i; - TableElement new; - - new.team = team; - - for(i=0;ilen;i++) + if(lig(i).id == clid) + return &lig(i); + + g_warning("league_from_clid: didn't find league with id %d\n", clid); + return NULL; +} diff --git a/src/league.h b/src/league.h index cd7a29eb..ad3c9800 100644 --- a/src/league.h +++ b/src/league.h @@ -19,4 +19,7 @@ league_table_element_new(Team *team); gint league_cup_get_index_from_clid(gint clid); +League* +league_from_clid(gint clid); + #endif diff --git a/src/live_game.c b/src/live_game.c index 05ef849c..ffa85140 100644 --- a/src/live_game.c +++ b/src/live_game.c @@ -1,112 +1,18 @@ +#include "enums.h" #include "fixture.h" #include "free.h" #include "game_gui.h" #include "live_game.h" #include "maths.h" +#include "misc_callback_func.h" +#include "option.h" #include "player.h" +#include "table.h" #include "team.h" #include "treeview.h" +#include "user.h" #include "variables.h" - -/** Constants determining the type of a LiveGameEvent. - @see live_game_create_event_type() */ - -/** Base probability that the ball gets from defending area - to midfield area. */ -#define CONSTANT_LIVE_GAME_AREA_DEF_MID 0.5 -/** Influence of attack/defend values on the base probability; the lower - the smaller the influence. */ -#define CONSTANT_LIVE_GAME_AREA_DEF_MID_TEAM_EXPONENT 0.5 - -/** Base probability that the ball gets from midfield area - to attack area or back to defend area. */ -#define CONSTANT_LIVE_GAME_AREA_MID_ATT 0.5 -#define CONSTANT_LIVE_GAME_AREA_MID_DEF 0.3 -/** Influence of attack/defend values on the base probability; the lower - the smaller the influence. */ -#define CONSTANT_LIVE_GAME_AREA_MID_TEAM_EXPONENT 1 - -/** Base probability that the ball gets from attacking area - to midfield area. */ -#define CONSTANT_LIVE_GAME_AREA_ATT_MID 0.3 -/** Influence of attack/defend values on the base probability; the lower - the smaller the influence. */ -#define CONSTANT_LIVE_GAME_AREA_ATT_MID_TEAM_EXPONENT 0.5 - -/** Base probability of a general event (no foul, no injury, no goal etc.) */ -#define CONSTANT_LIVE_GAME_EVENT_GENERAL 0.5 - -/** Base probability for possession change. */ -#define CONSTANT_LIVE_GAME_POSSESSION_CHANGES 0.2 -/** Influence of the team values on the possession change. */ -#define CONSTANT_LIVE_GAME_POSSESSION_TEAM_EXPONENT 2 - -/** Base prob for a scoring chance if a team is attacking. */ -#define CONSTANT_LIVE_GAME_SCORING_CHANCE 0.2 -/** Team values influence on the scoring chance. */ -#define CONSTANT_LIVE_GAME_SCORING_CHANCE_TEAM_EXPONENT 1 - -/** Probability that it's the player in possession who - has the scoring chance. */ -#define CONSTANT_LIVE_GAME_PLAYER_IN_POSS_SHOOTS 0.5 - -/** Base probability to score with a scoring chance. */ -#define CONSTANT_LIVE_GAME_SCORE_BASE_PROB 0.15 -/** Base probability to score with a free kick. */ -#define CONSTANT_LIVE_GAME_SCORE_FREE_KICK 0.35 -/** Base probability to score with a penalty. */ -#define CONSTANT_LIVE_GAME_SCORE_PENALTY 0.8 -/** Influence of the attacker/goalie skills on the probability to score. */ -#define CONSTANT_LIVE_GAME_SCORE_DUEL_EXPONENT 0.3 -/** Influence of the team attacking/defending values on the probability to score. */ -#define CONSTANT_LIVE_GAME_SCORE_TEAM_EXPONENT 0.7 - -/** The smaller this number, the smaller the probability of - many stopping minutes after 90 or 45 minutes. */ -#define CONSTANT_LIVE_GAME_BREAK_BASE 0.6 -/** The bigger this number, the faster the probability of - yet another additional minute after the 45th minute decays. */ -#define CONSTANT_LIVE_GAME_45_BREAK_EXPONENT_FACTOR 1.3 -/** The bigger this number, the faster the probability of - yet another additional minute after the 90th minute decays. */ -#define CONSTANT_LIVE_GAME_90_BREAK_EXPONENT_FACTOR 0.7 -/** The probability that the team that shot on the goal stays - in possession after a post or cross-bar hit. */ -#define CONSTANT_LIVE_GAME_POSSESSION_AFTER_POST 0.3 - -/** Probability that there is a passing event after a special event. - @see live_game_event_general() */ -#define CONSTANT_LIVE_GAME_GENERAL_EVENT_SECOND_PLAYER 0.5 - -/** Constants for stadium events. */ -#define CONSTANT_LIVE_GAME_STADIUM_EVENT_EXPONENT (0.1 * CONSTANT_LIVE_GAME_EVENT_GENERAL) -#define CONSTANT_LIVE_GAME_STADIUM_EVENT_FIRE 0.2 -#define CONSTANT_LIVE_GAME_STADIUM_EVENT_RIOTS 0.5 -#define CONSTANT_LIVE_GAME_STADIUM_EVENT_BREAKDOWN 1.0 - -/** Foul probabilities. */ -#define CONSTANT_LIVE_GAME_FOUL (20.0 / 90.0 * CONSTANT_LIVE_GAME_EVENT_GENERAL) -#define CONSTANT_LIVE_GAME_FOUL_RED_INJURY 0.05 -#define CONSTANT_LIVE_GAME_FOUL_RED 0.08 -#define CONSTANT_LIVE_GAME_FOUL_YELLOW 0.23 - -/** Injury probabilities. */ -#define CONSTANT_LIVE_GAME_INJURY (3.0 / 90 * CONSTANT_LIVE_GAME_EVENT_GENERAL) -#define CONSTANT_LIVE_GAME_INJURY_GOALIE_FACTOR 0.2 -#define CONSTANT_LIVE_GAME_INJURY_IS_TEMP 0.7 - -/** Probability that a scoring chance is an own goal. */ -#define CONSTANT_LIVE_GAME_SCORING_CHANCE_IS_OWN_GOAL 0.01 - -/** Probability of a free kick after a foul. */ -#define CONSTANT_LIVE_GAME_FREE_KICK_PROB 0.15 - -/** Probability of a penalty after a foul. */ -#define CONSTANT_LIVE_GAME_PENALTY_PROB 0.05 - -/** Probability that a scoring chance is a header. */ -#define CONSTANT_LIVE_GAME_SCORING_CHANCE_IS_HEADER 0.35 - +#include "window.h" /** The live game we calculate. */ LiveGame *match; @@ -114,9 +20,9 @@ LiveGame *match; gboolean show; /** Convenience abbrev. */ -#define units match->units -#define uni(i) g_array_index(units, LiveGameUnit, i) -#define last_unit uni(units->len - 1) +#define unis match->units +#define uni(i) g_array_index(unis, LiveGameUnit, i) +#define last_unit uni(unis->len - 1) #define tm match->fix->teams #define tm0 match->fix->teams[0] #define tm1 match->fix->teams[1] @@ -129,22 +35,39 @@ gboolean show; void live_game_calculate_fixture(Fixture *fix) { - live_game_reset(fix); + Fixture *local_fix = NULL; + + if(stat0 != STATUS_LIVE_GAME_PAUSE) + { + local_fix = fix; + live_game_reset(local_fix); + game_calculate_attendance(local_fix); + } + else + { + stat0 = STATUS_SHOW_LIVE_GAME; + local_fix = usr(stat2).live_game.fix; + match = &usr(stat2).live_game; + } do { - live_game_create_unit(); - + live_game_create_unit(); live_game_evaluate_unit(&last_unit); if(show) game_gui_live_game_show_unit(&last_unit); - } - while(last_unit.event.type != LIVE_GAME_EVENT_END_MATCH); + while(last_unit.event.type != LIVE_GAME_EVENT_END_MATCH && + stat0 != STATUS_LIVE_GAME_PAUSE); - if(last_unit.event.type == LIVE_GAME_EVENT_END_MATCH) + if(stat0 != STATUS_LIVE_GAME_PAUSE) + { live_game_create_stats(); + + if(query_fixture_has_tables(local_fix)) + table_update(local_fix); + } } /** Create a game unit for the live game. @@ -154,15 +77,15 @@ live_game_create_unit(void) { LiveGameUnit new; - if(debug) + if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1) printf("live_game_create_unit\n"); - if(units->len == 0) + if(unis->len == 0) { live_game_create_start_unit(); return; } - if(uni(units->len - 1).event.type == LIVE_GAME_EVENT_END_MATCH) + if(uni(unis->len - 1).event.type == LIVE_GAME_EVENT_END_MATCH) { g_warning("live_game_create_unit: called after end of match.\n"); return; @@ -174,21 +97,23 @@ live_game_create_unit(void) new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = -1; new.area = last_unit.area; + new.result[0] = last_unit.result[0]; + new.result[1] = last_unit.result[1]; if(query_live_game_event_is_break(new.minute, new.time)) { new.event.type = live_game_get_break(); new.possession = last_unit.possession; - live_game_generate_commentary(&new); - g_array_append_val(units, new); + live_game_generate_commentary(&new, FALSE); + g_array_append_val(unis, new); return; } - else if(last_unit.time == LIVE_GAME_UNIT_TIME_PENALTIES) + else if(new.time == LIVE_GAME_UNIT_TIME_PENALTIES) new.event.type = LIVE_GAME_EVENT_PENALTY; else live_game_fill_new_unit(&new); - g_array_append_val(units, new); + g_array_append_val(unis, new); } /** Fill in a new unit depending on the team values and the constants from above. @@ -200,14 +125,14 @@ live_game_fill_new_unit(LiveGameUnit *new) gfloat rndom = math_rnd(0, 1); gfloat stadium_event = 1 - powf((gfloat)tm0->stadium.safety / 100, - CONSTANT_LIVE_GAME_STADIUM_EVENT_EXPONENT); + const_float("float_live_game_stadium_event_exponent")); gfloat possession_change, scoring_chance = 0; - if(debug) + if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1) printf("live_game_fill_new_unit\n"); - possession_change = CONSTANT_LIVE_GAME_EVENT_GENERAL * - CONSTANT_LIVE_GAME_POSSESSION_CHANGES / - live_game_pit_teams(old, CONSTANT_LIVE_GAME_POSSESSION_TEAM_EXPONENT); + possession_change = const_float("float_live_game_event_general") * + const_float("float_live_game_possession_changes") / + live_game_pit_teams(old, const_float("float_live_game_possession_team_exponent")); new->possession = old->possession; @@ -215,20 +140,20 @@ live_game_fill_new_unit(LiveGameUnit *new) new->area = live_game_get_area(new); if(new->area == LIVE_GAME_UNIT_AREA_ATTACK) - scoring_chance = CONSTANT_LIVE_GAME_SCORING_CHANCE * - live_game_pit_teams(new, CONSTANT_LIVE_GAME_SCORING_CHANCE_TEAM_EXPONENT); + scoring_chance = const_float("float_live_game_scoring_chance") * + live_game_pit_teams(new, const_float("float_live_game_scoring_chance_team_exponent")); - if(rndom < CONSTANT_LIVE_GAME_FOUL) + if(rndom < const_float("float_live_game_foul")) new->event.type = LIVE_GAME_EVENT_FOUL; - else if(rndom < CONSTANT_LIVE_GAME_FOUL + - CONSTANT_LIVE_GAME_INJURY) + else if(rndom < const_float("float_live_game_foul") + + const_float("float_live_game_injury")) new->event.type = LIVE_GAME_EVENT_INJURY; - else if(rndom < CONSTANT_LIVE_GAME_FOUL + - CONSTANT_LIVE_GAME_INJURY + + else if(rndom < const_float("float_live_game_foul") + + const_float("float_live_game_injury") + stadium_event && !match->stadium_event) new->event.type = LIVE_GAME_EVENT_STADIUM; - else if(rndom < CONSTANT_LIVE_GAME_FOUL + - CONSTANT_LIVE_GAME_INJURY + + else if(rndom < const_float("float_live_game_foul") + + const_float("float_live_game_injury") + stadium_event + possession_change) { new->event.type = LIVE_GAME_EVENT_LOST_POSSESSION; @@ -238,8 +163,8 @@ live_game_fill_new_unit(LiveGameUnit *new) else if(new->area == LIVE_GAME_UNIT_AREA_DEFEND) new->area = LIVE_GAME_UNIT_AREA_ATTACK; } - else if(rndom < CONSTANT_LIVE_GAME_FOUL + - CONSTANT_LIVE_GAME_INJURY + + else if(rndom < const_float("float_live_game_foul") + + const_float("float_live_game_injury") + stadium_event + possession_change + scoring_chance) new->event.type = LIVE_GAME_EVENT_SCORING_CHANCE; @@ -253,7 +178,7 @@ live_game_create_start_unit(void) { LiveGameUnit new; - if(debug) + if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1) printf("live_game_create_start_unit\n"); new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = -1; @@ -266,11 +191,12 @@ live_game_create_start_unit(void) new.possession = math_rndi(0, 1); new.area = LIVE_GAME_UNIT_AREA_MIDFIELD; match->started_game = new.possession; + new.result[0] = new.result[1] = 0; new.event.type = LIVE_GAME_EVENT_START_MATCH; new.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = new.possession; - g_array_append_val(units, new); + g_array_append_val(unis, new); } /** Evaluate a live game unit. This means we find out what happens @@ -282,7 +208,7 @@ live_game_evaluate_unit(LiveGameUnit *unit) { gint type = unit->event.type; - if(debug) + if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1) printf("live_game_evaluate_unit type %d\n", type); if(type == LIVE_GAME_EVENT_FOUL) live_game_event_foul(TRUE); @@ -298,17 +224,15 @@ live_game_evaluate_unit(LiveGameUnit *unit) live_game_event_penalty(); else if(type == LIVE_GAME_EVENT_GENERAL) live_game_event_general(FALSE); - else if(type == LIVE_GAME_EVENT_START_MATCH || - type == LIVE_GAME_EVENT_HALF_TIME || + else if(type == LIVE_GAME_EVENT_START_MATCH) + live_game_generate_commentary(&last_unit, TRUE); + else if(type == LIVE_GAME_EVENT_HALF_TIME || type == LIVE_GAME_EVENT_EXTRA_TIME || type == LIVE_GAME_EVENT_PENALTIES) { - live_game_generate_commentary(&last_unit); + live_game_generate_commentary(&last_unit, FALSE); if(show) - game_gui_live_game_show_unit(&last_unit); - - if(type != LIVE_GAME_EVENT_PENALTIES) - live_game_event_general(TRUE); + misc_callback_pause_live_game(); } else if(type != LIVE_GAME_EVENT_END_MATCH) g_warning("live_game_evaluate_unit: unknown event type %d\n", @@ -324,11 +248,11 @@ live_game_event_foul(gboolean general) gfloat rndom = math_rnd(0, 1); gint type; - if(debug) + if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1) printf("live_game_event_foul\n"); - if(uni(units->len - 2).event.type == LIVE_GAME_EVENT_GENERAL) + if(uni(unis->len - 2).event.type == LIVE_GAME_EVENT_GENERAL) last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = - uni(units->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER]; + uni(unis->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER]; else last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = game_get_player(tm[last_unit.possession], @@ -338,20 +262,18 @@ live_game_event_foul(gboolean general) game_get_player(tm[!last_unit.possession], last_unit.area, 0, -1, FALSE); - if(rndom < CONSTANT_LIVE_GAME_FOUL_RED_INJURY) + if(rndom < const_float("float_live_game_foul_red_injury")) type = LIVE_GAME_EVENT_FOUL_RED_INJURY; - else if(rndom < CONSTANT_LIVE_GAME_FOUL_RED) + else if(rndom < const_float("float_live_game_foul_red")) type = LIVE_GAME_EVENT_FOUL_RED; - else if(rndom < CONSTANT_LIVE_GAME_FOUL_YELLOW) + else if(rndom < const_float("float_live_game_foul_yellow")) type = LIVE_GAME_EVENT_FOUL_YELLOW; else type = LIVE_GAME_EVENT_FOUL; last_unit.event.type = type; - live_game_generate_commentary(&last_unit); - if(show) - game_gui_live_game_show_unit(&last_unit); + live_game_generate_commentary(&last_unit, TRUE); if(type == LIVE_GAME_EVENT_FOUL_RED || type == LIVE_GAME_EVENT_FOUL_RED_INJURY || @@ -369,9 +291,9 @@ live_game_event_foul(gboolean general) if(last_unit.area == LIVE_GAME_UNIT_AREA_ATTACK) { rndom = math_rnd(0, 1); - if(rndom < CONSTANT_LIVE_GAME_PENALTY_PROB) + if(rndom < const_float("float_live_game_penalty_prob")) live_game_event_penalty(); - else if(rndom < CONSTANT_LIVE_GAME_FREE_KICK_PROB) + else if(rndom < const_float("float_live_game_free_kick_prob")) live_game_event_free_kick(); else live_game_event_general(TRUE); @@ -384,28 +306,26 @@ live_game_event_foul(gboolean general) void live_game_event_lost_possession(void) { - if(debug) + if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1) printf("live_game_event_lost_possession\n"); last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = game_get_player(tm[last_unit.possession], last_unit.area, 0, -1, TRUE); - if(uni(units->len - 2).event.type == LIVE_GAME_EVENT_GENERAL) + if(uni(unis->len - 2).event.type == LIVE_GAME_EVENT_GENERAL) last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = - uni(units->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER]; + uni(unis->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER]; else last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = game_get_player(tm[!last_unit.possession], - uni(units->len - 2).area, 0, -1, FALSE); + uni(unis->len - 2).area, 0, -1, FALSE); - if(debug) + if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1) printf("## pls %d %d\n", last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER], last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2]); - live_game_generate_commentary(&last_unit); - if(show) - game_gui_live_game_show_unit(&last_unit); + live_game_generate_commentary(&last_unit, TRUE); live_game_event_general(TRUE); } @@ -421,13 +341,13 @@ live_game_event_injury(gint team, gint player, gboolean create_new) { LiveGameUnit new; - if(debug) + if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1) printf("live_game_event_injury\n"); if(create_new) { new = last_unit; new.event.commentary = g_string_new("injury"); - g_array_append_val(units, new); + g_array_append_val(unis, new); last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = player; last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = @@ -439,12 +359,10 @@ live_game_event_injury(gint team, gint player, gboolean create_new) last_unit.minute = -1; last_unit.event.type = LIVE_GAME_EVENT_INJURY; - if(math_rnd(0, 1) < CONSTANT_LIVE_GAME_INJURY_IS_TEMP) + if(math_rnd(0, 1) < const_float("float_live_game_injury_is_temp")) last_unit.event.type = LIVE_GAME_EVENT_TEMP_INJURY; - live_game_generate_commentary(&last_unit); - if(show) - game_gui_live_game_show_unit(&last_unit); + live_game_generate_commentary(&last_unit, TRUE); /*d*/ live_game_event_general(TRUE); @@ -456,18 +374,16 @@ live_game_event_stadium(void) { gfloat rndom = math_rnd(0, 1); - if(debug) + if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1) printf("live_game_event_stadium\n"); - if(rndom < CONSTANT_LIVE_GAME_STADIUM_EVENT_FIRE) + if(rndom < const_float("float_live_game_stadium_event_fire")) last_unit.event.type = LIVE_GAME_EVENT_STADIUM_FIRE; - else if(rndom < CONSTANT_LIVE_GAME_STADIUM_EVENT_RIOTS) + else if(rndom < const_float("float_live_game_stadium_event_riots")) last_unit.event.type = LIVE_GAME_EVENT_STADIUM_RIOTS; - else if(rndom < CONSTANT_LIVE_GAME_STADIUM_EVENT_BREAKDOWN) + else if(rndom < const_float("float_live_game_stadium_event_breakdown")) last_unit.event.type = LIVE_GAME_EVENT_STADIUM_BREAKDOWN; - live_game_generate_commentary(&last_unit); - if(show) - game_gui_live_game_show_unit(&last_unit); + live_game_generate_commentary(&last_unit, TRUE); live_game_event_general(TRUE); } @@ -476,9 +392,9 @@ live_game_event_stadium(void) void live_game_event_scoring_chance(void) { - if(debug) + if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1) printf("live_game_event_scoring_chance\n"); - if(math_rnd(0, 1) < CONSTANT_LIVE_GAME_SCORING_CHANCE_IS_OWN_GOAL) + if(math_rnd(0, 1) < const_float("float_live_game_scoring_chance_is_own_goal")) { last_unit.event.type = LIVE_GAME_EVENT_OWN_GOAL; last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = @@ -486,21 +402,21 @@ live_game_event_scoring_chance(void) } else { - if(uni(units->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER] != -1 && - math_rnd(0, 1) < CONSTANT_LIVE_GAME_PLAYER_IN_POSS_SHOOTS) + if(uni(unis->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER] != -1 && + math_rnd(0, 1) < const_float("float_live_game_player_in_poss_shoots")) last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = - uni(units->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER]; + uni(unis->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER]; else { - if(uni(units->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER] != -1) + if(uni(unis->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER] != -1) { last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = game_get_player(tm[last_unit.possession], last_unit.area, 0, - uni(units->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER], + uni(unis->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER], TRUE); last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = - uni(units->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER]; + uni(unis->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER]; } else { @@ -514,9 +430,7 @@ live_game_event_scoring_chance(void) } } - live_game_generate_commentary(&last_unit); - if(show) - game_gui_live_game_show_unit(&last_unit); + live_game_generate_commentary(&last_unit, TRUE); live_game_event_duel(); } @@ -527,41 +441,42 @@ live_game_event_penalty(void) { LiveGameUnit new; - if(debug) + if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1) printf("live_game_event_penalty\n"); - new = last_unit; - new.minute = -1; - new.event.type = LIVE_GAME_EVENT_PENALTY; - new.event.commentary = g_string_new("penalty"); - g_array_append_val(units, new); + if(last_unit.time != LIVE_GAME_UNIT_TIME_PENALTIES) + { + new = last_unit; + new.minute = -1; + new.event.type = LIVE_GAME_EVENT_PENALTY; + new.event.commentary = g_string_new("penalty"); + + g_array_append_val(unis, new); + } if(last_unit.time == LIVE_GAME_UNIT_TIME_PENALTIES) { - if(uni(units->len - 2).event.type == LIVE_GAME_EVENT_PENALTIES) + if(uni(unis->len - 2).event.type == LIVE_GAME_EVENT_PENALTIES) { - last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = - math_rndi(0, 1); + last_unit.possession = math_rndi(0, 1); last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = - game_get_player(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]], - GAME_PLAYER_TYPE_PENALTY, 0, -1, FALSE); + game_get_player(tm[last_unit.possession], + GAME_PLAYER_TYPE_PENALTY, -1, -1, FALSE); } - else if(uni(units->len - 4).event.type == LIVE_GAME_EVENT_PENALTIES) + else if(uni(unis->len - 4).event.type == LIVE_GAME_EVENT_PENALTIES) { - last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = - !uni(units->len - 3).event.values[LIVE_GAME_EVENT_VALUE_TEAM]; + last_unit.possession = !uni(unis->len - 3).possession; last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = - game_get_player(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]], - GAME_PLAYER_TYPE_PENALTY, 0, -1, FALSE); + game_get_player(tm[last_unit.possession], + GAME_PLAYER_TYPE_PENALTY, -1, -1, FALSE); } else { - last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = - !uni(units->len - 2).event.values[LIVE_GAME_EVENT_VALUE_TEAM]; + last_unit.possession = !uni(unis->len - 3).possession; last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = - game_get_player(tm[last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM]], + game_get_player(tm[last_unit.possession], GAME_PLAYER_TYPE_PENALTY, - -uni(units->len - 4).event.values[LIVE_GAME_EVENT_VALUE_PLAYER], -1, FALSE); + uni(unis->len - 4).event.values[LIVE_GAME_EVENT_VALUE_PLAYER], -1, FALSE); } } else @@ -569,18 +484,18 @@ live_game_event_penalty(void) last_unit.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = last_unit.possession; - if(my_team == tm[last_unit.possession] && - options[OPT_PENALTY_SHOOTER] != -1) + if(team_is_user(tm[last_unit.possession]) != -1 && + option_int("int_opt_user_penalty_shooter", + usr(team_is_user(tm[last_unit.possession])).options) != -1) last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = - options[OPT_PENALTY_SHOOTER]; + option_int("int_opt_user_penalty_shooter", + usr(team_is_user(tm[last_unit.possession])).options); else last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = - game_get_player(tm[last_unit.possession], GAME_PLAYER_TYPE_PENALTY, 0, -1, FALSE); + game_get_player(tm[last_unit.possession], GAME_PLAYER_TYPE_PENALTY, -1, -1, FALSE); } - live_game_generate_commentary(&last_unit); - if(show) - game_gui_live_game_show_unit(&last_unit); + live_game_generate_commentary(&last_unit, TRUE); live_game_event_duel(); } @@ -592,12 +507,16 @@ live_game_event_general(gboolean create_new) { LiveGameUnit new; - if(debug) + if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1) printf("live_game_event_general\n"); if(create_new) { new.minute = live_game_get_minute(); new.time = last_unit.time; + new.event.type = LIVE_GAME_EVENT_GENERAL; + new.event.commentary = g_string_new("general"); + new.result[0] = last_unit.result[0]; + new.result[1] = last_unit.result[1]; if(last_unit.event.type == LIVE_GAME_EVENT_GENERAL || last_unit.event.type == LIVE_GAME_EVENT_START_MATCH || @@ -613,9 +532,9 @@ live_game_event_general(gboolean create_new) last_unit.event.type == LIVE_GAME_EVENT_STADIUM_RIOTS || ((last_unit.event.type == LIVE_GAME_EVENT_POST || last_unit.event.type == LIVE_GAME_EVENT_CROSS_BAR) && - math_rnd(0, 1) < CONSTANT_LIVE_GAME_POSSESSION_AFTER_POST)) + math_rnd(0, 1) < const_float("float_live_game_possession_after_post"))) { - if(debug) + if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1) printf("##### last type: %d\n", last_unit.event.type); new.possession = last_unit.possession; new.area = (last_unit.event.type == LIVE_GAME_EVENT_GENERAL) ? @@ -651,20 +570,17 @@ live_game_event_general(gboolean create_new) g_warning("live_game_event_general: unknown event type: %d\n", last_unit.event.type); - new.event.type = LIVE_GAME_EVENT_GENERAL; - new.event.commentary = g_string_new("general"); - - g_array_append_val(units, new); + g_array_append_val(unis, new); } live_game_event_general_get_players(); - if(debug) + if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1) printf("+++ general %d %d\n", last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER], last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2]); - live_game_generate_commentary(&last_unit); + live_game_generate_commentary(&last_unit, FALSE); } /** Fill in the players values in a general unit. */ @@ -674,12 +590,12 @@ live_game_event_general_get_players(void) gint *pl1 = &last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER]; gint *pl2 = &last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2]; gint old_pl1 = - uni(units->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER], + uni(unis->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER], old_pl2 = - uni(units->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER2]; - gint type = uni(units->len - 2).event.type; + uni(unis->len - 2).event.values[LIVE_GAME_EVENT_VALUE_PLAYER2]; + gint type = uni(unis->len - 2).event.type; - if(debug) + if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1) printf("live_game_event_general_get_players\n"); *pl1 = *pl2 = -1; @@ -694,7 +610,7 @@ live_game_event_general_get_players(void) { *pl1 = game_get_player(tm[last_unit.possession], last_unit.area, 0, -1, TRUE); - if(math_rnd(0, 1) < CONSTANT_LIVE_GAME_GENERAL_EVENT_SECOND_PLAYER) + if(math_rnd(0, 1) < const_float("float_live_game_general_event_second_player")) *pl2 = game_get_player(tm[last_unit.possession], last_unit.area, 0, *pl1, TRUE); } @@ -712,7 +628,7 @@ live_game_event_free_kick(void) { LiveGameUnit new = last_unit; - if(debug) + if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1) printf("live_game_event_free_kick\n"); new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = -1; @@ -723,19 +639,19 @@ live_game_event_free_kick(void) new.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = new.possession; new.event.commentary = g_string_new("freekick"); - if(tm[new.possession] == my_team && - options[OPT_PENALTY_SHOOTER] != -1) + if(team_is_user(tm[new.possession]) != -1 && + option_int("int_opt_user_penalty_shooter", + usr(team_is_user(tm[last_unit.possession])).options) != -1) new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = - options[OPT_PENALTY_SHOOTER]; + option_int("int_opt_user_penalty_shooter", + usr(team_is_user(tm[last_unit.possession])).options); else new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = game_get_player(tm[new.possession], new.area, 0, -1, TRUE); - g_array_append_val(units, new); + g_array_append_val(unis, new); - live_game_generate_commentary(&last_unit); - if(show) - game_gui_live_game_show_unit(&last_unit); + live_game_generate_commentary(&last_unit, TRUE); live_game_event_duel(); } @@ -746,7 +662,7 @@ live_game_event_send_off(gint team, gint player) { LiveGameUnit new = last_unit; - if(debug) + if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1) printf("live_game_event_send_off\n"); new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = -1; @@ -758,14 +674,11 @@ live_game_event_send_off(gint team, gint player) new.event.values[LIVE_GAME_EVENT_VALUE_TEAM] = team; new.event.commentary = g_string_new("send off"); - g_array_append_val(units, new); + g_array_append_val(unis, new); - live_game_generate_commentary(&last_unit); - if(show) - game_gui_live_game_show_unit(&last_unit); + live_game_generate_commentary(&last_unit, TRUE); } - /** Calculate whether a player who tries to score succeeds. */ void live_game_event_duel(void) @@ -777,15 +690,11 @@ live_game_event_duel(void) Player *attacker, *goalie; gint res_idx1, res_idx2; - if(debug) + if(opt_int("int_opt_debug") && fixture_user_team_involved(match->fix) != -1) printf("live_game_event_duel\n"); - new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = - new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = -1; new.minute = -1; - - new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER] = - last_unit.event.values[LIVE_GAME_EVENT_VALUE_PLAYER]; + new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] = -1; new.event.commentary = g_string_new("duel"); @@ -793,9 +702,9 @@ live_game_event_duel(void) new.event.values[LIVE_GAME_EVENT_VALUE_PLAYER]); goalie = player_of(tm[!new.possession], 0); duel_factor = (((gfloat)attacker->cskill * powf((gfloat)attacker->fitness / 100, - CONSTANT_GAME_PLAYER_FITNESS_EXPONENT)) / + const_float("float_player_fitness_exponent"))) / ((gfloat)goalie->cskill * powf((gfloat)goalie->fitness / 100, - CONSTANT_GAME_PLAYER_FITNESS_EXPONENT))); + const_float("float_player_fitness_exponent")))); res_idx1 = new.possession; if(new.time == LIVE_GAME_UNIT_TIME_PENALTIES) res_idx2 = 2; @@ -805,29 +714,28 @@ live_game_event_duel(void) res_idx2 = 0; if(last_unit.event.type == LIVE_GAME_EVENT_PENALTY) - scoring_prob = CONSTANT_LIVE_GAME_SCORE_PENALTY * duel_factor; + scoring_prob = const_float("float_live_game_score_penalty") * duel_factor; else if(last_unit.event.type == LIVE_GAME_EVENT_FREE_KICK) - scoring_prob = CONSTANT_LIVE_GAME_SCORE_FREE_KICK * duel_factor; + scoring_prob = const_float("float_live_game_score_free_kick") * duel_factor; else - scoring_prob = CONSTANT_LIVE_GAME_SCORE_BASE_PROB * - powf(duel_factor, CONSTANT_LIVE_GAME_SCORE_DUEL_EXPONENT) * + scoring_prob = const_float("float_live_game_score_base_prob") * + powf(duel_factor, const_float("float_live_game_score_duel_exponent")) * powf(match->team_values[new.possession][GAME_TEAM_VALUE_ATTACK] / - match->team_values[new.possession][GAME_TEAM_VALUE_DEFEND], - CONSTANT_LIVE_GAME_SCORE_TEAM_EXPONENT); - + match->team_values[!new.possession][GAME_TEAM_VALUE_DEFEND], + const_float("float_live_game_score_team_exponent")); + if(rndom < scoring_prob) { new.event.type = LIVE_GAME_EVENT_GOAL; match->fix->result[res_idx1][res_idx2]++; + new.result[res_idx1]++; } else new.event.type = math_gauss_disti(LIVE_GAME_EVENT_POST, LIVE_GAME_EVENT_CROSS_BAR); - g_array_append_val(units, new); + g_array_append_val(unis, new); - live_game_generate_commentary(&last_unit); - if(show) - game_gui_live_game_show_unit(&last_unit); + live_game_generate_commentary(&last_unit, TRUE); if(last_unit.time != LIVE_GAME_UNIT_TIME_PENALTIES) live_game_event_general(TRUE); @@ -843,7 +751,7 @@ query_live_game_second_yellow(gint team, gint player) { gint i; - for(i=0;ilen - 1;i++) + for(i=0;ilen - 1;i++) if(uni(i).event.type == LIVE_GAME_EVENT_FOUL_YELLOW && uni(i).possession != team && uni(i).event.values[LIVE_GAME_EVENT_VALUE_PLAYER2] == player) @@ -863,8 +771,11 @@ query_live_game_event_is_break(gint minute, gint time) { gfloat rndom; - if(time == LIVE_GAME_UNIT_TIME_EXTRA_TIME && minute == 120) - return TRUE; + if(fixture_user_team_involved(match->fix) != -1 && opt_int("int_opt_debug")) + printf("## time %d min %d\n", time, minute); + + if(time == LIVE_GAME_UNIT_TIME_EXTRA_TIME) + return (minute >= 120); if(time == LIVE_GAME_UNIT_TIME_PENALTIES) return query_live_game_penalties_over(); @@ -873,12 +784,14 @@ query_live_game_event_is_break(gint minute, gint time) if(time == LIVE_GAME_UNIT_TIME_FIRST_HALF) return (minute >= 45 && rndom > - powf(CONSTANT_LIVE_GAME_BREAK_BASE, - (gfloat)(minute - 44) * CONSTANT_LIVE_GAME_45_BREAK_EXPONENT_FACTOR)); + powf(const_float("float_live_game_break_base"), + (gfloat)(minute - 44) * + const_float("float_live_game_45_break_exponent_factor"))); else return (minute >= 90 && rndom > - powf(CONSTANT_LIVE_GAME_BREAK_BASE, - (gfloat)(minute - 89) * CONSTANT_LIVE_GAME_90_BREAK_EXPONENT_FACTOR)); + powf(const_float("float_live_game_break_base"), + (gfloat)(minute - 89) * + const_float("float_live_game_90_break_exponent_factor"))); } /** Find out whether the final result of the penalties is @@ -891,17 +804,18 @@ query_live_game_penalties_over(void) gint i; gint pen_attempted[2] = {0, 0}; - for(i=units->len - 1; i > 0; i--) + for(i=unis->len - 1; i > 0; i--) if(uni(i).time == LIVE_GAME_UNIT_TIME_PENALTIES) { if(uni(i).event.type == LIVE_GAME_EVENT_PENALTY) - pen_attempted[uni(i).event.values[LIVE_GAME_EVENT_VALUE_TEAM]]++; + pen_attempted[uni(i).possession]++; } else break; if(pen_attempted[0] + pen_attempted[1] >= 10) - return (match->fix->result[0][2] != match->fix->result[1][2]); + return (match->fix->result[0][2] != match->fix->result[1][2] && + pen_attempted[0] == pen_attempted[1]); return (match->fix->result[0][2] - match->fix->result[1][2] > 5 - pen_attempted[1] || @@ -959,8 +873,7 @@ live_game_get_time(const LiveGameUnit *unit) return time; } -/** Return the minute for the next game unit. This depends on - #CONSTANT_LIVE_GAME_UNITS_PER_MINUTE. +/** Return the minute for the next game unit. @return A new minute for a LiveGameUnit. */ gint live_game_get_minute(void) @@ -975,7 +888,7 @@ live_game_get_minute(void) last_unit.time == LIVE_GAME_UNIT_TIME_PENALTIES) return 120; - for(i=units->len - 1; i>=0; i--) + for(i=unis->len - 1; i>=0; i--) if(uni(i).minute != -1) return uni(i).minute + 1; @@ -991,12 +904,12 @@ live_game_unit_get_minute(const LiveGameUnit *unit) { gint i, j; - for(i=units->len -1; i >= 0; i--) + for(i=unis->len - 1; i >= 0; i--) if(&uni(i) == unit) break; if(i == -1) - g_warning("live_game_unit_get_minute: reached end of units array.\n"); + g_warning("live_game_unit_get_minute: reached end of unis array.\n"); else for(j=i;j>=0;j--) if(uni(j).minute != -1) @@ -1010,11 +923,19 @@ live_game_unit_get_minute(const LiveGameUnit *unit) void live_game_reset(Fixture *fix) { - match = query_my_team_involved(fix) ? &live_game : &live_game_temp; - show = (query_my_team_involved(fix) && options[OPT_BOOL_SHOW_LIVE]); + match = (fixture_user_team_involved(fix) != -1) ? + &usr(fixture_user_team_involved(fix)).live_game : &live_game_temp; + show = (fixture_user_team_involved(fix) != -1 && + option_int("int_opt_user_show_live_game", + usr(fixture_user_team_involved(fix)).options)); + + stat2 = fixture_user_team_involved(fix); + + if(show && window.live == NULL) + window.live = window_create(WINDOW_LIVE); free_live_game(match); - units = g_array_new(FALSE, FALSE, sizeof(LiveGameUnit)); + unis = g_array_new(FALSE, FALSE, sizeof(LiveGameUnit)); match->fix = fix; match->subs_left[0] = match->subs_left[1] = 3; @@ -1022,17 +943,18 @@ live_game_reset(Fixture *fix) if(fix->home_advantage) match->home_advantage = - math_rnd(CONSTANT_GAME_HOME_ADVANTAGE_LOWER, - CONSTANT_GAME_HOME_ADVANTAGE_UPPER); + math_rnd(const_float("float_game_home_advantage_lower"), + const_float("float_game_home_advantage_upper")); game_get_values(match->fix, match->team_values, match->home_advantage); } -/** Generate commentary for the live game event in the unit. +/** Generate commentary for the live game event in the unit + and show the unit in the live game window. @param unit The unit we comment. */ void -live_game_generate_commentary(LiveGameUnit *unit) +live_game_generate_commentary(LiveGameUnit *unit, gboolean show_unit) { GString *commentary = unit->event.commentary; @@ -1165,6 +1087,9 @@ live_game_generate_commentary(LiveGameUnit *unit) g_string_printf(commentary, "There are riots in the stadium."); break; } + + if(show && show_unit) + game_gui_live_game_show_unit(unit); } /** Assemble some stats like ball possession or shots @@ -1178,13 +1103,13 @@ live_game_create_stats(void) for(i=0;ivalues[0][i] = stat->values[1][i] = 0; - + stat->values[0][LIVE_GAME_STAT_VALUE_GOALS] = math_sum_int_array(match->fix->result[0], 2); stat->values[1][LIVE_GAME_STAT_VALUE_GOALS] = math_sum_int_array(match->fix->result[1], 2); - for(i=0;ilen;i++) + for(i=0;ilen;i++) { if(uni(i).minute != -1) possession[uni(i).possession]++; @@ -1215,22 +1140,23 @@ live_game_create_stats(void) stat->values[1][LIVE_GAME_STAT_VALUE_POSSESSION] = 100 - stat->values[0][LIVE_GAME_STAT_VALUE_POSSESSION]; - printf("goals\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_GOALS], - stat->values[1][LIVE_GAME_STAT_VALUE_GOALS]); - printf("shots\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_SHOTS], - stat->values[1][LIVE_GAME_STAT_VALUE_SHOTS]); - printf("poss\t %d%% \t %d%%\n", stat->values[0][LIVE_GAME_STAT_VALUE_POSSESSION], - stat->values[1][LIVE_GAME_STAT_VALUE_POSSESSION]); - printf("pen.\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_PENALTIES], - stat->values[1][LIVE_GAME_STAT_VALUE_PENALTIES]); - printf("fouls\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_FOULS], - stat->values[1][LIVE_GAME_STAT_VALUE_FOULS]); - printf("cards\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_CARDS], - stat->values[1][LIVE_GAME_STAT_VALUE_CARDS]); - printf("reds\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_REDS], - stat->values[1][LIVE_GAME_STAT_VALUE_REDS]); - printf("inj.\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_INJURIES], - stat->values[1][LIVE_GAME_STAT_VALUE_INJURIES]); +/*d*/ +/* printf("goals\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_GOALS], */ +/* stat->values[1][LIVE_GAME_STAT_VALUE_GOALS]); */ +/* printf("shots\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_SHOTS], */ +/* stat->values[1][LIVE_GAME_STAT_VALUE_SHOTS]); */ +/* printf("poss\t %d%% \t %d%%\n", stat->values[0][LIVE_GAME_STAT_VALUE_POSSESSION], */ +/* stat->values[1][LIVE_GAME_STAT_VALUE_POSSESSION]); */ +/* printf("pen.\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_PENALTIES], */ +/* stat->values[1][LIVE_GAME_STAT_VALUE_PENALTIES]); */ +/* printf("fouls\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_FOULS], */ +/* stat->values[1][LIVE_GAME_STAT_VALUE_FOULS]); */ +/* printf("cards\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_CARDS], */ +/* stat->values[1][LIVE_GAME_STAT_VALUE_CARDS]); */ +/* printf("reds\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_REDS], */ +/* stat->values[1][LIVE_GAME_STAT_VALUE_REDS]); */ +/* printf("inj.\t %d \t %d\n", stat->values[0][LIVE_GAME_STAT_VALUE_INJURIES], */ +/* stat->values[1][LIVE_GAME_STAT_VALUE_INJURIES]); */ } /** Calculate which area the ball is going to be in in @@ -1240,19 +1166,17 @@ live_game_create_stats(void) gint live_game_get_area(const LiveGameUnit *unit) { - /*d*/ - gint i; gint new_area = unit->area; gfloat rndom = math_rnd(0, 1); gfloat probs[4] = - {CONSTANT_LIVE_GAME_AREA_DEF_MID * - live_game_pit_teams(unit, CONSTANT_LIVE_GAME_AREA_DEF_MID_TEAM_EXPONENT), - CONSTANT_LIVE_GAME_AREA_MID_ATT * - live_game_pit_teams(unit, CONSTANT_LIVE_GAME_AREA_MID_TEAM_EXPONENT), - CONSTANT_LIVE_GAME_AREA_MID_DEF / - live_game_pit_teams(unit, CONSTANT_LIVE_GAME_AREA_MID_TEAM_EXPONENT), - CONSTANT_LIVE_GAME_AREA_ATT_MID / - live_game_pit_teams(unit, CONSTANT_LIVE_GAME_AREA_ATT_MID_TEAM_EXPONENT)}; + {const_float("float_live_game_area_def_mid") * + live_game_pit_teams(unit, const_float("float_live_game_area_def_mid_team_exponent")), + const_float("float_live_game_area_mid_att") * + live_game_pit_teams(unit, const_float("float_live_game_area_mid_team_exponent")), + const_float("float_live_game_area_mid_def") / + live_game_pit_teams(unit, const_float("float_live_game_area_mid_team_exponent")), + const_float("float_live_game_area_att_mid") / + live_game_pit_teams(unit, const_float("float_live_game_area_att_mid_team_exponent"))}; if(unit->area == LIVE_GAME_UNIT_AREA_DEFEND && rndom < probs[0]) new_area = LIVE_GAME_UNIT_AREA_MIDFIELD; @@ -1267,8 +1191,6 @@ live_game_get_area(const LiveGameUnit *unit) if(rndom < probs[3]) new_area = LIVE_GAME_UNIT_AREA_MIDFIELD; - if(debug) - printf("**** new area %d\n", new_area); return new_area; } @@ -1305,7 +1227,7 @@ live_game_event_injury_get_player(void) for(j=0;j<2;j++) { - probs[j * 11] = CONSTANT_LIVE_GAME_INJURY_GOALIE_FACTOR * + probs[j * 11] = const_float("float_live_game_injury_goalie_factor") * (gfloat)(100 - player_of(tm[j], 0)->fitness) * (player_of(tm[j], 0)->cskill != 0); for(i=1;i<11;i++) diff --git a/src/live_game.h b/src/live_game.h index e58b7ab8..5a4921bc 100644 --- a/src/live_game.h +++ b/src/live_game.h @@ -65,7 +65,7 @@ void live_game_event_send_off(gint team, gint player); void -live_game_generate_commentary(LiveGameUnit *unit); +live_game_generate_commentary(LiveGameUnit *unit, gboolean show_unit); void live_game_event_duel(void); diff --git a/src/live_game_struct.h b/src/live_game_struct.h index e704e495..d036170f 100644 --- a/src/live_game_struct.h +++ b/src/live_game_struct.h @@ -141,6 +141,9 @@ typedef struct like a substitution that doesn't count as a match time consuming event. @see #GameUnitTime */ gint minute, time; + + /** The match result at the time of this unit. */ + gint result[2]; /** The event belonging to the game unit. */ LiveGameEvent event; @@ -165,9 +168,8 @@ typedef struct gfloat home_advantage; /** The array of units. @see #GameUnit */ GArray *units; + /** Match statistics. @see #LiveGameStats */ LiveGameStats stats; - GtkWidget *window; - } LiveGame; #endif diff --git a/src/main.c b/src/main.c index bb77f577..eb3d9447 100644 --- a/src/main.c +++ b/src/main.c @@ -6,6 +6,7 @@ #include /*d*/ +#include "misc_callbacks.h" #include "file.h" #include "free.h" #include "main.h" @@ -22,17 +23,21 @@ main_init_variables(void) country.name = country.symbol = country.sid = NULL; transfer_list = NULL; player_names = NULL; - my_team = NULL; - - font_name = g_string_new("0"); - debug = FALSE; - live_game.units = g_array_new(FALSE, FALSE, sizeof(LiveGameUnit)); - live_game.window = NULL; - live_game_temp.units = g_array_new(FALSE, FALSE, sizeof(LiveGameUnit)); - live_game_temp.window = NULL; + window.main = window.startup = window.startup_users = + window.live = NULL; + + live_game_temp.units = NULL; + + users = g_array_new(FALSE, FALSE, sizeof(User)); + + options = g_array_new(FALSE, FALSE, sizeof(Option)); + constants = g_array_new(FALSE, FALSE, sizeof(Option)); popups_active = 0; + selected_row[0] = selected_row[1] = -1; + + file_load_conf_files(); } /** @@ -70,25 +75,33 @@ main_init(gint argc, gchar *argv[]) gint main (gint argc, gchar *argv[]) { + gint x_pos, y_pos; #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif - - gtk_set_locale (); - gtk_init (&argc, &argv); + + gtk_set_locale (); + gtk_init (&argc, &argv); - main_init(argc, argv); + main_init(argc, argv); - window_show_startup(); + window_create(WINDOW_STARTUP_USERS); + window_show_startup(); + gtk_window_get_position(GTK_WINDOW(window.startup), &x_pos, &y_pos); + gtk_window_move(GTK_WINDOW(window.startup_users), x_pos, y_pos); + stat0 = STATUS_TEAM_SELECTION; + /*d*/ + on_button_add_player_clicked(NULL, NULL); + - gtk_main (); + gtk_main (); - main_exit_program(EXIT_OK, NULL); + main_exit_program(EXIT_OK, NULL); - return 0; + return 0; } /** Exit the program with the given exit code and message. Try to diff --git a/src/maths.c b/src/maths.c index 5f243495..ebaca6e6 100644 --- a/src/maths.c +++ b/src/maths.c @@ -158,11 +158,11 @@ math_get_bye_len(gint number) { gint i; - for(i=10;i>=0;i--) - if((gint)powf(2, i) <= number) + for(i=0;i<20;i++) + if((gint)powf(2, i) >= number) break; - return number - (gint)powf(2, i); + return (gint)powf(2, i) - number; } /** Return the sum of the integers in the array. @@ -170,7 +170,7 @@ math_get_bye_len(gint number) @param max The size of the array. @return The sum of all the integers in the array. */ gint -math_sum_int_array(gint *array, gint max) +math_sum_int_array(const gint *array, gint max) { gint i, sum = 0; diff --git a/src/maths.h b/src/maths.h index 859a7091..a014428e 100644 --- a/src/maths.h +++ b/src/maths.h @@ -31,6 +31,6 @@ gint math_get_bye_len(gint number); gint -math_sum_int_array(gint *array, gint max); +math_sum_int_array(const gint *array, gint max); #endif diff --git a/src/misc2_interface.c b/src/misc2_interface.c index 2ea03b60..ec8c11df 100644 --- a/src/misc2_interface.c +++ b/src/misc2_interface.c @@ -95,7 +95,6 @@ create_stadium_window (void) label1 = gtk_label_new (_("Increase (seats)")); gtk_widget_show (label1); gtk_box_pack_start (GTK_BOX (vbox2), label1, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label1), GTK_JUSTIFY_LEFT); hseparator1 = gtk_hseparator_new (); gtk_widget_show (hseparator1); @@ -139,7 +138,6 @@ create_stadium_window (void) label2 = gtk_label_new (_("Costs")); gtk_widget_show (label2); gtk_box_pack_start (GTK_BOX (vbox3), label2, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label2), GTK_JUSTIFY_LEFT); hseparator2 = gtk_hseparator_new (); gtk_widget_show (hseparator2); @@ -149,25 +147,21 @@ create_stadium_window (void) label_cost0 = gtk_label_new (_("label4")); gtk_widget_show (label_cost0); gtk_box_pack_start (GTK_BOX (vbox3), label_cost0, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label_cost0), GTK_JUSTIFY_LEFT); gtk_misc_set_padding (GTK_MISC (label_cost0), 0, 4); label_cost1 = gtk_label_new (_("label5")); gtk_widget_show (label_cost1); gtk_box_pack_start (GTK_BOX (vbox3), label_cost1, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label_cost1), GTK_JUSTIFY_LEFT); gtk_misc_set_padding (GTK_MISC (label_cost1), 0, 4); label_cost2 = gtk_label_new (_("label6")); gtk_widget_show (label_cost2); gtk_box_pack_start (GTK_BOX (vbox3), label_cost2, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label_cost2), GTK_JUSTIFY_LEFT); gtk_misc_set_padding (GTK_MISC (label_cost2), 0, 4); label_cost3 = gtk_label_new (_("label7")); gtk_widget_show (label_cost3); gtk_box_pack_start (GTK_BOX (vbox3), label_cost3, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label_cost3), GTK_JUSTIFY_LEFT); gtk_misc_set_padding (GTK_MISC (label_cost3), 0, 4); vseparator2 = gtk_vseparator_new (); @@ -182,7 +176,6 @@ create_stadium_window (void) label3 = gtk_label_new (_("Finished (weeks)")); gtk_widget_show (label3); gtk_box_pack_start (GTK_BOX (vbox4), label3, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label3), GTK_JUSTIFY_LEFT); hseparator3 = gtk_hseparator_new (); gtk_widget_show (hseparator3); @@ -192,25 +185,21 @@ create_stadium_window (void) label8 = gtk_label_new (_("Before next match")); gtk_widget_show (label8); gtk_box_pack_start (GTK_BOX (vbox4), label8, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label8), GTK_JUSTIFY_LEFT); gtk_misc_set_padding (GTK_MISC (label8), 0, 3); label_finished0 = gtk_label_new (_("1-2")); gtk_widget_show (label_finished0); gtk_box_pack_start (GTK_BOX (vbox4), label_finished0, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label_finished0), GTK_JUSTIFY_LEFT); gtk_misc_set_padding (GTK_MISC (label_finished0), 0, 3); label_finished1 = gtk_label_new (_("3-4")); gtk_widget_show (label_finished1); gtk_box_pack_start (GTK_BOX (vbox4), label_finished1, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label_finished1), GTK_JUSTIFY_LEFT); gtk_misc_set_padding (GTK_MISC (label_finished1), 0, 3); label_finished2 = gtk_label_new (_("5-6")); gtk_widget_show (label_finished2); gtk_box_pack_start (GTK_BOX (vbox4), label_finished2, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label_finished2), GTK_JUSTIFY_LEFT); gtk_misc_set_padding (GTK_MISC (label_finished2), 0, 3); hseparator4 = gtk_hseparator_new (); @@ -246,7 +235,6 @@ create_stadium_window (void) label12 = gtk_label_new_with_mnemonic (_("OK")); gtk_widget_show (label12); gtk_box_pack_start (GTK_BOX (hbox3), label12, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label12), GTK_JUSTIFY_LEFT); button_cancel = gtk_button_new (); gtk_widget_show (button_cancel); @@ -272,7 +260,6 @@ create_stadium_window (void) label13 = gtk_label_new_with_mnemonic (_("Cancel")); gtk_widget_show (label13); gtk_box_pack_start (GTK_BOX (hbox4), label13, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label13), GTK_JUSTIFY_LEFT); g_signal_connect ((gpointer) stadium_window, "delete_event", G_CALLBACK (on_button_cancel_clicked), @@ -384,7 +371,6 @@ create_job_offer_window (void) label20 = gtk_label_new (_("label20")); gtk_widget_show (label20); gtk_box_pack_start (GTK_BOX (vbox5), label20, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label20), GTK_JUSTIFY_LEFT); hseparator5 = gtk_hseparator_new (); gtk_widget_show (hseparator5); @@ -402,37 +388,31 @@ create_job_offer_window (void) label15 = gtk_label_new (_("Name")); gtk_widget_show (label15); gtk_box_pack_start (GTK_BOX (vbox6), label15, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label15), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label15), 2.23517e-10, 0.5); label16 = gtk_label_new (_("League")); gtk_widget_show (label16); gtk_box_pack_start (GTK_BOX (vbox6), label16, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label16), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label16), 2.23517e-10, 0.5); label17 = gtk_label_new (_("Rank")); gtk_widget_show (label17); gtk_box_pack_start (GTK_BOX (vbox6), label17, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label17), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label17), 2.23517e-10, 0.5); label18 = gtk_label_new (_("Money (approx.)")); gtk_widget_show (label18); gtk_box_pack_start (GTK_BOX (vbox6), label18, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label18), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label18), 2.23517e-10, 0.5); label19 = gtk_label_new (_("Stadium capacity")); gtk_widget_show (label19); gtk_box_pack_start (GTK_BOX (vbox6), label19, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label19), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label19), 2.23517e-10, 0.5); label14 = gtk_label_new (_("Stadium safety")); gtk_widget_show (label14); gtk_box_pack_start (GTK_BOX (vbox6), label14, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label14), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label14), 0, 0.5); vseparator3 = gtk_vseparator_new (); @@ -447,32 +427,26 @@ create_job_offer_window (void) label21 = gtk_label_new (_("label21")); gtk_widget_show (label21); gtk_box_pack_start (GTK_BOX (vbox7), label21, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label21), GTK_JUSTIFY_LEFT); label22 = gtk_label_new (_("label22")); gtk_widget_show (label22); gtk_box_pack_start (GTK_BOX (vbox7), label22, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label22), GTK_JUSTIFY_LEFT); label23 = gtk_label_new (_("label23")); gtk_widget_show (label23); gtk_box_pack_start (GTK_BOX (vbox7), label23, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label23), GTK_JUSTIFY_LEFT); label24 = gtk_label_new (_("label24")); gtk_widget_show (label24); gtk_box_pack_start (GTK_BOX (vbox7), label24, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label24), GTK_JUSTIFY_LEFT); label25 = gtk_label_new (_("label25")); gtk_widget_show (label25); gtk_box_pack_start (GTK_BOX (vbox7), label25, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label25), GTK_JUSTIFY_LEFT); label26 = gtk_label_new (_("label26")); gtk_widget_show (label26); gtk_box_pack_start (GTK_BOX (vbox7), label26, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label26), GTK_JUSTIFY_LEFT); hseparator6 = gtk_hseparator_new (); gtk_widget_show (hseparator6); @@ -482,7 +456,6 @@ create_job_offer_window (void) label28 = gtk_label_new (_("Player list")); gtk_widget_show (label28); gtk_box_pack_start (GTK_BOX (vbox5), label28, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label28), GTK_JUSTIFY_LEFT); scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL); gtk_widget_show (scrolledwindow1); @@ -501,7 +474,6 @@ create_job_offer_window (void) label27 = gtk_label_new (_("label27")); gtk_widget_show (label27); gtk_box_pack_start (GTK_BOX (vbox5), label27, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label27), GTK_JUSTIFY_LEFT); gtk_misc_set_padding (GTK_MISC (label27), 0, 5); hbox6 = gtk_hbox_new (FALSE, 0); @@ -528,7 +500,6 @@ create_job_offer_window (void) label31 = gtk_label_new_with_mnemonic (_("OK")); gtk_widget_show (label31); gtk_box_pack_start (GTK_BOX (hbox9), label31, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label31), GTK_JUSTIFY_LEFT); button_cancel = gtk_button_new (); gtk_widget_show (button_cancel); @@ -550,7 +521,6 @@ create_job_offer_window (void) label30 = gtk_label_new_with_mnemonic (_("Cancel")); gtk_widget_show (label30); gtk_box_pack_start (GTK_BOX (hbox8), label30, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label30), GTK_JUSTIFY_LEFT); g_signal_connect ((gpointer) button_ok, "clicked", G_CALLBACK (on_button_offer_ok_clicked), @@ -666,7 +636,6 @@ create_graph_window (void) label_title = gtk_label_new (_("Statistics")); gtk_widget_show (label_title); gtk_box_pack_start (GTK_BOX (vbox8), label_title, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label_title), GTK_JUSTIFY_LEFT); vbox9 = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox9); @@ -687,32 +656,26 @@ create_graph_window (void) label36 = gtk_label_new (_("label36")); gtk_widget_show (label36); gtk_box_pack_start (GTK_BOX (vbox10), label36, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label36), GTK_JUSTIFY_LEFT); label37 = gtk_label_new (_("label37")); gtk_widget_show (label37); gtk_box_pack_start (GTK_BOX (vbox10), label37, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label37), GTK_JUSTIFY_LEFT); label38 = gtk_label_new (_("label38")); gtk_widget_show (label38); gtk_box_pack_start (GTK_BOX (vbox10), label38, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label38), GTK_JUSTIFY_LEFT); label39 = gtk_label_new (_("label39")); gtk_widget_show (label39); gtk_box_pack_start (GTK_BOX (vbox10), label39, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label39), GTK_JUSTIFY_LEFT); label40 = gtk_label_new (_("label40")); gtk_widget_show (label40); gtk_box_pack_start (GTK_BOX (vbox10), label40, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label40), GTK_JUSTIFY_LEFT); label41 = gtk_label_new (""); gtk_widget_show (label41); gtk_box_pack_start (GTK_BOX (vbox12), label41, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label41), GTK_JUSTIFY_LEFT); vbox11 = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox11); @@ -736,7 +699,6 @@ create_graph_window (void) label33 = gtk_label_new (_("Weeks / Seasons")); gtk_widget_show (label33); gtk_box_pack_start (GTK_BOX (vbox9), label33, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label33), GTK_JUSTIFY_LEFT); hseparator8 = gtk_hseparator_new (); gtk_widget_show (hseparator8); @@ -842,7 +804,6 @@ create_graph_window (void) label35 = gtk_label_new_with_mnemonic (_("Close")); gtk_widget_show (label35); gtk_box_pack_start (GTK_BOX (hbox14), label35, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label35), GTK_JUSTIFY_LEFT); g_signal_connect ((gpointer) graph_window, "delete_event", G_CALLBACK (on_graph_window_delete_event), diff --git a/src/misc_callback_func.c b/src/misc_callback_func.c index 846393de..bca00691 100644 --- a/src/misc_callback_func.c +++ b/src/misc_callback_func.c @@ -1,3 +1,4 @@ +#include "game_gui.h" #include "misc_callback_func.h" #include "start_end.h" #include "support.h" @@ -19,7 +20,7 @@ misc_callback_show_team_list(GtkWidget *widget, const gchar *country_file) xml_country_read(country_file); - treeview_show_team_list(GTK_TREE_VIEW(treeview_startup), FALSE); + treeview_show_team_list(GTK_TREE_VIEW(treeview_startup), FALSE, FALSE); /*d*/ /* for(i=0;ilen;i++) */ @@ -50,25 +51,99 @@ misc_callback_show_team_list(GtkWidget *widget, const gchar *country_file) /* } */ } -/** Start a new game after the user's selected a team. - @param widget A widget from the startup window that enables us - to get the row in the team list the user has selected. */ +/** Start a new game after users and teams are selected. */ void -misc_callback_start_game(GtkWidget *widget) +misc_callback_start_game(void) { - GtkTreeView *treeview = - GTK_TREE_VIEW(lookup_widget(widget, "treeview_startup")); - GtkWidget *window_startup = - lookup_widget(widget, "window_startup"); - - my_team = treeview_get_pointer(treeview, 2); + gint i; + + stat0 = STATUS_MAIN; + start_new_game(); - user_set_up_my_team_new_game(widget); + for(i=0;ilen;i++) + user_set_up_team_new_game(&usr(i)); - window_destroy(&window_startup); + window_destroy(&window.startup); + window_destroy(&window.startup_users); - window_show_main(); + window_create(WINDOW_MAIN); - treeview_show_user_player_list(1); + game_gui_show_main(); +} + +/** Add a user to the users array. */ +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 = + GTK_TREE_VIEW(lookup_widget(window.startup, "treeview_startup")); + GtkEntry *entry_player_name = + GTK_ENTRY(lookup_widget(window.startup, "entry_player_name")); + const gchar *player_name = gtk_entry_get_text(entry_player_name); + User new_user = user_new(); + + if(strlen(player_name) > 0) + g_string_printf(new_user.name, "%s", 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 = treeview_get_pointer(treeview, 2); + + g_array_append_val(users, new_user); + + treeview_show_users_startup(); + + treeview_show_team_list(GTK_TREE_VIEW(lookup_widget(window.startup, "treeview_startup")), + FALSE, FALSE); + + if(users->len == 1) + { + gtk_widget_set_sensitive(lookup_widget(window.startup, "team_selection_ok"), TRUE); + gtk_widget_set_sensitive(lookup_widget(window.startup, "combo_country"), FALSE); + } +} + +/** Remove a user from the users list. + @param event The mouse click event on the treeview. */ +void +misc_callback_remove_user(GdkEventButton *event) +{ + GtkTreeView *treeview = + GTK_TREE_VIEW(lookup_widget(window.startup_users, "treeview_users")); + + treeview_select_row(treeview, event); + + user_remove(treeview_get_index(treeview, 0) - 1, FALSE); + + treeview_show_users_startup(); + + if(users->len == 0) + { + gtk_widget_set_sensitive(lookup_widget(window.startup, "team_selection_ok"), FALSE); + gtk_widget_set_sensitive(lookup_widget(window.startup, "combo_country"), TRUE); + } +} + +/** Stop the live game so that users can make subs etc. */ +void +misc_callback_pause_live_game(void) +{ + gtk_widget_hide(lookup_widget(window.live, "button_pause")); + gtk_widget_show(lookup_widget(window.live, "button_resume")); + + game_gui_set_main_window_sensitivity(TRUE); + + stat0 = STATUS_LIVE_GAME_PAUSE; } diff --git a/src/misc_callback_func.h b/src/misc_callback_func.h index 5b676620..042c4033 100644 --- a/src/misc_callback_func.h +++ b/src/misc_callback_func.h @@ -4,9 +4,18 @@ #include "bygfoot.h" void -misc_callback_start_game(GtkWidget *widget); +misc_callback_start_game(void); void misc_callback_show_team_list(GtkWidget *widget, const gchar *country_file); +void +misc_callback_add_player(void); + +void +misc_callback_remove_user(GdkEventButton *event); + +void +misc_callback_pause_live_game(void); + #endif diff --git a/src/misc_callbacks.c b/src/misc_callbacks.c index 4c416b55..294d2564 100644 --- a/src/misc_callbacks.c +++ b/src/misc_callbacks.c @@ -1,12 +1,39 @@ #include - +#include "callback_func.h" #include "free.h" +#include "game_gui.h" +#include "live_game.h" #include "misc_callback_func.h" #include "misc_callbacks.h" +#include "option.h" +#include "user.h" #include "variables.h" #include "window.h" +void +on_button_add_player_clicked (GtkButton *button, + gpointer user_data) +{ + misc_callback_add_player(); +} + + +void +on_entry_player_name_activate (GtkEntry *entry, + gpointer user_data) +{ + on_button_add_player_clicked(NULL, NULL); +} + + +void +on_team_selection_ok_clicked (GtkButton *button, + gpointer user_data) +{ + misc_callback_start_game(); +} + void on_team_selection_cancel_clicked (GtkButton *button, gpointer user_data) @@ -22,7 +49,8 @@ on_team_selection_tv_row_activated (GtkTreeView *treeview, GtkTreeViewColumn *column, gpointer user_data) { - misc_callback_start_game(GTK_WIDGET(treeview)); + if(GTK_WIDGET_IS_SENSITIVE(lookup_widget(window.startup, "team_selection_ok"))) + misc_callback_start_game(); } @@ -66,16 +94,6 @@ on_button_start_editor_clicked (GtkButton *button, } -void -on_team_selection_ok_clicked (GtkButton *button, - gpointer user_data) -{ - - misc_callback_start_game(GTK_WIDGET(button)); - -} - - void on_team_selection_load_clicked (GtkButton *button, gpointer user_data) @@ -192,7 +210,7 @@ void on_button_live_close_clicked (GtkButton *button, gpointer user_data) { - window_destroy(&live_game.window); + callback_show_next_live_game(); } @@ -222,7 +240,7 @@ void on_button_pause_clicked (GtkButton *button, gpointer user_data) { - + misc_callback_pause_live_game(); } @@ -230,14 +248,29 @@ void on_button_resume_clicked (GtkButton *button, gpointer user_data) { - + gtk_widget_hide(GTK_WIDGET(button)); + gtk_widget_show(lookup_widget(window.live, "button_pause")); + game_gui_set_main_window_sensitivity(FALSE); + live_game_calculate_fixture(NULL); } void on_spinbutton_speed_value_changed (GtkSpinButton *spinbutton, gpointer user_data) { - options[OPT_LIVE_SPEED] = - gtk_spin_button_get_value_as_int(spinbutton); + option_set_int("int_opt_user_live_game_speed", + usr(stat2).options, gtk_spin_button_get_value_as_int(spinbutton)); } + + +gboolean +on_treeview_users_button_press_event (GtkWidget *widget, + GdkEventButton *event, + gpointer user_data) +{ + misc_callback_remove_user(event); + + + return FALSE; +} diff --git a/src/misc_callbacks.h b/src/misc_callbacks.h index b01c02b3..d524abd9 100644 --- a/src/misc_callbacks.h +++ b/src/misc_callbacks.h @@ -115,8 +115,22 @@ void on_button_resume_clicked (GtkButton *button, gpointer user_data); -#endif void on_spinbutton_speed_value_changed (GtkSpinButton *spinbutton, gpointer user_data); + +void +on_button_add_player_clicked (GtkButton *button, + gpointer user_data); + +#endif + +gboolean +on_treeview_users_button_press_event (GtkWidget *widget, + GdkEventButton *event, + gpointer user_data); + +void +on_entry_player_name_activate (GtkEntry *entry, + gpointer user_data); diff --git a/src/misc_interface.c b/src/misc_interface.c index 5cee1caf..e4d54f77 100644 --- a/src/misc_interface.c +++ b/src/misc_interface.c @@ -34,14 +34,6 @@ create_window_startup (void) GtkWidget *scrolledwindow1; GtkWidget *treeview_startup; GtkWidget *hseparator10; - GtkWidget *label4; - GtkWidget *eventbox1; - GtkWidget *hbox2; - GtkWidget *team_selection_radio1; - GSList *team_selection_radio1_group = NULL; - GtkWidget *team_selection_radio2; - GtkWidget *team_selection_radio3; - GtkWidget *hseparator11; GtkWidget *vbox34; GtkWidget *label69; GtkWidget *hbox44; @@ -53,24 +45,30 @@ create_window_startup (void) GtkWidget *hbox45; GtkWidget *image45; GtkWidget *label70; + GtkWidget *hseparator11; + GtkWidget *label4; + GtkWidget *eventbox1; + GtkWidget *hbox2; + GtkWidget *team_selection_radio1; + GSList *team_selection_radio1_group = NULL; + GtkWidget *team_selection_radio2; + GtkWidget *team_selection_radio3; GtkWidget *hseparator12; - GtkWidget *hbox46; - GtkWidget *vbox35; - GtkWidget *checkbutton_no_def; - GtkWidget *checkbutton_only_names; - GtkWidget *checkbutton_load_my_team; - GtkWidget *vseparator18; - GtkWidget *button_start_editor; - GtkWidget *alignment15; - GtkWidget *hbox47; - GtkWidget *image55; - GtkWidget *label71; + GtkWidget *hbox54; + GtkWidget *label75; + GtkWidget *entry_player_name; + GtkWidget *button_add_player; + GtkWidget *alignment19; + GtkWidget *hbox55; + GtkWidget *image59; + GtkWidget *label76; + GtkWidget *hseparator13; GtkWidget *hbox3; GtkWidget *team_selection_ok; - GtkWidget *alignment1; - GtkWidget *hbox4; - GtkWidget *image2; - GtkWidget *label1; + GtkWidget *alignment18; + GtkWidget *hbox53; + GtkWidget *image58; + GtkWidget *label74; GtkWidget *team_selection_cancel; GtkWidget *alignment2; GtkWidget *hbox5; @@ -116,47 +114,6 @@ create_window_startup (void) gtk_box_pack_start (GTK_BOX (vbox2), hseparator10, FALSE, FALSE, 0); gtk_widget_set_size_request (hseparator10, 1, 10); - label4 = gtk_label_new (_("Start in")); - gtk_widget_show (label4); - gtk_box_pack_start (GTK_BOX (vbox2), label4, FALSE, FALSE, 0); - gtk_misc_set_alignment (GTK_MISC (label4), 0.05, 0.5); - - eventbox1 = gtk_event_box_new (); - gtk_widget_show (eventbox1); - gtk_box_pack_start (GTK_BOX (vbox2), eventbox1, FALSE, TRUE, 5); - gtk_tooltips_set_tip (tooltips, eventbox1, _("Play normal league games and cups"), NULL); - - hbox2 = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox2); - gtk_container_add (GTK_CONTAINER (eventbox1), hbox2); - - 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)); - - hseparator11 = gtk_hseparator_new (); - gtk_widget_show (hseparator11); - gtk_box_pack_start (GTK_BOX (vbox2), hseparator11, FALSE, FALSE, 0); - gtk_widget_set_size_request (hseparator11, 1, 10); - vbox34 = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox34); gtk_box_pack_start (GTK_BOX (vbox2), vbox34, FALSE, TRUE, 5); @@ -206,64 +163,90 @@ create_window_startup (void) gtk_widget_show (label70); gtk_box_pack_start (GTK_BOX (hbox45), label70, FALSE, FALSE, 0); + hseparator11 = gtk_hseparator_new (); + gtk_widget_show (hseparator11); + gtk_box_pack_start (GTK_BOX (vbox2), hseparator11, FALSE, FALSE, 0); + gtk_widget_set_size_request (hseparator11, 1, 10); + + label4 = gtk_label_new (_("Start in")); + gtk_widget_show (label4); + gtk_box_pack_start (GTK_BOX (vbox2), label4, FALSE, FALSE, 0); + gtk_misc_set_alignment (GTK_MISC (label4), 0.05, 0.5); + + eventbox1 = gtk_event_box_new (); + gtk_widget_show (eventbox1); + gtk_box_pack_start (GTK_BOX (vbox2), eventbox1, FALSE, TRUE, 5); + gtk_tooltips_set_tip (tooltips, eventbox1, _("Play normal league games and cups"), NULL); + + hbox2 = gtk_hbox_new (FALSE, 0); + gtk_widget_show (hbox2); + gtk_container_add (GTK_CONTAINER (eventbox1), hbox2); + + 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 (); gtk_widget_show (hseparator12); gtk_box_pack_start (GTK_BOX (vbox2), hseparator12, FALSE, FALSE, 0); gtk_widget_set_size_request (hseparator12, 1, 10); - hbox46 = gtk_hbox_new (FALSE, 0); - gtk_widget_show (hbox46); - gtk_box_pack_start (GTK_BOX (vbox2), hbox46, FALSE, TRUE, 0); + hbox54 = gtk_hbox_new (FALSE, 5); + gtk_widget_show (hbox54); + gtk_box_pack_start (GTK_BOX (vbox2), hbox54, FALSE, TRUE, 0); - vbox35 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (vbox35); - gtk_box_pack_start (GTK_BOX (hbox46), vbox35, FALSE, TRUE, 0); + label75 = gtk_label_new (_("Player name")); + gtk_widget_show (label75); + gtk_box_pack_start (GTK_BOX (hbox54), label75, FALSE, FALSE, 0); - checkbutton_no_def = gtk_check_button_new_with_mnemonic (_("Don't load team definitions")); - gtk_widget_show (checkbutton_no_def); - gtk_box_pack_start (GTK_BOX (vbox35), checkbutton_no_def, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (checkbutton_no_def), 2); - gtk_tooltips_set_tip (tooltips, checkbutton_no_def, _("If you check this, the game generates all players randomly and won't read the file with team definitions"), NULL); + entry_player_name = gtk_entry_new (); + gtk_widget_show (entry_player_name); + gtk_box_pack_start (GTK_BOX (hbox54), entry_player_name, TRUE, TRUE, 0); + gtk_entry_set_max_length (GTK_ENTRY (entry_player_name), 12); + gtk_entry_set_width_chars (GTK_ENTRY (entry_player_name), 12); - checkbutton_only_names = gtk_check_button_new_with_mnemonic (_("Load only names from team definition file")); - gtk_widget_show (checkbutton_only_names); - gtk_box_pack_start (GTK_BOX (vbox35), checkbutton_only_names, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (checkbutton_only_names), 2); - gtk_tooltips_set_tip (tooltips, checkbutton_only_names, _("If you check this, only the player names and the team structures are loaded from the definition file, values like skill or age are generated randomly"), NULL); + button_add_player = gtk_button_new (); + gtk_widget_show (button_add_player); + gtk_box_pack_start (GTK_BOX (hbox54), button_add_player, FALSE, FALSE, 0); - checkbutton_load_my_team = gtk_check_button_new_with_mnemonic (_("Load my team from definitions file")); - gtk_widget_show (checkbutton_load_my_team); - gtk_box_pack_start (GTK_BOX (vbox35), checkbutton_load_my_team, FALSE, FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (checkbutton_load_my_team), 2); - gtk_tooltips_set_tip (tooltips, checkbutton_load_my_team, _("Check this if you'd like to have your team loaded from the definitions file no matter what the other checkbuttons say."), NULL); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbutton_load_my_team), TRUE); + alignment19 = gtk_alignment_new (0.5, 0.5, 0, 0); + gtk_widget_show (alignment19); + gtk_container_add (GTK_CONTAINER (button_add_player), alignment19); - vseparator18 = gtk_vseparator_new (); - gtk_widget_show (vseparator18); - gtk_box_pack_start (GTK_BOX (hbox46), vseparator18, FALSE, TRUE, 0); - gtk_widget_set_size_request (vseparator18, 10, 1); + hbox55 = gtk_hbox_new (FALSE, 2); + gtk_widget_show (hbox55); + gtk_container_add (GTK_CONTAINER (alignment19), hbox55); - button_start_editor = gtk_button_new (); - gtk_widget_show (button_start_editor); - gtk_box_pack_start (GTK_BOX (hbox46), button_start_editor, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (button_start_editor), 3); - gtk_tooltips_set_tip (tooltips, button_start_editor, _("You can start the editor from the commandline with 'bygfoot -e' or '--editor'"), NULL); + image59 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_BUTTON); + gtk_widget_show (image59); + gtk_box_pack_start (GTK_BOX (hbox55), image59, FALSE, FALSE, 0); - alignment15 = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_show (alignment15); - gtk_container_add (GTK_CONTAINER (button_start_editor), alignment15); + label76 = gtk_label_new_with_mnemonic (_("Add player")); + gtk_widget_show (label76); + gtk_box_pack_start (GTK_BOX (hbox55), label76, FALSE, FALSE, 0); - hbox47 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox47); - gtk_container_add (GTK_CONTAINER (alignment15), hbox47); - - image55 = gtk_image_new_from_stock ("gtk-preferences", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image55); - gtk_box_pack_start (GTK_BOX (hbox47), image55, FALSE, FALSE, 0); - - label71 = gtk_label_new_with_mnemonic (_("Start Bygfoot Team Editor")); - gtk_widget_show (label71); - gtk_box_pack_start (GTK_BOX (hbox47), label71, FALSE, FALSE, 0); + hseparator13 = gtk_hseparator_new (); + gtk_widget_show (hseparator13); + gtk_box_pack_start (GTK_BOX (vbox2), hseparator13, FALSE, TRUE, 0); + gtk_widget_set_size_request (hseparator13, 1, 10); hbox3 = gtk_hbox_new (FALSE, 0); gtk_widget_show (hbox3); @@ -273,26 +256,27 @@ create_window_startup (void) gtk_widget_show (team_selection_ok); gtk_box_pack_start (GTK_BOX (hbox3), team_selection_ok, TRUE, TRUE, 0); gtk_container_set_border_width (GTK_CONTAINER (team_selection_ok), 2); - gtk_tooltips_set_tip (tooltips, team_selection_ok, _("Return"), NULL); + gtk_widget_set_sensitive (team_selection_ok, FALSE); + gtk_tooltips_set_tip (tooltips, team_selection_ok, _("Space"), NULL); gtk_widget_add_accelerator (team_selection_ok, "clicked", accel_group, - GDK_Return, 0, + GDK_space, 0, GTK_ACCEL_VISIBLE); - alignment1 = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_show (alignment1); - gtk_container_add (GTK_CONTAINER (team_selection_ok), alignment1); + alignment18 = gtk_alignment_new (0.5, 0.5, 0, 0); + gtk_widget_show (alignment18); + gtk_container_add (GTK_CONTAINER (team_selection_ok), alignment18); - hbox4 = gtk_hbox_new (FALSE, 2); - gtk_widget_show (hbox4); - gtk_container_add (GTK_CONTAINER (alignment1), hbox4); + hbox53 = gtk_hbox_new (FALSE, 2); + gtk_widget_show (hbox53); + gtk_container_add (GTK_CONTAINER (alignment18), hbox53); - image2 = gtk_image_new_from_stock ("gtk-apply", GTK_ICON_SIZE_BUTTON); - gtk_widget_show (image2); - gtk_box_pack_start (GTK_BOX (hbox4), image2, FALSE, FALSE, 0); + image58 = gtk_image_new_from_stock ("gtk-apply", GTK_ICON_SIZE_BUTTON); + gtk_widget_show (image58); + gtk_box_pack_start (GTK_BOX (hbox53), image58, FALSE, FALSE, 0); - label1 = gtk_label_new_with_mnemonic (_("OK")); - gtk_widget_show (label1); - gtk_box_pack_start (GTK_BOX (hbox4), label1, FALSE, FALSE, 0); + label74 = gtk_label_new_with_mnemonic (_("Start")); + gtk_widget_show (label74); + gtk_box_pack_start (GTK_BOX (hbox53), label74, FALSE, FALSE, 0); team_selection_cancel = gtk_button_new (); gtk_widget_show (team_selection_cancel); @@ -356,14 +340,11 @@ create_window_startup (void) g_signal_connect ((gpointer) button_select_country_file, "clicked", G_CALLBACK (on_button_select_country_file_clicked), NULL); - g_signal_connect ((gpointer) checkbutton_no_def, "toggled", - G_CALLBACK (on_checkbutton_load_randomly_toggled), + g_signal_connect ((gpointer) entry_player_name, "activate", + G_CALLBACK (on_entry_player_name_activate), NULL); - g_signal_connect ((gpointer) checkbutton_only_names, "toggled", - G_CALLBACK (on_checkbutton_only_names_toggled), - NULL); - g_signal_connect ((gpointer) button_start_editor, "clicked", - G_CALLBACK (on_button_start_editor_clicked), + g_signal_connect ((gpointer) button_add_player, "clicked", + G_CALLBACK (on_button_add_player_clicked), NULL); g_signal_connect ((gpointer) team_selection_ok, "clicked", G_CALLBACK (on_team_selection_ok_clicked), @@ -381,13 +362,6 @@ create_window_startup (void) GLADE_HOOKUP_OBJECT (window_startup, scrolledwindow1, "scrolledwindow1"); GLADE_HOOKUP_OBJECT (window_startup, treeview_startup, "treeview_startup"); GLADE_HOOKUP_OBJECT (window_startup, hseparator10, "hseparator10"); - GLADE_HOOKUP_OBJECT (window_startup, label4, "label4"); - GLADE_HOOKUP_OBJECT (window_startup, eventbox1, "eventbox1"); - GLADE_HOOKUP_OBJECT (window_startup, hbox2, "hbox2"); - 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, hseparator11, "hseparator11"); GLADE_HOOKUP_OBJECT (window_startup, vbox34, "vbox34"); GLADE_HOOKUP_OBJECT (window_startup, label69, "label69"); GLADE_HOOKUP_OBJECT (window_startup, hbox44, "hbox44"); @@ -399,24 +373,29 @@ create_window_startup (void) GLADE_HOOKUP_OBJECT (window_startup, hbox45, "hbox45"); GLADE_HOOKUP_OBJECT (window_startup, image45, "image45"); GLADE_HOOKUP_OBJECT (window_startup, label70, "label70"); + GLADE_HOOKUP_OBJECT (window_startup, hseparator11, "hseparator11"); + GLADE_HOOKUP_OBJECT (window_startup, label4, "label4"); + GLADE_HOOKUP_OBJECT (window_startup, eventbox1, "eventbox1"); + GLADE_HOOKUP_OBJECT (window_startup, hbox2, "hbox2"); + 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, hbox46, "hbox46"); - GLADE_HOOKUP_OBJECT (window_startup, vbox35, "vbox35"); - GLADE_HOOKUP_OBJECT (window_startup, checkbutton_no_def, "checkbutton_no_def"); - GLADE_HOOKUP_OBJECT (window_startup, checkbutton_only_names, "checkbutton_only_names"); - GLADE_HOOKUP_OBJECT (window_startup, checkbutton_load_my_team, "checkbutton_load_my_team"); - GLADE_HOOKUP_OBJECT (window_startup, vseparator18, "vseparator18"); - GLADE_HOOKUP_OBJECT (window_startup, button_start_editor, "button_start_editor"); - GLADE_HOOKUP_OBJECT (window_startup, alignment15, "alignment15"); - GLADE_HOOKUP_OBJECT (window_startup, hbox47, "hbox47"); - GLADE_HOOKUP_OBJECT (window_startup, image55, "image55"); - GLADE_HOOKUP_OBJECT (window_startup, label71, "label71"); + GLADE_HOOKUP_OBJECT (window_startup, hbox54, "hbox54"); + GLADE_HOOKUP_OBJECT (window_startup, label75, "label75"); + GLADE_HOOKUP_OBJECT (window_startup, entry_player_name, "entry_player_name"); + GLADE_HOOKUP_OBJECT (window_startup, button_add_player, "button_add_player"); + GLADE_HOOKUP_OBJECT (window_startup, alignment19, "alignment19"); + GLADE_HOOKUP_OBJECT (window_startup, hbox55, "hbox55"); + GLADE_HOOKUP_OBJECT (window_startup, image59, "image59"); + GLADE_HOOKUP_OBJECT (window_startup, label76, "label76"); + GLADE_HOOKUP_OBJECT (window_startup, hseparator13, "hseparator13"); GLADE_HOOKUP_OBJECT (window_startup, hbox3, "hbox3"); GLADE_HOOKUP_OBJECT (window_startup, team_selection_ok, "team_selection_ok"); - GLADE_HOOKUP_OBJECT (window_startup, alignment1, "alignment1"); - GLADE_HOOKUP_OBJECT (window_startup, hbox4, "hbox4"); - GLADE_HOOKUP_OBJECT (window_startup, image2, "image2"); - GLADE_HOOKUP_OBJECT (window_startup, label1, "label1"); + GLADE_HOOKUP_OBJECT (window_startup, alignment18, "alignment18"); + GLADE_HOOKUP_OBJECT (window_startup, hbox53, "hbox53"); + GLADE_HOOKUP_OBJECT (window_startup, image58, "image58"); + GLADE_HOOKUP_OBJECT (window_startup, label74, "label74"); GLADE_HOOKUP_OBJECT (window_startup, team_selection_cancel, "team_selection_cancel"); GLADE_HOOKUP_OBJECT (window_startup, alignment2, "alignment2"); GLADE_HOOKUP_OBJECT (window_startup, hbox5, "hbox5"); @@ -1073,3 +1052,40 @@ create_help_window (void) return help_window; } +GtkWidget* +create_window_startup_users (void) +{ + GtkWidget *window_startup_users; + GtkWidget *scrolledwindow10; + GtkWidget *treeview_users; + GtkTooltips *tooltips; + + tooltips = gtk_tooltips_new (); + + window_startup_users = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_window_set_title (GTK_WINDOW (window_startup_users), _("Players")); + gtk_window_set_default_size (GTK_WINDOW (window_startup_users), 250, 200); + gtk_window_set_gravity (GTK_WINDOW (window_startup_users), GDK_GRAVITY_NORTH_EAST); + + scrolledwindow10 = gtk_scrolled_window_new (NULL, NULL); + gtk_widget_show (scrolledwindow10); + gtk_container_add (GTK_CONTAINER (window_startup_users), scrolledwindow10); + + treeview_users = gtk_tree_view_new (); + gtk_widget_show (treeview_users); + gtk_container_add (GTK_CONTAINER (scrolledwindow10), treeview_users); + gtk_tooltips_set_tip (tooltips, treeview_users, _("Click on a player to remove him"), NULL); + + g_signal_connect ((gpointer) treeview_users, "button_press_event", + G_CALLBACK (on_treeview_users_button_press_event), + NULL); + + /* Store pointers to all widgets, for use by lookup_widget(). */ + GLADE_HOOKUP_OBJECT_NO_REF (window_startup_users, window_startup_users, "window_startup_users"); + GLADE_HOOKUP_OBJECT (window_startup_users, scrolledwindow10, "scrolledwindow10"); + GLADE_HOOKUP_OBJECT (window_startup_users, treeview_users, "treeview_users"); + GLADE_HOOKUP_OBJECT_NO_REF (window_startup_users, tooltips, "tooltips"); + + return window_startup_users; +} + diff --git a/src/misc_interface.h b/src/misc_interface.h index c0329060..24943e17 100644 --- a/src/misc_interface.h +++ b/src/misc_interface.h @@ -8,3 +8,4 @@ GtkWidget* create_fsel_window (void); GtkWidget* create_font_sel_window (void); GtkWidget* create_window_live (void); GtkWidget* create_help_window (void); +GtkWidget* create_window_startup_users (void); diff --git a/src/option.c b/src/option.c index e69de29b..3ef97a46 100644 --- a/src/option.c +++ b/src/option.c @@ -0,0 +1,98 @@ +#include "option.h" +#include "variables.h" + +/** Return the string going with the option + named 'name'. + @param name The name of the option. + @return The string_value of the option. + @see #Option */ +gchar* +option_string(gchar *name, GArray *option_array) +{ + gint i; + + for(i=0;ilen;i++) + if(strcmp(g_array_index(option_array, Option, i).name->str, name) == 0) + return g_array_index(option_array, Option, i).string_value->str; + + g_warning("option_string: option named %s not found\n", name); + + return NULL; +} + +/** Return the integer going with the option + named 'name'. + @param name The name of the option. + @return The value of the option. + @see #Option */ +gint +option_int(gchar *name, GArray *option_array) +{ + gint i; + + for(i=0;ilen;i++) + if(strcmp(g_array_index(option_array, Option, i).name->str, name) == 0) + return g_array_index(option_array, Option, i).value; + + g_warning("option_int: option named %s not found\n", name); + + return -1; +} + +/** Return the int going with the option named 'name' + cast to float and divided by 1000. + @param name The name of the option. + @return The value of the option cast to float and divided by 1000. + @see #Option */ +gfloat +option_float(gchar *name, GArray *option_array) +{ + gint i; + + for(i=0;ilen;i++) + if(strcmp(g_array_index(option_array, Option, i).name->str, name) == 0) + return (gfloat)g_array_index(option_array, Option, i).value / 1000; + + g_warning("option_float: option named %s not found\n", name); + + return -1; +} + +/** Change the value of a string option in the array. + @param name The name of the option. + @param option_array The option array. + @param new_value The value we set. */ +void +option_set_string(gchar *name, GArray *option_array, gchar *new_value) +{ + gint i; + + for(i=0;ilen;i++) + if(strcmp(g_array_index(option_array, Option, i).name->str, name) == 0) + { + g_string_printf(g_array_index(option_array, Option, i).string_value, + "%s", new_value); + return; + } + + g_warning("option_set_string: option named %s not found\n", name); +} + +/** Change the value of an int option in the array. + @param name The name of the option. + @param option_array The option array. + @param new_value The value we set. */ +void +option_set_int(gchar *name, GArray *option_array, gint new_value) +{ + gint i; + + for(i=0;ilen;i++) + if(strcmp(g_array_index(option_array, Option, i).name->str, name) == 0) + { + g_array_index(option_array, Option, i).value = new_value; + return; + } + + g_warning("option_set_int: option named %s not found\n", name); +} diff --git a/src/option.h b/src/option.h index 737db9c5..d2125814 100644 --- a/src/option.h +++ b/src/option.h @@ -1,6 +1,45 @@ #ifndef OPTION_H #define OPTION_H +#include #include "bygfoot.h" +/** Convenience abbrevs. */ +#define option_set_float(name, option_array, value) option_set_int(name, option_array, (gint)rint(value * 1000)) + +#define opt_str(name) option_string(name, options) +#define opt_int(name) option_int(name, options) +#define opt_float(name) option_float(name, options) + +#define opt_set_int(name, value) option_set_int(name, options, value) +#define opt_set_str(name, value) option_set_string(name, options, value) +#define opt_set_float(name, value) option_set_float(name, options, value) + +#define opt_user_str(name) option_string(name, usr(current_user).options) +#define opt_user_int(name) option_int(name, usr(current_user).options) +#define opt_user_float(name) option_float(name, usr(current_user).options) + +#define opt_user_set_int(name, value) option_set_int(name, usr(current_user).options, value) +#define opt_user_set_str(name, value) option_set_string(name, usr(current_user).options, value) +#define opt_user_set_float(name, value) option_set_float(name, usr(current_user).options, value) + +#define const_str(name) option_string(name, constants) +#define const_int(name) option_int(name, constants) +#define const_float(name) option_float(name, constants) + +gfloat +option_float(gchar *name, GArray *option_array); + +gint +option_int(gchar *name, GArray *option_array); + +gchar* +option_string(gchar *name, GArray *option_array); + +void +option_set_string(gchar *name, GArray *option_array, gchar *new_value); + +void +option_set_int(gchar *name, GArray *option_array, gint new_value); + #endif diff --git a/src/options_interface.c b/src/options_interface.c index 9ce1e1d7..850bdf63 100644 --- a/src/options_interface.c +++ b/src/options_interface.c @@ -306,7 +306,6 @@ create_opt_window (void) label53 = gtk_label_new (_("At the beginning of a new week show first")); gtk_widget_show (label53); gtk_box_pack_start (GTK_BOX (vbox32), label53, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label53), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label53), 0, 0.5); hbox66 = gtk_hbox_new (FALSE, 0); @@ -344,7 +343,6 @@ create_opt_window (void) label43 = gtk_label_new (_(" Live game duration factor ")); gtk_widget_show (label43); gtk_box_pack_start (GTK_BOX (hbox21), label43, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label43), GTK_JUSTIFY_LEFT); spin_live_duration_adj = gtk_adjustment_new (0, -100, 100, 1, 10, 10); spin_live_duration = gtk_spin_button_new (GTK_ADJUSTMENT (spin_live_duration_adj), 1, 0); @@ -361,7 +359,6 @@ create_opt_window (void) label58 = gtk_label_new (_(" ")); gtk_widget_show (label58); gtk_box_pack_start (GTK_BOX (hbox39), label58, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label58), GTK_JUSTIFY_LEFT); check_live_tendency = gtk_check_button_new_with_mnemonic (_("Show live game tendency bar")); gtk_widget_show (check_live_tendency); @@ -393,12 +390,10 @@ create_opt_window (void) label55 = gtk_label_new_with_mnemonic (_("Change font")); gtk_widget_show (label55); gtk_box_pack_start (GTK_BOX (hbox35), label55, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label55), GTK_JUSTIFY_LEFT); label54 = gtk_label_new (_(" used in the main windows")); gtk_widget_show (label54); gtk_box_pack_start (GTK_BOX (hbox34), label54, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label54), GTK_JUSTIFY_LEFT); hbox46 = gtk_hbox_new (FALSE, 0); gtk_widget_show (hbox46); @@ -407,7 +402,6 @@ create_opt_window (void) label71 = gtk_label_new (_("Change team name ")); gtk_widget_show (label71); gtk_box_pack_start (GTK_BOX (hbox46), label71, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label71), GTK_JUSTIFY_LEFT); entry_team_name = gtk_entry_new (); gtk_widget_show (entry_team_name); @@ -436,7 +430,6 @@ create_opt_window (void) label45 = gtk_label_new (_("Messages")); gtk_widget_show (label45); gtk_box_pack_start (GTK_BOX (hbox22), label45, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label45), GTK_JUSTIFY_LEFT); radio_mess1 = gtk_radio_button_new_with_mnemonic (NULL, _("Moving")); gtk_widget_show (radio_mess1); @@ -495,12 +488,10 @@ create_opt_window (void) label89 = gtk_label_new (_("Apperance and behaviour of the game")); gtk_widget_show (label89); gtk_frame_set_label_widget (GTK_FRAME (frame1), label89); - gtk_label_set_justify (GTK_LABEL (label89), GTK_JUSTIFY_LEFT); label83 = gtk_label_new (_("Look & Feel")); gtk_widget_show (label83); gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 0), label83); - gtk_label_set_justify (GTK_LABEL (label83), GTK_JUSTIFY_LEFT); frame2 = gtk_frame_new (NULL); gtk_widget_show (frame2); @@ -534,17 +525,14 @@ create_opt_window (void) label82 = gtk_label_new (_(" weeks")); gtk_widget_show (label82); gtk_box_pack_start (GTK_BOX (hbox62), label82, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label82), GTK_JUSTIFY_LEFT); label90 = gtk_label_new (_("Options for loading and saving games")); gtk_widget_show (label90); gtk_frame_set_label_widget (GTK_FRAME (frame2), label90); - gtk_label_set_justify (GTK_LABEL (label90), GTK_JUSTIFY_LEFT); label84 = gtk_label_new (_("Load & Save")); gtk_widget_show (label84); gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 1), label84); - gtk_label_set_justify (GTK_LABEL (label84), GTK_JUSTIFY_LEFT); frame3 = gtk_frame_new (NULL); gtk_widget_show (frame3); @@ -675,7 +663,6 @@ create_opt_window (void) label78 = gtk_label_new (""); gtk_widget_show (label78); gtk_box_pack_start (GTK_BOX (vbox28), label78, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label78), GTK_JUSTIFY_LEFT); gtk_misc_set_padding (GTK_MISC (label78), 0, 4); vbox29 = gtk_vbox_new (FALSE, 2); @@ -727,25 +714,21 @@ create_opt_window (void) label73 = gtk_label_new (_(" and ")); gtk_widget_show (label73); gtk_box_pack_start (GTK_BOX (vbox30), label73, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label73), GTK_JUSTIFY_LEFT); gtk_misc_set_padding (GTK_MISC (label73), 0, 4); label74 = gtk_label_new (_(" and ")); gtk_widget_show (label74); gtk_box_pack_start (GTK_BOX (vbox30), label74, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label74), GTK_JUSTIFY_LEFT); gtk_misc_set_padding (GTK_MISC (label74), 0, 4); label75 = gtk_label_new (_(" and ")); gtk_widget_show (label75); gtk_box_pack_start (GTK_BOX (vbox30), label75, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label75), GTK_JUSTIFY_LEFT); gtk_misc_set_padding (GTK_MISC (label75), 0, 4); label76 = gtk_label_new (""); gtk_widget_show (label76); gtk_box_pack_start (GTK_BOX (vbox30), label76, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label76), GTK_JUSTIFY_LEFT); gtk_misc_set_padding (GTK_MISC (label76), 0, 4); hbox54 = gtk_hbox_new (FALSE, 0); @@ -797,7 +780,6 @@ create_opt_window (void) label77 = gtk_label_new (""); gtk_widget_show (label77); gtk_box_pack_start (GTK_BOX (vboxa31), label77, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label77), GTK_JUSTIFY_LEFT); gtk_misc_set_padding (GTK_MISC (label77), 0, 4); hbox53 = gtk_hbox_new (FALSE, 0); @@ -822,17 +804,14 @@ create_opt_window (void) label95 = gtk_label_new (""); gtk_widget_show (label95); gtk_frame_set_label_widget (GTK_FRAME (frame7), label95); - gtk_label_set_justify (GTK_LABEL (label95), GTK_JUSTIFY_LEFT); label91 = gtk_label_new (_("Options concering the transfer list")); gtk_widget_show (label91); gtk_frame_set_label_widget (GTK_FRAME (frame3), label91); - gtk_label_set_justify (GTK_LABEL (label91), GTK_JUSTIFY_LEFT); label85 = gtk_label_new (_("Transfers")); gtk_widget_show (label85); gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 2), label85); - gtk_label_set_justify (GTK_LABEL (label85), GTK_JUSTIFY_LEFT); frame4 = gtk_frame_new (NULL); gtk_widget_show (frame4); @@ -864,12 +843,10 @@ create_opt_window (void) label92 = gtk_label_new (_("Whether to confirm certain actions")); gtk_widget_show (label92); gtk_frame_set_label_widget (GTK_FRAME (frame4), label92); - gtk_label_set_justify (GTK_LABEL (label92), GTK_JUSTIFY_LEFT); label86 = gtk_label_new (_("Confirmations")); gtk_widget_show (label86); gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 3), label86); - gtk_label_set_justify (GTK_LABEL (label86), GTK_JUSTIFY_LEFT); frame5 = gtk_frame_new (NULL); gtk_widget_show (frame5); @@ -891,7 +868,6 @@ create_opt_window (void) label98 = gtk_label_new (_("Attribute")); gtk_widget_show (label98); gtk_box_pack_start (GTK_BOX (vbox42), label98, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label98), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label98), 1.11759e-08, 0.5); hseparator12 = gtk_hseparator_new (); @@ -902,97 +878,81 @@ create_opt_window (void) label109 = gtk_label_new (_("Name")); gtk_widget_show (label109); gtk_box_pack_start (GTK_BOX (vbox42), label109, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label109), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label109), 0, 0.5); label110 = gtk_label_new (_("Current position")); gtk_widget_show (label110); gtk_box_pack_start (GTK_BOX (vbox42), label110, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label110), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label110), 0, 0.5); label111 = gtk_label_new (_("Position")); gtk_widget_show (label111); gtk_box_pack_start (GTK_BOX (vbox42), label111, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label111), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label111), 0, 0.5); label112 = gtk_label_new (_("Current skill")); gtk_widget_show (label112); gtk_box_pack_start (GTK_BOX (vbox42), label112, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label112), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label112), 0, 0.5); label99 = gtk_label_new (_("Skill")); gtk_widget_show (label99); gtk_box_pack_start (GTK_BOX (vbox42), label99, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label99), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label99), 0, 0.5); label100 = gtk_label_new (_("Fitness")); gtk_widget_show (label100); gtk_box_pack_start (GTK_BOX (vbox42), label100, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label100), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label100), 0, 0.5); label101 = gtk_label_new (_("Games")); gtk_widget_show (label101); gtk_box_pack_start (GTK_BOX (vbox42), label101, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label101), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label101), 0, 0.5); label102 = gtk_label_new (_("Goals")); gtk_widget_show (label102); gtk_box_pack_start (GTK_BOX (vbox42), label102, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label102), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label102), 0, 0.5); label103 = gtk_label_new (_("Status")); gtk_widget_show (label103); gtk_box_pack_start (GTK_BOX (vbox42), label103, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label103), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label103), 0, 0.5); label104 = gtk_label_new (_("Age")); gtk_widget_show (label104); gtk_box_pack_start (GTK_BOX (vbox42), label104, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label104), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label104), 0, 0.5); label105 = gtk_label_new (_("Estimated talent")); gtk_widget_show (label105); gtk_box_pack_start (GTK_BOX (vbox42), label105, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label105), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label105), 0, 0.5); label106 = gtk_label_new (_("Yellow cards")); gtk_widget_show (label106); gtk_box_pack_start (GTK_BOX (vbox42), label106, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label106), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label106), 0, 0.5); label107 = gtk_label_new (_("Value")); gtk_widget_show (label107); gtk_box_pack_start (GTK_BOX (vbox42), label107, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label107), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label107), 0, 0.5); label108 = gtk_label_new (_("Wage")); gtk_widget_show (label108); gtk_box_pack_start (GTK_BOX (vbox42), label108, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label108), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label108), 0, 0.5); label113 = gtk_label_new (_("Team")); gtk_widget_show (label113); gtk_box_pack_start (GTK_BOX (vbox42), label113, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label113), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label113), 0, 0.5); label114 = gtk_label_new (_("League")); gtk_widget_show (label114); gtk_box_pack_start (GTK_BOX (vbox42), label114, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label114), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label114), 0, 0.5); vseparator6 = gtk_vseparator_new (); @@ -1007,7 +967,6 @@ create_opt_window (void) label130 = gtk_label_new (_("Player list 1")); gtk_widget_show (label130); gtk_box_pack_start (GTK_BOX (vbox45), label130, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label130), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label130), 2.23517e-10, 0.5); hseparator13 = gtk_hseparator_new (); @@ -1091,7 +1050,6 @@ create_opt_window (void) label115 = gtk_label_new (_("Player list 2")); gtk_widget_show (label115); gtk_box_pack_start (GTK_BOX (vbox46), label115, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label115), GTK_JUSTIFY_LEFT); gtk_misc_set_alignment (GTK_MISC (label115), 0, 0.5); hseparator14 = gtk_hseparator_new (); @@ -1166,12 +1124,10 @@ create_opt_window (void) label93 = gtk_label_new (_("Player attributes that are shown in the two player lists")); gtk_widget_show (label93); gtk_frame_set_label_widget (GTK_FRAME (frame5), label93); - gtk_label_set_justify (GTK_LABEL (label93), GTK_JUSTIFY_LEFT); label87 = gtk_label_new (_("Player attributes")); gtk_widget_show (label87); gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 4), label87); - gtk_label_set_justify (GTK_LABEL (label87), GTK_JUSTIFY_LEFT); frame8 = gtk_frame_new (NULL); gtk_widget_show (frame8); @@ -1189,7 +1145,6 @@ create_opt_window (void) label136 = gtk_label_new (_("Option")); gtk_widget_show (label136); gtk_box_pack_start (GTK_BOX (vbox50), label136, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label136), GTK_JUSTIFY_LEFT); hseparator17 = gtk_hseparator_new (); gtk_widget_show (hseparator17); @@ -1208,7 +1163,6 @@ create_opt_window (void) label140 = gtk_label_new (_("Update interval (in weeks)")); gtk_widget_show (label140); gtk_container_add (GTK_CONTAINER (eventbox4), label140); - gtk_label_set_justify (GTK_LABEL (label140), GTK_JUSTIFY_LEFT); eventbox5 = gtk_event_box_new (); gtk_widget_show (eventbox5); @@ -1218,7 +1172,6 @@ create_opt_window (void) label141 = gtk_label_new (_("Maximal history length")); gtk_widget_show (label141); gtk_container_add (GTK_CONTAINER (eventbox5), label141); - gtk_label_set_justify (GTK_LABEL (label141), GTK_JUSTIFY_LEFT); eventbox6 = gtk_event_box_new (); gtk_widget_show (eventbox6); @@ -1228,7 +1181,6 @@ create_opt_window (void) label142 = gtk_label_new (_("Delete history at end of season")); gtk_widget_show (label142); gtk_container_add (GTK_CONTAINER (eventbox6), label142); - gtk_label_set_justify (GTK_LABEL (label142), GTK_JUSTIFY_LEFT); vseparator8 = gtk_vseparator_new (); gtk_widget_show (vseparator8); @@ -1241,7 +1193,6 @@ create_opt_window (void) label134 = gtk_label_new (_("Team histories")); gtk_widget_show (label134); gtk_box_pack_start (GTK_BOX (vbox48), label134, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label134), GTK_JUSTIFY_LEFT); hseparator15 = gtk_hseparator_new (); gtk_widget_show (hseparator15); @@ -1279,7 +1230,6 @@ create_opt_window (void) label135 = gtk_label_new (_("Player histories")); gtk_widget_show (label135); gtk_box_pack_start (GTK_BOX (vbox49), label135, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label135), GTK_JUSTIFY_LEFT); hseparator16 = gtk_hseparator_new (); gtk_widget_show (hseparator16); @@ -1308,12 +1258,10 @@ create_opt_window (void) label132 = gtk_label_new (_("Team and player histories")); gtk_widget_show (label132); gtk_frame_set_label_widget (GTK_FRAME (frame8), label132); - gtk_label_set_justify (GTK_LABEL (label132), GTK_JUSTIFY_LEFT); label131 = gtk_label_new (_("Histories")); gtk_widget_show (label131); gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 5), label131); - gtk_label_set_justify (GTK_LABEL (label131), GTK_JUSTIFY_LEFT); frame6 = gtk_frame_new (NULL); gtk_widget_show (frame6); @@ -1334,12 +1282,10 @@ create_opt_window (void) label94 = gtk_label_new (_("Miscellaneous options")); gtk_widget_show (label94); gtk_frame_set_label_widget (GTK_FRAME (frame6), label94); - gtk_label_set_justify (GTK_LABEL (label94), GTK_JUSTIFY_LEFT); label88 = gtk_label_new (_("Misc")); gtk_widget_show (label88); gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 6), label88); - gtk_label_set_justify (GTK_LABEL (label88), GTK_JUSTIFY_LEFT); hseparator8 = gtk_hseparator_new (); gtk_widget_show (hseparator8); @@ -1379,7 +1325,6 @@ create_opt_window (void) label47 = gtk_label_new_with_mnemonic (_("OK")); gtk_widget_show (label47); gtk_box_pack_start (GTK_BOX (hbox26), label47, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label47), GTK_JUSTIFY_LEFT); button_opt_cancel = gtk_button_new (); gtk_widget_show (button_opt_cancel); @@ -1405,7 +1350,6 @@ create_opt_window (void) label48 = gtk_label_new_with_mnemonic (_("Cancel")); gtk_widget_show (label48); gtk_box_pack_start (GTK_BOX (hbox27), label48, FALSE, FALSE, 0); - gtk_label_set_justify (GTK_LABEL (label48), GTK_JUSTIFY_LEFT); g_signal_connect ((gpointer) opt_window, "delete_event", G_CALLBACK (on_opt_window_delete_event), diff --git a/src/player.c b/src/player.c index ac22eb49..2f85d75a 100644 --- a/src/player.c +++ b/src/player.c @@ -1,60 +1,12 @@ +#include "cup.h" #include "free.h" #include "league.h" #include "maths.h" +#include "option.h" #include "player.h" #include "team.h" #include "variables.h" -/** How much a player's skill can deviate from - the average skill in his team. */ -#define CONSTANT_PLAYER_AVERAGE_SKILL_VARIANCE 0.1 -/** Lower limit for player ages. */ -#define CONSTANT_PLAYER_AGE_LOWER (18 * 52) -/** Upper limit for player ages. */ -#define CONSTANT_PLAYER_AGE_UPPER (36 * 52) -/** Lower limit for player peak ages. */ -#define CONSTANT_PLAYER_PEAK_AGE_LOWER (30 * 52) -/** Upper limit for player peak ages. */ -#define CONSTANT_PLAYER_PEAK_AGE_UPPER (33 * 52) -/** By how many weeks the peak age of goalies is - greater. */ -#define CONSTANT_PLAYER_PEAK_AGE_GOALIE_ADDITION (2 * 52) -/** Limits for initial fitness. */ -#define CONSTANT_PLAYER_FITNESS_LOWER 85 -/** Limits for initial fitness. */ -#define CONSTANT_PLAYER_FITNESS_UPPER 100 - -/** The bounds determining the player positions in a newly created - team for players 13 to CONSTANT_TEAM_MAX_PLAYERS. - Player 11 is always the second goalie. */ -#define CONSTANT_PLAYER_POS_BOUND1 15 -#define CONSTANT_PLAYER_POS_BOUND2 18 - -/** Bounds for the contract time at player generation. */ -#define CONSTANT_PLAYER_CONTRACT_LOWER 52 -#define CONSTANT_PLAYER_CONTRACT_UPPER 4 * 52 - -/** Bounds for the last skill update at player generation. */ -#define CONSTANT_PLAYER_LSU_LOWER 2 -#define CONSTANT_PLAYER_LSU_UPPER 10 - -/** These determine the value calculation of players. - Value is a function of skill and talent involving - a power. - @see player_assign_value()*/ -#define CONSTANT_PLAYER_VALUE_SKILL_WEIGHT 0.65 -#define CONSTANT_PLAYER_VALUE_POWER 3.5 - -/** These determine the wage calculation of players. - Wage depends on the value and a random factor near 1. - @see player_assign_wage() */ -#define CONSTANT_PLAYER_WAGE_VALUE_FACTOR 0.01 -#define CONSTANT_PLAYER_WAGE_RANDOM_DEV 0.15 - -/** This determines the accuracy of the scout's - talent estimate. The smaller the better. */ -#define CONSTANT_PLAYER_ETAL_SCOUT_FACTOR 7 - /** Create and return a new player. @param tm The team the player will belong to. @param average_skill The average skill of the team. @@ -64,8 +16,8 @@ Player player_new(Team *tm, gint average_skill) { gfloat skill_factor = - math_rnd(1 - CONSTANT_PLAYER_AVERAGE_SKILL_VARIANCE, - 1 + CONSTANT_PLAYER_AVERAGE_SKILL_VARIANCE); + math_rnd(1 - const_float("float_player_average_skill_variance"), + 1 + const_float("float_player_average_skill_variance")); Player new; new.name = @@ -73,27 +25,32 @@ player_new(Team *tm, gint average_skill) new.id = player_new_id(tm->players); new.pos = player_get_position_from_structure(tm->structure, tm->players->len); new.cpos = new.pos; - new.skill = CLAMP((gint)rint((gfloat)average_skill * skill_factor), 0, CONSTANT_PLAYER_MAX_SKILL); + new.skill = CLAMP((gint)rint((gfloat)average_skill * skill_factor), 0, + const_int("int_player_max_skill")); new.cskill = new.skill; - new.age = math_gauss_disti(CONSTANT_PLAYER_AGE_LOWER, - CONSTANT_PLAYER_AGE_UPPER); + new.age = math_gauss_disti(const_int("int_player_age_lower"), + const_int("int_player_age_upper")); new.peak_age = - math_rndi(CONSTANT_PLAYER_PEAK_AGE_LOWER + - (new.pos == PLAYER_POS_GOALIE) * CONSTANT_PLAYER_PEAK_AGE_GOALIE_ADDITION, - CONSTANT_PLAYER_PEAK_AGE_UPPER + - (new.pos == PLAYER_POS_GOALIE) * CONSTANT_PLAYER_PEAK_AGE_GOALIE_ADDITION); + math_rndi(const_int("int_player_peak_age_lower") + + (new.pos == PLAYER_POS_GOALIE) * + const_int("int_player_peak_age_goalie_addition"), + const_int("int_player_peak_age_upper") + + (new.pos == PLAYER_POS_GOALIE) * + const_int("int_player_peak_age_goalie_addition")); new.talent = player_new_talent(new.skill); - new.etal = player_estimate_talent(&new); - new.fitness = math_rndi(CONSTANT_PLAYER_FITNESS_LOWER, CONSTANT_PLAYER_FITNESS_UPPER); + player_estimate_talent(&new); + new.fitness = math_rndi(const_int("int_player_fitness_lower"), + const_int("int_player_fitness_upper")); new.health = new.recovery = 0; new.games_goals = g_array_new(FALSE, FALSE, sizeof(PlayerGamesGoals)); new.value = player_assign_value(&new); new.wage = player_assign_wage(&new); - new.contract = math_rndi(CONSTANT_PLAYER_CONTRACT_LOWER, CONSTANT_PLAYER_CONTRACT_UPPER); - new.lsu = math_rndi(CONSTANT_PLAYER_LSU_LOWER, CONSTANT_PLAYER_LSU_UPPER); + new.contract = math_rndi(const_int("int_player_contract_lower"), + const_int("int_player_contract_upper")); + new.lsu = math_rndi(const_int("int_player_lsu_lower"), + const_int("int_player_lsu_upper")); new.cards = g_array_new(FALSE, FALSE, sizeof(PlayerCard)); - /* todo: make player history struct. */ - new.history = NULL; + new.team = tm; return new; @@ -107,7 +64,7 @@ player_new_id(const GArray *players) { gint i, j; - for(i=0;ilen;j++) if(g_array_index(players, Player, j).id == i) @@ -140,10 +97,10 @@ player_get_position_from_structure(gint structure, gint player_number) if(player_number % 11 == 0) position = PLAYER_POS_GOALIE; else if(player_number < bound[0] || - (player_number > 10 && player_number < CONSTANT_PLAYER_POS_BOUND1)) + (player_number > 10 && player_number < const_int("int_player_pos_bound1"))) position = PLAYER_POS_DEFENDER; else if(player_number < bound[1] || - (player_number > 10 && player_number < CONSTANT_PLAYER_POS_BOUND2)) + (player_number > 10 && player_number < const_int("int_player_pos_bound2"))) position = PLAYER_POS_MIDFIELDER; else position = PLAYER_POS_FORWARD; @@ -157,37 +114,37 @@ player_get_position_from_structure(gint structure, gint player_number) gint player_new_talent(gint skill) { - gint talent = math_gauss_disti(2 * skill - CONSTANT_PLAYER_MAX_SKILL, - CONSTANT_PLAYER_MAX_SKILL); + gint talent = math_gauss_disti(2 * skill - const_int("int_player_max_skill"), + const_int("int_player_max_skill")); if(talent < skill) talent = 2 * skill - talent; return talent; } -/** Estimate a player's talent. The quality of the estimate - depends on the quality of the scout. - @param pl The player of which we'd like to estimate the talent. - @return A talent estimate. */ -gint -player_estimate_talent(const Player *pl) +/** Estimate a player's talent. + @param pl The player of which we'd like to estimate the talent. */ +void +player_estimate_talent(Player *pl) { - gint i; + gint i, j; + gint scout_deviance[QUALITY_END]; /* the maximal deviance in both directions */ gint deviance_bound[2] = - {pl->talent - pl->skill, CONSTANT_PLAYER_MAX_SKILL - pl->talent}; + {pl->talent - pl->skill, const_int("int_player_max_skill") - pl->talent}; - /* the scout's maximal deviance */ - gfloat scout_deviance = (scout % 10) * CONSTANT_PLAYER_ETAL_SCOUT_FACTOR; - - /* adjust deviance_bounds with regard to the scout's - deviance */ - for(i=0;i<2;i++) - deviance_bound[i] = MIN(deviance_bound[i], scout_deviance); - - return math_rndi(pl->talent - deviance_bound[0], - pl->talent + deviance_bound[1]); + for(i=0;ietal[i] = math_rndi(pl->talent - deviance_bound[0], + pl->talent + deviance_bound[1]); + } } /** Assign a (transfer) value to a player. The value depends on skill, @@ -199,17 +156,19 @@ player_assign_value(const Player *pl) { gint value; - value = (gint)powf((CONSTANT_PLAYER_VALUE_SKILL_WEIGHT * (gfloat)pl->skill - + (1 - CONSTANT_PLAYER_VALUE_SKILL_WEIGHT) * (gfloat)pl->talent * 0.7), - CONSTANT_PLAYER_VALUE_POWER); + value = (gint)powf((const_float("float_player_value_skill_weight") * + (gfloat)pl->skill + + (1 - const_float("float_player_value_skill_weight")) * + (gfloat)pl->talent * 0.7), + const_float("float_player_value_power")); - if(pl->age <= CONSTANT_PLAYER_AGE_LOWER + 2 * 52) + if(pl->age <= const_int("int_player_age_lower") + 2 * 52) value = (gint)((gfloat)value * 1.05); - else if(pl->age <= CONSTANT_PLAYER_AGE_LOWER + 4 * 52) + else if(pl->age <= const_int("int_player_age_lower") + 4 * 52) value = (gint)((gfloat)value * 1.1); - else if(pl->age >= CONSTANT_PLAYER_AGE_UPPER - 4 * 52) + else if(pl->age >= const_int("int_player_age_upper") - 4 * 52) value = (gint)((gfloat)value * 0.95); - else if(pl->age >= CONSTANT_PLAYER_AGE_UPPER - 2 * 52) + else if(pl->age >= const_int("int_player_age_upper") - 2 * 52) value = (gint)((gfloat)value * 0.9); value = math_round_integer(value, 2); @@ -226,9 +185,9 @@ player_assign_wage(const Player *pl) { gfloat wage; - wage = rint(((gfloat)pl->value * CONSTANT_PLAYER_WAGE_VALUE_FACTOR) * - math_rnd(1 - CONSTANT_PLAYER_WAGE_RANDOM_DEV, - 1 + CONSTANT_PLAYER_WAGE_RANDOM_DEV) ); + wage = rint(((gfloat)pl->value * const_float("float_player_wage_value_factor")) * + math_rnd(1 - const_float("float_player_wage_random_dev"), + 1 + const_float("float_player_wage_random_dev") )); return math_round_integer((gint)wage, 1); } @@ -249,7 +208,6 @@ player_copy(const Player *source, Player *dest) dest->name = g_string_new(source->name->str); dest->cards = g_array_new(FALSE, FALSE, sizeof(PlayerCard)); dest->games_goals = g_array_new(FALSE, FALSE, sizeof(PlayerGamesGoals)); - dest->history = NULL; for(i=0;icards->len;i++) g_array_append_val(dest->cards, @@ -268,7 +226,7 @@ player_copy(const Player *source, Player *dest) void player_append_to_array(const Player *pl, Team *tm) { - Player new_player = player_new(tm, CONSTANT_PLAYER_MAX_SKILL); + Player new_player = player_new(tm, const_int("int_player_max_skill")); player_copy(pl, &new_player); @@ -382,3 +340,142 @@ player_of_id(const Team *tm, gint id) return NULL; } + +/** Compare two players in a pointer array. + @param pl1 Pointer to the pointer to the first player. + @param pl2 Pointer to the pointer to the second player. + @param data Coded integer that tells us which attribute to compare. */ +gint +player_compare_func(gconstpointer a, gconstpointer b, gpointer data) +{ + const Player *pl1 = *(const Player**)a; + const Player *pl2 = *(const Player**)b; + gint type = GPOINTER_TO_INT(data); + gint return_value = 0; + + if(type == PLAYER_COMPARE_ATTRIBUTE_GAME_SKILL) + { + if(pl1->cskill == pl2->cskill && pl1->fitness == pl2->fitness) + return_value = 0; + else if((gfloat)pl1->cskill * + powf((gfloat)pl1->fitness / 100, + const_float("float_player_fitness_exponent")) > + (gfloat)pl2->cskill * + powf((gfloat)pl2->fitness / 100, + const_float("float_player_fitness_exponent"))) + return_value = -1; + else + return_value = 1; + } + + return return_value; +} + +/** Move a player from one player array to another one. + @param tm1 The source team. + @param player_number The index of the player in the players array. + @param tm2 The dest team. + @param insert_at The new index of the player in the players array. */ +void +player_move(Team *tm1, gint player_number, Team *tm2, gint insert_at) +{ + Player pl = *player_of(tm1, player_number); + + pl.team = tm2; + + g_array_remove_index(tm1->players, player_number); + + g_array_insert_val(tm2->players, insert_at, pl); +} + +/** Swap two players. */ +void +player_swap(Team *tm1, gint player_number1, Team *tm2, gint player_number2) +{ + gint move = (tm1 == tm2 && player_number1 < player_number2) ? + -1 : 1; + + player_move(tm1, player_number1, tm2, player_number2); + if(player_number2 < 11) + player_of(tm2, player_number2)->cpos = + player_get_position_from_structure(tm2->structure, player_number2); + else + player_of(tm2, player_number2)->cpos = player_of(tm2, player_number2)->pos; + player_of(tm2, player_number2)->cskill = + player_get_cskill(player_of(tm2, player_number2)); + + player_move(tm2, player_number2 + move, + tm1, player_number1); + if(player_number1 < 11) + player_of(tm1, player_number1)->cpos = + player_get_position_from_structure(tm1->structure, player_number1); + else + player_of(tm1, player_number1)->cpos = player_of(tm1, player_number1)->pos; + player_of(tm1, player_number1)->cskill = + player_get_cskill(player_of(tm1, player_number1)); +} + +/** Return the player's cskill depending on + whether he's on his normal position or not. + @param pl The player we examine. + @return A new cskill. */ +gint +player_get_cskill(const Player *pl) +{ + gfloat cskill_factor; + + if(pl->health != PLAYER_INJURY_NONE || + player_is_banned(pl) > 0) + cskill_factor = 0.0; + else if(pl->pos == pl->cpos) + cskill_factor = 1.0; + else if(pl->cpos == PLAYER_POS_GOALIE || + pl->pos == PLAYER_POS_GOALIE) + cskill_factor = 0.5; + else if(abs(pl->cpos - pl->pos) == 2) + cskill_factor = 0.65; + else + cskill_factor = 0.75; + + if(pl->cpos != pl->pos) + return MIN(pl->talent * cskill_factor, pl->skill); + else + return pl->skill * (cskill_factor != 0); +} + +/** Find out whether the player is banned in + the next match or whether he will be if he + gets a yellow card. + @param pl The player we examine. + @return Number of games banned, or 0 if not banned, or -1 + if yellow. */ +gint +player_is_banned(const Player *pl) +{ + gint i; + Fixture *fix = team_get_next_fixture(pl->team); + gint yellow_red; + + if(fix == NULL) + return 0; + + if(fix->clid < ID_CUP_START) + yellow_red = league_from_clid(fix->clid)->yellow_red; + else + yellow_red = cup_from_clid(fix->clid)->yellow_red; + + for(i=0;icards->len;i++) + if(g_array_index(pl->cards, PlayerCard, 0).clid == fix->clid) + { + if(g_array_index(pl->cards, PlayerCard, 0).red > 0) + return g_array_index(pl->cards, PlayerCard, 0).red; + + if(g_array_index(pl->cards, PlayerCard, 0).yellow == + yellow_red - 1) + return -1; + + return 0; + } + + return 0; +} diff --git a/src/player.h b/src/player.h index a9eab315..c00d2c3f 100644 --- a/src/player.h +++ b/src/player.h @@ -5,6 +5,12 @@ #include "player_struct.h" #include "team_struct.h" +enum PlayerCompareAttrib +{ + PLAYER_COMPARE_ATTRIBUTE_GAME_SKILL = 0, + PLAYER_COMPARE_ATTRIBUTE_END +}; + Player player_new(Team *tm, gint average_skill); @@ -17,8 +23,8 @@ player_get_position_from_structure(gint structure, gint player_number); gint player_new_talent(gint skill); -gint -player_estimate_talent(const Player *pl); +void +player_estimate_talent(Player *pl); gint player_assign_value(const Player *pl); @@ -50,4 +56,19 @@ player_of(const Team *tm, gint number); Player* player_of_id(const Team *tm, gint id); +gint +player_compare_func(gconstpointer a, gconstpointer b, gpointer data); + +void +player_move(Team *tm1, gint player_number, Team *tm2, gint insert_at); + +void +player_swap(Team *tm1, gint player_number1, Team *tm2, gint player_number2); + +gint +player_get_cskill(const Player *pl); + +gint +player_is_banned(const Player *pl); + #endif diff --git a/src/player_struct.h b/src/player_struct.h index a7b92b12..bd953445 100644 --- a/src/player_struct.h +++ b/src/player_struct.h @@ -2,24 +2,9 @@ #define PLAYER_STRUCT_H #include "bygfoot.h" +#include "enums.h" #include "team_struct.h" -/** Highest skill and talent a player can have. */ -#define CONSTANT_PLAYER_MAX_SKILL 99 -/** Influence of boost on player's skill. */ -#define CONSTANT_PLAYER_BOOST_SKILL_EFFECT 0.3 -/** Influence of boost on player's fitness decay. */ -#define CONSTANT_PLAYER_BOOST_FITNESS_EFFECT 1.0 -/** Influence of boost on injury probability. */ -#define CONSTANT_PLAYER_BOOST_INJURY_EFFECT 1.0 -/** Influence of boost on cards probability. */ -#define CONSTANT_PLAYER_BOOST_CARD_EFFECT 1.0 - -/** The influence of the fitness on the current skill. - This determines the player's contribution to the team - during a game. The higher the value the bigger the influence. */ -#define CONSTANT_PLAYER_FITNESS_IMPACT_ON_SKILL 0.25 - /** Player positions. */ @@ -75,12 +60,13 @@ typedef struct gint pos, /**< Position. @see #PlayerPos */ cpos, /**< Current position. @see #PlayerPos */ - skill, /**< Skill. Between 0 and CONSTANT_PLAYER_MAX_SKILL. */ + skill, /**< Skill. Between 0 and a constant (specified in the constants file). */ cskill, /**< Current Skill. */ age, /**< Age in weeks */ peak_age, /**< Age at which the player reaches his peak ability. */ talent, /**< Talent. The peak ability (which isn't always reached). */ - etal, /**< Estimated talent (the user never sees the actual talent). */ + etal[QUALITY_END], /**< Estimated talent (the user never sees the actual talent). + Depends on scout quality. */ fitness, /**< Fitness. Between 0 and 99. */ health, /**< Health. An integer signifying an injury or good health. @see #PlayerInjury */ recovery, /**< Weeks until the player gets healthy. */ @@ -97,8 +83,6 @@ typedef struct /** Array of cards; one item per league and cup. @see PlayerCard*/ GArray *cards; - /** Player history. To be specified. */ - GArray *history; /** Pointer to the player's team. */ Team *team; diff --git a/src/start_end.c b/src/start_end.c index 6b3fd54d..563ad9d4 100644 --- a/src/start_end.c +++ b/src/start_end.c @@ -2,15 +2,37 @@ #include "file.h" #include "fixture.h" #include "league.h" +#include "live_game.h" #include "main.h" #include "maths.h" #include "player.h" #include "start_end.h" +#include "table.h" #include "team.h" #include "transfer.h" +#include "user.h" #include "variables.h" #include "xml_name.h" +/** Prototype of a function called at the start or + end of a week round. */ +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}; + +/** Array of functions called when a week round + is started. */ +WeekFunc start_week_round_funcs[] = +{NULL}; + +/** Array of functions called when a week + is started. */ +WeekFunc start_week_funcs[] = {NULL}; + /** Generate the teams etc. */ void start_new_game(void) @@ -46,10 +68,12 @@ start_write_variables(void) gint i; season = week = week_round = 1; - scout = physio = QUALITY_AVERAGE; - + current_user = 0; + //week=23; week_round = 2; transfer_list = g_array_new(FALSE, FALSE, sizeof(TransferPlayer)); - file_load_conf_file(); + + for(i=0;ilen;i++) + file_load_user_conf_file(&usr(i)); } /** Generate the teams in the leagues. */ @@ -89,21 +113,156 @@ start_load_cup_teams(void) { cup_load_choose_teams(&cp(i)); cup_load_choose_team_user(&cp(i)); - - /*d*/ -/* for(j=0;jlen;j++) */ -/* { */ -/* printf("%d %s clid %d id %d\n", j, */ -/* g_array_index(cp(i).teams, Team, j).name->str, */ -/* g_array_index(cp(i).teams, Team, j).clid, */ -/* g_array_index(cp(i).teams, Team, j).id); */ -/* } */ -/* for(j=0;jlen;j++) */ -/* { */ -/* printf("%d %s clid %d id %d\n", j, */ -/* ((Team*)g_ptr_array_index(cp(i).user_teams, j))->name->str, */ -/* ((Team*)g_ptr_array_index(cp(i).user_teams, j))->clid, */ -/* ((Team*)g_ptr_array_index(cp(i).user_teams, j))->id); */ -/* } */ } } + +/** End a week round. */ +void +end_week_round(void) +{ + gint i; + gboolean new_week = TRUE; + WeekFunc *end_func = end_week_round_funcs; + + while(*end_func != NULL) + { + (*end_func)(); + end_func++; + } + + week_round++; + + for(i=0;ilen;i++) + if(query_fixture_in_week_round(lig(i).id, week, week_round)) + { + new_week = FALSE; + break; + } + + for(i=0;ilen;i++) + if(query_fixture_in_week_round(cp(i).id, week, week_round)) + { + new_week = FALSE; + break; + } + + if(new_week) + { + week++; + week_round = 1; + + start_week(); + } + + start_week_round(); +} + +/** Calculate the match results of a week round. */ +void +end_week_round_results(void) +{ + gint i, j; + + if(week_round == 1) + { + for(i=0;ilen;i++) + for(j=0;jlen;j++) + if(g_array_index(lig(i).fixtures, Fixture, j).week_number == week && + g_array_index(lig(i).fixtures, Fixture, j).week_round_number == week_round && + g_array_index(lig(i).fixtures, Fixture, j).attendance == -1) + { + live_game_calculate_fixture(&g_array_index(lig(i).fixtures, Fixture, j)); + /*d*/ +/* printf("%d %d %d %25s %2d - %2d %-25s\n", week, week_round, */ +/* g_array_index(lig(i).fixtures, Fixture, j).clid, */ +/* g_array_index(lig(i).fixtures, Fixture, j).teams[0]->name->str, */ +/* g_array_index(lig(i).fixtures, Fixture, j).result[0][0], */ +/* g_array_index(lig(i).fixtures, Fixture, j).result[1][0], */ +/* g_array_index(lig(i).fixtures, Fixture, j).teams[1]->name->str); */ + } + } + else + { + for(i=0;ilen;i++) + for(j=0;jlen;j++) + if(g_array_index(cp(i).fixtures, Fixture, j).week_number == week && + g_array_index(cp(i).fixtures, Fixture, j).week_round_number == week_round && + g_array_index(lig(i).fixtures, Fixture, j).attendance == -1) + { + live_game_calculate_fixture(&g_array_index(cp(i).fixtures, Fixture, j)); + /*d*/ + printf("%d %d %d %25s %d %d %d - %d %d %d %-25s\n", week, week_round, + g_array_index(cp(i).fixtures, Fixture, j).clid, + g_array_index(cp(i).fixtures, Fixture, j).teams[0]->name->str, + g_array_index(cp(i).fixtures, Fixture, j).result[0][0], + g_array_index(cp(i).fixtures, Fixture, j).result[0][1], + g_array_index(cp(i).fixtures, Fixture, j).result[0][2], + g_array_index(cp(i).fixtures, Fixture, j).result[1][0], + g_array_index(cp(i).fixtures, Fixture, j).result[1][1], + g_array_index(cp(i).fixtures, Fixture, j).result[1][2], + g_array_index(cp(i).fixtures, Fixture, j).teams[1]->name->str); + } + } + printf("\n"); +} + +/** Sort league and cup tables. */ +void +end_week_round_sort_tables(void) +{ + gint i, j; + + for(i=0;ilen;i++) + if(query_fixture_in_week_round(lig(i).id, week, week_round)) + g_array_sort_with_data(lig(i).table.elements, + (GCompareDataFunc)table_element_compare_func, + GINT_TO_POINTER(lig(i).id)); + + for(i=0;ilen;i++) + if(cp(i).tables != NULL && cp(i).tables->len != 0 && + query_fixture_in_week_round(cp(i).id, week, week_round) && + g_array_index(cp(i).fixtures, Fixture, cp(i).fixtures->len - 1).round == + g_array_index(cp(i).tables, Table, 0).round) + for(j=0;jlen;j++) + g_array_sort_with_data(g_array_index(cp(i).tables, Table, j).elements, + (GCompareDataFunc)table_element_compare_func, + GINT_TO_POINTER(cp(i).id)); +} + +/** Update cup fixtures. */ +void +end_week_round_update_fixtures(void) +{ + gint i; + + for(i=0;ilen;i++) + if(cp(i).next_fixture_update_week == week && + cp(i).next_fixture_update_week_round == week_round) + fixture_update(&cp(i)); +} + +/** Start a new week round. */ +void +start_week_round(void) +{ + WeekFunc *start_func = start_week_round_funcs; + + while(*start_func != NULL) + { + (*start_func)(); + start_func++; + } +} + +/** Start a new week. */ +void +start_week(void) +{ + WeekFunc *start_func = start_week_funcs; + + while(*start_func != NULL) + { + (*start_func)(); + start_func++; + } +} diff --git a/src/start_end.h b/src/start_end.h index 6137b3c0..49a258f5 100644 --- a/src/start_end.h +++ b/src/start_end.h @@ -18,4 +18,22 @@ start_generate_league_teams(void); void start_load_cup_teams(void); +void +end_week_round(void); + +void +end_week_round_results(void); + +void +end_week_round_sort_tables(void); + +void +end_week_round_update_fixtures(void); + +void +start_week_round(void); + +void +start_week(void); + #endif diff --git a/src/support.h b/src/support.h index 92201b97..a32649e5 100644 --- a/src/support.h +++ b/src/support.h @@ -15,6 +15,7 @@ # include # undef _ # define _(String) dgettext (PACKAGE, String) +# define Q_(String) g_strip_context ((String), gettext (String)) # ifdef gettext_noop # define N_(String) gettext_noop (String) # else @@ -27,6 +28,7 @@ # define dcgettext(Domain,Message,Type) (Message) # define bindtextdomain(Domain,Directory) (Domain) # define _(String) (String) +# define Q_(String) g_strip_context ((String), (String)) # define N_(String) (String) #endif diff --git a/src/table.c b/src/table.c new file mode 100644 index 00000000..61bea8c6 --- /dev/null +++ b/src/table.c @@ -0,0 +1,182 @@ +#include "cup.h" +#include "league.h" +#include "maths.h" +#include "table.h" +#include "variables.h" + +/** Return a nullified table element. + @param team The team pointer of the element. + @param clid The cup/league id. + @param round The cup round. + @see #TableElement */ +TableElement +table_element_new(Team *team) +{ + gint i; + TableElement new; + + new.team = team; + + for(i=0;iresult[0][0] < fix->result[1][0]); + TableElement *elements[2] = {NULL, NULL}; + + table_update_get_elements(elements, fix); + + for(i=0;i<2;i++) + { + elements[i]->values[TABLE_PLAYED]++; + elements[i]->values[TABLE_GF] += fix->result[i][0]; + elements[i]->values[TABLE_GA] += fix->result[!i][0]; + } + + if(fix->result[0][0] == fix->result[1][0]) + for(i=0;i<2;i++) + { + elements[i]->values[TABLE_DRAW]++; + elements[i]->values[TABLE_PTS] += 1; + } + else + { + elements[idx]->values[TABLE_WON]++; + elements[idx]->values[TABLE_PTS] += 3; + elements[!idx]->values[TABLE_LOST]++; + } +} + +/** Get the pointers to the table entries + representing the two teams from the fixture. + @param elements The table entries. + @fix The fixture. */ +void +table_update_get_elements(TableElement **elements, const Fixture *fix) +{ + gint i, j; + Table *table; + + if(fix->clid < ID_CUP_START) + { + table = &league_from_clid(fix->clid)->table; + for(i=0;ielements->len;i++) + { + if(g_array_index(table->elements, TableElement, i).team == fix->teams[0]) + elements[0] = &g_array_index(table->elements, TableElement, i); + else if(g_array_index(table->elements, TableElement, i).team == fix->teams[1]) + elements[1] = &g_array_index(table->elements, TableElement, i); + } + } + else + for(i=0;iclid)->tables->len;i++) + { + table = &g_array_index(cup_from_clid(fix->clid)->tables, Table, i); + if(elements[0] == NULL || elements[1] == NULL) + for(j=0;jelements->len;j++) + { + if(g_array_index(table->elements, TableElement, j).team == fix->teams[0]) + elements[0] = &g_array_index(table->elements, TableElement, j); + else if(g_array_index(table->elements, TableElement, j).team == fix->teams[1]) + elements[1] = &g_array_index(table->elements, TableElement, j); + } + } +} + +/** Compare function used to sort the tables. + @param a The first table element. + @param b The second element. + @param clid_round The clid and the cup round of the table + encoded as a gpointer. */ +gint +table_element_compare_func(gconstpointer a, + gconstpointer b, + gpointer clid_pointer) +{ + gint i; + gint clid, cup_round, value; + TableElement *element1 = (TableElement*)a, + *element2 = (TableElement*)b; + GArray *fixtures; + const Fixture *fix[2] = {NULL, NULL}; + + if(element1->team == element2->team) + return 0; + + clid = GPOINTER_TO_INT(clid_pointer); + if(clid < ID_CUP_START) + { + cup_round = -1; + fixtures = league_from_clid(clid)->fixtures; + } + else + { + cup_round = g_array_index(cup_from_clid(clid)->tables, Table, 0).round; + fixtures = cup_from_clid(clid)->fixtures; + } + + if(element1->values[TABLE_PTS] > element2->values[TABLE_PTS]) + value = -1; + + else if(element1->values[TABLE_PTS] < element2->values[TABLE_PTS]) + value = 1; + + else if(element1->values[TABLE_GF] - element1->values[TABLE_GA] > + element2->values[TABLE_GF] - element2->values[TABLE_GA]) + value = -1; + + else if(element1->values[TABLE_GF] - element1->values[TABLE_GA] < + element2->values[TABLE_GF] - element2->values[TABLE_GA]) + value = 1; + + else if(element1->values[TABLE_GA] > element2->values[TABLE_GA]) + value = -1; + + else if(element1->values[TABLE_GA] < element2->values[TABLE_GA]) + value = 1; + + else + { + for(i=0;ilen;i++) + { + if(g_array_index(fixtures, Fixture, i).round == cup_round && + g_array_index(fixtures, Fixture, i).week_number <= week && + g_array_index(fixtures, Fixture, i).week_round_number <= week_round) + { + if(g_array_index(fixtures, Fixture, i).teams[0] == element1->team && + g_array_index(fixtures, Fixture, i).teams[1] == element2->team) + fix[0] = &g_array_index(fixtures, Fixture, i); + else if(g_array_index(fixtures, Fixture, i).teams[1] == element1->team && + g_array_index(fixtures, Fixture, i).teams[0] == element2->team) + fix[1] = &g_array_index(fixtures, Fixture, i); + } + } + + if(fix[0] == NULL || fix[1] == NULL) + value = -1; + else + { + if(fix[0]->result[0][0] + fix[1]->result[1][0] > + fix[0]->result[1][0] + fix[1]->result[0][0]) + value = -1; + else if(fix[0]->result[0][0] + fix[1]->result[1][0] < + fix[0]->result[1][0] + fix[1]->result[0][0]) + value = 1; + else if(fix[1]->result[1][0] > fix[0]->result[1][0]) + value = -1; + else + value = 1; + } + } + + return value; +} diff --git a/src/table.h b/src/table.h new file mode 100644 index 00000000..d2a0bc93 --- /dev/null +++ b/src/table.h @@ -0,0 +1,23 @@ +#ifndef TABLE_H +#define TABLE_H + +#include "bygfoot.h" +#include "fixture_struct.h" +#include "table_struct.h" + +TableElement +table_element_new(Team *team); + +void +table_update(const Fixture *fix); + +void +table_update_get_elements(TableElement **elements, const Fixture *fix); + +gint +table_element_compare_func(gconstpointer a, + gconstpointer b, + gpointer clid_round); + +#endif + diff --git a/src/table_struct.h b/src/table_struct.h index 80eb8233..6077862b 100644 --- a/src/table_struct.h +++ b/src/table_struct.h @@ -40,6 +40,8 @@ typedef struct { GString *name; gint clid; + /** The cup round (or -1 if it's a league). */ + gint round; GArray *elements; } Table; diff --git a/src/team.c b/src/team.c index cec84ac5..8341d1f8 100644 --- a/src/team.c +++ b/src/team.c @@ -3,35 +3,12 @@ #include "free.h" #include "league.h" #include "maths.h" +#include "option.h" #include "player.h" #include "team.h" +#include "user.h" #include "variables.h" -/** - Constants determining the probabilities for - the playing styles of CPU teams. - @see team_assign_playing_style(). -*/ -#define CONSTANT_TEAM_PLAYING_STYLE_PROB1 0.1 -#define CONSTANT_TEAM_PLAYING_STYLE_PROB2 0.25 -#define CONSTANT_TEAM_PLAYING_STYLE_PROB3 0.75 -#define CONSTANT_TEAM_PLAYING_STYLE_PROB4 0.9 - -/** - Constants determining the probabilities for - the playing structures of CPU teams. - @see team_assign_playing_structure(). -*/ -#define CONSTANT_TEAM_PLAYING_STRUCTURE_PROB1 0.15 -#define CONSTANT_TEAM_PLAYING_STRUCTURE_PROB2 0.5 -#define CONSTANT_TEAM_PLAYING_STRUCTURE_PROB3 0.7 -#define CONSTANT_TEAM_PLAYING_STRUCTURE_PROB4 0.85 - -/** Kinda hard to explain. - @see team_generate_players() - @see player_generate() */ -#define CONSTANT_TEAM_SKILL_VARIANCE 0.2//0.075/*d*/ - /** Generate a team with default values, e.g. random playing structure and an empty string @@ -60,7 +37,6 @@ team_new(void) /** Return a random playing style. @see The #TeamPlayingStyle enumeration. - @see The #CONSTANT_TEAM_PLAYING_STYLE_PROB1 define. */ gint team_assign_playing_style(void) @@ -70,16 +46,16 @@ team_assign_playing_style(void) rndom = math_rnd(0,1); /* all out defend */ - if(rndom < CONSTANT_TEAM_PLAYING_STYLE_PROB1) + if(rndom < const_float("float_team_playing_style_prob1")) return -2; /* defend */ - else if(rndom < CONSTANT_TEAM_PLAYING_STYLE_PROB2) + else if(rndom < const_float("float_team_playing_style_prob2")) return -1; /* balanced */ - else if(rndom < CONSTANT_TEAM_PLAYING_STYLE_PROB3) + else if(rndom < const_float("float_team_playing_style_prob3")) return 0; /* attack */ - else if(rndom < CONSTANT_TEAM_PLAYING_STYLE_PROB4) + else if(rndom < const_float("float_team_playing_style_prob4")) return 1; /* all out attack */ @@ -88,20 +64,19 @@ team_assign_playing_style(void) /** Return a random playing structure. - @see The #CONSTANT_TEAM_PLAYING_STRUCTURE_PROB1 define. */ gint team_assign_playing_structure(void) { gfloat rndom = math_rnd(0,1); - if(rndom < CONSTANT_TEAM_PLAYING_STRUCTURE_PROB1) + if(rndom < const_float("float_team_playing_structure_prob1")) return 532; - else if(rndom < CONSTANT_TEAM_PLAYING_STRUCTURE_PROB2) + else if(rndom < const_float("float_team_playing_structure_prob2")) return 442; - else if(rndom < CONSTANT_TEAM_PLAYING_STRUCTURE_PROB3) + else if(rndom < const_float("float_team_playing_structure_prob3")) return 352; - else if(rndom < CONSTANT_TEAM_PLAYING_STRUCTURE_PROB4) + else if(rndom < const_float("float_team_playing_structure_prob4")) return 433; return 343; @@ -128,8 +103,8 @@ void team_generate_players(Team *tm) { gint i; - gfloat skill_factor = math_rnd(1 - CONSTANT_TEAM_SKILL_VARIANCE, - 1 + CONSTANT_TEAM_SKILL_VARIANCE); + gfloat skill_factor = math_rnd(1 - const_float("float_team_skill_variance"), + 1 + const_float("float_team_skill_variance")); Player new; gint average_skill; @@ -143,9 +118,9 @@ team_generate_players(Team *tm) (gfloat)team_return_league_cup_value_int(tm, LEAGUE_CUP_VALUE_SKILL_DIFF)) * skill_factor; - average_skill = CLAMP(average_skill, 0, CONSTANT_PLAYER_MAX_SKILL); + average_skill = CLAMP(average_skill, 0, const_int("int_player_max_skill")); - for(i=0;iplayers, new); @@ -218,7 +193,7 @@ team_get_league_cup_string(const Team *tm, gint value_type, gchar *buf) { gint idx = league_cup_get_index_from_clid(tm->clid); - if(tm->clid >= ID_CUP_START) + if(tm->clid < ID_CUP_START) switch(value_type) { default: @@ -273,7 +248,7 @@ team_copy(const Team *source, Team *dest) for(i=0;iplayers->len;i++) { - new_player = player_new(dest, CONSTANT_PLAYER_MAX_SKILL); + new_player = player_new(dest, const_int("int_player_max_skill")); free_player(&new_player); player_copy(&g_array_index(source->players, Player, i), &new_player); @@ -487,17 +462,162 @@ team_get_next_fixture(const Team *tm) return fix; } -/** Calculate the average cskill of the first 11 players. - @param tm The team we examine. - @return The average skill. */ -gfloat -team_average_cskill(const Team *tm) +/** Check whether the team is a user-managed team. + @param tm The team we examine. + @return The user's index in the #users array or -1.*/ +gint +team_is_user(const Team *tm) { gint i; + + for(i=0;ilen;i++) + if(usr(i).tm == tm) + return i; + + return -1; +} + +/** Return the overall average skill or + the cskill of the first 11 players. + @param tm The team we examine. + @param cskill Whether to take into account all players. */ +gfloat +team_get_average_skill(const Team *tm, gboolean cskill) +{ + gint i, counter = 0; gfloat sum = 0; - for(i=0;iplayers->len);i++) - sum += ((gfloat)player_of(tm, i)->cskill * powf((gfloat)player_of(tm, i)->fitness / 100, 0.25)); + if(!cskill) + { + for(i=0;iplayers->len;i++) + if(player_of(tm, i)->cskill != 0) + { + sum += player_of(tm, i)->skill; + counter++; + } + } + else + for(i=0;i<11;i++) + { + sum += player_of(tm, i)->cskill * + powf((gfloat)player_of(tm, i)->fitness / 100, + const_float("float_player_fitness_exponent")); + counter++; + } - return sum / (gfloat)(i - 1); + return sum / (gfloat)counter; +} + +/** Return the rank of the team. + @param tm The team we examine. */ +gint +team_rank(const Team *tm) +{ + gint i, j; + GArray *elements = NULL; + + if(tm->clid < ID_CUP_START) + { + elements = league_from_clid(tm->clid)->table.elements; + for(i=0;ilen;i++) + if(g_array_index(elements, TableElement, i).team == tm) + return i + 1; + } + else + { + for(i=0;iclid)->tables->len;i++) + { + elements = g_array_index(cup_from_clid(tm->clid)->tables, Table, i).elements; + for(j=0;jlen;j++) + if(g_array_index(elements, TableElement, j).team == tm) + return j + 1; + } + } + + return -1; +} + +/** Return the structure that fits the positions of + the first 11 players. + @param tm The team we examine. + @return A new structure. */ +gint +team_find_appropriate_structure(const Team *tm) +{ + gint i; + gint structure = 0; + + for(i=1;i<11;i++) + { + if(player_of(tm, i)->pos == PLAYER_POS_DEFENDER) + structure += 100; + else if(player_of(tm, i)->pos == PLAYER_POS_MIDFIELDER) + structure += 10; + else + structure++; + } + + return structure; +} + +/** Change the structure of a team and the appropriate + cpos and cskill values. + @param tm The team. + @param new_structure The new structure value, e.g. 442. */ +void +team_change_structure(Team *tm, gint new_structure) +{ + gint i; + + tm->structure = new_structure; + + for(i=1;i<11;i++) + { + player_of(tm, i)->cpos = + player_get_position_from_structure(new_structure, i); + + player_of(tm, i)->cskill = + player_get_cskill(player_of(tm, i)); + } +} + +/* Try to set each of the first 11 players on his + favoured position and sort the substitutes by position. + @param tm The team we rearrange. */ +void +team_rearrange(Team *tm) +{ + gint i, j; + + /* reaarrange field players */ + for(i=0;i<11;i++) + { + if(player_of(tm, i)->pos != + player_of(tm, i)->cpos) + { + for(j=i+1;j<11;j++) + if(player_of(tm, j)->pos == + player_of(tm, i)->cpos && + player_of(tm, j)->cskill > 0) + { + player_swap(tm, i, tm, j); + break; + } + } + } + + /* sort substitutes */ + i = 11; + while(i != tm->players->len) + { + for(j=i+1;jplayers->len;j++) + if(player_of(tm, i)->pos > + player_of(tm, j)->pos) + { + player_swap(tm, i, tm, j); + i = 10; + break; + } + i++; + } } diff --git a/src/team.h b/src/team.h index 7318c20e..07353ad6 100644 --- a/src/team.h +++ b/src/team.h @@ -6,9 +6,6 @@ #include "fixture_struct.h" #include "team_struct.h" -/** Maximum number of players in a team. */ -#define CONSTANT_TEAM_MAX_PLAYERS 20 - Team team_new(void); @@ -64,6 +61,21 @@ Fixture* team_get_next_fixture(const Team *tm); gfloat -team_average_cskill(const Team *tm); +team_get_average_skill(const Team *tm, gboolean cskill); + +gint +team_is_user(const Team *tm); + +gint +team_rank(const Team *tm); + +void +team_change_structure(Team *tm, gint new_structure); + +gint +team_find_appropriate_structure(const Team *tm); + +void +team_rearrange(Team *tm); #endif diff --git a/src/transfer.h b/src/transfer.h index 4a5882ac..a12ef6ee 100644 --- a/src/transfer.h +++ b/src/transfer.h @@ -4,9 +4,6 @@ #include "bygfoot.h" #include "team.h" -#define CONSTANT_TRANSFER_MAX_PLAYERS 20 -#define CONSTANT_TRANSFER_DEADLINE 35 - /** Structure representing a player on the transfer list. */ typedef struct { diff --git a/src/treeview.c b/src/treeview.c index 30b68df6..87351290 100644 --- a/src/treeview.c +++ b/src/treeview.c @@ -7,69 +7,30 @@ #include "live_game.h" #include "maths.h" #include "misc.h" +#include "option.h" #include "support.h" #include "team.h" #include "treeview.h" #include "treeview_cell.h" +#include "user.h" #include "variables.h" #include "window.h" -/** Return the filename of the icon going with the LiveGameEvent - with type event_type. - @param event_type The type of the event. - @return A filename specifying a pixmap. */ -gchar* -treeview_live_game_icon(gint event_type) +/** Select the row that's been clicked on. */ +void +treeview_select_row(GtkTreeView *treeview, GdkEventButton *event) { - switch(event_type) - { - default: - return ""; - break; - case LIVE_GAME_EVENT_FOUL_YELLOW: - return "yellow.png"; - break; - case LIVE_GAME_EVENT_FOUL_RED: - return "red.png"; - break; - case LIVE_GAME_EVENT_SEND_OFF: - return "red.png"; - break; - case LIVE_GAME_EVENT_SAVE: - return "save.png"; - break; - case LIVE_GAME_EVENT_GOAL: - return "goal.png"; - break; - } + GtkTreeSelection *selection = + gtk_tree_view_get_selection(treeview); + GtkTreePath *path; + + if(!gtk_tree_view_get_path_at_pos(treeview, + event->x, event->y, + &path, NULL, NULL, NULL)) + return; - return ""; -} - -/** Return a new pixbuf created from the specified filename. - @param filename Name of a pixmap file located in one of the support directories. - @return A new pixbuf or NULL on error. */ -GdkPixbuf* -treeview_pixbuf_from_filename(gchar *filename) -{ - GdkPixbuf *symbol = NULL; - GError *error = NULL; - gchar *symbol_file = NULL; - - if(filename != NULL && strlen(filename) != 0) - { - symbol_file = file_find_support_file(filename); - if(symbol_file != NULL) - { - symbol = gdk_pixbuf_new_from_file(symbol_file, &error); - misc_print_error(&error, FALSE); - g_free(symbol_file); - } - } - else - symbol = NULL; - - return symbol; + gtk_tree_selection_select_path(selection, path); + gtk_tree_path_free(path); } /** Return the number in the 'column'th column of the currently @@ -130,7 +91,7 @@ treeview_clear(GtkTreeView *treeview) gint i; gint number_of_columns; GtkTreeView *list = (treeview == NULL) ? - GTK_TREE_VIEW(lookup_widget(main_window, "player_info")) : + GTK_TREE_VIEW(lookup_widget(window.main, "player_info")) : treeview; gtk_tree_view_set_model(GTK_TREE_VIEW(list), @@ -167,6 +128,64 @@ treeview_get_col_number_column (GtkTreeViewColumn *col) return num; } +/** Return the filename of the icon going with the LiveGameEvent + with type event_type. + @param event_type The type of the event. + @return A filename specifying a pixmap. */ +gchar* +treeview_live_game_icon(gint event_type) +{ + switch(event_type) + { + default: + return ""; + break; + case LIVE_GAME_EVENT_FOUL_YELLOW: + return "yellow.png"; + break; + case LIVE_GAME_EVENT_FOUL_RED: + return "red.png"; + break; + case LIVE_GAME_EVENT_SEND_OFF: + return "red.png"; + break; + case LIVE_GAME_EVENT_SAVE: + return "save.png"; + break; + case LIVE_GAME_EVENT_GOAL: + return "goal.png"; + break; + } + + return ""; +} + +/** Return a new pixbuf created from the specified filename. + @param filename Name of a pixmap file located in one of the support directories. + @return A new pixbuf or NULL on error. */ +GdkPixbuf* +treeview_pixbuf_from_filename(gchar *filename) +{ + GdkPixbuf *symbol = NULL; + GError *error = NULL; + gchar *symbol_file = NULL; + + if(filename != NULL && strlen(filename) != 0) + { + symbol_file = file_find_support_file(filename); + if(symbol_file != NULL) + { + symbol = gdk_pixbuf_new_from_file(symbol_file, &error); + misc_print_error(&error, FALSE); + g_free(symbol_file); + } + } + else + symbol = NULL; + + return symbol; +} + /** Creates the model for the treeview in the team selection window. The model contains a list of all the teams from the leagues in @@ -174,10 +193,11 @@ treeview_get_col_number_column (GtkTreeViewColumn *col) teams from international cups are shown, too. @param show_cup_teams Whether or not teams from international cups are shown. + @param show_user_teams Whether or not user teams are shown. @return The model containing the team names. */ GtkTreeModel* -treeview_create_team_selection_list(gboolean show_cup_teams) +treeview_create_team_selection_list(gboolean show_cup_teams, gboolean show_user_teams) { gint i, j, cnt = 1; GtkListStore *liststore; @@ -196,13 +216,16 @@ treeview_create_team_selection_list(gboolean show_cup_teams) for(j=0;jlen;j++) { - gtk_list_store_append(liststore, &iter); - gtk_list_store_set(liststore, &iter, - 0, cnt++, - 1, symbol, - 2, (gpointer)&g_array_index(lig(i).teams, Team, j), - 3, lig(i).name->str, - -1); + if(team_is_user(&g_array_index(lig(i).teams, Team, j)) == -1) + { + gtk_list_store_append(liststore, &iter); + gtk_list_store_set(liststore, &iter, + 0, cnt++, + 1, symbol, + 2, (gpointer)&g_array_index(lig(i).teams, Team, j), + 3, lig(i).name->str, + -1); + } } if(symbol != NULL) @@ -257,8 +280,6 @@ treeview_set_up_team_selection_treeview (GtkTreeView *treeview) gtk_tree_view_column_pack_start(col, renderer, TRUE); gtk_tree_view_column_add_attribute(col, renderer, "text", 0); - if(strcmp(font_name->str, "0") != 0) - g_object_set(renderer, "font", font_name->str, NULL); /* Flags */ col = gtk_tree_view_column_new(); @@ -293,12 +314,14 @@ treeview_set_up_team_selection_treeview (GtkTreeView *treeview) @param treeview The treeview we show the list in. @param show_cup_teams Whether or not teams from international cups are shown. + @param show_user_teams Whether or not user teams are shown. */ void -treeview_show_team_list(GtkTreeView *treeview, gboolean show_cup_teams) +treeview_show_team_list(GtkTreeView *treeview, gboolean show_cup_teams, + gboolean show_user_teams) { GtkTreeModel *team_list = - treeview_create_team_selection_list(show_cup_teams); + treeview_create_team_selection_list(show_cup_teams, show_user_teams); GtkTreeSelection *selection; treeview_clear(treeview); @@ -337,7 +360,7 @@ treeview_create_player_list(GPtrArray *players, gint *attributes, gint max, gboo gtk_list_store_append(liststore, &iter); if(show_separator && i == 11) { - gtk_list_store_set(liststore, &iter, 0, CONSTANT_TREEVIEW_CELL_INT_EMPTY, -1); + gtk_list_store_set(liststore, &iter, 0, const_int("int_treeview_cell_int_empty"), -1); for(j=0;jtm), attribute, TRUE); } /** Show the commentary and the minute belonging to the unit. @@ -465,11 +491,11 @@ treeview_live_game_show_commentary(const LiveGameUnit *unit) GdkPixbuf *symbol = NULL; GtkAdjustment *adjustment = gtk_scrolled_window_get_vadjustment( - GTK_SCROLLED_WINDOW(lookup_widget(live_game.window, + GTK_SCROLLED_WINDOW(lookup_widget(window.live, "scrolledwindow9"))); GtkListStore *liststore = GTK_LIST_STORE( - gtk_tree_view_get_model(GTK_TREE_VIEW(lookup_widget(live_game.window, "treeview_commentary")))); + gtk_tree_view_get_model(GTK_TREE_VIEW(lookup_widget(window.live, "treeview_commentary")))); GtkTreeIter iter; gchar buf[SMALL]; @@ -494,7 +520,6 @@ treeview_live_game_show_commentary(const LiveGameUnit *unit) GtkTreeModel* treeview_live_game_create_init_commentary(const LiveGameUnit *unit) { - gint i, j; GtkListStore *liststore; GtkTreeIter iter; GdkPixbuf *symbol = NULL; @@ -525,7 +550,7 @@ void treeview_live_game_set_up_commentary(void) { GtkTreeView *treeview = - GTK_TREE_VIEW(lookup_widget(live_game.window, "treeview_commentary")); + GTK_TREE_VIEW(lookup_widget(window.live, "treeview_commentary")); GtkTreeViewColumn *col; GtkCellRenderer *renderer; @@ -560,7 +585,7 @@ void treeview_live_game_show_initial_commentary(const LiveGameUnit *unit) { GtkTreeView *treeview = - GTK_TREE_VIEW(lookup_widget(live_game.window, "treeview_commentary")); + GTK_TREE_VIEW(lookup_widget(window.live, "treeview_commentary")); GtkTreeModel *model = NULL; treeview_clear(treeview); @@ -595,8 +620,8 @@ treeview_live_game_create_result(const LiveGameUnit *unit) GDK_TYPE_PIXBUF); gtk_list_store_append(liststore, &iter); - gtk_list_store_set(liststore, &iter, 0, NULL, 1, (gpointer)live_game.fix, - 2, (gpointer)live_game.fix, 3, (gpointer)live_game.fix, 4, NULL, -1); + gtk_list_store_set(liststore, &iter, 0, NULL, 1, (gpointer)usr(stat2).live_game.fix, + 2, (gpointer)unit, 3, (gpointer)usr(stat2).live_game.fix, 4, NULL, -1); gtk_list_store_set(liststore, &iter, 0 + (unit->possession == 1) * 4, symbol, -1); @@ -611,7 +636,7 @@ void treeview_live_game_set_up_result(void) { GtkTreeView *treeview = - GTK_TREE_VIEW(lookup_widget(live_game.window, "treeview_result")); + GTK_TREE_VIEW(lookup_widget(window.live, "treeview_result")); GtkTreeViewColumn *col; GtkCellRenderer *renderer; @@ -664,7 +689,7 @@ void treeview_live_game_show_result(const LiveGameUnit *unit) { GtkTreeView *treeview = - GTK_TREE_VIEW(lookup_widget(live_game.window, "treeview_result")); + GTK_TREE_VIEW(lookup_widget(window.live, "treeview_result")); GtkTreeModel *model = NULL; treeview_clear(treeview); @@ -677,3 +702,88 @@ treeview_live_game_show_result(const LiveGameUnit *unit) gtk_tree_view_set_model(treeview, model); g_object_unref(model); } + +/** Fill a tree model with the users. */ +GtkTreeModel* +treeview_create_users_startup(void) +{ + gint i; + GtkListStore *liststore; + GtkTreeIter iter; + + liststore = gtk_list_store_new(4, + G_TYPE_INT, + G_TYPE_STRING, + G_TYPE_STRING, + G_TYPE_STRING); + for(i=0;ilen;i++) + { + gtk_list_store_append(liststore, &iter); + gtk_list_store_set(liststore, &iter, 0, i + 1, + 1, usr(i).name->str, + 2, usr(i).tm->name->str, + -1); + + if(stat0 == STATUS_TEAM_SELECTION && usr(i).scout != 0) + { + if(usr(i).scout == 1) + gtk_list_store_set(liststore, &iter, 3, + lig(0).name->str, -1); + else + gtk_list_store_set(liststore, &iter, 3, + lig(ligs->len - 1).name->str, -1); + } + else + gtk_list_store_set(liststore, &iter, 3, + league_from_clid(usr(i).tm->clid)->name->str, -1); + } + + return GTK_TREE_MODEL(liststore); +} + +/** Set up the users treeview. + @param treeview The treeview we use. */ +void +treeview_set_up_users_startup(GtkTreeView *treeview) +{ + gint i; + GtkTreeViewColumn *col; + GtkCellRenderer *renderer; + gchar *titles[4] = + {_(""), + _("Name"), + _("Team"), + _("Start in")}; + + gtk_tree_selection_set_mode(gtk_tree_view_get_selection(treeview), + GTK_SELECTION_SINGLE); + + for(i=0;i<4;i++) + { + col = gtk_tree_view_column_new(); + gtk_tree_view_column_set_title(col, titles[i]); + gtk_tree_view_append_column(treeview, col); + renderer = gtk_cell_renderer_text_new(); + gtk_tree_view_column_pack_start(col, renderer, TRUE); + gtk_tree_view_column_add_attribute(col, renderer, + "text", i); + } +} + +/** Show the list of users at startup. + @param treeview The treeview we use. */ +void +treeview_show_users_startup(void) +{ + GtkTreeView *treeview = + GTK_TREE_VIEW(lookup_widget(window.startup_users, "treeview_users")); + GtkTreeModel *model = NULL; + + treeview_clear(treeview); + gtk_tree_view_set_headers_visible(treeview, TRUE); + + treeview_set_up_users_startup(treeview); + model = treeview_create_users_startup(); + gtk_tree_view_set_model(treeview, model); + g_object_unref(model); +} diff --git a/src/treeview.h b/src/treeview.h index 845e0b0c..f167c266 100644 --- a/src/treeview.h +++ b/src/treeview.h @@ -4,6 +4,10 @@ #include "bygfoot.h" #include "live_game_struct.h" #include "player_struct.h" +#include "user_struct.h" + +void +treeview_select_row(GtkTreeView *treeview, GdkEventButton *event); GdkPixbuf* treeview_pixbuf_from_filename(gchar *filename); @@ -24,13 +28,15 @@ gint treeview_get_col_number_column (GtkTreeViewColumn *col); GtkTreeModel* -treeview_create_team_selection_list(gboolean show_cup_teams); +treeview_create_team_selection_list(gboolean show_cup_teams, + gboolean show_user_teams); void treeview_set_up_team_selection_treeview (GtkTreeView *treeview); void -treeview_show_team_list(GtkTreeView *treeview, gboolean show_cup_teams); +treeview_show_team_list(GtkTreeView *treeview, gboolean show_cup_teams, + gboolean show_user_teams); GtkTreeModel* treeview_create_player_list(GPtrArray *players, gint *attributes, gint max, gboolean show_separator); @@ -43,7 +49,7 @@ treeview_show_player_list(GtkTreeView *treeview, GPtrArray *players, PlayerListA gboolean show_separator); void -treeview_show_user_player_list(gint player_list); +treeview_show_user_player_list(const User *user, gint player_list); void treeview_live_game_show_commentary(const LiveGameUnit *unit); @@ -69,4 +75,13 @@ treeview_live_game_set_up_result(void); void treeview_live_game_show_result(const LiveGameUnit *unit); +void +treeview_show_users_startup(void); + +GtkTreeModel* +treeview_create_users_startup(void); + +void +treeview_set_up_users_startup(GtkTreeView *treeview); + #endif diff --git a/src/treeview_cell.c b/src/treeview_cell.c index a3c0f625..d7f88b68 100644 --- a/src/treeview_cell.c +++ b/src/treeview_cell.c @@ -1,49 +1,12 @@ #include "maths.h" #include "misc.h" +#include "option.h" #include "player.h" #include "team.h" #include "treeview.h" #include "treeview_cell.h" - -#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_GOALIE_BG "Black" -#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_GOALIE_FG "White" -#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_DEFENDER_BG "Darkgreen" -#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_DEFENDER_FG "White" -#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_MIDFIELDER_BG "Darkblue" -#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_MIDFIELDER_FG "White" -#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_FORWARD_BG "Darkred" -#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_FORWARD_FG "White" - -#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_INJURY "Lightgreen" -#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_BANNED "Red" - -#define CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_FITNESS_BELOW1 85 -#define CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_FITNESS_BELOW2 70 -#define CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_FITNESS_BELOW3 60 -#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_FITNESS_NORMAL "DarkGreen" -#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_FITNESS_BELOW1 "DarkOrange" -#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_FITNESS_BELOW2 "OrangeRed" -#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_FITNESS_BELOW3 "Red" - -#define CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_CONTRACT_BELOW1 52 -#define CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_CONTRACT_BELOW2 40 -#define CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_CONTRACT_BELOW3 20 -#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_CONTRACT_NORMAL "DarkGreen" -#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_CONTRACT_BELOW1 "DarkOrange" -#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_CONTRACT_BELOW2 "OrangeRed" -#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_CONTRACT_BELOW3 "Red" - -#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_BAD_CSKILL_BG "Lightblue" -#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_BAD_CSKILL_FG "Red" - -/** Font attributes for the live game window result. */ -#define CONSTANT_TREEVIEW_CELL_LIVE_GAME_RESULT_ATTRIBUTES "weight='bold' size='large'" - -/* #define CONSTANT_TREEVIEW_CELL_COLOR_ "" */ -/* #define CONSTANT_TREEVIEW_CELL_COLOR_ "" */ -/* #define CONSTANT_TREEVIEW_CELL_COLOR_ "" */ -/* #define CONSTANT_TREEVIEW_CELL_COLOR_ "" */ - +#include "user.h" +#include "variables.h" /** Render a cell in the team selection treeview. @see The GTK reference. */ @@ -57,9 +20,6 @@ treeview_cell_team_selection(GtkTreeViewColumn *col, gint column = GPOINTER_TO_INT(user_data); gpointer team_pointer; - if(strcmp(font_name->str, "0") != 0) - g_object_set(renderer, "font", font_name->str, NULL); - gtk_tree_model_get(model, iter, column, &team_pointer, -1); if(column == 2) @@ -68,8 +28,7 @@ treeview_cell_team_selection(GtkTreeViewColumn *col, g_warning("treeview_cell_team_selection: unknown column: %d\n", column); } -/** Render an integer. This is only so that we know when to draw nothing. - @see #CONSTANT_TREEVIEW_CELL_INT_EMPTY */ +/** Render an integer. This is only so that we know when to draw nothing. */ void treeview_cell_int_to_cell(GtkTreeViewColumn *col, GtkCellRenderer *renderer, @@ -81,12 +40,12 @@ treeview_cell_int_to_cell(GtkTreeViewColumn *col, gint value; gchar buf[SMALL]; - if(strcmp(font_name->str, "0") != 0) - g_object_set(renderer, "font", font_name->str, NULL); + if(strcmp(usr(current_user).font_name->str, "0") != 0) + g_object_set(renderer, "font", usr(current_user).font_name->str, NULL); gtk_tree_model_get(model, iter, column, &value, -1); - if(value == CONSTANT_TREEVIEW_CELL_INT_EMPTY) + if(value == const_int("int_treeview_cell_int_empty")) strcpy(buf, ""); else sprintf(buf, "%d", value); @@ -109,11 +68,11 @@ treeview_cell_player_to_cell(GtkTreeViewColumn *col, bg_color[SMALL]; Player *pl; - if(strcmp(font_name->str, "0") != 0) - g_object_set(renderer, "font", font_name->str, NULL); + if(strcmp(usr(current_user).font_name->str, "0") != 0) + g_object_set(renderer, "font", usr(current_user).font_name->str, NULL); - strcpy(fg_color, "black"); - strcpy(bg_color, "white"); + strcpy(fg_color, const_str("string_treeview_cell_color_default_foreground")); + strcpy(bg_color, const_str("string_treeview_cell_color_default_background")); strcpy(buf, ""); gtk_tree_model_get(model, iter, column, &pl, -1); @@ -136,7 +95,7 @@ treeview_cell_player_to_cell(GtkTreeViewColumn *col, treeview_cell_player_pos_to_cell(renderer, buf, pl->pos); break; case PLAYER_LIST_ATTRIBUTE_CSKILL: - sprintf(buf, "%d", pl->cskill); + treeview_cell_player_cskill_to_cell(renderer, buf, pl); break; case PLAYER_LIST_ATTRIBUTE_SKILL: sprintf(buf, "%d", pl->skill); @@ -161,7 +120,7 @@ treeview_cell_player_to_cell(GtkTreeViewColumn *col, sprintf(buf, "%d", (gint)rint((gfloat)pl->age / 52)); break; case PLAYER_LIST_ATTRIBUTE_ETAL: - sprintf(buf, "%d", pl->etal); + sprintf(buf, "%d", pl->etal[usr(current_user).scout % 10]); break; case PLAYER_LIST_ATTRIBUTE_VALUE: misc_print_grouped_int(pl->value, buf, FALSE); @@ -192,14 +151,18 @@ treeview_cell_player_contract_to_cell(GtkCellRenderer *renderer, gchar *buf, gin { sprintf(buf, "%.1f", (gfloat)contract_time / 52); - if(contract_time < CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_CONTRACT_BELOW3) - g_object_set(renderer, "foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_CONTRACT_BELOW3, NULL); - else if(contract_time < CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_CONTRACT_BELOW2) - g_object_set(renderer, "foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_CONTRACT_BELOW2, NULL); - else if(contract_time < CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_CONTRACT_BELOW1) - g_object_set(renderer, "foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_CONTRACT_BELOW1, NULL); + if(contract_time < const_int("int_treeview_cell_limit_player_contract_below3")) + g_object_set(renderer, "foreground", + const_str("string_treeview_cell_color_player_contract_below3"), NULL); + else if(contract_time < const_int("int_treeview_cell_limit_player_contract_below2")) + g_object_set(renderer, "foreground", + const_str("string_treeview_cell_color_player_contract_below2"), NULL); + else if(contract_time < const_int("int_treeview_cell_limit_player_contract_below1")) + g_object_set(renderer, "foreground", + const_str("string_treeview_cell_color_player_contract_below1"), NULL); else - g_object_set(renderer, "foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_CONTRACT_NORMAL, NULL); + g_object_set(renderer, "foreground", + const_str("string_treeview_cell_color_player_contract_normal"), NULL); } /** Render a cell of player yellow cards. @@ -241,34 +204,29 @@ treeview_cell_player_cards_to_cell(gchar *buf, const Player *pl) void treeview_cell_player_status_to_cell(GtkCellRenderer *renderer, gchar *buf, const Player *pl) { - gint i; - Fixture *fix = team_get_next_fixture(pl->team); + gint ban = player_is_banned(pl); if(pl->health != PLAYER_INJURY_NONE) { sprintf(buf, _("INJ(%d)"), pl->recovery); g_object_set(renderer, "background", - CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_INJURY, NULL); + const_str("string_treeview_cell_color_player_injury"), NULL); return; } - if(fix == NULL) + if(ban > 0) { - strcpy(buf, "OK"); - return; + sprintf(buf, _("BAN(%d)"), ban); + g_object_set(renderer, "background", + const_str("string_treeview_cell_color_player_banned"), NULL); } + else + strcpy(buf, _("OK")); - for(i=0;icards->len;i++) - if(g_array_index(pl->cards, PlayerCard, 0).clid == fix->clid) - { - sprintf(buf, _("BAN(%d)"), g_array_index(pl->cards, PlayerCard, 0).red); - g_object_set(renderer, "background", - CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_BANNED, NULL); - return; - } - - strcpy(buf, "OK"); + if(ban == -1) + g_object_set(renderer, "background", + const_str("string_treeview_cell_color_player_yellow_danger"), NULL); } /** Render a cell of player games or goals. @@ -325,14 +283,18 @@ treeview_cell_player_fitness_to_cell(GtkCellRenderer *renderer, gchar *buf, gint { sprintf(buf, "%d%%", fitness); - if(fitness < CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_FITNESS_BELOW3) - g_object_set(renderer, "foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_FITNESS_BELOW3, NULL); - else if(fitness < CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_FITNESS_BELOW2) - g_object_set(renderer, "foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_FITNESS_BELOW2, NULL); - else if(fitness < CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_FITNESS_BELOW1) - g_object_set(renderer, "foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_FITNESS_BELOW1, NULL); + if(fitness < const_int("int_treeview_cell_limit_player_fitness_below3")) + g_object_set(renderer, "foreground", + const_str("string_treeview_cell_color_player_fitness_below3"), NULL); + else if(fitness < const_int("int_treeview_cell_limit_player_fitness_below2")) + g_object_set(renderer, "foreground", + const_str("string_treeview_cell_color_player_fitness_below2"), NULL); + else if(fitness < const_int("int_treeview_cell_limit_player_fitness_below2")) + g_object_set(renderer, "foreground", + const_str("string_treeview_cell_color_player_fitness_below2"), NULL); else - g_object_set(renderer, "foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_FITNESS_NORMAL, NULL); + g_object_set(renderer, "foreground", + const_str("string_treeview_cell_color_player_fitness_normal"), NULL); } /** Render a cell of player position or cposition. @@ -346,23 +308,31 @@ treeview_cell_player_pos_to_cell(GtkCellRenderer *renderer, gchar *buf, gint pos { default: strcpy(buf, "G"); - g_object_set(renderer, "background", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_GOALIE_BG, - "foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_GOALIE_FG, NULL); + g_object_set(renderer, "background", + const_str("string_treeview_cell_color_player_pos_goalie_bg"), + "foreground", + const_str("string_treeview_cell_color_player_pos_goalie_fg"), NULL); break; case PLAYER_POS_DEFENDER: strcpy(buf, "D"); - g_object_set(renderer, "background", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_DEFENDER_BG, - "foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_DEFENDER_FG, NULL); + g_object_set(renderer, "background", + const_str("string_treeview_cell_color_player_pos_defender_bg"), + "foreground", + const_str("string_treeview_cell_color_player_pos_defender_fg"), NULL); break; case PLAYER_POS_MIDFIELDER: strcpy(buf, "M"); - g_object_set(renderer, "background", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_MIDFIELDER_BG, - "foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_MIDFIELDER_FG, NULL); + g_object_set(renderer, "background", + const_str("string_treeview_cell_color_player_pos_midfielder_bg"), + "foreground", + const_str("string_treeview_cell_color_player_pos_midfielder_fg"), NULL); break; case PLAYER_POS_FORWARD: strcpy(buf, "F"); - g_object_set(renderer, "background", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_FORWARD_BG, - "foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_FORWARD_FG, NULL); + g_object_set(renderer, "background", + const_str("string_treeview_cell_color_player_pos_forward_bg"), + "foreground", + const_str("string_treeview_cell_color_player_pos_forward_fg"), NULL); break; } } @@ -375,12 +345,20 @@ void treeview_cell_player_cskill_to_cell(GtkCellRenderer *renderer, gchar *buf, const Player *pl) { sprintf(buf, "%d", (gint)rint((gfloat)pl->cskill * - powf((gfloat)pl->fitness, - CONSTANT_PLAYER_FITNESS_IMPACT_ON_SKILL))); + powf((gfloat)pl->fitness / 100, + const_float("float_player_fitness_impact_on_skill")))); if(pl->cskill < pl->skill) - g_object_set(renderer, "background", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_BAD_CSKILL_BG, - "foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_BAD_CSKILL_FG, NULL); + g_object_set(renderer, "background", + const_str("string_treeview_cell_color_player_bad_cskill_bg"), + "foreground", + const_str("string_treeview_cell_color_player_bad_cskill_bg"), NULL); + else + g_object_set(renderer, "background", + const_str("string_treeview_cell_color_default_background"), + "foreground", + const_str("string_treeview_cell_color_default_foreground"), NULL); + } /** Render the result (team names and goals) in the live game view. */ @@ -392,29 +370,30 @@ treeview_cell_live_game_result(GtkTreeViewColumn *col, gpointer user_data) { - gint i, result[2]; gint column = treeview_get_col_number_column(col); gchar buf[SMALL]; - Fixture *fix; + Fixture *fix = NULL; + LiveGameUnit *unit = NULL; - if(strcmp(font_name->str, "0") != 0) - g_object_set(renderer, "font", font_name->str, NULL); + if(strcmp(usr(current_user).font_name->str, "0") != 0) + g_object_set(renderer, "font", usr(current_user).font_name->str, NULL); strcpy(buf, ""); - gtk_tree_model_get(model, iter, column, &fix, -1); - - if(fix != NULL) + if(column == 1 || column == 3) { - for(i=0;i<2;i++) - result[i] = math_sum_int_array(fix->result[i], 3); + gtk_tree_model_get(model, iter, column, &fix, -1); + sprintf(buf, "%s", + const_str("string_treeview_cell_live_game_result_attributes"), + fix->teams[column == 3]->name->str); + } + else if(column == 2) + { + gtk_tree_model_get(model, iter, column, &unit, -1); + sprintf(buf, "%d : %d", + const_str("string_treeview_cell_live_game_result_attributes"), + unit->result[0], unit->result[1]); - if(column== 1 || column == 3) - sprintf(buf, "%s", CONSTANT_TREEVIEW_CELL_LIVE_GAME_RESULT_ATTRIBUTES, - fix->teams[column == 3]->name->str); - else - sprintf(buf, "%d : %d", CONSTANT_TREEVIEW_CELL_LIVE_GAME_RESULT_ATTRIBUTES, - result[0], result[1]); } g_object_set(renderer, "markup", buf, NULL); diff --git a/src/treeview_cell.h b/src/treeview_cell.h index 20cdcd70..96e959b6 100644 --- a/src/treeview_cell.h +++ b/src/treeview_cell.h @@ -2,10 +2,6 @@ #define TREEVIEW_CELL_H #include "bygfoot.h" -#include "variables.h" - -/** The integer that the cell data functions will interpret as an empty string. */ -#define CONSTANT_TREEVIEW_CELL_INT_EMPTY -5 void treeview_cell_team_selection(GtkTreeViewColumn *col, @@ -15,7 +11,6 @@ treeview_cell_team_selection(GtkTreeViewColumn *col, gpointer user_data); -/** Render an integer. This is only so that we know when to draw nothing. */ void treeview_cell_int_to_cell(GtkTreeViewColumn *col, GtkCellRenderer *renderer, @@ -23,7 +18,6 @@ treeview_cell_int_to_cell(GtkTreeViewColumn *col, GtkTreeIter *iter, gpointer user_data); -/** Render a player list cell. */ void treeview_cell_player_to_cell(GtkTreeViewColumn *col, GtkCellRenderer *renderer, @@ -56,4 +50,7 @@ treeview_cell_live_game_result(GtkTreeViewColumn *col, GtkTreeIter *iter, gpointer user_data); +void +treeview_cell_player_cskill_to_cell(GtkCellRenderer *renderer, gchar *buf, const Player *pl); + #endif diff --git a/src/user.c b/src/user.c index efc73531..6e72ed54 100644 --- a/src/user.c +++ b/src/user.c @@ -1,80 +1,121 @@ +#include "free.h" #include "league.h" #include "maths.h" +#include "option.h" #include "player.h" #include "support.h" #include "team.h" #include "user.h" -/** These determine how the initial money of the user - depends on the size of the stadium. */ -#define CONSTANT_INITIAL_MONEY_LOWER 80 -#define CONSTANT_INITIAL_MONEY_UPPER 110 - -/** Move the user's team to top or bottom league - at the beginning of a new game and set up the user's team. */ -void -user_set_up_my_team_new_game(GtkWidget *widget) +/** Create a new user with default values. */ +User +user_new(void) +{ + User new; + + new.name = g_string_new("NONAME"); + new.font_name = g_string_new("0"); + new.tm = NULL; + + new.live_game.units = NULL; + new.live_game.fix = NULL; + + new.options = g_array_new(FALSE, FALSE, sizeof(Option)); + + return new; +} + +/** Move a user's team to top or bottom league + at the beginning of a new game and set up the team. + @param user The user we set up the team for. */ +void +user_set_up_team_new_game(User *user) { - GtkWidget *radiobutton1 = - lookup_widget(widget, "team_selection_radio1"); - GtkWidget *radiobutton2 = - lookup_widget(widget, "team_selection_radio2"); gchar buf[SMALL]; gint rndom, max, lig_idx = -1; - if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton2))) - user_set_up_my_team(); + if(user->scout == 0) + user_set_up_team(user); else { - if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton1)) && - lig(0).id != my_team->clid) + if(user->scout == 1 && + lig(0).id != user->tm->clid) lig_idx = 0; - else if(lig(ligs->len - 1).id != my_team->clid) + else if(lig(ligs->len - 1).id != user->tm->clid) lig_idx = ligs->len - 1; max = lig(lig_idx).teams->len - 1; rndom = math_rndi(0, max); 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", - my_team->name->str); - g_string_printf(my_team->name, "%s", buf); + user->tm->name->str); + g_string_printf(user->tm->name, "%s", buf); - my_team = &g_array_index(lig(lig_idx).teams, Team, rndom); + user->tm = &g_array_index(lig(lig_idx).teams, Team, rndom); - user_set_up_my_team(); + user_set_up_team(user); } } -/** Set up finances, reomve some players etc. for a new user team. */ +/** Set up finances, remove some players etc. for a new user team. + @param user The user whose team we set up. */ void -user_set_up_my_team(void) +user_set_up_team(User *user) { gint i, j; for(i=PLAYER_POS_DEFENDER; i<=PLAYER_POS_FORWARD; i++) - for(j=my_team->players->len - 1; j > 10; j--) - if(g_array_index(my_team->players, Player, j).pos == i) + for(j=user->tm->players->len - 1; j > 10; j--) + if(g_array_index(user->tm->players, Player, j).pos == i) { - player_remove_from_team(my_team, j); + player_remove_from_team(user->tm, j); break; } - scout = physio = QUALITY_AVERAGE; + user->scout = user->physio = QUALITY_AVERAGE; - user_set_up_finances(); + user_set_up_finances(user); } -/** Set up the user's finances when he's got a new team.*/ +/** Set up the user's finances when he's got a new team. + @param user The user we set up the finances for. */ void -user_set_up_finances(void) +user_set_up_finances(User *user) { gint i; for(i=0; ifinances[i] = 0; - finances[FIN_MONEY] = - math_round_integer(my_team->stadium.capacity * - math_rndi(CONSTANT_INITIAL_MONEY_LOWER, - CONSTANT_INITIAL_MONEY_UPPER), 2); + user->finances[FIN_MONEY] = + math_round_integer(user->tm->stadium.capacity * + math_rndi(const_int("int_initial_money_lower"), + const_int("int_initial_money_upper")), 2); +} + +/** Remove a user from the game. + @param idx The index of the user in the #users array. + @param regenerate_team Whether the user's team has to be + regenerated. */ +void +user_remove(gint idx, gboolean regenerate_team) +{ + free_user(&usr(idx)); + g_array_remove_index(users, idx); +} + +void +user_set_player_list_attributes(const User *user, PlayerListAttribute *attribute, gint list_number) +{ + gint i, cnt = 0; + gchar prefix[SMALL]; + + sprintf(prefix, "int_opt_user_pl%d_att", list_number); + + for(i=0;ioptions->len;i++) + if(g_str_has_prefix(g_array_index(user->options, Option, i).name->str, prefix)) + { + attribute->on_off[cnt] = g_array_index(user->options, Option, i).value; + cnt++; + } } diff --git a/src/user.h b/src/user.h index 717f8d53..b4d7b229 100644 --- a/src/user.h +++ b/src/user.h @@ -2,15 +2,28 @@ #define USER_H #include "bygfoot.h" +#include "user_struct.h" #include "variables.h" -void -user_set_up_my_team_new_game(GtkWidget *widget); +/** Convenience abbrevs. */ +#define usr(i) g_array_index(users, User, i) void -user_set_up_my_team(void); +user_set_up_team_new_game(User *user); void -user_set_up_finances(void); +user_set_up_team(User *user); + +void +user_set_up_finances(User *user); + +User +user_new(void); + +void +user_remove(gint idx, gboolean regenerate_team); + +void +user_set_player_list_attributes(const User *user, PlayerListAttribute *attribute, gint list_number); #endif diff --git a/src/user_struct.h b/src/user_struct.h new file mode 100644 index 00000000..b2fd23b9 --- /dev/null +++ b/src/user_struct.h @@ -0,0 +1,33 @@ +#ifndef USER_STRUCT_H +#define USER_STRUCT_H + +#include "bygfoot.h" +#include "enums.h" +#include "team_struct.h" +#include "live_game_struct.h" + +/** A structure representing a human player. */ +typedef struct +{ + /** Username. */ + GString *name; + /** The team the user manages. */ + Team *tm; + /** User options. */ + GArray *options; + /** The user's finances. @see #FinanceValue */ + gint finances[FIN_END]; + /** The attributes shown in the player lists. + @see #PlayerListAttribute + @see #PlayerListAttributeValue */ + PlayerListAttribute player_list_attributes[3]; + /** The user's scout and physio qualities. + @see #Quality */ + gint scout, physio; + /** The font used in treeviews. */ + GString *font_name; + /** The variable for the latest user live game. @see #Game */ + LiveGame live_game; +} User; + +#endif diff --git a/src/variables.h b/src/variables.h index 4c767746..ff5bc28f 100644 --- a/src/variables.h +++ b/src/variables.h @@ -3,6 +3,7 @@ #include "live_game_struct.h" #include "player_struct.h" #include "team_struct.h" +#include "user_struct.h" /** * The main variable of the game. @@ -10,55 +11,44 @@ */ Country country; -/** The id of the league or cup of the user's team and its numerical id. */ -Team *my_team; - /** The season, week and week round numbers. We keep track of the time in the game with these variables. */ gint season, week, week_round; -/** The user's scout and physio qualities. - @see #Quality */ -gint scout, physio; - -/** The user's finances. @see #FinanceValue */ -gint finances[FIN_END]; -/** The user's settings. @see #OptionValue */ -gint options[OPT_END]; -/** The attributes shown in the player lists. - @see #PlayerListAttribute - @see #PlayerListAttributeValue */ -PlayerListAttribute player_list_attributes[3]; - -/** Some counters. @see #CounterValue */ -gint counters[COUNT_END]; +/** Array of options that get read from + bygfoot.conf. */ +GArray *options; +/** Array of constants that get read from the constans + file specified in bygfoot.conf. */ +GArray *constants; /** The array containing players to be transfered. @see TransferPlayer */ GArray *transfer_list; -/** The font used in treeviews. */ -GString *font_name; - -/** Whether we are in debug mode. */ -gboolean debug; - /** These help us keep track of what's happening. */ -gint status, status2, status3, status4, status5; +gint status[5]; + +/** The currently selected rows in the treeviews. */ +gint selected_row[2]; /** An array of player names that we keep in memory. */ GPtrArray *player_names; -/** The pointer to the main window of the game. */ -GtkWidget *main_window; +/** The struct containing the window pointers. */ +Windows window; /** With this we keep track of the number of popup windows and make the main window sensitive or insensitive, depending. */ gint popups_active; -/** The variable for the latest user live game. @see #Game */ -LiveGame live_game; - /** The variable for non-user games (which aren't shown). */ LiveGame live_game_temp; + +/** The array of human players. @see #User */ +GArray *users; + +/** The index of the current user in the #users array. */ +gint current_user; + diff --git a/src/window.c b/src/window.c index 3ccb2bd5..52ac1b7b 100644 --- a/src/window.c +++ b/src/window.c @@ -1,9 +1,12 @@ #include "file.h" #include "free.h" +#include "game_gui.h" #include "interface.h" #include "main.h" #include "misc_interface.h" +#include "option.h" #include "support.h" +#include "user.h" #include "variables.h" #include "window.h" @@ -36,27 +39,18 @@ window_show_startup(void) free_g_string_array(&dir_contents); } -/** Create and show the main window. */ -void -window_show_main(void) -{ - main_window = window_create(WINDOW_MAIN); - - gtk_widget_show(main_window); -} - /** Set 'Bygfoot x.y.z' into the title of a window. @param window The window widget pointer. @see #VERS */ GtkWidget* -window_set_version(GtkWidget *window) +window_set_version(GtkWidget *wind) { gchar buf[SMALL]; sprintf(buf, "Bygfoot Football Manager %s", VERS); - gtk_window_set_title(GTK_WINDOW(window), buf); + gtk_window_set_title(GTK_WINDOW(wind), buf); - return window; + return wind; } /** Create and show a window. Which one depends on the argument. @@ -67,62 +61,76 @@ window_set_version(GtkWidget *window) GtkWidget* window_create(gint window_type) { - GtkWidget *window = NULL; + GtkWidget *wind = NULL; popups_active++; switch(window_type) { default: - if(main_window == NULL) + if(window.main == NULL) { - window = create_main_window(); + window.main = create_main_window(); popups_active--; + wind = window.main; + game_gui_print_message("Welcome to Bygfoot "VERS); } else - window = main_window; - window_set_version(window); + wind = window.main; break; case WINDOW_STARTUP: - window = create_window_startup(); - window_set_version(window); + if(window.startup != NULL) + g_warning("window_create: called on already existing window\n"); + else + window.startup = create_window_startup(); + wind = window.startup; break; case WINDOW_LIVE: - window = create_window_live(); - window_set_version(window); + if(window.live != NULL) + g_warning("window_create: called on already existing window\n"); + else + window.live = create_window_live(); + wind = window.live; gtk_spin_button_set_value( - GTK_SPIN_BUTTON(lookup_widget(window, "spinbutton_speed")), - (gfloat)options[OPT_LIVE_SPEED]); + GTK_SPIN_BUTTON(lookup_widget(wind, "spinbutton_speed")), + (gfloat)option_int("int_opt_user_live_game_speed", usr(stat2).options)); break; - } + case WINDOW_STARTUP_USERS: + if(window.startup_users != NULL) + g_warning("window_create: called on already existing window\n"); + else + window.startup_users = create_window_startup_users(); + wind = window.startup_users; + break; + } - gtk_widget_show(window); + window_set_version(wind); + gtk_widget_show(wind); - if(popups_active != 0 && main_window != NULL) - gtk_widget_set_sensitive(main_window, FALSE); + if(popups_active != 0 && window.main != NULL) + gtk_widget_set_sensitive(window.main, FALSE); - return window; + return wind; } /** Destroy a window widget and set the popups and main window sensitivity correctly. @param window The window we destroy. */ void -window_destroy(GtkWidget **window) +window_destroy(GtkWidget **wind) { - if(*window == NULL) + if(*wind == NULL) return; - if(*window != main_window) + if(*wind != window.main) { popups_active--; - if(popups_active == 0 && main_window != NULL) - gtk_widget_set_sensitive(main_window, TRUE); + if(popups_active == 0 && window.main != NULL) + gtk_widget_set_sensitive(window.main, TRUE); } - gtk_widget_destroy(*window); + gtk_widget_destroy(*wind); - *window = NULL; + *wind = NULL; } - diff --git a/src/window.h b/src/window.h index 23b406a3..be142120 100644 --- a/src/window.h +++ b/src/window.h @@ -10,15 +10,13 @@ enum Windows WINDOW_MAIN = 0, WINDOW_STARTUP, WINDOW_LIVE, + WINDOW_STARTUP_USERS, WINDOW_END }; void window_show_startup(void); -void -window_show_main(void); - GtkWidget* window_set_version(GtkWidget *window); diff --git a/src/xml_league.c b/src/xml_league.c index 2918d7ad..452fcaa3 100644 --- a/src/xml_league.c +++ b/src/xml_league.c @@ -2,6 +2,7 @@ #include "league.h" #include "misc.h" #include "team.h" +#include "table.h" #include "variables.h" #include "xml_league.h" @@ -159,8 +160,6 @@ xml_league_read_end_element (GMarkupParseContext *context, gpointer user_data, GError **error) { - TableElement new_table_element; - if(strcmp(element_name, TAG_NAME) == 0 || strcmp(element_name, TAG_SHORT_NAME) == 0 || strcmp(element_name, TAG_SID) == 0 || @@ -184,12 +183,7 @@ xml_league_read_end_element (GMarkupParseContext *context, strcmp(element_name, TAG_PROM_REL_ELEMENT_DEST_SID) == 0) state = STATE_PROM_REL_ELEMENT; else if(strcmp(element_name, TAG_TEAM) == 0) - { state = STATE_TEAMS; - new_table_element = league_table_element_new( - &g_array_index(new_league.teams, Team, new_league.teams->len - 1)); - g_array_append_val(new_league.table.elements, new_table_element); - } else if(strcmp(element_name, TAG_TEAM_NAME) == 0) state = STATE_TEAM; else if(strcmp(element_name, TAG_LEAGUE) != 0) @@ -275,6 +269,8 @@ xml_league_read_text (GMarkupParseContext *context, void xml_league_read(const gchar *league_name, GArray *leagues) { + gint i; + TableElement new_table_element; gchar *file_name = file_find_support_file(league_name); GMarkupParser parser = {xml_league_read_start_element, xml_league_read_end_element, @@ -313,6 +309,12 @@ xml_league_read(const gchar *league_name, GArray *leagues) g_free(file_contents); g_array_append_val(leagues, new_league); + for(i=0;ilen - 1).teams->len;i++) + { + new_table_element = + table_element_new(&g_array_index(lig(ligs->len - 1).teams, Team, i)); + g_array_append_val(lig(ligs->len - 1).table.elements, new_table_element); + } } else { diff --git a/support_files/bygfoot.conf b/support_files/bygfoot.conf index 0b1d4e81..875db34f 100644 --- a/support_files/bygfoot.conf +++ b/support_files/bygfoot.conf @@ -1,87 +1,22 @@ # Bygfoot Football Manager -# Configuration file +# Global configuration file # Most of these options are uncommented because their meaning # is rather clear if you take a look at the options window in the game. -confirm_new_week_round 1 -confirm_unfit 1 -confirm_quit 1 -save_will_ovewrite 1 -show_live_game 1 -live_game_speed 0 -show_tendency_bar 1 -maximize_main_window 1 -notify_transfer 0 -notify_pos -1 -notify_league_upper -1 -notify_league_lower -1 -notify_cups 0 -notify_age_upper 36 -notify_age_lower 18 -notify_skill_upper 99 -notify_skill_lower 1 -notify_etal_upper 99 -notify_etal_lower 1 -notify_value -1 -show_job_offers 1 -message_style 1 -prefer_messages 0 -autosave 0 -autosave_interval 3 -sort_transfer_list 0 -sort_transfer_attribute 1 -reaarrange_adapts 1 -swap_adapts 1 -history_team_interval 5 -history_player_interval 10 -history_team_max 30 -history_player_max 20 -history_team_delete 0 -history_player_delete 0 -boost 0 -compress 1 -objective 1 -penalty_shooter -1 - -pl1_att_name 1 -pl1_att_cpos 1 -pl1_att_pos 1 -pl1_att_cskill 1 -pl1_att_skill 1 -pl1_att_fitness 1 -pl1_att_games 1 -pl1_att_goals 1 -pl1_att_status 1 -pl1_att_cards 0 -pl1_att_age 1 -pl1_att_etal 1 -pl1_att_value 0 -pl1_att_wage 0 -pl1_att_contract 0 -pl1_att_team 0 -pl1_att_league_cup 0 - -pl2_att_name 1 -pl2_att_cpos 0 -pl2_att_pos 1 -pl2_att_cskill 0 -pl2_att_skill 1 -pl2_att_fitness 0 -pl2_att_games 0 -pl2_att_goals 0 -pl2_att_status 1 -pl2_att_cards 0 -pl2_att_age 1 -pl2_att_etal 1 -pl2_att_value 1 -pl2_att_wage 1 -pl2_att_contract 1 -pl2_att_team 0 -pl2_att_league_cup 0 - -# font name; if 0, the default system font's used -font_name 0 +int_opt_confirm_new_week_round 1 +int_opt_confirm_quit 1 +int_opt_save_will_ovewrite 1 +int_opt_maximize_main_window 1 +int_opt_prefer_messages 0 +int_opt_autosave 0 +int_opt_autosave_interval 3 +int_opt_compress 1 +int_opt_objective 1 # whether some debugging info's shown (in the console) -debug 0 +int_opt_debug 0 + +string_opt_player_names_file player_names.xml +string_opt_constants_file bygfoot_constants +string_opt_default_user_conf_file bygfoot_user.conf diff --git a/support_files/bygfoot_constants b/support_files/bygfoot_constants new file mode 100644 index 00000000..1612ffe5 --- /dev/null +++ b/support_files/bygfoot_constants @@ -0,0 +1,279 @@ +#### int constants + +# number of seconds until messages disappear +int_game_gui_message_duration 5 + +# lower limit for player ages. +int_player_age_lower 936 +# upper limit for player ages. +int_player_age_upper 1872 +# lower limit for player peak ages. +int_player_peak_age_lower 1560 +# upper limit for player peak ages. +int_player_peak_age_upper 1716 +# by how many weeks the peak age of goalies is +# greater. +int_player_peak_age_goalie_addition 104 +# limits for initial fitness. +int_player_fitness_lower 85 +# limits for initial fitness. +int_player_fitness_upper 100 + +# the bounds determining the player positions in a newly created +# team for players 13 to constant_team_max_players. +# player 11 is always the second goalie. +int_player_pos_bound1 15 +int_player_pos_bound2 18 + +# bounds for the contract time at player generation. +int_player_contract_lower 52 +int_player_contract_upper 208 + +# bounds for the last skill update at player generation. +int_player_lsu_lower 2 +int_player_lsu_upper 10 + +# this determines the accuracy of the scout's +# talent estimate. the smaller the better. +int_player_etal_scout_factor 7 + +# fitness limits below which fitness is shown +# in orange and red etc. +int_treeview_cell_limit_player_fitness_below1 85 +int_treeview_cell_limit_player_fitness_below2 70 +int_treeview_cell_limit_player_fitness_below3 60 + +# contract limits below which contract time is shown +# in orange and red etc. +int_treeview_cell_limit_player_contract_below1 52 +int_treeview_cell_limit_player_contract_below2 40 +int_treeview_cell_limit_player_contract_below3 20 + +# the integer that the cell data functions will interpret as an empty string. +int_treeview_cell_int_empty -5 + +# transfer list configuration +int_transfer_max_players 20 +int_transfer_deadline 35 + +# maximum number of players in a team. +int_team_max_players 20 + +# highest skill and talent a player can have. +int_player_max_skill 99 + +# determines initial money of the users +int_initial_money_lower 80 +int_initial_money_upper 110 + + +#### float constants +#### these get divided by 1000 and loaded as floats +#### so we write 500 if we'd like to have 0.5 + +# live game scale configuration +float_game_gui_live_game_scale_attack 300 +float_game_gui_live_game_scale_chance 450 +float_game_gui_live_game_scale_range 10000 + +# How much a player's skill can deviate from +# the average skill in his team. +float_player_average_skill_variance 100 + +# these determine the value calculation of players. +# value is a function of skill and talent involving +# a power. +float_player_value_skill_weight 650 +float_player_value_power 3500 + +# these determine the wage calculation of players. +# wage depends on the value and a random factor near 1. +float_player_wage_value_factor 10 +float_player_wage_random_dev 150 + +# constants determining the probabilities for +# the playing styles of cpu teams. +float_team_playing_style_prob1 100 +float_team_playing_style_prob2 250 +float_team_playing_style_prob3 750 +float_team_playing_style_prob4 900 + +# constants determining the probabilities for +# the playing structures of cpu teams. +float_team_playing_structure_prob1 150 +float_team_playing_structure_prob2 500 +float_team_playing_structure_prob3 700 +float_team_playing_structure_prob4 850 + +# kinda hard to explain. +# @see team_generate_players() +# @see player_generate() +float_team_skill_variance 75 + +# base probability that the ball gets from defending area +# to midfield area. +float_live_game_area_def_mid 500 +# influence of attack/defend values on the base probability; the lower +# the smaller the influence. +float_live_game_area_def_mid_team_exponent 1000 + +# base probability that the ball gets from midfield area +# to attack area or back to defend area. +float_live_game_area_mid_att 500 +float_live_game_area_mid_def 300 +# influence of attack/defend values on the base probability; the lower +# the smaller the influence. +float_live_game_area_mid_team_exponent 1250 + +# base probability that the ball gets from attacking area +# to midfield area. +float_live_game_area_att_mid 300 +# influence of attack/defend values on the base probability; the lower +# the smaller the influence. +float_live_game_area_att_mid_team_exponent 1000 + +# base probability of a general event (no foul, no injury, no goal etc.) +float_live_game_event_general 500 + +# base probability for possession change. +float_live_game_possession_changes 200 +# influence of the team values on the possession change. +float_live_game_possession_team_exponent 4000 + +# base prob for a scoring chance if a team is attacking. +float_live_game_scoring_chance 300 +# team values influence on the scoring chance. +float_live_game_scoring_chance_team_exponent 1250 + +# probability that it's the player in possession who +# has the scoring chance. +float_live_game_player_in_poss_shoots 500 + +# base probability to score with a scoring chance. +float_live_game_score_base_prob 300 +# base probability to score with a free kick. +float_live_game_score_free_kick 50 +# base probability to score with a penalty. +float_live_game_score_penalty 800 +# influence of the attacker/goalie skills on the probability to score. +float_live_game_score_duel_exponent 300 +# influence of the team attacking/defending values on the probability to score. +float_live_game_score_team_exponent 700 + +# the smaller this number, the smaller the probability of +# many stopping minutes after 90 or 45 minutes. +float_live_game_break_base 600 +# the bigger this number, the faster the probability of +# yet another additional minute after the 45th minute decays. +float_live_game_45_break_exponent_factor 1300 +# the bigger this number, the faster the probability of +# yet another additional minute after the 90th minute decays. +float_live_game_90_break_exponent_factor 700 +# the probability that the team that shot on the goal stays +# in possession after a post or cross-bar hit. +float_live_game_possession_after_post 300 + +# probability that there is a passing event after a special event. +float_live_game_general_event_second_player 500 + +# constants for stadium events. +float_live_game_stadium_event_exponent 50 +float_live_game_stadium_event_fire 200 +float_live_game_stadium_event_riots 500 +float_live_game_stadium_event_breakdown 1000 + +# foul probabilities. +float_live_game_foul 110 +float_live_game_foul_red_injury 50 +float_live_game_foul_red 80 +float_live_game_foul_yellow 230 + +# injury probabilities. +float_live_game_injury 17 +float_live_game_injury_goalie_factor 200 +float_live_game_injury_is_temp 700 + +# probability that a scoring chance is an own goal. +float_live_game_scoring_chance_is_own_goal 10 + +# probability of a free kick after a foul. +float_live_game_free_kick_prob 150 + +# probability of a penalty after a foul. +float_live_game_penalty_prob 50 + +# probability that a scoring chance is a header. +float_live_game_scoring_chance_is_header 350 + +# influence in % of the game style towards more attack. +float_game_style_factor 75 + +# influence of boost on player's skill. +float_player_boost_skill_effect 300 +# influence of boost on player's fitness decay. +float_player_boost_fitness_effect 1000 +# influence of boost on injury probability. +float_player_boost_injury_effect 1000 +# influence of boost on cards probability. +float_player_boost_card_effect 1000 + +# the influence of the fitness on the current skill. +# this determines the player's contribution to the team +# during a game. the higher the value the bigger the influence. +float_player_fitness_impact_on_skill 250 + +# influence of the fitness on the player contribution. +# the higher the worse. @see game_get_player_contribution() +float_player_fitness_exponent 250 + +# bounds for the home advantage factor +float_game_home_advantage_lower 40 +float_game_home_advantage_upper 80 + + + +#### string constants + +# live game scale configuration +string_game_gui_live_game_scale_color_defend lightblue +string_game_gui_live_game_scale_color_midfield khaki +string_game_gui_live_game_scale_color_attack gold +string_game_gui_live_game_scale_color_chance orange +string_game_gui_live_game_scale_color_goal red +string_game_gui_live_game_scale_color_miss lightgreen + +# default background and foreground in treeviews +string_treeview_cell_color_default_background white +string_treeview_cell_color_default_foreground black + +# player list colours +string_treeview_cell_color_player_pos_goalie_bg black +string_treeview_cell_color_player_pos_goalie_fg white +string_treeview_cell_color_player_pos_defender_bg darkgreen +string_treeview_cell_color_player_pos_defender_fg white +string_treeview_cell_color_player_pos_midfielder_bg darkblue +string_treeview_cell_color_player_pos_midfielder_fg white +string_treeview_cell_color_player_pos_forward_bg darkred +string_treeview_cell_color_player_pos_forward_fg white + +string_treeview_cell_color_player_injury lightgreen +string_treeview_cell_color_player_banned red +string_treeview_cell_color_player_yellow_danger yellow + +string_treeview_cell_color_player_fitness_normal darkgreen +string_treeview_cell_color_player_fitness_below1 darkorange +string_treeview_cell_color_player_fitness_below2 orangered +string_treeview_cell_color_player_fitness_below3 red + +string_treeview_cell_color_player_contract_normal darkgreen +# see also the int constants for contract limits +string_treeview_cell_color_player_contract_below1 darkorange +string_treeview_cell_color_player_contract_below2 orangered +string_treeview_cell_color_player_contract_below3 red + +# colours for cskill in wrong position +string_treeview_cell_color_player_bad_cskill_bg lightblue +string_treeview_cell_color_player_bad_cskill_fg red + +# font attributes for the live game window result. +string_treeview_cell_live_game_result_attributes weight='bold' size='large' diff --git a/support_files/bygfoot_user.conf b/support_files/bygfoot_user.conf new file mode 100644 index 00000000..eec629b5 --- /dev/null +++ b/support_files/bygfoot_user.conf @@ -0,0 +1,72 @@ +# Bygfoot Football Manager +# Default user configuration file + +# Most of these options are uncommented because their meaning +# is rather clear if you take a look at the options window in the game. + +int_opt_user_confirm_unfit 1 +int_opt_user_show_live_game 0 +int_opt_user_live_game_speed -10 +int_opt_user_show_tendency_bar 1 +int_opt_user_notify_transfer 0 +int_opt_user_notify_pos -1 +int_opt_user_notify_league_upper -1 +int_opt_user_notify_league_lower -1 +int_opt_user_notify_cups 0 +int_opt_user_notify_age_upper 36 +int_opt_user_notify_age_lower 18 +int_opt_user_notify_skill_upper 99 +int_opt_user_notify_skill_lower 1 +int_opt_user_notify_etal_upper 99 +int_opt_user_notify_etal_lower 1 +int_opt_user_notify_value -1 +int_opt_user_show_job_offers 1 +int_opt_user_sort_transfer_list 0 +int_opt_user_sort_transfer_attribute 1 +int_opt_user_reaarrange_adapts 1 +int_opt_user_swap_adapts 1 +int_opt_user_boost 0 +int_opt_user_penalty_shooter -1 + +# the order of these attributes is important +# don't change it +int_opt_user_pl1_att_name 1 +int_opt_user_pl1_att_cpos 1 +int_opt_user_pl1_att_pos 1 +int_opt_user_pl1_att_cskill 1 +int_opt_user_pl1_att_skill 1 +int_opt_user_pl1_att_fitness 1 +int_opt_user_pl1_att_games 1 +int_opt_user_pl1_att_goals 1 +int_opt_user_pl1_att_status 1 +int_opt_user_pl1_att_cards 0 +int_opt_user_pl1_att_age 1 +int_opt_user_pl1_att_etal 1 +int_opt_user_pl1_att_value 0 +int_opt_user_pl1_att_wage 0 +int_opt_user_pl1_att_contract 0 +int_opt_user_pl1_att_team 0 +int_opt_user_pl1_att_league_cup 0 + +# the order of these attributes is important +# don't change it +int_opt_user_pl2_att_name 1 +int_opt_user_pl2_att_cpos 0 +int_opt_user_pl2_att_pos 1 +int_opt_user_pl2_att_cskill 0 +int_opt_user_pl2_att_skill 1 +int_opt_user_pl2_att_fitness 0 +int_opt_user_pl2_att_games 0 +int_opt_user_pl2_att_goals 0 +int_opt_user_pl2_att_status 1 +int_opt_user_pl2_att_cards 0 +int_opt_user_pl2_att_age 1 +int_opt_user_pl2_att_etal 1 +int_opt_user_pl2_att_value 1 +int_opt_user_pl2_att_wage 1 +int_opt_user_pl2_att_contract 1 +int_opt_user_pl2_att_team 0 +int_opt_user_pl2_att_league_cup 0 + +# font name; if 0, the default system font's used +string_opt_user_font_name 0