Made some progress; removed editor gui.

This commit is contained in:
gyboth 2005-03-03 12:46:48 +00:00
parent 4663d2312b
commit 7e07d74abd
80 changed files with 5124 additions and 4329 deletions

View File

@ -417,7 +417,7 @@ WARN_LOGFILE =
# directories like "/usr/src/myproject". Separate the files or directories # directories like "/usr/src/myproject". Separate the files or directories
# with spaces. # 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 # 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 # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp

View File

@ -2,7 +2,9 @@
AM_CFLAGS = -Wall AM_CFLAGS = -Wall
SUBDIRS = src po b-u SUBDIRS = src po
bin_SCRIPTS = bygfoot-update
EXTRA_DIST = \ EXTRA_DIST = \
autogen.sh \ autogen.sh \
@ -11,9 +13,9 @@ EXTRA_DIST = \
dist_man6_MANS = man/bygfoot.6 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: install-data-local:
@$(NORMAL_INSTALL) @$(NORMAL_INSTALL)

793
bygfoot-update Executable file
View File

@ -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 <<END
Usage: bygfoot-update [OPTIONS]
Note: You can call bygfoot-update without any options.
MAIN OPTIONS:
-c|--country-files Download country files with official team names
and team definitions file
-n|--new-package Download the latest complete package
-u|--update Update your Bygfoot source package using patches
-b|--cvs Get CVS version
AUXILIARY OPTIONS:
Global:
-A|--auto Assume [y] for all prompts
-h|--help Print help and exit
-l|--show-log Don't clear the log file before exiting;
show its contents instead.
-t|--temp-dir DIR Set temp directory to DIR
-v|--version Print version information and exit
Relevant for source update mode:
-a|--apply-all Apply all new patches without prompting
-p|--package-dir DIR Set source package directory to DIR
-r|--recompile Run './configure && make' after updating
-R|--no-recompile Don't recompile after updating
Relevant for country files mode:
-C|--country-dir DIR Set destination directory for the
country files and def file to DIR
Relevant for package download mode:
-f|--format FORMAT Set package format to FORMAT:
'src', 'rpm', 'srpm', 'bin' or 'deb.
Note that 'deb' isn't allowed for unstable
packages.
-t|--temp-dir DIR Set download destination directory
to DIR (same as temp directory)
-T|--type TYPE Download latest TYPE package, TYPE
being either 'stable' or 'unstable'.
-V|--get-version Fetch version number of the latest
release from the server and exit.
Relevant for CVS mode:
-B|--branch BRANCH Which CVS branch to get; currently 1 or 2
for the 1.8 or 1.9 branch.
-U|--username NAME Your SourceForge.Net username used for
checking out, or A for anonymous checkout.
END
}
# print program version
function print_version()
{
cat <<END
bygfoot-update: A bash script keeping your Bygfoot Football Manager up-to-date.
Version $version.
See the file UPDATE for some more information.
Call bygfoot-update -h|--help for usage information.
END
}
# print output to stdout and the log file
function my_echo()
{
echo "$@" 2>> $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

File diff suppressed because it is too large Load Diff

View File

@ -71,124 +71,6 @@
</packing> </packing>
</child> </child>
<child>
<widget class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="label" translatable="yes">Start in</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.05</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkEventBox" id="eventbox1">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Play normal league games and cups</property>
<property name="visible_window">True</property>
<property name="above_child">False</property>
<child>
<widget class="GtkHBox" id="hbox2">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkRadioButton" id="team_selection_radio1">
<property name="border_width">3</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Top league</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="team_selection_radio2">
<property name="border_width">3</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Current league</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">True</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<property name="group">team_selection_radio1</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="team_selection_radio3">
<property name="border_width">3</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Bottom league</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<property name="group">team_selection_radio1</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">5</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHSeparator" id="hseparator11">
<property name="width_request">1</property>
<property name="height_request">10</property>
<property name="visible">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child> <child>
<widget class="GtkVBox" id="vbox34"> <widget class="GtkVBox" id="vbox34">
<property name="visible">True</property> <property name="visible">True</property>
@ -363,6 +245,124 @@
</packing> </packing>
</child> </child>
<child>
<widget class="GtkHSeparator" id="hseparator11">
<property name="width_request">1</property>
<property name="height_request">10</property>
<property name="visible">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="label" translatable="yes">Start in</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.05</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkEventBox" id="eventbox1">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Play normal league games and cups</property>
<property name="visible_window">True</property>
<property name="above_child">False</property>
<child>
<widget class="GtkHBox" id="hbox2">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkRadioButton" id="team_selection_radio1">
<property name="border_width">3</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Top league</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="team_selection_radio2">
<property name="border_width">3</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Current league</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">True</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<property name="group">team_selection_radio1</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="team_selection_radio3">
<property name="border_width">3</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Bottom league</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<property name="group">team_selection_radio1</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">5</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child> <child>
<widget class="GtkHSeparator" id="hseparator12"> <widget class="GtkHSeparator" id="hseparator12">
<property name="width_request">1</property> <property name="width_request">1</property>
@ -377,114 +377,63 @@
</child> </child>
<child> <child>
<widget class="GtkHBox" id="hbox46"> <widget class="GtkHBox" id="hbox54">
<property name="visible">True</property> <property name="visible">True</property>
<property name="homogeneous">False</property> <property name="homogeneous">False</property>
<property name="spacing">0</property> <property name="spacing">5</property>
<child> <child>
<widget class="GtkVBox" id="vbox35"> <widget class="GtkLabel" id="label75">
<property name="visible">True</property> <property name="visible">True</property>
<property name="homogeneous">False</property> <property name="label" translatable="yes">Player name</property>
<property name="spacing">0</property> <property name="use_underline">False</property>
<property name="use_markup">False</property>
<child> <property name="justify">GTK_JUSTIFY_LEFT</property>
<widget class="GtkCheckButton" id="checkbutton_no_def"> <property name="wrap">False</property>
<property name="border_width">2</property> <property name="selectable">False</property>
<property name="visible">True</property> <property name="xalign">0.5</property>
<property name="tooltip" translatable="yes">If you check this, the game generates all players randomly and won't read the file with team definitions</property> <property name="yalign">0.5</property>
<property name="can_focus">True</property> <property name="xpad">0</property>
<property name="label" translatable="yes">Don't load team definitions</property> <property name="ypad">0</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_checkbutton_load_randomly_toggled" last_modification_time="Tue, 11 May 2004 15:35:43 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="checkbutton_only_names">
<property name="border_width">2</property>
<property name="visible">True</property>
<property name="tooltip" translatable="yes">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</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Load only names from team definition file</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_checkbutton_only_names_toggled" last_modification_time="Thu, 20 May 2004 08:45:07 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="checkbutton_load_my_team">
<property name="border_width">2</property>
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Check this if you'd like to have your team loaded from the definitions file no matter what the other checkbuttons say.</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Load my team from definitions file</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">True</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="padding">0</property>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="entry_player_name">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">12</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
<property name="width_chars">12</property>
<signal name="activate" handler="on_entry_player_name_activate" last_modification_time="Sat, 26 Feb 2005 10:40:03 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkVSeparator" id="vseparator18"> <widget class="GtkButton" id="button_add_player">
<property name="width_request">10</property>
<property name="height_request">1</property>
<property name="visible">True</property> <property name="visible">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button_start_editor">
<property name="border_width">3</property>
<property name="visible">True</property>
<property name="tooltip" translatable="yes">You can start the editor from the commandline with 'bygfoot -e' or '--editor'</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property> <property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property> <property name="focus_on_click">True</property>
<signal name="clicked" handler="on_button_start_editor_clicked" last_modification_time="Fri, 14 May 2004 12:55:57 GMT"/> <signal name="clicked" handler="on_button_add_player_clicked" last_modification_time="Fri, 25 Feb 2005 16:22:19 GMT"/>
<child> <child>
<widget class="GtkAlignment" id="alignment15"> <widget class="GtkAlignment" id="alignment19">
<property name="visible">True</property> <property name="visible">True</property>
<property name="xalign">0.5</property> <property name="xalign">0.5</property>
<property name="yalign">0.5</property> <property name="yalign">0.5</property>
@ -496,15 +445,15 @@
<property name="right_padding">0</property> <property name="right_padding">0</property>
<child> <child>
<widget class="GtkHBox" id="hbox47"> <widget class="GtkHBox" id="hbox55">
<property name="visible">True</property> <property name="visible">True</property>
<property name="homogeneous">False</property> <property name="homogeneous">False</property>
<property name="spacing">2</property> <property name="spacing">2</property>
<child> <child>
<widget class="GtkImage" id="image55"> <widget class="GtkImage" id="image59">
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock">gtk-preferences</property> <property name="stock">gtk-add</property>
<property name="icon_size">4</property> <property name="icon_size">4</property>
<property name="xalign">0.5</property> <property name="xalign">0.5</property>
<property name="yalign">0.5</property> <property name="yalign">0.5</property>
@ -519,9 +468,9 @@
</child> </child>
<child> <child>
<widget class="GtkLabel" id="label71"> <widget class="GtkLabel" id="label76">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">Start Bygfoot Team Editor</property> <property name="label" translatable="yes">Add player</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="use_markup">False</property> <property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property> <property name="justify">GTK_JUSTIFY_LEFT</property>
@ -545,8 +494,8 @@
</widget> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="padding">0</property>
<property name="expand">True</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">False</property>
</packing> </packing>
</child> </child>
</widget> </widget>
@ -557,6 +506,19 @@
</packing> </packing>
</child> </child>
<child>
<widget class="GtkHSeparator" id="hseparator13">
<property name="width_request">1</property>
<property name="height_request">10</property>
<property name="visible">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child> <child>
<widget class="GtkHBox" id="hbox3"> <widget class="GtkHBox" id="hbox3">
<property name="visible">True</property> <property name="visible">True</property>
@ -567,15 +529,16 @@
<widget class="GtkButton" id="team_selection_ok"> <widget class="GtkButton" id="team_selection_ok">
<property name="border_width">2</property> <property name="border_width">2</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="tooltip" translatable="yes">Return</property> <property name="sensitive">False</property>
<property name="tooltip" translatable="yes">Space</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property> <property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property> <property name="focus_on_click">True</property>
<signal name="clicked" handler="on_team_selection_ok_clicked" last_modification_time="Tue, 27 Jan 2004 17:27:11 GMT"/> <signal name="clicked" handler="on_team_selection_ok_clicked" last_modification_time="Fri, 25 Feb 2005 16:22:55 GMT"/>
<accelerator key="Return" modifiers="0" signal="clicked"/> <accelerator key="space" modifiers="0" signal="clicked"/>
<child> <child>
<widget class="GtkAlignment" id="alignment1"> <widget class="GtkAlignment" id="alignment18">
<property name="visible">True</property> <property name="visible">True</property>
<property name="xalign">0.5</property> <property name="xalign">0.5</property>
<property name="yalign">0.5</property> <property name="yalign">0.5</property>
@ -587,13 +550,13 @@
<property name="right_padding">0</property> <property name="right_padding">0</property>
<child> <child>
<widget class="GtkHBox" id="hbox4"> <widget class="GtkHBox" id="hbox53">
<property name="visible">True</property> <property name="visible">True</property>
<property name="homogeneous">False</property> <property name="homogeneous">False</property>
<property name="spacing">2</property> <property name="spacing">2</property>
<child> <child>
<widget class="GtkImage" id="image2"> <widget class="GtkImage" id="image58">
<property name="visible">True</property> <property name="visible">True</property>
<property name="stock">gtk-apply</property> <property name="stock">gtk-apply</property>
<property name="icon_size">4</property> <property name="icon_size">4</property>
@ -610,9 +573,9 @@
</child> </child>
<child> <child>
<widget class="GtkLabel" id="label1"> <widget class="GtkLabel" id="label74">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">OK</property> <property name="label" translatable="yes">Start</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="use_markup">False</property> <property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property> <property name="justify">GTK_JUSTIFY_LEFT</property>
@ -1936,4 +1899,45 @@
</child> </child>
</widget> </widget>
<widget class="GtkWindow" id="window_startup_users">
<property name="visible">True</property>
<property name="title" translatable="yes">Players</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="default_width">250</property>
<property name="default_height">200</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_EAST</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow10">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
<property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="treeview_users">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Click on a player to remove him</property>
<property name="can_focus">True</property>
<property name="headers_visible">True</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
<signal name="button_press_event" handler="on_treeview_users_button_press_event" last_modification_time="Fri, 25 Feb 2005 19:29:22 GMT"/>
</widget>
</child>
</widget>
</child>
</widget>
</glade-interface> </glade-interface>

View File

@ -12,21 +12,23 @@ AC_HEADER_STDC
pkg_modules="gtk+-2.0 >= 2.0.0" pkg_modules="gtk+-2.0 >= 2.0.0"
PKG_CHECK_MODULES(PACKAGE, [$pkg_modules]) 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_CFLAGS)
AC_SUBST(PACKAGE_LIBS) AC_SUBST(PACKAGE_LIBS)
GETTEXT_PACKAGE=bygfoot GETTEXT_PACKAGE=bygfoot
AC_SUBST(GETTEXT_PACKAGE) 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. dnl Add the languages which your application supports here.
ALL_LINGUAS="fr de ru ro hu pt_BR" ALL_LINGUAS=""
AM_GLIB_GNU_GETTEXT AM_GLIB_GNU_GETTEXT
AC_OUTPUT([ AC_OUTPUT([
Makefile Makefile
src/Makefile src/Makefile
b-u/Makefile
po/Makefile.in po/Makefile.in
]) ])

View File

@ -12,9 +12,6 @@ bygfoot_SOURCES = \
callback_func.c callback_func.h \ callback_func.c callback_func.h \
callbacks.c callbacks.h \ callbacks.c callbacks.h \
cup.c cup.h free.h maths.h misc.h team.h variables.h xml_league.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 \ file.c file.h free.h misc.h support.h \
finance.c finance.h \ finance.c finance.h \
fixture.c cup.h fixture.h league_struct.h main.h maths.h misc.h team.h variables.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 \ 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 \ 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 \ support.c support.h \
table.c table.h \
team.c cup.h free.h league.h maths.h player.h team.h variables.h \ team.c cup.h free.h league.h maths.h player.h team.h variables.h \
transfer.c transfer.h \ transfer.c transfer.h \
treeview.c gui.h league.h support.h team.h treeview.h variables.h \ treeview.c gui.h league.h support.h team.h treeview.h variables.h \
treeview_cell.c treeview_cell.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 \ 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_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 \ xml_country.c file.h free.h league.h misc.h variables.h xml_cup.h xml_country.h xml_league.h \

View File

@ -24,6 +24,33 @@
#define SMALL 10000 #define SMALL 10000
#define BIG 1000000 #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. * Exit codes.
*/ */
@ -39,23 +66,6 @@ enum ExitCodes
EXIT_END 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. * A struct representing a country.
*/ */
@ -69,17 +79,21 @@ typedef struct
GArray *leagues, *cups; GArray *leagues, *cups;
} Country; } Country;
/** Convenience abbreviation. */ /** Struct used for having all the windows
#define ligs country.leagues in one place. */
/** Convenience abbreviation. */ typedef struct
#define lig(i) g_array_index(country.leagues, League, i) {
GtkWidget *main,
*startup,
*startup_users,
*live;
} Windows;
/** Convenience abbreviation. */ /** A struct representing an option or a constant. */
#define cps country.cups typedef struct
/** Convenience abbreviation. */ {
#define cp(i) g_array_index(country.cups, Cup, i) GString *name, *string_value;
gint value;
/** Convenience abbreviation. */ } Option;
#define player_name(i) ((GString*)g_ptr_array_index(player_names, i))->str;
#endif #endif

View File

@ -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;i<ligs->len;i++)
for(j=0;j<lig(i).fixtures->len;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;i<cps->len;i++)
for(j=0;j<cp(i).fixtures->len;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);
}
}

View File

@ -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

View File

@ -1,12 +1,7 @@
#include "callbacks.h" #include "callbacks.h"
/*d*/ #include "callback_func.h"
#include "game.h" #include "enums.h"
#include "live_game.h" #include "game_gui.h"
#include "maths.h"
#include "player.h"
#include "team.h"
#include "gui.h"
#include "main.h" #include "main.h"
#include "treeview.h" #include "treeview.h"
#include "variables.h" #include "variables.h"
@ -146,29 +141,8 @@ void
on_button_new_week_clicked (GtkButton *button, on_button_new_week_clicked (GtkButton *button,
gpointer user_data) gpointer user_data)
{ {
/*d*/ stat0 = STATUS_SHOW_LIVE_GAME;
gint i, j, k; callback_show_next_live_game();
Fixture *fix;/* = &g_array_index(lig(0).fixtures, Fixture, */
/* math_rndi(0, lig(0).fixtures->len - 1)); */
for(k=0;k<lig(0).fixtures->len;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++;
} }
@ -179,13 +153,26 @@ on_button_help_clicked (GtkButton *button,
} }
gboolean gboolean
on_player_list_button_press_event (GtkWidget *widget, on_player_list1_button_press_event (GtkWidget *widget,
GdkEventButton *event, GdkEventButton *event,
gpointer user_data) 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 void
on_menu_tables_activate (GtkMenuItem *menuitem, on_menu_tables_activate (GtkMenuItem *menuitem,
gpointer user_data) 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 void
on_menu_player_activate (GtkMenuItem *menuitem, on_menu_player_activate (GtkMenuItem *menuitem,
gpointer user_data) 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 void
on_menu_put_on_transfer_list_activate (GtkMenuItem *menuitem, on_menu_put_on_transfer_list_activate (GtkMenuItem *menuitem,
gpointer user_data) 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 void
on_menu_my_league_results_activate (GtkMenuItem *menuitem, on_menu_my_league_results_activate (GtkMenuItem *menuitem,
gpointer user_data) gpointer user_data)
@ -635,11 +501,11 @@ on_menu_browse_teams_activate (GtkMenuItem *menuitem,
gpointer user_data) gpointer user_data)
{ {
GtkWidget *treeview_right = 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)
{
}

View File

@ -2,7 +2,6 @@
#define CALLBACKS_H #define CALLBACKS_H
#include "bygfoot.h" #include "bygfoot.h"
#include "interface.h" #include "interface.h"
#include "support.h" #include "support.h"
@ -79,11 +78,6 @@ void
on_button_help_clicked (GtkButton *button, on_button_help_clicked (GtkButton *button,
gpointer user_data); gpointer user_data);
gboolean
on_player_list_button_press_event (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data);
void void
on_structure_entry_activate (GtkEntry *entry, on_structure_entry_activate (GtkEntry *entry,
gpointer user_data); gpointer user_data);
@ -152,54 +146,6 @@ void
on_menu_fixtures_activate (GtkMenuItem *menuitem, on_menu_fixtures_activate (GtkMenuItem *menuitem,
gpointer user_data); 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 void
on_menu_tables_activate (GtkMenuItem *menuitem, on_menu_tables_activate (GtkMenuItem *menuitem,
gpointer user_data); gpointer user_data);
@ -212,10 +158,6 @@ void
on_menu_season_history_activate (GtkMenuItem *menuitem, on_menu_season_history_activate (GtkMenuItem *menuitem,
gpointer user_data); gpointer user_data);
void
on_menu_team_history_activate (GtkMenuItem *menuitem,
gpointer user_data);
void void
on_menu_player_activate (GtkMenuItem *menuitem, on_menu_player_activate (GtkMenuItem *menuitem,
gpointer user_data); gpointer user_data);
@ -224,10 +166,6 @@ void
on_menu_show_info_activate (GtkMenuItem *menuitem, on_menu_show_info_activate (GtkMenuItem *menuitem,
gpointer user_data); gpointer user_data);
void
on_menu_show_history_activate (GtkMenuItem *menuitem,
gpointer user_data);
void void
on_menu_put_on_transfer_list_activate (GtkMenuItem *menuitem, on_menu_put_on_transfer_list_activate (GtkMenuItem *menuitem,
gpointer user_data); gpointer user_data);
@ -297,10 +235,6 @@ void
on_menu_physio_bad_activate (GtkMenuItem *menuitem, on_menu_physio_bad_activate (GtkMenuItem *menuitem,
gpointer user_data); gpointer user_data);
void
on_menu_boost_activate (GtkMenuItem *menuitem,
gpointer user_data);
void void
on_menu_my_league_results_activate (GtkMenuItem *menuitem, on_menu_my_league_results_activate (GtkMenuItem *menuitem,
gpointer user_data); gpointer user_data);
@ -314,8 +248,6 @@ gboolean
on_treeview_right_button_press_event (GtkWidget *widget, on_treeview_right_button_press_event (GtkWidget *widget,
GdkEventButton *event, GdkEventButton *event,
gpointer user_data); gpointer user_data);
#endif
void void
on_menu_finances_stadium_activate (GtkMenuItem *menuitem, on_menu_finances_stadium_activate (GtkMenuItem *menuitem,
gpointer user_data); gpointer user_data);
@ -335,3 +267,34 @@ on_menu_get_loan_activate (GtkMenuItem *menuitem,
void void
on_menu_pay_loan_activate (GtkMenuItem *menuitem, on_menu_pay_loan_activate (GtkMenuItem *menuitem,
gpointer user_data); 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);

View File

@ -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++) 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, if(!query_is_in_international_cups(
Team, permutation[i - choose_team->start_idx + 1]))) &g_array_index(lig(number - 1).teams,
Team, permutation[i - choose_team->start_idx + 1])))
{ {
g_ptr_array_add(cup->user_teams, g_ptr_array_add(cup->user_teams,
(gpointer)&g_array_index(lig(number - 1).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_teams = cup_round_get_number_of_teams(cup, cup_round);
number_of_matchdays = 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) else if(g_array_index(cup->rounds, CupRound, cup_round).home_away)
number_of_matchdays = 2; number_of_matchdays = 2;
@ -353,3 +355,19 @@ cup_get_team_pointers(const Cup *cup)
return teams; 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;i<cps->len;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;
}

View File

@ -37,4 +37,7 @@ cup_get_matchdays_in_cup_round(const Cup *cup, gint cup_round);
gint gint
cup_round_get_number_of_teams(const Cup *cup, gint cup_round); cup_round_get_number_of_teams(const Cup *cup, gint cup_round);
Cup*
cup_from_clid(gint clid);
#endif #endif

View File

@ -1,175 +0,0 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gtk/gtk.h>
#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)
{
}

View File

@ -1,85 +0,0 @@
#include <gtk/gtk.h>
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);

View File

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +0,0 @@
/*
* DO NOT EDIT THIS FILE - it is generated by Glade.
*/
GtkWidget* create_editor_window (void);

View File

@ -1,6 +1,16 @@
#ifndef ENUMS_H #ifndef ENUMS_H
#define 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. */ /** Indices for the #finances variable. */
enum FinanceValue enum FinanceValue
{ {
@ -19,7 +29,7 @@ enum FinanceValue
FIN_END FIN_END
}; };
/** Indices for the #counters variable. */ /** Indices for the counters variable in #User. */
enum CounterValue enum CounterValue
{ {
COUNT_LOAN = 0, /** How many weeks until user has to pay back his loan. */ COUNT_LOAN = 0, /** How many weeks until user has to pay back his loan. */
@ -39,50 +49,19 @@ enum CounterValue
COUNT_END COUNT_END
}; };
/** Indices for the #options variable. */ /** Possible values for a status variable. */
enum OptionValue enum Status0Value
{ {
OPT_BOOL_CONF_NEW_ROUND = 0, /**< Whether beginning of a new week round has to be confirmed. */ STATUS_NONE = 0,
OPT_BOOL_CONF_UNFIT, /**< Unfit player confirmation. */ STATUS_MAIN,
OPT_BOOL_CONF_QUIT, /**< Quit confirmation. */ STATUS_SHOW_LIVE_GAME,
OPT_BOOL_OVERWRITE, /**< Clicking on save overwrites current save game. */ STATUS_LIVE_GAME_PAUSE,
OPT_BOOL_SHOW_LIVE, /**< Whether live game is shown. */ STATUS_BROWSE_TEAMS,
OPT_LIVE_SPEED, /**< Live game speed. */ STATUS_TEAM_SELECTION,
OPT_BOOL_LIVE_TENDENCY, /**< Tendency bar. */ /** We set this so that we know that
OPT_BOOL_MAXIMIZE, /**< Whether to start maximized. */ gui signals have to be ignored for the time being. */
OPT_BOOL_NOTIFY, /**< Whether transfer list notification is on. */ STATUS_GUI_NO_REACTION,
OPT_NOTIFY_POS, /**< Whether we look for a certain position. */ STATUS_END
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
}; };
#endif #endif

View File

@ -2,7 +2,9 @@
#include "free.h" #include "free.h"
#include "main.h" #include "main.h"
#include "misc.h" #include "misc.h"
#include "option.h"
#include "support.h" #include "support.h"
#include "user.h"
#include "variables.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 /** Read the file until the next line that's not a comment or
a blank line and copy the line into buf. a blank line. Split the line into the part before and after
@param fil The file stream. the first white space and copy them into the char arrays.
@param buf The buffer we fill. Trailing and leading white spaces and trailing comments are stripped.
@return TRUE if the file still contains lines to read, FALSE otherwise. */ @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 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) feof(fil) == 0)
{ {
fscanf(fil, "%[\n \t]*", local_buf); fscanf(fil, "%[\n \t]*", buf);
fscanf(fil, "%[^\n]", local_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"); g_warning("\n the text file I'm reading contains a line longer than 100 chars.\n\n");
if(buf != NULL) for(i=0;i<strlen(buf);i++)
strcpy(buf, local_buf); if(buf[i] == '#')
{
buf[i] = '\0';
break;
}
for(i=strlen(buf) - 1;i>0;i--)
if(buf[i] == '\t' || buf[i] == ' ')
buf[i] = '\0';
else
break;
sscanf(buf, "%[^ ]%[ ]%[^\n]", opt_name, trash, opt_value);
} }
return (feof(fil) == 0); return (feof(fil) == 0);
} }
/** Supply the strings in the config file that belong to the options. /** Load a file containing name - value pairs into
@param opt_names The array we write the optionstrings into. the specified array. */
@param player_list_att_names The array we write the player list attribute strings into. */
void 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"); free_option_array(option_array, TRUE);
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");
strcpy(opt_names[OPT_BOOL_NOTIFY], "notify_transfer"); while(file_get_next_opt_line(fil, opt_name, opt_value))
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++)
{ {
for(j=0;j<PLAYER_LIST_ATTRIBUTE_END;j++) new.name = g_string_new(opt_name);
sprintf(player_list_att_names[i][j], "pl%d_att_", i + 1); if(g_str_has_prefix(opt_name, "string_"))
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_NAME], "name");
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_CPOS], "cpos");
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_POS], "pos");
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_CSKILL], "cskill");
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_SKILL], "skill");
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_FITNESS], "fitness");
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_GAMES], "games");
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_GOALS], "goals");
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_STATUS], "status");
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_CARDS], "cards");
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_AGE], "age");
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_ETAL], "etal");
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_VALUE], "value");
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_WAGE], "wage");
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_CONTRACT], "contract");
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_TEAM], "team");
strcat(player_list_att_names[i][PLAYER_LIST_ATTRIBUTE_LEAGUE_CUP], "league_cup");
}
}
/** Load the options at the beginning of a new game from
the configuration file. */
void
file_load_conf_file(void)
{
gint i, j;
gchar opt_names[OPT_END][50];
gchar player_list_attribute_names[2][PLAYER_LIST_ATTRIBUTE_END][50];
FILE *fil;
gchar *conf_file = file_find_support_file("bygfoot.conf");
gchar buf[SMALL];
gchar buf2[SMALL];
gchar trash[SMALL];
file_my_fopen(conf_file, "r", &fil, TRUE);
g_free(conf_file);
file_write_opt_names(opt_names, player_list_attribute_names);
while(file_get_next_line(fil, buf))
{
for(i=0;i<OPT_END;i++)
if(strncmp(opt_names[i], buf, strlen(opt_names[i])) == 0)
sscanf(buf, "%[^-0-9 ]%d", trash, &options[i]);
for(j=0;j<2;j++)
for(i=0;i<PLAYER_LIST_ATTRIBUTE_END;i++)
if(strncmp(player_list_attribute_names[j][i], buf, strlen(player_list_attribute_names[j][i])) == 0)
sscanf(buf, "%[^ ]%[ ]%d", trash, buf2,
&player_list_attributes[j].on_off[i]);
if(strncmp(buf, "font_name", strlen("font_name")) == 0)
{ {
sscanf(buf, "%[font_name ]%[^\n]", trash, buf2); new.string_value = g_string_new(opt_value);
g_string_printf(font_name, "%s", buf2); new.value = -1;
}
else
{
new.string_value = NULL;
sscanf(opt_value, "%d", &new.value);
} }
if(strncmp(buf, "debug", strlen("debug")) == 0) g_array_append_val(*option_array, new);
sscanf(buf, "%[debug ]%d", trash, &debug);
} }
}
/** Save the current options to the configuration file. */
void
file_save_conf(void)
{
gint i, j;
gchar opt_names[OPT_END][50];
gchar player_list_att_names[2][PLAYER_LIST_ATTRIBUTE_END][50];
FILE *fil = NULL;
gchar *conf_file = file_find_support_file("bygfoot.conf");
if(!file_my_fopen(conf_file, "w", &fil, FALSE))
return;
g_free(conf_file);
file_write_opt_names(opt_names, player_list_att_names);
for(i=0;i<OPT_PENALTY_SHOOTER;i++)
fprintf(fil, "%s %d\n", opt_names[i], options[i]);
fprintf(fil, "%s -1\n", opt_names[OPT_PENALTY_SHOOTER]);
for(j=0;j<2;j++)
{
fprintf(fil, "\n");
for(i=0;i<PLAYER_LIST_ATTRIBUTE_END;i++)
fprintf(fil, "%s %d\n", player_list_att_names[j][i],
player_list_attributes[j].on_off[i]);
}
fprintf(fil, "\n");
fprintf(fil, "font_name %s\n", font_name->str);
fprintf(fil, "debug %d\n", debug);
fclose(fil); 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);
}

View File

@ -3,6 +3,7 @@
#include "bygfoot.h" #include "bygfoot.h"
#include "player_struct.h" #include "player_struct.h"
#include "user_struct.h"
void void
file_add_support_directory_recursive (const gchar *directory); file_add_support_directory_recursive (const gchar *directory);
@ -11,7 +12,7 @@ gchar*
file_find_support_file (const gchar *filename); file_find_support_file (const gchar *filename);
gboolean gboolean
file_get_next_line(FILE *fil, gchar *buf); file_get_next_opt_line(FILE *fil, gchar *opt_name, gchar *opt_value);
GPtrArray* GPtrArray*
file_dir_get_contents(const gchar *dir_name, const gchar *prefix); file_dir_get_contents(const gchar *dir_name, const gchar *prefix);
@ -26,12 +27,22 @@ void
file_get_definitions_dir(gchar *dir); file_get_definitions_dir(gchar *dir);
void 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 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 void
file_save_conf(void); file_save_conf(void);
void
file_load_user_conf_file(User *user);
void
file_load_const_file(void);
#endif #endif

View File

@ -5,6 +5,7 @@
#include "main.h" #include "main.h"
#include "maths.h" #include "maths.h"
#include "misc.h" #include "misc.h"
#include "table.h"
#include "team.h" #include "team.h"
#include "variables.h" #include "variables.h"
@ -57,7 +58,7 @@ fixture_write_cup_fixtures(Cup *cup)
if(g_array_index(cup->rounds, CupRound, 0). if(g_array_index(cup->rounds, CupRound, 0).
round_robin_number_of_groups > 0) round_robin_number_of_groups > 0)
fixture_write_cup_round_robin(cup, 0); fixture_write_cup_round_robin(cup, 0, NULL);
else else
{ {
if(cup->type == CUP_TYPE_INTERNATIONAL) if(cup->type == CUP_TYPE_INTERNATIONAL)
@ -65,7 +66,7 @@ fixture_write_cup_fixtures(Cup *cup)
else else
teams = team_get_pointers_from_choose_teams(cup->choose_teams); 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*/ /*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;i<cup->bye->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;i<teams->len;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;i<cup->fixtures->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;i<fixtures->len;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;i<fixtures->len;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;i<fixtures->len;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;i<cup->tables->len;i++)
for(j=0;j<g_array_index(cup->tables, 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;i<cupround->round_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;i<fixtures->len;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. /** Write round robins for the given cup and cup round.
@param cup The cup the fixtures are for. @param cup The cup the fixtures are for.
@param cup_round The cup round. */ @param cup_round The cup round. */
void 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 i, j;
gint number_of_groups = gint number_of_groups =
g_array_index(cup->rounds, CupRound, cup_round).round_robin_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]; GPtrArray *teams_group[number_of_groups];
Table new_table; Table new_table;
TableElement new_table_element; TableElement new_table_element;
if(cup_round == 0) if(teams == NULL)
teams = misc_randomise_g_pointer_array(cup_get_team_pointers(cup)); 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) 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.name = g_string_new(cup->name->str);
new_table.clid = cup->id; new_table.clid = cup->id;
new_table.round = cup_round;
new_table.elements = g_array_new(FALSE, FALSE, sizeof(TableElement)); new_table.elements = g_array_new(FALSE, FALSE, sizeof(TableElement));
teams_group[i] = g_ptr_array_new(); 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)); g_ptr_array_add(teams_group[i], g_ptr_array_index(teams, j + i * number_of_groups));
new_table_element = 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); 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]); fixture_write_round_robin((gpointer)cup, cup_round, teams_group[i]);
} }
cup->next_fixture_update_week = cup->next_fixture_update_week = (cup_round < cup->rounds->len - 1) ?
g_array_index(cup->fixtures, Fixture, cup->fixtures->len - 1).week_number; g_array_index(cup->fixtures, Fixture, cup->fixtures->len - 1).week_number : -1;
cup->next_fixture_update_week_round = 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; g_array_index(cup->fixtures, Fixture, cup->fixtures->len - 1).week_round_number : -1;
} }
/** Write round robin fixtures for the teams in the array. /** 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 i, j;
gint first_week, week_gap, clid, first_fixture; gint first_week, week_gap, clid, first_fixture;
gboolean home_advantage, second_leg, decisive; gboolean home_advantage;
League *league = NULL; League *league = NULL;
Cup *cup = NULL; Cup *cup = NULL;
gint len = teams->len; 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); home_advantage = (!g_array_index(cup->rounds, CupRound, cup_round).neutral);
} }
second_leg = decisive = FALSE;
first_fixture = fixtures->len; first_fixture = fixtures->len;
if(first_week < 1) 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, fixture_write_round_robin_matchday(fixtures, cup_round, teams, i,
first_week + i * week_gap, first_week + i * week_gap,
fixture_get_free_round(first_week + i * week_gap, clid), fixture_get_free_round(first_week + i * week_gap, clid),
clid, home_advantage, second_leg, decisive); clid, home_advantage);
/* second half of fixtures */ /* second half of fixtures */
for(i = 0; i < len - 1; i++) 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], g_array_index(fixtures, Fixture, first_fixture + i * (len / 2) + j).teams[0],
first_week + (len - 1 + i) * week_gap, first_week + (len - 1 + i) * week_gap,
fixture_get_free_round(first_week + (len - 1 + i) * week_gap, clid), 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. /** 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_number The week the matchday takes place.
@param week_round_number The week_round 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 clid The id of the league or cup.
@param home_advantage Whether there's home advantage. @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 void
fixture_write_round_robin_matchday(GArray *fixtures, gint cup_round, GPtrArray *teams, fixture_write_round_robin_matchday(GArray *fixtures, gint cup_round, GPtrArray *teams,
gint special, gint week_number, gint week_round_number, gint special, gint week_number, gint week_round_number,
gint clid, gboolean home_advantage, gboolean second_leg, gint clid, gboolean home_advantage)
gboolean decisive)
{ {
gint i; gint i;
gint len = teams->len / 2; gint len = teams->len / 2;
@ -256,7 +461,7 @@ fixture_write_round_robin_matchday(GArray *fixtures, gint cup_round, GPtrArray *
for(i=0;i<len;i++) for(i=0;i<len;i++)
fixture_write(fixtures, (Team*)home[i], (Team*)away[i], week_number, week_round_number, fixture_write(fixtures, (Team*)home[i], (Team*)away[i], week_number, week_round_number,
clid, cup_round, home_advantage, second_leg, decisive); clid, cup_round, 0, home_advantage, FALSE, FALSE);
} }
/** Write fixtures for a knockout round, e.g. home/away games. /** Write fixtures for a knockout round, e.g. home/away games.
@ -264,7 +469,7 @@ fixture_write_round_robin_matchday(GArray *fixtures, gint cup_round, GPtrArray *
@param cup The cup the fixtures belong to. @param cup The cup the fixtures belong to.
@param cup_round The index of the cup round. */ @param cup_round The index of the cup round. */
void void
fixture_write_knockout_round(GPtrArray *teams, Cup *cup, gint cup_round) fixture_write_knockout_round(Cup *cup, gint cup_round, GPtrArray *teams)
{ {
gint i, len = teams->len; gint i, len = teams->len;
gint first_week = cup_get_first_week_of_cup_round(cup, cup_round); 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++) for(i=0; i<(len - bye_len) / 2; i++)
fixture_write(cup->fixtures, (Team*)g_ptr_array_index(teams, 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, (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->neutral, FALSE, (!round->home_away && round->replay == 0));/*todo: adjust
round->replay */ round->replay */
if(round->home_away) 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), 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, (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, 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 = cup->next_fixture_update_week = (cup_round < cup->rounds->len - 1) ?
g_array_index(cup->fixtures, Fixture, cup->fixtures->len - 1).week_number; g_array_index(cup->fixtures, Fixture, cup->fixtures->len - 1).week_number : -1;
cup->next_fixture_update_week_round = 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; g_array_index(cup->fixtures, Fixture, cup->fixtures->len - 1).week_round_number : -1;
} }
/** Write a fixture and append it to a fixture array. /** 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 week_round_number The week_round it takes place.
@param clid The id of the league or cup. @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 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 home_advantage Whether there's home advantage.
@param second_leg Whether this is the second leg of a round. @param second_leg Whether this is the second leg of a round.
@param decisive Whether the match has to have a winner. */ @param decisive Whether the match has to have a winner. */
void void
fixture_write(GArray *fixtures, Team *home_team, Team *away_team, gint week_number, 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, gint week_round_number, gint clid, gint cup_round, gint replay_number,
gboolean second_leg, gboolean decisive) gboolean home_advantage, gboolean second_leg, gboolean decisive)
{ {
gint i; gint i;
Fixture new; Fixture new;
new.clid = clid; new.clid = clid;
new.round = cup_round; new.round = cup_round;
new.replay_number = replay_number;
new.week_number = week_number; new.week_number = week_number;
new.week_round_number = week_round_number; new.week_round_number = week_round_number;
new.teams[0] = (Team*)home_team; 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.home_advantage = home_advantage;
new.second_leg = second_leg; new.second_leg = second_leg;
new.decisive = decisive; new.decisive = decisive;
new.attendance = 0; new.attendance = -1;
g_array_append_val(fixtures, new); g_array_append_val(fixtures, new);
} }
@ -390,14 +597,91 @@ query_fixture_is_earlier(const Fixture *fix1, const Fixture *fix2)
gboolean gboolean
query_fixture_is_draw(const Fixture *fix) 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;i<fixtures->len;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; return FALSE;
} }
/** Check whether the user's team participates. /** Return a pointer to the first leg going with
@param fix The fixture we check. the fixture.
@return TRUE or FALSE. */ @param fix The second leg fixture.
gboolean @return A fixture pointer or NULL if failed. */
query_my_team_involved(const Fixture *fix) 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;i<cup_from_clid(fix->clid)->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;
} }

View File

@ -13,7 +13,7 @@ void
fixture_write_cup_fixtures(Cup *cup); fixture_write_cup_fixtures(Cup *cup);
void void
fixture_write_cup_round_robin(Cup *cup, gint cup_round); fixture_write_cup_round_robin(Cup *cup, gint cup_round, GPtrArray *teams);
void void
fixture_write_round_robin(gpointer league_cup, gint cup_round, GPtrArray *teams); 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 void
fixture_write_round_robin_matchday(GArray *fixtures, gint cup_round, GPtrArray *teams, fixture_write_round_robin_matchday(GArray *fixtures, gint cup_round, GPtrArray *teams,
gint special, gint week_number, gint week_round_number, gint special, gint week_number, gint week_round_number,
gint clid, gboolean home_advantage, gboolean second_leg, gint clid, gboolean home_advantage);
gboolean decisive);
void void
fixture_write_knockout_round(GPtrArray *teams, Cup *cup, gint cup_round); fixture_write_knockout_round(Cup *cup, gint cup_round, GPtrArray *teams);
void void
fixture_write(GArray *fixtures, Team *home_team, Team *away_team, gint week_number, 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, gint week_round_number, gint clid, gint cup_round, gint replay_number,
gboolean second_leg, gboolean decisive); 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 gint
fixture_get_free_round(gint week_number, gint clid); fixture_get_free_round(gint week_number, gint clid);
@ -41,7 +55,16 @@ query_fixture_is_earlier(const Fixture *fix1, const Fixture *fix2);
gboolean gboolean
query_fixture_is_draw(const Fixture *fix); query_fixture_is_draw(const Fixture *fix);
gint
fixture_user_team_involved(const Fixture *fix);
gboolean 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 #endif

View File

@ -12,6 +12,8 @@ typedef struct
gint clid; gint clid;
/** The round (in a cup) the fixture belongs to. */ /** The round (in a cup) the fixture belongs to. */
gint round; gint round;
/** The replay number (ie. how often the match was repeated because of a draw). */
gint replay_number;
/** When it takes place. */ /** When it takes place. */
gint week_number, week_round_number; gint week_number, week_round_number;
/** The teams involved. */ /** The teams involved. */

View File

@ -3,6 +3,7 @@
#include "free.h" #include "free.h"
#include "league.h" #include "league.h"
#include "player.h" #include "player.h"
#include "user.h"
#include "variables.h" #include "variables.h"
#include "window.h" #include "window.h"
@ -15,19 +16,71 @@ free_memory(void)
{ {
free_variables(); free_variables();
free_country(); free_country();
free_g_string(&font_name); free_users();
free_live_game(&live_game);
free_live_game(&live_game_temp); free_live_game(&live_game_temp);
} }
/** Free the users array. */
void
free_users(void)
{
gint i;
if(users == NULL)
return;
for(i=0;i<users->len;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. */ /** Free a live game variable. */
void void
free_live_game(LiveGame *match) free_live_game(LiveGame *match)
{ {
gint i; gint i;
window_destroy(&match->window);
if(match->units == NULL) if(match->units == NULL)
return; return;
@ -250,6 +303,9 @@ free_variables(void)
free_g_string_array(&player_names); free_g_string_array(&player_names);
free_g_array(&transfer_list); free_g_array(&transfer_list);
free_option_array(&options, FALSE);
free_option_array(&constants, FALSE);
} }
/** /**

View File

@ -7,6 +7,7 @@
#include "live_game_struct.h" #include "live_game_struct.h"
#include "player_struct.h" #include "player_struct.h"
#include "team_struct.h" #include "team_struct.h"
#include "user_struct.h"
void void
free_g_array(GArray **array); free_g_array(GArray **array);
@ -20,6 +21,12 @@ free_g_string(GString **string);
void void
free_memory(void); free_memory(void);
void
free_users(void);
void
free_user(User *user);
void void
free_country(void); free_country(void);
@ -59,4 +66,7 @@ free_player(Player *pl);
void void
free_live_game(LiveGame *match); free_live_game(LiveGame *match);
void
free_option_array(GArray **array, gboolean reset);
#endif #endif

View File

@ -1,14 +1,12 @@
#include "fixture.h" #include "fixture.h"
#include "game.h" #include "game.h"
#include "maths.h" #include "maths.h"
#include "option.h"
#include "player.h" #include "player.h"
#include "team.h" #include "team.h"
#include "user.h"
#include "variables.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 /** How the cskill of field players get weighted for the team values in
a match. Rows are player position, columns value type. a match. Rows are player position, columns value type.
@see game_get_player_contribution() */ @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; gfloat style_factor;
/*d*/ /*d*/
printf("\nhome %.2f\n", home_advantage); /* printf("\nhome %.2f\n", home_advantage); */
for(i=0;i<2;i++) for(i=0;i<2;i++)
{ {
for(j=0;j<GAME_TEAM_VALUE_END;j++) for(j=0;j<GAME_TEAM_VALUE_END;j++)
team_values[i][j] = 0; team_values[i][j] = 0;
style_factor = (gfloat)tm[i]->style * CONSTANT_GAME_STYLE_FACTOR; style_factor = (gfloat)tm[i]->style * const_float("float_game_style_factor");
team_values[i][GAME_TEAM_VALUE_GOALIE] = team_values[i][GAME_TEAM_VALUE_GOALIE] =
game_get_player_contribution(player_of(tm[i], 0), FALSE) * game_get_player_contribution(player_of(tm[i], 0), FALSE) *
(1 + home_advantage * (i == 0)) * (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++) 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] *= team_values[i][GAME_TEAM_VALUE_ATTACK] *=
((1 + style_factor) * (1 + home_advantage * (i == 0)) * ((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] *= team_values[i][GAME_TEAM_VALUE_DEFEND] *=
((1 - style_factor) * (1 + home_advantage * (i == 0)) * ((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 &&
/*d*/ option_int("int_opt_user_boost", usr(team_is_user(tm[i])).options) == 1)));
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]);
} }
} }
@ -81,7 +78,7 @@ gfloat
game_get_player_contribution(const Player *pl, gint type) game_get_player_contribution(const Player *pl, gint type)
{ {
return (gfloat)(pl->cskill * powf((gfloat)pl->fitness / 100, 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]); 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 tm The team we examine.
@param player_type Whether we concentrate on attacking or defending players @param player_type Whether we concentrate on attacking or defending players
or would like to have a penalty shooting player. 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 not_this_one A player to exclude.
@param skills Whether to weight with skills, too. @param skills Whether to weight with skills, too.
@return A player index. */ @return A player index. */
gint gint
game_get_player(const Team *tm, gint player_type, 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) gboolean skills)
{ {
gint i, player = not_this_one; 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) else if(player_type == GAME_PLAYER_TYPE_INJURY)
weights[0] = -1; weights[0] = -1;
else if(player_type == GAME_PLAYER_TYPE_PENALTY) else if(player_type == GAME_PLAYER_TYPE_PENALTY)
/*d*/ return game_get_penalty_taker(tm, last_penalty);
return player_of(tm, 10)->id;
game_get_player_probs(tm->players, probs, weights, skills); 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 * probs[0] = (skills) ? (gfloat)g_array_index(players, Player, 1).cskill *
powf((gfloat)g_array_index(players, Player, 1).fitness, 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] :
weights[g_array_index(players, Player, 1).pos - 1]; weights[g_array_index(players, Player, 1).pos - 1];
for(i=1;i<10;i++) for(i=1;i<10;i++)
probs[i] = probs[i - 1] + probs[i] = probs[i - 1] +
((skills) ? (gfloat)g_array_index(players, Player, i + 1).cskill * ((skills) ? (gfloat)g_array_index(players, Player, i + 1).cskill *
powf((gfloat)g_array_index(players, Player, i + 1).fitness, 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] :
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;i<players->len - 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;
}

View File

@ -5,14 +5,6 @@
#include "fixture_struct.h" #include "fixture_struct.h"
#include "player_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. /** Indices for the team_value array.
@see game_get_values() */ @see game_get_values() */
enum GameTeamValue enum GameTeamValue
@ -50,4 +42,10 @@ game_get_player(const Team *tm, gint player_type,
void void
game_get_player_probs(GArray *players, gfloat *probs, gfloat *weights, gboolean skills); 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 #endif

View File

@ -1,24 +1,20 @@
#include <unistd.h> #include <unistd.h>
#include "game_gui.h" #include "game_gui.h"
#include "gui.h"
#include "league.h"
#include "live_game.h"
#include "maths.h"
#include "option.h"
#include "treeview.h" #include "treeview.h"
#include "support.h" #include "support.h"
#include "window.h" #include "team.h"
#include "user.h"
/** Constants determining the live game area scale #include "variables.h"
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"
/** Show the live game in the live game window. /** 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 void
game_gui_live_game_show_unit(const LiveGameUnit *unit) 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; gfloat fraction = (gfloat)live_game_unit_get_minute(unit) / 90;
GtkProgressBar *progress_bar; GtkProgressBar *progress_bar;
if(live_game.window == NULL) if(unit->event.type == LIVE_GAME_EVENT_START_MATCH)
{
live_game.window = window_create(WINDOW_LIVE);
treeview_live_game_show_initial_commentary(unit); 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 else
treeview_live_game_show_commentary(unit); treeview_live_game_show_commentary(unit);
treeview_live_game_show_result(unit); treeview_live_game_show_result(unit);
game_gui_live_game_set_hscale(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)); 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_fraction(progress_bar, (fraction > 1) ? 1 : fraction);
gtk_progress_bar_set_text(progress_bar, buf); 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()) while(gtk_events_pending())
gtk_main_iteration(); gtk_main_iteration();
if(unit->event.type == LIVE_GAME_EVENT_END_MATCH) 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. /** 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) 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), 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 || else if(unit->event.type == LIVE_GAME_EVENT_GOAL ||
unit->event.type == LIVE_GAME_EVENT_OWN_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), 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 || else if(unit->event.type == LIVE_GAME_EVENT_SCORING_CHANCE ||
unit->event.type == LIVE_GAME_EVENT_PENALTY || unit->event.type == LIVE_GAME_EVENT_PENALTY ||
unit->event.type == LIVE_GAME_EVENT_FREE_KICK) 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), 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 +
(CONSTANT_GAME_GUI_LIVE_GAME_SCALE_RANGE * (const_float("float_game_gui_live_game_scale_range") *
CONSTANT_GAME_GUI_LIVE_GAME_SCALE_CHANCE * const_float("float_game_gui_live_game_scale_chance") *
((unit->possession == 0) ? 1 : -1))); ((unit->possession == 0) ? 1 : -1)));
} }
else if(unit->event.type == LIVE_GAME_EVENT_POST || else if(unit->event.type == LIVE_GAME_EVENT_POST ||
unit->event.type == LIVE_GAME_EVENT_MISSED || unit->event.type == LIVE_GAME_EVENT_MISSED ||
unit->event.type == LIVE_GAME_EVENT_SAVE || unit->event.type == LIVE_GAME_EVENT_SAVE ||
unit->event.type == LIVE_GAME_EVENT_CROSS_BAR) 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) 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), 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 +
(CONSTANT_GAME_GUI_LIVE_GAME_SCALE_RANGE * (const_float("float_game_gui_live_game_scale_range") *
CONSTANT_GAME_GUI_LIVE_GAME_SCALE_ATTACK * const_float("float_game_gui_live_game_scale_attack") *
((unit->possession == 0) ? 1 : -1))); ((unit->possession == 0) ? 1 : -1)));
} }
else if(unit->area == LIVE_GAME_UNIT_AREA_DEFEND) 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), 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 +
(CONSTANT_GAME_GUI_LIVE_GAME_SCALE_RANGE * (const_float("float_game_gui_live_game_scale_range") *
CONSTANT_GAME_GUI_LIVE_GAME_SCALE_ATTACK * const_float("float_game_gui_live_game_scale_attack") *
((unit->possession == 0) ? -1 : 1))); ((unit->possession == 0) ? -1 : 1)));
} }
else else
g_warning("game_gui_live_game_set_hscale: don't know what to do!\n"); 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); 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<INSENSITIVE_ITEM_END;i++)
gtk_widget_set_sensitive(insensitive_items[i], !value);
gtk_widget_set_sensitive(window.main, value);
} }

View File

@ -2,8 +2,7 @@
#define GAME_GUI_H #define GAME_GUI_H
#include "bygfoot.h" #include "bygfoot.h"
#include "live_game.h" #include "live_game_struct.h"
#include "variables.h"
void void
game_gui_live_game_show_unit(const LiveGameUnit *unit); game_gui_live_game_show_unit(const LiveGameUnit *unit);
@ -11,4 +10,32 @@ game_gui_live_game_show_unit(const LiveGameUnit *unit);
void void
game_gui_live_game_set_hscale(const LiveGameUnit *unit, GtkHScale *hscale); game_gui_live_game_set_hscale(const LiveGameUnit *unit, GtkHScale *hscale);
void
game_gui_set_main_window_header(void);
void
game_gui_show_main(void);
void
game_gui_get_radio_items(GtkWidget **style, GtkWidget **scout,
GtkWidget **physio);
void
game_gui_print_message(gchar *text);
void
game_gui_read_radio_items(GtkWidget *widget);
void
game_gui_write_radio_items(void);
gboolean
game_gui_clear_entry_message(gpointer data);
void
game_gui_set_main_window_sensitivity(gboolean value);
void
game_gui_write_av_skills(void);
#endif #endif

View File

@ -1,3 +1,52 @@
#include "gui.h" #include "gui.h"
#include "misc.h"
#include "variables.h" #include "variables.h"
/* Set into or append an integer into a label.
@param label The label.
@param number The number.
@param append Whether or not to append.*/
void
gui_label_set_text_from_int(GtkLabel *label, gint number, gboolean append)
{
const gchar *current_text = gtk_label_get_text(label);
gchar buf[SMALL], buf2[SMALL];
strcpy(buf, "");
strcpy(buf2, "");
if(number > 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);
}

View File

@ -3,13 +3,11 @@
#include "bygfoot.h" #include "bygfoot.h"
/** Possible values for the status variable. */ void
enum StatusValue gui_label_set_text_from_int(GtkLabel *label, gint number, gboolean append);
{
STATUS_NONE = 0, void
STATUS_MAIN, gui_label_set_text_from_float(GtkLabel *label, gfloat number,
STATUS_BROWSE_TEAMS, gboolean append, gint precision);
STATUS_END
};
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -33,6 +33,7 @@ league_new(void)
new.table.name = g_string_new(""); new.table.name = g_string_new("");
new.table.clid = new.id; new.table.clid = new.id;
new.table.round = -1;
new.table.elements = g_array_new(FALSE, FALSE, sizeof(TableElement)); new.table.elements = g_array_new(FALSE, FALSE, sizeof(TableElement));
new.first_week = new.week_gap = 1; new.first_week = new.week_gap = 1;
@ -83,22 +84,6 @@ league_new_id(void)
return -1; 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;i<TABLE_END;i++)
new.values[i] = 0;
return new;
}
/** Get the array index of the given league or cup id. /** Get the array index of the given league or cup id.
@param clid The id of the league or cup. @param clid The id of the league or cup.
@return The index in the leagues or cups array. */ @return The index in the leagues or cups array. */
@ -130,3 +115,19 @@ league_cup_get_index_from_clid(gint clid)
return index; return index;
} }
/** Return the league pointer belonging to the id.
@param clid The id we look for.
@return The league pointer or NULL if failed. */
League*
league_from_clid(gint clid)
{
gint i;
for(i=0;i<ligs->len;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;
}

View File

@ -19,4 +19,7 @@ league_table_element_new(Team *team);
gint gint
league_cup_get_index_from_clid(gint clid); league_cup_get_index_from_clid(gint clid);
League*
league_from_clid(gint clid);
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -65,7 +65,7 @@ void
live_game_event_send_off(gint team, gint player); live_game_event_send_off(gint team, gint player);
void void
live_game_generate_commentary(LiveGameUnit *unit); live_game_generate_commentary(LiveGameUnit *unit, gboolean show_unit);
void void
live_game_event_duel(void); live_game_event_duel(void);

View File

@ -141,6 +141,9 @@ typedef struct
like a substitution that doesn't count as a like a substitution that doesn't count as a
match time consuming event. @see #GameUnitTime */ match time consuming event. @see #GameUnitTime */
gint minute, time; gint minute, time;
/** The match result at the time of this unit. */
gint result[2];
/** The event belonging to the game unit. */ /** The event belonging to the game unit. */
LiveGameEvent event; LiveGameEvent event;
@ -165,9 +168,8 @@ typedef struct
gfloat home_advantage; gfloat home_advantage;
/** The array of units. @see #GameUnit */ /** The array of units. @see #GameUnit */
GArray *units; GArray *units;
/** Match statistics. @see #LiveGameStats */
LiveGameStats stats; LiveGameStats stats;
GtkWidget *window;
} LiveGame; } LiveGame;
#endif #endif

View File

@ -6,6 +6,7 @@
#include <time.h> #include <time.h>
/*d*/ /*d*/
#include "misc_callbacks.h"
#include "file.h" #include "file.h"
#include "free.h" #include "free.h"
#include "main.h" #include "main.h"
@ -22,17 +23,21 @@ main_init_variables(void)
country.name = country.symbol = country.sid = NULL; country.name = country.symbol = country.sid = NULL;
transfer_list = NULL; transfer_list = NULL;
player_names = 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)); window.main = window.startup = window.startup_users =
live_game.window = NULL; window.live = NULL;
live_game_temp.units = g_array_new(FALSE, FALSE, sizeof(LiveGameUnit));
live_game_temp.window = 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; 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 gint
main (gint argc, gchar *argv[]) main (gint argc, gchar *argv[])
{ {
gint x_pos, y_pos;
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE); textdomain (GETTEXT_PACKAGE);
#endif #endif
gtk_set_locale (); gtk_set_locale ();
gtk_init (&argc, &argv); 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 /** Exit the program with the given exit code and message. Try to

View File

@ -158,11 +158,11 @@ math_get_bye_len(gint number)
{ {
gint i; gint i;
for(i=10;i>=0;i--) for(i=0;i<20;i++)
if((gint)powf(2, i) <= number) if((gint)powf(2, i) >= number)
break; break;
return number - (gint)powf(2, i); return (gint)powf(2, i) - number;
} }
/** Return the sum of the integers in the array. /** 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. @param max The size of the array.
@return The sum of all the integers in the array. */ @return The sum of all the integers in the array. */
gint gint
math_sum_int_array(gint *array, gint max) math_sum_int_array(const gint *array, gint max)
{ {
gint i, sum = 0; gint i, sum = 0;

View File

@ -31,6 +31,6 @@ gint
math_get_bye_len(gint number); math_get_bye_len(gint number);
gint gint
math_sum_int_array(gint *array, gint max); math_sum_int_array(const gint *array, gint max);
#endif #endif

View File

@ -95,7 +95,6 @@ create_stadium_window (void)
label1 = gtk_label_new (_("Increase (seats)")); label1 = gtk_label_new (_("Increase (seats)"));
gtk_widget_show (label1); gtk_widget_show (label1);
gtk_box_pack_start (GTK_BOX (vbox2), label1, FALSE, FALSE, 0); 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 (); hseparator1 = gtk_hseparator_new ();
gtk_widget_show (hseparator1); gtk_widget_show (hseparator1);
@ -139,7 +138,6 @@ create_stadium_window (void)
label2 = gtk_label_new (_("Costs")); label2 = gtk_label_new (_("Costs"));
gtk_widget_show (label2); gtk_widget_show (label2);
gtk_box_pack_start (GTK_BOX (vbox3), label2, FALSE, FALSE, 0); 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 (); hseparator2 = gtk_hseparator_new ();
gtk_widget_show (hseparator2); gtk_widget_show (hseparator2);
@ -149,25 +147,21 @@ create_stadium_window (void)
label_cost0 = gtk_label_new (_("label4")); label_cost0 = gtk_label_new (_("label4"));
gtk_widget_show (label_cost0); gtk_widget_show (label_cost0);
gtk_box_pack_start (GTK_BOX (vbox3), label_cost0, FALSE, FALSE, 0); 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); gtk_misc_set_padding (GTK_MISC (label_cost0), 0, 4);
label_cost1 = gtk_label_new (_("label5")); label_cost1 = gtk_label_new (_("label5"));
gtk_widget_show (label_cost1); gtk_widget_show (label_cost1);
gtk_box_pack_start (GTK_BOX (vbox3), label_cost1, FALSE, FALSE, 0); 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); gtk_misc_set_padding (GTK_MISC (label_cost1), 0, 4);
label_cost2 = gtk_label_new (_("label6")); label_cost2 = gtk_label_new (_("label6"));
gtk_widget_show (label_cost2); gtk_widget_show (label_cost2);
gtk_box_pack_start (GTK_BOX (vbox3), label_cost2, FALSE, FALSE, 0); 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); gtk_misc_set_padding (GTK_MISC (label_cost2), 0, 4);
label_cost3 = gtk_label_new (_("label7")); label_cost3 = gtk_label_new (_("label7"));
gtk_widget_show (label_cost3); gtk_widget_show (label_cost3);
gtk_box_pack_start (GTK_BOX (vbox3), label_cost3, FALSE, FALSE, 0); 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); gtk_misc_set_padding (GTK_MISC (label_cost3), 0, 4);
vseparator2 = gtk_vseparator_new (); vseparator2 = gtk_vseparator_new ();
@ -182,7 +176,6 @@ create_stadium_window (void)
label3 = gtk_label_new (_("Finished (weeks)")); label3 = gtk_label_new (_("Finished (weeks)"));
gtk_widget_show (label3); gtk_widget_show (label3);
gtk_box_pack_start (GTK_BOX (vbox4), label3, FALSE, FALSE, 0); 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 (); hseparator3 = gtk_hseparator_new ();
gtk_widget_show (hseparator3); gtk_widget_show (hseparator3);
@ -192,25 +185,21 @@ create_stadium_window (void)
label8 = gtk_label_new (_("Before next match")); label8 = gtk_label_new (_("Before next match"));
gtk_widget_show (label8); gtk_widget_show (label8);
gtk_box_pack_start (GTK_BOX (vbox4), label8, FALSE, FALSE, 0); 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); gtk_misc_set_padding (GTK_MISC (label8), 0, 3);
label_finished0 = gtk_label_new (_("1-2")); label_finished0 = gtk_label_new (_("1-2"));
gtk_widget_show (label_finished0); gtk_widget_show (label_finished0);
gtk_box_pack_start (GTK_BOX (vbox4), label_finished0, FALSE, FALSE, 0); 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); gtk_misc_set_padding (GTK_MISC (label_finished0), 0, 3);
label_finished1 = gtk_label_new (_("3-4")); label_finished1 = gtk_label_new (_("3-4"));
gtk_widget_show (label_finished1); gtk_widget_show (label_finished1);
gtk_box_pack_start (GTK_BOX (vbox4), label_finished1, FALSE, FALSE, 0); 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); gtk_misc_set_padding (GTK_MISC (label_finished1), 0, 3);
label_finished2 = gtk_label_new (_("5-6")); label_finished2 = gtk_label_new (_("5-6"));
gtk_widget_show (label_finished2); gtk_widget_show (label_finished2);
gtk_box_pack_start (GTK_BOX (vbox4), label_finished2, FALSE, FALSE, 0); 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); gtk_misc_set_padding (GTK_MISC (label_finished2), 0, 3);
hseparator4 = gtk_hseparator_new (); hseparator4 = gtk_hseparator_new ();
@ -246,7 +235,6 @@ create_stadium_window (void)
label12 = gtk_label_new_with_mnemonic (_("OK")); label12 = gtk_label_new_with_mnemonic (_("OK"));
gtk_widget_show (label12); gtk_widget_show (label12);
gtk_box_pack_start (GTK_BOX (hbox3), label12, FALSE, FALSE, 0); 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 (); button_cancel = gtk_button_new ();
gtk_widget_show (button_cancel); gtk_widget_show (button_cancel);
@ -272,7 +260,6 @@ create_stadium_window (void)
label13 = gtk_label_new_with_mnemonic (_("Cancel")); label13 = gtk_label_new_with_mnemonic (_("Cancel"));
gtk_widget_show (label13); gtk_widget_show (label13);
gtk_box_pack_start (GTK_BOX (hbox4), label13, FALSE, FALSE, 0); 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_signal_connect ((gpointer) stadium_window, "delete_event",
G_CALLBACK (on_button_cancel_clicked), G_CALLBACK (on_button_cancel_clicked),
@ -384,7 +371,6 @@ create_job_offer_window (void)
label20 = gtk_label_new (_("label20")); label20 = gtk_label_new (_("label20"));
gtk_widget_show (label20); gtk_widget_show (label20);
gtk_box_pack_start (GTK_BOX (vbox5), label20, FALSE, FALSE, 0); 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 (); hseparator5 = gtk_hseparator_new ();
gtk_widget_show (hseparator5); gtk_widget_show (hseparator5);
@ -402,37 +388,31 @@ create_job_offer_window (void)
label15 = gtk_label_new (_("Name")); label15 = gtk_label_new (_("Name"));
gtk_widget_show (label15); gtk_widget_show (label15);
gtk_box_pack_start (GTK_BOX (vbox6), label15, FALSE, FALSE, 0); 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); gtk_misc_set_alignment (GTK_MISC (label15), 2.23517e-10, 0.5);
label16 = gtk_label_new (_("League")); label16 = gtk_label_new (_("League"));
gtk_widget_show (label16); gtk_widget_show (label16);
gtk_box_pack_start (GTK_BOX (vbox6), label16, FALSE, FALSE, 0); 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); gtk_misc_set_alignment (GTK_MISC (label16), 2.23517e-10, 0.5);
label17 = gtk_label_new (_("Rank")); label17 = gtk_label_new (_("Rank"));
gtk_widget_show (label17); gtk_widget_show (label17);
gtk_box_pack_start (GTK_BOX (vbox6), label17, FALSE, FALSE, 0); 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); gtk_misc_set_alignment (GTK_MISC (label17), 2.23517e-10, 0.5);
label18 = gtk_label_new (_("Money (approx.)")); label18 = gtk_label_new (_("Money (approx.)"));
gtk_widget_show (label18); gtk_widget_show (label18);
gtk_box_pack_start (GTK_BOX (vbox6), label18, FALSE, FALSE, 0); 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); gtk_misc_set_alignment (GTK_MISC (label18), 2.23517e-10, 0.5);
label19 = gtk_label_new (_("Stadium capacity")); label19 = gtk_label_new (_("Stadium capacity"));
gtk_widget_show (label19); gtk_widget_show (label19);
gtk_box_pack_start (GTK_BOX (vbox6), label19, FALSE, FALSE, 0); 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); gtk_misc_set_alignment (GTK_MISC (label19), 2.23517e-10, 0.5);
label14 = gtk_label_new (_("Stadium safety")); label14 = gtk_label_new (_("Stadium safety"));
gtk_widget_show (label14); gtk_widget_show (label14);
gtk_box_pack_start (GTK_BOX (vbox6), label14, FALSE, FALSE, 0); 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); gtk_misc_set_alignment (GTK_MISC (label14), 0, 0.5);
vseparator3 = gtk_vseparator_new (); vseparator3 = gtk_vseparator_new ();
@ -447,32 +427,26 @@ create_job_offer_window (void)
label21 = gtk_label_new (_("label21")); label21 = gtk_label_new (_("label21"));
gtk_widget_show (label21); gtk_widget_show (label21);
gtk_box_pack_start (GTK_BOX (vbox7), label21, FALSE, FALSE, 0); 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")); label22 = gtk_label_new (_("label22"));
gtk_widget_show (label22); gtk_widget_show (label22);
gtk_box_pack_start (GTK_BOX (vbox7), label22, FALSE, FALSE, 0); 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")); label23 = gtk_label_new (_("label23"));
gtk_widget_show (label23); gtk_widget_show (label23);
gtk_box_pack_start (GTK_BOX (vbox7), label23, FALSE, FALSE, 0); 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")); label24 = gtk_label_new (_("label24"));
gtk_widget_show (label24); gtk_widget_show (label24);
gtk_box_pack_start (GTK_BOX (vbox7), label24, FALSE, FALSE, 0); 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")); label25 = gtk_label_new (_("label25"));
gtk_widget_show (label25); gtk_widget_show (label25);
gtk_box_pack_start (GTK_BOX (vbox7), label25, FALSE, FALSE, 0); 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")); label26 = gtk_label_new (_("label26"));
gtk_widget_show (label26); gtk_widget_show (label26);
gtk_box_pack_start (GTK_BOX (vbox7), label26, FALSE, FALSE, 0); 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 (); hseparator6 = gtk_hseparator_new ();
gtk_widget_show (hseparator6); gtk_widget_show (hseparator6);
@ -482,7 +456,6 @@ create_job_offer_window (void)
label28 = gtk_label_new (_("Player list")); label28 = gtk_label_new (_("Player list"));
gtk_widget_show (label28); gtk_widget_show (label28);
gtk_box_pack_start (GTK_BOX (vbox5), label28, FALSE, FALSE, 0); 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); scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_show (scrolledwindow1); gtk_widget_show (scrolledwindow1);
@ -501,7 +474,6 @@ create_job_offer_window (void)
label27 = gtk_label_new (_("label27")); label27 = gtk_label_new (_("label27"));
gtk_widget_show (label27); gtk_widget_show (label27);
gtk_box_pack_start (GTK_BOX (vbox5), label27, FALSE, FALSE, 0); 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); gtk_misc_set_padding (GTK_MISC (label27), 0, 5);
hbox6 = gtk_hbox_new (FALSE, 0); hbox6 = gtk_hbox_new (FALSE, 0);
@ -528,7 +500,6 @@ create_job_offer_window (void)
label31 = gtk_label_new_with_mnemonic (_("OK")); label31 = gtk_label_new_with_mnemonic (_("OK"));
gtk_widget_show (label31); gtk_widget_show (label31);
gtk_box_pack_start (GTK_BOX (hbox9), label31, FALSE, FALSE, 0); 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 (); button_cancel = gtk_button_new ();
gtk_widget_show (button_cancel); gtk_widget_show (button_cancel);
@ -550,7 +521,6 @@ create_job_offer_window (void)
label30 = gtk_label_new_with_mnemonic (_("Cancel")); label30 = gtk_label_new_with_mnemonic (_("Cancel"));
gtk_widget_show (label30); gtk_widget_show (label30);
gtk_box_pack_start (GTK_BOX (hbox8), label30, FALSE, FALSE, 0); 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_signal_connect ((gpointer) button_ok, "clicked",
G_CALLBACK (on_button_offer_ok_clicked), G_CALLBACK (on_button_offer_ok_clicked),
@ -666,7 +636,6 @@ create_graph_window (void)
label_title = gtk_label_new (_("Statistics")); label_title = gtk_label_new (_("Statistics"));
gtk_widget_show (label_title); gtk_widget_show (label_title);
gtk_box_pack_start (GTK_BOX (vbox8), label_title, FALSE, FALSE, 0); 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); vbox9 = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox9); gtk_widget_show (vbox9);
@ -687,32 +656,26 @@ create_graph_window (void)
label36 = gtk_label_new (_("label36")); label36 = gtk_label_new (_("label36"));
gtk_widget_show (label36); gtk_widget_show (label36);
gtk_box_pack_start (GTK_BOX (vbox10), label36, FALSE, FALSE, 0); 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")); label37 = gtk_label_new (_("label37"));
gtk_widget_show (label37); gtk_widget_show (label37);
gtk_box_pack_start (GTK_BOX (vbox10), label37, FALSE, FALSE, 0); 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")); label38 = gtk_label_new (_("label38"));
gtk_widget_show (label38); gtk_widget_show (label38);
gtk_box_pack_start (GTK_BOX (vbox10), label38, FALSE, FALSE, 0); 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")); label39 = gtk_label_new (_("label39"));
gtk_widget_show (label39); gtk_widget_show (label39);
gtk_box_pack_start (GTK_BOX (vbox10), label39, FALSE, FALSE, 0); 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")); label40 = gtk_label_new (_("label40"));
gtk_widget_show (label40); gtk_widget_show (label40);
gtk_box_pack_start (GTK_BOX (vbox10), label40, FALSE, FALSE, 0); 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 (""); label41 = gtk_label_new ("");
gtk_widget_show (label41); gtk_widget_show (label41);
gtk_box_pack_start (GTK_BOX (vbox12), label41, FALSE, FALSE, 0); 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); vbox11 = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox11); gtk_widget_show (vbox11);
@ -736,7 +699,6 @@ create_graph_window (void)
label33 = gtk_label_new (_("Weeks / Seasons")); label33 = gtk_label_new (_("Weeks / Seasons"));
gtk_widget_show (label33); gtk_widget_show (label33);
gtk_box_pack_start (GTK_BOX (vbox9), label33, FALSE, FALSE, 0); 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 (); hseparator8 = gtk_hseparator_new ();
gtk_widget_show (hseparator8); gtk_widget_show (hseparator8);
@ -842,7 +804,6 @@ create_graph_window (void)
label35 = gtk_label_new_with_mnemonic (_("Close")); label35 = gtk_label_new_with_mnemonic (_("Close"));
gtk_widget_show (label35); gtk_widget_show (label35);
gtk_box_pack_start (GTK_BOX (hbox14), label35, FALSE, FALSE, 0); 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_signal_connect ((gpointer) graph_window, "delete_event",
G_CALLBACK (on_graph_window_delete_event), G_CALLBACK (on_graph_window_delete_event),

View File

@ -1,3 +1,4 @@
#include "game_gui.h"
#include "misc_callback_func.h" #include "misc_callback_func.h"
#include "start_end.h" #include "start_end.h"
#include "support.h" #include "support.h"
@ -19,7 +20,7 @@ misc_callback_show_team_list(GtkWidget *widget, const gchar *country_file)
xml_country_read(country_file); xml_country_read(country_file);
treeview_show_team_list(GTK_TREE_VIEW(treeview_startup), FALSE); treeview_show_team_list(GTK_TREE_VIEW(treeview_startup), FALSE, FALSE);
/*d*/ /*d*/
/* for(i=0;i<cps->len;i++) */ /* for(i=0;i<cps->len;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. /** Start a new game after users and teams are selected. */
@param widget A widget from the startup window that enables us
to get the row in the team list the user has selected. */
void void
misc_callback_start_game(GtkWidget *widget) misc_callback_start_game(void)
{ {
GtkTreeView *treeview = gint i;
GTK_TREE_VIEW(lookup_widget(widget, "treeview_startup"));
GtkWidget *window_startup = stat0 = STATUS_MAIN;
lookup_widget(widget, "window_startup");
my_team = treeview_get_pointer(treeview, 2);
start_new_game(); start_new_game();
user_set_up_my_team_new_game(widget); for(i=0;i<users->len;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;
} }

View File

@ -4,9 +4,18 @@
#include "bygfoot.h" #include "bygfoot.h"
void void
misc_callback_start_game(GtkWidget *widget); misc_callback_start_game(void);
void void
misc_callback_show_team_list(GtkWidget *widget, const gchar *country_file); 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 #endif

View File

@ -1,12 +1,39 @@
#include <string.h> #include <string.h>
#include "callback_func.h"
#include "free.h" #include "free.h"
#include "game_gui.h"
#include "live_game.h"
#include "misc_callback_func.h" #include "misc_callback_func.h"
#include "misc_callbacks.h" #include "misc_callbacks.h"
#include "option.h"
#include "user.h"
#include "variables.h" #include "variables.h"
#include "window.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 void
on_team_selection_cancel_clicked (GtkButton *button, on_team_selection_cancel_clicked (GtkButton *button,
gpointer user_data) gpointer user_data)
@ -22,7 +49,8 @@ on_team_selection_tv_row_activated (GtkTreeView *treeview,
GtkTreeViewColumn *column, GtkTreeViewColumn *column,
gpointer user_data) 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 void
on_team_selection_load_clicked (GtkButton *button, on_team_selection_load_clicked (GtkButton *button,
gpointer user_data) gpointer user_data)
@ -192,7 +210,7 @@ void
on_button_live_close_clicked (GtkButton *button, on_button_live_close_clicked (GtkButton *button,
gpointer user_data) gpointer user_data)
{ {
window_destroy(&live_game.window); callback_show_next_live_game();
} }
@ -222,7 +240,7 @@ void
on_button_pause_clicked (GtkButton *button, on_button_pause_clicked (GtkButton *button,
gpointer user_data) gpointer user_data)
{ {
misc_callback_pause_live_game();
} }
@ -230,14 +248,29 @@ void
on_button_resume_clicked (GtkButton *button, on_button_resume_clicked (GtkButton *button,
gpointer user_data) 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 void
on_spinbutton_speed_value_changed (GtkSpinButton *spinbutton, on_spinbutton_speed_value_changed (GtkSpinButton *spinbutton,
gpointer user_data) gpointer user_data)
{ {
options[OPT_LIVE_SPEED] = option_set_int("int_opt_user_live_game_speed",
gtk_spin_button_get_value_as_int(spinbutton); 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;
}

View File

@ -115,8 +115,22 @@ void
on_button_resume_clicked (GtkButton *button, on_button_resume_clicked (GtkButton *button,
gpointer user_data); gpointer user_data);
#endif
void void
on_spinbutton_speed_value_changed (GtkSpinButton *spinbutton, on_spinbutton_speed_value_changed (GtkSpinButton *spinbutton,
gpointer user_data); 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);

View File

@ -34,14 +34,6 @@ create_window_startup (void)
GtkWidget *scrolledwindow1; GtkWidget *scrolledwindow1;
GtkWidget *treeview_startup; GtkWidget *treeview_startup;
GtkWidget *hseparator10; 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 *vbox34;
GtkWidget *label69; GtkWidget *label69;
GtkWidget *hbox44; GtkWidget *hbox44;
@ -53,24 +45,30 @@ create_window_startup (void)
GtkWidget *hbox45; GtkWidget *hbox45;
GtkWidget *image45; GtkWidget *image45;
GtkWidget *label70; 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 *hseparator12;
GtkWidget *hbox46; GtkWidget *hbox54;
GtkWidget *vbox35; GtkWidget *label75;
GtkWidget *checkbutton_no_def; GtkWidget *entry_player_name;
GtkWidget *checkbutton_only_names; GtkWidget *button_add_player;
GtkWidget *checkbutton_load_my_team; GtkWidget *alignment19;
GtkWidget *vseparator18; GtkWidget *hbox55;
GtkWidget *button_start_editor; GtkWidget *image59;
GtkWidget *alignment15; GtkWidget *label76;
GtkWidget *hbox47; GtkWidget *hseparator13;
GtkWidget *image55;
GtkWidget *label71;
GtkWidget *hbox3; GtkWidget *hbox3;
GtkWidget *team_selection_ok; GtkWidget *team_selection_ok;
GtkWidget *alignment1; GtkWidget *alignment18;
GtkWidget *hbox4; GtkWidget *hbox53;
GtkWidget *image2; GtkWidget *image58;
GtkWidget *label1; GtkWidget *label74;
GtkWidget *team_selection_cancel; GtkWidget *team_selection_cancel;
GtkWidget *alignment2; GtkWidget *alignment2;
GtkWidget *hbox5; GtkWidget *hbox5;
@ -116,47 +114,6 @@ create_window_startup (void)
gtk_box_pack_start (GTK_BOX (vbox2), hseparator10, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox2), hseparator10, FALSE, FALSE, 0);
gtk_widget_set_size_request (hseparator10, 1, 10); 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); vbox34 = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox34); gtk_widget_show (vbox34);
gtk_box_pack_start (GTK_BOX (vbox2), vbox34, FALSE, TRUE, 5); gtk_box_pack_start (GTK_BOX (vbox2), vbox34, FALSE, TRUE, 5);
@ -206,64 +163,90 @@ create_window_startup (void)
gtk_widget_show (label70); gtk_widget_show (label70);
gtk_box_pack_start (GTK_BOX (hbox45), label70, FALSE, FALSE, 0); 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 (); hseparator12 = gtk_hseparator_new ();
gtk_widget_show (hseparator12); gtk_widget_show (hseparator12);
gtk_box_pack_start (GTK_BOX (vbox2), hseparator12, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox2), hseparator12, FALSE, FALSE, 0);
gtk_widget_set_size_request (hseparator12, 1, 10); gtk_widget_set_size_request (hseparator12, 1, 10);
hbox46 = gtk_hbox_new (FALSE, 0); hbox54 = gtk_hbox_new (FALSE, 5);
gtk_widget_show (hbox46); gtk_widget_show (hbox54);
gtk_box_pack_start (GTK_BOX (vbox2), hbox46, FALSE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox2), hbox54, FALSE, TRUE, 0);
vbox35 = gtk_vbox_new (FALSE, 0); label75 = gtk_label_new (_("Player name"));
gtk_widget_show (vbox35); gtk_widget_show (label75);
gtk_box_pack_start (GTK_BOX (hbox46), vbox35, FALSE, TRUE, 0); 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")); entry_player_name = gtk_entry_new ();
gtk_widget_show (checkbutton_no_def); gtk_widget_show (entry_player_name);
gtk_box_pack_start (GTK_BOX (vbox35), checkbutton_no_def, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox54), entry_player_name, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (checkbutton_no_def), 2); gtk_entry_set_max_length (GTK_ENTRY (entry_player_name), 12);
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); 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")); button_add_player = gtk_button_new ();
gtk_widget_show (checkbutton_only_names); gtk_widget_show (button_add_player);
gtk_box_pack_start (GTK_BOX (vbox35), checkbutton_only_names, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox54), button_add_player, 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);
checkbutton_load_my_team = gtk_check_button_new_with_mnemonic (_("Load my team from definitions file")); alignment19 = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_widget_show (checkbutton_load_my_team); gtk_widget_show (alignment19);
gtk_box_pack_start (GTK_BOX (vbox35), checkbutton_load_my_team, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (button_add_player), alignment19);
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);
vseparator18 = gtk_vseparator_new (); hbox55 = gtk_hbox_new (FALSE, 2);
gtk_widget_show (vseparator18); gtk_widget_show (hbox55);
gtk_box_pack_start (GTK_BOX (hbox46), vseparator18, FALSE, TRUE, 0); gtk_container_add (GTK_CONTAINER (alignment19), hbox55);
gtk_widget_set_size_request (vseparator18, 10, 1);
button_start_editor = gtk_button_new (); image59 = gtk_image_new_from_stock ("gtk-add", GTK_ICON_SIZE_BUTTON);
gtk_widget_show (button_start_editor); gtk_widget_show (image59);
gtk_box_pack_start (GTK_BOX (hbox46), button_start_editor, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox55), image59, FALSE, FALSE, 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);
alignment15 = gtk_alignment_new (0.5, 0.5, 0, 0); label76 = gtk_label_new_with_mnemonic (_("Add player"));
gtk_widget_show (alignment15); gtk_widget_show (label76);
gtk_container_add (GTK_CONTAINER (button_start_editor), alignment15); gtk_box_pack_start (GTK_BOX (hbox55), label76, FALSE, FALSE, 0);
hbox47 = gtk_hbox_new (FALSE, 2); hseparator13 = gtk_hseparator_new ();
gtk_widget_show (hbox47); gtk_widget_show (hseparator13);
gtk_container_add (GTK_CONTAINER (alignment15), hbox47); gtk_box_pack_start (GTK_BOX (vbox2), hseparator13, FALSE, TRUE, 0);
gtk_widget_set_size_request (hseparator13, 1, 10);
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);
hbox3 = gtk_hbox_new (FALSE, 0); hbox3 = gtk_hbox_new (FALSE, 0);
gtk_widget_show (hbox3); gtk_widget_show (hbox3);
@ -273,26 +256,27 @@ create_window_startup (void)
gtk_widget_show (team_selection_ok); gtk_widget_show (team_selection_ok);
gtk_box_pack_start (GTK_BOX (hbox3), team_selection_ok, TRUE, TRUE, 0); 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_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, gtk_widget_add_accelerator (team_selection_ok, "clicked", accel_group,
GDK_Return, 0, GDK_space, 0,
GTK_ACCEL_VISIBLE); GTK_ACCEL_VISIBLE);
alignment1 = gtk_alignment_new (0.5, 0.5, 0, 0); alignment18 = gtk_alignment_new (0.5, 0.5, 0, 0);
gtk_widget_show (alignment1); gtk_widget_show (alignment18);
gtk_container_add (GTK_CONTAINER (team_selection_ok), alignment1); gtk_container_add (GTK_CONTAINER (team_selection_ok), alignment18);
hbox4 = gtk_hbox_new (FALSE, 2); hbox53 = gtk_hbox_new (FALSE, 2);
gtk_widget_show (hbox4); gtk_widget_show (hbox53);
gtk_container_add (GTK_CONTAINER (alignment1), hbox4); gtk_container_add (GTK_CONTAINER (alignment18), hbox53);
image2 = gtk_image_new_from_stock ("gtk-apply", GTK_ICON_SIZE_BUTTON); image58 = gtk_image_new_from_stock ("gtk-apply", GTK_ICON_SIZE_BUTTON);
gtk_widget_show (image2); gtk_widget_show (image58);
gtk_box_pack_start (GTK_BOX (hbox4), image2, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox53), image58, FALSE, FALSE, 0);
label1 = gtk_label_new_with_mnemonic (_("OK")); label74 = gtk_label_new_with_mnemonic (_("Start"));
gtk_widget_show (label1); gtk_widget_show (label74);
gtk_box_pack_start (GTK_BOX (hbox4), label1, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox53), label74, FALSE, FALSE, 0);
team_selection_cancel = gtk_button_new (); team_selection_cancel = gtk_button_new ();
gtk_widget_show (team_selection_cancel); gtk_widget_show (team_selection_cancel);
@ -356,14 +340,11 @@ create_window_startup (void)
g_signal_connect ((gpointer) button_select_country_file, "clicked", g_signal_connect ((gpointer) button_select_country_file, "clicked",
G_CALLBACK (on_button_select_country_file_clicked), G_CALLBACK (on_button_select_country_file_clicked),
NULL); NULL);
g_signal_connect ((gpointer) checkbutton_no_def, "toggled", g_signal_connect ((gpointer) entry_player_name, "activate",
G_CALLBACK (on_checkbutton_load_randomly_toggled), G_CALLBACK (on_entry_player_name_activate),
NULL); NULL);
g_signal_connect ((gpointer) checkbutton_only_names, "toggled", g_signal_connect ((gpointer) button_add_player, "clicked",
G_CALLBACK (on_checkbutton_only_names_toggled), G_CALLBACK (on_button_add_player_clicked),
NULL);
g_signal_connect ((gpointer) button_start_editor, "clicked",
G_CALLBACK (on_button_start_editor_clicked),
NULL); NULL);
g_signal_connect ((gpointer) team_selection_ok, "clicked", g_signal_connect ((gpointer) team_selection_ok, "clicked",
G_CALLBACK (on_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, scrolledwindow1, "scrolledwindow1");
GLADE_HOOKUP_OBJECT (window_startup, treeview_startup, "treeview_startup"); GLADE_HOOKUP_OBJECT (window_startup, treeview_startup, "treeview_startup");
GLADE_HOOKUP_OBJECT (window_startup, hseparator10, "hseparator10"); 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, vbox34, "vbox34");
GLADE_HOOKUP_OBJECT (window_startup, label69, "label69"); GLADE_HOOKUP_OBJECT (window_startup, label69, "label69");
GLADE_HOOKUP_OBJECT (window_startup, hbox44, "hbox44"); 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, hbox45, "hbox45");
GLADE_HOOKUP_OBJECT (window_startup, image45, "image45"); GLADE_HOOKUP_OBJECT (window_startup, image45, "image45");
GLADE_HOOKUP_OBJECT (window_startup, label70, "label70"); 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, hseparator12, "hseparator12");
GLADE_HOOKUP_OBJECT (window_startup, hbox46, "hbox46"); GLADE_HOOKUP_OBJECT (window_startup, hbox54, "hbox54");
GLADE_HOOKUP_OBJECT (window_startup, vbox35, "vbox35"); GLADE_HOOKUP_OBJECT (window_startup, label75, "label75");
GLADE_HOOKUP_OBJECT (window_startup, checkbutton_no_def, "checkbutton_no_def"); GLADE_HOOKUP_OBJECT (window_startup, entry_player_name, "entry_player_name");
GLADE_HOOKUP_OBJECT (window_startup, checkbutton_only_names, "checkbutton_only_names"); GLADE_HOOKUP_OBJECT (window_startup, button_add_player, "button_add_player");
GLADE_HOOKUP_OBJECT (window_startup, checkbutton_load_my_team, "checkbutton_load_my_team"); GLADE_HOOKUP_OBJECT (window_startup, alignment19, "alignment19");
GLADE_HOOKUP_OBJECT (window_startup, vseparator18, "vseparator18"); GLADE_HOOKUP_OBJECT (window_startup, hbox55, "hbox55");
GLADE_HOOKUP_OBJECT (window_startup, button_start_editor, "button_start_editor"); GLADE_HOOKUP_OBJECT (window_startup, image59, "image59");
GLADE_HOOKUP_OBJECT (window_startup, alignment15, "alignment15"); GLADE_HOOKUP_OBJECT (window_startup, label76, "label76");
GLADE_HOOKUP_OBJECT (window_startup, hbox47, "hbox47"); GLADE_HOOKUP_OBJECT (window_startup, hseparator13, "hseparator13");
GLADE_HOOKUP_OBJECT (window_startup, image55, "image55");
GLADE_HOOKUP_OBJECT (window_startup, label71, "label71");
GLADE_HOOKUP_OBJECT (window_startup, hbox3, "hbox3"); GLADE_HOOKUP_OBJECT (window_startup, hbox3, "hbox3");
GLADE_HOOKUP_OBJECT (window_startup, team_selection_ok, "team_selection_ok"); GLADE_HOOKUP_OBJECT (window_startup, team_selection_ok, "team_selection_ok");
GLADE_HOOKUP_OBJECT (window_startup, alignment1, "alignment1"); GLADE_HOOKUP_OBJECT (window_startup, alignment18, "alignment18");
GLADE_HOOKUP_OBJECT (window_startup, hbox4, "hbox4"); GLADE_HOOKUP_OBJECT (window_startup, hbox53, "hbox53");
GLADE_HOOKUP_OBJECT (window_startup, image2, "image2"); GLADE_HOOKUP_OBJECT (window_startup, image58, "image58");
GLADE_HOOKUP_OBJECT (window_startup, label1, "label1"); GLADE_HOOKUP_OBJECT (window_startup, label74, "label74");
GLADE_HOOKUP_OBJECT (window_startup, team_selection_cancel, "team_selection_cancel"); GLADE_HOOKUP_OBJECT (window_startup, team_selection_cancel, "team_selection_cancel");
GLADE_HOOKUP_OBJECT (window_startup, alignment2, "alignment2"); GLADE_HOOKUP_OBJECT (window_startup, alignment2, "alignment2");
GLADE_HOOKUP_OBJECT (window_startup, hbox5, "hbox5"); GLADE_HOOKUP_OBJECT (window_startup, hbox5, "hbox5");
@ -1073,3 +1052,40 @@ create_help_window (void)
return help_window; 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;
}

View File

@ -8,3 +8,4 @@ GtkWidget* create_fsel_window (void);
GtkWidget* create_font_sel_window (void); GtkWidget* create_font_sel_window (void);
GtkWidget* create_window_live (void); GtkWidget* create_window_live (void);
GtkWidget* create_help_window (void); GtkWidget* create_help_window (void);
GtkWidget* create_window_startup_users (void);

View File

@ -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;i<option_array->len;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;i<option_array->len;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;i<option_array->len;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;i<option_array->len;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;i<option_array->len;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);
}

View File

@ -1,6 +1,45 @@
#ifndef OPTION_H #ifndef OPTION_H
#define OPTION_H #define OPTION_H
#include <math.h>
#include "bygfoot.h" #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 #endif

View File

@ -306,7 +306,6 @@ create_opt_window (void)
label53 = gtk_label_new (_("At the beginning of a new week show first")); label53 = gtk_label_new (_("At the beginning of a new week show first"));
gtk_widget_show (label53); gtk_widget_show (label53);
gtk_box_pack_start (GTK_BOX (vbox32), label53, FALSE, FALSE, 0); 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); gtk_misc_set_alignment (GTK_MISC (label53), 0, 0.5);
hbox66 = gtk_hbox_new (FALSE, 0); hbox66 = gtk_hbox_new (FALSE, 0);
@ -344,7 +343,6 @@ create_opt_window (void)
label43 = gtk_label_new (_(" Live game duration factor ")); label43 = gtk_label_new (_(" Live game duration factor "));
gtk_widget_show (label43); gtk_widget_show (label43);
gtk_box_pack_start (GTK_BOX (hbox21), label43, FALSE, FALSE, 0); 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_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); 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 (_(" ")); label58 = gtk_label_new (_(" "));
gtk_widget_show (label58); gtk_widget_show (label58);
gtk_box_pack_start (GTK_BOX (hbox39), label58, FALSE, FALSE, 0); 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")); check_live_tendency = gtk_check_button_new_with_mnemonic (_("Show live game tendency bar"));
gtk_widget_show (check_live_tendency); gtk_widget_show (check_live_tendency);
@ -393,12 +390,10 @@ create_opt_window (void)
label55 = gtk_label_new_with_mnemonic (_("Change font")); label55 = gtk_label_new_with_mnemonic (_("Change font"));
gtk_widget_show (label55); gtk_widget_show (label55);
gtk_box_pack_start (GTK_BOX (hbox35), label55, FALSE, FALSE, 0); 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")); label54 = gtk_label_new (_(" used in the main windows"));
gtk_widget_show (label54); gtk_widget_show (label54);
gtk_box_pack_start (GTK_BOX (hbox34), label54, FALSE, FALSE, 0); 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); hbox46 = gtk_hbox_new (FALSE, 0);
gtk_widget_show (hbox46); gtk_widget_show (hbox46);
@ -407,7 +402,6 @@ create_opt_window (void)
label71 = gtk_label_new (_("Change team name ")); label71 = gtk_label_new (_("Change team name "));
gtk_widget_show (label71); gtk_widget_show (label71);
gtk_box_pack_start (GTK_BOX (hbox46), label71, FALSE, FALSE, 0); 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 (); entry_team_name = gtk_entry_new ();
gtk_widget_show (entry_team_name); gtk_widget_show (entry_team_name);
@ -436,7 +430,6 @@ create_opt_window (void)
label45 = gtk_label_new (_("Messages")); label45 = gtk_label_new (_("Messages"));
gtk_widget_show (label45); gtk_widget_show (label45);
gtk_box_pack_start (GTK_BOX (hbox22), label45, FALSE, FALSE, 0); 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")); radio_mess1 = gtk_radio_button_new_with_mnemonic (NULL, _("Moving"));
gtk_widget_show (radio_mess1); gtk_widget_show (radio_mess1);
@ -495,12 +488,10 @@ create_opt_window (void)
label89 = gtk_label_new (_("Apperance and behaviour of the game")); label89 = gtk_label_new (_("Apperance and behaviour of the game"));
gtk_widget_show (label89); gtk_widget_show (label89);
gtk_frame_set_label_widget (GTK_FRAME (frame1), 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")); label83 = gtk_label_new (_("Look & Feel"));
gtk_widget_show (label83); gtk_widget_show (label83);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 0), 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); frame2 = gtk_frame_new (NULL);
gtk_widget_show (frame2); gtk_widget_show (frame2);
@ -534,17 +525,14 @@ create_opt_window (void)
label82 = gtk_label_new (_(" weeks")); label82 = gtk_label_new (_(" weeks"));
gtk_widget_show (label82); gtk_widget_show (label82);
gtk_box_pack_start (GTK_BOX (hbox62), label82, FALSE, FALSE, 0); 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")); label90 = gtk_label_new (_("Options for loading and saving games"));
gtk_widget_show (label90); gtk_widget_show (label90);
gtk_frame_set_label_widget (GTK_FRAME (frame2), 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")); label84 = gtk_label_new (_("Load & Save"));
gtk_widget_show (label84); gtk_widget_show (label84);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 1), 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); frame3 = gtk_frame_new (NULL);
gtk_widget_show (frame3); gtk_widget_show (frame3);
@ -675,7 +663,6 @@ create_opt_window (void)
label78 = gtk_label_new (""); label78 = gtk_label_new ("");
gtk_widget_show (label78); gtk_widget_show (label78);
gtk_box_pack_start (GTK_BOX (vbox28), label78, FALSE, FALSE, 0); 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); gtk_misc_set_padding (GTK_MISC (label78), 0, 4);
vbox29 = gtk_vbox_new (FALSE, 2); vbox29 = gtk_vbox_new (FALSE, 2);
@ -727,25 +714,21 @@ create_opt_window (void)
label73 = gtk_label_new (_(" and ")); label73 = gtk_label_new (_(" and "));
gtk_widget_show (label73); gtk_widget_show (label73);
gtk_box_pack_start (GTK_BOX (vbox30), label73, FALSE, FALSE, 0); 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); gtk_misc_set_padding (GTK_MISC (label73), 0, 4);
label74 = gtk_label_new (_(" and ")); label74 = gtk_label_new (_(" and "));
gtk_widget_show (label74); gtk_widget_show (label74);
gtk_box_pack_start (GTK_BOX (vbox30), label74, FALSE, FALSE, 0); 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); gtk_misc_set_padding (GTK_MISC (label74), 0, 4);
label75 = gtk_label_new (_(" and ")); label75 = gtk_label_new (_(" and "));
gtk_widget_show (label75); gtk_widget_show (label75);
gtk_box_pack_start (GTK_BOX (vbox30), label75, FALSE, FALSE, 0); 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); gtk_misc_set_padding (GTK_MISC (label75), 0, 4);
label76 = gtk_label_new (""); label76 = gtk_label_new ("");
gtk_widget_show (label76); gtk_widget_show (label76);
gtk_box_pack_start (GTK_BOX (vbox30), label76, FALSE, FALSE, 0); 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); gtk_misc_set_padding (GTK_MISC (label76), 0, 4);
hbox54 = gtk_hbox_new (FALSE, 0); hbox54 = gtk_hbox_new (FALSE, 0);
@ -797,7 +780,6 @@ create_opt_window (void)
label77 = gtk_label_new (""); label77 = gtk_label_new ("");
gtk_widget_show (label77); gtk_widget_show (label77);
gtk_box_pack_start (GTK_BOX (vboxa31), label77, FALSE, FALSE, 0); 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); gtk_misc_set_padding (GTK_MISC (label77), 0, 4);
hbox53 = gtk_hbox_new (FALSE, 0); hbox53 = gtk_hbox_new (FALSE, 0);
@ -822,17 +804,14 @@ create_opt_window (void)
label95 = gtk_label_new (""); label95 = gtk_label_new ("");
gtk_widget_show (label95); gtk_widget_show (label95);
gtk_frame_set_label_widget (GTK_FRAME (frame7), 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")); label91 = gtk_label_new (_("Options concering the transfer list"));
gtk_widget_show (label91); gtk_widget_show (label91);
gtk_frame_set_label_widget (GTK_FRAME (frame3), 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")); label85 = gtk_label_new (_("Transfers"));
gtk_widget_show (label85); gtk_widget_show (label85);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 2), 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); frame4 = gtk_frame_new (NULL);
gtk_widget_show (frame4); gtk_widget_show (frame4);
@ -864,12 +843,10 @@ create_opt_window (void)
label92 = gtk_label_new (_("Whether to confirm certain actions")); label92 = gtk_label_new (_("Whether to confirm certain actions"));
gtk_widget_show (label92); gtk_widget_show (label92);
gtk_frame_set_label_widget (GTK_FRAME (frame4), 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")); label86 = gtk_label_new (_("Confirmations"));
gtk_widget_show (label86); gtk_widget_show (label86);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 3), 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); frame5 = gtk_frame_new (NULL);
gtk_widget_show (frame5); gtk_widget_show (frame5);
@ -891,7 +868,6 @@ create_opt_window (void)
label98 = gtk_label_new (_("Attribute")); label98 = gtk_label_new (_("Attribute"));
gtk_widget_show (label98); gtk_widget_show (label98);
gtk_box_pack_start (GTK_BOX (vbox42), label98, FALSE, FALSE, 0); 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); gtk_misc_set_alignment (GTK_MISC (label98), 1.11759e-08, 0.5);
hseparator12 = gtk_hseparator_new (); hseparator12 = gtk_hseparator_new ();
@ -902,97 +878,81 @@ create_opt_window (void)
label109 = gtk_label_new (_("Name")); label109 = gtk_label_new (_("Name"));
gtk_widget_show (label109); gtk_widget_show (label109);
gtk_box_pack_start (GTK_BOX (vbox42), label109, FALSE, FALSE, 0); 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); gtk_misc_set_alignment (GTK_MISC (label109), 0, 0.5);
label110 = gtk_label_new (_("Current position")); label110 = gtk_label_new (_("Current position"));
gtk_widget_show (label110); gtk_widget_show (label110);
gtk_box_pack_start (GTK_BOX (vbox42), label110, FALSE, FALSE, 0); 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); gtk_misc_set_alignment (GTK_MISC (label110), 0, 0.5);
label111 = gtk_label_new (_("Position")); label111 = gtk_label_new (_("Position"));
gtk_widget_show (label111); gtk_widget_show (label111);
gtk_box_pack_start (GTK_BOX (vbox42), label111, FALSE, FALSE, 0); 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); gtk_misc_set_alignment (GTK_MISC (label111), 0, 0.5);
label112 = gtk_label_new (_("Current skill")); label112 = gtk_label_new (_("Current skill"));
gtk_widget_show (label112); gtk_widget_show (label112);
gtk_box_pack_start (GTK_BOX (vbox42), label112, FALSE, FALSE, 0); 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); gtk_misc_set_alignment (GTK_MISC (label112), 0, 0.5);
label99 = gtk_label_new (_("Skill")); label99 = gtk_label_new (_("Skill"));
gtk_widget_show (label99); gtk_widget_show (label99);
gtk_box_pack_start (GTK_BOX (vbox42), label99, FALSE, FALSE, 0); 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); gtk_misc_set_alignment (GTK_MISC (label99), 0, 0.5);
label100 = gtk_label_new (_("Fitness")); label100 = gtk_label_new (_("Fitness"));
gtk_widget_show (label100); gtk_widget_show (label100);
gtk_box_pack_start (GTK_BOX (vbox42), label100, FALSE, FALSE, 0); 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); gtk_misc_set_alignment (GTK_MISC (label100), 0, 0.5);
label101 = gtk_label_new (_("Games")); label101 = gtk_label_new (_("Games"));
gtk_widget_show (label101); gtk_widget_show (label101);
gtk_box_pack_start (GTK_BOX (vbox42), label101, FALSE, FALSE, 0); 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); gtk_misc_set_alignment (GTK_MISC (label101), 0, 0.5);
label102 = gtk_label_new (_("Goals")); label102 = gtk_label_new (_("Goals"));
gtk_widget_show (label102); gtk_widget_show (label102);
gtk_box_pack_start (GTK_BOX (vbox42), label102, FALSE, FALSE, 0); 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); gtk_misc_set_alignment (GTK_MISC (label102), 0, 0.5);
label103 = gtk_label_new (_("Status")); label103 = gtk_label_new (_("Status"));
gtk_widget_show (label103); gtk_widget_show (label103);
gtk_box_pack_start (GTK_BOX (vbox42), label103, FALSE, FALSE, 0); 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); gtk_misc_set_alignment (GTK_MISC (label103), 0, 0.5);
label104 = gtk_label_new (_("Age")); label104 = gtk_label_new (_("Age"));
gtk_widget_show (label104); gtk_widget_show (label104);
gtk_box_pack_start (GTK_BOX (vbox42), label104, FALSE, FALSE, 0); 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); gtk_misc_set_alignment (GTK_MISC (label104), 0, 0.5);
label105 = gtk_label_new (_("Estimated talent")); label105 = gtk_label_new (_("Estimated talent"));
gtk_widget_show (label105); gtk_widget_show (label105);
gtk_box_pack_start (GTK_BOX (vbox42), label105, FALSE, FALSE, 0); 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); gtk_misc_set_alignment (GTK_MISC (label105), 0, 0.5);
label106 = gtk_label_new (_("Yellow cards")); label106 = gtk_label_new (_("Yellow cards"));
gtk_widget_show (label106); gtk_widget_show (label106);
gtk_box_pack_start (GTK_BOX (vbox42), label106, FALSE, FALSE, 0); 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); gtk_misc_set_alignment (GTK_MISC (label106), 0, 0.5);
label107 = gtk_label_new (_("Value")); label107 = gtk_label_new (_("Value"));
gtk_widget_show (label107); gtk_widget_show (label107);
gtk_box_pack_start (GTK_BOX (vbox42), label107, FALSE, FALSE, 0); 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); gtk_misc_set_alignment (GTK_MISC (label107), 0, 0.5);
label108 = gtk_label_new (_("Wage")); label108 = gtk_label_new (_("Wage"));
gtk_widget_show (label108); gtk_widget_show (label108);
gtk_box_pack_start (GTK_BOX (vbox42), label108, FALSE, FALSE, 0); 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); gtk_misc_set_alignment (GTK_MISC (label108), 0, 0.5);
label113 = gtk_label_new (_("Team")); label113 = gtk_label_new (_("Team"));
gtk_widget_show (label113); gtk_widget_show (label113);
gtk_box_pack_start (GTK_BOX (vbox42), label113, FALSE, FALSE, 0); 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); gtk_misc_set_alignment (GTK_MISC (label113), 0, 0.5);
label114 = gtk_label_new (_("League")); label114 = gtk_label_new (_("League"));
gtk_widget_show (label114); gtk_widget_show (label114);
gtk_box_pack_start (GTK_BOX (vbox42), label114, FALSE, FALSE, 0); 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); gtk_misc_set_alignment (GTK_MISC (label114), 0, 0.5);
vseparator6 = gtk_vseparator_new (); vseparator6 = gtk_vseparator_new ();
@ -1007,7 +967,6 @@ create_opt_window (void)
label130 = gtk_label_new (_("Player list 1")); label130 = gtk_label_new (_("Player list 1"));
gtk_widget_show (label130); gtk_widget_show (label130);
gtk_box_pack_start (GTK_BOX (vbox45), label130, FALSE, FALSE, 0); 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); gtk_misc_set_alignment (GTK_MISC (label130), 2.23517e-10, 0.5);
hseparator13 = gtk_hseparator_new (); hseparator13 = gtk_hseparator_new ();
@ -1091,7 +1050,6 @@ create_opt_window (void)
label115 = gtk_label_new (_("Player list 2")); label115 = gtk_label_new (_("Player list 2"));
gtk_widget_show (label115); gtk_widget_show (label115);
gtk_box_pack_start (GTK_BOX (vbox46), label115, FALSE, FALSE, 0); 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); gtk_misc_set_alignment (GTK_MISC (label115), 0, 0.5);
hseparator14 = gtk_hseparator_new (); 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")); label93 = gtk_label_new (_("Player attributes that are shown in the two player lists"));
gtk_widget_show (label93); gtk_widget_show (label93);
gtk_frame_set_label_widget (GTK_FRAME (frame5), 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")); label87 = gtk_label_new (_("Player attributes"));
gtk_widget_show (label87); gtk_widget_show (label87);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 4), 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); frame8 = gtk_frame_new (NULL);
gtk_widget_show (frame8); gtk_widget_show (frame8);
@ -1189,7 +1145,6 @@ create_opt_window (void)
label136 = gtk_label_new (_("Option")); label136 = gtk_label_new (_("Option"));
gtk_widget_show (label136); gtk_widget_show (label136);
gtk_box_pack_start (GTK_BOX (vbox50), label136, FALSE, FALSE, 0); 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 (); hseparator17 = gtk_hseparator_new ();
gtk_widget_show (hseparator17); gtk_widget_show (hseparator17);
@ -1208,7 +1163,6 @@ create_opt_window (void)
label140 = gtk_label_new (_("Update interval (in weeks)")); label140 = gtk_label_new (_("Update interval (in weeks)"));
gtk_widget_show (label140); gtk_widget_show (label140);
gtk_container_add (GTK_CONTAINER (eventbox4), label140); gtk_container_add (GTK_CONTAINER (eventbox4), label140);
gtk_label_set_justify (GTK_LABEL (label140), GTK_JUSTIFY_LEFT);
eventbox5 = gtk_event_box_new (); eventbox5 = gtk_event_box_new ();
gtk_widget_show (eventbox5); gtk_widget_show (eventbox5);
@ -1218,7 +1172,6 @@ create_opt_window (void)
label141 = gtk_label_new (_("Maximal history length")); label141 = gtk_label_new (_("Maximal history length"));
gtk_widget_show (label141); gtk_widget_show (label141);
gtk_container_add (GTK_CONTAINER (eventbox5), label141); gtk_container_add (GTK_CONTAINER (eventbox5), label141);
gtk_label_set_justify (GTK_LABEL (label141), GTK_JUSTIFY_LEFT);
eventbox6 = gtk_event_box_new (); eventbox6 = gtk_event_box_new ();
gtk_widget_show (eventbox6); gtk_widget_show (eventbox6);
@ -1228,7 +1181,6 @@ create_opt_window (void)
label142 = gtk_label_new (_("Delete history at end of season")); label142 = gtk_label_new (_("Delete history at end of season"));
gtk_widget_show (label142); gtk_widget_show (label142);
gtk_container_add (GTK_CONTAINER (eventbox6), label142); gtk_container_add (GTK_CONTAINER (eventbox6), label142);
gtk_label_set_justify (GTK_LABEL (label142), GTK_JUSTIFY_LEFT);
vseparator8 = gtk_vseparator_new (); vseparator8 = gtk_vseparator_new ();
gtk_widget_show (vseparator8); gtk_widget_show (vseparator8);
@ -1241,7 +1193,6 @@ create_opt_window (void)
label134 = gtk_label_new (_("Team histories")); label134 = gtk_label_new (_("Team histories"));
gtk_widget_show (label134); gtk_widget_show (label134);
gtk_box_pack_start (GTK_BOX (vbox48), label134, FALSE, FALSE, 0); 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 (); hseparator15 = gtk_hseparator_new ();
gtk_widget_show (hseparator15); gtk_widget_show (hseparator15);
@ -1279,7 +1230,6 @@ create_opt_window (void)
label135 = gtk_label_new (_("Player histories")); label135 = gtk_label_new (_("Player histories"));
gtk_widget_show (label135); gtk_widget_show (label135);
gtk_box_pack_start (GTK_BOX (vbox49), label135, FALSE, FALSE, 0); 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 (); hseparator16 = gtk_hseparator_new ();
gtk_widget_show (hseparator16); gtk_widget_show (hseparator16);
@ -1308,12 +1258,10 @@ create_opt_window (void)
label132 = gtk_label_new (_("Team and player histories")); label132 = gtk_label_new (_("Team and player histories"));
gtk_widget_show (label132); gtk_widget_show (label132);
gtk_frame_set_label_widget (GTK_FRAME (frame8), 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")); label131 = gtk_label_new (_("Histories"));
gtk_widget_show (label131); gtk_widget_show (label131);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 5), 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); frame6 = gtk_frame_new (NULL);
gtk_widget_show (frame6); gtk_widget_show (frame6);
@ -1334,12 +1282,10 @@ create_opt_window (void)
label94 = gtk_label_new (_("Miscellaneous options")); label94 = gtk_label_new (_("Miscellaneous options"));
gtk_widget_show (label94); gtk_widget_show (label94);
gtk_frame_set_label_widget (GTK_FRAME (frame6), 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")); label88 = gtk_label_new (_("Misc"));
gtk_widget_show (label88); gtk_widget_show (label88);
gtk_notebook_set_tab_label (GTK_NOTEBOOK (notebook1), gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook1), 6), 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 (); hseparator8 = gtk_hseparator_new ();
gtk_widget_show (hseparator8); gtk_widget_show (hseparator8);
@ -1379,7 +1325,6 @@ create_opt_window (void)
label47 = gtk_label_new_with_mnemonic (_("OK")); label47 = gtk_label_new_with_mnemonic (_("OK"));
gtk_widget_show (label47); gtk_widget_show (label47);
gtk_box_pack_start (GTK_BOX (hbox26), label47, FALSE, FALSE, 0); 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 (); button_opt_cancel = gtk_button_new ();
gtk_widget_show (button_opt_cancel); gtk_widget_show (button_opt_cancel);
@ -1405,7 +1350,6 @@ create_opt_window (void)
label48 = gtk_label_new_with_mnemonic (_("Cancel")); label48 = gtk_label_new_with_mnemonic (_("Cancel"));
gtk_widget_show (label48); gtk_widget_show (label48);
gtk_box_pack_start (GTK_BOX (hbox27), label48, FALSE, FALSE, 0); 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_signal_connect ((gpointer) opt_window, "delete_event",
G_CALLBACK (on_opt_window_delete_event), G_CALLBACK (on_opt_window_delete_event),

View File

@ -1,60 +1,12 @@
#include "cup.h"
#include "free.h" #include "free.h"
#include "league.h" #include "league.h"
#include "maths.h" #include "maths.h"
#include "option.h"
#include "player.h" #include "player.h"
#include "team.h" #include "team.h"
#include "variables.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. /** Create and return a new player.
@param tm The team the player will belong to. @param tm The team the player will belong to.
@param average_skill The average skill of the team. @param average_skill The average skill of the team.
@ -64,8 +16,8 @@ Player
player_new(Team *tm, gint average_skill) player_new(Team *tm, gint average_skill)
{ {
gfloat skill_factor = gfloat skill_factor =
math_rnd(1 - CONSTANT_PLAYER_AVERAGE_SKILL_VARIANCE, math_rnd(1 - const_float("float_player_average_skill_variance"),
1 + CONSTANT_PLAYER_AVERAGE_SKILL_VARIANCE); 1 + const_float("float_player_average_skill_variance"));
Player new; Player new;
new.name = new.name =
@ -73,27 +25,32 @@ player_new(Team *tm, gint average_skill)
new.id = player_new_id(tm->players); new.id = player_new_id(tm->players);
new.pos = player_get_position_from_structure(tm->structure, tm->players->len); new.pos = player_get_position_from_structure(tm->structure, tm->players->len);
new.cpos = new.pos; 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.cskill = new.skill;
new.age = math_gauss_disti(CONSTANT_PLAYER_AGE_LOWER, new.age = math_gauss_disti(const_int("int_player_age_lower"),
CONSTANT_PLAYER_AGE_UPPER); const_int("int_player_age_upper"));
new.peak_age = new.peak_age =
math_rndi(CONSTANT_PLAYER_PEAK_AGE_LOWER + math_rndi(const_int("int_player_peak_age_lower") +
(new.pos == PLAYER_POS_GOALIE) * CONSTANT_PLAYER_PEAK_AGE_GOALIE_ADDITION, (new.pos == PLAYER_POS_GOALIE) *
CONSTANT_PLAYER_PEAK_AGE_UPPER + const_int("int_player_peak_age_goalie_addition"),
(new.pos == PLAYER_POS_GOALIE) * CONSTANT_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.talent = player_new_talent(new.skill);
new.etal = player_estimate_talent(&new); player_estimate_talent(&new);
new.fitness = math_rndi(CONSTANT_PLAYER_FITNESS_LOWER, CONSTANT_PLAYER_FITNESS_UPPER); new.fitness = math_rndi(const_int("int_player_fitness_lower"),
const_int("int_player_fitness_upper"));
new.health = new.recovery = 0; new.health = new.recovery = 0;
new.games_goals = g_array_new(FALSE, FALSE, sizeof(PlayerGamesGoals)); new.games_goals = g_array_new(FALSE, FALSE, sizeof(PlayerGamesGoals));
new.value = player_assign_value(&new); new.value = player_assign_value(&new);
new.wage = player_assign_wage(&new); new.wage = player_assign_wage(&new);
new.contract = math_rndi(CONSTANT_PLAYER_CONTRACT_LOWER, CONSTANT_PLAYER_CONTRACT_UPPER); new.contract = math_rndi(const_int("int_player_contract_lower"),
new.lsu = math_rndi(CONSTANT_PLAYER_LSU_LOWER, CONSTANT_PLAYER_LSU_UPPER); 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)); new.cards = g_array_new(FALSE, FALSE, sizeof(PlayerCard));
/* todo: make player history struct. */
new.history = NULL;
new.team = tm; new.team = tm;
return new; return new;
@ -107,7 +64,7 @@ player_new_id(const GArray *players)
{ {
gint i, j; gint i, j;
for(i=0;i<CONSTANT_TEAM_MAX_PLAYERS;i++) for(i=0;i<const_int("int_team_max_players");i++)
{ {
for(j=0;j<players->len;j++) for(j=0;j<players->len;j++)
if(g_array_index(players, Player, j).id == i) 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) if(player_number % 11 == 0)
position = PLAYER_POS_GOALIE; position = PLAYER_POS_GOALIE;
else if(player_number < bound[0] || 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; position = PLAYER_POS_DEFENDER;
else if(player_number < bound[1] || 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; position = PLAYER_POS_MIDFIELDER;
else else
position = PLAYER_POS_FORWARD; position = PLAYER_POS_FORWARD;
@ -157,37 +114,37 @@ player_get_position_from_structure(gint structure, gint player_number)
gint gint
player_new_talent(gint skill) player_new_talent(gint skill)
{ {
gint talent = math_gauss_disti(2 * skill - CONSTANT_PLAYER_MAX_SKILL, gint talent = math_gauss_disti(2 * skill - const_int("int_player_max_skill"),
CONSTANT_PLAYER_MAX_SKILL); const_int("int_player_max_skill"));
if(talent < skill) if(talent < skill)
talent = 2 * skill - talent; talent = 2 * skill - talent;
return talent; return talent;
} }
/** Estimate a player's talent. The quality of the estimate /** Estimate a player's talent.
depends on the quality of the scout. @param pl The player of which we'd like to estimate the talent. */
@param pl The player of which we'd like to estimate the talent. void
@return A talent estimate. */ player_estimate_talent(Player *pl)
gint
player_estimate_talent(const Player *pl)
{ {
gint i; gint i, j;
gint scout_deviance[QUALITY_END];
/* the maximal deviance in both directions */ /* the maximal deviance in both directions */
gint deviance_bound[2] = 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 */ for(i=0;i<QUALITY_END;i++)
gfloat scout_deviance = (scout % 10) * CONSTANT_PLAYER_ETAL_SCOUT_FACTOR; {
scout_deviance[i] = (i + 1) * const_int("int_player_etal_scout_factor");
/* adjust deviance_bounds with regard to the scout's /* adjust deviance_bounds with regard to the scout's
deviance */ deviance */
for(i=0;i<2;i++) for(j=0;j<2;j++)
deviance_bound[i] = MIN(deviance_bound[i], scout_deviance); deviance_bound[j] = MIN(deviance_bound[j], scout_deviance[i]);
return math_rndi(pl->talent - deviance_bound[0], pl->etal[i] = math_rndi(pl->talent - deviance_bound[0],
pl->talent + deviance_bound[1]); pl->talent + deviance_bound[1]);
}
} }
/** Assign a (transfer) value to a player. The value depends on skill, /** Assign a (transfer) value to a player. The value depends on skill,
@ -199,17 +156,19 @@ player_assign_value(const Player *pl)
{ {
gint value; gint value;
value = (gint)powf((CONSTANT_PLAYER_VALUE_SKILL_WEIGHT * (gfloat)pl->skill value = (gint)powf((const_float("float_player_value_skill_weight") *
+ (1 - CONSTANT_PLAYER_VALUE_SKILL_WEIGHT) * (gfloat)pl->talent * 0.7), (gfloat)pl->skill +
CONSTANT_PLAYER_VALUE_POWER); (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); 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); 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); 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 = (gint)((gfloat)value * 0.9);
value = math_round_integer(value, 2); value = math_round_integer(value, 2);
@ -226,9 +185,9 @@ player_assign_wage(const Player *pl)
{ {
gfloat wage; gfloat wage;
wage = rint(((gfloat)pl->value * CONSTANT_PLAYER_WAGE_VALUE_FACTOR) * wage = rint(((gfloat)pl->value * const_float("float_player_wage_value_factor")) *
math_rnd(1 - CONSTANT_PLAYER_WAGE_RANDOM_DEV, math_rnd(1 - const_float("float_player_wage_random_dev"),
1 + CONSTANT_PLAYER_WAGE_RANDOM_DEV) ); 1 + const_float("float_player_wage_random_dev") ));
return math_round_integer((gint)wage, 1); 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->name = g_string_new(source->name->str);
dest->cards = g_array_new(FALSE, FALSE, sizeof(PlayerCard)); dest->cards = g_array_new(FALSE, FALSE, sizeof(PlayerCard));
dest->games_goals = g_array_new(FALSE, FALSE, sizeof(PlayerGamesGoals)); dest->games_goals = g_array_new(FALSE, FALSE, sizeof(PlayerGamesGoals));
dest->history = NULL;
for(i=0;i<source->cards->len;i++) for(i=0;i<source->cards->len;i++)
g_array_append_val(dest->cards, g_array_append_val(dest->cards,
@ -268,7 +226,7 @@ player_copy(const Player *source, Player *dest)
void void
player_append_to_array(const Player *pl, Team *tm) 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); player_copy(pl, &new_player);
@ -382,3 +340,142 @@ player_of_id(const Team *tm, gint id)
return NULL; 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;i<pl->cards->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;
}

View File

@ -5,6 +5,12 @@
#include "player_struct.h" #include "player_struct.h"
#include "team_struct.h" #include "team_struct.h"
enum PlayerCompareAttrib
{
PLAYER_COMPARE_ATTRIBUTE_GAME_SKILL = 0,
PLAYER_COMPARE_ATTRIBUTE_END
};
Player Player
player_new(Team *tm, gint average_skill); player_new(Team *tm, gint average_skill);
@ -17,8 +23,8 @@ player_get_position_from_structure(gint structure, gint player_number);
gint gint
player_new_talent(gint skill); player_new_talent(gint skill);
gint void
player_estimate_talent(const Player *pl); player_estimate_talent(Player *pl);
gint gint
player_assign_value(const Player *pl); player_assign_value(const Player *pl);
@ -50,4 +56,19 @@ player_of(const Team *tm, gint number);
Player* Player*
player_of_id(const Team *tm, gint id); 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 #endif

View File

@ -2,24 +2,9 @@
#define PLAYER_STRUCT_H #define PLAYER_STRUCT_H
#include "bygfoot.h" #include "bygfoot.h"
#include "enums.h"
#include "team_struct.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. Player positions.
*/ */
@ -75,12 +60,13 @@ typedef struct
gint pos, /**< Position. @see #PlayerPos */ gint pos, /**< Position. @see #PlayerPos */
cpos, /**< Current 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. */ cskill, /**< Current Skill. */
age, /**< Age in weeks */ age, /**< Age in weeks */
peak_age, /**< Age at which the player reaches his peak ability. */ peak_age, /**< Age at which the player reaches his peak ability. */
talent, /**< Talent. The peak ability (which isn't always reached). */ 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. */ fitness, /**< Fitness. Between 0 and 99. */
health, /**< Health. An integer signifying an injury or good health. @see #PlayerInjury */ health, /**< Health. An integer signifying an injury or good health. @see #PlayerInjury */
recovery, /**< Weeks until the player gets healthy. */ recovery, /**< Weeks until the player gets healthy. */
@ -97,8 +83,6 @@ typedef struct
/** Array of cards; one item per league and cup. /** Array of cards; one item per league and cup.
@see PlayerCard*/ @see PlayerCard*/
GArray *cards; GArray *cards;
/** Player history. To be specified. */
GArray *history;
/** Pointer to the player's team. */ /** Pointer to the player's team. */
Team *team; Team *team;

View File

@ -2,15 +2,37 @@
#include "file.h" #include "file.h"
#include "fixture.h" #include "fixture.h"
#include "league.h" #include "league.h"
#include "live_game.h"
#include "main.h" #include "main.h"
#include "maths.h" #include "maths.h"
#include "player.h" #include "player.h"
#include "start_end.h" #include "start_end.h"
#include "table.h"
#include "team.h" #include "team.h"
#include "transfer.h" #include "transfer.h"
#include "user.h"
#include "variables.h" #include "variables.h"
#include "xml_name.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. */ /** Generate the teams etc. */
void void
start_new_game(void) start_new_game(void)
@ -46,10 +68,12 @@ start_write_variables(void)
gint i; gint i;
season = week = week_round = 1; 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)); transfer_list = g_array_new(FALSE, FALSE, sizeof(TransferPlayer));
file_load_conf_file();
for(i=0;i<users->len;i++)
file_load_user_conf_file(&usr(i));
} }
/** Generate the teams in the leagues. */ /** Generate the teams in the leagues. */
@ -89,21 +113,156 @@ start_load_cup_teams(void)
{ {
cup_load_choose_teams(&cp(i)); cup_load_choose_teams(&cp(i));
cup_load_choose_team_user(&cp(i)); cup_load_choose_team_user(&cp(i));
/*d*/
/* for(j=0;j<cp(i).teams->len;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;j<cp(i).user_teams->len;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;i<ligs->len;i++)
if(query_fixture_in_week_round(lig(i).id, week, week_round))
{
new_week = FALSE;
break;
}
for(i=0;i<cps->len;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;i<ligs->len;i++)
for(j=0;j<lig(i).fixtures->len;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;i<cps->len;i++)
for(j=0;j<cp(i).fixtures->len;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;i<ligs->len;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;i<cps->len;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;j<cp(i).tables->len;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;i<cps->len;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++;
}
}

View File

@ -18,4 +18,22 @@ start_generate_league_teams(void);
void void
start_load_cup_teams(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 #endif

View File

@ -15,6 +15,7 @@
# include <libintl.h> # include <libintl.h>
# undef _ # undef _
# define _(String) dgettext (PACKAGE, String) # define _(String) dgettext (PACKAGE, String)
# define Q_(String) g_strip_context ((String), gettext (String))
# ifdef gettext_noop # ifdef gettext_noop
# define N_(String) gettext_noop (String) # define N_(String) gettext_noop (String)
# else # else
@ -27,6 +28,7 @@
# define dcgettext(Domain,Message,Type) (Message) # define dcgettext(Domain,Message,Type) (Message)
# define bindtextdomain(Domain,Directory) (Domain) # define bindtextdomain(Domain,Directory) (Domain)
# define _(String) (String) # define _(String) (String)
# define Q_(String) g_strip_context ((String), (String))
# define N_(String) (String) # define N_(String) (String)
#endif #endif

182
src/table.c Normal file
View File

@ -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;i<TABLE_END;i++)
new.values[i] = 0;
return new;
}
/** Update the appropriate table entries after
a fixture has been calculated.
@param fix The fixture that's just been calculated. */
void
table_update(const Fixture *fix)
{
gint i;
gint idx = (fix->result[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;i<table->elements->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;i<cup_from_clid(fix->clid)->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;j<table->elements->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;i<fixtures->len;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;
}

23
src/table.h Normal file
View File

@ -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

View File

@ -40,6 +40,8 @@ typedef struct
{ {
GString *name; GString *name;
gint clid; gint clid;
/** The cup round (or -1 if it's a league). */
gint round;
GArray *elements; GArray *elements;
} Table; } Table;

View File

@ -3,35 +3,12 @@
#include "free.h" #include "free.h"
#include "league.h" #include "league.h"
#include "maths.h" #include "maths.h"
#include "option.h"
#include "player.h" #include "player.h"
#include "team.h" #include "team.h"
#include "user.h"
#include "variables.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. Generate a team with default values, e.g.
random playing structure and an empty string random playing structure and an empty string
@ -60,7 +37,6 @@ team_new(void)
/** /**
Return a random playing style. Return a random playing style.
@see The #TeamPlayingStyle enumeration. @see The #TeamPlayingStyle enumeration.
@see The #CONSTANT_TEAM_PLAYING_STYLE_PROB1 define.
*/ */
gint gint
team_assign_playing_style(void) team_assign_playing_style(void)
@ -70,16 +46,16 @@ team_assign_playing_style(void)
rndom = math_rnd(0,1); rndom = math_rnd(0,1);
/* all out defend */ /* all out defend */
if(rndom < CONSTANT_TEAM_PLAYING_STYLE_PROB1) if(rndom < const_float("float_team_playing_style_prob1"))
return -2; return -2;
/* defend */ /* defend */
else if(rndom < CONSTANT_TEAM_PLAYING_STYLE_PROB2) else if(rndom < const_float("float_team_playing_style_prob2"))
return -1; return -1;
/* balanced */ /* balanced */
else if(rndom < CONSTANT_TEAM_PLAYING_STYLE_PROB3) else if(rndom < const_float("float_team_playing_style_prob3"))
return 0; return 0;
/* attack */ /* attack */
else if(rndom < CONSTANT_TEAM_PLAYING_STYLE_PROB4) else if(rndom < const_float("float_team_playing_style_prob4"))
return 1; return 1;
/* all out attack */ /* all out attack */
@ -88,20 +64,19 @@ team_assign_playing_style(void)
/** /**
Return a random playing structure. Return a random playing structure.
@see The #CONSTANT_TEAM_PLAYING_STRUCTURE_PROB1 define.
*/ */
gint gint
team_assign_playing_structure(void) team_assign_playing_structure(void)
{ {
gfloat rndom = math_rnd(0,1); gfloat rndom = math_rnd(0,1);
if(rndom < CONSTANT_TEAM_PLAYING_STRUCTURE_PROB1) if(rndom < const_float("float_team_playing_structure_prob1"))
return 532; return 532;
else if(rndom < CONSTANT_TEAM_PLAYING_STRUCTURE_PROB2) else if(rndom < const_float("float_team_playing_structure_prob2"))
return 442; return 442;
else if(rndom < CONSTANT_TEAM_PLAYING_STRUCTURE_PROB3) else if(rndom < const_float("float_team_playing_structure_prob3"))
return 352; return 352;
else if(rndom < CONSTANT_TEAM_PLAYING_STRUCTURE_PROB4) else if(rndom < const_float("float_team_playing_structure_prob4"))
return 433; return 433;
return 343; return 343;
@ -128,8 +103,8 @@ void
team_generate_players(Team *tm) team_generate_players(Team *tm)
{ {
gint i; gint i;
gfloat skill_factor = math_rnd(1 - CONSTANT_TEAM_SKILL_VARIANCE, gfloat skill_factor = math_rnd(1 - const_float("float_team_skill_variance"),
1 + CONSTANT_TEAM_SKILL_VARIANCE); 1 + const_float("float_team_skill_variance"));
Player new; Player new;
gint average_skill; 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)) * (gfloat)team_return_league_cup_value_int(tm, LEAGUE_CUP_VALUE_SKILL_DIFF)) *
skill_factor; 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;i<CONSTANT_TEAM_MAX_PLAYERS;i++) for(i=0;i<const_int("int_team_max_players");i++)
{ {
new = player_new(tm, average_skill); new = player_new(tm, average_skill);
g_array_append_val(tm->players, new); g_array_append_val(tm->players, 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); 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) switch(value_type)
{ {
default: default:
@ -273,7 +248,7 @@ team_copy(const Team *source, Team *dest)
for(i=0;i<source->players->len;i++) for(i=0;i<source->players->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); free_player(&new_player);
player_copy(&g_array_index(source->players, Player, i), player_copy(&g_array_index(source->players, Player, i),
&new_player); &new_player);
@ -487,17 +462,162 @@ team_get_next_fixture(const Team *tm)
return fix; return fix;
} }
/** Calculate the average cskill of the first 11 players. /** Check whether the team is a user-managed team.
@param tm The team we examine. @param tm The team we examine.
@return The average skill. */ @return The user's index in the #users array or -1.*/
gfloat gint
team_average_cskill(const Team *tm) team_is_user(const Team *tm)
{ {
gint i; gint i;
for(i=0;i<users->len;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; gfloat sum = 0;
for(i=0;i<MIN(11, tm->players->len);i++) if(!cskill)
sum += ((gfloat)player_of(tm, i)->cskill * powf((gfloat)player_of(tm, i)->fitness / 100, 0.25)); {
for(i=0;i<tm->players->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;i<elements->len;i++)
if(g_array_index(elements, TableElement, i).team == tm)
return i + 1;
}
else
{
for(i=0;i<cup_from_clid(tm->clid)->tables->len;i++)
{
elements = g_array_index(cup_from_clid(tm->clid)->tables, Table, i).elements;
for(j=0;j<elements->len;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;j<tm->players->len;j++)
if(player_of(tm, i)->pos >
player_of(tm, j)->pos)
{
player_swap(tm, i, tm, j);
i = 10;
break;
}
i++;
}
} }

View File

@ -6,9 +6,6 @@
#include "fixture_struct.h" #include "fixture_struct.h"
#include "team_struct.h" #include "team_struct.h"
/** Maximum number of players in a team. */
#define CONSTANT_TEAM_MAX_PLAYERS 20
Team Team
team_new(void); team_new(void);
@ -64,6 +61,21 @@ Fixture*
team_get_next_fixture(const Team *tm); team_get_next_fixture(const Team *tm);
gfloat 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 #endif

View File

@ -4,9 +4,6 @@
#include "bygfoot.h" #include "bygfoot.h"
#include "team.h" #include "team.h"
#define CONSTANT_TRANSFER_MAX_PLAYERS 20
#define CONSTANT_TRANSFER_DEADLINE 35
/** Structure representing a player on the transfer list. */ /** Structure representing a player on the transfer list. */
typedef struct typedef struct
{ {

View File

@ -7,69 +7,30 @@
#include "live_game.h" #include "live_game.h"
#include "maths.h" #include "maths.h"
#include "misc.h" #include "misc.h"
#include "option.h"
#include "support.h" #include "support.h"
#include "team.h" #include "team.h"
#include "treeview.h" #include "treeview.h"
#include "treeview_cell.h" #include "treeview_cell.h"
#include "user.h"
#include "variables.h" #include "variables.h"
#include "window.h" #include "window.h"
/** Return the filename of the icon going with the LiveGameEvent /** Select the row that's been clicked on. */
with type event_type. void
@param event_type The type of the event. treeview_select_row(GtkTreeView *treeview, GdkEventButton *event)
@return A filename specifying a pixmap. */
gchar*
treeview_live_game_icon(gint event_type)
{ {
switch(event_type) GtkTreeSelection *selection =
{ gtk_tree_view_get_selection(treeview);
default: GtkTreePath *path;
return "";
break; if(!gtk_tree_view_get_path_at_pos(treeview,
case LIVE_GAME_EVENT_FOUL_YELLOW: event->x, event->y,
return "yellow.png"; &path, NULL, NULL, NULL))
break; return;
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 ""; gtk_tree_selection_select_path(selection, path);
} gtk_tree_path_free(path);
/** 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;
} }
/** Return the number in the 'column'th column of the currently /** Return the number in the 'column'th column of the currently
@ -130,7 +91,7 @@ treeview_clear(GtkTreeView *treeview)
gint i; gint i;
gint number_of_columns; gint number_of_columns;
GtkTreeView *list = (treeview == NULL) ? GtkTreeView *list = (treeview == NULL) ?
GTK_TREE_VIEW(lookup_widget(main_window, "player_info")) : GTK_TREE_VIEW(lookup_widget(window.main, "player_info")) :
treeview; treeview;
gtk_tree_view_set_model(GTK_TREE_VIEW(list), gtk_tree_view_set_model(GTK_TREE_VIEW(list),
@ -167,6 +128,64 @@ treeview_get_col_number_column (GtkTreeViewColumn *col)
return num; 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. Creates the model for the treeview in the team selection window.
The model contains a list of all the teams from the leagues in 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. teams from international cups are shown, too.
@param show_cup_teams Whether or not teams from international @param show_cup_teams Whether or not teams from international
cups are shown. cups are shown.
@param show_user_teams Whether or not user teams are shown.
@return The model containing the team names. @return The model containing the team names.
*/ */
GtkTreeModel* 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; gint i, j, cnt = 1;
GtkListStore *liststore; GtkListStore *liststore;
@ -196,13 +216,16 @@ treeview_create_team_selection_list(gboolean show_cup_teams)
for(j=0;j<lig(i).teams->len;j++) for(j=0;j<lig(i).teams->len;j++)
{ {
gtk_list_store_append(liststore, &iter); if(team_is_user(&g_array_index(lig(i).teams, Team, j)) == -1)
gtk_list_store_set(liststore, &iter, {
0, cnt++, gtk_list_store_append(liststore, &iter);
1, symbol, gtk_list_store_set(liststore, &iter,
2, (gpointer)&g_array_index(lig(i).teams, Team, j), 0, cnt++,
3, lig(i).name->str, 1, symbol,
-1); 2, (gpointer)&g_array_index(lig(i).teams, Team, j),
3, lig(i).name->str,
-1);
}
} }
if(symbol != NULL) 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_pack_start(col, renderer, TRUE);
gtk_tree_view_column_add_attribute(col, renderer, gtk_tree_view_column_add_attribute(col, renderer,
"text", 0); "text", 0);
if(strcmp(font_name->str, "0") != 0)
g_object_set(renderer, "font", font_name->str, NULL);
/* Flags */ /* Flags */
col = gtk_tree_view_column_new(); 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 treeview The treeview we show the list in.
@param show_cup_teams Whether or not teams from international @param show_cup_teams Whether or not teams from international
cups are shown. cups are shown.
@param show_user_teams Whether or not user teams are shown.
*/ */
void 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 = GtkTreeModel *team_list =
treeview_create_team_selection_list(show_cup_teams); treeview_create_team_selection_list(show_cup_teams, show_user_teams);
GtkTreeSelection *selection; GtkTreeSelection *selection;
treeview_clear(treeview); treeview_clear(treeview);
@ -337,7 +360,7 @@ treeview_create_player_list(GPtrArray *players, gint *attributes, gint max, gboo
gtk_list_store_append(liststore, &iter); gtk_list_store_append(liststore, &iter);
if(show_separator && i == 11) 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;j<max;j++) for(j=0;j<max;j++)
gtk_list_store_set(liststore, &iter, j + 1, NULL, -1); gtk_list_store_set(liststore, &iter, j + 1, NULL, -1);
@ -418,7 +441,7 @@ treeview_set_up_player_list (GtkTreeView *treeview, gint *attributes, gint max)
player attributes according to 'attrib'. player attributes according to 'attrib'.
@param treeview The treeview we fill. @param treeview The treeview we fill.
@param players The pointer array with the players. We free it afterwards. @param players The pointer array with the players. We free it afterwards.
@param attrib The #PlayerListAttrib that determines which attributes to show. @param attrib The #PlayerListAttribute that determines which attributes to show.
@param show_separator Whether we draw a blank line after the 11th player. */ @param show_separator Whether we draw a blank line after the 11th player. */
void void
treeview_show_player_list(GtkTreeView *treeview, GPtrArray *players, PlayerListAttribute attribute, treeview_show_player_list(GtkTreeView *treeview, GPtrArray *players, PlayerListAttribute attribute,
@ -445,16 +468,19 @@ treeview_show_player_list(GtkTreeView *treeview, GPtrArray *players, PlayerListA
} }
/** Show the list of the user's players in the left view. /** Show the list of the user's players in the left view.
@param user The user we show the players of.
@param player_list The tab we use. */ @param player_list The tab we use. */
void void
treeview_show_user_player_list(gint player_list) treeview_show_user_player_list(const User *user, gint player_list)
{ {
PlayerListAttribute attribute;
GtkWidget *treeview = (player_list == 1) ? GtkWidget *treeview = (player_list == 1) ?
lookup_widget(main_window, "player_list1") : lookup_widget(window.main, "player_list1") :
lookup_widget(main_window, "player_list2"); lookup_widget(window.main, "player_list2");
treeview_show_player_list(GTK_TREE_VIEW(treeview), team_get_player_pointers(my_team), user_set_player_list_attributes(user, &attribute, player_list);
player_list_attributes[(player_list != 1)], TRUE); treeview_show_player_list(GTK_TREE_VIEW(treeview),
team_get_player_pointers(user->tm), attribute, TRUE);
} }
/** Show the commentary and the minute belonging to the unit. /** 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; GdkPixbuf *symbol = NULL;
GtkAdjustment *adjustment = GtkAdjustment *adjustment =
gtk_scrolled_window_get_vadjustment( gtk_scrolled_window_get_vadjustment(
GTK_SCROLLED_WINDOW(lookup_widget(live_game.window, GTK_SCROLLED_WINDOW(lookup_widget(window.live,
"scrolledwindow9"))); "scrolledwindow9")));
GtkListStore *liststore = GtkListStore *liststore =
GTK_LIST_STORE( 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; GtkTreeIter iter;
gchar buf[SMALL]; gchar buf[SMALL];
@ -494,7 +520,6 @@ treeview_live_game_show_commentary(const LiveGameUnit *unit)
GtkTreeModel* GtkTreeModel*
treeview_live_game_create_init_commentary(const LiveGameUnit *unit) treeview_live_game_create_init_commentary(const LiveGameUnit *unit)
{ {
gint i, j;
GtkListStore *liststore; GtkListStore *liststore;
GtkTreeIter iter; GtkTreeIter iter;
GdkPixbuf *symbol = NULL; GdkPixbuf *symbol = NULL;
@ -525,7 +550,7 @@ void
treeview_live_game_set_up_commentary(void) treeview_live_game_set_up_commentary(void)
{ {
GtkTreeView *treeview = GtkTreeView *treeview =
GTK_TREE_VIEW(lookup_widget(live_game.window, "treeview_commentary")); GTK_TREE_VIEW(lookup_widget(window.live, "treeview_commentary"));
GtkTreeViewColumn *col; GtkTreeViewColumn *col;
GtkCellRenderer *renderer; GtkCellRenderer *renderer;
@ -560,7 +585,7 @@ void
treeview_live_game_show_initial_commentary(const LiveGameUnit *unit) treeview_live_game_show_initial_commentary(const LiveGameUnit *unit)
{ {
GtkTreeView *treeview = GtkTreeView *treeview =
GTK_TREE_VIEW(lookup_widget(live_game.window, "treeview_commentary")); GTK_TREE_VIEW(lookup_widget(window.live, "treeview_commentary"));
GtkTreeModel *model = NULL; GtkTreeModel *model = NULL;
treeview_clear(treeview); treeview_clear(treeview);
@ -595,8 +620,8 @@ treeview_live_game_create_result(const LiveGameUnit *unit)
GDK_TYPE_PIXBUF); GDK_TYPE_PIXBUF);
gtk_list_store_append(liststore, &iter); gtk_list_store_append(liststore, &iter);
gtk_list_store_set(liststore, &iter, 0, NULL, 1, (gpointer)live_game.fix, gtk_list_store_set(liststore, &iter, 0, NULL, 1, (gpointer)usr(stat2).live_game.fix,
2, (gpointer)live_game.fix, 3, (gpointer)live_game.fix, 4, NULL, -1); 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); 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) treeview_live_game_set_up_result(void)
{ {
GtkTreeView *treeview = GtkTreeView *treeview =
GTK_TREE_VIEW(lookup_widget(live_game.window, "treeview_result")); GTK_TREE_VIEW(lookup_widget(window.live, "treeview_result"));
GtkTreeViewColumn *col; GtkTreeViewColumn *col;
GtkCellRenderer *renderer; GtkCellRenderer *renderer;
@ -664,7 +689,7 @@ void
treeview_live_game_show_result(const LiveGameUnit *unit) treeview_live_game_show_result(const LiveGameUnit *unit)
{ {
GtkTreeView *treeview = GtkTreeView *treeview =
GTK_TREE_VIEW(lookup_widget(live_game.window, "treeview_result")); GTK_TREE_VIEW(lookup_widget(window.live, "treeview_result"));
GtkTreeModel *model = NULL; GtkTreeModel *model = NULL;
treeview_clear(treeview); treeview_clear(treeview);
@ -677,3 +702,88 @@ treeview_live_game_show_result(const LiveGameUnit *unit)
gtk_tree_view_set_model(treeview, model); gtk_tree_view_set_model(treeview, model);
g_object_unref(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;i<users->len;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);
}

View File

@ -4,6 +4,10 @@
#include "bygfoot.h" #include "bygfoot.h"
#include "live_game_struct.h" #include "live_game_struct.h"
#include "player_struct.h" #include "player_struct.h"
#include "user_struct.h"
void
treeview_select_row(GtkTreeView *treeview, GdkEventButton *event);
GdkPixbuf* GdkPixbuf*
treeview_pixbuf_from_filename(gchar *filename); treeview_pixbuf_from_filename(gchar *filename);
@ -24,13 +28,15 @@ gint
treeview_get_col_number_column (GtkTreeViewColumn *col); treeview_get_col_number_column (GtkTreeViewColumn *col);
GtkTreeModel* GtkTreeModel*
treeview_create_team_selection_list(gboolean show_cup_teams); treeview_create_team_selection_list(gboolean show_cup_teams,
gboolean show_user_teams);
void void
treeview_set_up_team_selection_treeview (GtkTreeView *treeview); treeview_set_up_team_selection_treeview (GtkTreeView *treeview);
void 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* GtkTreeModel*
treeview_create_player_list(GPtrArray *players, gint *attributes, gint max, gboolean show_separator); treeview_create_player_list(GPtrArray *players, gint *attributes, gint max, gboolean show_separator);
@ -43,7 +49,7 @@ treeview_show_player_list(GtkTreeView *treeview, GPtrArray *players, PlayerListA
gboolean show_separator); gboolean show_separator);
void void
treeview_show_user_player_list(gint player_list); treeview_show_user_player_list(const User *user, gint player_list);
void void
treeview_live_game_show_commentary(const LiveGameUnit *unit); treeview_live_game_show_commentary(const LiveGameUnit *unit);
@ -69,4 +75,13 @@ treeview_live_game_set_up_result(void);
void void
treeview_live_game_show_result(const LiveGameUnit *unit); 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 #endif

View File

@ -1,49 +1,12 @@
#include "maths.h" #include "maths.h"
#include "misc.h" #include "misc.h"
#include "option.h"
#include "player.h" #include "player.h"
#include "team.h" #include "team.h"
#include "treeview.h" #include "treeview.h"
#include "treeview_cell.h" #include "treeview_cell.h"
#include "user.h"
#define CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_GOALIE_BG "Black" #include "variables.h"
#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_ "" */
/** Render a cell in the team selection treeview. /** Render a cell in the team selection treeview.
@see The GTK reference. */ @see The GTK reference. */
@ -57,9 +20,6 @@ treeview_cell_team_selection(GtkTreeViewColumn *col,
gint column = GPOINTER_TO_INT(user_data); gint column = GPOINTER_TO_INT(user_data);
gpointer team_pointer; 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); gtk_tree_model_get(model, iter, column, &team_pointer, -1);
if(column == 2) if(column == 2)
@ -68,8 +28,7 @@ treeview_cell_team_selection(GtkTreeViewColumn *col,
g_warning("treeview_cell_team_selection: unknown column: %d\n", column); 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. /** Render an integer. This is only so that we know when to draw nothing. */
@see #CONSTANT_TREEVIEW_CELL_INT_EMPTY */
void void
treeview_cell_int_to_cell(GtkTreeViewColumn *col, treeview_cell_int_to_cell(GtkTreeViewColumn *col,
GtkCellRenderer *renderer, GtkCellRenderer *renderer,
@ -81,12 +40,12 @@ treeview_cell_int_to_cell(GtkTreeViewColumn *col,
gint value; gint value;
gchar buf[SMALL]; gchar buf[SMALL];
if(strcmp(font_name->str, "0") != 0) if(strcmp(usr(current_user).font_name->str, "0") != 0)
g_object_set(renderer, "font", font_name->str, NULL); g_object_set(renderer, "font", usr(current_user).font_name->str, NULL);
gtk_tree_model_get(model, iter, column, &value, -1); 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, ""); strcpy(buf, "");
else else
sprintf(buf, "%d", value); sprintf(buf, "%d", value);
@ -109,11 +68,11 @@ treeview_cell_player_to_cell(GtkTreeViewColumn *col,
bg_color[SMALL]; bg_color[SMALL];
Player *pl; Player *pl;
if(strcmp(font_name->str, "0") != 0) if(strcmp(usr(current_user).font_name->str, "0") != 0)
g_object_set(renderer, "font", font_name->str, NULL); g_object_set(renderer, "font", usr(current_user).font_name->str, NULL);
strcpy(fg_color, "black"); strcpy(fg_color, const_str("string_treeview_cell_color_default_foreground"));
strcpy(bg_color, "white"); strcpy(bg_color, const_str("string_treeview_cell_color_default_background"));
strcpy(buf, ""); strcpy(buf, "");
gtk_tree_model_get(model, iter, column, &pl, -1); 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); treeview_cell_player_pos_to_cell(renderer, buf, pl->pos);
break; break;
case PLAYER_LIST_ATTRIBUTE_CSKILL: case PLAYER_LIST_ATTRIBUTE_CSKILL:
sprintf(buf, "%d", pl->cskill); treeview_cell_player_cskill_to_cell(renderer, buf, pl);
break; break;
case PLAYER_LIST_ATTRIBUTE_SKILL: case PLAYER_LIST_ATTRIBUTE_SKILL:
sprintf(buf, "%d", pl->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)); sprintf(buf, "%d", (gint)rint((gfloat)pl->age / 52));
break; break;
case PLAYER_LIST_ATTRIBUTE_ETAL: case PLAYER_LIST_ATTRIBUTE_ETAL:
sprintf(buf, "%d", pl->etal); sprintf(buf, "%d", pl->etal[usr(current_user).scout % 10]);
break; break;
case PLAYER_LIST_ATTRIBUTE_VALUE: case PLAYER_LIST_ATTRIBUTE_VALUE:
misc_print_grouped_int(pl->value, buf, FALSE); 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); sprintf(buf, "%.1f", (gfloat)contract_time / 52);
if(contract_time < CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_CONTRACT_BELOW3) if(contract_time < const_int("int_treeview_cell_limit_player_contract_below3"))
g_object_set(renderer, "foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_CONTRACT_BELOW3, NULL); g_object_set(renderer, "foreground",
else if(contract_time < CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_CONTRACT_BELOW2) const_str("string_treeview_cell_color_player_contract_below3"), NULL);
g_object_set(renderer, "foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_CONTRACT_BELOW2, NULL); else if(contract_time < const_int("int_treeview_cell_limit_player_contract_below2"))
else if(contract_time < CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_CONTRACT_BELOW1) g_object_set(renderer, "foreground",
g_object_set(renderer, "foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_CONTRACT_BELOW1, NULL); 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 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. /** Render a cell of player yellow cards.
@ -241,34 +204,29 @@ treeview_cell_player_cards_to_cell(gchar *buf, const Player *pl)
void void
treeview_cell_player_status_to_cell(GtkCellRenderer *renderer, gchar *buf, const Player *pl) treeview_cell_player_status_to_cell(GtkCellRenderer *renderer, gchar *buf, const Player *pl)
{ {
gint i; gint ban = player_is_banned(pl);
Fixture *fix = team_get_next_fixture(pl->team);
if(pl->health != PLAYER_INJURY_NONE) if(pl->health != PLAYER_INJURY_NONE)
{ {
sprintf(buf, _("INJ(%d)"), pl->recovery); sprintf(buf, _("INJ(%d)"), pl->recovery);
g_object_set(renderer, "background", g_object_set(renderer, "background",
CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_INJURY, NULL); const_str("string_treeview_cell_color_player_injury"), NULL);
return; return;
} }
if(fix == NULL) if(ban > 0)
{ {
strcpy(buf, "OK"); sprintf(buf, _("BAN(%d)"), ban);
return; g_object_set(renderer, "background",
const_str("string_treeview_cell_color_player_banned"), NULL);
} }
else
strcpy(buf, _("OK"));
for(i=0;i<pl->cards->len;i++) if(ban == -1)
if(g_array_index(pl->cards, PlayerCard, 0).clid == fix->clid) g_object_set(renderer, "background",
{ const_str("string_treeview_cell_color_player_yellow_danger"), NULL);
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");
} }
/** Render a cell of player games or goals. /** 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); sprintf(buf, "%d%%", fitness);
if(fitness < CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_FITNESS_BELOW3) if(fitness < const_int("int_treeview_cell_limit_player_fitness_below3"))
g_object_set(renderer, "foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_FITNESS_BELOW3, NULL); g_object_set(renderer, "foreground",
else if(fitness < CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_FITNESS_BELOW2) const_str("string_treeview_cell_color_player_fitness_below3"), NULL);
g_object_set(renderer, "foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_FITNESS_BELOW2, NULL); else if(fitness < const_int("int_treeview_cell_limit_player_fitness_below2"))
else if(fitness < CONSTANT_TREEVIEW_CELL_LIMIT_PLAYER_FITNESS_BELOW1) g_object_set(renderer, "foreground",
g_object_set(renderer, "foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_FITNESS_BELOW1, NULL); 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 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. /** 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: default:
strcpy(buf, "G"); strcpy(buf, "G");
g_object_set(renderer, "background", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_GOALIE_BG, g_object_set(renderer, "background",
"foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_GOALIE_FG, NULL); const_str("string_treeview_cell_color_player_pos_goalie_bg"),
"foreground",
const_str("string_treeview_cell_color_player_pos_goalie_fg"), NULL);
break; break;
case PLAYER_POS_DEFENDER: case PLAYER_POS_DEFENDER:
strcpy(buf, "D"); strcpy(buf, "D");
g_object_set(renderer, "background", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_DEFENDER_BG, g_object_set(renderer, "background",
"foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_DEFENDER_FG, NULL); const_str("string_treeview_cell_color_player_pos_defender_bg"),
"foreground",
const_str("string_treeview_cell_color_player_pos_defender_fg"), NULL);
break; break;
case PLAYER_POS_MIDFIELDER: case PLAYER_POS_MIDFIELDER:
strcpy(buf, "M"); strcpy(buf, "M");
g_object_set(renderer, "background", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_MIDFIELDER_BG, g_object_set(renderer, "background",
"foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_MIDFIELDER_FG, NULL); const_str("string_treeview_cell_color_player_pos_midfielder_bg"),
"foreground",
const_str("string_treeview_cell_color_player_pos_midfielder_fg"), NULL);
break; break;
case PLAYER_POS_FORWARD: case PLAYER_POS_FORWARD:
strcpy(buf, "F"); strcpy(buf, "F");
g_object_set(renderer, "background", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_FORWARD_BG, g_object_set(renderer, "background",
"foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_POS_FORWARD_FG, NULL); const_str("string_treeview_cell_color_player_pos_forward_bg"),
"foreground",
const_str("string_treeview_cell_color_player_pos_forward_fg"), NULL);
break; break;
} }
} }
@ -375,12 +345,20 @@ void
treeview_cell_player_cskill_to_cell(GtkCellRenderer *renderer, gchar *buf, const Player *pl) treeview_cell_player_cskill_to_cell(GtkCellRenderer *renderer, gchar *buf, const Player *pl)
{ {
sprintf(buf, "%d", (gint)rint((gfloat)pl->cskill * sprintf(buf, "%d", (gint)rint((gfloat)pl->cskill *
powf((gfloat)pl->fitness, powf((gfloat)pl->fitness / 100,
CONSTANT_PLAYER_FITNESS_IMPACT_ON_SKILL))); const_float("float_player_fitness_impact_on_skill"))));
if(pl->cskill < pl->skill) if(pl->cskill < pl->skill)
g_object_set(renderer, "background", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_BAD_CSKILL_BG, g_object_set(renderer, "background",
"foreground", CONSTANT_TREEVIEW_CELL_COLOR_PLAYER_BAD_CSKILL_FG, NULL); 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. */ /** 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) gpointer user_data)
{ {
gint i, result[2];
gint column = treeview_get_col_number_column(col); gint column = treeview_get_col_number_column(col);
gchar buf[SMALL]; gchar buf[SMALL];
Fixture *fix; Fixture *fix = NULL;
LiveGameUnit *unit = NULL;
if(strcmp(font_name->str, "0") != 0) if(strcmp(usr(current_user).font_name->str, "0") != 0)
g_object_set(renderer, "font", font_name->str, NULL); g_object_set(renderer, "font", usr(current_user).font_name->str, NULL);
strcpy(buf, ""); strcpy(buf, "");
gtk_tree_model_get(model, iter, column, &fix, -1); if(column == 1 || column == 3)
if(fix != NULL)
{ {
for(i=0;i<2;i++) gtk_tree_model_get(model, iter, column, &fix, -1);
result[i] = math_sum_int_array(fix->result[i], 3); sprintf(buf, "<span %s>%s</span>",
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, "<span %s>%d : %d</span>",
const_str("string_treeview_cell_live_game_result_attributes"),
unit->result[0], unit->result[1]);
if(column== 1 || column == 3)
sprintf(buf, "<span %s>%s</span>", CONSTANT_TREEVIEW_CELL_LIVE_GAME_RESULT_ATTRIBUTES,
fix->teams[column == 3]->name->str);
else
sprintf(buf, "<span %s>%d : %d</span>", CONSTANT_TREEVIEW_CELL_LIVE_GAME_RESULT_ATTRIBUTES,
result[0], result[1]);
} }
g_object_set(renderer, "markup", buf, NULL); g_object_set(renderer, "markup", buf, NULL);

View File

@ -2,10 +2,6 @@
#define TREEVIEW_CELL_H #define TREEVIEW_CELL_H
#include "bygfoot.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 void
treeview_cell_team_selection(GtkTreeViewColumn *col, treeview_cell_team_selection(GtkTreeViewColumn *col,
@ -15,7 +11,6 @@ treeview_cell_team_selection(GtkTreeViewColumn *col,
gpointer user_data); gpointer user_data);
/** Render an integer. This is only so that we know when to draw nothing. */
void void
treeview_cell_int_to_cell(GtkTreeViewColumn *col, treeview_cell_int_to_cell(GtkTreeViewColumn *col,
GtkCellRenderer *renderer, GtkCellRenderer *renderer,
@ -23,7 +18,6 @@ treeview_cell_int_to_cell(GtkTreeViewColumn *col,
GtkTreeIter *iter, GtkTreeIter *iter,
gpointer user_data); gpointer user_data);
/** Render a player list cell. */
void void
treeview_cell_player_to_cell(GtkTreeViewColumn *col, treeview_cell_player_to_cell(GtkTreeViewColumn *col,
GtkCellRenderer *renderer, GtkCellRenderer *renderer,
@ -56,4 +50,7 @@ treeview_cell_live_game_result(GtkTreeViewColumn *col,
GtkTreeIter *iter, GtkTreeIter *iter,
gpointer user_data); gpointer user_data);
void
treeview_cell_player_cskill_to_cell(GtkCellRenderer *renderer, gchar *buf, const Player *pl);
#endif #endif

View File

@ -1,80 +1,121 @@
#include "free.h"
#include "league.h" #include "league.h"
#include "maths.h" #include "maths.h"
#include "option.h"
#include "player.h" #include "player.h"
#include "support.h" #include "support.h"
#include "team.h" #include "team.h"
#include "user.h" #include "user.h"
/** These determine how the initial money of the user /** Create a new user with default values. */
depends on the size of the stadium. */ User
#define CONSTANT_INITIAL_MONEY_LOWER 80 user_new(void)
#define CONSTANT_INITIAL_MONEY_UPPER 110 {
User new;
/** Move the user's team to top or bottom league
at the beginning of a new game and set up the user's team. */ new.name = g_string_new("NONAME");
void new.font_name = g_string_new("0");
user_set_up_my_team_new_game(GtkWidget *widget) 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]; gchar buf[SMALL];
gint rndom, max, lig_idx = -1; gint rndom, max, lig_idx = -1;
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton2))) if(user->scout == 0)
user_set_up_my_team(); user_set_up_team(user);
else else
{ {
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(radiobutton1)) && if(user->scout == 1 &&
lig(0).id != my_team->clid) lig(0).id != user->tm->clid)
lig_idx = 0; 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; lig_idx = ligs->len - 1;
max = lig(lig_idx).teams->len - 1; max = lig(lig_idx).teams->len - 1;
rndom = math_rndi(0, max); rndom = math_rndi(0, max);
sprintf(buf, "%s", g_array_index(lig(lig_idx).teams, Team, rndom).name->str); 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", g_string_printf(g_array_index(lig(lig_idx).teams, Team, rndom).name, "%s",
my_team->name->str); user->tm->name->str);
g_string_printf(my_team->name, "%s", buf); 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 void
user_set_up_my_team(void) user_set_up_team(User *user)
{ {
gint i, j; gint i, j;
for(i=PLAYER_POS_DEFENDER; i<=PLAYER_POS_FORWARD; i++) for(i=PLAYER_POS_DEFENDER; i<=PLAYER_POS_FORWARD; i++)
for(j=my_team->players->len - 1; j > 10; j--) for(j=user->tm->players->len - 1; j > 10; j--)
if(g_array_index(my_team->players, Player, j).pos == i) 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; 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 void
user_set_up_finances(void) user_set_up_finances(User *user)
{ {
gint i; gint i;
for(i=0; i<FIN_END;i++) for(i=0; i<FIN_END;i++)
finances[i] = 0; user->finances[i] = 0;
finances[FIN_MONEY] = user->finances[FIN_MONEY] =
math_round_integer(my_team->stadium.capacity * math_round_integer(user->tm->stadium.capacity *
math_rndi(CONSTANT_INITIAL_MONEY_LOWER, math_rndi(const_int("int_initial_money_lower"),
CONSTANT_INITIAL_MONEY_UPPER), 2); 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;i<user->options->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++;
}
} }

View File

@ -2,15 +2,28 @@
#define USER_H #define USER_H
#include "bygfoot.h" #include "bygfoot.h"
#include "user_struct.h"
#include "variables.h" #include "variables.h"
void /** Convenience abbrevs. */
user_set_up_my_team_new_game(GtkWidget *widget); #define usr(i) g_array_index(users, User, i)
void void
user_set_up_my_team(void); user_set_up_team_new_game(User *user);
void 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 #endif

33
src/user_struct.h Normal file
View File

@ -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

View File

@ -3,6 +3,7 @@
#include "live_game_struct.h" #include "live_game_struct.h"
#include "player_struct.h" #include "player_struct.h"
#include "team_struct.h" #include "team_struct.h"
#include "user_struct.h"
/** /**
* The main variable of the game. * The main variable of the game.
@ -10,55 +11,44 @@
*/ */
Country country; 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. /** The season, week and week round numbers.
We keep track of the time in the game with these variables. */ We keep track of the time in the game with these variables. */
gint season, week, week_round; gint season, week, week_round;
/** The user's scout and physio qualities. /** Array of options that get read from
@see #Quality */ bygfoot.conf. */
gint scout, physio; GArray *options;
/** Array of constants that get read from the constans
/** The user's finances. @see #FinanceValue */ file specified in bygfoot.conf. */
gint finances[FIN_END]; GArray *constants;
/** 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];
/** The array containing players to be transfered. /** The array containing players to be transfered.
@see TransferPlayer */ @see TransferPlayer */
GArray *transfer_list; 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. */ /** 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. */ /** An array of player names that we keep in memory. */
GPtrArray *player_names; GPtrArray *player_names;
/** The pointer to the main window of the game. */ /** The struct containing the window pointers. */
GtkWidget *main_window; Windows window;
/** With this we keep track of the number of popup /** With this we keep track of the number of popup
windows and make the main window sensitive or windows and make the main window sensitive or
insensitive, depending. */ insensitive, depending. */
gint popups_active; 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). */ /** The variable for non-user games (which aren't shown). */
LiveGame live_game_temp; 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;

View File

@ -1,9 +1,12 @@
#include "file.h" #include "file.h"
#include "free.h" #include "free.h"
#include "game_gui.h"
#include "interface.h" #include "interface.h"
#include "main.h" #include "main.h"
#include "misc_interface.h" #include "misc_interface.h"
#include "option.h"
#include "support.h" #include "support.h"
#include "user.h"
#include "variables.h" #include "variables.h"
#include "window.h" #include "window.h"
@ -36,27 +39,18 @@ window_show_startup(void)
free_g_string_array(&dir_contents); 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. /** Set 'Bygfoot x.y.z' into the title of a window.
@param window The window widget pointer. @param window The window widget pointer.
@see #VERS */ @see #VERS */
GtkWidget* GtkWidget*
window_set_version(GtkWidget *window) window_set_version(GtkWidget *wind)
{ {
gchar buf[SMALL]; gchar buf[SMALL];
sprintf(buf, "Bygfoot Football Manager %s", VERS); 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. /** Create and show a window. Which one depends on the argument.
@ -67,62 +61,76 @@ window_set_version(GtkWidget *window)
GtkWidget* GtkWidget*
window_create(gint window_type) window_create(gint window_type)
{ {
GtkWidget *window = NULL; GtkWidget *wind = NULL;
popups_active++; popups_active++;
switch(window_type) switch(window_type)
{ {
default: default:
if(main_window == NULL) if(window.main == NULL)
{ {
window = create_main_window(); window.main = create_main_window();
popups_active--; popups_active--;
wind = window.main;
game_gui_print_message("Welcome to Bygfoot "VERS);
} }
else else
window = main_window; wind = window.main;
window_set_version(window);
break; break;
case WINDOW_STARTUP: case WINDOW_STARTUP:
window = create_window_startup(); if(window.startup != NULL)
window_set_version(window); g_warning("window_create: called on already existing window\n");
else
window.startup = create_window_startup();
wind = window.startup;
break; break;
case WINDOW_LIVE: case WINDOW_LIVE:
window = create_window_live(); if(window.live != NULL)
window_set_version(window); 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_set_value(
GTK_SPIN_BUTTON(lookup_widget(window, "spinbutton_speed")), GTK_SPIN_BUTTON(lookup_widget(wind, "spinbutton_speed")),
(gfloat)options[OPT_LIVE_SPEED]); (gfloat)option_int("int_opt_user_live_game_speed", usr(stat2).options));
break; 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) if(popups_active != 0 && window.main != NULL)
gtk_widget_set_sensitive(main_window, FALSE); gtk_widget_set_sensitive(window.main, FALSE);
return window; return wind;
} }
/** Destroy a window widget and set the popups and /** Destroy a window widget and set the popups and
main window sensitivity correctly. main window sensitivity correctly.
@param window The window we destroy. */ @param window The window we destroy. */
void void
window_destroy(GtkWidget **window) window_destroy(GtkWidget **wind)
{ {
if(*window == NULL) if(*wind == NULL)
return; return;
if(*window != main_window) if(*wind != window.main)
{ {
popups_active--; popups_active--;
if(popups_active == 0 && main_window != NULL) if(popups_active == 0 && window.main != NULL)
gtk_widget_set_sensitive(main_window, TRUE); gtk_widget_set_sensitive(window.main, TRUE);
} }
gtk_widget_destroy(*window); gtk_widget_destroy(*wind);
*window = NULL; *wind = NULL;
} }

View File

@ -10,15 +10,13 @@ enum Windows
WINDOW_MAIN = 0, WINDOW_MAIN = 0,
WINDOW_STARTUP, WINDOW_STARTUP,
WINDOW_LIVE, WINDOW_LIVE,
WINDOW_STARTUP_USERS,
WINDOW_END WINDOW_END
}; };
void void
window_show_startup(void); window_show_startup(void);
void
window_show_main(void);
GtkWidget* GtkWidget*
window_set_version(GtkWidget *window); window_set_version(GtkWidget *window);

View File

@ -2,6 +2,7 @@
#include "league.h" #include "league.h"
#include "misc.h" #include "misc.h"
#include "team.h" #include "team.h"
#include "table.h"
#include "variables.h" #include "variables.h"
#include "xml_league.h" #include "xml_league.h"
@ -159,8 +160,6 @@ xml_league_read_end_element (GMarkupParseContext *context,
gpointer user_data, gpointer user_data,
GError **error) GError **error)
{ {
TableElement new_table_element;
if(strcmp(element_name, TAG_NAME) == 0 || if(strcmp(element_name, TAG_NAME) == 0 ||
strcmp(element_name, TAG_SHORT_NAME) == 0 || strcmp(element_name, TAG_SHORT_NAME) == 0 ||
strcmp(element_name, TAG_SID) == 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) strcmp(element_name, TAG_PROM_REL_ELEMENT_DEST_SID) == 0)
state = STATE_PROM_REL_ELEMENT; state = STATE_PROM_REL_ELEMENT;
else if(strcmp(element_name, TAG_TEAM) == 0) else if(strcmp(element_name, TAG_TEAM) == 0)
{
state = STATE_TEAMS; 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) else if(strcmp(element_name, TAG_TEAM_NAME) == 0)
state = STATE_TEAM; state = STATE_TEAM;
else if(strcmp(element_name, TAG_LEAGUE) != 0) else if(strcmp(element_name, TAG_LEAGUE) != 0)
@ -275,6 +269,8 @@ xml_league_read_text (GMarkupParseContext *context,
void void
xml_league_read(const gchar *league_name, GArray *leagues) xml_league_read(const gchar *league_name, GArray *leagues)
{ {
gint i;
TableElement new_table_element;
gchar *file_name = file_find_support_file(league_name); gchar *file_name = file_find_support_file(league_name);
GMarkupParser parser = {xml_league_read_start_element, GMarkupParser parser = {xml_league_read_start_element,
xml_league_read_end_element, xml_league_read_end_element,
@ -313,6 +309,12 @@ xml_league_read(const gchar *league_name, GArray *leagues)
g_free(file_contents); g_free(file_contents);
g_array_append_val(leagues, new_league); g_array_append_val(leagues, new_league);
for(i=0;i<lig(ligs->len - 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 else
{ {

View File

@ -1,87 +1,22 @@
# Bygfoot Football Manager # Bygfoot Football Manager
# Configuration file # Global configuration file
# Most of these options are uncommented because their meaning # Most of these options are uncommented because their meaning
# is rather clear if you take a look at the options window in the game. # is rather clear if you take a look at the options window in the game.
confirm_new_week_round 1 int_opt_confirm_new_week_round 1
confirm_unfit 1 int_opt_confirm_quit 1
confirm_quit 1 int_opt_save_will_ovewrite 1
save_will_ovewrite 1 int_opt_maximize_main_window 1
show_live_game 1 int_opt_prefer_messages 0
live_game_speed 0 int_opt_autosave 0
show_tendency_bar 1 int_opt_autosave_interval 3
maximize_main_window 1 int_opt_compress 1
notify_transfer 0 int_opt_objective 1
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
# whether some debugging info's shown (in the console) # 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

View File

@ -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'

View File

@ -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