Copy of the last stable Version from CVS

This commit is contained in:
mrsmola 2007-01-17 14:51:47 +00:00 committed by Tom Stellard
parent 82bb59b25c
commit 4a518680b3
787 changed files with 148320 additions and 0 deletions

View File

@ -0,0 +1,27 @@
Bygfoot Football Manager
AUTHOR: Gyozo Both (gyboth@bygfoot.com)
http://bygfoot.sourceforge.net
Homepage designer:
Jose Geraldo Gouvea (Brazil)
Icons:
Mark Symonds (Australia)
Windows port:
Simon Binns (Australia)
Patches and ideas:
Mark Calderbank (England), Michal Rudolf (Poland)
Country file contributors:
See Help -> Contributors.
Translators:
See Help -> Contributors.
Debian maintainer:
Isaac Clerencia (Spain)
FreeBSD port:
Pav Lucistnik (Czech Republic)

View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

View File

@ -0,0 +1,444 @@
9/6/2006: v2.1.0
- fixed some minor bugs
- updated German definition
6/4/2006: v2.0.0
- updated English, Scottish and Irish definitions (thanks to Mark)
- updated German definition
- fixed a bug that prevented 1st league CPU teams from growing
stronger when the user became champion
- fixed some zenity-related errors in the bygfoot-update script
- updated translations
- fixed a bug that lead to a crash on AMD64-systems
- corrected some spelling mistakes in the English commentary file
(Mark)
5/12/2006: v1.9.6
- fixed a bug that made the main window remain insensitive after
opening and closing some other window
- fixed a bug that crashed the game when loading memorable matches
- fixed some nonsensical decisions in the strategy xml files
- updated Irish definition (Mark Calderbank)
- fixed a bug that crashed the game if you changed boost/style in
the live game window near the end of the game
- fixed a bug that made the WC 2006 unplayable (the final in
Germany got skipped)
3/24/2006: v1.9.5
- fixed a bug that led to a 'cup not found' exit after a few
seasons
- fixed a minor youth academy bug
- added a splash screen
- added definition for the Euro 2008
- added a definition for Sweden and a Swedish translation (thanks
to Daniel Nylander)
12/22/2005: v1.9.4
- fixed an annoying crash that occurs every time a user wins a cup or
loses a cup final
- fixed a bug that prevented the Windows version from saving
correctly
12/14/2005: v1.9.3
- updated German country definition (thanks to Sebastian Vöcking,
Michael Trent)
- added strategies for CPU teams
- added option to randomise teams in cups in the startup window
(relevant for the World Cup definition, mainly)
- added search popup to the teams list in the startup window (just
type a few letters to begin search)
- added betting
- minor bugfixes
- boost costs money
- reworked the Brazilian definition, making it more like it is in
reality
- added some nice pictures to the progress bar shown when
calculating results or loading/saving games
- added job exchange (including jobs from abroad!)
- added definition for Greece (thanks to Theodore Dimitriadis)
- minor usability improvements, involving the startup window and
right/left-clicking on players
- removed source update feature from the bygfoot-update script
(use the CVS version to live on the bleeding edge)
10/16/2005: v1.9.2
- fixed some minor bugs
- updated translations
- added Spanish and Chinese translations
- switched from 'arj' to GNU 'zip' in the Windows port
- added player streaks (hot/cold)
- added definition for the Netherlands (thanks to Zwakstroom)
- added definition for the World Cup 2006 Germany
- minor definition system improvements
- window geometry can be saved
- boost and style change 'on the fly' during live games
- added season results view (Figures -> Season results)
- added command line options
09/10/2005: v1.9.1
- updated German and Dutch translations
- added Polish (complete), French (almost complete), Romanian
(a.c.) and Bulgarian (a.c.) translations
- added i18n support for the binary package
- transfer offers are remembered
- added sponsorship money
- fixed some minor bugs
- improved live game commentary (moved to XML files, added
conditions etc.)
- added country definitions for Australia, Bulgaria, Victoria
(Australia), Spain and Serbia&Montenegro
- added youth academy
- added experimental Windows port (thanks to Simon Binns)
- improved definition system
- added memorable matches feature
06/18/2005: v1.9.0
- complete rewriting of the game, too many changes to count them
and keep them in mind. among the most important ones are:
- real interactive live game
- hotseat multiplayer
- extremely flexible and customizable country definitions
- country-specific player names
- constants determining game behaviour are loaded from a text file
making it easy to change and fine-tune the game
06/18/2005: v1.8.2
- corrected a bug in the update script
- fixed the job offer bug
- added some more keyboard shortcuts
- corrected a 'ghost-player'-bug after a transfer
01/30/2005: v1.8.1
- added Dutch translation and country file for Belgium (thanks to
ATD)
- fixed a bug that prevented loading of custom country files
- fixed a season objective bug
- fixed a floating point bug (thanks to Ken Brush)
01/30/2005: v1.8.0 (changes compared to 1.6.3)
- added a lot of new and fine icons (thanks to Vector)
- added GeoVah's season objective patch (thanks, GeoVah)
- added possibility to disable savegame compression
- stadium events are less harsh
- there are more players from lower leagues on the transfer list
- switched the load/save system to XML, making it slower but more
flexible (thanks to Arnaud Le Rouzic for valuable help)
- improved the options window (tabs make it more orderly now)
- added second player list (also with tabs)
- complete Bygfoot packages can be downloaded with the update
script now
- added gettext support and French, German, Russian, Hungarian,
Romanian and Portuguese translations (see AUTHORS)
- fixed a bug concerning own goals in live games
- added player and team 'histories'
- added boost feature
- added country file for Mexico (thanks to Arturo Mendez)
- added country files for Chile (thanks to Julio Saldivar)
- improved the update script
- added a simple gui for the script
- added updated country file for Italy (thanks to Marco Fabbri)
- fixed a bug that led to no ticket income for cup games
- fixed a bug that occurred when you made a stadium enlargement
over several weeks
- replaced official team names with city names because of
trademark issues (the official names can be downloaded from
http://www.bygfoot.com)
- removed official player names because of the same reason (you
can still download them from the homepage)
- added injuries and cards display for opponent teams in the match
summary
- clicking on a team name in the tables shows the team's player list
- clicking on a fixture shows the player list of one of the teams,
depending on the mouse button you use
- job offers show a lot more information on the team offering the
job
- a player can suffer an injury that forces him to retire
- added own goals and penalties in regulation and extra time
- added reasons why a player was banned (thanks to Tom Chance for
the correct football expressions)
- added player and some more team awards (with prize money) at the
end of a season
NOTE: The 1.8 branch is not savegame-compatible to the 1.6.x
versions.
11/23/2004: v1.7.3
- switched the load/save system to XML, making it slower but more
flexible (thanks to Arnaud Le Rouzic for valuable help)
- improved the options window (tabs make it more orderly now)
- added second player list (also with tabs)
- complete Bygfoot packages can be downloaded with the update
script now
- added gettext support and French, German, Russian, Hungarian,
Romanian and Portuguese translations
- fixed a bug concerning own goals in live games
- added player and team 'histories'
- added boost feature
11/23/2004: v1.6.3
- fixed a bug that caused the game to interpret promotion game
home/away results incorrectly
- added translations for the interface (so the game's partly
translated)
09/30/2004: v1.7.2
- added country file for Mexico (thanks to Arturo Mendez)
- improved the update script
- added a simple gui for the script
- added updated country file for Italy (thanks to Marco Fabbri)
- fixed a bug that led to no ticket income for cup games
- fixed a bug that occurred when you made a stadium enlargement
over several weeks
- replaced official team names with city names because of
trademark issues (the official names can be downloaded from
http://www.bygfoot.com)
- removed official player names because of the same reason (you
can still download them from the homepage)
09/30/2004: v1.6.2
- improved the update script
- added updated country file for Italy (thanks to Marco Fabbri)
- fixed a bug that led to no ticket income for cup games
- fixed a bug that occurred when you made a stadium enlargement
over several weeks
- replaced official team names with city names because of
trademark issues (the official names can be downloaded from
http://www.bygfoot.com)
- removed official player names because of the same reason (you
can still download them from the homepage)
09/09/2004: v1.6.1 + 1.7.1
- corrected a bug that caused the game to hang if live games were
switched on and there were no games to play
- added an online update script for the source package
('bygfoot-update')
09/05/2004: v1.7.0
- added injuries and cards display for opponent teams in the match
summary
- clicking on a team name in the tables shows the team's player list
- clicking on a fixture shows the player list of one of the teams,
depending on the mouse button you use
- job offers show a lot more information on the team offering the
job
- a player can suffer an injury that forces him to retire
- added own goals and penalties in regulation and extra time
- added reasons why a player was banned (thanks to Tom Chance for
the correct football expressions)
- added player and some more team awards (with prize money) at the
end of a season
09/05/2004: v1.6.0
- added possibility to have messages shown instead of popups
when possible
- added extended stadium capacity enlargement possibilities
- added possibility to fire a player
- added 'Player actions' button
- changed the current skill and fitness display a bit: current
skill is now the skill that's really used when computing games
(except for the home advantage factor); fitness can be 100% now
and is shown in different colors (thanks to arnaudus)
- corrected a minor display bug (you could see the updated rank in
the main window when playing two live games already after the
first one)
- added uninstall possibility for the src version
- added manpage
- added a configuration file:
$HOME/.bygfoot/text_files/bygfoot.conf; this way, your favourite
settings get loaded even if you start a new game
- added physician quality (like scout); better physician costs
more but players heal better on average
- healing time of players can be overestimated; until now it was
always underestimated (i.e. the player was injured _at least_ as
long as the expected recovery time)
- corrected a save/load bug that occurred when you saved a game
just before getting a new scout
NOTE: The 1.6 branch is not savegame-compatible to the 1.4.x
versions.
08/17/2004: v1.5.2
- added possibility to have messages shown instead of popups
when possible
- added extended stadium capacity enlargement possibilities
- added possibility to fire a player
- added 'Player actions' button
- changed the current skill and fitness display a bit: current
skill is now the skill that's really used when computing games
(except for the home advantage factor); fitness can be 100% now
and is shown in different colors (thanks to arnaudus)
- corrected a minor display bug (you could see the updated rank in
the main window when playing two live games already after the
first one)
08/17/2004: v1.4.3
- corrected the '1-2'-bug: you couldn't enter these two digits
into fields like the structure field because they were used as
keyboard shortcuts for browsing forward and back. browsing's done
with 'q' and 'w' now, and 'q' quits the game only when the browse
buttons aren't shown (e.g. in main menu mode)
- corrected some minor transfer list bugs (there seem to be
infinitely many of these :-( )
- fixed a bug that occurred when cup matches that ended drawn were
shown
- corrected a sorting bug (occurred when computing the tables)
07/12/2004: v1.4.2, v1.5.1
- corrected the transfer list bug
07/10/2004: v1.5.0
- added uninstall possibility for the src version
- added manpage
- added a configuration file:
$HOME/.bygfoot/text_files/bygfoot.conf; this way, your favourite
settings get loaded even if you start a new game
- added physician quality (like scout); better physician costs
more but players heal better on average
- healing time of players can be overestimated; until now it was
always underestimated (i.e. the player was injured _at least_ as
long as the expected recovery time)
NOTE: This version is unfortunately once again not
savegame-compatible to 1.4.0. I'm terribly sorry.
07/10/2004: v1.4.1
- corrected the freeze bug that occurred when you had a
$HOME/.bygfoot directory from an older Bygfoot version
- fixed bookmaker's tip bug (thanks to metoneca)
- changed that absurd 'physicist' to 'physio'
- reduced the damage a fire caused to your stadium
07/03/2004: v1.4.0
- added Michal Rudolf's country file for Poland
- added possibility to play in international cups only
(e.g. participate in Champions' League only, without playing
regular league games)
- you can see information on your next opponents in the right part
of the main window
- swapping two players automatically adapts team structure (but
you can switch this off, of course)
- as you can see: the version numbering has changed. no
alphas and omegas anymore!
- added export/import features to the Editor; you can export
individual teams to files and import such files into your local
team definitions file
- extended the filter rules for transfer list notification
- added Autosave option
- fixed a non-technical bug: european team names didn't
change at the beginning of a new season
- fixed a scrolling bug that occurred in the live game window when
penalties were shot
- added average skill labels in the main window
- players are put onto the transfer list by right-clicking instead
of left-clicking; left-clicking always swaps players now
- converted player names to lowercase (which sounds easier than it
is in reality; utf8 seems to have disadvantages, too)
- the 'Rearrange Team' button automatically changes the team
structure to the appropriate value
- savegames located in the $HOME/.bygfoot/saves directory can be
loaded from the command line without full path names
- country files located in one of the support files directories
(e.g. $HOME/.bygfoot/text_files) can be loaded with '-f filename'
without full path names
- fixed a money bug: you can pay debts with your drawing
credit now
- introduced playing style for cpu-teams (they always played
balanced until now)
- added variable interest rates for your debts (the more you owe,
the lower the interest rate)
- added possibility to display fixtures of all leagues
NOTE: This version is unfortunately not compatible anymore to
saved games of previous versions.
06/10/2004: v1.3 beta
- corrected a horrible bug in the prize money function (thanks to
Ken Brush)
- added possibility to change team names with the Editor
- added Jose Geraldo Gouvea's country file for Brazil
- fixed some compiler warnings
- fixed a bug that made it impossible to load a custom country
file from the team selection window
05/24/2004: v1.3 alpha
- first version including the Bygfoot Team Editor
- you can edit complete teams and store them in a text file
- switched to UTF-8 encoding: all text files are encoded that way,
so that almost any special character (eg. in a team or player
name) can be displayed correctly
- added Cristian Spoiala's country file for Romania
- fixed a bug that made it possible that you got hired by your own
team
- fixed a bug that occured when displaying a game result
- created several new source files so that the code is distributed
better now
05/07/2004: v1.1 beta
- added possibility to change the name of your team
- added possibility to filter transfer notifications by age
- added prize money for teams finishing 1st - 3rd in the league
- fixed a bug that caused players to have empty name when loading
games from the command line
- fixed a bug that led to poor attendance in cup games
- added unselect feature in the player list
- really good players appear less often on the transfer list
- added drawing credit
04/16/2004: v1.1 alpha 'Eurofoot'
- added some European leagues to choose from; the game
structure stays the same, though
- accordingly, the player names aren't just English ones anymore but
international ones
- improved player generation phase concerning speed: the game
starts much quicker now
- improved 'new week' functions; the results come even quicker
- you can create an own 'localisation' by copying and editing one
of the 'team_names_XX' files, so that you have custom team names
and league/cup names
- added an 'Undo' button
NOTE: This version is unfortunately not compatible anymore to
saved games of previous versions. This is because of the new
player and team names.
04/07/2004: v1.0 final 'Quickfoot'
- connected the skill level of European teams to the average level
of the Premiership so that it doesn't become too easy to win the
European Cups after a couple of seasons
- worked a bit on speed issues; the game should start a bit faster
and calculate the results quicker, too
02/24/2004: v1.0 beta
- stadium values may be increased twice a week now
- added some buttons to give easier access to tables and fixtures
- added quick options in the main window
- changed most of the finance issues: the ticket income is higher,
but the difference between players with similar propertiers
(skill etc.) in different leagues is much smaller now
- UEFA Cup is now harder to win
- fixed a bug that led to the same number of goal chances in every
game regardless of the individual teams that played (this made
it very hard for even the best teams to win predictably against
weaker opponents)
- fixed a bug that allowed players to have a talent above 9.9
- fixed a bug that caused the game to reject some normal save
files
- fixed a bug that made it less probable to sell a player the
better the scout was
- fixed a bug that caused a player with expected recovery time 11
to get healthy within a week
02/14/2004: v1.0 alpha
- first graphical version using GTK+ 2
- new features: - live game
- playing style (attack/defend)
- buy players not on the transferlist
01/02/2002 v0.5 pre-alpha, alpha and beta
- text-based version full of pointers and containing an
untraceable segfault

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,266 @@
Bygfoot Football Manager 1.9.0
AUTHOR: Gyozo Both (gyboth@bygfoot.com)
http://www.bygfoot.com
Further below you find the extensive description on how to use 'configure' and
'make' to build this package; for most users, however, the standard
three-step procedure
1. ./configure
2. make
3. (as root) make install
should work perfectly. The default install prefix is /usr/local;
you can override with './configure --prefix=your_prefix'.
I have also made the experience that giving 'configure' an
optimization flag 'configure CFLAGS=-O3' makes the binary smaller; it
should also make the game faster, but the difference is probably
not noticeable. '-Os' will make the executable even smaller.
If you'd like to remove the game, type 'make uninstall' (as root).
You'll need a more or less up-to-date system and some devel-packages
to be able to compile 'bygfoot':
- glib2
- gtk+2
- pango
- atk
- pkg-config
- freetype2.
If you don't have these, you should consider downloading one of the pre-compiled
versions (rpm, deb or simple bin).
#####################################################################
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
Foundation, Inc.
This file is free documentation; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. (Caching is
disabled by default to prevent problems with accidental use of stale
cache files.)
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You only need
`configure.ac' if you want to change it or regenerate `configure' using
a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. Run `./configure --help'
for details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not support the `VPATH'
variable, you have to compile the package for one architecture at a
time in the source code directory. After you have installed the
package for one architecture, use `make distclean' before reconfiguring
for another architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=PATH' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' cannot figure out
automatically, but needs to determine by the type of machine the package
will run on. Usually, assuming the package is built to be run on the
_same_ architectures, `configure' can figure that out, but if it prints
a message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the `--target=TYPE' option to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
will cause the specified gcc to be used as the C compiler (unless it is
overridden in the site shell script).
`configure' Invocation
======================
`configure' recognizes the following options to control how it
operates.
`--help'
`-h'
Print a summary of the options to `configure', and exit.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.

File diff suppressed because one or more lines are too long

View File

View File

@ -0,0 +1,36 @@
Bygfoot Football Manager UNKNOWN_VERSION
AUTHOR: Gyozo Both (gyboth@bygfoot.com)
http://bygfoot.sourceforge.net
DESCRIPTION
Bygfoot is a small and simple graphical football (a.k.a. soccer) manager game
featuring many international leagues and cups. You manage a team from one such
league: you form the team, buy and sell players, get promoted or relegated and
of course try to be successful.
INSTALLATION AND UPDATE
See INSTALL for instructions on how to install Bygfoot.
Have a look at UPDATE for instructions on how to keep your Bygfoot version
up-to-date easily.
BUG REPORTS AND PRAISE
If you like the game and have suggestions on how to improve it (keep in mind
that the game is kept simple on purpose, so don't suggest something like 'each
player should have separate skill-values for their right and left foot and you
should add the colour of their eye, too') or find bugs, write me to the above
address or submit a report on the website. You should describe the
circumstances of the occurence of the bug and whether you can reproduce it or
not. If there's an output, attaching it (unless it's a simple, hateful,
embarrassing segfault) might be helpful, too. If it's reproducible, it'd be
very helpful to attach a savegame.
Another way you can contribute to Bygfoot is to write a country file and send
me the result. See the forums at http://bygfoot.sourceforge.net/forum on help
and advice.

View File

@ -0,0 +1,39 @@
Bygfoot Football Manager
AUTHOR: Gyozo Both (gyboth@bygfoot.com)
http://www.bygfoot.com
This file tries to tell you how to use the CVS bygfoot-unstable versions.
1. If you'd just like to compile and play the game, you have to run
'./autogen.sh' in order to create the build files. Afterwards you can
compile the package just like any other src package with make and make
install. You'll need the following packages (as far as I know):
- glib2
- gtk+2
- pango
- atk
- pkg-config
- freetype2.
2. If you'd like to change the source code, but not the *interface* source
files, you can do it without problems. Please send me patches if you've
implemented interesting new features or corrected a bug.
3. Here's the trickiest part. The Bygfoot interface files are generated by
Glade 2 from the *.glade files (which are in XML format). You can get it
from http://glade.gnome.org. If you'd like to change a part of the
interface, you have to:
a) find out in which of the *.glade files the things you want to change
are. For instance, if you'd like to change something in the options window,
you'd have to use bygfoot_options.glade (ignore the *.gladep files).
b) open the file with glade-2.
c) edit the interface (by clicking around wildly with your mouse).
d) save the changes and generate the *interface* files.
d) recompile.
I hope this works for you. If not, please contact me.

View File

@ -0,0 +1,6 @@
Bygfoot Football Manager
AUTHOR: Gyozo Both (gyboth@bygfoot.com)
http://bygfoot.sourceforge.net
See this forum at the homepage:
http://bygfoot.sourceforge.net/phpBB2/viewforum.php?f=3

View File

@ -0,0 +1,25 @@
Bygfoot Football Manager
AUTHOR: Gyozo Both (gyboth@bygfoot.com)
http://bygfoot.sourceforge.net
The bygfoot-update script is located in the 'b-u' directory of the source
package (1.8 branch) or in the build directory (1.9 branch). After installing
with 'make install' it will also be copied to PREFIX/bin, PREFIX mostly being
/usr/local.
The RPM package installs the script to /usr/bin.
For the binary package, the script is located in the bygfoot-X.Y.Z-binary
directory.
Call the script with the '-h' or '--help' switch to see command line options.
You can use the script to
- keep your source package up-to-date using patches
- download new releases
- download official country file names (1.8 branch)
- get a CVS version.
If you have trouble or questions, email me or post at the forums:
http://bygfoot.sourceforge.net/phpBB2/index.php

View File

@ -0,0 +1,7 @@
#undef ENABLE_NLS
#undef HAVE_CATGETS
#undef HAVE_GETTEXT
#undef GETTEXT_PACKAGE
#undef HAVE_LC_MESSAGES
#undef HAVE_STPCPY
#undef HAVE_LIBSM

159
bygfoot_2.0.1_stable/autogen.sh Executable file
View File

@ -0,0 +1,159 @@
#!/bin/sh
# Run this to generate all the initial makefiles, etc.
srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.
DIE=0
if [ -n "$GNOME2_DIR" ]; then
ACLOCAL_FLAGS="-I $GNOME2_DIR/share/aclocal $ACLOCAL_FLAGS"
LD_LIBRARY_PATH="$GNOME2_DIR/lib:$LD_LIBRARY_PATH"
PATH="$GNOME2_DIR/bin:$PATH"
export PATH
export LD_LIBRARY_PATH
fi
(test -f $srcdir/configure.in) || {
echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
echo " top-level package directory"
exit 1
}
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`autoconf' installed."
echo "Download the appropriate package for your distribution,"
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
DIE=1
}
(grep "^AC_PROG_INTLTOOL" $srcdir/configure.in >/dev/null) && {
(intltoolize --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`intltool' installed."
echo "You can get it from:"
echo " ftp://ftp.gnome.org/pub/GNOME/"
DIE=1
}
}
(grep "^AM_PROG_XML_I18N_TOOLS" $srcdir/configure.in >/dev/null) && {
(xml-i18n-toolize --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`xml-i18n-toolize' installed."
echo "You can get it from:"
echo " ftp://ftp.gnome.org/pub/GNOME/"
DIE=1
}
}
(grep "^AM_PROG_LIBTOOL" $srcdir/configure.in >/dev/null) && {
(libtool --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`libtool' installed."
echo "You can get it from: ftp://ftp.gnu.org/pub/gnu/"
DIE=1
}
}
(grep "^AM_GLIB_GNU_GETTEXT" $srcdir/configure.in >/dev/null) && {
(grep "sed.*POTFILES" $srcdir/configure.in) > /dev/null || \
(glib-gettextize --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`glib' installed."
echo "You can get it from: ftp://ftp.gtk.org/pub/gtk"
DIE=1
}
}
(automake --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`automake' installed."
echo "You can get it from: ftp://ftp.gnu.org/pub/gnu/"
DIE=1
NO_AUTOMAKE=yes
}
# if no automake, don't bother testing for aclocal
test -n "$NO_AUTOMAKE" || (aclocal --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: Missing \`aclocal'. The version of \`automake'"
echo "installed doesn't appear recent enough."
echo "You can get automake from ftp://ftp.gnu.org/pub/gnu/"
DIE=1
}
if test "$DIE" -eq 1; then
exit 1
fi
if test -z "$*"; then
echo "**Warning**: I am going to run \`configure' with no arguments."
echo "If you wish to pass any to it, please specify them on the"
echo \`$0\'" command line."
echo
fi
case $CC in
xlc )
am_opt=--include-deps;;
esac
for coin in `find $srcdir -path $srcdir/CVS -prune -o -name configure.in -print`
do
dr=`dirname $coin`
if test -f $dr/NO-AUTO-GEN; then
echo skipping $dr -- flagged as no auto-gen
else
echo processing $dr
( cd $dr
aclocalinclude="$ACLOCAL_FLAGS"
if grep "^AM_GLIB_GNU_GETTEXT" configure.in >/dev/null; then
echo "Creating $dr/aclocal.m4 ..."
test -r $dr/aclocal.m4 || touch $dr/aclocal.m4
echo "Running glib-gettextize... Ignore non-fatal messages."
echo "no" | glib-gettextize --force --copy
echo "Making $dr/aclocal.m4 writable ..."
test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4
fi
if grep "^AC_PROG_INTLTOOL" configure.in >/dev/null; then
echo "Running intltoolize..."
intltoolize --copy --force --automake
fi
if grep "^AM_PROG_XML_I18N_TOOLS" configure.in >/dev/null; then
echo "Running xml-i18n-toolize..."
xml-i18n-toolize --copy --force --automake
fi
if grep "^AM_PROG_LIBTOOL" configure.in >/dev/null; then
if test -z "$NO_LIBTOOLIZE" ; then
echo "Running libtoolize..."
libtoolize --force --copy
fi
fi
echo "Running aclocal $aclocalinclude ..."
aclocal $aclocalinclude
if grep "^AM_CONFIG_HEADER" configure.in >/dev/null; then
echo "Running autoheader..."
autoheader
fi
echo "Running automake --gnu $am_opt ..."
automake --add-missing --gnu $am_opt
echo "Running autoconf ..."
autoconf
)
fi
done
conf_flags="--enable-maintainer-mode"
if test x$NOCONFIGURE = x; then
echo Running $srcdir/configure $conf_flags "$@" ...
$srcdir/configure $conf_flags "$@" \
&& echo Now type \`make\' to compile. || exit 1
else
echo Skipping configure process.
fi

View File

@ -0,0 +1,946 @@
#!/bin/bash
####################################################
# Bygfoot Football Manager #
# AUTHOR: Gyozo Both (gyboth@bygfoot.com) #
# http://bygfoot.sourceforge.net #
####################################################
# Skript that updates src packages of the Bygfoot Football Manager
# using wget to retrieve patches from the homepage
# version number
version="2.0.0"
# the bygfoot release version the script is shipped with
relversion=UNKNOWN_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
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="$*"
# which cvs version to get
cvs_version1=bygfoot-unstable
cvs_version2=bygfoot2-unstable
cvs_version=
# whether we use zenity
use_zenity=
# 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
# SourceForge.Net username (for cvs checkout)
cvs_user=
# 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 some official team names of well known teams
-n|--new-package Download the latest complete package
-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
-Z|--no-zenity Don't use zenity even if the version installed
is usable
directory
Relevant for package download mode:
-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'.
Relevant for CVS mode:
-B|--branch BRANCH Which CVS branch to get; currently 1 or 2
for the 1.8 or 2.0 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
if [ $use_zenity -eq 1 ]; then
my_zenity --title="Bygfoot Online Update Log" --text-info --filename=$log_file
else
dialog --title "Bygfoot Online Update" --textbox $log_file 22 75
fi
else
echo "** WARNING: log file $log_file not readable."
fi
fi
cleanup
exit $1
}
# parse arguments
function parse_args()
{
TEMP=`getopt -o aAbcB:C:hlnNp:rRt:T:uU:vZ --long apply-all,\
auto,branch:,country-files,country-dir:,cvs,,help,new-package,no-check,\
package-dir:,recompile,no-recompile,show-log,temp-dir:,type:,update,username:\
version,no-zenity -- $*`
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 ;;
-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 ;;
-Z|--no-zenity) use_zenity=0; shift ;;
--) shift; break ;;
esac
done
}
# clean up in the temp dir
function cleanup()
{
my_echo
my_echo "** b-u: Removing output file $input_file."
rm -rfv $input_file 2>> $log_file | tee -a $log_file
if [ ! -z $tmpdir ]; then
if [ $mode -ne $mode_pack ]; then
my_echo "** b-u: Cleaning up in the temp directory."
rm -rfv 2>> $log_file | tee -a $log_file
fi
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
}
# wrapper for zenity
function my_zenity()
{
zenity "$@" 1> $input_file
exitval=$?
if [ $exitval -eq 255 ]; then
my_echo "** b-u: zenity error."
read a
elif [ $exitval -eq 1 ]; then
my_echo "** b-u: User abort."
my_exit $EXITUSR
fi
}
# check for high enough version of zenity
function check_zenity()
{
my_echo -n "** b-u: checking for zenity..."
if ! which zenity &> /dev/null; then
my_echo " not installed. I'm going to use dialog."
else
zenver=$(zenity --version)
zenver1=$(echo $zenver |sed "s/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/g")
zenver2=$(echo $zenver |sed "s/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/g")
zenver3=$(echo $zenver |sed "s/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/g")
if [ $zenver1 -ge 2 -a $zenver2 -ge 9 -a $zenver3 -ge 0 ]; then
my_echo " $zenver1.$zenver2.$zenver3 found."
use_zenity=1
else
my_echo " $zenver1.$zenver2.$zenver3 not good enough. I'm going to use dialog."
use_zenity=0
fi
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
if [ -z $use_zenity ]; then
check_zenity
fi
}
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 team definitions
function get_team_defs()
{
if [ ! -d teams ]; then
mkdir teams
fi
pushd teams &> /dev/null
rm -vf team_defs 2>> $log_file | tee -a $log_file
my_wget http://bygfoot.sourceforge.net/revisions/team_defs
while read key value; do
if [ ! -z $key ]; then
if [ $key = "end_section" ]; then
file_name=$(echo $uri | sed "s/.*\(team_.*bz2\)/\1/g" | sed "s/\.bz2//g")
def_name=$(echo $file_name | sed "s/team_//g" | sed "s/\..*//g")
if [ -e $file_name.xml ]; then
mv $file_name.xml $file_name.xml.old
fi
if [ -e $file_name.png ]; then
mv $file_name.png $file_name.png.old
fi
my_wget $uri
tar xfj $file_name.bz2
rm -rfv $file_name.bz2 2>> $log_file | tee -a $log_file
if [ -d ../$country ]; then
pushd ../$country &> /dev/null
team_found=0
for league in league*xml; do
for team in "$team_name1" "$team_name2"; do
if grep "<team_name>$team</team_name>" $league &> /dev/null; then
team_found=1
cp -f $league $league.bak
my_echo " + Adding $team to $league..."
perl -0777 -pe "s+(team_name\>$team\</team_name\>)[\n\t ]*\<def_file\>[^\<]*\</def_file\>[\n\t ]*+\1\n+g" $league.bak | perl -0777 -pe "s+([\t ]*)(\<team_name\>$team\</team_name\>)+\1\2\n\1\<def_file\>$def_name\</def_file>+g" > $league
fi
done
done
if [ $team_found -eq 0 ]; then
echo " ** $team_name1 / $team_name2 not found in any of the leagues! **"
fi
popd &> /dev/null
else
my_echo "Country directory $country not found."
fi
team_name1=
team_name2=
uri=
country=
else
case $key in
uri) uri=$value ;;
team_name1) team_name1="$value" ;;
team_name2) team_name2="$value" ;;
country) country=$value ;;
esac
fi
fi
done < team_defs
rm -vf team_defs 2>> $log_file | tee -a $log_file
popd &> /dev/null
}
# get country files with official team names
function get_country_files()
{
my_echo
my_echo "** b-u: Fetching official team names and"
my_echo "** b-u: team definitions files."
pushd $countrydir &>/dev/null
my_wget http://bygfoot.sourceforge.net/revisions/official_names
while read -d : oldname && read newname
do
if [ "$oldname" == "League" ]; then
DIRNAME=$newname
my_echo " + Adding official names to $DIRNAME..."
else
oldname="${oldname## }"
newname="${newname%% }"
sed -i -e "s/>$oldname</>$newname</" $DIRNAME/league*.xml
fi
done < official_names
rm -vf official_names 2>> $log_file | tee -a $log_file
get_team_defs
popd &> /dev/null
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
if [ $use_zenity -eq 1 ]; then
my_zenity --title="Select source package directory" \
--file-selection --directory
else
dialog --title "Bygfoot Online Update" \
--inputbox "Source package directory" 22 80 $PWD 2> $input_file
fi
read_input
pushd $tempvar &> /dev/null; packdir=$PWD; popd &> /dev/null
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
if [ $use_zenity -eq 1 ]; then
my_zenity --title="Select temporary directory" \
--file-selection --directory
else
dialog --title "Bygfoot Online Update" \
--inputbox "Temporary directory\n(you need read/write permissions there)" \
22 80 /tmp 2> $input_file
fi
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 [ $use_zenity -eq 1 ]; then
my_zenity --title="Bygfoot Online Update" --info \
--text="If you use the binary version of Bygfoot, you should specify './support_files/definitions' as country dir. If you use an installed version, you should specify '$HOME/.bygfoot-X/definitions' (X being the version number you use)."
else
dialog --title "Bygfoot Online Update" --msgbox "If you use the binary version of Bygfoot, you should specify './support_files/definitons' as country dir. If you use an installed version, you should specify '$HOME/.bygfoot-X/definitions' (X being the version number you use)." \
22 80 2> $input_file
fi
if [ -z $countrydir ]; then
if [ $auto -eq 0 ]; then
if [ $use_zenity -eq 1 ]; then
my_zenity --title="Definitions dir (right click to show hidden)" \
--file-selection --directory
else
dialog --title "Bygfoot Online Update" \
--inputbox "Directory containing definitions directory" \
22 80 $HOME/.bygfoot/definitions 2> $input_file
fi
read_input
if [ ! -z $tempvar ]; then
pushd $tempvar &> /dev/null; countrydir=$PWD; popd &> /dev/null
else
countrydir=$HOME/.bygfoot/definitions
fi
else
countrydir=$HOME/.bygfoot/definitions
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
if [ $use_zenity -eq 1 ]; then
my_zenity --title="Bygfoot Online Update" --error \
--text="I couldn't find the file containing your current revision number and type ($packdir/revision_number)."
else
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
fi
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-tmp
}
# fetch a revision archive from the homepage and
# patch the src package
function get_revision()
{
local newrevdir=$tmpdir/bygfoot-update-tmp/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
if [ $use_zenity -eq 1 ]; then
my_zenity --title="Patch README" --text-info --filename=README
else
dialog --title "Bygfoot Online Update" --textbox README 22 75
fi
if [ $apply_all -eq 0 ]; then
if [ $use_zenity -eq 1 ]; then
my_zenity --title="Bygfoot Online Update" --list \
--text="Apply patch? (You can't apply newer ones if you don't apply this one because they depend on each other." \
--radiolist --column "" --column "" --column "" \
TRUE 1 Yes \
FALSE 2 No \
FALSE 3 All
else
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
fi
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-tmp 2>> $log_file | tee -a $log_file
mkdir -v bygfoot-update-tmp 2>> $log_file | tee -a $log_file
cd bygfoot-update-tmp
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
if [ $use_zenity -eq 1 ]; then
my_zenity --title="Bygfoot Online Update" --info \
--text="$found new revisions found. Your new revision number should be $[revnr + found]. Have a look at the files README, ChangeLog and ReleaseNotes to see the changes that were made."
else
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
fi
if [ $recompile -eq 0 -a $auto -eq 0 ]; then
if [ $use_zenity -eq 1 ]; then
my_zenity --title="Bygfoot Online Update" --question --text="Would you like me to execute 'configure &amp;&amp; make' ?"
else
dialog --title "Bygfoot Online Update" --yesno "Would you like me to execute 'configure && make' ?" 22 80 2> $input_file
fi
read_input
fi
if [ $recompile -ne -1 ]; then
cd $packdir
./configure && make 2>> $log_file | tee -a $log_file
fi
else
if [ $use_zenity -eq 1 ]; then
my_zenity --title="Bygfoot Online Update" --info \
--text="No new revisions found.\nYour package seems to be up-to-date."
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
fi
my_echo
my_echo "** b-u: done."
my_exit $EXITOK
}
# 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
if [ $use_zenity -eq 1 ]; then
my_zenity --title="Bygfoot Online Update" --list \
--text="Specify package type:" \
--radiolist --column "" --column "" --column "" \
TRUE 1 Stable \
FALSE 2 Unstable
else
dialog --title "Bygfoot Online Update" --menu "Specify package type" \
22 80 10 \
1 "Stable" \
2 "Unstable" 2> $input_file
fi
read_input
if [ $tempvar -eq 2 ]; then
type=$type_unstable
else
type=$type_stable
fi
else
type=$type_stable
fi
}
function get_latest_versions()
{
pushd $tmpdir &> /dev/null
rm -rfv bygfoot-update-tmp 2>> $log_file | tee -a $log_file
mkdir -v bygfoot-update-tmp
cd bygfoot-update-tmp
my_wget http://bygfoot.sourceforge.net/packages/$type/versions
packlist=`cat versions`
if [ $auto -eq 1 ]; then
return
fi
if [ $use_zenity -eq 1 ]; then
zencmd="zenity --title=Bygfoot_Online_Update --list --text=Select_package.Your_version_is_$relversion(as_far_as_I_know). --radiolist --print-column 2"
zencmd="$zencmd --column - --column - --column Package"
cnt=1
for package in $packlist; do
if [ $cnt -eq 1 ]; then
zencmd="$zencmd TRUE $cnt $package"
else
zencmd="$zencmd FALSE $cnt $package"
fi
cnt=$[cnt + 1];
done
selected_package=$($zencmd)
if [ $? -eq 1 ];then
my_echo "** b-u: User abort."
my_exit $EXITUSR
fi
else
dialcmd="dialog --title Bygfoot_Online_Update --menu Select_package.Your_version_is_$relversion(as_far_as_I_know). 22 80 10"
for package in $packlist; do
dialcmd="$dialcmd $package -"
done
$dialcmd 2> $input_file
read_input
selected_package=$tempvar
fi
}
function get_new_package()
{
my_wget http://bygfoot.sourceforge.net/packages/$type/$selected_package
if [ $use_zenity -eq 1 ]; then
my_zenity --title="Bygfoot Online Update" --info \
--text="You can find the package $selected_package in the directory $PWD."
else
dialog --title "Bygfoot Online Update" \
--msgbox "You can find the package $selected_package\nin the directory $PWD." \
22 80 2> $input_file
fi
my_echo "** b-u: Done."
my_exit $EXITOK
}
# download a bygfoot package
function get_package()
{
get_type
get_latest_versions
get_new_package
}
function get_mode()
{
if [ ! -z $mode ]; then
return
fi
if [ $auto -eq 1 ]; then
mode=$mode_src
return
fi
if [ $use_zenity -eq 1 ]; then
my_zenity --title="Bygfoot Online Update" --list \
--text="Main Menu" \
--radiolist --column "" --column "" --column "" \
TRUE 1 "Download the latest Bygfoot release" \
FALSE 2 "Get official team names and team definitions" \
FALSE 3 "Get CVS version (11+ MB)"
else
dialog --title "Bygfoot Online Update" --menu "Main Menu" 22 80 10 \
1 " Download the latest Bygfoot release" \
2 " Get official team names and team definitions" \
3 " Get CVS version (11+ MB)" 2> $input_file
fi
read_input
if [ -z $tempvar ]; then
mode=$mode_pack
return
fi
if [ $tempvar -eq 1 ]; then
mode=$mode_pack
elif [ $tempvar -eq 2 ]; then
mode=$mode_country
else
mode=$mode_cvs
fi
}
function get_cvs()
{
if [ -z $cvs_version ];then
if [ $use_zenity -eq 1 ]; then
my_zenity --title="Bygfoot Online Update" --list \
--text="Specify CVS version" \
--radiolist --column "" --column "" --column "" \
FALSE 1 " 1.8 branch" \
TRUE 2 " 2.0 branch"
else
dialog --title "Bygfoot Online Update" --menu "Specify CVS version" 22 80 10 \
1 " 1.8 branch" \
2 " 2.0 branch" 2> $input_file
fi
read_input
if [ $tempvar -eq 2 ]; then
cvs_version=$cvs_version2
else
cvs_version=$cvs_version1
fi
fi
if [ -z $cvs_user ];then
if [ $use_zenity -eq 1 ]; then
my_zenity --title="Bygfoot Online Update" --entry \
--text="If you'd like to check out as a developer, enter your SourceForge.net username. Leave empty to check out anonymously."
else
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
fi
read_input
if [ -z $tempvar ]; then
cvs_command="cvs -z3 -d:pserver:anonymous@bygfoot.cvs.sourceforge.net:/cvsroot/bygfoot"
else
cvs_command="cvs -z3 -d:ext:$tempvar@bygfoot.cvs.sourceforge.net:/cvsroot/bygfoot"
fi
else
if [ $cvs_user = "A" ]; then
cvs_command="cvs -z3 -d:pserver:anonymous@bygfoot.cvs.sourceforge.net:/cvsroot/bygfoot"
else
cvs_command="cvs -z3 -d:ext:$cvs_user@bygfoot.cvs.sourceforge.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
if [ $use_zenity -eq 1 ]; then
my_zenity --title="Bygfoot Online Update" --question \
--text="Would you like me to execute 'autogen.sh &amp;&amp; make' ?"
else
dialog --title "Bygfoot Online Update" \
--yesno "Would you like me to execute 'autogen.sh && make' ?" 22 80 2> $input_file
fi
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

@ -0,0 +1,10 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd">
<glade-project>
<name>Bygfoot</name>
<program_name>bygfoot</program_name>
<pixmaps_directory>support_files/pixmaps</pixmaps_directory>
<gnome_support>FALSE</gnome_support>
<backup_source_files>FALSE</backup_source_files>
</glade-project>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,17 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd">
<glade-project>
<name>bygfoot_editor</name>
<program_name>bygfoot_editor</program_name>
<pixmaps_directory>support_files/pixmaps</pixmaps_directory>
<gnome_support>FALSE</gnome_support>
<output_main_file>FALSE</output_main_file>
<output_support_files>FALSE</output_support_files>
<output_build_files>FALSE</output_build_files>
<backup_source_files>FALSE</backup_source_files>
<main_source_file>editor_interface.c</main_source_file>
<main_header_file>editor_interface.h</main_header_file>
<handler_source_file>editor_callbacks.c</handler_source_file>
<handler_header_file>editor_callbacks.h</handler_header_file>
</glade-project>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,17 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd">
<glade-project>
<name>bygfoot_misc</name>
<program_name>bygfoot_misc</program_name>
<pixmaps_directory>support_files/pixmaps</pixmaps_directory>
<gnome_support>FALSE</gnome_support>
<output_main_file>FALSE</output_main_file>
<output_support_files>FALSE</output_support_files>
<output_build_files>FALSE</output_build_files>
<backup_source_files>FALSE</backup_source_files>
<main_source_file>misc_interface.c</main_source_file>
<main_header_file>misc_interface.h</main_header_file>
<handler_source_file>misc_callbacks.c</handler_source_file>
<handler_header_file>misc_callbacks.h</handler_header_file>
</glade-project>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,17 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd">
<glade-project>
<name>bygfoot_misc2</name>
<program_name>bygfoot_misc2</program_name>
<pixmaps_directory>support_files/pixmaps</pixmaps_directory>
<gnome_support>FALSE</gnome_support>
<output_main_file>FALSE</output_main_file>
<output_support_files>FALSE</output_support_files>
<output_build_files>FALSE</output_build_files>
<backup_source_files>FALSE</backup_source_files>
<main_source_file>misc2_interface.c</main_source_file>
<main_header_file>misc2_interface.h</main_header_file>
<handler_source_file>misc2_callbacks.c</handler_source_file>
<handler_header_file>misc2_callbacks.h</handler_header_file>
</glade-project>

View File

@ -0,0 +1,935 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
<widget class="GtkWindow" id="window_bets">
<property name="border_width">5</property>
<property name="visible">True</property>
<property name="title" translatable="yes"></property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
<property name="modal">True</property>
<property name="default_width">600</property>
<property name="default_height">700</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_WEST</property>
<signal name="delete_event" handler="on_window_bets_delete_event" last_modification_time="Thu, 27 Oct 2005 17:10:03 GMT"/>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">3</property>
<child>
<widget class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="label" translatable="yes">Betting -- Left click on odd to place or remove bet</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.5</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="GtkHSeparator" id="hseparator1">
<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="GtkHBox" id="hbox1">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkCheckButton" id="checkbutton_bet_all_leagues">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Whether to show matches of all leagues. Use the options window to toggle permanently.</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Show matches from all leagues</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="button_press_event" handler="on_checkbutton_bet_all_leagues_button_press_event" last_modification_time="Thu, 27 Oct 2005 19:23:57 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="checkbutton_bet_cups">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Whether to show cup matches. Use the options window to toggle permanently.</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Show matches from cups</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="button_press_event" handler="on_checkbutton_bet_cups_button_press_event" last_modification_time="Thu, 27 Oct 2005 19:24:05 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_bet_user_recent">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Whether to show only your bets in the recent bets list</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Show only my recent bets</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="button_press_event" handler="on_checkbutton_bet_user_recent_button_press_event" last_modification_time="Thu, 27 Oct 2005 19:45:03 GMT"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkHSeparator" id="hseparator2">
<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="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="treeview_bets">
<property name="visible">True</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_bets_button_press_event" last_modification_time="Thu, 27 Oct 2005 19:43:51 GMT"/>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button_bet_close">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Esc</property>
<property name="can_focus">True</property>
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_button_bet_close_clicked" last_modification_time="Thu, 27 Oct 2005 17:12:51 GMT"/>
<accelerator key="Escape" modifiers="0" signal="clicked"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
<widget class="GtkWindow" id="window_splash">
<property name="border_width">5</property>
<property name="visible">True</property>
<property name="title" translatable="yes"></property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER_ALWAYS</property>
<property name="modal">False</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_WEST</property>
<signal name="delete_event" handler="on_window_splash_delete_event" last_modification_time="Fri, 10 Feb 2006 14:27:35 GMT"/>
<child>
<widget class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">3</property>
<child>
<widget class="GtkNotebook" id="notebook1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="show_tabs">True</property>
<property name="show_border">True</property>
<property name="tab_pos">GTK_POS_TOP</property>
<property name="scrollable">False</property>
<property name="enable_popup">False</property>
<child>
<widget class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="pixbuf">bygfoot_splash.png</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="label"> </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.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow2">
<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_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="treeview_splash_contributors">
<property name="visible">True</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>
</widget>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
<property name="tab_fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="label" translatable="yes">Contributors</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.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="type">tab</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHSeparator" id="hseparator3">
<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="GtkVBox" id="vbox3">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkHBox" id="hbox2">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">3</property>
<child>
<widget class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="stock">gtk-dialog-info</property>
<property name="icon_size">5</property>
<property name="xalign">0.5</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="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="label" translatable="yes" comments="Splash screen hint question.">Did you know?</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</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="GtkLabel" id="label_splash_hintcounter">
<property name="visible">True</property>
<property name="label" translatable="yes"></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.5</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>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label_splash_hint">
<property name="height_request">90</property>
<property name="visible">True</property>
<property name="label" translatable="yes"></property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">True</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">5</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox10">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">3</property>
<child>
<widget class="GtkButton" id="button_splash_hint_back">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_button_splash_hint_back_clicked" last_modification_time="Fri, 10 Feb 2006 14:49:00 GMT"/>
<child>
<widget class="GtkAlignment" id="alignment4">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="hbox8">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image6">
<property name="visible">True</property>
<property name="stock">gtk-go-back</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</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="GtkLabel" id="label11">
<property name="visible">True</property>
<property name="label" translatable="yes">Previous</property>
<property name="use_underline">True</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.5</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>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button_splash_hint_next">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_button_splash_hint_next_clicked" last_modification_time="Fri, 10 Feb 2006 14:49:10 GMT"/>
<child>
<widget class="GtkAlignment" id="alignment5">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="hbox9">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image7">
<property name="visible">True</property>
<property name="stock">gtk-go-forward</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</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="GtkLabel" id="label12">
<property name="visible">True</property>
<property name="label" translatable="yes">Next</property>
<property name="use_underline">True</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.5</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>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHSeparator" id="hseparator4">
<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="GtkHBox" id="hbox3">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">3</property>
<child>
<widget class="GtkButton" id="button_splash_new_game">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Ctrl-N</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_button_splash_new_game_clicked" last_modification_time="Fri, 10 Feb 2006 14:25:43 GMT"/>
<accelerator key="n" modifiers="GDK_CONTROL_MASK" signal="clicked"/>
<child>
<widget class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="hbox4">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image3">
<property name="visible">True</property>
<property name="stock">gtk-new</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</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="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="label" translatable="yes">Start _new game</property>
<property name="use_underline">True</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.5</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>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button_splash_load_game">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Ctrl-O</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_button_splash_load_game_clicked" last_modification_time="Fri, 10 Feb 2006 14:25:49 GMT"/>
<accelerator key="o" modifiers="GDK_CONTROL_MASK" signal="clicked"/>
<child>
<widget class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="hbox5">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image4">
<property name="visible">True</property>
<property name="stock">gtk-open</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</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="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="label" translatable="yes">_Load game</property>
<property name="use_underline">True</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.5</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>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button_splash_resume_game">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Ctrl-R</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_button_splash_resume_game_clicked" last_modification_time="Fri, 10 Feb 2006 14:26:33 GMT"/>
<accelerator key="r" modifiers="GDK_CONTROL_MASK" signal="clicked"/>
<child>
<widget class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="hbox6">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image5">
<property name="visible">True</property>
<property name="stock">gtk-revert-to-saved</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</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="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="label" translatable="yes">_Resume game</property>
<property name="use_underline">True</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.5</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>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button_splash_quit">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Esc</property>
<property name="can_focus">True</property>
<property name="label">gtk-quit</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_button_splash_quit_clicked" last_modification_time="Fri, 10 Feb 2006 14:27:04 GMT"/>
<accelerator key="Escape" modifiers="0" signal="clicked"/>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox7">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">5</property>
<child>
<widget class="GtkLabel" id="label_splash_progress">
<property name="width_request">400</property>
<property name="visible">True</property>
<property name="label" translatable="yes">Ready</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</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="GtkProgressBar" id="progressbar_splash">
<property name="height_request">10</property>
<property name="visible">True</property>
<property name="orientation">GTK_PROGRESS_LEFT_TO_RIGHT</property>
<property name="fraction">0</property>
<property name="pulse_step">0.10000000149</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd">
<glade-project>
<name>bygfoot_misc3</name>
<program_name>bygfoot_misc3</program_name>
<pixmaps_directory>support_files/pixmaps</pixmaps_directory>
<gnome_support>FALSE</gnome_support>
<output_main_file>FALSE</output_main_file>
<output_support_files>FALSE</output_support_files>
<output_build_files>FALSE</output_build_files>
<backup_source_files>FALSE</backup_source_files>
<main_source_file>misc3_interface.c</main_source_file>
<main_header_file>misc3_interface.h</main_header_file>
<handler_source_file>misc3_callbacks.c</handler_source_file>
<handler_header_file>misc3_callbacks.h</handler_header_file>
</glade-project>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,17 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd">
<glade-project>
<name>bygfoot_options</name>
<program_name>bygfoot_options</program_name>
<pixmaps_directory>support_files/pixmaps</pixmaps_directory>
<gnome_support>FALSE</gnome_support>
<output_main_file>FALSE</output_main_file>
<output_support_files>FALSE</output_support_files>
<output_build_files>FALSE</output_build_files>
<backup_source_files>FALSE</backup_source_files>
<main_source_file>options_interface.c</main_source_file>
<main_header_file>options_interface.h</main_header_file>
<handler_source_file>options_callbacks.c</handler_source_file>
<handler_header_file>options_callbacks.h</handler_header_file>
</glade-project>

View File

@ -0,0 +1,84 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT(configure.in)
AM_INIT_AUTOMAKE(bygfoot, 0.1)
AM_CONFIG_HEADER(config.h)
AM_MAINTAINER_MODE
AC_ISC_POSIX
AC_PROG_CC
AM_PROG_CC_STDC
AC_HEADER_STDC
pkg_modules="gtk+-2.0 >= 2.6"
dnl echo -n "checking for gthread-2.0 ... "
dnl if pkg-config --exists gthread-2.0 ; then
dnl echo "yes"
dnl pkg_modules="$pkg_modules gthread-2.0"
dnl else
dnl echo "no"
dnl AC_MSG_ERROR(gthread-2.0 not found)
dnl fi
PKG_CHECK_MODULES(PACKAGE, [$pkg_modules])
AC_SUBST(PACKAGE_CFLAGS)
AC_SUBST(PACKAGE_LIBS)
GETTEXT_PACKAGE=bygfoot
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package.])
dnl Add the languages which your application supports here.
ALL_LINGUAS="de nl fr pl ro bg zh es da sv"
AM_GLIB_GNU_GETTEXT
dnl gstreamer checking
AC_ARG_ENABLE(gstreamer,
AC_HELP_STRING([--enable-gstreamer],[use GStreamer for media]),
[case "${enableval}" in
yes) ENABLE_GST=yes ;;
no) ENABLE_GST=no ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-gstreamer) ;;
esac],
[ENABLE_GST=no]) dnl Default value
dnl localedir specification
LOCALEDIR="$datadir/locale"
AC_ARG_WITH([localedir],
AS_HELP_STRING([--with-localedir@<:@=DIR@:>@], [install locale data under specified dir]),
LOCALEDIR="${withval}"
)
AC_SUBST([LOCALEDIR])
if test x$ENABLE_GST = xyes; then
HAVE_GSTREAMER=0
dnl start with 0.8
GST_MAJORMINOR=0.8
GSTREAMER_REQUIRED=0.8
PKG_CHECK_MODULES(GST, \
gstreamer-$GST_MAJORMINOR >= $GSTREAMER_REQUIRED,
HAVE_GSTREAMER=1,HAVE_GSTREAMER=0)
if test "x$HAVE_GSTREAMER" = "x0"; then
AC_MSG_ERROR(you need gstreamer development packages installed !)
fi
AC_SUBST(GST_CFLAGS)
AC_SUBST(GST_LIBS)
AC_SUBST(HAVE_GSTREAMER)
AC_DEFINE_UNQUOTED(HAVE_GSTREAMER, $HAVE_GSTREAME,[gstreamer])
AC_MSG_RESULT(GStreamer)
fi
AC_OUTPUT([
Makefile
src/Makefile
po/Makefile.in
])

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,84 @@
.TH "BYGFOOT" 6 "" ""
.P
.SS NAME
\fBBygfoot\fP \- a football management game for Linux and other Unices.
.SS SYNOPSIS
bygfoot [\-e|\-\-editor] [\-d dir] [\-f file] [\-u|\-\-update] game
.SS DESCRIPTION
This man page documents version 1.6 of \fBBygfoot\fP. \fBBygfoot\fP is a
small and simple football (a.k.a. soccer) manager game featuring some of
the world's most important leagues and cups. You manage a team from one
such league: you form the team, buy and sell players, get promoted or
relegated and of course try to be successful.
The game is deliberately kept simple. Players have only one value that
reflects their playing ability, namely their skill value (they have
some other values, though, like age or position). The only thing that
you have to do besides managing your players is to look after your
stadium: keep / make it safe and see that you have enough capacity.
Because of the simplicity of the game, and because most buttons have
tool\-tips you won't need much help while playing.
.SS OPTIONS
\-d [dir] \- allows you to choose another directory to search for
pixmaps and text\-files. Default directories that are searched are
$HOME/.bygfoot, ./support_files and possibly (depending on the package
format you have) /usr/local/share/bygfoot/support_files.
\-f [file] \- allows you to choose a custom country file instead of one
of those included with your \fBBygfoot\fP release. You can omit the full
path if the file's in $HOME/.bygfoot/text_files.
\-e \-\-editor \- allows you to start directly the team editor.
\-u \-\-update \- starts the Bygfoot Online Update Frontend (available
in versions higher than 1.7.0 rev2.
[game] \- allows you to load directly a previously saved game. You can omit the full
path if the file's in $HOME/.bygfoot/saves.
Any other argument is interpreted as [game].
.SS FILES
/usr/share/bygfoot/support_files/ \- directory containing pixmaps
used by the GUI (prefix might be /usr/local if you've compiled
the game yourself).
/usr/share/bygfoot/support_files/text_files/ \- directory containing the
built\-in country files, team definitions and other text data.
/usr/bin/bygfoot \- the standalone executable (depends on GTK+2).
$HOME/.bygfoot \- user configuration directory.
.SS AUTHOR
\fBBygfoot\fP is written and maintained by Gyözö Both (gyboth_at_bygfoot_dot_com), following
suggestions from people all over the world.
.SS COPYRIGHT NOTICE
Copyright (c) 2004 by Gyözö Both. Released under the GNU General Public
Licence. The full text of the licence is available in the source directory
with the name COPYING. If you have not downloaded the source, or if the
file you have downloaded is missing the licence, you can read it online at the
Free Software Foundation site at http://www.gnu.org or at http://www.fsf.org.
A copy of the licence can also be obtained from the author of this software.
.SS DOCUMENTATION AUTHORSHIP
Copyright (c) 2004 by José Geraldo Gouvêa and Gyözö Both.
.SS INVITATION
You are invited to help expand the playability and the functionalities of
this game by sending your patches and contributions. You can also join
the development team at SourceForge.net if you know C programming and
can spare some time.
Even if you are not a programmer you can contribute to the project by sending
new country files, team definitions, artwork or \-\-\- preferably \-\-\- by donating
to the project. See more about this at the official \fBBygfoot\fP website at
http://www.bygfoot.com.
.\" man code generated by txt2tags 1.7 (http://txt2tags.sf.net)
.\" cmdline: txt2tags -t man -t man bygfoot.t2t

View File

@ -0,0 +1,4 @@
*.gmo
POTFILES
Makefile
Makefile.in

View File

@ -0,0 +1,254 @@
# Makefile for program source directory in GNU NLS utilities package.
# Copyright (C) 1995, 1996, 1997 by Ulrich Drepper <drepper@gnu.ai.mit.edu>
#
# This file file be copied and used freely without restrictions. It can
# be used in projects which are not available under the GNU Public License
# but which still want to provide support for the GNU gettext functionality.
# Please note that the actual code is *not* freely available.
#
# - Modified by Owen Taylor <otaylor@redhat.com> to use GETTEXT_PACKAGE
# instead of PACKAGE and to look for po2tbl in ./ not in intl/
#
# - Modified by jacob berkman <jacob@ximian.com> to install
# Makefile.in.in and po2tbl.sed.in for use with glib-gettextize
GETTEXT_PACKAGE = @GETTEXT_PACKAGE@
PACKAGE = @PACKAGE@
VERSION = @VERSION@
SHELL = /bin/sh
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
datadir = @datadir@
libdir = @libdir@
localedir = $(libdir)/locale
gnulocaledir = $(datadir)/locale
gettextsrcdir = $(datadir)/glib-2.0/gettext/po
subdir = po
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
MKINSTALLDIRS = $(top_srcdir)/@MKINSTALLDIRS@
CC = @CC@
GENCAT = @GENCAT@
GMSGFMT = @GMSGFMT@
MSGFMT = @MSGFMT@
XGETTEXT = @XGETTEXT@
MSGMERGE = msgmerge
DEFS = @DEFS@
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@
INCLUDES = -I.. -I$(top_srcdir)/intl
COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS)
SOURCES =
POFILES = @POFILES@
GMOFILES = @GMOFILES@
DISTFILES = ChangeLog Makefile.in.in POTFILES.in $(GETTEXT_PACKAGE).pot \
$(POFILES) $(GMOFILES) $(SOURCES)
POTFILES = \
CATALOGS = @CATALOGS@
CATOBJEXT = @CATOBJEXT@
INSTOBJEXT = @INSTOBJEXT@
.SUFFIXES:
.SUFFIXES: .c .o .po .pox .gmo .mo .msg .cat
.c.o:
$(COMPILE) $<
.po.pox:
$(MAKE) $(GETTEXT_PACKAGE).pot
$(MSGMERGE) $< $(srcdir)/$(GETTEXT_PACKAGE).pot -o $*.pox
.po.mo:
$(MSGFMT) -o $@ $<
.po.gmo:
file=$(srcdir)/`echo $* | sed 's,.*/,,'`.gmo \
&& rm -f $$file && $(GMSGFMT) -o $$file $<
.po.cat:
sed -f ../intl/po2msg.sed < $< > $*.msg \
&& rm -f $@ && $(GENCAT) $@ $*.msg
all: all-@USE_NLS@
all-yes: $(CATALOGS)
all-no:
$(srcdir)/$(GETTEXT_PACKAGE).pot: $(POTFILES)
$(XGETTEXT) --default-domain=$(GETTEXT_PACKAGE) --directory=$(top_srcdir) \
--add-comments --keyword=_ --keyword=N_ \
--files-from=$(srcdir)/POTFILES.in \
&& test ! -f $(GETTEXT_PACKAGE).po \
|| ( rm -f $(srcdir)/$(GETTEXT_PACKAGE).pot \
&& mv $(GETTEXT_PACKAGE).po $(srcdir)/$(GETTEXT_PACKAGE).pot )
install: install-exec install-data
install-exec:
install-data: install-data-@USE_NLS@
install-data-no: all
install-data-yes: all
if test -r "$(MKINSTALLDIRS)"; then \
$(MKINSTALLDIRS) $(DESTDIR)$(datadir); \
else \
$(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(datadir); \
fi
@catalogs='$(CATALOGS)'; \
for cat in $$catalogs; do \
cat=`basename $$cat`; \
case "$$cat" in \
*.gmo) destdir=$(gnulocaledir);; \
*) destdir=$(localedir);; \
esac; \
lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
dir=$(DESTDIR)$$destdir/$$lang/LC_MESSAGES; \
if test -r "$(MKINSTALLDIRS)"; then \
$(MKINSTALLDIRS) $$dir; \
else \
$(SHELL) $(top_srcdir)/mkinstalldirs $$dir; \
fi; \
if test -r $$cat; then \
$(INSTALL_DATA) $$cat $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT); \
echo "installing $$cat as $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT)"; \
else \
$(INSTALL_DATA) $(srcdir)/$$cat $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT); \
echo "installing $(srcdir)/$$cat as" \
"$$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT)"; \
fi; \
if test -r $$cat.m; then \
$(INSTALL_DATA) $$cat.m $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m; \
echo "installing $$cat.m as $$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m"; \
else \
if test -r $(srcdir)/$$cat.m ; then \
$(INSTALL_DATA) $(srcdir)/$$cat.m \
$$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m; \
echo "installing $(srcdir)/$$cat as" \
"$$dir/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m"; \
else \
true; \
fi; \
fi; \
done
if test "$(PACKAGE)" = "glib"; then \
if test -r "$(MKINSTALLDIRS)"; then \
$(MKINSTALLDIRS) $(DESTDIR)$(gettextsrcdir); \
else \
$(SHELL) $(top_srcdir)/mkinstalldirs $(DESTDIR)$(gettextsrcdir); \
fi; \
$(INSTALL_DATA) $(srcdir)/Makefile.in.in \
$(DESTDIR)$(gettextsrcdir)/Makefile.in.in; \
else \
: ; \
fi
# Define this as empty until I found a useful application.
installcheck:
uninstall:
catalogs='$(CATALOGS)'; \
for cat in $$catalogs; do \
cat=`basename $$cat`; \
lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT); \
rm -f $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m; \
rm -f $(DESTDIR)$(gnulocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT); \
rm -f $(DESTDIR)$(gnulocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE)$(INSTOBJEXT).m; \
done
if test "$(PACKAGE)" = "glib"; then \
rm -f $(DESTDIR)$(gettextsrcdir)/Makefile.in.in; \
fi
check: all
dvi info tags TAGS ID:
mostlyclean:
rm -f core core.* *.pox $(GETTEXT_PACKAGE).po *.old.po cat-id-tbl.tmp
rm -fr *.o
clean: mostlyclean
distclean: clean
rm -f Makefile Makefile.in POTFILES *.mo *.msg *.cat *.cat.m
maintainer-clean: distclean
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
rm -f $(GMOFILES)
distdir = ../$(GETTEXT_PACKAGE)-$(VERSION)/$(subdir)
dist distdir: update-po $(DISTFILES)
dists="$(DISTFILES)"; \
for file in $$dists; do \
ln $(srcdir)/$$file $(distdir) 2> /dev/null \
|| cp -p $(srcdir)/$$file $(distdir); \
done
update-po: Makefile
$(MAKE) $(GETTEXT_PACKAGE).pot
tmpdir=`pwd`; \
cd $(srcdir); \
catalogs='$(CATALOGS)'; \
for cat in $$catalogs; do \
cat=`basename $$cat`; \
lang=`echo $$cat | sed 's/\$(CATOBJEXT)$$//'`; \
echo "$$lang:"; \
if $(MSGMERGE) $$lang.po $(GETTEXT_PACKAGE).pot -o $$tmpdir/$$lang.new.po; then \
if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
rm -f $$tmpdir/$$lang.new.po; \
else \
if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
:; \
else \
echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
rm -f $$tmpdir/$$lang.new.po; \
exit 1; \
fi; \
fi; \
else \
echo "msgmerge for $$cat failed!"; \
rm -f $$tmpdir/$$lang.new.po; \
fi; \
done
# POTFILES is created from POTFILES.in by stripping comments, empty lines
# and Intltool tags (enclosed in square brackets), and appending a full
# relative path to them
POTFILES: POTFILES.in
( if test 'x$(srcdir)' != 'x.'; then \
posrcprefix='$(top_srcdir)/'; \
else \
posrcprefix="../"; \
fi; \
rm -f $@-t $@ \
&& (sed -e '/^#/d' \
-e "s/^\[.*\] +//" \
-e '/^[ ]*$$/d' \
-e "s@.*@ $$posrcprefix& \\\\@" < $(srcdir)/$@.in \
| sed -e '$$s/\\$$//') > $@-t \
&& chmod a-w $@-t \
&& mv $@-t $@ )
Makefile: Makefile.in.in ../config.status POTFILES
cd .. \
&& CONFIG_FILES=$(subdir)/$@.in CONFIG_HEADERS= \
$(SHELL) ./config.status
# Tell versions [3.59,3.63) of GNU make not to export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -0,0 +1,32 @@
# List of source files containing translatable strings.
src/callback_func.c
src/callbacks.c
src/cup.c
src/finance.c
src/fixture.c
src/game.c
src/game_gui.c
src/interface.c
src/lg_commentary.c
src/live_game.c
src/load_save.c
src/main.c
src/misc2_callback_func.c
src/misc2_callbacks.c
src/misc2_interface.c
src/misc_callback_func.c
src/misc_callbacks.c
src/misc_interface.c
src/nonsourcestrings.c
src/options_interface.c
src/player.c
src/support.c
src/team.c
src/transfer.c
src/treeview2.c
src/treeview.c
src/treeview_helper.c
src/user.c
src/window.c
src/xml.c
src/youth_academy.c

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
unstable10

View File

@ -0,0 +1,86 @@
## Process this file with automake to produce Makefile.in
AM_CFLAGS = -Wall #-fprofile-arcs -ftest-coverage -pg
INCLUDES = \
-DPACKAGE_DATA_DIR=\""$(datadir)"\" \
-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
@PACKAGE_CFLAGS@ @GST_CFLAGS@
bin_PROGRAMS = bygfoot
bygfoot_SOURCES = \
bet.c bet.h finance.h fixture.h game_gui.h league.h main.h maths.h misc.h option.h player.h support.h treeview2.h user.h \
callback_func.c bet.h callback_func.h callbacks.h cup.h finance.h fixture.h game_gui.h gui.h league.h live_game.h maths.h misc.h option.h player.h start_end.h team.h transfer.h treeview.h treeview_helper.h user.h window.h \
callbacks.c callback_func.h callbacks.h debug.h free.h game_gui.h game.h gui.h job.h league.h load_save.h main.h misc2_callback_func.h option.h player.h table.h team.h transfer.h treeview2.h treeview.h treeview_helper.h user.h window.h \
cup.c cup.h fixture.h free.h league.h main.h maths.h misc.h option.h table.h team.h variables.h xml_league.h \
debug.c callbacks.h debug.h game_gui.h league.h live_game.h option.h strategy.h support.h team.h user.h variables.h \
file.c file.h free.h language.h main.h misc.h option.h support.h variables.h \
finance.c callbacks.h finance.h game_gui.h league.h maths.h option.h player.h team.h user.h \
fixture.c cup.h fixture.h free.h league.h main.h maths.h misc.h option.h table.h team.h user.h variables.h \
free.c bet_struct.h free.h lg_commentary_struct.h strategy_struct.h transfer.h user.h variables.h \
game.c cup.h finance.h fixture.h game_gui.h game.h league.h live_game.h main.h maths.h misc.h option.h player.h table.h team.h treeview.h user.h variables.h \
game_gui.c callbacks.h file.h game_gui.h gui.h job.h league.h live_game.h maths.h misc.h option.h support.h team.h treeview.h user.h variables.h window.h \
gui.c gui.h misc.h option.h support.h variables.h window.h \
interface.c callbacks.h interface.h support.h \
job.c bet.h cup.h file.h free.h job.h league.h live_game.h main.h maths.h option.h start_end.h team.h transfer.h user.h variables.h xml_country.h \
language.c callbacks.h free.h language.h lg_commentary.h misc.h option.h variables.h window.h \
lg_commentary.c cup.h file.h fixture.h free.h language.h league.h lg_commentary.h live_game.h main.h maths.h misc.h option.h player.h team.h variables.h xml_lg_commentary.h \
league.c cup.h free.h league.h main.h maths.h misc.h option.h player.h stat.h table.h team.h user.h variables.h \
live_game.c callbacks.h fixture.h free.h game_gui.h game.h league.h lg_commentary.h live_game.h main.h maths.h misc_callback_func.h misc.h option.h player.h strategy.h support.h team.h treeview.h user.h variables.h window.h \
load_save.c callbacks.h file.h game_gui.h gui.h language.h load_save.h misc.h option.h support.h user.h variables.h window.h xml.h xml_loadsave_cup.h xml_loadsave_jobs.h xml_loadsave_league.h xml_loadsave_leagues_cups.h xml_loadsave_misc.h xml_loadsave_season_stats.h xml_loadsave_transfers.h xml_loadsave_users.h \
main.c bet_struct.h debug.h file.h free.h job_struct.h language.h lg_commentary.h live_game.h load_save.h main.h misc_callbacks.h misc.h name_struct.h option.h start_end.h stat_struct.h strategy_struct.h transfer_struct.h variables.h window.h xml_strategy.h \
maths.c maths.h misc.h variables.h \
misc.c main.h maths.h misc.h option.h variables.h \
misc_callbacks.c callback_func.h callbacks.h game_gui.h game.h gui.h live_game.h load_save.h main.h maths.h misc_callback_func.h misc_callbacks.h option.h user.h variables.h window.h xml_country.h \
misc_callback_func.c callbacks.h debug.h finance.h free.h game_gui.h game.h gui.h load_save.h main.h maths.h misc_callback_func.h misc.h option.h start_end.h support.h treeview.h treeview_helper.h user.h variables.h window.h xml_country.h xml_name.h \
misc2_callbacks.c bet.h callback_func.h callbacks.h debug.h finance.h free.h game_gui.h job.h league.h load_save.h main.h misc2_callback_func.h misc2_callbacks.h misc2_interface.h player.h support.h team.h transfer.h treeview2.h treeview.h treeview_helper.h user.h window.h \
misc3_callbacks.c bet.h fixture.h main.h misc3_callbacks.h misc3_interface.h misc_callback_func.h option.h support.h treeview2.h treeview_helper.h user.h variables.h window.h \
misc2_callback_func.c callback_func.h callbacks.h file.h finance.h free.h game_gui.h job.h league.h maths.h misc2_callback_func.h misc.h option.h player.h support.h team.h transfer.h treeview2.h treeview.h treeview_helper.h user.h window.h \
misc_interface.c misc_callbacks.h misc_interface.h support.h \
misc2_interface.c misc2_callbacks.h misc2_interface.h support.h \
misc3_interface.c misc3_callbacks.h misc3_interface.h support.h \
name.c main.h name.h option.h variables.h xml_name.h \
option.c main.h misc.h option.h variables.h \
option_gui.c callbacks.h file.h game_gui.h language.h misc.h option_gui.h option.h support.h treeview.h user.h variables.h \
options_callbacks.c file.h option_gui.h options_callbacks.h options_interface.h support.h user.h variables.h window.h \
options_interface.c options_callbacks.h options_interface.h support.h \
player.c cup.h fixture.h free.h game_gui.h league.h main.h maths.h misc.h name.h option.h player.h team.h transfer.h user.h \
start_end.c bet.h cup.h file.h finance.h fixture.h free.h game_gui.h gui.h job.h league.h live_game.h load_save.h main.h maths.h misc.h name.h option.h player.h start_end.h stat.h table.h team.h transfer.h user.h variables.h xml_name.h youth_academy.h \
stat.c cup.h free.h league.h option.h player.h stat.h table_struct.h team.h variables.h \
strategy.c fixture.h league.h live_game.h main.h misc.h option.h player.h strategy.h team.h \
support.c support.h \
table.c cup.h league.h misc.h table.h variables.h \
team.c cup.h file.h finance.h fixture.h game_gui.h game.h league.h main.h maths.h misc.h option.h player.h strategy.h team.h transfer.h user.h xml_team.h \
transfer.c callbacks.h cup.h finance.h free.h game_gui.h main.h maths.h misc.h option.h player.h support.h team.h transfer.h treeview.h user.h \
treeview.c cup.h file.h finance.h fixture.h free.h game_gui.h game.h language.h league.h live_game.h maths.h misc.h option.h player.h support.h team.h transfer.h treeview.h treeview_helper.h user.h \
treeview2.c bet.h fixture.h job.h league.h live_game.h misc.h option.h support.h team.h treeview2.h treeview_helper.h user.h \
treeview_helper.c bet.h cup.h file.h fixture.h free.h job.h league.h misc.h option.h player.h support.h team.h transfer.h treeview2.h treeview.h treeview_helper.h user.h variables.h \
user.c bet.h cup.h file.h finance.h fixture.h free.h game_gui.h league.h live_game.h main.h maths.h misc.h name.h option.h player.h support.h team.h transfer.h treeview.h user.h window.h xml_mmatches.h youth_academy.h \
window.c callbacks.h debug.h file.h finance.h free.h game_gui.h gui.h interface.h language.h league.h live_game.h load_save.h main.h maths.h misc2_interface.h misc3_interface.h misc_callback_func.h misc_interface.h option_gui.h option.h options_interface.h support.h transfer.h treeview2.h treeview.h treeview_helper.h user.h window.h \
xml.c cup.h file.h free.h gui.h league.h misc.h option.h support.h table.h transfer_struct.h user.h variables.h xml.h xml_loadsave_cup.h xml_loadsave_fixtures.h xml_loadsave_league.h xml_loadsave_league_stat.h xml_loadsave_live_game.h xml_loadsave_table.h xml_loadsave_teams.h xml_loadsave_transfers.h xml_loadsave_users.h \
xml_loadsave_cup.c cup.h file.h misc.h table.h team.h xml.h xml_loadsave_cup.h xml_loadsave_fixtures.h xml_loadsave_table.h xml_loadsave_teams.h \
xml_loadsave_fixtures.c file.h fixture.h misc.h team.h xml.h xml_loadsave_fixtures.h \
xml_loadsave_jobs.c file.h free.h job.h misc.h variables.h xml.h xml_loadsave_jobs.h xml_loadsave_teams.h \
xml_loadsave_league.c file.h league.h misc.h xml.h xml_loadsave_cup.h xml_loadsave_fixtures.h xml_loadsave_league.h xml_loadsave_league_stat.h xml_loadsave_table.h xml_loadsave_teams.h \
xml_loadsave_leagues_cups.c cup.h file.h free.h league_struct.h misc.h xml.h xml_loadsave_cup.h xml_loadsave_league.h xml_loadsave_leagues_cups.h \
xml_loadsave_league_stat.c file.h misc.h stat.h team.h xml.h xml_loadsave_league_stat.h \
xml_loadsave_live_game.c cup.h file.h fixture.h league.h live_game.h misc.h option.h variables.h xml.h xml_loadsave_live_game.h \
xml_loadsave_misc.c bet_struct.h cup.h file.h fixture.h free.h misc.h variables.h xml.h xml_loadsave_cup.h xml_loadsave_league.h xml_loadsave_misc.h \
xml_loadsave_players.c misc.h player.h team.h xml.h xml_loadsave_players.h \
xml_loadsave_season_stats.c file.h free.h misc.h stat.h variables.h xml.h xml_loadsave_league_stat.h xml_loadsave_season_stats.h \
xml_loadsave_table.c file.h misc.h team.h xml.h xml_loadsave_table.h \
xml_loadsave_teams.c file.h misc.h player.h team.h xml.h xml_loadsave_players.h xml_loadsave_teams.h \
xml_loadsave_transfers.c file.h misc.h team.h transfer.h xml.h xml_loadsave_transfers.h \
xml_loadsave_users.c bet_struct.h file.h fixture.h misc.h team.h user.h variables.h xml.h xml_loadsave_live_game.h xml_loadsave_players.h xml_loadsave_users.h \
xml_cup.c cup.h file.h main.h misc.h option.h variables.h xml_cup.h \
xml_country.c file.h free.h misc.h option.h variables.h xml_country.h xml_cup.h xml_league.h \
xml_league.c cup_struct.h file.h free.h league.h misc.h option.h table.h team.h variables.h xml_cup.h xml_league.h \
xml_lg_commentary.c free.h lg_commentary.h live_game.h misc.h variables.h xml_lg_commentary.h \
xml_mmatches.c file.h free.h live_game.h misc.h user.h xml.h xml_loadsave_live_game.h xml_mmatches.h \
xml_name.c file.h free.h misc.h name.h variables.h xml_name.h \
xml_strategy.c file.h free.h main.h misc.h strategy_struct.h xml_strategy.h \
xml_team.c file.h free.h main.h misc.h option.h player.h team.h variables.h xml_team.h \
youth_academy.c free.h maths.h name.h option.h player.h team.h user.h youth_academy.h
bygfoot_LDADD = @PACKAGE_LIBS@ @GST_LIBS@ $(INTLLIBS)

View File

@ -0,0 +1,272 @@
/*
bet.c
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "bet.h"
#include "finance.h"
#include "fixture.h"
#include "game_gui.h"
#include "league.h"
#include "main.h"
#include "maths.h"
#include "misc.h"
#include "option.h"
#include "player.h"
#include "support.h"
#include "treeview2.h"
#include "user.h"
/** Round a betting odd to a multiple of 0.05. */
gfloat
bet_round_odd(gfloat odd)
{
gint local_odd = (gint)rint(odd * 100);
if(local_odd % 5 == 0)
return odd;
if(local_odd % 5 >= 3)
return (gfloat)(local_odd + (5 - local_odd % 5)) / 100;
return (gfloat)(local_odd - local_odd % 5) / 100;
}
/** Find the bet containing the fixture. */
BetMatch*
bet_from_fixture(gint fix_id)
{
gint i, j;
for(i=1;i>=0;i--)
for(j=0;j<bets[i]->len;j++)
if(g_array_index(bets[i], BetMatch, j).fix_id == fix_id)
return &g_array_index(bets[i], BetMatch, j);
main_exit_program(EXIT_BET_ERROR,
"bet_from_fixture: bet going with fixture %d not found",
fix_id);
return NULL;
}
/** Manage the bets made by the users. */
void
bet_update_user_bets(void)
{
gint i, j, outcome;
const BetMatch *bet = NULL;
const Fixture *fix = NULL;
for(i=0;i<users->len;i++)
{
g_array_free(usr(i).bets[0], TRUE);
usr(i).bets[0] = g_array_new(FALSE, FALSE, sizeof(BetUser));
for(j=0;j<usr(i).bets[1]->len;j++)
{
bet = bet_from_fixture(g_array_index(usr(i).bets[1], BetUser, j).fix_id);
fix = fixture_from_id(g_array_index(usr(i).bets[1], BetUser, j).fix_id, TRUE);
if(fix->result[0][0] < fix->result[1][0])
outcome = 2;
else
outcome = (fix->result[0][0] == fix->result[1][0]);
if(outcome == g_array_index(usr(i).bets[1], BetUser, j).outcome)
{
usr(i).money +=
(gint)rint((gfloat)g_array_index(usr(i).bets[1], BetUser, j).wager *
bet->odds[outcome]);
usr(i).money_in[1][MON_IN_BETS] +=
(gint)rint((gfloat)g_array_index(usr(i).bets[1], BetUser, j).wager *
bet->odds[outcome]);
g_array_index(usr(i).bets[1], BetUser, j).wager =
(gint)rint((gfloat)g_array_index(usr(i).bets[1], BetUser, j).wager *
bet->odds[outcome]);
}
else
{
usr(i).money -=
g_array_index(usr(i).bets[1], BetUser, j).wager;
usr(i).money_out[1][MON_OUT_BETS] -=
g_array_index(usr(i).bets[1], BetUser, j).wager;
g_array_index(usr(i).bets[1], BetUser, j).wager *= -1;
}
g_array_append_val(usr(i).bets[0],
g_array_index(usr(i).bets[1], BetUser, j));
}
g_array_free(usr(i).bets[1], TRUE);
usr(i).bets[1] = g_array_new(FALSE, FALSE, sizeof(BetUser));
}
}
/** Calculate the odds for the bet. */
void
bet_get_odds(BetMatch *bet)
{
const Fixture *fix = fixture_from_id(bet->fix_id, TRUE);
gfloat home_advantage = (fix->home_advantage) ?
(const_float("float_game_home_advantage_lower") +
const_float("float_game_home_advantage_upper")) / 2 : 0;
gfloat av_skill[2] = {0, 0}, skilldiff;
gint i, j, better_idx;
for(i=0;i<2;i++)
{
for(j=0;j<11;j++)
av_skill[i] +=
player_get_game_skill(player_of_idx_team(fix->teams[i], j),
FALSE, TRUE);
av_skill[i] /= 11;
}
av_skill[0] *= (1 + home_advantage);
skilldiff = ABS(av_skill[0] - av_skill[1]);
better_idx = 2 * (av_skill[0] < av_skill[1]);
bet->odds[better_idx] =
0.33 + skilldiff * const_float("float_bet_better_factor");
bet->odds[2 - better_idx] =
0.33 + skilldiff * const_float("float_bet_worse_factor");
for(i=0;i<2;i++)
bet->odds[i * 2] = CLAMP(bet->odds[i * 2],
const_float("float_bet_lower_limit"),
1 - const_float("float_bet_lower_limit"));
bet->odds[1] = (1 - bet->odds[0] - bet->odds[2]);
bet->odds[1] = CLAMP(bet->odds[1],
const_float("float_bet_lower_limit"),
1 - const_float("float_bet_lower_limit"));
for(i=0;i<3;i++)
bet->odds[i] =
bet_round_odd((1 / bet->odds[i]) *
(1 - const_float("float_bet_commission_decrease")));
}
/** Write the bets for the current week round. */
void
bet_update(void)
{
gint i;
GPtrArray *fixtures = fixture_get_week_list(week, week_round);
BetMatch new_bet;
bet_update_user_bets();
g_array_free(bets[0], TRUE);
bets[0] = g_array_new(FALSE, FALSE, sizeof(BetMatch));
for(i=0;i<bets[1]->len;i++)
g_array_append_val(bets[0],
g_array_index(bets[1], BetMatch, i));
g_array_free(bets[1], TRUE);
bets[1] = g_array_new(FALSE, FALSE, sizeof(BetMatch));
for(i=0;i<fixtures->len;i++)
if(fixture_user_team_involved((Fixture*)g_ptr_array_index(fixtures, i)) == -1)
{
new_bet.fix_id = ((Fixture*)g_ptr_array_index(fixtures, i))->id;
bet_get_odds(&new_bet);
g_array_append_val(bets[1], new_bet);
}
g_ptr_array_free(fixtures, TRUE);
}
/** Return the user bet if the user betted on the bet or NULL. */
BetUser*
bet_is_user(const BetMatch *bet)
{
gint i, j;
for(i=1;i>=0;i--)
for(j=0;j<current_user.bets[i]->len;j++)
if(bet->fix_id == g_array_index(current_user.bets[i], BetUser, j).fix_id)
return &g_array_index(current_user.bets[i], BetUser, j);
return NULL;
}
/** Place a new bet.
@return TRUE on success, FALSE otherwise. */
gboolean
bet_place(gint fix_id, gint outcome, gint wager)
{
gint max_wager = (gint)rint(finance_wage_unit(current_user.tm) *
const_float("float_bet_wager_limit_factor"));
BetUser new_bet;
gchar buf[SMALL];
if(wager <= 0)
return TRUE;
if(wager > BUDGET(cur_user))
{
game_gui_show_warning(_("You don't have the money."));
return FALSE;
}
if(wager > max_wager)
{
misc_print_grouped_int(max_wager, buf);
game_gui_show_warning(_("The betting office doesn't allow you to wager more than %s."), buf);
gtk_spin_button_set_value(
GTK_SPIN_BUTTON(lookup_widget(window.digits, "spinbutton1")),
(gdouble)max_wager);
return FALSE;
}
new_bet.fix_id = fix_id;
new_bet.outcome = outcome;
new_bet.wager = wager;
g_array_append_val(current_user.bets[1], new_bet);
if(window.bets != NULL)
treeview2_show_bets();
return TRUE;
}
/** Remove the bet on the given fixture. */
void
bet_remove(gint fix_id)
{
gint i;
for(i=0;i<current_user.bets[1]->len;i++)
if(g_array_index(current_user.bets[1], BetUser, i).fix_id == fix_id)
{
g_array_remove_index(current_user.bets[1], i);
return;
}
}

View File

@ -0,0 +1,57 @@
/*
bet.h
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef BET_H
#define BET_H
#include "bet_struct.h"
#include "bygfoot.h"
#include "fixture_struct.h"
BetMatch*
bet_from_fixture(gint fix_id);
void
bet_update_user_bets(void);
void
bet_get_odds(BetMatch *bet);
void
bet_update(void);
gfloat
bet_round_odd(gfloat odd);
BetUser*
bet_is_user(const BetMatch *bet);
gboolean
bet_place(gint fix_id, gint outcome, gint wager);
void
bet_remove(gint fix_id);
#endif

View File

@ -0,0 +1,53 @@
/*
bet_struct.h
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef BET_STRUCT_H
#define BET_STRUCT_H
#include "bygfoot.h"
#include "fixture_struct.h"
/** A struct representing a betting possibility: a fixture plus odds. */
typedef struct
{
/** The match the bet is about. */
gint fix_id;
/** The odds for a win, draw or loss of the first team. */
gfloat odds[3];
} BetMatch;
/** A struct representing a bet by a user. */
typedef struct
{
/** Match the user betted on. */
gint fix_id;
/** Which outcome he picked. */
gint outcome;
/** How much he wagered. */
gint wager;
} BetUser;
#endif

View File

@ -0,0 +1,172 @@
/*
bygfoot.h
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef BYGFOOT_H
#define BYGFOOT_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gtk/gtk.h>
#include "gettext_macros.h"
/**
* Program version number.
*/
#define VERS "2.1.0"
/** Home dir name */
//#define HOMEDIRNAME ".bygfoot-cvs"
#define HOMEDIRNAME ".bygfoot"
/**
* Convenience macros, used for string sizes (typically buf[SMALL]).
*/
#define SMALL 10000
#define BIG 1000000
/** Starting numbers of league, cup and supercup numerical ids. */
#define ID_LEAGUE_START 1000
#define ID_CUP_START 7000
#define player_id_new (counters[COUNT_PLAYER_ID]++)
#define team_id_new (counters[COUNT_TEAM_ID]++)
#define cup_id_new (counters[COUNT_CUP_ID]++)
#define league_id_new (counters[COUNT_LEAGUE_ID]++)
#define fixture_id_new (counters[COUNT_FIX_ID]++)
#define lg_commentary_id_new (counters[COUNT_LG_COMM_ID]++)
/** 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 acps country.allcups
/** Convenience abbreviation. */
#define acp(i) ((Cup*)g_ptr_array_index(country.allcups, i))
/** Convenience abbrevs. */
#define stat0 status[0]
#define stat1 status[1]
#define stat2 status[2]
#define stat3 status[3]
#define stat4 status[4]
#define stat5 status[5]
#define debug const_int("int_debug")
/**
* Exit codes.
*/
enum ExitCodes
{
EXIT_OK = 0, /**< Normal exit. */
EXIT_GENERAL, /**< A general, multi-purpose exit code. */
EXIT_NO_COUNTRY_FILES, /**< Exit when no country files have been found. */
EXIT_FILE_OPEN_FAILED, /**< A file could not be opened. */
EXIT_PRINT_ERROR, /**< Exit when the print_error function is called on a set error.*/
EXIT_NO_LEAGUES, /**< The game must contain at least one league. */
EXIT_CHOOSE_TEAM_ERROR, /**< There was a problem loading the choose_teams. @see cup_load_choose_teams() */
EXIT_FIXTURE_WRITE_ERROR, /**< There was an error writing the fixtures. */
EXIT_USER_FIRED, /**< Single user was fired and didn't accept the new offer. */
EXIT_FIRST_WEEK_ERROR, /**< First week of cup was negative. */
EXIT_OPTION_NOT_FOUND, /**< An option couldn't be found. */
EXIT_POINTER_NOT_FOUND, /**< We didn't find a pointer needed. */
EXIT_INT_NOT_FOUND, /**< We didn't find an integer value (mostly indices). */
EXIT_FILE_NOT_FOUND, /**< Some file couldn't be found. */
EXIT_NO_SUPPORT_DIR, /**< No support directory found. */
EXIT_CUP_ROUND_ERROR, /**< Too few cup rounds. */
EXIT_LOAD_TEAM_DEF, /**< Error loading a team definition file. */
EXIT_DEF_SORT, /**< Error sorting a team after loading the definition. */
EXIT_PROM_REL, /**< Error when executing the promotion/relegation stuff. */
EXIT_STRATEGY_ERROR, /**< Error related to CPU strategies. */
EXIT_BET_ERROR, /**< Error related to betting. */
EXIT_END
};
/**
* A struct representing a country.
*/
typedef struct
{
gchar *name, /**< Name of the country. */
*symbol, /**< Symbol of the country, eg a flag pixmap. */
*sid; /**< Id of the country, eg 'england'. */
/** A rating point from 0-10 telling us
how good the first league of the country is.
Spain, for instance, has rating 10, whereas Ireland has only 5. */
gint rating;
/** Leagues and cups arrays. */
GArray *leagues, *cups;
/** Pointer array holding all cups. */
GPtrArray *allcups;
} Country;
/** Struct used for having all the windows
in one place. */
typedef struct
{
GtkWidget *main,
*startup,
*live,
*warning,
*progress,
*digits,
*stadium,
*job_offer,
*yesno,
*options,
*font_sel,
*file_chooser,
*contract,
*menu_player,
*menu_youth,
*user_management,
*wdebug,
*help,
*transfer_dialog,
*sponsors,
*mmatches,
*bets,
*splash;
/** The position of the horizontal divider is stored here. */
gint paned_pos;
} Windows;
#endif

View File

@ -0,0 +1,807 @@
/*
callback_func.c
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "callback_func.h"
#include "callbacks.h"
#include "cup.h"
#include "finance.h"
#include "fixture.h"
#include "game_gui.h"
#include "gui.h"
#include "league.h"
#include "live_game.h"
#include "maths.h"
#include "misc.h"
#include "option.h"
#include "player.h"
#include "start_end.h"
#include "team.h"
#include "transfer.h"
#include "treeview.h"
#include "treeview_helper.h"
#include "user.h"
#include "window.h"
#include "bet.h"
/** Show the users' live games. */
void
callback_show_next_live_game(void)
{
gint i, j;
for(i=0;i<users->len;i++)
usr(i).counters[COUNT_USER_TOOK_TURN] = 0;
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 &&
option_int("int_opt_user_show_live_game",
&usr(fixture_user_team_involved(&g_array_index(lig(i).fixtures, Fixture, j))).
options))
{
live_game_calculate_fixture(&g_array_index(lig(i).fixtures, Fixture, j));
return;
}
for(i=0;i<acps->len;i++)
for(j=0;j<acp(i)->fixtures->len;j++)
if(g_array_index(acp(i)->fixtures, Fixture, j).week_number == week &&
g_array_index(acp(i)->fixtures, Fixture, j).week_round_number == week_round &&
fixture_user_team_involved(&g_array_index(acp(i)->fixtures, Fixture, j)) != -1 &&
g_array_index(acp(i)->fixtures, Fixture, j).attendance == -1 &&
option_int("int_opt_user_show_live_game",
&usr(fixture_user_team_involved(&g_array_index(acp(i)->fixtures, Fixture, j))).
options))
{
live_game_calculate_fixture(&g_array_index(acp(i)->fixtures, Fixture, j));
return;
}
window_destroy(&window.live);
/* no more user games to show: end round. */
end_week_round();
setsav0;
}
/** 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(stat0 == STATUS_SHOW_TRANSFER_LIST)
{
selected_row = -1;
transfer_add_remove_user_player(player_of_idx_team(current_user.tm, idx));
}
else if(stat0 == STATUS_SHOW_YA)
{
selected_row = idx;
on_menu_move_to_youth_academy_activate(NULL, NULL);
}
else
{
if(selected_row == -1)
{
selected_row = idx;
return;
}
player_swap(current_user.tm, selected_row,
current_user.tm, idx);
if(opt_user_int("int_opt_user_swap_adapts") == 1 &&
current_user.tm->structure !=
team_find_appropriate_structure(current_user.tm))
{
team_change_structure(current_user.tm,
team_find_appropriate_structure(current_user.tm));
team_rearrange(current_user.tm);
}
game_gui_write_av_skills(NULL);
selected_row = -1;
treeview_show_user_player_list();
if(stat0 == STATUS_MAIN)
treeview_show_next_opponent();
}
}
else if(event->button == 3)
{
selected_row = idx;
window_show_menu_player((GdkEvent*)event);
}
setsav0;
}
/** Show the last match of the current user.
@param start Whether we start the replay from the beginning or continue it. */
void
callback_show_last_match(gboolean start, LiveGame *lg)
{
gint i;
stat4 = -1;
if(start)
{
stat2 = cur_user;
statp = lg;
window_create(WINDOW_LIVE);
gui_set_sensitive_lg_meters(FALSE);
treeview_show_game_stats(
GTK_TREE_VIEW(lookup_widget(window.live, "treeview_stats")), lg);
}
else
{
gtk_widget_set_sensitive(lookup_widget(window.live, "button_pause"), TRUE);
gtk_widget_set_sensitive(lookup_widget(window.live, "button_resume"), FALSE);
}
for(i=stat3;i<lg->units->len;i++)
{
game_gui_live_game_show_unit(&g_array_index(lg->units, LiveGameUnit, i));
if(stat4 == STATUS_SHOW_LAST_MATCH_PAUSE ||
stat4 == STATUS_SHOW_LAST_MATCH_ABORT)
{
stat3 = i + 1;
break;
}
}
if(stat4 == STATUS_SHOW_LAST_MATCH_PAUSE)
{
gtk_widget_set_sensitive(lookup_widget(window.live, "button_pause"), FALSE);
gtk_widget_set_sensitive(lookup_widget(window.live, "button_resume"), TRUE);
}
else if(stat4 == STATUS_SHOW_LAST_MATCH_ABORT)
{
window_destroy(&window.live);
stat1 = stat2 = stat3 = stat4 = -1;
}
else
stat3 = -1;
}
/** Show the last match stats of the current user. */
void
callback_show_last_match_stats(void)
{
current_user.live_game.fix =
fixture_from_id(current_user.live_game.fix_id, TRUE);
treeview_show_game_stats(GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right")),
&current_user.live_game);
}
/** Show fixtures by week and round (as opposed to
competition-wise).
@param type Whether to show current, next or previous weeks. */
void
callback_show_fixtures_week(gint type)
{
switch(type)
{
default:
g_warning("callback_show_fixtures_week: unknown type %d \n", type);
return;
break;
case SHOW_CURRENT:
if(week == 1 && week_round == 1)
{
stat1 = week;
stat2 = week_round;
}
else if(week_round == 1)
{
stat1 = week - 1;
stat2 = fixture_get_last_week_round(week - 1);
}
else
{
stat1 = week;
stat2 = week_round - 1;
}
break;
case SHOW_NEXT:
fixture_get_next_week(&stat1, &stat2);
break;
case SHOW_PREVIOUS:
fixture_get_previous_week(&stat1, &stat2);
break;
}
treeview_show_fixtures_week(stat1, stat2);
}
/** Show some fixtures.
@param type An integer telling us which league/cup and which
week and round to show. */
void
callback_show_fixtures(gint type)
{
const Fixture *fix = fixture_get(type, stat1, stat2, stat3,
current_user.tm);
treeview_show_fixtures(GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right")),
fix->clid, fix->week_number, fix->week_round_number);
stat1 = fix->clid;
stat2 = fix->week_number;
stat3 = fix->week_round_number;
}
/** Show tables.
@type Integer telling us whether to show the current user's
tables or those of the previous/next league/cup. */
void
callback_show_tables(gint type)
{
gint clid = -1;
if(type == SHOW_CURRENT)
clid = team_get_table_clid(current_user.tm);
else if(type == SHOW_NEXT_LEAGUE)
clid = league_cup_get_next_clid(stat1, FALSE);
else if(type == SHOW_PREVIOUS_LEAGUE)
clid = league_cup_get_previous_clid(stat1, FALSE);
else
{
g_warning("callback_show_tables: unknown type %d \n", type);
return;
}
while((clid < ID_CUP_START && !league_from_clid(clid)->active) ||
(clid >= ID_CUP_START && cup_has_tables(clid) == -1))
{
if(type == SHOW_PREVIOUS_LEAGUE)
clid = league_cup_get_previous_clid(clid, FALSE);
else
clid = league_cup_get_next_clid(clid, FALSE);
}
stat1 = clid;
treeview_show_table(GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right")),
clid);
}
/** Open the digits window to get a loan. */
void
callback_get_loan(void)
{
gchar buf[SMALL], buf2[SMALL];
gint max_loan =
finance_team_drawing_credit_loan(current_user.tm, TRUE) + current_user.debt;
if(max_loan <= 0)
{
game_gui_print_message(_("The bank doesn't grant you more money."));
return;
}
stat1 = STATUS_GET_LOAN;
misc_print_grouped_int(max_loan, buf2);
sprintf(buf, _("You can take out at most %s."), buf2);
window_show_digits(buf, _("Loan"), max_loan, NULL, 0);
}
/** Open the digits window to pay back a loan. */
void
callback_pay_loan(void)
{
gchar buf[SMALL], buf2[SMALL];
gint max_payback = MIN(BUDGET(cur_user), -current_user.debt);
if(current_user.debt == 0)
{
game_gui_print_message(_("You are not indebted."));
return;
}
if(max_payback <= 0)
{
game_gui_print_message(_("You don't have enough money to pay back."));
return;
}
stat1 = STATUS_PAY_LOAN;
misc_print_grouped_int(max_payback, buf2);
sprintf(buf, _("You can pay back at most %s"), buf2);
window_show_digits(buf, _("Payback"), max_payback, NULL, 0);
}
/** Manage a click on a player of the current team on the
transfer list.
@param button The mouse button number.
@param idx The index of the selected player in the transfer list. */
void
callback_transfer_list_user(gint button, gint idx)
{
gchar buf[SMALL],
buf2[SMALL], buf3[SMALL];
if(button == 3 ||
(button == 1 && trans(idx).offers->len == 0))
{
transfer_remove_player(idx);
on_button_transfers_clicked(NULL, NULL);
setsav0;
}
else if(button == 1)
{
if(trans(idx).offers->len > 0 &&
transoff(idx, 0).status != TRANSFER_OFFER_ACCEPTED)
game_gui_print_message(_("There are some offers for the player which you rejected or will see next week."));
else
{
misc_print_grouped_int(transoff(idx, 0).fee, buf2);
misc_print_grouped_int(ABS(transoff(idx, 0).fee -
player_of_id_team(current_user.tm,
trans(idx).id)->value), buf3);
if(transoff(idx, 0).fee -
player_of_id_team(current_user.tm, trans(idx).id)->value > 0)
strcat(buf3, _(" more"));
else
strcat(buf3, _(" less"));
sprintf(buf, _("%s would like to buy %s. They offer %s for him, which is %s than the player's value. Do you accept?"), transoff(idx, 0).tm->name,
player_of_id_team(current_user.tm, trans(idx).id)->name,
buf2, buf3);
stat1 = STATUS_TRANSFER_OFFER_USER;
stat2 = idx;
window_show_transfer_dialog(buf);
}
}
}
/** Handle a click on a cpu player for which the offer
got accepted. */
void
callback_transfer_list_cpu(gint button, gint idx)
{
gchar buf[SMALL], buf2[SMALL], buf3[SMALL];
if(button == 2)
return;
if(button == 3)
{
g_array_remove_index(trans(idx).offers, 0);
if(trans(idx).offers->len > 0)
transfer_offers_notify(&trans(idx), FALSE);
game_gui_print_message(_("Your offer has been removed."));
on_button_transfers_clicked(NULL, NULL);
return;
}
if(current_user.tm->players->len == const_int("int_team_max_players"))
{
game_gui_show_warning(_("Your roster is already full. You can't buy more players."));
return;
}
misc_print_grouped_int(transoff(idx, 0).fee, buf2);
misc_print_grouped_int(transoff(idx, 0).wage, buf3);
sprintf(buf, _("You offered a transfer fee of %s and a wage of %s for %s. The owners and the player are satisfied with your offer. Do you still want to buy the player?"),
buf2, buf3, player_of_id_team(trans(idx).tm, trans(idx).id)->name);
stat1 = STATUS_TRANSFER_OFFER_CPU;
stat2 = idx;
window_show_transfer_dialog(buf);
}
/** Handle a click on the transfer list.
@param button The mouse button number.
@param idx The index of the selected player in the transfer list. */
void
callback_transfer_list_clicked(gint button, gint idx)
{
gchar buf[SMALL];
Transfer *tr = &trans(idx);
gint old_fee, old_wage = -1;
if(tr->tm == current_user.tm)
{
callback_transfer_list_user(button, idx);
return;
}
else if(tr->offers->len > 0 &&
transoff(idx, 0).status == TRANSFER_OFFER_ACCEPTED)
{
if(transoff(idx, 0).tm == current_user.tm)
{
if(team_is_user(tr->tm) != -1)
{
game_gui_print_message(_("User %s didn't consider your offer yet."),
user_from_team(tr->tm)->name);
}
else
callback_transfer_list_cpu(button, idx);
}
else
game_gui_print_message(_("The player is locked (the team owners are considering an offer currently)."));
return;
}
if(week >= transfer_get_deadline())
{
game_gui_print_message(_("The transfer deadline is over."));
return;
}
stat1 = STATUS_SHOW_TRANSFER_LIST;
stat2 = idx;
if(tr->offers->len > 0)
transfer_get_previous_offer(tr, current_user.tm, &old_fee, &old_wage);
if(old_wage == -1)
{
sprintf(buf, _("You are making an offer for %s. Your scout's recommendations for fee and wage are preset."),
player_of_id_team(tr->tm, tr->id)->name);
window_show_digits(buf, _("Fee"), tr->fee[current_user.scout % 10],
_("Wage"), tr->wage[current_user.scout % 10]);
}
else
{
sprintf(buf, _("You are making an offer for %s again. Your previous values for fee and wage are preset."),
player_of_id_team(tr->tm, tr->id)->name);
window_show_digits(buf, _("Fee"), old_fee, _("Wage"), old_wage);
}
}
/** Show the contract window for the player with the specified index. */
void
callback_offer_new_contract(gint idx)
{
gint i;
gchar buf[SMALL];
Player *pl = player_of_idx_team(current_user.tm, idx);
gfloat scout_dev = math_rnd(-const_float("float_transfer_scout_deviance_wage"),
const_float("float_transfer_scout_deviance_wage")) *
(current_user.scout % 10 + 1);
GtkSpinButton *spinbuttons[4];
if(pl->contract >= 2)
{
game_gui_show_warning(_("You can't offer a new contract if the old one is still above 2 years."));
return;
}
else if(pl->offers == const_int("int_contract_max_offers"))
{
game_gui_show_warning(_("The player won't negotiate with you anymore."));
return;
}
stat1 = player_assign_wage(pl);
statp = (gpointer)pl;
if(pl->age < pl->peak_age)
stat1 = MAX(stat1, pl->wage);
else
stat1 = MIN(stat1, pl->wage);
window_create(WINDOW_CONTRACT);
sprintf(buf, _("You are negotiating with %s about a new contract. Pay attention to what you're doing; if you don't come to terms with him within %d offers, he's going to leave your team after his current contract expires (unless you sell him). You may only abort BEFORE making the first offer.\nYour scout's recommendations are preset:"),
pl->name,
const_int("int_contract_max_offers"));
gtk_label_set_text(GTK_LABEL(lookup_widget(window.contract, "label_contract")), buf);
for(i=0;i<4;i++)
{
sprintf(buf, "spinbutton_contract%d", i + 1);
spinbuttons[i] = GTK_SPIN_BUTTON(lookup_widget(window.contract, buf));
gtk_spin_button_set_value(spinbuttons[i],
rint((gfloat)stat1 *
(1 + (i * const_float("float_contract_scale_factor") *
powf(-1, (pl->age > pl->peak_age)))) *
(1 + scout_dev)));
}
setsav0;
}
/** Show the player list of a team in the browse-teams mode. */
void
callback_show_team(gint type)
{
GtkTreeView *treeview_right =
GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right"));
const Team *tm;
const GArray *teams = NULL;
const GPtrArray *teamsp = NULL;
gint len = -1;
if(type == SHOW_CURRENT)
{
tm = (const Team*)treeview_helper_get_pointer(treeview_right, 2);
stat1 = team_get_index(tm);
stat2 = tm->clid;
}
else
{
if(type == SHOW_NEXT_LEAGUE)
{
stat2 = league_cup_get_next_clid(stat2, TRUE);
while(stat2 >= ID_CUP_START && cup_from_clid(stat2)->teams->len == 0)
stat2 = league_cup_get_next_clid(stat2, TRUE);
}
else if(type == SHOW_PREVIOUS_LEAGUE)
{
stat2 = league_cup_get_previous_clid(stat2, TRUE);
while(stat2 >= ID_CUP_START && cup_from_clid(stat2)->teams->len == 0)
stat2 = league_cup_get_previous_clid(stat2, TRUE);
}
if(stat2 < ID_CUP_START)
{
teams = (GArray*)league_cup_get_teams(stat2);
len = teams->len;
}
else
{
teamsp = (GPtrArray*)league_cup_get_teams(stat2);
len = teamsp->len;
}
if(type == SHOW_NEXT)
stat1 = (stat1 == len - 1) ? 0 : stat1 + 1;
else if(type == SHOW_PREVIOUS)
stat1 = (stat1 == 0) ? len - 1 : stat1 - 1;
else
stat1 = 0;
if(stat2 < ID_CUP_START)
tm = &g_array_index(teams, Team, stat1);
else
tm = (Team*)g_ptr_array_index(teamsp, stat1);
}
stat0 = STATUS_BROWSE_TEAMS;
if(tm != current_user.tm)
{
treeview_show_player_list_team(treeview_right, tm, current_user.scout % 10);
game_gui_write_av_skills(tm);
}
else
callback_show_team((type == SHOW_PREVIOUS) ? SHOW_PREVIOUS : SHOW_NEXT);
}
/** Show a sortable list of all players in a league or cup. */
void
callback_show_player_list(gint type)
{
stat0 = STATUS_SHOW_PLAYER_LIST;
switch(type)
{
default:
g_warning("callback_show_player_list: unknown type %d \n", type);
return;
break;
case SHOW_CURRENT:
stat1 = current_user.tm->clid;
break;
case SHOW_NEXT_LEAGUE:
stat1 = league_cup_get_next_clid(stat1, TRUE);
while(stat1 >= ID_CUP_START && cup_from_clid(stat1)->teams->len == 0)
stat1 = league_cup_get_next_clid(stat1, TRUE);
break;
case SHOW_PREVIOUS_LEAGUE:
stat1 = league_cup_get_previous_clid(stat1, TRUE);
while(stat1 >= ID_CUP_START && cup_from_clid(stat1)->teams->len == 0)
stat1 = league_cup_get_previous_clid(stat1, TRUE);
break;
}
treeview_show_all_players(stat1);
}
/** Fire a player. */
void
callback_fire_player(gint idx)
{
gchar buf[SMALL], buf2[SMALL];
Player *pl = player_of_idx_team(current_user.tm, idx);
stat1 = STATUS_FIRE_PLAYER;
stat2 = idx;
stat3 = (gint)rint(pl->wage * const_float("float_player_fire_wage_factor") * pl->contract);
misc_print_grouped_int(stat3, buf2);
sprintf(buf, _("You want to fire %s. Since his contract expires in %.1f years, he demands a compensation of %s. Do you accept?"), pl->name, pl->contract, buf2);
window_show_yesno(buf);
}
/** Show a page with the information in the league stats
structure. */
void
callback_show_league_stats(gint type)
{
switch(type)
{
default:
g_warning("callback_show_league_stats: unknown type %d \n", type);
return;
break;
case SHOW_CURRENT:
stat1 = current_user.tm->clid;
while(stat1 >= ID_CUP_START ||
!league_from_clid(stat1)->active)
stat1 = league_cup_get_next_clid(stat1, FALSE);
break;
case SHOW_NEXT_LEAGUE:
stat1 = league_cup_get_next_clid(stat1, FALSE);
while(stat1 >= ID_CUP_START)
stat1 = league_cup_get_next_clid(stat1, FALSE);
break;
case SHOW_PREVIOUS_LEAGUE:
stat1 = league_cup_get_previous_clid(stat1, FALSE);
while(stat1 >= ID_CUP_START)
stat1 = league_cup_get_previous_clid(stat1, FALSE);
break;
}
treeview_show_league_stats(stat1);
}
/** Show the appropriate season history page in the right treeview. */
void
callback_show_season_history(gint type)
{
const SeasonStat *stat = NULL;
gint len = season_stats->len;
switch(type)
{
default:
g_warning("callback_show_season_history: unknown type %d \n", type);
return;
break;
case SHOW_CURRENT:
stat1 = -1;
stat2 = len - 1;
break;
case SHOW_NEXT_LEAGUE:
stat = &g_array_index(season_stats, SeasonStat, stat2);
if(stat1 == -1)
stat1 = 0;
else if(stat1 == stat->league_champs->len - 1)
stat1 = -1;
else
stat1++;
break;
case SHOW_PREVIOUS_LEAGUE:
stat = &g_array_index(season_stats, SeasonStat, stat2);
if(stat1 == -1)
stat1 = stat->league_champs->len - 1;
else if(stat1 == 0)
stat1 = -1;
else
stat1--;
break;
case SHOW_NEXT:
stat2 = (stat2 + 1) % len;
break;
case SHOW_PREVIOUS:
stat2 = (stat2 == 0) ? len - 1 : stat2 - 1;
break;
}
treeview_show_season_history(stat1, stat2);
}
/** Show the player list of the next opponent. */
void
callback_show_next_opponent(void)
{
const Fixture *fix = team_get_fixture(current_user.tm, FALSE);
const Team *opp = (fix == NULL) ? NULL :
fix->teams[fix->teams[0] == current_user.tm];
GtkTreeView *treeview_right =
GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right"));
if(opp == NULL)
return;
stat0 = STATUS_BROWSE_TEAMS;
stat1 = team_get_index(opp);
stat2 = opp->clid;
treeview_show_player_list_team(treeview_right, opp, current_user.scout % 10);
}
/** Show the player list after the user clicked on a player in
the browse players mode. */
void
callback_show_player_team(void)
{
GtkTreeView *treeview_right =
GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right"));
const Player *pl =
(const Player*)treeview_helper_get_pointer(treeview_right, 2);
stat0 = STATUS_BROWSE_TEAMS;
stat1 = team_get_index(pl->team);
stat2 = pl->team->clid;
treeview_show_player_list_team(treeview_right, pl->team, current_user.scout % 10);
}
/** Show the youth players of the current user. */
void
callback_show_youth_academy(void)
{
gint i;
PlayerListAttribute attributes;
for(i=0;i<PLAYER_LIST_ATTRIBUTE_END;i++)
attributes.on_off[i] = 0;
attributes.on_off[PLAYER_LIST_ATTRIBUTE_NAME] =
attributes.on_off[PLAYER_LIST_ATTRIBUTE_POS] =
attributes.on_off[PLAYER_LIST_ATTRIBUTE_SKILL] =
attributes.on_off[PLAYER_LIST_ATTRIBUTE_FITNESS] =
attributes.on_off[PLAYER_LIST_ATTRIBUTE_STATUS] =
attributes.on_off[PLAYER_LIST_ATTRIBUTE_AGE] =
attributes.on_off[PLAYER_LIST_ATTRIBUTE_ETAL] = 1;
if(stat0 != STATUS_SHOW_YA)
game_gui_print_message(_("Left click to move players to and from the youth academy; right click for context menu."));
treeview_show_player_list(
GTK_TREE_VIEW(lookup_widget(window.main, "treeview_right")),
player_get_pointers_from_array(current_user.youth_academy.players),
attributes, FALSE);
}

View File

@ -0,0 +1,89 @@
/*
callback_func.h
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef CALLBACK_FUNC_H
#define CALLBACK_FUNC_H
#include "bygfoot.h"
#include "live_game_struct.h"
void
callback_show_next_live_game(void);
void
callback_player_clicked(gint idx, GdkEventButton *event);
void
callback_show_last_match(gboolean start, LiveGame *lg);
void
callback_show_fixtures(gint type);
void
callback_show_tables(gint type);
void
callback_pay_loan(void);
void
callback_get_loan(void);
void
callback_transfer_list_clicked(gint button, gint idx);
void
callback_offer_new_contract(gint idx);
void
callback_show_team(gint type);
void
callback_show_player_list(gint type);
void
callback_fire_player(gint idx);
void
callback_show_last_match_stats(void);
void
callback_show_fixtures_week(gint type);
void
callback_show_league_stats(gint type);
void
callback_show_season_history(gint type);
void
callback_show_next_opponent(void);
void
callback_show_player_team(void);
void
callback_show_youth_academy(void);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,346 @@
/*
callbacks.h
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef CALLBACKS_H
#define CALLBACKS_H
#include "bygfoot.h"
#include "interface.h"
#include "support.h"
gboolean
on_button_quit_clicked (GtkWidget *widget,
GdkEvent *event,
gpointer user_data);
void
on_menu_new_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_open_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_save_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_save_as_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_quit_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_about_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_button_load_clicked (GtkButton *button,
gpointer user_data);
void
on_button_save_clicked (GtkButton *button,
gpointer user_data);
void
on_button_back_to_main_clicked (GtkButton *button,
gpointer user_data);
void
on_button_transfers_clicked (GtkButton *button,
gpointer user_data);
void
on_button_new_week_clicked (GtkButton *button,
gpointer user_data);
gboolean
on_player_list2_button_press_event (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data);
void
on_button_browse_clicked (GtkButton *button,
gpointer user_data);
void
on_button_browse_forward_clicked (GtkButton *button,
gpointer user_data);
void
on_button_browse_back_clicked (GtkButton *button,
gpointer user_data);
void
on_menu_preferences_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_fixtures_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_tables_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_season_history_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_put_on_transfer_list_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_remove_from_transfer_list_activate
(GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_fire_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_shoots_penalties_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_my_league_results_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_browse_teams_activate (GtkMenuItem *menuitem,
gpointer user_data);
gboolean
on_treeview_right_button_press_event (GtkWidget *widget,
GdkEventButton *event,
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_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_release_event (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data);
void
on_menu_manage_users_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_user_show_last_match_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_user_show_last_stats_activate (GtkMenuItem *menuitem,
gpointer user_data);
gboolean
on_eventbox_style_button_press_event (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data);
gboolean
on_eventbox_boost_button_press_event (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data);
void
on_button_cl_back_clicked (GtkButton *button,
gpointer user_data);
void
on_button_cl_forward_clicked (GtkButton *button,
gpointer user_data);
void
on_menu_show_finances_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_show_stadium_activate (GtkMenuItem *menuitem,
gpointer user_data);
gboolean
on_menu_check_button_press_event (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data);
void
on_menu_offer_new_contract_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_show_info_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_player_menu_put_on_transfer_list_activate
(GtkMenuItem *menuitem,
gpointer user_data);
void
on_player_menu_remove_from_transfer_list_activate
(GtkMenuItem *menuitem,
gpointer user_data);
void
on_player_menu_offer_new_contract_activate
(GtkMenuItem *menuitem,
gpointer user_data);
void
on_player_menu_fire_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_player_menu_shoots_penalties_activate
(GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_browse_players_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_player_menu_show_info_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_rearrange_team_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_load_last_save_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_fixtures_week_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_user_show_history_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_button_reset_players_clicked (GtkButton *button,
gpointer user_data);
void
on_menu_reset_players_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_league_stats_activate (GtkMenuItem *menuitem,
gpointer user_data);
gboolean
on_button_quit_button_press_event (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data);
void
on_menu_help_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_contributors_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_user_show_coming_matches_activate
(GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_show_youth_academy_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_set_investment_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_move_to_youth_academy_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_player_menu_move_to_youth_academy_activate
(GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_youth_move_to_team_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_youth_kick_out_of_academy_activate
(GtkMenuItem *menuitem,
gpointer user_data);
void
on_mm_add_last_match_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_mm_manage_matches_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_save_window_geometry_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_season_results_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_betting_activate (GtkMenuItem *menuitem,
gpointer user_data);
void
on_menu_show_job_exchange_activate (GtkMenuItem *menuitem,
gpointer user_data);
gboolean
on_hpaned2_button_release_event (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,129 @@
/*
cup.h
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef CUP_H
#define CUP_H
#include "bygfoot.h"
#include "cup_struct.h"
#include "fixture_struct.h"
#include "league_struct.h"
#define cup_get_last_tables_round(clid) &g_array_index(cup_from_clid(clid)->rounds, CupRound, cup_has_tables(clid))
#define cup_get_last_tables(clid) g_array_index(cup_from_clid(clid)->rounds, CupRound, cup_has_tables(clid)).tables
#define query_cup_has_property(clid, string) query_misc_string_in_array(string, cup_from_clid(clid)->properties)
#define query_cup_is_international(clid) query_cup_has_property(clid, "international")
#define query_cup_is_national(clid) query_cup_has_property(clid, "national")
#define query_cup_hide(clid) query_cup_has_property(clid, "hide")
#define query_cup_weak_at_home(clid) query_cup_has_property(clid, "weak_at_home")
Cup
cup_new(gboolean new_id);
CupChooseTeam
cup_choose_team_new(void);
CupRound
cup_round_new(void);
void
cup_reset(Cup *cup);
void
cup_get_team_pointers(Cup *cup, gint round);
void
cup_load_choose_team_generate(Cup *cup, CupRound *cup_round, const CupChooseTeam *ct);
void
cup_load_choose_team(Cup *cup, GPtrArray *teams, const CupChooseTeam *ct);
gint
cup_get_first_week_of_cup_round(Cup *cup, gint cup_round);
gint
cup_get_matchdays_in_cup_round(const Cup *cup, gint round);
gint
cup_round_get_number_of_teams(const Cup *cup, gint round);
gint
cup_round_get_byes(const Cup *cup, gint round);
gint
cup_round_get_new_teams(const CupRound *cup_round);
Cup*
cup_from_clid(gint clid);
Cup*
cup_from_sid(const gchar* sid);
void
cup_round_name(const Fixture *fix, gchar *buf);
GPtrArray*
cup_get_teams_sorted(const Cup *cup);
gint
cup_compare_success_tables(const Team *tm1, const Team *tm2, const Cup *cup, gint round);
gint
cup_compare_success(gconstpointer a, gconstpointer b, gpointer data);
gint
cup_compare_success_knockout(const Team *tm1, const Team *tm2, const GArray *fixtures);
gint
cup_get_round_reached(const Team *tm, const GArray *fixtures);
gboolean
query_cup_begins(const Cup *cup);
void
cup_get_choose_team_league_cup(const CupChooseTeam *ct,
const League **league, const Cup **cup);
gint
cup_get_last_week_from_first(const Cup *cup, gint first_week);
void
cup_get_round_name(const Cup *cup, gint round, gchar *buf);
gint
cup_has_tables(gint clid);
Team*
cup_get_winner(const Cup *cup);
gboolean
query_cup_transfer(void);
gchar*
cup_get_highlight_colour(const Cup *cup);
#endif

View File

@ -0,0 +1,165 @@
/*
cup_struct.h
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef CUP_STRUCT_H
#define CUP_STRUCT_H
#include "bygfoot.h"
#include "table_struct.h"
/** Rules for a round of a cup.
Cups consist of rounds, e.g. the final counts as
a round or the round robin games. */
typedef struct
{
/** Whether there are home and away games or only one leg.
Default: TRUE. */
gboolean home_away;
/** How many times a match gets repeated if there's a draw.
Default: 0. */
gint replay;
/** Whether the matches are on neutral ground.
Default: FALSE. */
gboolean neutral;
/** Whether the teams array gets randomised before writing the fixtures.
Default: TRUE. FALSE makes only sense in the first cup round. */
gboolean randomise_teams;
/** How many round robin groups there are.
Default: 0 (ie. no round robin). */
gint round_robin_number_of_groups;
/** How many teams advance from each group.
Default: -1. */
gint round_robin_number_of_advance;
/** How many teams advance apart from those that
are specified already (e.g. the first two advance
and additionally the best 3 from all the groups.
Default: 0. */
gint round_robin_number_of_best_advance;
/** Number of new teams participating in the cup round
(ie. teams that get loaded and are not advancing from a previous
round). */
gint new_teams;
/** The number of byes to be awarded for this cup round.
The default is enough to bring the next round to a power of two. */
gint byes;
/** Number of weeks the cup round is delayed (or scheduled sooner if
the value is negative) with respect to the previous cup round and
the week gap. Default: 0. */
gint delay;
/** The teams that got loaded for this cup round.
Mostly this only happens in the first round. */
GArray *teams;
/** Pointers to all teams loaded in the cup round; these
teams get passed to the fixture generation function
together with the teams advancing from the previous round. */
GPtrArray *team_ptrs;
/** Which new teams come into the cup (@see #CupChooseTeam) */
GArray *choose_teams;
/** The round robin tables (in case there is a round robin). */
GArray *tables;
} CupRound;
/**
Rules for choosing teams from the league files.
This could tell us to select the first three teams
from the league 'Italy 1' to participate in the cup.
*/
typedef struct
{
/** The string id of the league we choose from.
Default: "". */
gchar *sid;
/** The number of teams chosen.
Default: -1 (ie. all teams are chosen). */
gint number_of_teams;
/** The range from which the teams are chosen,
e.g. 2 and 5 means the teams from 2 to 5 are chosen
(given that 'number_of_teams' is 4).
Defaults: -1 (ie. the teams are chosen from the whole
range of teams in the league). */
gint start_idx, end_idx;
/** Whether the teams are chosen randomly,
ie. 3 random teams from the range 1-20.
Default: FALSE. */
gboolean randomly;
/** Whether the team is generated and loaded from
a league file or taken from one of the country's leagues
or cups. Default: FALSE. */
gboolean generate;
} CupChooseTeam;
/** Structure representing a cup. */
typedef struct
{
/** Name and short name of the cup, a pixmap path,
and the string id (e.g. england_fa or so).
Default: "". */
gchar *name, *short_name, *symbol, *sid;
/** Numerical id. */
gint id;
/** An integer specifying which cups are mutually exclusive for
league teams, e.g. the same team can't participate in the UEFA Cup and
the Champions' League. */
gint group;
/** Last week (typically the week the final
takes place) and weeks between matchdays.
Default: -1 and 1. */
gint last_week, week_gap;
/** This determines when the cup gets added to the acps
pointer array (and becomes visible for the user). Also determines
when the cup fixtures for the first round get written.
Default: 0 (ie. the cup is visible from the first week). */
gint add_week;
/** Number of yellow cards that lead to a missed match.
Default: 1000 (off). */
gint yellow_red;
/** Difference of the average talent for the cup teams compared to
the league with highest average talent.
Default: 0. */
gfloat talent_diff;
/** The week and week_round at the beginning of which the fixtures
have to be updated. */
gint next_fixture_update_week;
gint next_fixture_update_week_round;
/** A gchar pointer array of properties (like "national"). */
GPtrArray *properties;
/** The rounds of the cup.
@see #CupRound*/
GArray *rounds;
/** Pointer array containing teams that got a bye for a round of the cup. */
GPtrArray *bye;
/** The teams belonging to the cup (stored in the cup rounds,
these are only pointers).
Relevant only if it's an international one. */
GPtrArray *teams;
/** Pointer array with the names of all the teams in the cup.
Also the teams from the country's leagues. */
GPtrArray *team_names;
/** The fixtures of a season for the cup. */
GArray *fixtures;
} Cup;
#endif

View File

@ -0,0 +1,197 @@
/*
debug.c
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "callbacks.h"
#include "debug.h"
#include "game_gui.h"
#include "league.h"
#include "live_game.h"
#include "option.h"
#include "strategy.h"
#include "support.h"
#include "team.h"
#include "user.h"
#include "variables.h"
/** Take some debug action depending on the text. Text is a prefix and a number. */
void
debug_action(const gchar *text)
{
gchar buf[SMALL];
gint value = -1;
sscanf(text, "%[^-0-9]%d", buf, &value);
if(g_str_has_prefix(text, "deb"))
{
option_set_int("int_debug", &constants, value);
game_gui_print_message("Debug value set to %d.", value);
}
else if(g_str_has_prefix(text, "cap"))
{
current_user.tm->stadium.capacity += value;
game_gui_print_message("Stadium capacity changed by %d. New: %d.", value,
current_user.tm->stadium.capacity);
}
else if(g_str_has_prefix(text, "saf"))
{
current_user.tm->stadium.safety += ((gfloat)value / 100);
current_user.tm->stadium.safety =
CLAMP(current_user.tm->stadium.safety, 0, 1);
game_gui_print_message("Stadium safety changed by %d. New: %.2f", value,
current_user.tm->stadium.safety);
}
else if(g_str_has_prefix(text, "mon"))
{
current_user.money += value;
game_gui_print_message("Money changed by %d. New: %d.", value,
current_user.money);
}
else if(g_str_has_prefix(text, "suc"))
{
current_user.counters[COUNT_USER_SUCCESS] += value;
game_gui_print_message("Success counter changed by %d. New: %d.", value,
current_user.counters[COUNT_USER_SUCCESS]);
}
else if(g_str_has_prefix(text, "scout"))
{
current_user.scout = value;
game_gui_print_message("Scout changed to %d.", value);
}
else if(g_str_has_prefix(text, "phys"))
{
current_user.physio = value;
game_gui_print_message("Physio changed to %d.", value);
}
else if(g_str_has_prefix(text, "yc"))
{
current_user.youth_academy.coach = value;
game_gui_print_message("Youth coach changed to %d.", value);
}
else if(g_str_has_prefix(text, "pospref"))
{
current_user.youth_academy.pos_pref = value;
game_gui_print_message("Recruiting pref changed to %d.", value);
}
else if(g_str_has_prefix(text, "goto"))
{
while(week < value)
on_button_new_week_clicked(NULL, NULL);
}
else if(g_str_has_prefix(text, "testcom") ||
g_str_has_prefix(text, "tc"))
{
stat5 = -value - 1000;
game_gui_print_message("Commentary type displayed: %d.", value);
}
else if(g_str_has_prefix(text, "help"))
{
g_print("Debug options:\n"
"deb \t set debug value\n"
"cap \t change stadium capacity\n"
"saf \t change stadium safety\n"
"mon \t change money\n"
"suc \t change success counter\n"
"scout \t change scout\n"
"physio \t change physio\n"
"youth coach \t change youth coach\n"
"pospref \t change recruiting pref\n"
"goto \t Press 'new week' automatically until\n"
" \t the appropriate week is reached\n"
"testcom|tc \t Test a specific live game commentary.\n"
" \t Find the numbers in live_game_struct.h (LiveGameEventType)\n"
" \t Use 'goto' afterwards.\n"
"help \t display this help\n");
}
setsav0;
}
gboolean
debug_reset_counter(gpointer data)
{
counters[COUNT_SHOW_DEBUG] = 0;
return FALSE;
}
void
debug_calibrate_betting_odds(gint skilldiffmax, gint matches_per_skilldiff)
{
gint i, skilldiff, matches;
Fixture *fix = &g_array_index(lig(0).fixtures, Fixture, 0);
fix->home_advantage = FALSE;
for(skilldiff=0;skilldiff<=skilldiffmax;skilldiff++)
{
gint res[3] = {0, 0, 0};
for(matches=0;matches<matches_per_skilldiff;matches++)
{
fix->attendance = -1;
fix->result[0][0] = fix->result[1][0] = 0;
for(i=0;i<fix->teams[0]->players->len;i++)
{
strategy_repair_player(&g_array_index(fix->teams[0]->players, Player, i));
strategy_repair_player(&g_array_index(fix->teams[1]->players, Player, i));
g_array_index(fix->teams[0]->players, Player, i).skill = 90;
g_array_index(fix->teams[1]->players, Player, i).skill = 90 - skilldiff;
g_array_index(fix->teams[0]->players, Player, i).fitness = 0.9;
g_array_index(fix->teams[1]->players, Player, i).fitness = 0.9;
}
live_game_calculate_fixture(fix);
if(fix->result[0][0] < fix->result[1][0])
res[2]++;
else
res[(fix->result[0][0] == fix->result[1][0])]++;
}
g_print("sd %3d res %3d %3d %3d prob %.2f %.2f %.2f\n", skilldiff,
res[0], res[1], res[2], (gfloat)res[0] / (gfloat)matches,
(gfloat)res[1] / (gfloat)matches, (gfloat)res[2] / (gfloat)matches);
}
}
/** Check whether the 4 forwards, boost on, style all-out-attack
easter egg should be activated. */
gboolean
debug_egg_forwards_boost_style(void)
{
gint i, fwds = 0;
if(current_user.tm->boost != 1 ||
current_user.tm->style != 2 ||
current_user.tm->players->len < 11)
return FALSE;
for(i=0;i<11;i++)
if(g_array_index(current_user.tm->players, Player, i).cpos == 3 &&
g_array_index(current_user.tm->players, Player, i).cskill > 0)
fwds++;
return (fwds > 3);
}

View File

@ -0,0 +1,44 @@
/*
debug.h
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef DEBUG_H
#define DEBUG_H
#include "bygfoot.h"
void
debug_action(const gchar *text);
gboolean
debug_reset_counter(gpointer data);
void
debug_calibrate_betting_odds(gint skilldiffmax, gint matches_per_skilldiff);
gboolean
debug_egg_forwards_boost_style(void);
#endif

View File

@ -0,0 +1,147 @@
/*
enums.h
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef ENUMS_H
#define ENUMS_H
/** Some counters. */
enum Counters
{
COUNT_AUTOSAVE = 0,
COUNT_AUTOSAVE_FILE,
COUNT_TEAM_ID,
COUNT_PLAYER_ID,
COUNT_CUP_ID,
COUNT_LEAGUE_ID,
COUNT_FIX_ID,
COUNT_LG_COMM_ID,
COUNT_SHOW_DEBUG,
COUNT_HINT_NUMBER,
COUNT_END
};
/** Scout and physio qualities. */
enum Quality
{
QUALITY_BEST = 0,
QUALITY_GOOD,
QUALITY_AVERAGE,
QUALITY_BAD,
QUALITY_END
};
/** Indices for the #finances variable. */
enum FinanceValue
{
FIN_PRIZE = 0, /**< Prize money at the end of the season. */
FIN_DEBTS, /**< User's debts. */
FIN_MONEY, /**< User's money. */
FIN_TICKETS, /**< Ticket income (weekly). */
FIN_JOURNEY, /**< Journey costs (weekly). */
FIN_WAGES, /**< Wages (weekly). */
FIN_SCOUT, /**< Scout wage (weekly). */
FIN_PHYSIO, /**< Physio wage (weekly). */
FIN_TRANSFERS_IN, /**< Transfer fees income (weekly). */
FIN_TRANSFERS_OUT, /**< Transfer fees spent (weekly). */
FIN_STADIUM, /**< Stadium improvement (weekly). */
FIN_STAD_BILLS, /**< Bills for riots or fire or so (weekly). */
FIN_END
};
/** Enum used to determine what kind of fixtures or
tables to show (e.g. when an arrow is clicked on). */
enum ShowType
{
SHOW_TEAM = 0,
SHOW_CURRENT,
SHOW_NEXT,
SHOW_PREVIOUS,
SHOW_NEXT_LEAGUE,
SHOW_PREVIOUS_LEAGUE,
SHOW_END
};
/** Possible values for a status variable. */
enum Status0Value
{
STATUS_NONE = 0,
STATUS_MAIN,
STATUS_SHOW_LIVE_GAME,
STATUS_LIVE_GAME_PAUSE,
STATUS_LIVE_GAME_CHANGE,
STATUS_SHOW_TEAM_LIST,
STATUS_SHOW_PLAYER_INFO,
STATUS_BROWSE_TEAMS,
STATUS_TEAM_SELECTION,
STATUS_SHOW_LAST_MATCH,
STATUS_SHOW_LAST_MATCH_PAUSE,
STATUS_SHOW_LAST_MATCH_ABORT,
STATUS_SHOW_LAST_MATCH_STATS,
STATUS_SHOW_FIXTURES,
STATUS_SHOW_FIXTURES_WEEK,
STATUS_SHOW_TABLES,
STATUS_SHOW_FINANCES,
STATUS_SHOW_TRANSFER_LIST,
STATUS_SHOW_USER_HISTORY,
STATUS_GET_LOAN,
STATUS_PAY_LOAN,
STATUS_SHOW_EVENT,
STATUS_JOB_OFFER_SUCCESS,
STATUS_JOB_OFFER_FIRE_FINANCE,
STATUS_JOB_OFFER_FIRE_FAILURE,
STATUS_TRANSFER_OFFER_USER,
STATUS_TRANSFER_OFFER_CPU,
STATUS_CUSTOM_STRUCTURE,
STATUS_SHOW_LEAGUE_RESULTS,
STATUS_SHOW_SEASON_RESULTS,
STATUS_SHOW_LEAGUE_STATS,
STATUS_SHOW_SEASON_HISTORY,
STATUS_SHOW_PLAYER_LIST,
STATUS_FIRE_PLAYER,
STATUS_USER_MANAGEMENT,
STATUS_SHOW_PREVIEW,
STATUS_SAVE_GAME,
STATUS_LOAD_GAME,
STATUS_LOAD_GAME_SPLASH,
STATUS_QUERY_UNFIT,
STATUS_QUERY_QUIT,
STATUS_QUERY_USER_NO_TURN,
STATUS_GENERATE_TEAMS,
STATUS_SPONSOR_CONTINUE,
STATUS_SHOW_YA,
STATUS_SET_YA_PERCENTAGE,
STATUS_QUERY_KICK_YOUTH,
STATUS_SELECT_MM_FILE_LOAD,
STATUS_SELECT_MM_FILE_ADD,
STATUS_SELECT_MM_FILE_IMPORT,
STATUS_SELECT_MM_FILE_EXPORT,
STATUS_PLACE_BET,
STATUS_SHOW_JOB_EXCHANGE,
STATUS_JOB_EXCHANGE_SHOW_TEAM,
STATUS_SPLASH,
STATUS_END
};
#endif

View File

@ -0,0 +1,772 @@
/*
file.c
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "file.h"
#include "free.h"
#include "language.h"
#include "main.h"
#include "misc.h"
#include "option.h"
#include "support.h"
#include "variables.h"
/**
Add the specified directory to the list of directories file_find_support_file()
searches for support files.
Any subdirectories are added recursively.
@param directory The full path of the directory to be added.
@see file_find_support_file()
@see #support_directories
*/
void
file_add_support_directory_recursive (const gchar *directory)
{
GDir *newdir =
g_dir_open(directory, 0, NULL);
const gchar *file;
gchar *fullpath;
if(newdir == NULL)
return;
add_pixmap_directory(directory);
support_directories = g_list_prepend (support_directories,
g_strdup (directory));
while(TRUE)
{
file = g_dir_read_name(newdir);
if(file == NULL)
break;
fullpath = g_strdup_printf ("%s%s%s", directory,
G_DIR_SEPARATOR_S, file);
if(g_file_test(fullpath, G_FILE_TEST_IS_DIR))
file_add_support_directory_recursive(fullpath);
g_free(fullpath);
}
g_dir_close(newdir);
}
/**
Search the list of support directories for a given file and return
the full path name.
The return value must be freed.
@param filename The name of the file we look for (without path).
@param warning Whether to show a warning if we don't find the file.
@return A pointer to the full path string of the file or NULL if
we didn't find the file. The gchar* must be freed.
@see #support_directories
@see file_add_support_directory_recursive()
*/
gchar*
file_find_support_file (const gchar *filename, gboolean warning)
{
GList *elem = support_directories;
while (elem)
{
gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
G_DIR_SEPARATOR_S, filename);
if (g_file_test (pathname, G_FILE_TEST_EXISTS) &&
!g_file_test(pathname, G_FILE_TEST_IS_DIR))
return pathname;
g_free (pathname);
elem = elem->next;
}
if(warning)
g_warning("file_find_support_file: file '%s' not found.", filename);
return NULL;
}
/** Execute command with 'system' and give a warning if return value is -1.
@return TRUE on success, FALSE, otherwise. */
gboolean
file_my_system(const gchar *command)
{
if(system(command) != 0)
{
g_warning("file_my_system: system returned -1 when executing '%s'.", command);
if(!os_is_unix)
{
g_warning("Press RETURN to try to continue.");
getchar();
}
return FALSE;
}
return TRUE;
}
/** A custom function opening files.
@param filename The full path to the file or a file name from the support files.
@param bits The mode we use, e.g. "r" or "w". @see fopen()
@param fil The file pointer that will point to the opened stream.
@param abort_program Whether to abort the program if we encounter an error.
@return TRUE on success, FALSE otherwise. */
gboolean
file_my_fopen(const gchar *filename, gchar *bits, FILE **fil, gboolean abort_program)
{
gchar *support_file = NULL;
*fil = fopen(filename, bits);
if(*fil != NULL)
return TRUE;
support_file = file_find_support_file(filename, FALSE);
*fil = fopen(support_file, bits);
if(*fil != NULL)
{
g_free(support_file);
return TRUE;
}
g_warning("Could not open file '%s' in mode '%s'.\n", filename, bits);
if(abort_program)
main_exit_program(EXIT_FILE_OPEN_FAILED, NULL);
return FALSE;
}
/** Create a $HOME/.bygfoot dir and other stuff if necessary. */
void
file_check_home_dir_create_dirs(void)
{
gint i;
gchar *dirs[3] =
{HOMEDIRNAME,
HOMEDIRNAME G_DIR_SEPARATOR_S "definitions",
HOMEDIRNAME G_DIR_SEPARATOR_S "saves"};
const gchar *home = g_get_home_dir();
gchar buf[SMALL];
for(i=0;i<3;i++)
{
sprintf(buf, "%s%s%s", home, G_DIR_SEPARATOR_S, dirs[i]);
if(!g_file_test(buf, G_FILE_TEST_EXISTS))
file_mkdir(buf);
}
}
/** Add the basic config files to the list of file to copy
into the user home dir. */
void
file_check_home_dir_get_conf_files(GPtrArray **files_to_copy)
{
gint i;
gchar *conf_files[2] =
{"bygfoot.conf",
"bygfoot_user.conf"};
const gchar *home = g_get_home_dir();
gchar *conf_file = NULL;
gchar buf[SMALL];
for(i=0;i<2;i++)
{
sprintf(buf, "%s%s%s%s%s", home, G_DIR_SEPARATOR_S,
HOMEDIRNAME, G_DIR_SEPARATOR_S, conf_files[i]);
if(!g_file_test(buf, G_FILE_TEST_EXISTS))
{
conf_file = file_find_support_file(conf_files[i], TRUE);
g_ptr_array_add(files_to_copy[0], g_strdup(conf_file));
g_ptr_array_add(files_to_copy[1], g_strdup(buf));
}
}
}
/** Add the xml definition files to the list of files to copy
into the home dir. */
void
file_check_home_dir_get_definition_dir(const gchar *dirname, const gchar *basename,
GPtrArray **files_to_copy)
{
gint i;
gchar buf[SMALL], buf2[SMALL];
const gchar *home = g_get_home_dir();
GPtrArray *dir_contents = NULL;
sprintf(buf, "%s%s%s%s%s", home, G_DIR_SEPARATOR_S,
HOMEDIRNAME, G_DIR_SEPARATOR_S, basename);
if(!g_file_test(buf, G_FILE_TEST_EXISTS))
file_mkdir(buf);
dir_contents = file_dir_get_contents(dirname, "", "");
for(i=0;i<dir_contents->len;i++)
{
sprintf(buf, "%s%s%s%s%s%s%s", home, G_DIR_SEPARATOR_S,
HOMEDIRNAME, G_DIR_SEPARATOR_S, basename, G_DIR_SEPARATOR_S,
(gchar*)g_ptr_array_index(dir_contents, i));
if(g_str_has_suffix((gchar*)g_ptr_array_index(dir_contents, i), ".xml") &&
!g_file_test(buf, G_FILE_TEST_EXISTS))
{
sprintf(buf2, "%s%s%s", dirname, G_DIR_SEPARATOR_S,
(gchar*)g_ptr_array_index(dir_contents, i));
g_ptr_array_add(files_to_copy[0], g_strdup(buf2));
g_ptr_array_add(files_to_copy[1], g_strdup(buf));
}
else
{
sprintf(buf, "%s%s%s", dirname, G_DIR_SEPARATOR_S,
(gchar*)g_ptr_array_index(dir_contents, i));
if(g_file_test(buf, G_FILE_TEST_IS_DIR))
{
sprintf(buf2, "%s%s%s", basename, G_DIR_SEPARATOR_S,
(gchar*)g_ptr_array_index(dir_contents, i));
file_check_home_dir_get_definition_dir(buf, buf2, files_to_copy);
}
}
}
free_gchar_array(&dir_contents);
}
/** Step through the support dirs to find xml definition files
that get copied into the home dir. */
void
file_check_home_dir_get_definition_files(GPtrArray **files_to_copy)
{
GList *elem = support_directories;
while(elem != NULL)
{
if(g_str_has_suffix((gchar*)elem->data, "definitions"))
file_check_home_dir_get_definition_dir((const gchar*)elem->data,
"definitions",
files_to_copy);
elem = elem->next;
}
}
/** Execute the copy commands on the files assembled earlier. */
void
file_check_home_dir_copy_files(GPtrArray **files_to_copy)
{
gint i;
gchar buf[SMALL];
const gchar *filename = NULL;
GtkLabel *label_splash_progress =
GTK_LABEL(lookup_widget(window.splash, "label_splash_progress"));
GtkProgressBar *progressbar_splash =
GTK_PROGRESS_BAR(lookup_widget(window.splash, "progressbar_splash"));
GtkWidget *hint_buttons[2] =
{lookup_widget(window.splash, "button_splash_hint_back"),
lookup_widget(window.splash, "button_splash_hint_next")};
GtkWidget *hbox_buttons = lookup_widget(window.splash, "hbox3");
if(files_to_copy[0]->len > 0)
{
gtk_widget_set_sensitive(hint_buttons[0], FALSE);
gtk_widget_set_sensitive(hint_buttons[1], FALSE);
gtk_widget_set_sensitive(hbox_buttons, FALSE);
}
for(i=0;i<files_to_copy[0]->len;i++)
{
filename = g_strrstr((gchar*)g_ptr_array_index(files_to_copy[0], i),
G_DIR_SEPARATOR_S);
if(filename == NULL)
filename = (gchar*)g_ptr_array_index(files_to_copy[0], i);
else
filename = filename + 1;
sprintf(buf, _("Copying %s"), filename);
gtk_label_set_text(label_splash_progress, buf);
gtk_progress_bar_set_fraction(progressbar_splash,
(gdouble)i /(gdouble)files_to_copy[0]->len);
while(gtk_events_pending())
gtk_main_iteration();
file_copy_file((gchar*)g_ptr_array_index(files_to_copy[0], i),
(gchar*)g_ptr_array_index(files_to_copy[1], i));
}
gtk_progress_bar_set_fraction(progressbar_splash, 1);
gtk_label_set_text(label_splash_progress, _("Ready"));
while(gtk_events_pending())
gtk_main_iteration();
if(files_to_copy[0]->len > 0)
{
gtk_widget_set_sensitive(hint_buttons[0], TRUE);
gtk_widget_set_sensitive(hint_buttons[1], TRUE);
gtk_widget_set_sensitive(hbox_buttons, TRUE);
}
}
/** Copy some files into the user's home directory. */
gboolean
file_check_home_dir(void)
{
GPtrArray *files_to_copy[2] = {g_ptr_array_new(),
g_ptr_array_new()};
file_check_home_dir_create_dirs();
file_check_home_dir_get_conf_files(files_to_copy);
file_check_home_dir_get_definition_files(files_to_copy);
file_check_home_dir_copy_files(files_to_copy);
free_gchar_array(&(files_to_copy[0]));
free_gchar_array(&(files_to_copy[1]));
return FALSE;
}
/**
Retrieve those files in the given directory
that start with the given prefix and suffix. The file names are stored
in an array of strings.
@param dir_name The full path to the directory.
@param prefix The prefix that files must have to be included.
@param suffix The suffix that files must have to be included.
@return A GPtrArray with pointers to the strings of the file
names. The array must be freed with free_gchar_array().
*/
GPtrArray*
file_dir_get_contents(const gchar *dir_name, const gchar *prefix, const gchar *suffix)
{
GError *error = NULL;
GDir *dir = g_dir_open(dir_name, 0, &error);
GPtrArray *contents = g_ptr_array_new();
const gchar *file = NULL;
misc_print_error(&error, FALSE);
if(dir == NULL)
return contents;
file = g_dir_read_name(dir);
if(file == NULL)
return contents;
while(file != NULL)
{
if(g_str_has_prefix(file, prefix) &&
g_str_has_suffix(file, suffix))
g_ptr_array_add(contents, (gpointer)g_strdup(file));
file = g_dir_read_name(dir);
}
g_dir_close(dir);
return contents;
}
/** Return the country definition files found in the support dirs. */
GPtrArray*
file_get_country_files(void)
{
gint i;
GList *elem = support_directories;
GPtrArray *country_files = g_ptr_array_new();
GPtrArray *dir_contents = NULL;
while(elem != NULL)
{
dir_contents = file_dir_get_contents((gchar*)elem->data, "country_", ".xml");
for(i=0;i<dir_contents->len;i++)
if(!query_misc_string_in_array((gchar*)g_ptr_array_index(dir_contents, i),
country_files))
g_ptr_array_add(country_files,
g_strdup((gchar*)g_ptr_array_index(dir_contents, i)));
free_gchar_array(&dir_contents);
elem = elem->next;
}
return country_files;
}
/** Read the file until the next line that's not a comment or
a blank line. Split the line into the part before and after
the first white space and copy them into the char arrays.
Trailing and leading white spaces and trailing comments are stripped.
@param fil The file stream.
@param opt_name The first char array (an option name, mostly).
@param opt_value The second array (an option value, mostly).
@return TRUE if the file still contains lines to read, FALSE otherwise. */
gboolean
file_get_next_opt_line(FILE *fil, gchar *opt_name, gchar *opt_value)
{
gint i;
gchar trash[SMALL];
gchar buf[BIG];
strcpy(buf, "");
strcpy(opt_name, "");
strcpy(opt_value, "");
while( (buf[0] == '#' || strlen(buf) == 0) &&
feof(fil) == 0)
{
fscanf(fil, "%[\n \t]*", buf);
fscanf(fil, "%[^\n]", buf);
}
if(buf[0] != '#' && strlen(buf) != 0)
{
if(strlen(buf) > 1000)
g_warning("\n the text file I'm reading contains a line longer than 1000 chars.\n\n");
for(i=0;i<strlen(buf);i++)
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, "%[^ \t]%[ \t]%[^\n]", opt_name, trash, opt_value);
}
return (feof(fil) == 0);
}
/** Save an optionlist to a file. */
void
file_save_opt_file(const gchar *filename, OptionList *optionlist)
{
gint i;
FILE *fil = NULL;
file_my_fopen(filename, "w", &fil, TRUE);
for(i=0;i<optionlist->list->len;i++)
if(g_str_has_prefix(g_array_index(optionlist->list, Option, i).name, "string_"))
fprintf(fil, "%s %s\n", g_array_index(optionlist->list, Option, i).name,
g_array_index(optionlist->list, Option, i).string_value);
else
fprintf(fil, "%s %d\n", g_array_index(optionlist->list, Option, i).name,
g_array_index(optionlist->list, Option, i).value);
fclose(fil);
}
/** Load a file containing name - value pairs into
the specified array. */
void
file_load_opt_file(const gchar *filename, OptionList *optionlist)
{
gint i;
gchar opt_name[SMALL], opt_value[SMALL];
Option new;
FILE *fil = NULL;
free_option_list(optionlist, TRUE);
file_my_fopen(filename, "r", &fil, TRUE);
while(file_get_next_opt_line(fil, opt_name, opt_value))
{
new.name = g_strdup(opt_name);
if(g_str_has_prefix(opt_name, "string_"))
{
new.string_value = g_strdup(opt_value);
new.value = -1;
}
else
{
new.string_value = NULL;
sscanf(opt_value, "%d", &new.value);
}
g_array_append_val(optionlist->list, new);
if((g_str_has_suffix(new.name, "_unix") && os_is_unix) ||
(g_str_has_suffix(new.name, "_win32") && !os_is_unix))
{
strcpy(opt_name, new.name);
opt_name[strlen(new.name) - (os_is_unix ? 5 : 6)] = '\0';
new.name = g_strdup(opt_name);
new.string_value = g_strdup(opt_value);
g_array_append_val(optionlist->list, new);
}
}
for(i=0;i<optionlist->list->len;i++)
g_datalist_set_data(&optionlist->datalist, g_array_index(optionlist->list, Option, i).name,
&g_array_index(optionlist->list, Option, i));
fclose(fil);
}
/** Load the appropriate hints file. */
void
file_load_hints_file(void)
{
gchar buf[SMALL], hints_file[SMALL];
gchar *hints_file_sup = NULL;
language_get_code(buf);
sprintf(hints_file, "bygfoot_hints_%s", buf);
hints_file_sup = file_find_support_file(hints_file, FALSE);
if(hints_file_sup != NULL)
g_free(hints_file_sup);
else
strcpy(hints_file, "bygfoot_hints_en");
file_load_opt_file(hints_file, &hints);
}
/** Load the options at the beginning of a new game from
the configuration files. */
void
file_load_conf_files(void)
{
gint i;
gchar *conf_file = file_find_support_file("bygfoot.conf", TRUE);
file_load_opt_file(conf_file, &options);
g_free(conf_file);
file_load_opt_file(opt_str("string_opt_constants_file"), &constants);
file_load_opt_file(opt_str("string_opt_appearance_file"), &constants_app);
file_load_opt_file("bygfoot_tokens", &tokens);
file_load_hints_file();
for(i=0;i<tokens.list->len;i++)
g_array_index(tokens.list, Option, i).value = i;
}
/** 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);
conf_file = file_find_support_file(buf, FALSE);
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"), TRUE);
}
file_load_opt_file(conf_file, &user->options);
g_free(conf_file);
}
/** Return the primary support dir (probably './support_files' or
the Bygfoot dir in $HOME). */
const gchar*
file_get_first_support_dir(void)
{
GList *elem = support_directories;
while (elem)
{
if(g_str_has_suffix((gchar*)elem->data, HOMEDIRNAME) ||
g_str_has_suffix((gchar*)elem->data, "support_files"))
return (const gchar*)elem->data;
elem = elem->next;
}
main_exit_program(EXIT_NO_SUPPORT_DIR,
"file_get_first_support_dir: no primary support dir found.");
return NULL;
}
/** Return the first support directory which has the given suffix.*/
const gchar*
file_get_first_support_dir_suffix(const gchar *suffix)
{
GList *elem = support_directories;
while (elem)
{
if(g_str_has_suffix((gchar*)elem->data, suffix))
return (const gchar*)elem->data;
elem = elem->next;
}
g_warning("file_get_first_support_dir_suffix: no dir with suffix %s found.",
suffix);
return NULL;
}
/** Compress the files starting with the prefix.
@param destfile The name of the file to create. */
void
file_compress_files(const gchar *destfile, const gchar *prefix)
{
gint i;
gchar buf[SMALL];
gchar *basename = g_path_get_basename(prefix),
*dirname = g_path_get_dirname(prefix),
*zipbasename = g_path_get_basename(destfile),
*pwd = g_get_current_dir();
GPtrArray *files = file_dir_get_contents(dirname, basename, "");
chdir(dirname);
if (os_is_unix)
sprintf(buf, "%s %s %s",
const_str("string_fs_compress_command"),
const_str("string_fs_compress_switches"),
zipbasename);
else
sprintf(buf, "\"%s%s%s\" %s %s", pwd, G_DIR_SEPARATOR_S,
const_str("string_fs_compress_command"),
const_str("string_fs_compress_switches"),
zipbasename);
for(i=0;i<files->len;i++)
{
strcat(buf, " ");
strcat(buf, (gchar*)g_ptr_array_index(files, i));
}
file_my_system(buf);
chdir(pwd);
sprintf(buf, "%s%s%s*", dirname, G_DIR_SEPARATOR_S, basename);
file_remove_files(buf);
free_gchar_array(&files);
g_free(basename);
g_free(dirname);
g_free(zipbasename);
g_free(pwd);
}
/** Decompress the specified file. */
void
file_decompress(const gchar *filename)
{
gchar buf[SMALL];
gchar *dirname = g_path_get_dirname(filename),
*basename = g_path_get_basename(filename),
*pwd = g_get_current_dir();
chdir(dirname);
if (os_is_unix)
sprintf(buf, "%s %s %s",
const_str("string_fs_uncompress_command"),
const_str("string_fs_uncompress_switches"),
basename);
else
sprintf(buf, "\"%s%s%s\" %s %s", pwd, G_DIR_SEPARATOR_S,
const_str("string_fs_uncompress_command"),
const_str("string_fs_uncompress_switches"),
basename);
file_my_system(buf);
g_free(dirname);
g_free(basename);
chdir(pwd);
g_free(pwd);
}
/** Execute the appropriate remove command with 'files'
as argument (can be directories or a regexp, too). */
void
file_remove_files(const gchar *files)
{
gchar buf[SMALL];
if(os_is_unix)
sprintf(buf, "%s %s", const_str("string_fs_remove_file_command"), files);
else
sprintf(buf, "%s \"%s\"", const_str("string_fs_remove_file_command"), files);
file_my_system(buf);
}
/** Execute the appropriate copy command. */
void
file_copy_file(const gchar *source_file, const gchar *dest_file)
{
gchar buf[SMALL];
if(os_is_unix)
sprintf(buf, "%s %s %s", const_str("string_fs_copy_file_command"),
source_file, dest_file);
else
sprintf(buf, "%s \"%s\" \"%s\"", const_str("string_fs_copy_file_command"),
source_file, dest_file);
file_my_system(buf);
}
/** Find out where the Bygfoot directory we can write to resides
and write the location into the string. */
void
file_get_bygfoot_dir(gchar *dir)
{
const gchar *home = g_get_home_dir();
gchar *pwd = g_get_current_dir();
if(os_is_unix)
sprintf(dir, "%s%s%s", home, G_DIR_SEPARATOR_S, HOMEDIRNAME);
else
sprintf(dir, "%s%s", pwd, G_DIR_SEPARATOR_S);
g_free(pwd);
}

View File

@ -0,0 +1,112 @@
/*
file.h
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef FILE_H
#define FILE_H
#include "bygfoot.h"
#include "player_struct.h"
#include "user_struct.h"
#ifdef G_OS_UNIX
#define file_mkdir(dirname) mkdir(dirname, (S_IRUSR | S_IWUSR | S_IXUSR))
#else
#define file_mkdir(dirname) mkdir(dirname)
#endif
void
file_add_support_directory_recursive (const gchar *directory);
gchar*
file_find_support_file (const gchar *filename, gboolean warning);
gboolean
file_get_next_opt_line(FILE *fil, gchar *opt_name, gchar *opt_value);
void
file_load_opt_file(const gchar *filename, OptionList *optionlist);
void
file_save_opt_file(const gchar *filename, OptionList *optionlist);
GPtrArray*
file_dir_get_contents(const gchar *dir_name, const gchar *prefix, const gchar *suffix);
gboolean
file_my_fopen(const gchar *filename, gchar *bits, FILE **fil, gboolean abort_program);
GPtrArray*
file_get_country_files(void);
void
file_load_conf_files(void);
void
file_load_user_conf_file(User *user);
gboolean
file_check_home_dir(void);
void
file_check_home_dir_get_conf_files(GPtrArray **files_to_copy);
void
file_check_home_dir_get_definition_files(GPtrArray **files_to_copy);
void
file_check_home_dir_get_definition_dir(const gchar *dirname, const gchar *basename,
GPtrArray **files_to_copy);
void
file_check_home_dir_copy_files(GPtrArray **files_to_copy);
gboolean
file_my_system(const gchar *command);
const gchar*
file_get_first_support_dir(void);
const gchar*
file_get_first_support_dir_suffix(const gchar *suffix);
void
file_compress_files(const gchar *destfile, const gchar *prefix);
void
file_decompress(const gchar *filename);
void
file_remove_files(const gchar *files);
void
file_copy_file(const gchar *source_file, const gchar *dest_file);
void
file_get_bygfoot_dir(gchar *dir);
void
file_load_hints_file(void);
#endif

View File

@ -0,0 +1,303 @@
/*
finance.c
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "callbacks.h"
#include "finance.h"
#include "game_gui.h"
#include "league.h"
#include "maths.h"
#include "option.h"
#include "player.h"
#include "team.h"
#include "user.h"
/** Weekly update of finances. */
void
finance_update_user_weekly(User *user)
{
gint i;
Team *tm = user->tm;
Team *new_team = NULL;
gfloat physio_factor[4] =
{const_float("float_finance_physio_factor1"),
const_float("float_finance_physio_factor2"),
const_float("float_finance_physio_factor3"),
const_float("float_finance_physio_factor4")};
gfloat scout_factor[4] =
{const_float("float_finance_scout_factor1"),
const_float("float_finance_scout_factor2"),
const_float("float_finance_scout_factor3"),
const_float("float_finance_scout_factor4")};
gfloat yc_factor[4] =
{const_float("float_finance_yc_factor1"),
const_float("float_finance_yc_factor2"),
const_float("float_finance_yc_factor3"),
const_float("float_finance_yc_factor4")};
if(user->money > G_MAXINT - 50000000)
{
user_event_add(user, EVENT_TYPE_CHARITY,
-1, -1, NULL, NULL);
user->money = (user->money - user->money % 2) / 2;
}
if(week % 2 == 1)
{
for(i=0;i<MON_OUT_END;i++)
{
user->money_out[0][i] = user->money_out[1][i];
user->money_out[1][i] = 0;
}
for(i=0;i<MON_IN_END;i++)
{
user->money_in[0][i] = user->money_in[1][i];
user->money_in[1][i] = 0;
}
}
user->money += user->sponsor.benefit;
user->money_in[1][MON_IN_SPONSOR] += user->sponsor.benefit;
user->sponsor.contract = MAX(user->sponsor.contract - 1, 0);
user->money -= (gint)rint((gfloat)user->sponsor.benefit *
(gfloat)user->youth_academy.percentage / 100);
user->money_out[1][MON_OUT_YA] -= (gint)rint((gfloat)user->sponsor.benefit *
(gfloat)user->youth_academy.percentage / 100);
if(user->counters[COUNT_USER_NEW_SPONSOR] > 1)
user->counters[COUNT_USER_NEW_SPONSOR]--;
else if(user->sponsor.contract == 4 &&
math_rnd(0, 1) < ((1 - const_float("float_sponsor_continue_prob")) /
(2 * (gfloat)const_int("int_user_success_offer_limit")) *
user->counters[COUNT_USER_SUCCESS]) +
(1 - (1 - const_float("float_sponsor_continue_prob")) / 2))
user->counters[COUNT_USER_NEW_SPONSOR] = -1;
else if(user->sponsor.contract == 0)
user->counters[COUNT_USER_NEW_SPONSOR] = 1;
if(query_team_plays(tm, week - 1, 1))
for(i=0;i<tm->players->len;i++)
{
user->money_out[1][MON_OUT_WAGE] -= g_array_index(tm->players, Player, i).wage;
user->money -= g_array_index(tm->players, Player, i).wage;
if(player_of_idx_team(tm, i)->health > 0)
{
user->money -= (gint)(finance_wage_unit(tm) * physio_factor[user->physio % 10]);
user->money_out[1][MON_OUT_PHYSIO] -=
(gint)(finance_wage_unit(tm) * physio_factor[user->physio % 10]);
}
}
user->money_out[1][MON_OUT_SCOUT] -= (gint)(finance_wage_unit(tm) * scout_factor[user->scout % 10]);
user->money -= (gint)(finance_wage_unit(tm) * scout_factor[user->scout % 10]);
if(user->youth_academy.players->len > 0)
{
user->money_out[1][MON_OUT_YC] -= (gint)(finance_wage_unit(tm) * yc_factor[user->youth_academy.coach % 10]);
user->money -= (gint)(finance_wage_unit(tm) * yc_factor[user->youth_academy.coach % 10]);
}
user->debt = (gint)rint((gfloat)user->debt * (1 + const_float("float_finance_interest")));
if(user->money < -finance_team_drawing_credit_loan(user->tm, FALSE) &&
user->counters[COUNT_USER_POSITIVE] == -1 && debug < 50)
{
user->counters[COUNT_USER_OVERDRAWN]++;
if(user->counters[COUNT_USER_OVERDRAWN] <=
const_int("int_finance_overdraw_limit"))
{
user_event_add(user, EVENT_TYPE_OVERDRAW,
user->counters[COUNT_USER_OVERDRAWN], -1, NULL, NULL);
user->counters[COUNT_USER_POSITIVE] =
const_int("int_finance_overdraw_positive");
}
}
else if(user->counters[COUNT_USER_POSITIVE] > -1)
user->counters[COUNT_USER_POSITIVE]--;
if(user->counters[COUNT_USER_LOAN] > -1)
user->counters[COUNT_USER_LOAN]--;
if(user->counters[COUNT_USER_LOAN] == 0 && debug < 50)
user_event_add(user, EVENT_TYPE_WARNING, -1, -1, NULL,
_("You have to pay back your loan this week."));
if(user->counters[COUNT_USER_POSITIVE] == 0 && debug < 50)
user_event_add(user, EVENT_TYPE_WARNING, -1, -1, NULL,
_("Your bank account has to be above your drawing credit limit next week."));
if(((user->counters[COUNT_USER_LOAN] == -1 && user->debt != 0) ||
(user->counters[COUNT_USER_POSITIVE] == -1 &&
user->money < -finance_team_drawing_credit_loan(user->tm, FALSE))) && debug < 50)
{
new_team = team_get_new(tm, TRUE);
user_event_add(user, EVENT_TYPE_FIRE_FINANCE, -1, -1, new_team, NULL);
}
}
/** Return a base value for team finances.
Scout wages etc. depend on this value. */
gfloat
finance_wage_unit(const Team *tm)
{
gint i;
gfloat sum = 0;
for(i=0;i<tm->players->len;i++)
sum += player_of_idx_team(tm, i)->wage;
return sum / (gfloat)tm->players->len;
}
/** Calculate the drawing credit or maximum loan of a team
based on player values and stadium data. */
gint
finance_team_drawing_credit_loan(const Team *tm, gboolean loan)
{
gint i;
gfloat sum = 0;
for(i=0;i<tm->players->len;i++)
sum += player_of_idx_team(tm, i)->value;
sum = (sum * const_float("float_finance_credit_player_value_weight")) +
((gfloat)tm->stadium.capacity *
powf(tm->stadium.safety, const_float("float_finance_credit_stadium_safety_exponent")) *
const_float("float_finance_credit_stadium_weight"));
sum *= (loan) ? const_float("float_finance_credit_factor_loan") :
const_float("float_finance_credit_factor_drawing");
return (gint)rint(sum);
}
/** Contract a loan for the current user.
@param value The amount of money. */
void
finance_get_loan(gint value)
{
current_user.money += value;
current_user.debt -= value;
current_user.counters[COUNT_USER_LOAN] = (current_user.counters[COUNT_USER_LOAN] == -1) ?
const_int("int_finance_payback_weeks") :
current_user.counters[COUNT_USER_LOAN];
game_gui_print_message(_("You have %d weeks to pay back your loan."),
current_user.counters[COUNT_USER_LOAN]);
on_menu_show_finances_activate(NULL, NULL);
}
/** Pay back some loan for the current user.
@param value The amount of money paid back. */
void
finance_pay_loan(gint value)
{
gint add = (gint)rint((gfloat)value / (gfloat)(-current_user.debt) *
(gfloat)const_int("int_finance_payback_weeks"));
current_user.money -= value;
current_user.debt += value;
if(current_user.debt == 0)
{
current_user.counters[COUNT_USER_LOAN] = -1;
game_gui_print_message(_("You are free from debt."));
}
else
{
current_user.counters[COUNT_USER_LOAN] =
MIN(current_user.counters[COUNT_USER_LOAN] + add,
const_int("int_finance_payback_weeks"));
game_gui_print_message(_("You have %d weeks to pay back the rest of your loan."),
current_user.counters[COUNT_USER_LOAN]);
}
on_menu_show_finances_activate(NULL, NULL);
}
/** Return the cost of a stadium improvement.
@param value The improvement value, either number of new seats
or safety increase.
@param capacity Whether seats are built or capacity increased. */
gint
finance_get_stadium_improvement_cost(gfloat value, gboolean capacity)
{
gfloat return_value;
if(capacity)
{
return_value = finance_wage_unit(current_user.tm) *
(value / (gfloat)const_int("int_stadium_improvement_base_seats"))*
const_float("float_stadium_improvement_wage_unit_factor_seats");
if(value - (gfloat)const_int("int_stadium_improvement_base_seats") >=
const_int("int_stadium_improvement_max_discount_seats"))
return_value *= (1 - const_float("float_stadium_improvement_max_discount"));
else
return_value *= (1 - const_float("float_stadium_improvement_max_discount") *
((value - (gfloat)const_int("int_stadium_improvement_base_seats")) /
(gfloat)const_int("int_stadium_improvement_max_discount_seats")));
}
else
{
return_value = finance_wage_unit(current_user.tm) *
(value / const_float("float_stadium_improvement_base_safety"))*
const_float("float_stadium_improvement_wage_unit_factor_safety");
if(value - const_float("float_stadium_improvement_base_safety") >=
const_float("float_stadium_improvement_max_discount_safety"))
return_value *= (1 - const_float("float_stadium_improvement_max_discount"));
else
return_value *= (1 - const_float("float_stadium_improvement_max_discount") *
((value - const_float("float_stadium_improvement_base_safety")) /
const_float("float_stadium_improvement_max_discount_safety")));
}
return (gint)rint(return_value);
}
/** Return the expected duration of a stadium improvement.
@param value The improvement value, either number of new seats
or safety increase.
@param capacity Whether seats are built or capacity increased. */
gint
finance_get_stadium_improvement_duration(gfloat value, gboolean capacity)
{
gint return_value;
if(capacity)
return_value = (gint)((value - 1) /
(gfloat)const_int("int_stadium_improvement_base_seats")) + 1;
else
return_value =
(gint)(((gint)rint(value * 100) - 1) /
(gint)rint(const_float("float_stadium_improvement_base_safety") * 100)) + 1;
return return_value;
}

View File

@ -0,0 +1,56 @@
/*
finance.h
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef FINANCE_H
#define FINANCE_H
#include "bygfoot.h"
#include "user_struct.h"
/** The amount of money the user can spend. */
#define BUDGET(idx) (finance_team_drawing_credit_loan(usr(idx).tm, FALSE) + usr(idx).money)
void
finance_update_user_weekly(User *user);
gfloat
finance_wage_unit(const Team *tm);
gint
finance_team_drawing_credit_loan(const Team *tm, gboolean loan);
void
finance_pay_loan(gint value);
void
finance_get_loan(gint value);
gint
finance_get_stadium_improvement_cost(gfloat value, gboolean capacity);
gint
finance_get_stadium_improvement_duration(gfloat value, gboolean capacity);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,159 @@
/*
fixture.h
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef FIXTURE_H
#define FIXTURE_H
#include "bygfoot.h"
#include "cup_struct.h"
#include "fixture_struct.h"
#include "league_struct.h"
enum FixtureCompare
{
FIXTURE_COMPARE_DATE = 0,
FIXTURE_COMPARE_END
};
/** Check whether the team with given id participates in the fixture. */
#define query_fixture_team_involved(fix, team_id) (fix->team_ids[0] == team_id || fix->team_ids[1] == team_id)
void
fixture_write_league_fixtures(League *league);
void
fixture_write_cup_fixtures(Cup *cup);
void
fixture_write_cup_round_robin(Cup *cup, gint cup_round, GPtrArray *teams);
void
fixture_write_round_robin(gpointer league_cup, gint cup_round, GPtrArray *teams, gboolean one_round);
void
fixture_write_round_robin_matchday(GArray *fixtures, gint cup_round, GPtrArray *teams,
gint special, gint week_number,
gint clid, gboolean home_advantage);
void
fixture_write_knockout_round(Cup *cup, gint cup_round, GPtrArray *teams);
void
fixture_write(GArray *fixtures, Team *home_team, Team *away_team, gint week_number,
gint week_round_number, gint clid, gint cup_round, gint replay_number,
gboolean home_advantage, gboolean second_leg, gboolean decisive);
void
fixture_update(Cup *cup);
gboolean
fixture_update_write_replays(Cup *cup);
GPtrArray*
fixture_get_cup_round_winners(const Cup *cup);
GPtrArray*
fixture_get_round_robin_advance(const Cup *cup, gint round);
gpointer
fixture_winner_of(const Fixture *fix, gboolean team_id);
gint
fixture_get_free_round(gint week_number, const GPtrArray *teams,
gint team_id1, gint team_id2);
gboolean
query_fixture_is_earlier(const Fixture *fix1, const Fixture *fix2);
gboolean
query_fixture_is_later(const Fixture *fix1, const Fixture *fix2);
gboolean
query_fixture_is_draw(const Fixture *fix);
gint
fixture_user_team_involved(const Fixture *fix);
gboolean
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);
GPtrArray*
fixture_get_week_list_clid(gint clid, gint week_number, gint week_round_number);
void
fixture_result_to_buf(const Fixture *fix, gchar *buf, gboolean swap);
gint
fixture_get_number_of_matches(gint week_number, gint week_round_number);
Fixture*
fixture_get(gint type, gint clid, gint week_number, gint week_round_number, const Team *tm);
Fixture*
fixture_get_next(gint clid, gint week_number, gint week_round_number);
Fixture*
fixture_get_previous(gint clid, gint week_number, gint week_round_number);
GPtrArray*
fixture_get_latest(const Team *tm);
gint
fixture_compare_func(gconstpointer a, gconstpointer b, gpointer data);
GPtrArray*
fixture_get_matches(const Team *tm1, const Team *tm2);
GPtrArray*
fixture_get_coming(const Team *tm);
Fixture*
fixture_from_id(gint id, gboolean abort_program);
gint
fixture_get_last_week_round(gint week_number);
void
fixture_get_next_week(gint *week_number, gint *week_round_number);
void
fixture_get_previous_week(gint *week_number, gint *week_round_number);
GPtrArray*
fixture_get_week_list(gint week_number, gint week_round_number);
GPtrArray*
fixture_get_season_results(void);
gint
fixture_get_goals_to_win(const Fixture *fix, const Team *tm);
#endif

View File

@ -0,0 +1,62 @@
/*
fixture_struct.h
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef FIXTURE_STRUCT_H
#define FIXTURE_STRUCT_H
#include "bygfoot.h"
#include "team_struct.h"
/** Structure representing a fixture, or, in other words,
a match. */
typedef struct
{
/** The cup or league the fixture belongs to. */
gint clid;
/** The unique id of the fixture. */
gint id;
/** The round (in a cup) the fixture belongs to. */
gint round;
/** The replay number (ie. how often the match was repeated because of a draw). */
gint replay_number;
/** When it takes place. */
gint week_number, week_round_number;
/** The teams involved. */
Team *teams[2];
/** Ids of the teams. Needed when the team
pointers get invalid (e.g. after promotion/relegation). */
gint team_ids[2];
/** The number of goals for each team in
regulation, extra time and penalty shoot-out. */
gint result[2][3];
/** Whether there's home advantage, this is second leg,
or the game has to be decided. */
gboolean home_advantage, second_leg, decisive;
/** How many people attended and whether there were
special events. */
gint attendance;
} Fixture;
#endif

View File

@ -0,0 +1,808 @@
/*
free.c
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "bet_struct.h"
#include "free.h"
#include "lg_commentary_struct.h"
#include "strategy_struct.h"
#include "transfer.h"
#include "user.h"
#include "variables.h"
/**
Free all memory allocated by the program.
This mainly means we have to free a lot of strings
and GArrays. */
void
free_memory(void)
{
free_variables();
free_names(FALSE);
free_transfer_list();
free_strategies();
free_country(&country, FALSE);
free_users(FALSE);
free_bets(FALSE);
free_live_game(&live_game_temp);
free_lg_commentary(FALSE);
free_support_dirs();
free_jobs(FALSE);
}
/** Free the transfer list. */
void
free_transfer_list(void)
{
gint i;
for(i=0;i<transfer_list->len;i++)
g_array_free(g_array_index(transfer_list, Transfer, i).offers, TRUE);
free_g_array(&transfer_list);
}
/** Free the memory occupied by the season stats. */
void
free_season_stats(gboolean reset)
{
gint i, j;
if(season_stats == NULL)
{
if(reset)
season_stats = g_array_new(FALSE, FALSE, sizeof(SeasonStat));
return;
}
for(i=0;i<season_stats->len;i++)
{
for(j=0;j<g_array_index(season_stats, SeasonStat, i).league_stats->len;j++)
free_league_stats(
&g_array_index(g_array_index(season_stats, SeasonStat, i).league_stats,
LeagueStat, j));
for(j=0;j<g_array_index(season_stats, SeasonStat, i).league_champs->len;j++)
{
free_gchar_ptr(
g_array_index(
g_array_index(season_stats, SeasonStat, i).league_champs,
ChampStat, j).cl_name);
free_gchar_ptr(
g_array_index(
g_array_index(season_stats, SeasonStat, i).league_champs,
ChampStat, j).team_name);
}
for(j=0;j<g_array_index(season_stats, SeasonStat, i).cup_champs->len;j++)
{
free_gchar_ptr(
g_array_index(
g_array_index(season_stats, SeasonStat, i).cup_champs,
ChampStat, j).cl_name);
free_gchar_ptr(
g_array_index(
g_array_index(season_stats, SeasonStat, i).cup_champs,
ChampStat, j).team_name);
}
g_array_free(g_array_index(season_stats, SeasonStat, i).cup_champs, TRUE);
g_array_free(g_array_index(season_stats, SeasonStat, i).league_champs, TRUE);
}
free_g_array(&season_stats);
if(reset)
season_stats = g_array_new(FALSE, FALSE, sizeof(SeasonStat));
}
/** Free the users array. */
void
free_users(gboolean reset)
{
gint i;
if(users == NULL)
{
if(reset)
users = g_array_new(FALSE, FALSE, sizeof(User));
return;
}
for(i=0;i<users->len;i++)
free_user(&usr(i));
free_g_array(&users);
if(reset)
users = g_array_new(FALSE, FALSE, sizeof(User));
}
/** Free the memory the user occupies.
@param user The user we free. */
void
free_user(User *user)
{
gint i, j;
free_gchar_ptr(user->name);
free_g_string(&user->sponsor.name);
free_gchar_ptr(user->mmatches_file);
free_live_game(&user->live_game);
free_option_list(&user->options, FALSE);
for(i=0;i<user->events->len;i++)
free_event(&g_array_index(user->events, Event, i));
free_g_array(&user->events);
for(i=0;i<user->history->len;i++)
{
free_gchar_ptr(g_array_index(user->history,
UserHistory, i).team_name);
for(j=0;j<3;j++)
free_gchar_ptr(g_array_index(user->history,
UserHistory, i).string[j]);
}
free_g_array(&user->history);
free_mmatches(&user->mmatches, FALSE);
free_player_array(&user->youth_academy.players);
free_g_array(&user->bets[0]);
free_g_array(&user->bets[1]);
}
/** Free the memorable matches array of the user and the memorable matches
file name . */
void
free_mmatches(GArray **mmatches, gboolean reset)
{
gint i;
if(*mmatches == NULL)
{
if(reset)
*mmatches = g_array_new(FALSE, FALSE, sizeof(MemMatch));
return;
}
for(i=0;i<(*mmatches)->len;i++)
{
free_g_string(&g_array_index(*mmatches, MemMatch, i).competition_name);
free_gchar_ptr(g_array_index(*mmatches, MemMatch, i).country_name);
free_live_game(&g_array_index(*mmatches, MemMatch, i).lg);
}
free_g_array(mmatches);
if(reset)
*mmatches = g_array_new(FALSE, FALSE, sizeof(MemMatch));
}
/** Free a user event. */
void
free_event(Event *event)
{
free_gchar_ptr(event->value_string);
}
/** 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_list(OptionList *optionlist, gboolean reset)
{
gint i;
if(optionlist->list == NULL)
{
if(reset)
{
optionlist->list = g_array_new(FALSE, FALSE, sizeof(Option));
g_datalist_init(&optionlist->datalist);
}
return;
}
for(i=0;i<optionlist->list->len;i++)
{
free_gchar_ptr(g_array_index(optionlist->list, Option, i).name);
free_gchar_ptr(g_array_index(optionlist->list, Option, i).string_value);
}
free_g_array(&optionlist->list);
if(reset)
{
optionlist->list = g_array_new(FALSE, FALSE, sizeof(Option));
g_datalist_init(&optionlist->datalist);
}
}
/** Free a live game variable. */
void
free_live_game(LiveGame *match)
{
gint i, j, k;
if(match->units == NULL || match->started_game == -1)
return;
for(i=0;i<match->units->len;i++)
free_gchar_ptr(g_array_index(match->units, LiveGameUnit, i).event.commentary);
for(i=0;i<2;i++)
{
free_g_array(&match->action_ids[i]);
free_gchar_ptr(match->team_names[i]);
for(j=0;j<LIVE_GAME_STAT_ARRAY_END;j++)
{
for(k=0;k<match->stats.players[i][j]->len;k++)
g_free(g_ptr_array_index(match->stats.players[i][j], k));
free_g_ptr_array(&match->stats.players[i][j]);
}
}
free_g_array(&match->units);
}
/**
Free a country variable.
*/
void
free_country(Country *cntry, gboolean reset)
{
free_gchar_ptr(cntry->name);
free_gchar_ptr(cntry->symbol);
free_gchar_ptr(cntry->sid);
free_leagues_array(&cntry->leagues, reset);
free_cups_array(&cntry->cups, reset);
free_g_ptr_array(&cntry->allcups);
if(reset)
cntry->allcups = g_ptr_array_new();
}
/**
Free the memory occupied by a leagues array.
@param leagues The pointer to the array we free.
*/
void
free_leagues_array(GArray **leagues, gboolean reset)
{
gint i;
if(*leagues == NULL)
{
if(reset)
*leagues = g_array_new(FALSE, FALSE, sizeof(League));
return;
}
for(i=0;i<(*leagues)->len;i++)
free_league(&g_array_index(*leagues, League, i));
free_g_array(leagues);
if(reset)
*leagues = g_array_new(FALSE, FALSE, sizeof(League));
}
/**
Free the memory occupied by a league.
@param league The pointer to the league we free.
*/
void
free_league(League *league)
{
free_gchar_ptr(league->name);
free_gchar_ptr(league->short_name);
free_gchar_ptr(league->symbol);
free_gchar_ptr(league->sid);
free_gchar_ptr(league->prom_rel.prom_games_dest_sid);
free_gchar_ptr(league->prom_rel.prom_games_cup_sid);
if(league->teams != NULL)
free_teams_array(&league->teams, FALSE);
free_g_array(&league->teams);
free_g_array(&league->prom_rel.elements);;
free_table(&league->table);
free_g_array(&league->fixtures);
free_league_stats(&league->stats);
}
/** Free the league stats. */
void
free_league_stats(LeagueStat *stats)
{
gint i;
free_gchar_ptr(stats->league_name);
free_gchar_ptr(stats->league_symbol);
for(i=0;i<stats->teams_off->len;i++)
{
free_gchar_ptr(g_array_index(stats->teams_off, Stat, i).team_name);
free_gchar_ptr(g_array_index(stats->teams_off, Stat, i).value_string);
}
free_g_array(&stats->teams_off);
for(i=0;i<stats->teams_def->len;i++)
{
free_gchar_ptr(g_array_index(stats->teams_def, Stat, i).team_name);
free_gchar_ptr(g_array_index(stats->teams_def, Stat, i).value_string);
}
free_g_array(&stats->teams_def);
for(i=0;i<stats->player_scorers->len;i++)
free_gchar_ptr(g_array_index(stats->player_scorers, Stat, i).value_string);
free_g_array(&stats->player_scorers);
for(i=0;i<stats->player_goalies->len;i++)
free_gchar_ptr(g_array_index(stats->player_goalies, Stat, i).value_string);
free_g_array(&stats->player_goalies);
}
/** Free a table. */
void
free_table(Table *table)
{
free_gchar_ptr(table->name);
free_g_array(&table->elements);
}
/** Free the memory occupied by a teams array.
@param teams The pointer to the array we free. */
void
free_teams_array(GArray **teams, gboolean reset)
{
gint i;
if(*teams == NULL)
{
if(reset)
*teams = g_array_new(FALSE, FALSE, sizeof(Team));
return;
}
for(i=0;i<(*teams)->len;i++)
free_team(&g_array_index(*teams, Team, i));
free_g_array(teams);
if(reset)
*teams = g_array_new(FALSE, FALSE, sizeof(Team));
}
/**
Free the memory occupied by a team.
@param tm The pointer to the team we free.
*/
void
free_team(Team *tm)
{
free_gchar_ptr(tm->stadium.name);
free_gchar_ptr(tm->name);
free_gchar_ptr(tm->names_file);
free_gchar_ptr(tm->symbol);
free_gchar_ptr(tm->def_file);
free_player_array(&tm->players);
}
/** Free an array containing players. */
void
free_player_array(GArray **players)
{
gint i;
if(*players != NULL)
{
for(i=0;i<(*players)->len;i++)
free_player(&g_array_index((*players), Player, i));
free_g_array(players);
}
}
/** Free the memory occupied by a player.
@param pl The pointer to the player we free. */
void
free_player(Player *pl)
{
free_gchar_ptr(pl->name);
free_g_array(&pl->cards);
free_g_array(&pl->games_goals);
}
/**
Free the memory occupied by a cups array.
@param cups The pointer to the array we free.
*/
void
free_cups_array(GArray **cups, gboolean reset)
{
gint i;
if(*cups == NULL)
{
if(reset)
*cups = g_array_new(FALSE, FALSE, sizeof(Cup));
return;
}
for(i=0;i<(*cups)->len;i++)
free_cup(&g_array_index(*cups, Cup, i));
free_g_array(cups);
if(reset)
*cups = g_array_new(FALSE, FALSE, sizeof(Cup));
}
/**
Free the memory occupied by a cup.
@param cup The pointer to the cup we free.
*/
void
free_cup(Cup *cup)
{
gint i, j;
free_gchar_ptr(cup->name);
free_gchar_ptr(cup->short_name);
free_gchar_ptr(cup->symbol);
free_gchar_ptr(cup->sid);
for(i=0;i<cup->rounds->len;i++)
if(g_array_index(cup->rounds, CupRound, i).round_robin_number_of_groups > 0)
{
for(j=0;j<g_array_index(cup->rounds, CupRound, i).tables->len;j++)
free_table(&g_array_index(g_array_index(cup->rounds, CupRound, i).tables, Table, j));
for(j=0;j<g_array_index(cup->rounds, CupRound, i).choose_teams->len;j++)
free_cup_choose_team(
&g_array_index(g_array_index(cup->rounds, CupRound, i).choose_teams, CupChooseTeam, j));
free_g_array(&g_array_index(cup->rounds, CupRound, i).choose_teams);
free_teams_array(&g_array_index(cup->rounds, CupRound, i).teams, FALSE);
g_ptr_array_free(g_array_index(cup->rounds, CupRound, i).team_ptrs, TRUE);
}
free_g_array(&cup->rounds);
free_g_array(&cup->fixtures);
free_g_ptr_array(&cup->bye);
free_gchar_array(&cup->team_names);
free_g_ptr_array(&cup->teams);
free_gchar_array(&cup->properties);
}
/**
Free the memory occupied by a CupChooseTeam.
@param cup_choose_team The pointer to the team we free.
*/
void
free_cup_choose_team(CupChooseTeam *cup_choose_team)
{
free_gchar_ptr(cup_choose_team->sid);
}
/** Free some global variables (except for the country variable). */
void
free_variables(void)
{
free_option_list(&options, FALSE);
free_option_list(&settings, FALSE);
free_option_list(&constants, FALSE);
free_option_list(&constants_app, FALSE);
free_option_list(&tokens, FALSE);
free_gchar_ptr(save_file);
g_rand_free(rand_generator);
free_season_stats(FALSE);
}
/** Free the list with live game commentary text. */
void
free_lg_commentary(gboolean reset)
{
gint i, j;
for(i=0;i<LIVE_GAME_EVENT_END;i++)
if(lg_commentary[i] != NULL)
{
for(j=0;j<lg_commentary[i]->len;j++)
{
free_gchar_ptr(g_array_index(lg_commentary[i], LGCommentary, j).text);
free_gchar_ptr(g_array_index(lg_commentary[i], LGCommentary, j).condition);
}
free_g_array(&lg_commentary[i]);
}
if(reset)
for(i=0;i<LIVE_GAME_EVENT_END;i++)
lg_commentary[i] = g_array_new(FALSE, FALSE, sizeof(LGCommentary));
}
/**
Free a GPtrArray containing strings.
@param array The array to be freed.
*/
void
free_gchar_array(GPtrArray **array)
{
gint i;
if(*array == NULL)
return;
for(i=0;i<(*array)->len;i++)
free_gchar_ptr(g_ptr_array_index(*array, i));
free_g_ptr_array(array);
*array = NULL;
}
/** Free a GString if it isn't NULL.
@param string The string to be freed. */
void
free_g_string(GString **string)
{
if(*string == NULL)
return;
g_string_free(*string, TRUE);
*string = NULL;
}
/** Free a GArray if it isn't NULL.
@param array The array to be freed. */
void
free_g_array(GArray **array)
{
if(*array == NULL)
return;
g_array_free(*array, TRUE);
*array = NULL;
}
/** Free a GPtrArray if it isn't NULL.
@param array The array to be freed. */
void
free_g_ptr_array(GPtrArray **array)
{
if(*array == NULL)
return;
g_ptr_array_free(*array, TRUE);
*array = NULL;
}
/** Free the glist containing the support directories. */
void
free_support_dirs(void)
{
GList *elem = support_directories;
if(elem == NULL)
return;
while(elem)
{
free_gchar_ptr(elem->data);
elem = elem->next;
}
g_list_free(support_directories);
support_directories = NULL;
}
/** Free a list of names. */
void
free_name_list(NameList *namelist, gboolean reset)
{
gint i;
if(namelist->sid == NULL)
{
if(reset)
{
namelist->sid = NULL;
namelist->first_names = g_ptr_array_new();
namelist->last_names = g_ptr_array_new();
}
return;
}
free_gchar_ptr(namelist->sid);
for(i=0;i<namelist->first_names->len;i++)
free_gchar_ptr(g_ptr_array_index(namelist->first_names, i));
free_g_ptr_array(&namelist->first_names);
for(i=0;i<namelist->last_names->len;i++)
free_gchar_ptr(g_ptr_array_index(namelist->last_names, i));
free_g_ptr_array(&namelist->last_names);
if(reset)
{
namelist->sid = NULL;
namelist->first_names = g_ptr_array_new();
namelist->last_names = g_ptr_array_new();
}
}
/** Free the array with the name lists. */
void
free_names(gboolean reset)
{
gint i;
if(name_lists == NULL)
{
if(reset)
name_lists = g_array_new(FALSE, FALSE, sizeof(NameList));
return;
}
for(i=0;i<name_lists->len;i++)
free_name_list(&g_array_index(name_lists, NameList, i), FALSE);
free_g_array(&name_lists);
if(reset)
name_lists = g_array_new(FALSE, FALSE, sizeof(NameList));
}
/** Free the array with the CPU strategies. */
void
free_strategies(void)
{
gint i, j;
for(i=0;i<strategies->len;i++)
{
g_free(g_array_index(strategies, Strategy, i).sid);
g_free(g_array_index(strategies, Strategy, i).desc);
for(j=0;j<g_array_index(strategies, Strategy, i).prematch->len;j++)
{
g_free(
g_array_index(
g_array_index(
strategies, Strategy, i).prematch, StrategyPrematch, j).condition);
g_array_free(
g_array_index(
g_array_index(strategies, Strategy, i).prematch, StrategyPrematch, j).formations,
TRUE);
}
g_array_free(g_array_index(strategies, Strategy, i).prematch, TRUE);
for(j=0;j<g_array_index(strategies, Strategy, i).match_action->len;j++)
{
g_free(
g_array_index(
g_array_index(
strategies, Strategy, i).match_action, StrategyMatchAction, j).condition);
g_free(
g_array_index(
g_array_index(
strategies, Strategy, i).match_action, StrategyMatchAction, j).sub_condition);
}
g_array_free(g_array_index(strategies, Strategy, i).match_action, TRUE);
}
g_array_free(strategies, TRUE);
}
/** Free the betting arrays. */
void
free_bets(gboolean reset)
{
free_g_array(&(bets[0]));
free_g_array(&(bets[1]));
if(reset)
{
bets[0] = g_array_new(FALSE, FALSE, sizeof(BetMatch));
bets[1] = g_array_new(FALSE, FALSE, sizeof(BetMatch));
}
}
/** Free a job struct.
@param free_team Whether to free the team associated
with the job if it's an international offer. */
void
free_job(Job *job, gboolean free_tm)
{
gint i;
if(job->type == JOB_TYPE_INTERNATIONAL)
{
free_gchar_ptr(job->country_file);
free_gchar_ptr(job->country_name);
free_gchar_ptr(job->league_name);
for(i=0;i<job_teams->len;i++)
if(g_array_index(job_teams, Team, i).id == job->team_id)
{
if(free_tm)
free_team(&g_array_index(job_teams, Team, i));
g_array_remove_index(job_teams, i);
}
}
}
/** Free the jobs and job_teams arrays. */
void
free_jobs(gboolean reset)
{
gint i;
if(jobs == NULL)
{
if(reset)
{
jobs = g_array_new(FALSE, FALSE, sizeof(Job));
job_teams = g_array_new(FALSE, FALSE, sizeof(Team));
}
return;
}
for(i=0;i<jobs->len;i++)
free_job(&g_array_index(jobs, Job, i), TRUE);
free_g_array(&jobs);
free_g_array(&job_teams);
if(reset)
{
jobs = g_array_new(FALSE, FALSE, sizeof(Job));
job_teams = g_array_new(FALSE, FALSE, sizeof(Team));
}
}

View File

@ -0,0 +1,143 @@
/*
free.h
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef FREE_H
#define FREE_H
#include "bygfoot.h"
#include "cup_struct.h"
#include "job_struct.h"
#include "league_struct.h"
#include "live_game_struct.h"
#include "name_struct.h"
#include "player_struct.h"
#include "team_struct.h"
#include "user_struct.h"
#define free_gchar_ptr(string) {g_free(string); string = NULL;}
void
free_g_array(GArray **array);
void
free_g_ptr_array(GPtrArray **array);
void
free_g_string(GString **string);
void
free_memory(void);
void
free_users(gboolean reset);
void
free_user(User *user);
void
free_country(Country *cntry, gboolean reset);
void
free_leagues_array(GArray **leagues, gboolean reset);
void
free_league(League *league);
void
free_teams_array(GArray **teams, gboolean reset);
void
free_team(Team *team);
void
free_cups_array(GArray **cups, gboolean reset);
void
free_cup(Cup *cup);
void
free_cup_choose_team(CupChooseTeam *cup_choose_team);
void
free_variables(void);
void
free_gchar_array(GPtrArray **array);
void
free_player_array(GArray **players);
void
free_player(Player *pl);
void
free_live_game(LiveGame *match);
void
free_lg_commentary(gboolean reset);
void
free_option_list(OptionList *optionlist, gboolean reset);
void
free_event(Event *event);
void
free_support_dirs(void);
void
free_table(Table *table);
void
free_league_stats(LeagueStat *stats);
void
free_season_stats(gboolean reset);
void
free_transfer_list(void);
void
free_name_list(NameList *namelist, gboolean reset);
void
free_names(gboolean reset);
void
free_mmatches(GArray **mmatches, gboolean reset);
void
free_strategies(void);
void
free_bets(gboolean reset);
void
free_job(Job *job, gboolean free_tm);
void
free_jobs(gboolean reset);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,125 @@
/*
game.h
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef GAME_H
#define GAME_H
#include "bygfoot.h"
#include "fixture_struct.h"
#include "player_struct.h"
#include "live_game_struct.h"
/** Player types. @see game_get_player() */
enum GamePlayerType
{
GAME_PLAYER_TYPE_DEFEND = LIVE_GAME_UNIT_AREA_DEFEND,
GAME_PLAYER_TYPE_MIDFIELD = LIVE_GAME_UNIT_AREA_MIDFIELD,
GAME_PLAYER_TYPE_ATTACK = LIVE_GAME_UNIT_AREA_ATTACK,
GAME_PLAYER_TYPE_PENALTY,
GAME_PLAYER_TYPE_END
};
void
game_get_values(const Fixture *fix, gfloat team_values[][GAME_TEAM_VALUE_END],
gfloat home_advantage);
gfloat
game_get_player_contribution(const Player *pl, gboolean attack, gboolean special);
gint
game_get_player(const Team *tm, gint player_type,
gint number_of_penalty, gint not_this_one,
gboolean skills);
void
game_get_player_probs(GArray *players, gfloat *probs, gfloat *weights, gboolean skills);
gint
game_get_penalty_taker(const Team *tm, gint last_penalty);
void
game_initialize(Fixture *fix);
void
game_save_team_states(void);
gboolean
game_check_live_game_resume_state(void);
void
game_get_subs(gint team_number, gint *subs_in, gint *subs_out);
gint
game_substitute_player(Team *tm, gint player_number);
void
game_player_injury(Player *pl);
gfloat
game_get_foul_possession_factor(gboolean boost1, gboolean boost2);
gint
game_find_to_substitute(gint clid, const Team *tm);
void
game_substitute_player_send_off(gint clid, Team *tm, gint player_number,
gint *to_substitute, gint *substitute);
void
game_decrease_fitness(const Fixture *fix);
gint
game_player_get_ban_duration(void);
void
game_update_stats(LiveGame *lg, const LiveGameUnit *unit);
void
game_update_stats_player(LiveGame *lg, const LiveGameUnit *unit);
void
game_post_match(Fixture *fix);
void
game_assign_attendance(Fixture *fix);
void
game_assign_attendance_neutral(Fixture *fix);
void
game_stadium_event(Stadium *stadium, gint type);
void
game_get_max_values(gfloat max_values[3]);
void
game_reset_players(gint idx);
gint
game_get_default_penalty_shooter(const Team *tm);
void
game_boost_cost(void);
#endif

View File

@ -0,0 +1,853 @@
/*
game_gui.c
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "callbacks.h"
#include "file.h"
#include "game_gui.h"
#include "gui.h"
#include "job.h"
#include "league.h"
#include "live_game.h"
#include "maths.h"
#include "misc.h"
#include "option.h"
#include "treeview.h"
#include "support.h"
#include "team.h"
#include "user.h"
#include "variables.h"
#include "window.h"
/** Show the live game in the live game window.
@param unit The current unit we show. */
void
game_gui_live_game_show_unit(const LiveGameUnit *unit)
{
gchar buf[SMALL];
gfloat sleep_factor = (unit->time == 3) ?
const_float("float_game_gui_live_game_speed_penalties_factor") : 1;
gfloat fraction = (gfloat)live_game_unit_get_minute(unit) / 90;
GtkProgressBar *progress_bar =
GTK_PROGRESS_BAR(lookup_widget(window.live, "progressbar_live"));
GtkHScale *hscale =
GTK_HSCALE(lookup_widget(window.live, "hscale_area"));
GtkWidget *button_pause = lookup_widget(window.live, "button_pause"),
*button_resume = lookup_widget(window.live, "button_resume"),
*button_live_close = lookup_widget(window.live, "button_live_close"),
*eventbox_poss[2] = {lookup_widget(window.live, "eventbox_poss0"),
lookup_widget(window.live, "eventbox_poss1")};
GdkColor color;
if(unit->event.type == LIVE_GAME_EVENT_START_MATCH)
treeview_live_game_show_initial_commentary(unit);
else if(option_int("int_opt_user_live_game_verbosity",
&usr(stat2).options) > unit->event.verbosity)
treeview_live_game_show_commentary(unit);
treeview_live_game_show_result(unit);
gdk_color_parse (const_app("string_live_game_possession_color"), &color);
gtk_widget_modify_bg(eventbox_poss[unit->possession], GTK_STATE_NORMAL, &color);
gtk_widget_modify_bg(eventbox_poss[!unit->possession], GTK_STATE_NORMAL, NULL);
if(option_int("int_opt_user_show_tendency_bar",
&usr(stat2).options))
game_gui_live_game_set_hscale(unit, hscale);
else
gtk_widget_hide(GTK_WIDGET(hscale));
sprintf(buf, "%d.", live_game_unit_get_minute(unit));
gtk_progress_bar_set_fraction(progress_bar, (fraction > 1) ? 1 : fraction);
gtk_progress_bar_set_text(progress_bar, buf);
g_usleep((gint)rint(sleep_factor *
(gfloat)(const_int("int_game_gui_live_game_speed_max") +
(option_int("int_opt_user_live_game_speed", &usr(stat2).options) *
const_int("int_game_gui_live_game_speed_grad")))));
while(gtk_events_pending())
gtk_main_iteration();
if(unit->event.type == LIVE_GAME_EVENT_START_MATCH)
{
gtk_widget_set_sensitive(button_live_close, (stat1 == STATUS_SHOW_LAST_MATCH));
gtk_widget_set_sensitive(button_pause, TRUE);
gtk_widget_set_sensitive(button_resume, FALSE);
gtk_widget_grab_focus(button_pause);
}
else if(unit->event.type == LIVE_GAME_EVENT_END_MATCH)
{
gtk_widget_set_sensitive(button_live_close, TRUE);
gtk_widget_set_sensitive(button_pause, FALSE);
gtk_widget_set_sensitive(button_resume, FALSE);
gui_set_sensitive_lg_meters(FALSE);
gtk_widget_grab_focus(button_live_close);
game_gui_set_main_window_sensitivity(FALSE);
}
else if(unit->event.type == LIVE_GAME_EVENT_PENALTIES)
{
gtk_widget_set_sensitive(button_pause, (stat1 == STATUS_SHOW_LAST_MATCH));
gtk_widget_set_sensitive(button_resume, FALSE);
}
}
/** Set the area scale position and color in the live game window.
@param unit The current unit.
@param hscale The scale widget. */
void
game_gui_live_game_set_hscale(const LiveGameUnit *unit, GtkHScale *hscale)
{
GdkColor color;
gtk_widget_modify_bg(GTK_WIDGET(hscale), GTK_STATE_NORMAL, NULL);
if(unit->area == LIVE_GAME_UNIT_AREA_MIDFIELD)
{
gdk_color_parse(const_app("string_game_gui_live_game_scale_color_midfield"), &color);
gtk_range_set_value(GTK_RANGE(hscale),
const_float("float_game_gui_live_game_scale_range") / 2);
}
else if(unit->event.type == LIVE_GAME_EVENT_GOAL ||
unit->event.type == LIVE_GAME_EVENT_OWN_GOAL)
{
gdk_color_parse(const_app("string_game_gui_live_game_scale_color_goal"), &color);
gtk_range_set_value(GTK_RANGE(hscale),
const_float("float_game_gui_live_game_scale_range") *
(unit->possession == 0));
}
else if(unit->event.type == LIVE_GAME_EVENT_SCORING_CHANCE ||
unit->event.type == LIVE_GAME_EVENT_PENALTY ||
unit->event.type == LIVE_GAME_EVENT_FREE_KICK)
{
gdk_color_parse(const_app("string_game_gui_live_game_scale_color_chance"), &color);
gtk_range_set_value(GTK_RANGE(hscale),
const_float("float_game_gui_live_game_scale_range") / 2 +
(const_float("float_game_gui_live_game_scale_range") *
const_float("float_game_gui_live_game_scale_chance") *
((unit->possession == 0) ? 1 : -1)));
}
else if(unit->event.type == LIVE_GAME_EVENT_POST ||
unit->event.type == LIVE_GAME_EVENT_MISS ||
unit->event.type == LIVE_GAME_EVENT_SAVE ||
unit->event.type == LIVE_GAME_EVENT_CROSS_BAR)
gdk_color_parse(const_app("string_game_gui_live_game_scale_color_miss"), &color);
else if(unit->area == LIVE_GAME_UNIT_AREA_ATTACK)
{
gdk_color_parse(const_app("string_game_gui_live_game_scale_color_attack"), &color);
gtk_range_set_value(GTK_RANGE(hscale),
const_float("float_game_gui_live_game_scale_range") / 2 +
(const_float("float_game_gui_live_game_scale_range") *
const_float("float_game_gui_live_game_scale_attack") *
((unit->possession == 0) ? 1 : -1)));
}
else if(unit->area == LIVE_GAME_UNIT_AREA_DEFEND)
{
gdk_color_parse(const_app("string_game_gui_live_game_scale_color_defend"), &color);
gtk_range_set_value(GTK_RANGE(hscale),
const_float("float_game_gui_live_game_scale_range") / 2 +
(const_float("float_game_gui_live_game_scale_range") *
const_float("float_game_gui_live_game_scale_attack") *
((unit->possession == 0) ? -1 : 1)));
}
else
g_warning("game_gui_live_game_set_hscale: don't know what to do!\n");
gtk_widget_modify_bg(GTK_WIDGET(hscale), GTK_STATE_NORMAL, &color);
}
/** Show the player list of the opposing team in the live game
window. */
void
game_gui_live_game_show_opponent(void)
{
GtkImage *image_style =
GTK_IMAGE(lookup_widget(window.live, "image_lg_opp_style")),
*image_boost =
GTK_IMAGE(lookup_widget(window.live, "image_lg_opp_boost"));
GtkLabel *label_form =
GTK_LABEL(lookup_widget(window.live, "label_lg_formation")),
*label_avskill =
GTK_LABEL(lookup_widget(window.live, "label_lg_avskill"));
GtkTreeView *treeview =
GTK_TREE_VIEW(lookup_widget(window.live, "treeview_lg_opponent"));
gint idx = (team_is_user(((LiveGame*)statp)->fix->teams[0]) == -1);
const Team *tm = ((LiveGame*)statp)->fix->teams[!idx];
gint scout = user_from_team(((LiveGame*)statp)->fix->teams[idx])->scout;
gfloat avskills[2] = {team_get_average_skill(tm, TRUE),
team_get_average_skill(current_user.tm, TRUE)};
gchar buf[SMALL];
treeview_show_player_list_team(treeview, tm, scout);
game_gui_write_meter_images(tm, image_style, image_boost);
gui_label_set_text_from_int(label_form, tm->structure, FALSE);
sprintf(buf, "%.1f (%+.1f)", avskills[0],
avskills[0] - avskills[1]);
gtk_label_set_text(label_avskill, buf);
}
/** Look up the widgets in the main window. */
void
game_gui_get_radio_items(GtkWidget **style, GtkWidget **scout,
GtkWidget **physio, GtkWidget **boost,
GtkWidget **yc, GtkWidget **ya_pos_pref)
{
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");
boost[0] = lookup_widget(window.main, "menu_boost_anti");
boost[1] = lookup_widget(window.main, "menu_boost_off");
boost[2] = lookup_widget(window.main, "menu_boost_on");
yc[0] = lookup_widget(window.main, "menu_yc_best");
yc[1] = lookup_widget(window.main, "menu_yc_good");
yc[2] = lookup_widget(window.main, "menu_yc_average");
yc[3] = lookup_widget(window.main, "menu_yc_bad");
ya_pos_pref[0] = lookup_widget(window.main, "menu_recruit0");
ya_pos_pref[1] = lookup_widget(window.main, "menu_recruit1");
ya_pos_pref[2] = lookup_widget(window.main, "menu_recruit2");
ya_pos_pref[3] = lookup_widget(window.main, "menu_recruit3");
ya_pos_pref[4] = lookup_widget(window.main, "menu_recruit4");
}
/** Set information like season, user, week etc. into the appropriate labels. */
void
game_gui_set_main_window_header(void)
{
gint i, rank;
gchar buf[SMALL];
GtkLabel *label_user= GTK_LABEL(lookup_widget(window.main, "label_user")),
*label_season= GTK_LABEL(lookup_widget(window.main, "label_season")),
*label_week= GTK_LABEL(lookup_widget(window.main, "label_week")),
*label_round= GTK_LABEL(lookup_widget(window.main, "label_round")),
*label_team= GTK_LABEL(lookup_widget(window.main, "label_team")),
*label_league= GTK_LABEL(lookup_widget(window.main, "label_league")),
*label_rank= GTK_LABEL(lookup_widget(window.main, "label_rank")),
*label_money= GTK_LABEL(lookup_widget(window.main, "label_money"));
GtkWidget *menu_users[2] = {lookup_widget(window.main, "menu_next_user"),
lookup_widget(window.main, "menu_previous_user")};
gtk_label_set_text(label_user, current_user.name);
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);
if(!sett_int("int_opt_disable_finances"))
{
misc_print_grouped_int(current_user.money, buf);
gtk_label_set_text(label_money, buf);
}
else
{
gtk_widget_hide(GTK_WIDGET(label_money));
gtk_widget_hide(GTK_WIDGET(lookup_widget(window.main, "label34")));
}
rank = team_get_league_rank(current_user.tm);
if(rank != 0)
gui_label_set_text_from_int(label_rank, rank, FALSE);
else
{
gtk_widget_hide(GTK_WIDGET(label_rank));
gtk_widget_hide(lookup_widget(window.main, "label29"));
}
gtk_label_set_text(label_team, current_user.tm->name);
gtk_label_set_text(label_league, league_cup_get_name_string(current_user.tm->clid));
for(i=0;i<2;i++)
gtk_widget_set_sensitive(menu_users[i], (users->len > 1));
game_gui_write_av_skills(NULL);
game_gui_write_radio_items();
game_gui_write_meters(current_user.tm);
game_gui_write_check_items();
}
/** Set the average skills of the current team
into the appropriate labels. */
void
game_gui_write_av_skills(const Team *tm)
{
gchar buf[SMALL];
GtkLabel *label_av_skills= GTK_LABEL(lookup_widget(window.main, "label_av_skills"));
const Team *tm_local = (tm == NULL) ? current_user.tm : tm;
sprintf(buf, "%.1f %.1f",
team_get_average_skill(tm_local, TRUE),
team_get_average_skill(tm_local, FALSE));
gtk_label_set_text(label_av_skills, buf);
}
/** Set the images for the style and boost meters to the appropriate values
from the team settings. */
void
game_gui_write_meter_images(const Team *tm, GtkImage *style, GtkImage *boost)
{
gint i;
gchar *image_style_files[5] =
{file_find_support_file(const_app("string_game_gui_style_all_out_defend_icon"), TRUE),
file_find_support_file(const_app("string_game_gui_style_defend_icon"), TRUE),
file_find_support_file(const_app("string_game_gui_style_balanced_icon"), TRUE),
file_find_support_file(const_app("string_game_gui_style_attack_icon"), TRUE),
file_find_support_file(const_app("string_game_gui_style_all_out_attack_icon"), TRUE)};
gchar *image_boost_files[3] =
{file_find_support_file(const_app("string_game_gui_boost_anti_icon"), TRUE),
file_find_support_file(const_app("string_game_gui_boost_off_icon"), TRUE),
file_find_support_file(const_app("string_game_gui_boost_on_icon"), TRUE)};
gtk_image_set_from_file(style, image_style_files[tm->style + 2]);
gtk_image_set_from_file(boost, image_boost_files[tm->boost + 1]);
for(i=0;i<5;i++)
g_free(image_style_files[i]);
for(i=0;i<3;i++)
g_free(image_boost_files[i]);
}
/** Set the images for the style and boost meters in the main
window and the live game window. */
void
game_gui_write_meters(const Team *tm)
{
GtkImage *image_style_main = GTK_IMAGE(lookup_widget(window.main, "image_style")),
*image_boost_main = GTK_IMAGE(lookup_widget(window.main, "image_boost"));
GtkImage *image_style_live = NULL,
*image_boost_live = NULL;
game_gui_write_meter_images(tm, image_style_main, image_boost_main);
if(window.live != NULL)
{
image_style_live = GTK_IMAGE(lookup_widget(window.live, "image_lg_style"));
image_boost_live = GTK_IMAGE(lookup_widget(window.live, "image_lg_boost"));
game_gui_write_meter_images(tm, image_style_live, image_boost_live);
}
}
/** Activate the appropriate radio items for
playing style etc. according to the user settings. */
void
game_gui_write_radio_items(void)
{
GtkWidget *style[5], *scout[4], *physio[4],
*boost[3], *yc[4], *ya_pos_pref[5];
game_gui_get_radio_items(style, scout, physio, boost, yc, ya_pos_pref);
gtk_check_menu_item_set_active(
GTK_CHECK_MENU_ITEM(style[current_user.tm->style + 2]), TRUE);
gtk_check_menu_item_set_active(
GTK_CHECK_MENU_ITEM(scout[current_user.scout % 10]), TRUE);
gtk_check_menu_item_set_active(
GTK_CHECK_MENU_ITEM(physio[current_user.physio % 10]), TRUE);
gtk_check_menu_item_set_active(
GTK_CHECK_MENU_ITEM(boost[current_user.tm->boost + 1]), TRUE);
gtk_check_menu_item_set_active(
GTK_CHECK_MENU_ITEM(yc[current_user.youth_academy.coach % 10]), TRUE);
gtk_check_menu_item_set_active(
GTK_CHECK_MENU_ITEM(ya_pos_pref[current_user.youth_academy.pos_pref]), TRUE);
}
/** 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[3], *yc[4], *ya_pos_pref[5];
GtkWidget *style[5], *scout[4], *physio[4];
gint old_scout = current_user.scout,
old_physio = current_user.physio,
old_yc = current_user.youth_academy.coach;
game_gui_get_radio_items(style, scout, physio, boost, yc, ya_pos_pref);
for(i=0;i<3;i++)
if(widget == boost[i])
{
current_user.tm->boost = i - 1;
if(current_user.tm->boost == 1 && sett_int("int_opt_disable_boost_on"))
{
current_user.tm->boost = 0;
game_gui_print_message(_("Boost ON is disabled in this country definition."));
}
}
for(i=0;i<5;i++)
if(widget == style[i])
current_user.tm->style = i - 2;
if(!sett_int("int_opt_disable_transfers"))
{
for(i=0;i<4;i++)
if(widget == scout[i])
current_user.scout = 100 + i * 10 + old_scout % 10;
}
if(!sett_int("int_opt_disable_transfers"))
{
for(i=0;i<4;i++)
if(widget == physio[i])
current_user.physio = 100 + i * 10 + old_physio % 10;
}
if(!sett_int("int_opt_disable_ya"))
{
for(i=0;i<4;i++)
if(widget == yc[i])
current_user.youth_academy.coach = 100 + i * 10 + old_yc % 10;
}
if(!sett_int("int_opt_disable_ya"))
{
for(i=0;i<5;i++)
if(widget == ya_pos_pref[i])
current_user.youth_academy.pos_pref = i;
}
if(math_get_place(current_user.scout, 2) == old_scout % 10)
current_user.scout = old_scout % 10;
if(math_get_place(current_user.physio, 2) == old_physio % 10)
current_user.physio = old_physio % 10;
if(math_get_place(current_user.youth_academy.coach, 2) == old_yc % 10)
current_user.youth_academy.coach = old_yc % 10;
if(old_scout != current_user.scout ||
old_physio != current_user.physio ||
old_yc != current_user.youth_academy.coach)
game_gui_print_message(_("Next week you'll fire him and hire a new one."));
game_gui_write_meters(current_user.tm);
game_gui_write_radio_items();
treeview_show_next_opponent();
}
/** Show the main menu. */
void
game_gui_show_main(void)
{
game_gui_set_main_window_header();
treeview_show_user_player_list();
current_user.counters[COUNT_USER_TOOK_TURN] = 1;
if(current_user.counters[COUNT_USER_SHOW_RES] && stat0 != STATUS_LIVE_GAME_PAUSE)
{
on_menu_user_show_last_stats_activate(NULL, NULL);
current_user.counters[COUNT_USER_SHOW_RES] = 0;
/** Check the success counter and offer a job
(or fire player) if necessary. */
user_job_offer(&current_user);
}
else
treeview_show_next_opponent();
if(current_user.counters[COUNT_USER_NEW_SPONSOR] == 1)
user_show_sponsors();
else if(current_user.counters[COUNT_USER_NEW_SPONSOR] == -1)
user_show_sponsor_continue();
}
/** Print a message in the message area. */
void
game_gui_print_message(gchar *format, ...)
{
gchar text[SMALL];
va_list args;
va_start (args, format);
g_vsprintf(text, format, args);
va_end (args);
gtk_entry_set_text(GTK_ENTRY(lookup_widget(window.main, "entry_message")), text);
if(timeout_id != -1)
g_source_remove(timeout_id);
timeout_id = g_timeout_add(const_int("int_game_gui_message_duration") * 1000,
(GSourceFunc)game_gui_clear_entry_message, NULL);
}
/** Source function for the delay printing function. */
gboolean
game_gui_print_message_source(gpointer data)
{
game_gui_print_message((gchar*)data);
g_free(data);
return FALSE;
}
/** Print a message after some seconds of delay. */
void
game_gui_print_message_with_delay(const gchar *format, ...)
{
gchar text[SMALL];
va_list args;
va_start (args, format);
g_vsprintf(text, format, args);
va_end (args);
if(timeout_id != -1)
g_source_remove(timeout_id);
g_timeout_add(const_int("int_game_gui_message_delay") * 1000,
(GSourceFunc)game_gui_print_message_source,
(gpointer)g_strdup(text));
}
/** Function that gets called from time to time. */
gboolean
game_gui_clear_entry_message(gpointer data)
{
if(window.main != NULL)
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_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_YOUTH_ACADEMY,
INSENSITIVE_ITEM_MENU_SHOW_JOB_EXCHANGE,
INSENSITIVE_ITEM_MENU_PUT_ON_TRANSFER_LIST,
INSENSITIVE_ITEM_MENU_REMOVE_FROM_TRANSFER_LIST,
INSENSITIVE_ITEM_MENU_FIRE,
INSENSITIVE_ITEM_MENU_MOVE_TO_YOUTH_ACADEMY,
INSENSITIVE_ITEM_MENU_USER,
INSENSITIVE_ITEM_MENU_FINANCES_STADIUM,
INSENSITIVE_ITEM_MENU_HELP,
INSENSITIVE_ITEM_MENU_BROWSE_PLAYERS,
INSENSITIVE_ITEM_MENU_OFFER_CONTRACT,
INSENSITIVE_ITEM_END
};
enum MainWindowShowItems
{
SHOW_ITEM_RESET_BUTTON = 0,
SHOW_ITEM_RESET_MENU,
SHOW_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];
GtkWidget *show_items[SHOW_ITEM_END];
insensitive_items[INSENSITIVE_ITEM_TOOLBAR] =
lookup_widget(window.main, "hbox1");
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_YOUTH_ACADEMY] =
lookup_widget(window.main, "menu_youth_academy");
insensitive_items[INSENSITIVE_ITEM_MENU_SHOW_JOB_EXCHANGE] =
lookup_widget(window.main, "menu_show_job_exchange");
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_MOVE_TO_YOUTH_ACADEMY] =
lookup_widget(window.main, "menu_move_to_youth_academy");
insensitive_items[INSENSITIVE_ITEM_MENU_USER] =
lookup_widget(window.main, "menu_user");
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");
insensitive_items[INSENSITIVE_ITEM_MENU_BROWSE_PLAYERS] =
lookup_widget(window.main, "menu_browse_players");
insensitive_items[INSENSITIVE_ITEM_MENU_OFFER_CONTRACT] =
lookup_widget(window.main, "menu_offer_new_contract");
show_items[SHOW_ITEM_RESET_BUTTON] =
lookup_widget(window.main, "button_reset_players");
show_items[SHOW_ITEM_RESET_MENU] =
lookup_widget(window.main, "menu_reset_players");
for(i=0;i<INSENSITIVE_ITEM_END;i++)
gtk_widget_set_sensitive(insensitive_items[i], !value);
if(value)
for(i=0;i<SHOW_ITEM_END;i++)
gtk_widget_show(show_items[i]);
else
for(i=0;i<SHOW_ITEM_END;i++)
gtk_widget_hide(show_items[i]);
gtk_window_set_modal(GTK_WINDOW(window.live), !value);
}
/** Show a window with a warning.
@param text The text to show in the window. */
void
game_gui_show_warning(const gchar *format, ...)
{
gchar text[SMALL];
va_list args;
va_start (args, format);
g_vsprintf(text, format, args);
va_end (args);
if(opt_int("int_opt_prefer_messages") &&
window.main != NULL)
game_gui_print_message(text);
else
{
window_create(WINDOW_WARNING);
gtk_label_set_text(GTK_LABEL(lookup_widget(window.warning, "label_warning")), text);
}
}
/** Show the job offer window.
@param team The team offering the job or NULL if we're looking
at a job offer from the job exchange.
@param job The job pointer or NULL (depends on whether we're looking
at a job offer from the job exchange).
@param type The offer type (eg. whether the user's been fired). */
void
game_gui_show_job_offer(Team *team, Job *job, gint type)
{
gchar buf[SMALL], buf2[SMALL];
GtkLabel *label_text, *label_text2, *label_name,
*label_league, *label_rank, *label_money,
*label_cap, *label_saf, *label_average_skill;
Team *tm = (type != STATUS_JOB_EXCHANGE_SHOW_TEAM) ?
team : job_get_team(job);
statp = (type != STATUS_JOB_EXCHANGE_SHOW_TEAM) ?
(gpointer)team : (gpointer)job;
stat2 = type;
if(type == STATUS_JOB_OFFER_FIRE_FINANCE ||
type == STATUS_JOB_OFFER_FIRE_FAILURE)
user_history_add(&current_user, (type == STATUS_JOB_OFFER_FIRE_FINANCE) ?
USER_HISTORY_FIRE_FINANCE : USER_HISTORY_FIRE_FAILURE,
current_user.tm->name, team->name,
league_cup_get_name_string(team->clid), NULL);
window_create(WINDOW_JOB_OFFER);
label_text = GTK_LABEL(lookup_widget(window.job_offer, "label_text"));
label_text2 = GTK_LABEL(lookup_widget(window.job_offer, "label_text2"));
label_name = GTK_LABEL(lookup_widget(window.job_offer, "label_name"));
label_league = GTK_LABEL(lookup_widget(window.job_offer, "label_league"));
label_rank = GTK_LABEL(lookup_widget(window.job_offer, "label_rank"));
label_money = GTK_LABEL(lookup_widget(window.job_offer, "label_money"));
label_cap = GTK_LABEL(lookup_widget(window.job_offer, "label_cap"));
label_saf = GTK_LABEL(lookup_widget(window.job_offer, "label_saf"));
label_average_skill =
GTK_LABEL(lookup_widget(window.job_offer, "label_average_skill"));
if(type == STATUS_JOB_OFFER_FIRE_FINANCE)
sprintf(buf, _("The team owners have fired you because of financial mismanagement. Luckily, the owners of %s have heard of your dismissal and offer you a job. Here's some information on %s:"),
tm->name, tm->name);
else if(type == STATUS_JOB_OFFER_FIRE_FAILURE)
sprintf(buf, _("The team owners have fired you because of unsuccessfulness. Luckily, the owners of %s have heard of your dismissal and offer you a job. Here's some information on %s:"),
tm->name, tm->name);
else if(type == STATUS_JOB_OFFER_SUCCESS)
sprintf(buf, _("The owners of %s are deeply impressed by your success with %s and would like to hire you. Here's some information on %s:"),
tm->name, current_user.tm->name, tm->name);
else if(type == STATUS_JOB_EXCHANGE_SHOW_TEAM)
strcpy(buf, _("Click on OK to apply for the job. Click on CANCEL to close the window."));
strcpy(buf2, (type != STATUS_JOB_EXCHANGE_SHOW_TEAM) ?
_("Accept?") : _("Apply for the job?"));
if(type != STATUS_JOB_OFFER_SUCCESS &&
type != STATUS_JOB_EXCHANGE_SHOW_TEAM)
strcat(buf2, _(" (NOTE: If you don't, the game is over for you.)"));
gtk_label_set_text(label_text, buf);
gtk_label_set_text(label_text2, buf2);
gtk_label_set_text(label_name, tm->name);
gtk_label_set_text(label_league,
(type != STATUS_JOB_EXCHANGE_SHOW_TEAM) ?
league_cup_get_name_string(tm->clid) : job->league_name);
if(job == NULL ||
job->type == JOB_TYPE_NATIONAL)
gui_label_set_text_from_int(label_rank,
team_get_league_rank(tm), FALSE);
misc_print_grouped_int(
math_round_integer(tm->stadium.capacity *
math_rndi(const_int("int_initial_money_lower"),
const_int("int_initial_money_upper")), 2),
buf);
gtk_label_set_text(label_money, buf);
misc_print_grouped_int(tm->stadium.capacity, buf);
gtk_label_set_text(label_cap, buf);
gui_label_set_text_from_int(label_saf,
(gint)rint(tm->stadium.safety * 100), FALSE);
sprintf(buf, "%.1f", team_get_average_skill(tm, FALSE));
gtk_label_set_text(label_average_skill, buf);
treeview_show_player_list_team(
GTK_TREE_VIEW(lookup_widget(window.job_offer, "treeview_players")),
tm,
(type != STATUS_JOB_OFFER_SUCCESS && type != STATUS_JOB_EXCHANGE_SHOW_TEAM) ?
2 : current_user.scout);
}
/** Write the checkbuttons in the menus. */
void
game_gui_write_check_items(void)
{
GtkCheckMenuItem *menu_job_offers =
GTK_CHECK_MENU_ITEM(lookup_widget(window.main, "menu_job_offers")),
*menu_live_game =
GTK_CHECK_MENU_ITEM(lookup_widget(window.main, "menu_live_game")),
*menu_overwrite =
GTK_CHECK_MENU_ITEM(lookup_widget(window.main, "menu_overwrite"));
gtk_check_menu_item_set_active(menu_job_offers,
opt_user_int("int_opt_user_show_job_offers"));
gtk_check_menu_item_set_active(menu_live_game,
opt_user_int("int_opt_user_show_live_game"));
gtk_check_menu_item_set_active(menu_overwrite,
opt_int("int_opt_save_will_overwrite"));
}
/** Change the options according to the check menu widgets. */
void
game_gui_read_check_items(GtkWidget *widget)
{
GtkWidget *menu_job_offers =
lookup_widget(window.main, "menu_job_offers"),
*menu_live_game = lookup_widget(window.main, "menu_live_game"),
*menu_overwrite = lookup_widget(window.main, "menu_overwrite");
if(widget == menu_job_offers)
{
opt_user_set_int("int_opt_user_show_job_offers",
!opt_user_int("int_opt_user_show_job_offers"));
game_gui_print_message(_("Job offers set to %s."),
team_attribute_to_char(
TEAM_ATTRIBUTE_BOOST,
opt_user_int("int_opt_user_show_job_offers")));
}
else if(widget == menu_live_game)
{
opt_user_set_int("int_opt_user_show_live_game",
!opt_user_int("int_opt_user_show_live_game"));
game_gui_print_message(_("Live game set to %s."),
team_attribute_to_char(
TEAM_ATTRIBUTE_BOOST,
opt_user_int("int_opt_user_show_live_game")));
}
else if(widget == menu_overwrite)
{
opt_set_int("int_opt_save_will_overwrite",
!opt_int("int_opt_save_will_overwrite"));
game_gui_print_message(_("Overwrite set to %s."),
team_attribute_to_char(
TEAM_ATTRIBUTE_BOOST,
opt_int("int_opt_save_will_overwrite")));
}
else
g_warning("game_gui_read_check_items: unknown widget.");
}
/** Set the appropriate text into the labels in the help window.
@param help_list The stuff loaded from the bygfoot_help file. */
void
game_gui_set_help_labels(void)
{
GtkLabel *label_help_text1 =
GTK_LABEL(lookup_widget(window.help, "label_help_text1")),
*label_help_text2 = GTK_LABEL(lookup_widget(window.help, "label_help_text2"));
GString *text = g_string_new("");
gtk_label_set_text(label_help_text1,
_("Bygfoot is a very intuitive and simple game, so there isn't a full-grown documentation. However, if you have trouble, there are a few places to go.\n"));
g_string_append_printf(text, _("At the Bygfoot forums you can report bugs, ask for help and discuss the game (you don't have to register):\n"));
g_string_append_printf(text, "http://bygfoot.sourceforge.net/forum\n");
g_string_append_printf(text, _("\nIf you feel you've found out something about the game that has to be shared, you can add it to the Bygfoot Wiki:\n"));
g_string_append_printf(text, "http://mec-symonds.eng.monash.edu.au/cgi-bin/twiki/view/Bygfoot/WebHome");
gtk_label_set_text(label_help_text2, text->str);
g_string_free(text, TRUE);
}

View File

@ -0,0 +1,125 @@
/*
game_gui.h
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef GAME_GUI_H
#define GAME_GUI_H
#include <stdarg.h>
#include <glib/gprintf.h>
#include "bygfoot.h"
#include "job_struct.h"
#include "live_game_struct.h"
#include "option_struct.h"
#define setsav1 gtk_widget_set_sensitive(lookup_widget(window.main, "button_save"), FALSE);gtk_widget_set_sensitive(lookup_widget(window.main, "menu_save"), FALSE)
#define setsav0 gtk_widget_set_sensitive(lookup_widget(window.main, "button_save"), TRUE);gtk_widget_set_sensitive(lookup_widget(window.main, "menu_save"), TRUE)
#define getsav GTK_WIDGET_SENSITIVE(lookup_widget(window.main, "button_save"))
void
game_gui_live_game_show_unit(const LiveGameUnit *unit);
void
game_gui_live_game_set_hscale(const LiveGameUnit *unit, GtkHScale *hscale);
void
game_gui_live_game_show_opponent(void);
void
game_gui_set_main_window_header(void);
void
game_gui_show_main(void);
#ifdef G_OS_UNIX
void
game_gui_show_warning(const gchar *format, ...)
__attribute__ ((format (printf, 1, 2)));
#else
void
game_gui_show_warning(const gchar *format, ...);
#endif
#ifdef G_OS_UNIX
void
game_gui_print_message(gchar *format, ...)
__attribute__ ((format (printf, 1, 2)));
#else
void
game_gui_print_message(gchar *format, ...);
#endif
gboolean
game_gui_print_message_source(gpointer data);
#ifdef G_OS_UNIX
void
game_gui_print_message_with_delay(const gchar *format, ...)
__attribute__ ((format (printf, 1, 2)));
#else
void
game_gui_print_message_with_delay(const gchar *format, ...);
#endif
void
game_gui_get_radio_items(GtkWidget **style, GtkWidget **scout,
GtkWidget **physio, GtkWidget **boost,
GtkWidget **yc, GtkWidget **ya_pos_pref);
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(const Team *tm);
void
game_gui_write_meter_images(const Team *tm, GtkImage *style,
GtkImage *boost);
void
game_gui_write_meters(const Team *tm);
void
game_gui_show_job_offer(Team *team, Job *job, gint type);
void
game_gui_write_check_items(void);
void
game_gui_read_check_items(GtkWidget *widget);
void
game_gui_set_help_labels(void);
#endif

View File

@ -0,0 +1,56 @@
/*
gettext_macros.h
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
* Standard gettext macros.
*/
#ifndef G_OS_UNIX
#define ENABLE_NLS
#endif
#ifdef ENABLE_NLS
# ifndef G_OS_UNIX
# define PACKAGE "bygfoot"
# define GETTEXT_PACKAGE "bygfoot"
# define PACKAGE_LOCALE_DIR "./locale"
# endif
# include <libintl.h>
# undef _
# define _(String) dgettext (PACKAGE, String)
# ifdef gettext_noop
# define N_(String) gettext_noop (String)
# else
# define N_(String) (String)
# endif
#else
# define textdomain(String) (String)
# define gettext(String) (String)
# define dgettext(Domain,Message) (Message)
# define dcgettext(Domain,Message,Type) (Message)
# define bindtextdomain(Domain,Directory) (Domain)
# define _(String) (String)
# define N_(String) (String)
#endif

View File

@ -0,0 +1,144 @@
/*
gui.c
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "gui.h"
#include "misc.h"
#include "option.h"
#include "support.h"
#include "variables.h"
#include "window.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);
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);
}
/* Show a window with a progress bar.
@param value The value of the progress bar. If set to 1
or < 0 the progress bar window gets destroyed.
@param text The text to show in the progress bar.
@param pictype What kind of picture to show above the progress bar. */
void
gui_show_progress(gfloat value, const gchar *text, gint pictype)
{
GtkProgressBar *progressbar = NULL;
if(value == 1 || value < 0)
{
window_destroy(&window.progress);
return;
}
if(window.progress == NULL)
window_show_progress(pictype);
progressbar = GTK_PROGRESS_BAR(lookup_widget(window.progress, "progressbar"));
if(value >= 0 && value < 1)
gtk_progress_bar_set_fraction(progressbar, value);
else
gtk_progress_bar_pulse(progressbar);
if(text != NULL)
gtk_progress_bar_set_text(progressbar, text);
while(gtk_events_pending())
gtk_main_iteration();
}
/** Set either the right pair of arrows atop the right
treeview or the left pair or both to the specified
sensitivity state. */
void
gui_set_arrow_pair(gint pair, gboolean state)
{
gint i, j;
GtkWidget *buttons[2][2] =
{{lookup_widget(window.main ,"button_cl_back"),
lookup_widget(window.main ,"button_cl_forward")},
{lookup_widget(window.main ,"button_browse_back"),
lookup_widget(window.main ,"button_browse_forward")}};
if(pair < 3)
for(i=0;i<2;i++)
gtk_widget_set_sensitive(buttons[pair][i], state);
else
for(i=0;i<2;i++)
for(j=0;j<2;j++)
gtk_widget_set_sensitive(buttons[i][j], state);
}
/** Examine the status variable and set the
sensitivity of the arrows atop the right treeview
accordingly. */
void
gui_set_arrows(void)
{
gui_set_arrow_pair(3, FALSE);
if(stat0 == STATUS_SHOW_FIXTURES ||
stat0 == STATUS_BROWSE_TEAMS ||
stat0 == STATUS_SHOW_SEASON_HISTORY)
gui_set_arrow_pair(3, TRUE);
else if(stat0 == STATUS_SHOW_PLAYER_INFO ||
stat0 == STATUS_SHOW_FIXTURES_WEEK)
gui_set_arrow_pair(1, TRUE);
else if(stat0 == STATUS_SHOW_TABLES ||
stat0 == STATUS_SHOW_PLAYER_LIST ||
stat0 == STATUS_SHOW_LEAGUE_STATS)
gui_set_arrow_pair(0, TRUE);
}
/** Set the sensitivity of the live game window meters and their
eventboxes. */
void
gui_set_sensitive_lg_meters(gboolean state)
{
gtk_widget_set_sensitive(lookup_widget(window.live, "image_lg_style"), state);
gtk_widget_set_sensitive(lookup_widget(window.live, "eventbox_lg_style"), state);
gtk_widget_set_sensitive(lookup_widget(window.live, "image_lg_boost"), state);
gtk_widget_set_sensitive(lookup_widget(window.live, "eventbox_lg_boost"), state);
}

View File

@ -0,0 +1,55 @@
/*
gui.h
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef GUI_H
#define GUI_H
#include "bygfoot.h"
/** What kind of pictures we on top of the progress bar. */
enum PicType
{
PIC_TYPE_NONE = 0,
PIC_TYPE_SAVE,
PIC_TYPE_LOAD,
PIC_TYPE_MATCHPIC
};
void
gui_label_set_text_from_int(GtkLabel *label, gint number, gboolean append);
void
gui_show_progress(gfloat value, const gchar *text, gint pictype);
void
gui_set_arrow_pair(gint pair, gboolean state);
void
gui_set_arrows(void);
void
gui_set_sensitive_lg_meters(gboolean state);
#endif

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -0,0 +1,392 @@
/*
job.c
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "bet.h"
#include "cup.h"
#include "file.h"
#include "free.h"
#include "job.h"
#include "league.h"
#include "live_game.h"
#include "main.h"
#include "maths.h"
#include "option.h"
#include "start_end.h"
#include "team.h"
#include "transfer.h"
#include "user.h"
#include "variables.h"
#include "xml_country.h"
/** Update the job exchange: remove expired offers and add new ones. */
void
job_update(void)
{
gint i;
gint new_offers, int_offers;
for(i=jobs->len - 1; i >= 0; i--)
{
g_array_index(jobs, Job, i).time--;
if(g_array_index(jobs, Job, i).time <= 0)
job_remove(&g_array_index(jobs, Job, i), TRUE);
}
if(week % const_int("int_job_update_interval") != 2)
return;
new_offers = math_rndi(const_int("int_job_new_offers_lower"),
const_int("int_job_new_offers_upper"));
int_offers = (users->len == 1) ?
(gint)rint((gfloat)new_offers *
const_float("float_job_international_perc")) : 0;
for(i=0;i<new_offers - int_offers;i++)
job_add_new_national();
job_add_new_international(int_offers);
}
/** Add some new international job offers to the job exchange. */
void
job_add_new_international(gint num_of_new)
{
gint i, k, rndom, idx;
GPtrArray *country_files = file_get_country_files();
Country countries[num_of_new];
Team *tm = NULL;
League *league = NULL;
gint team_id = -1;
Job new_job;
k = 0;
for(i=0;i<num_of_new;i++)
{
countries[k].leagues = countries[k].cups = NULL;
countries[k].allcups = NULL;
countries[k].name = countries[k].symbol =
countries[k].sid = NULL;
do
rndom = math_rndi(0, country_files->len - 1);
while(g_strrstr((gchar*)g_ptr_array_index(country_files, rndom),
country.sid));
idx = job_country_is_in_list(
(gchar*)g_ptr_array_index(country_files, rndom),
countries, num_of_new);
if(idx == -1)
{
idx = k;
xml_country_read((gchar*)g_ptr_array_index(country_files, rndom),
&countries[k]);
counters[COUNT_LEAGUE_ID] -= countries[k].leagues->len;
k++;
}
job_pick_team_from_country(&countries[idx], &tm, &league);
new_job.country_file =
g_strdup_printf("country_%s.xml", countries[idx].sid);
new_job.time = math_rndi(const_int("int_job_update_interval") - 1,
const_int("int_job_update_interval") + 1);
new_job.country_name = g_strdup(countries[idx].name);
new_job.country_rating = countries[idx].rating;
new_job.league_name = g_strdup(league->name);
new_job.league_layer = league->layer;
team_id = job_team_is_in_cup(tm->name);
if(team_id == -1)
{
team_generate_players_stadium(tm, league->average_talent);
g_array_append_val(job_teams, *tm);
new_job.team_id = tm->id;
new_job.type = JOB_TYPE_INTERNATIONAL;
}
else
{
new_job.team_id = team_id;
new_job.type = JOB_TYPE_CUP;
}
new_job.talent_percent =
(gint)rint((team_get_average_talent(tm) /
league->average_talent) * 100);
g_array_append_val(jobs, new_job);
}
free_gchar_array(&country_files);
}
/** Find out whether the country file is already loaded and part
of the country array.
@param len The length of the array. */
gint
job_country_is_in_list(const gchar *country_file,
const Country *countries, gint len)
{
gint i;
for(i=0;i<len;i++)
{
if(countries[i].sid == NULL)
return -1;
else if(g_strrstr(country_file, countries[i].sid))
return i;
}
return -1;
}
/** Add a new national job offer to the job exchange. */
void
job_add_new_national(void)
{
Job new_job;
League *league = NULL;
Team *tm = NULL;
job_pick_team_from_country(&country, &tm, &league);
new_job.type = JOB_TYPE_NATIONAL;
new_job.time = math_rndi(const_int("int_job_update_interval") - 1,
const_int("int_job_update_interval") + 1);
new_job.country_file = NULL;
new_job.country_name = country.name;
new_job.country_rating = -1;
new_job.league_name = league->name;
new_job.league_layer = league->layer;
new_job.talent_percent =
(gint)rint((team_get_average_talent(tm) /
league->average_talent) * 100);
new_job.team_id = tm->id;
g_array_append_val(jobs, new_job);
}
void
job_pick_team_from_country(const Country *cntry, Team **tm, League **league)
{
gint i, rndom;
gint team_lens[cntry->leagues->len];
team_lens[0] = g_array_index(cntry->leagues, League, 0).teams->len;
for(i=1;i<cntry->leagues->len;i++)
team_lens[i] = team_lens[i - 1] +
g_array_index(cntry->leagues, League, i).teams->len;
do
{
rndom = math_rndi(0, team_lens[cntry->leagues->len - 1] - 1);
for(i=0;i<cntry->leagues->len;i++)
if(rndom < team_lens[i])
{
*tm = (i > 0) ?
&g_array_index(g_array_index(
cntry->leagues, League, i).teams,
Team, rndom - team_lens[i - 1]) :
&g_array_index(g_array_index(
cntry->leagues, League, i).teams,
Team, rndom);
*league = &g_array_index(cntry->leagues, League, i);
break;
}
}
while(team_is_user(*tm) != -1 ||
job_team_is_on_list((*tm)->id) != -1);
}
/** Find out whether the team with given id is already on the
job exchange list.
@return The index in the jobs array if the team is on the list or -1. */
gint
job_team_is_on_list(gint team_id)
{
gint i;
for(i=0;i<jobs->len;i++)
if(g_array_index(jobs, Job, i).team_id == team_id)
return i;
return -1;
}
/** Find out whether the team with given name is participating
in an international cup (and thus doesn't have to be generated).
@return The id of the team if found or -1. */
gint
job_team_is_in_cup(const gchar *team_name)
{
gint i, j;
for(i=0;i<acps->len;i++)
for(j=0;j<acp(i)->teams->len;j++)
if(strcmp(team_name,
((Team*)g_ptr_array_index(acp(i)->teams, j))->name) == 0)
return ((Team*)g_ptr_array_index(acp(i)->teams, j))->id;
return -1;
}
/** Find the team going with the job offer. */
Team*
job_get_team(const Job *job)
{
gint i, j;
if(job->type == JOB_TYPE_NATIONAL)
return team_of_id(job->team_id);
else if(job->type == JOB_TYPE_INTERNATIONAL)
{
for(i=0;i<job_teams->len;i++)
if(g_array_index(job_teams, Team, i).id == job->team_id)
return &g_array_index(job_teams, Team, i);
}
else
{
for(i=0;i<acps->len;i++)
for(j=0;j<acp(i)->teams->len;j++)
if(((Team*)g_ptr_array_index(acp(i)->teams, j))->id ==
job->team_id)
return (Team*)g_ptr_array_index(acp(i)->teams, j);
}
main_exit_program(EXIT_POINTER_NOT_FOUND,
"job_get_team: team not found (league %s, country %s.",
job->league_name, job->country_name);
return NULL;
}
/** Find out whether the user's application for the job gets
accepted. */
gboolean
query_job_application_successful(const Job *job, const User *user)
{
gfloat success_needed;
const Team *tm = job_get_team(job);
gfloat user_av_skill = team_get_average_skill(user->tm, FALSE),
job_av_skill = team_get_average_skill(tm, FALSE);
success_needed = (job_av_skill - user_av_skill) *
(gfloat)const_int("int_job_application_points_per_av_skill");
success_needed +=
((gfloat)(job->league_layer - league_from_clid(user->tm->clid)->layer) *
(gfloat)const_int("int_job_application_points_per_layer"));
if(job->type != JOB_TYPE_NATIONAL)
{
success_needed +=
(gfloat)const_int("int_job_application_points_international");
success_needed +=
((gfloat)(job->country_rating - country.rating) *
(gfloat)const_int("int_job_application_points_per_rating"));
}
return (user->counters[COUNT_USER_SUCCESS] >= success_needed);
}
/** Remove a job from the jobs array.
@param free Whether to free memory occupied by the job
and its team. */
void
job_remove(Job *job, gboolean free_tm)
{
gint i;
for(i=0;i<jobs->len;i++)
if(&g_array_index(jobs, Job, i) == job)
{
free_job(job, free_tm);
g_array_remove_index(jobs, i);
break;
}
}
/** Change the game so that the country is
used that's specified in the job. */
void
job_change_country(Job *job)
{
gint i, j, k;
Team tm = *(job_get_team(job));
gint season_temp = season + 1;
for(i=transfer_list->len - 1;i>=0;i--)
transfer_remove_player(i);
free_bets(TRUE);
/* There's only one user (otherwise
international job offers are disabled). */
for(i=0;i<2;i++)
{
g_array_free(usr(0).bets[i], TRUE);
usr(0).bets[i] = g_array_new(FALSE, FALSE, sizeof(BetUser));
}
live_game_reset(&usr(0).live_game, NULL, FALSE);
free_country(&country, TRUE);
xml_country_read(job->country_file, &country);
stat5 = STATUS_GENERATE_TEAMS;
for(i=0;i<ligs->len;i++)
for(j=0;j<lig(i).teams->len;j++)
if(strcmp(g_array_index(lig(i).teams, Team, j).name,
tm.name) != 0)
team_generate_players_stadium(&g_array_index(lig(i).teams, Team, j), 0);
else
{
tm.id = g_array_index(lig(i).teams, Team, j).id;
tm.clid = g_array_index(lig(i).teams, Team, j).clid;
job->team_id = tm.id;
free_team(&g_array_index(lig(i).teams, Team, j));
g_array_index(lig(i).teams, Team, j) = tm;
for(k=0;k<g_array_index(lig(i).teams, Team, j).players->len;k++)
g_array_index(g_array_index(lig(i).teams, Team, j).players,
Player, k).team =
&g_array_index(lig(i).teams, Team, j);
}
stat5 = -1;
/* Set season to 1 so that some special things
in the start_new_season function don't get applied. */
season = 1;
start_new_season();
season = season_temp;
}

View File

@ -0,0 +1,70 @@
/*
job.h
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef JOB_H
#define JOB_H
#include "bygfoot.h"
#include "job_struct.h"
#include "league_struct.h"
#include "team_struct.h"
#include "user_struct.h"
void
job_update(void);
void
job_add_new_international(gint num_of_new);
gint
job_country_is_in_list(const gchar *country_file,
const Country *countries, gint len);
void
job_add_new_national(void);
gint
job_team_is_on_list(gint team_id);
Team*
job_get_team(const Job *job);
gboolean
query_job_application_successful(const Job *job, const User *user);
void
job_remove(Job *job, gboolean free_tm);
void
job_pick_team_from_country(const Country *cntry, Team **tm, League **league);
gint
job_team_is_in_cup(const gchar *team_name);
void
job_change_country(Job *job);
#endif

View File

@ -0,0 +1,64 @@
/*
job_struct.h
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef JOB_STRUCT_H
#define JOB_STRUCT_H
/** Enumeration describing the type of a job. */
enum
{
/** Job offer by a team from the country
the user's playing. */
JOB_TYPE_NATIONAL = 0,
/** Job offer by a team from a different country
than user's playing. */
JOB_TYPE_INTERNATIONAL,
/** Job offer by a team from a different country
than user's playing; the team participates
in an international cup. */
JOB_TYPE_CUP,
JOB_TYPE_END
};
/** A structure representing a job in the job exchange. */
typedef struct
{
/** Whether it's an international job or a national one. */
gint type;
/** How many weeks remaining the offer is on the list. */
gint time;
/** Only relevant for international jobs. **/
gchar *country_file, *country_name, *league_name;
/** Only relevant for international jobs. **/
gint league_layer;
/** Only relevant for international jobs. **/
gint country_rating;
/** Average talent compared to the league average in percent. */
gint talent_percent;
/** The id of the team the job describes. */
gint team_id;
} Job;
#endif

View File

@ -0,0 +1,234 @@
/*
language.c
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <locale.h>
#include "callbacks.h"
#include "free.h"
#include "language.h"
#include "lg_commentary.h"
#include "misc.h"
#include "option.h"
#include "variables.h"
#include "window.h"
#ifndef G_OS_UNIX
extern int _nl_msg_cat_cntr=0;
#endif
/** Set the game language to the specified one. */
void
language_set(gint index)
{
gchar buf[SMALL], buf2[SMALL];
gchar *pwd = g_get_current_dir();
GPtrArray *codes =
misc_separate_strings(const_str("string_language_codes"));
if(index > 0)
strcpy(buf, (gchar*)g_ptr_array_index(codes, index - 1));
else
strcpy(buf, "");
if(strcmp(buf, opt_str("string_opt_language_code")) != 0 ||
window.main == NULL)
{
#ifdef ENABLE_NLS
sprintf(buf2, "%s%slocale", pwd, G_DIR_SEPARATOR_S);
g_free(pwd);
if(g_file_test(buf2, G_FILE_TEST_EXISTS))
{
bindtextdomain (GETTEXT_PACKAGE, buf2);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
}
#endif
g_setenv ("LANGUAGE", buf, TRUE);
opt_set_str("string_opt_language_code", buf);
{
extern int _nl_msg_cat_cntr;
++_nl_msg_cat_cntr;
}
if(window.main != NULL)
{
window_destroy(&window.main);
window_create(WINDOW_MAIN);
on_button_back_to_main_clicked(NULL, NULL);
}
}
lg_commentary_load_commentary_file_from_option();
free_gchar_array(&codes);
}
/** Get the index of the given code in the codes
array. */
gint
language_get_code_index(const gchar *code)
{
gint i, return_value = -1;
GPtrArray *codes =
misc_separate_strings(const_str("string_language_codes"));
gchar local_code[SMALL];
strcpy(local_code, code);
if(strcmp(code, "en") == 0)
strcpy(local_code, "C");
for(i=0;i<codes->len;i++)
if(strcmp(local_code, (gchar*)g_ptr_array_index(codes, i)) == 0)
{
return_value = i;
break;
}
free_gchar_array(&codes);
return return_value;
}
/** Compare country file names based on a preferred one (which
should get moved to the start). */
gint
language_compare_country_files(gconstpointer a, gconstpointer b, gpointer data)
{
gint i, j;
const gchar *prefdef = (const gchar*)data;
const gchar *def1 = *(const gchar**)a;
const gchar *def2 = *(const gchar**)b;
gint len1 = strlen(def1),
len2 = strlen(def2), lenmin = MIN(len1, len2);
gchar alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
gint return_value = 0;
if(strcmp(def1, def2) == 0)
return_value = 0;
else if(prefdef != NULL && strcmp(prefdef, def1) == 0)
return_value = -1;
else if(prefdef != NULL && strcmp(prefdef, def2) == 0)
return_value = 1;
else
{
for(i=0;i<lenmin;i++)
if(def1[i] != def2[i])
break;
if(i == lenmin)
return_value = (len2 < len1);
else
{
for(j=0;j<26;j++)
if(def1[i] == alphabet[j] ||
def2[i] == alphabet[j])
break;
if(j == 26)
{
g_warning("language_compare_country_files: chars %c and %c not comparable",
def1[i], def2[i]);
return_value = 0;
}
else
return_value = (def1[i] == alphabet[j]) ? -1 : 1;
}
}
return return_value;
}
/** Put the country matching the local language to the
beginning of the array if possible. */
void
language_pick_country(GPtrArray *country_files)
{
gint i, j;
GPtrArray *codes =
misc_separate_strings(const_str("string_language_codes"));
GPtrArray *defs =
misc_separate_strings(const_str("string_language_defs"));
gpointer prefdef = NULL;
const gchar *lang = g_getenv("LANG");
if(lang == NULL)
lang = g_getenv("LC_ALL");
if(lang != NULL)
for(i=0;i<codes->len;i++)
{
if(((g_str_has_prefix(lang, "en") &&
strcmp((gchar*)g_ptr_array_index(codes, i), "C") == 0) ||
g_str_has_prefix(lang, (gchar*)g_ptr_array_index(codes, i))) &&
strcmp((gchar*)g_ptr_array_index(defs, i), "NONE") != 0)
for(j=0;j<country_files->len;j++)
if(strcmp((gchar*)g_ptr_array_index(country_files, j),
(gchar*)g_ptr_array_index(defs, i)) == 0)
{
prefdef = g_ptr_array_index(country_files, j);
break;
}
if(prefdef != NULL)
break;
}
g_ptr_array_sort_with_data(
country_files,
(GCompareDataFunc)language_compare_country_files,
prefdef);
free_gchar_array(&codes);
free_gchar_array(&defs);
}
/** Find out which language to use (e.g. for live game commentary).
Write the code (en, de etc.) into the buffer. */
void
language_get_code(gchar *buf)
{
gchar *cur_locale = NULL;
#ifdef G_OS_UNIX
cur_locale = setlocale(LC_MESSAGES, NULL);
#else
cur_locale = g_win32_getlocale ();
#endif
if(strcmp(opt_str("string_opt_language_code"), "C") == 0)
strcpy(buf, "en");
else if(strcmp(opt_str("string_opt_language_code"), "") == 0 &&
cur_locale != NULL)
{
strncpy(buf, cur_locale, 2);
buf[2] = '\0';
}
else
strcpy(buf, opt_str("string_opt_language_code"));
}

View File

@ -0,0 +1,55 @@
/*
language.h
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef LANGUAGE_H
#define LANGUAGE_H
#include "bygfoot.h"
#include "option.h"
#include <locale.h>
#define language_get_current_index() (strlen(opt_str("string_opt_language_code")) > 0) ? language_get_code_index(opt_str("string_opt_language_code")) : -1
gint
language_get_code_index(const gchar *code);
void
language_set(gint index);
gint
language_compare_country_files(gconstpointer a, gconstpointer b, gpointer data);
void
language_pick_country(GPtrArray *country_files);
void
language_get_code(gchar *buf);
/* #ifndef G_OS_UNIX */
/* extern int _nl_msg_cat_cntr; */
/* #endif */
#endif

View File

@ -0,0 +1,854 @@
/*
league.c
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "cup.h"
#include "free.h"
#include "league.h"
#include "main.h"
#include "maths.h"
#include "misc.h"
#include "option.h"
#include "player.h"
#include "stat.h"
#include "table.h"
#include "team.h"
#include "user.h"
#include "variables.h"
/**
Create a new league with some default values.
@return The league we created.
@see League
*/
League
league_new(gboolean new_id)
{
League new;
new.name = NULL;
new.names_file = g_strdup(opt_str("string_opt_player_names_file"));
new.sid = NULL;
new.short_name = NULL;
new.symbol = NULL;
new.id = (new_id) ? league_id_new : -1;
new.layer = -1;
new.rr_break = 1;
new.average_talent = 0;
new.prom_rel.prom_games_dest_sid = NULL;
new.prom_rel.prom_games_loser_sid = NULL;
new.prom_rel.prom_games_cup_sid = NULL;
new.prom_rel.prom_games_number_of_advance = 1;
new.prom_rel.elements = g_array_new(FALSE, FALSE, sizeof(PromRelElement));
new.teams = g_array_new(FALSE, FALSE, sizeof(Team));
new.fixtures = g_array_new(FALSE, FALSE, sizeof(Fixture));
new.table = table_new();
new.table.clid = new.id;
new.first_week = new.week_gap = 1;
new.round_robins = 2;
new.yellow_red = 1000;
new.stats = stat_league_new("", "");
new.active = TRUE;
return new;
}
/**
Create a new PromRelElement with default values.
@return The PromRelElement we created.
@see PromRelElement
*/
PromRelElement
prom_rel_element_new(void)
{
PromRelElement new;
new.ranks[0] = new.ranks[1] = 0;
new.dest_sid = NULL;
new.type = PROM_REL_NONE;
return new;
}
/** Get the array index of the given league or cup id.
@param clid The id of the league or cup.
@return The index in the leagues or cups array. */
gint
league_cup_get_index_from_clid(gint clid)
{
gint i;
gint index = -1;
if(clid < ID_CUP_START)
{
for(i=0;i<ligs->len;i++)
if(lig(i).id == clid)
{
index = i;
break;
}
}
else
for(i=0;i<cps->len;i++)
if(cp(i).id == clid)
{
index = i;
break;
}
if(index == -1)
main_exit_program(EXIT_POINTER_NOT_FOUND,
"league_cup_get_index_from_clid: couldn't find league or cup with id %d\n",
clid);
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);
main_exit_program(EXIT_POINTER_NOT_FOUND,
"league_from_clid: didn't find league with id %d\n",
clid);
return NULL;
}
/** Return the id of the next league (or cup if we are
at the end of the leagues array).
@param clid The id of the current league or cup.
@param count_inactive Whether inactive leagues count. */
gint
league_cup_get_next_clid(gint clid, gboolean count_inactive)
{
gint i, return_value = -1;
if(clid < ID_CUP_START)
{
for(i=0;i<ligs->len;i++)
if(lig(i).id == clid)
break;
if(i != ligs->len - 1)
{
if(lig(i + 1).active || count_inactive)
return_value = lig(i + 1).id;
else
return_value = league_cup_get_next_clid(lig(i + 1).id, count_inactive);
}
else if(acps->len > 0)
return_value = acp(0)->id;
else
{
if(lig(0).active || count_inactive)
return_value = lig(0).id;
else
return_value = league_cup_get_next_clid(lig(0).id, count_inactive);
}
}
else
{
for(i=0;i<acps->len;i++)
if(acp(i)->id == clid)
break;
if(i != acps->len - 1)
return_value = acp(i + 1)->id;
else
{
if(lig(0).active || count_inactive)
return_value = lig(0).id;
else
return_value = league_cup_get_next_clid(lig(0).id, count_inactive);
}
}
return return_value;
}
/** Return the id of the previous league or cup.
@param clid The id of the current league or cup.
@param count_inactive Whether inactive leagues count. */
gint
league_cup_get_previous_clid(gint clid, gboolean count_inactive)
{
gint i, return_value = -1;
if(clid < ID_CUP_START)
{
for(i=ligs->len - 1;i>=0;i--)
if(lig(i).id == clid)
break;
if(i != 0)
{
if(lig(i - 1).active || count_inactive)
return_value = lig(i - 1).id;
else
return_value = league_cup_get_previous_clid(lig(i - 1).id, count_inactive);
}
else if(acps->len > 0)
return_value = acp(acps->len - 1)->id;
else
{
if(lig(ligs->len - 1).active || count_inactive)
return_value = lig(ligs->len - 1).id;
else
return_value = league_cup_get_previous_clid(lig(ligs->len - 1).id, count_inactive);
}
}
else
{
for(i=acps->len - 1;i>=0;i--)
if(acp(i)->id == clid)
break;
if(i != 0)
return_value = acp(i - 1)->id;
else
{
if(lig(ligs->len - 1).active || count_inactive)
return_value = lig(ligs->len - 1).id;
else
return_value = league_cup_get_previous_clid(lig(ligs->len - 1).id, count_inactive);
}
}
return return_value;
}
/** Return the fixture coming after the specified week and round.
@param league The league the fixtures of which we examine.
@return A fixture pointer or NULL. */
Fixture*
league_cup_get_next_fixture(gint clid, gint week_number, gint week_round_number)
{
gint i;
GArray *fixtures = league_cup_get_fixtures(clid);
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_number == week_number &&
g_array_index(fixtures, Fixture, i).week_round_number >= week_round_number))
return &g_array_index(fixtures, Fixture, i);
return NULL;
}
/** Return the fixture coming just before the specified week and round.
@param league The league the fixtures of which we examine.
@return A fixture pointer or NULL. */
Fixture*
league_cup_get_previous_fixture(gint clid, gint week_number, gint week_round_number)
{
gint i;
GArray *fixtures = league_cup_get_fixtures(clid);
for(i=fixtures->len - 1;i>=0;i--)
if(g_array_index(fixtures, Fixture, i).week_number < week_number ||
(g_array_index(fixtures, Fixture, i).week_number == week_number &&
g_array_index(fixtures, Fixture, i).week_round_number < week_round_number))
return &g_array_index(fixtures, Fixture, i);
return NULL;
}
/** Return the average stadium capacity of cpu teams
in the specified league or cup. */
gint
league_cup_average_capacity(gint clid)
{
gint i, cnt = 0;
gfloat sum = 0;
const GArray *teams = NULL;
const GPtrArray *teamsp = NULL;
if(clid < ID_CUP_START)
{
teams = (GArray*)league_cup_get_teams(clid);
for(i=0;i<teams->len;i++)
if(team_is_user(&g_array_index(teams, Team, i)) == -1)
{
sum += g_array_index(teams, Team, i).stadium.capacity;
cnt++;
}
}
else
{
teamsp = (GPtrArray*)league_cup_get_teams(clid);
for(i=0;i<teamsp->len;i++)
if(team_is_user((Team*)g_ptr_array_index(teamsp, i)) == -1)
{
sum += ((Team*)g_ptr_array_index(teamsp, i))->stadium.capacity;
cnt++;
}
}
return sum / (gfloat)cnt;
}
/** Get the index of the league with the specified string id. */
gint
league_index_from_sid(const gchar *sid)
{
gint i;
for(i=0;i<ligs->len;i++)
if(strcmp(lig(i).sid, sid) == 0)
return i;
main_exit_program(EXIT_INT_NOT_FOUND,
"league_index_from_sid: no index found for sid '%s'.\n", sid);
return -1;
}
/** Remove the team with the specified id from the teams
array without freeing the memory (used in promotion/relegation). */
void
league_remove_team_with_id(League *league, gint id)
{
gint i;
for(i=0;i<league->teams->len;i++)
if(g_array_index(league->teams, Team, i).id == id)
{
g_array_remove_index(league->teams, i);
return;
}
g_warning("league_remove_team_with_id: team with id %d in league %s not found\n",
id, league->name);
}
/** Nullify league stuff at the beginning of a season. */
void
league_season_start(League *league)
{
gint i, j;
gint idx = league_index_from_sid(league->sid);
gboolean user_champ =
(team_is_user(
team_of_id(
g_array_index(lig(0).table.elements, TableElement, 0).team_id)) != -1);
gboolean league_above_talent =
(team_get_average_talents(league->teams) > league->average_talent *
const_float("float_season_end_league_above_talent_factor") && !user_champ);
gboolean team_is_top = FALSE;
Team *tm = NULL;
gfloat team_change_lower =
const_float("float_season_end_team_change_lower"),
user_champ_addition =
const_float("float_season_end_user_champ_addition"),
user_champ_best_teams_addition =
const_float("float_season_end_user_champ_best_teams_addition"),
team_change_upper =
const_float("float_season_end_team_change_upper");
gint user_champ_best_teams_limit =
const_int("int_season_end_user_champ_best_teams_limit");
gfloat team_change_factor = 0;
if(user_champ)
{
tm = team_of_id(
g_array_index(lig(0).table.elements, TableElement, 0).team_id);
tm->luck = MAX(tm->luck * const_float("float_season_end_user_champ_luck_factor"),
const_float("float_luck_limit"));
}
else
for(i=0;i<users->len;i++)
if(usr(i).tm->luck < 1)
usr(i).tm->luck =
MIN(usr(i).tm->luck * const_float("float_season_end_user_champ_luck_factor_regen"), 1);
for(i=0;i<league->table.elements->len;i++)
{
g_array_index(league->table.elements, TableElement, i).team =
&g_array_index(league->teams, Team, i);
g_array_index(league->table.elements, TableElement, i).team_id =
g_array_index(league->teams, Team, i).id;
g_array_index(league->table.elements, TableElement, i).old_rank = i;
for(j=0;j<TABLE_END;j++)
g_array_index(league->table.elements, TableElement, i).values[j] = 0;
}
/*d*/
/* if(league == &lig(0)) */
/* printf("league %s av %.2f ab %d\n", league->name, */
/* team_get_average_talents(league->teams), league_above_talent); */
for(i=0;i<league->teams->len;i++)
{
team_is_top =
(team_get_league_rank(&g_array_index(league->teams, Team, i)) <=
user_champ_best_teams_limit && idx == 0 && user_champ);
team_change_factor =
(team_is_user(&g_array_index(league->teams, Team, i)) == -1) *
math_rnd(team_change_lower + user_champ * user_champ_addition +
team_is_top * user_champ_best_teams_addition -
league_above_talent * (user_champ_addition / 2),
team_change_upper + user_champ * user_champ_addition +
team_is_top * user_champ_best_teams_addition -
league_above_talent * (user_champ_addition / 2));
for(j=0;j<g_array_index(league->teams, Team, i).players->len;j++)
player_season_start(
&g_array_index(
g_array_index(
league->teams, Team, i).players, Player, j), team_change_factor);
g_array_index(league->teams, Team, i).stadium.average_attendance =
g_array_index(league->teams, Team, i).stadium.games =
g_array_index(league->teams, Team, i).stadium.possible_attendance = 0;
}
/* if(league == &lig(0)) */
/* printf("2 league %s av %.2f\n", league->name, */
/* team_get_average_talents(league->teams)); */
}
/** Find out whether the team with specified rank in the league
would participate in promotion games were the season to end. */
gboolean
query_league_rank_in_prom_games(const League *league, gint rank)
{
gint i, j, k;
const Cup *cup = NULL;
const CupRound *cup_round = NULL;
for(i=0;i<ligs->len;i++)
if(query_league_has_prom_games((&lig(i))))
{
cup = cup_from_sid(lig(i).prom_rel.prom_games_cup_sid);
for(k=0;k<cup->rounds->len;k++)
{
cup_round = &g_array_index(cup->rounds, CupRound, k);
for(j=0;j<cup_round->choose_teams->len;j++)
{
if(strcmp(g_array_index(cup_round->choose_teams, CupChooseTeam, j).sid,
league->sid) == 0 &&
((rank >= g_array_index(cup_round->choose_teams,
CupChooseTeam, j).start_idx &&
rank <= g_array_index(cup_round->choose_teams,
CupChooseTeam, j).end_idx &&
g_array_index(cup_round->choose_teams,
CupChooseTeam, j).randomly) ||
(rank >= g_array_index(cup_round->choose_teams,
CupChooseTeam, j).start_idx &&
rank < g_array_index(cup_round->choose_teams,
CupChooseTeam, j).start_idx +
g_array_index(cup_round->choose_teams,
CupChooseTeam, j).number_of_teams &&
!g_array_index(cup_round->choose_teams,
CupChooseTeam, j).randomly)))
return TRUE;
}
}
}
return FALSE;
}
/** Find out whether there are/were league matches. */
gboolean
query_league_matches_in_week(const League *league, gint week_number)
{
gint i;
for(i=0;i<league->fixtures->len;i++)
if(g_array_index(league->fixtures, Fixture, i).week_number == week_number)
return TRUE;
return FALSE;
}
/** Add the teams to promote/relegate (from the prom_rel elements)
from the league to the array. */
void
league_get_team_movements_prom_rel(const League *league, GArray *team_movements)
{
gint i, j, k;
TeamMove new_move;
const GArray *elements = league->prom_rel.elements;
GArray *dest_idcs = NULL;
GPtrArray *dest_sids = NULL;
for(i=0;i<elements->len;i++)
{
dest_sids = misc_separate_strings(
g_array_index(elements, PromRelElement, i).dest_sid);
gint dest_idcs_int[dest_sids->len];
gint dest_idcs_order[dest_sids->len];
for(j=0;j<dest_sids->len;j++)
dest_idcs_int[j] =
league_index_from_sid((gchar*)g_ptr_array_index(dest_sids, j));
for(j=g_array_index(elements, PromRelElement, i).ranks[0];
j<=g_array_index(elements, PromRelElement, i).ranks[1]; j++)
{
dest_idcs = g_array_new(FALSE, FALSE, sizeof(gint));
math_generate_permutation(dest_idcs_order, 0, dest_sids->len - 1);
for(k=0;k<dest_sids->len;k++)
g_array_append_val(dest_idcs, dest_idcs_int[dest_idcs_order[k]]);
new_move.tm = *(g_array_index(league->table.elements, TableElement, j - 1).team);
new_move.prom_rel_type = g_array_index(elements, PromRelElement, i).type;
new_move.dest_idcs = dest_idcs;
new_move.dest_assigned = FALSE;
g_array_append_val(team_movements, new_move);
}
free_gchar_array(&dest_sids);
}
}
/** Add the team movements from the promotion games
to the array. */
void
league_get_team_movements_prom_games(const League *league, GArray *team_movements,
const GPtrArray *prom_games_teams, gboolean up)
{
gint i, j;
TeamMove new_move;
GPtrArray *dest_sids = (up) ?
misc_separate_strings(league->prom_rel.prom_games_dest_sid) :
misc_separate_strings(league->prom_rel.prom_games_loser_sid);
GArray *dest_idcs = NULL;
gint dest_idcs_int[dest_sids->len];
gint dest_idcs_order[dest_sids->len];
gint start_idx = 0,
end_idx = league->prom_rel.prom_games_number_of_advance;
gint prom_type = PROM_REL_PROMOTION;
if(!up)
{
start_idx = league->prom_rel.prom_games_number_of_advance;
end_idx = prom_games_teams->len;
prom_type = PROM_REL_RELEGATION;
}
for(i=0;i<dest_sids->len;i++)
dest_idcs_int[i] =
league_index_from_sid((gchar*)g_ptr_array_index(dest_sids, i));
for(i=start_idx;i<end_idx;i++)
{
dest_idcs = g_array_new(FALSE, FALSE, sizeof(gint));
math_generate_permutation(dest_idcs_order, 0, dest_sids->len - 1);
for(j=0;j<dest_sids->len;j++)
g_array_append_val(dest_idcs, dest_idcs_int[dest_idcs_order[j]]);
new_move.tm = *((Team*)g_ptr_array_index(prom_games_teams, i));
new_move.prom_rel_type = prom_type;
new_move.dest_idcs = dest_idcs;
new_move.dest_assigned = FALSE;
g_array_append_val(team_movements, new_move);
}
free_gchar_array(&dest_sids);
}
/** Add the teams to promote/relegate from the league to the array
and remove them from the leagues. */
void
league_get_team_movements(League *league, GArray *team_movements)
{
GPtrArray *prom_games_teams = NULL;
const Cup *prom_cup = NULL;
league_get_team_movements_prom_rel(league, team_movements);
if(query_league_has_prom_games(league))
{
prom_cup = cup_from_sid(league->prom_rel.prom_games_cup_sid);
if(prom_cup == NULL)
{
g_warning("league_get_team_movements: promotion games cup not found for league %s (cup sid %s).\n",
league->name, league->prom_rel.prom_games_cup_sid);
return;
}
prom_games_teams = cup_get_teams_sorted(prom_cup);
league_get_team_movements_prom_games(league, team_movements, prom_games_teams, TRUE);
if(league->prom_rel.prom_games_loser_sid != NULL)
league_get_team_movements_prom_games(league, team_movements,
prom_games_teams, FALSE);
g_ptr_array_free(prom_games_teams, TRUE);
}
g_array_sort_with_data(league->teams, team_compare_func,
GINT_TO_POINTER(TEAM_COMPARE_LEAGUE_RANK + 100));
}
/** Find out whether there are unassigned TeamMoves in the array. */
gboolean
query_league_team_movements_unassigned(const GArray *team_movements)
{
gint i;
for(i=0;i<team_movements->len;i++)
if(!g_array_index(team_movements, TeamMove, i).dest_assigned)
return TRUE;
return FALSE;
}
/** Find out whether there are unassigned team moves with a single
destination value. */
gboolean
query_league_team_movements_unassigned_single(const GArray *team_movements)
{
gint i;
for(i=0;i<team_movements->len;i++)
if(!g_array_index(team_movements, TeamMove, i).dest_assigned &&
g_array_index(team_movements, TeamMove, i).dest_idcs->len == 1)
return TRUE;
return FALSE;
}
/** Print out the movements to the console (debug function). */
void
league_team_movements_print(const GArray *team_movements,
const gint *league_size, const gint *league_cur_size)
{
gint i, j;
const TeamMove *tmove = NULL;
g_print("%-25s Dest \t\t Possible\n\n", "Team");
for(i=0;i<team_movements->len;i++)
{
tmove = &g_array_index(team_movements, TeamMove, i);
if(tmove->dest_assigned)
g_print("%-25s (%d) %s \t\t", tmove->tm.name,
league_from_clid(tmove->tm.clid)->layer,
lig(g_array_index(tmove->dest_idcs, gint, 0)).name);
else
g_print("%-25s (%d) UNASSIGNED \t\t", tmove->tm.name,
league_from_clid(tmove->tm.clid)->layer);
for(j=0;j<tmove->dest_idcs->len;j++)
g_print("%d ", g_array_index(tmove->dest_idcs, gint, j));
g_print("\n");
}
g_print("%-20s Size Cursize\n", "League");
for(i=0;i<ligs->len;i++)
g_print("%-20s %d %d\n", lig(i).name, league_size[i],
league_cur_size[i]);
}
/** Compare two leagues when doing promotion/relegation. The league
that has fewer teams is preferred. */
gint
league_team_movements_compare_dest_idcs(gconstpointer a, gconstpointer b,
gpointer data)
{
gint league_idx1 = *(gint*)a,
league_idx2 = *(gint*)b;
const gint *league_cur_size = (const gint*)data;
if(league_cur_size[league_idx1] < league_cur_size[league_idx2])
return -1;
else if(league_cur_size[league_idx1] > league_cur_size[league_idx2])
return 1;
return 0;
}
/** Assign a random destination for the team move with given index
and remove the destination from all other unassigned moves if
the dest league is full. */
void
league_team_movements_assign_dest(GArray *team_movements, gint idx,
const gint *league_size, gint *league_cur_size)
{
gint i, j, dest_idx;
TeamMove *tmove = &g_array_index(team_movements, TeamMove, idx);
if(debug > 60)
g_print("league_team_movements_assign_dest %s\n", tmove->tm.name);
if(tmove->dest_idcs->len == 1)
dest_idx = g_array_index(tmove->dest_idcs, gint, 0);
else
{
g_array_sort_with_data(tmove->dest_idcs,
(GCompareDataFunc)league_team_movements_compare_dest_idcs,
(gpointer)league_cur_size);
dest_idx = g_array_index(tmove->dest_idcs, gint, 0);
}
league_cur_size[dest_idx]++;
if(league_cur_size[dest_idx] > league_size[dest_idx])
main_exit_program(EXIT_PROM_REL,
"league_team_movements_assign_dest: no room in league %s for team %s.",
lig(dest_idx).name, tmove->tm.name);
tmove->dest_assigned = TRUE;
if(debug > 60)
g_print("%s %d -> %d\n", tmove->tm.name,
league_from_clid(tmove->tm.clid)->layer,
league_from_clid(lig(dest_idx).id)->layer);
if(league_cur_size[dest_idx] == league_size[dest_idx])
for(i=0;i<team_movements->len;i++)
{
if(!g_array_index(team_movements, TeamMove, i).dest_assigned)
{
tmove = &g_array_index(team_movements, TeamMove, i);
for(j=tmove->dest_idcs->len - 1; j>= 0; j--)
if(g_array_index(tmove->dest_idcs, gint, j) == dest_idx)
g_array_remove_index(tmove->dest_idcs, j);
if(tmove->dest_idcs->len == 0)
main_exit_program(EXIT_PROM_REL,
"league_team_movements_assign_dest: no destinations left for team %s.",
tmove->tm.name);
}
}
if(team_is_user(&tmove->tm) != -1)
{
if(tmove->prom_rel_type == PROM_REL_PROMOTION)
user_history_add(&usr(team_is_user(&tmove->tm)),
USER_HISTORY_PROMOTED, tmove->tm.name,
lig(g_array_index(tmove->dest_idcs, gint, 0)).name,
NULL, NULL);
else
user_history_add(&usr(team_is_user(&tmove->tm)),
USER_HISTORY_RELEGATED, tmove->tm.name,
lig(g_array_index(tmove->dest_idcs, gint, 0)).name,
NULL, NULL);
}
}
/** Assign all unassigned TeamMoves in the array that only have one
destination value.
@param league_size The size of all leagues (i.e. how many teams they
should contain after promotion/relegation is finished).
@param league_cur_size The current size of all leagues (taking into
account the assigned team moves). */
void
league_team_movements_prune(GArray *team_movements, const gint *league_size,
gint *league_cur_size)
{
gint i;
if(debug > 60)
g_print("league_team_movements_prune\n");
while(query_league_team_movements_unassigned_single(team_movements))
{
for(i=0;i<team_movements->len;i++)
if(!g_array_index(team_movements, TeamMove, i).dest_assigned &&
g_array_index(team_movements, TeamMove, i).dest_idcs->len == 1)
league_team_movements_assign_dest(team_movements, i,
league_size, league_cur_size);
}
}
/** Try to assign destinations for the team movements based on the
array of possible destinations.
@param league_size The size of all leagues (i.e. how many teams they
should contain after promotion/relegation is finished). */
void
league_team_movements_destinations(GArray *team_movements, const gint *league_size)
{
gint i;
gint league_cur_size[ligs->len];
if(debug > 60)
g_print("league_team_movements_destinations\n");
for(i=0;i<ligs->len;i++)
league_cur_size[i] = lig(i).teams->len;
if(debug > 65)
league_team_movements_print(team_movements, league_size, league_cur_size);
while(query_league_team_movements_unassigned(team_movements))
{
league_team_movements_prune(team_movements, league_size, league_cur_size);
for(i=0;i<team_movements->len;i++)
if(!g_array_index(team_movements, TeamMove, i).dest_assigned)
league_team_movements_assign_dest(team_movements, i,
league_size, league_cur_size);
}
if(debug > 65)
league_team_movements_print(team_movements, league_size, league_cur_size);
}
/** Find out whether there are any active leagues in the country. */
gboolean
query_leagues_active_in_country(void)
{
gint i;
for(i=0;i<ligs->len;i++)
if(lig(i).active)
return TRUE;
return FALSE;
}

View File

@ -0,0 +1,136 @@
/*
league.h
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef LEAGUE_H
#define LEAGUE_H
#include "bygfoot.h"
#include "cup.h"
#include "league_struct.h"
#include "fixture_struct.h"
#define league_cup_get_teams(clid) (clid < ID_CUP_START) ? ((gpointer)(league_from_clid(clid)->teams)) : ((gpointer)(cup_from_clid(clid)->teams))
#define league_cup_get_fixtures(clid) (clid < ID_CUP_START) ? (league_from_clid(clid)->fixtures) : (cup_from_clid(clid)->fixtures)
#define league_cup_get_name_string(clid) (clid < ID_CUP_START) ? league_from_clid(clid)->name : cup_from_clid(clid)->name
#define league_cup_get_yellow_red(clid) (clid < ID_CUP_START) ? (league_from_clid(clid)->yellow_red) : (cup_from_clid(clid)->yellow_red)
#define query_league_has_prom_games(league) (league->prom_rel.prom_games_dest_sid != NULL)
/** A struct needed when managing promotions
and relegations. */
typedef struct
{
Team tm; /**< The team we move. */
GArray *dest_idcs; /**< Array of possible destination indices. */
gint prom_rel_type; /**< Promotion or relegation */
gboolean dest_assigned; /**< Whether a destination league for the team
is already assigned. */
} TeamMove;
League
league_new(gboolean new_id);
PromRelElement
prom_rel_element_new(void);
gint
league_cup_get_index_from_clid(gint clid);
League*
league_from_clid(gint clid);
gint
league_cup_get_next_clid(gint clid, gboolean count_inactive);
gint
league_cup_get_previous_clid(gint clid, gboolean count_inactive);
Fixture*
league_cup_get_next_fixture(gint clid, gint week_number, gint week_round_number);
Fixture*
league_cup_get_previous_fixture(gint clid, gint week_number, gint week_round_number);
gint
league_cup_average_capacity(gint clid);
void
league_get_team_movements(League *league, GArray *team_movements);
gint
league_index_from_sid(const gchar *sid);
void
league_remove_team_with_id(League *league, gint id);
void
league_season_start(League *league);
gboolean
query_league_rank_in_prom_games(const League *league, gint rank);
gboolean
query_league_prom_games_begin(const League *league);
gboolean
query_league_matches_in_week(const League *league, gint week_number);
void
league_get_team_movements_prom_rel(const League *league, GArray *team_movements);
void
league_get_team_movements_prom_games(const League *league, GArray *team_movements,
const GPtrArray *prom_games_teams, gboolean up);
void
league_team_movements_destinations(GArray *team_movements, const gint *league_size);
void
league_team_movements_prune(GArray *team_movements, const gint *league_size,
gint *league_cur_size);
void
league_team_movements_assign_dest(GArray *team_movements, gint idx,
const gint *league_size, gint *league_cur_size);
gboolean
query_league_team_movements_unassigned_single(const GArray *team_movements);
gboolean
query_league_team_movements_unassigned(const GArray *team_movements);
void
league_team_movements_print(const GArray *team_movements,
const gint *league_size, const gint *league_cur_size);
gint
league_team_movements_compare_dest_idcs(gconstpointer a, gconstpointer b,
gpointer data);
gboolean
query_leagues_active_in_country(void);
#endif

View File

@ -0,0 +1,129 @@
/*
league_struct.h
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef LEAGUE_STRUCT_H
#define LEAGUE_STRUCT_H
#include "bygfoot.h"
#include "cup_struct.h"
#include "stat_struct.h"
#include "table_struct.h"
enum PromRelType
{
PROM_REL_PROMOTION = 0,
PROM_REL_RELEGATION,
PROM_REL_NONE
};
/**
An element representing a promotion or relegation rule.
This means, a PromRelElement specifies a range of teams
that get promoted or relegated to a given league.
@see PromRel
*/
typedef struct
{
gint ranks[2]; /**< The range of teams; default 0 and 0 */
gchar *dest_sid; /**< The id of the destination league. Default "" */
gint type; /**< Type. Promotion or relegation or none. */
} PromRelElement;
/**
This structure specifies how promotion and relegation is handled in a league.
It contains promotion and relegation rules in an array and possibly also
a rule about promotion games to be played.
@see PromRelElement
*/
typedef struct
{
/** The id of the league the promotion games winner gets promoted to. Default "" */
gchar *prom_games_dest_sid;
/** The id of the league the promotion games losers get moved to. Default "" */
gchar *prom_games_loser_sid;
/** Number of teams that advance from the promotion games. Default: 1. */
gint prom_games_number_of_advance;
/** Array with promotion/relegation rules.
@see PromRelElement
*/
GArray *elements;
/** The cup determining how the promotion games are handled. */
gchar *prom_games_cup_sid;
} PromRel;
/**
Representation of a league.
@see PromRel
@see Table
*/
typedef struct
{
/** Default value "" */
gchar *name, *short_name, *sid, *symbol;
/** The sid of the player names file the
teams in the league take their names from.
Default: 'general', meaning the 'player_names_general.xml' file. */
gchar *names_file;
/** @see PromRel */
PromRel prom_rel;
/** Numerical id, as opposed to the string id 'sid'. */
gint id;
/** Layer of the league; this specifies which leagues are
parallel. */
gint layer;
/** The first week games are played. Default 1. */
gint first_week;
/** Weeks between two matchdays. Default 1. */
gint week_gap;
/** How many round robins are played. Important for
small leagues with 10 teams or so. Default: 1. */
gint round_robins;
/** */
gint rr_break;
/** Number of yellow cards until a player gets banned.
Default 1000 (which means 'off', basically). */
gint yellow_red;
/** Average talent for the first season. Default: -1. */
gfloat average_talent;
/** Array of teams in the league.
@see Team */
GArray *teams;
/** League table.
@see Table */
Table table;
/** The fixtures of a season for the league. */
GArray *fixtures;
/** The current league statistics. */
LeagueStat stats;
/** Whether the league is only a container for teams
or really a league with fixtures and all. */
gboolean active;
} League;
#endif

View File

@ -0,0 +1,688 @@
/*
lg_commentary.c
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <locale.h>
#include "cup.h"
#include "file.h"
#include "fixture.h"
#include "free.h"
#include "language.h"
#include "league.h"
#include "lg_commentary.h"
#include "live_game.h"
#include "main.h"
#include "maths.h"
#include "misc.h"
#include "option.h"
#include "player.h"
#include "team.h"
#include "variables.h"
#include "xml_lg_commentary.h"
/** The replacement strings for the live game commentary tokens. */
GPtrArray *token_rep[2];
/** Whether there was a commentary repetition rejection. */
gboolean repetition;
/** Generate commentary for the live game event in the unit.
@param live_game The live game being calculated.
@param unit The live game unit we generate the commentary for.
@param event_type The event type we generate the commentary for (needed
when commentary is being tested). */
void
lg_commentary_generate(const LiveGame *live_game, LiveGameUnit *unit,
const gchar *event_name, gint ev_type)
{
gint i, event_type = -1;
gint commentary_idx = -1;
gchar buf[SMALL];
GArray *commentaries = NULL;
if(unit != NULL)
event_type = unit->event.type;
else
event_type = (event_name == NULL) ? ev_type :
xml_lg_commentary_event_name_to_int(event_name);
if(event_type == -1)
return;
if(live_game != NULL)
{
lg_commentary_set_basic_tokens(unit, live_game->fix);
lg_commentary_set_team_tokens(unit, live_game->fix);
lg_commentary_set_player_tokens(unit, live_game->fix);
lg_commentary_set_stats_tokens(&live_game->stats);
}
if(event_type == LIVE_GAME_EVENT_STYLE_CHANGE_ALL_OUT_DEFEND ||
event_type == LIVE_GAME_EVENT_STYLE_CHANGE_DEFEND ||
event_type == LIVE_GAME_EVENT_STYLE_CHANGE_BALANCED ||
event_type == LIVE_GAME_EVENT_STYLE_CHANGE_ATTACK ||
event_type == LIVE_GAME_EVENT_STYLE_CHANGE_ALL_OUT_ATTACK)
commentaries = lg_commentary[LIVE_GAME_EVENT_STYLE_CHANGE_ALL_OUT_DEFEND];
else if(event_type == LIVE_GAME_EVENT_BOOST_CHANGE_ANTI ||
event_type == LIVE_GAME_EVENT_BOOST_CHANGE_OFF ||
event_type == LIVE_GAME_EVENT_BOOST_CHANGE_ON)
commentaries = lg_commentary[LIVE_GAME_EVENT_BOOST_CHANGE_ANTI];
else
commentaries = lg_commentary[event_type];
commentary_idx = lg_commentary_select(commentaries, buf);
if(commentary_idx == -1)
g_warning("lg_commentary_generate: didn't find fitting commentary for unit type %d \n",
event_type);
if(live_game != NULL)
{
unit->event.commentary = g_strdup(buf);
unit->event.commentary_id = (commentary_idx == -1) ?
-1 : g_array_index(commentaries, LGCommentary, commentary_idx).id;
for(i=0;i<tokens.list->len;i++)
if(i != option_int("string_token_team_home", &tokens) &&
i != option_int("string_token_team_away", &tokens) &&
i != option_int("string_token_attendance", &tokens) &&
i != option_int("string_token_cup_round_name", &tokens) &&
i != option_int("string_token_league_cup_name", &tokens) &&
i != option_int("string_token_yellow_limit", &tokens) &&
i != option_int("string_token_team_layer0", &tokens) &&
i != option_int("string_token_team_layer1", &tokens))
misc_token_remove(token_rep, i);
}
else
g_print("%s: \"%s\"\n", event_name, buf);
}
/** Select a commentary from the array depending on the tokens
available and write the text into the buffer. */
gint
lg_commentary_select(const GArray *commentaries, gchar *buf)
{
gint i, order[commentaries->len];
lg_commentary_get_order(commentaries, order);
repetition = FALSE;
for(i=0;i<commentaries->len;i++)
if(lg_commentary_check_commentary(&g_array_index(commentaries, LGCommentary, order[i]), buf))
break;
if(i == commentaries->len)
{
repetition = TRUE;
for(i=0;i<commentaries->len;i++)
if(lg_commentary_check_commentary(&g_array_index(commentaries, LGCommentary, order[i]), buf))
break;
}
if(i == commentaries->len)
{
strcpy(buf, "FIXME!");
return -1;
}
return order[i];
}
/** Check whether the commentary conditions are fulfilled and whether
we can replace all tokens in the commentary. */
gboolean
lg_commentary_check_commentary(const LGCommentary *commentary, gchar *dest)
{
gchar buf[SMALL];
if(strlen(commentary->text) == 0 ||
(commentary->condition != NULL &&
!misc_parse_condition(commentary->condition, token_rep)) ||
(repetition == FALSE && query_lg_commentary_is_repetition(commentary->id)))
return FALSE;
strcpy(dest, commentary->text);
do
{
strcpy(buf, dest);
misc_string_replace_tokens(dest, token_rep);
misc_string_replace_expressions(dest);
}
while(strcmp(buf, dest) != 0);
return (g_strrstr(dest, "_") == NULL);
}
/** Check whether a commentary with given id has been used in the last
few commentaries. Return TRUE if so and FALSE otherwise. */
gboolean
query_lg_commentary_is_repetition(gint id)
{
const GArray *units = ((LiveGame*)statp)->units;
gint units_min = units->len - const_int("int_lg_commentary_check_backwards") - 1;
gint i, min = MAX(units_min, 0);
for(i=units->len - 2; i>= min; i--)
if(g_array_index(units, LiveGameUnit, i).event.commentary_id == id)
return TRUE;
return FALSE;
}
/** Write a random order of indices into the integer array
(only depending on the priority values of the commentaries).
I don't like this implementation of ordering the commentaries
according to their priority :-P can't think of a better one, though. */
void
lg_commentary_get_order(const GArray *commentaries, gint *order)
{
gint i, j, order_idx = 0;
gint priority_sum = 0, bounds[commentaries->len + 1];
bounds[0] = 0;
for(i=0;i<commentaries->len;i++)
{
priority_sum += g_array_index(commentaries, LGCommentary, i).priority;
bounds[i + 1] = priority_sum;
order[i] = -1;
}
gint permutation[priority_sum];
math_generate_permutation(permutation, 1, priority_sum);
for(i=0;i<priority_sum;i++)
{
if(order_idx == commentaries->len)
break;
for(j=0;j<commentaries->len;j++)
if(bounds[j] < permutation[i] && permutation[i] <= bounds[j + 1])
{
if(!query_integer_is_in_array(j, order, commentaries->len))
{
order[order_idx] = j;
order_idx++;
}
break;
}
}
}
/** Fill the stats tokens. */
void
lg_commentary_set_stats_tokens(const LiveGameStats *stats)
{
misc_token_add(token_rep,
option_int("string_token_stat_shots0", &tokens),
misc_int_to_char(stats->values[0][LIVE_GAME_STAT_VALUE_SHOTS]));
misc_token_add(token_rep,
option_int("string_token_stat_shot_per0", &tokens),
misc_int_to_char(stats->values[0][LIVE_GAME_STAT_VALUE_SHOT_PERCENTAGE]));
misc_token_add(token_rep,
option_int("string_token_stat_poss0", &tokens),
misc_int_to_char((gint)rint(100 *
((gfloat)stats->values[0][LIVE_GAME_STAT_VALUE_POSSESSION] /
((gfloat)stats->values[0][LIVE_GAME_STAT_VALUE_POSSESSION] +
(gfloat)stats->values[1][LIVE_GAME_STAT_VALUE_POSSESSION])))));
misc_token_add(token_rep,
option_int("string_token_stat_pen0", &tokens),
misc_int_to_char(stats->values[0][LIVE_GAME_STAT_VALUE_PENALTIES]));
misc_token_add(token_rep,
option_int("string_token_stat_fouls0", &tokens),
misc_int_to_char(stats->values[0][LIVE_GAME_STAT_VALUE_FOULS]));
misc_token_add(token_rep,
option_int("string_token_stat_yellows0", &tokens),
misc_int_to_char(stats->values[0][LIVE_GAME_STAT_VALUE_CARDS]));
misc_token_add(token_rep,
option_int("string_token_stat_reds0", &tokens),
misc_int_to_char(stats->values[0][LIVE_GAME_STAT_VALUE_REDS]));
misc_token_add(token_rep,
option_int("string_token_stat_injs0", &tokens),
misc_int_to_char(stats->values[0][LIVE_GAME_STAT_VALUE_INJURIES]));
misc_token_add(token_rep,
option_int("string_token_stat_shots1", &tokens),
misc_int_to_char(stats->values[1][LIVE_GAME_STAT_VALUE_SHOTS]));
misc_token_add(token_rep,
option_int("string_token_stat_shot_per1", &tokens),
misc_int_to_char(stats->values[1][LIVE_GAME_STAT_VALUE_SHOT_PERCENTAGE]));
misc_token_add(token_rep,
option_int("string_token_stat_poss1", &tokens),
misc_int_to_char((gint)rint(100 * ((gfloat)stats->values[1][LIVE_GAME_STAT_VALUE_POSSESSION] /
((gfloat)stats->values[0][LIVE_GAME_STAT_VALUE_POSSESSION] +
(gfloat)stats->values[1][LIVE_GAME_STAT_VALUE_POSSESSION])))));
misc_token_add(token_rep,
option_int("string_token_stat_pen1", &tokens),
misc_int_to_char(stats->values[1][LIVE_GAME_STAT_VALUE_PENALTIES]));
misc_token_add(token_rep,
option_int("string_token_stat_fouls1", &tokens),
misc_int_to_char(stats->values[1][LIVE_GAME_STAT_VALUE_FOULS]));
misc_token_add(token_rep,
option_int("string_token_stat_yellows1", &tokens),
misc_int_to_char(stats->values[1][LIVE_GAME_STAT_VALUE_CARDS]));
misc_token_add(token_rep,
option_int("string_token_stat_reds1", &tokens),
misc_int_to_char(stats->values[1][LIVE_GAME_STAT_VALUE_REDS]));
misc_token_add(token_rep,
option_int("string_token_stat_injs1", &tokens),
misc_int_to_char(stats->values[1][LIVE_GAME_STAT_VALUE_INJURIES]));
}
/** Fill the tokens that contain general information. */
void
lg_commentary_set_basic_tokens(const LiveGameUnit *unit, const Fixture *fix)
{
gchar buf[SMALL];
gint tmp_int = 1, current_min = live_game_unit_get_minute(unit);
gint avskill0 = (gint)rint(team_get_average_skill(fix->teams[0], TRUE)),
avskill1 = (gint)rint(team_get_average_skill(fix->teams[1], TRUE));
sprintf(buf, "%d : %d", unit->result[0], unit->result[1]);
misc_token_add(token_rep,
option_int("string_token_result", &tokens),
g_strdup(buf));
misc_token_add(token_rep,
option_int("string_token_time", &tokens),
misc_int_to_char(unit->time));
misc_token_add(token_rep,
option_int("string_token_minute", &tokens),
misc_int_to_char(current_min));
tmp_int = live_game_get_minutes_remaining(unit);
if(tmp_int > 0)
misc_token_add(token_rep,
option_int("string_token_minute_remaining", &tokens),
misc_int_to_char(tmp_int));
if(query_fixture_is_draw(fix))
tmp_int = 120 - current_min;
else
tmp_int = 90 - current_min;
if(tmp_int > 0)
misc_token_add(token_rep,
option_int("string_token_minute_total", &tokens),
misc_int_to_char(tmp_int));
misc_token_add(token_rep,
option_int("string_token_goals0", &tokens),
misc_int_to_char(unit->result[0]));
misc_token_add(token_rep,
option_int("string_token_goals1", &tokens),
misc_int_to_char(unit->result[1]));
misc_token_add(token_rep,
option_int("string_token_goal_diff", &tokens),
misc_int_to_char(ABS(unit->result[0] - unit->result[1])));
misc_token_add(token_rep,
option_int("string_token_extra", &tokens),
lg_commentary_get_extra_data(unit, fix));
misc_token_add(token_rep,
option_int("string_token_possession", &tokens),
misc_int_to_char(unit->possession));
misc_token_add(token_rep,
option_int("string_token_no_possession", &tokens),
misc_int_to_char(!unit->possession));
misc_token_add(token_rep,
option_int("string_token_team_avskill0", &tokens),
misc_int_to_char(avskill0));
misc_token_add(token_rep,
option_int("string_token_team_avskill1", &tokens),
misc_int_to_char(avskill1));
misc_token_add(token_rep,
option_int("string_token_team_avskilldiff", &tokens),
misc_int_to_char(ABS(avskill0 - avskill1)));
}
/** Set the tokens containing team data. */
void
lg_commentary_set_team_tokens(const LiveGameUnit *unit, const Fixture *fix)
{
if(unit->result[0] != unit->result[1])
{
misc_token_add(token_rep,
option_int("string_token_team_losing", &tokens),
g_strdup(fix->teams[(unit->result[0] > unit->result[1])]->name));
misc_token_add(token_rep,
option_int("string_token_team_winning", &tokens),
g_strdup(fix->teams[(unit->result[0] < unit->result[1])]->name));
misc_token_add(token_rep,
option_int("string_token_team_losingn", &tokens),
misc_int_to_char((unit->result[0] > unit->result[1])));
misc_token_add(token_rep,
option_int("string_token_team_winningn", &tokens),
misc_int_to_char((unit->result[0] < unit->result[1])));
}
if(unit->event.team != -1)
misc_token_add(token_rep,
option_int("string_token_team", &tokens),
misc_int_to_char(unit->event.team));
}
/** Set the player tokens. */
void
lg_commentary_set_player_tokens(const LiveGameUnit *unit, const Fixture *fix)
{
Player *pl1 = NULL,
*pl2 = NULL;
if(unit->event.type == LIVE_GAME_EVENT_GENERAL ||
unit->event.type == LIVE_GAME_EVENT_SCORING_CHANCE ||
unit->event.type == LIVE_GAME_EVENT_HEADER ||
unit->event.type == LIVE_GAME_EVENT_PENALTY ||
unit->event.type == LIVE_GAME_EVENT_FREE_KICK)
{
pl1 = player_of_id_team(fix->teams[unit->possession],
unit->event.player);
if(unit->event.player2 != -1)
pl2 = player_of_id_team(fix->teams[unit->possession],
unit->event.player2);
}
else if(unit->event.type == LIVE_GAME_EVENT_SEND_OFF ||
unit->event.type == LIVE_GAME_EVENT_INJURY ||
unit->event.type == LIVE_GAME_EVENT_TEMP_INJURY ||
unit->event.type == LIVE_GAME_EVENT_SUBSTITUTION)
{
pl1 = player_of_id_team(fix->teams[unit->event.team],
unit->event.player);
if(unit->event.player2 != -1)
pl2 = player_of_id_team(fix->teams[unit->event.team],
unit->event.player2);
}
else if(unit->event.type == LIVE_GAME_EVENT_LOST_POSSESSION ||
unit->event.type == LIVE_GAME_EVENT_GOAL ||
unit->event.type == LIVE_GAME_EVENT_MISS ||
unit->event.type == LIVE_GAME_EVENT_SAVE ||
unit->event.type == LIVE_GAME_EVENT_POST ||
unit->event.type == LIVE_GAME_EVENT_CROSS_BAR)
{
pl1 = player_of_id_team(fix->teams[unit->possession],
unit->event.player);
pl2 = player_of_id_team(fix->teams[!unit->possession],
unit->event.player2);
}
else if(unit->event.type == LIVE_GAME_EVENT_OWN_GOAL)
pl1 = player_of_id_team(fix->teams[!unit->possession],
unit->event.player);
else if(unit->event.type == LIVE_GAME_EVENT_FOUL ||
unit->event.type == LIVE_GAME_EVENT_FOUL_RED ||
unit->event.type == LIVE_GAME_EVENT_FOUL_RED_INJURY ||
unit->event.type == LIVE_GAME_EVENT_FOUL_YELLOW)
{
pl1 = player_of_id_team(fix->teams[!unit->event.team],
unit->event.player);
pl2 = player_of_id_team(fix->teams[unit->event.team],
unit->event.player2);
}
if(pl1 != NULL)
{
misc_token_add(token_rep,
option_int("string_token_player0", &tokens),
player_get_last_name(pl1->name));
misc_token_add(token_rep,
option_int("string_token_player_goals0", &tokens),
misc_int_to_char(player_games_goals_get(
pl1, fix->clid, PLAYER_VALUE_GOALS)));
misc_token_add(token_rep,
option_int("string_token_player_goals_all0", &tokens),
misc_int_to_char(player_all_games_goals(pl1, PLAYER_VALUE_GOALS)));
}
if(pl2 != NULL)
{
misc_token_add(token_rep,
option_int("string_token_player1", &tokens),
player_get_last_name(pl2->name));
misc_token_add(token_rep,
option_int("string_token_player_goals1", &tokens),
misc_int_to_char(player_games_goals_get(pl2, fix->clid, PLAYER_VALUE_GOALS)));
misc_token_add(token_rep,
option_int("string_token_player_goals_all1", &tokens),
misc_int_to_char(player_all_games_goals(pl2, PLAYER_VALUE_GOALS)));
misc_token_add(token_rep,
option_int("string_token_player_yellows", &tokens),
misc_int_to_char(player_card_get(pl2, fix->clid, PLAYER_VALUE_CARD_YELLOW)));
}
}
/** Return some extra data depending on the unit type. */
gchar*
lg_commentary_get_extra_data(const LiveGameUnit *unit, const Fixture *fix)
{
gchar buf[SMALL];
switch(unit->event.type)
{
default:
return NULL;
break;
case LIVE_GAME_EVENT_STRUCTURE_CHANGE:
sprintf(buf, "%d",
fix->teams[unit->event.team]->structure);
break;
case LIVE_GAME_EVENT_STYLE_CHANGE_ALL_OUT_DEFEND:
strcpy(buf, _("ALL OUT DEFEND"));
break;
case LIVE_GAME_EVENT_STYLE_CHANGE_DEFEND:
strcpy(buf, _("DEFEND"));
break;
case LIVE_GAME_EVENT_STYLE_CHANGE_BALANCED:
strcpy(buf, _("BALANCED"));
break;
case LIVE_GAME_EVENT_STYLE_CHANGE_ATTACK:
strcpy(buf, _("ATTACK"));
break;
case LIVE_GAME_EVENT_STYLE_CHANGE_ALL_OUT_ATTACK:
strcpy(buf, _("ALL OUT ATTACK"));
break;
case LIVE_GAME_EVENT_BOOST_CHANGE_ANTI:
strcpy(buf, _("ANTI"));
break;
case LIVE_GAME_EVENT_BOOST_CHANGE_OFF:
strcpy(buf, _("OFF"));
break;
case LIVE_GAME_EVENT_BOOST_CHANGE_ON:
strcpy(buf, _("ON"));
break;
}
return g_strdup(buf);
}
/** Allocate memory for the token array and fill some tokens
at the beginning of the live game that don't change later. */
void
lg_commentary_initialize(const Fixture *fix)
{
gchar buf[SMALL];
token_rep[0] = g_ptr_array_new();
token_rep[1] = g_ptr_array_new();
misc_token_add(token_rep,
option_int("string_token_team_home", &tokens),
g_strdup(fix->teams[0]->name));
misc_token_add(token_rep,
option_int("string_token_team_away", &tokens),
g_strdup(fix->teams[1]->name));
if(fix->teams[0]->clid < ID_CUP_START)
misc_token_add(token_rep,
option_int("string_token_team_layer0", &tokens),
misc_int_to_char(league_from_clid(fix->teams[0]->clid)->layer));
if(fix->teams[1]->clid < ID_CUP_START)
misc_token_add(token_rep,
option_int("string_token_team_layer1", &tokens),
misc_int_to_char(league_from_clid(fix->teams[1]->clid)->layer));
if(fix->teams[0]->clid < ID_CUP_START &&
fix->teams[1]->clid < ID_CUP_START)
misc_token_add(token_rep,
option_int("string_token_team_layerdiff", &tokens),
misc_int_to_char(league_from_clid(fix->teams[0]->clid)->layer -
league_from_clid(fix->teams[1]->clid)->layer));
misc_token_add(token_rep,
option_int("string_token_league_cup_name", &tokens),
g_strdup(league_cup_get_name_string(fix->clid)));
if(fix->clid >= ID_CUP_START)
{
cup_get_round_name(cup_from_clid(fix->clid), fix->round, buf);
misc_token_add(token_rep,
option_int("string_token_cup_round_name", &tokens),
g_strdup(buf));
}
misc_print_grouped_int(fix->attendance, buf);
misc_token_add(token_rep,
option_int("string_token_attendance", &tokens),
g_strdup(buf));
misc_token_add(token_rep,
option_int("string_token_yellow_limit", &tokens),
misc_int_to_char(league_cup_get_yellow_red(fix->clid)));
}
/** Free the memory occupied by the tokens array and the permanent tokens. */
void
lg_commentary_free_tokens(void)
{
gint i;
for(i=token_rep[0]->len - 1;i >= 0; i--)
{
g_free(g_ptr_array_index(token_rep[0], i));
g_free(g_ptr_array_index(token_rep[1], i));
}
g_ptr_array_free(token_rep[0], TRUE);
g_ptr_array_free(token_rep[1], TRUE);
}
/** Load the appropriate commentary file by evaluating
the language option. */
void
lg_commentary_load_commentary_file_from_option(void)
{
gchar buf[SMALL], commentary_file[SMALL];
language_get_code(buf);
sprintf(commentary_file, "lg_commentary_%s.xml", buf);
lg_commentary_load_commentary_file(commentary_file, FALSE);
}
/** Load the commentary file given. Abort if not found and abort=TRUE,
load default english file otherwise. */
void
lg_commentary_load_commentary_file(const gchar *commentary_file, gboolean abort)
{
gchar *file_name = NULL;
if(g_file_test(commentary_file, G_FILE_TEST_EXISTS))
{
xml_lg_commentary_read(commentary_file);
return;
}
file_name = file_find_support_file(commentary_file, FALSE);
if(file_name != NULL)
{
xml_lg_commentary_read(file_name);
g_free(file_name);
}
else
{
if(abort)
main_exit_program(EXIT_FILE_NOT_FOUND,
"lg_commentary_load_commentary_file: file %s not found \n",
file_name);
else
lg_commentary_load_commentary_file("lg_commentary_en.xml", TRUE);
}
}
/** Load a file with tokens for commentary testing purposes. */
void
lg_commentary_test_load_token_file(const gchar *token_file)
{
gchar token_name[SMALL], token_value[SMALL];
FILE *fil = NULL;
file_my_fopen(token_file, "r", &fil, TRUE);
token_rep[0] = g_ptr_array_new();
token_rep[1] = g_ptr_array_new();
while(file_get_next_opt_line(fil, token_name, token_value))
{
g_ptr_array_add(token_rep[0], (gpointer)g_strdup(token_name));
g_ptr_array_add(token_rep[1], (gpointer)g_strdup(token_value));
}
}
/** Test a live game commentary file.
@param commentary_file the commentary file to test.
@param token_file the file containing the token values to use.
@param event_name the event to test (or 'all' to test all events).
@param number_of_passes how many commentaries to generate. */
void
lg_commentary_test(const gchar *commentary_file, const gchar* token_file,
const gchar *event_name, gint number_of_passes)
{
gint i, j;
LiveGame dummy;
lg_commentary_load_commentary_file(commentary_file, TRUE);
lg_commentary_test_load_token_file(token_file);
dummy.units = g_array_new(FALSE, FALSE, sizeof(gint));
statp = (gpointer)&dummy;
if(event_name == NULL)
for(i=0;i<LIVE_GAME_EVENT_END;i++)
for(j=0;j<number_of_passes;j++)
lg_commentary_generate(NULL, NULL, NULL, i);
else
for(i=0;i<number_of_passes;i++)
lg_commentary_generate(NULL, NULL, event_name, -1);
g_array_free(dummy.units, TRUE);
}

View File

@ -0,0 +1,84 @@
/*
lg_commentary.h
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef LG_COMMENTARY_H
#define LG_COMMENTARY_H
#include "bygfoot.h"
#include "fixture_struct.h"
#include "lg_commentary_struct.h"
#include "live_game_struct.h"
void
lg_commentary_free_tokens(void);
void
lg_commentary_initialize(const Fixture *fix);
gboolean
lg_commentary_check_commentary(const LGCommentary *commentary, gchar *dest);
gboolean
query_lg_commentary_is_repetition(gint id);
void
lg_commentary_get_order(const GArray *commentaries, gint *order);
void
lg_commentary_set_basic_tokens(const LiveGameUnit *unit, const Fixture *fix);;
void
lg_commentary_set_player_tokens(const LiveGameUnit *unit, const Fixture *fix);
void
lg_commentary_set_team_tokens(const LiveGameUnit *unit, const Fixture *fix);
void
lg_commentary_set_stats_tokens(const LiveGameStats *stats);
void
lg_commentary_generate(const LiveGame *live_game, LiveGameUnit *unit,
const gchar *event_name, gint ev_type);
gchar*
lg_commentary_get_extra_data(const LiveGameUnit *unit, const Fixture *fix);
void
lg_commentary_load_commentary_file_from_option(void);
void
lg_commentary_load_commentary_file(const gchar *commentary_file, gboolean abort);
void
lg_commentary_test_load_token_file(const gchar *token_file);
void
lg_commentary_test(const gchar *commentary_file, const gchar* token_file,
const gchar *event_name, gint number_of_passes);
gint
lg_commentary_select(const GArray *commentaries, gchar *buf);
#endif

View File

@ -0,0 +1,49 @@
/*
lg_commentary_struct.h
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef LG_COMMENTARY_STRUCT_H
#define LG_COMMENTARY_STRUCT_H
/** Structure describing a commentary
for the live game. */
typedef struct
{
/** The commentary text (possibly containing tokens). */
gchar *text;
/** A condition (if not fulfilled, the commentary doesn't get
shown). */
gchar *condition;
/** Priority of the commentary (compared to
the other ones for the same event).
The higher the priority the higher the
probability that the commentary gets picked. */
gint priority;
/** An id to keep track of already used commentaries in the
live game (so as not to use the same one too frequently). */
gint id;
} LGCommentary;
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,143 @@
/*
live_game.h
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef LIVE_GAME_H
#define LIVE_GAME_H
#include "bygfoot.h"
#include "live_game_struct.h"
void
live_game_calculate_fixture(Fixture *fix);
void
live_game_initialize(Fixture *fix);
gboolean
query_live_game_event_is_break(gint minute, gint time);
gboolean
query_live_game_penalties_over(void);
gint
live_game_get_break(void);
gint
live_game_get_time(const LiveGameUnit *unit);
gint
live_game_get_minute(void);
gint
live_game_get_minutes_remaining(const LiveGameUnit *unit);
void
live_game_create_unit(void);
void
live_game_fill_new_unit(LiveGameUnit *new);
void
live_game_create_start_unit(void);
void
live_game_evaluate_unit(LiveGameUnit *unit);
void
live_game_event_foul(void);
void
live_game_event_lost_possession(void);
void
live_game_event_injury(gint team, gint player, gboolean create_new);
void
live_game_event_stadium(void);
void
live_game_event_scoring_chance(void);
void
live_game_event_penalty();
void
live_game_event_general(gboolean create_new);
void
live_game_event_general_get_players(void);
void
live_game_event_free_kick(void);
void
live_game_event_send_off(gint team, gint player, gboolean second_yellow);
void
live_game_event_duel(void);
gboolean
query_live_game_second_yellow(gint team, gint player);
void
live_game_reset(LiveGame *live_game, Fixture *fix, gboolean free_variable);
gint
live_game_unit_get_minute(const LiveGameUnit *unit);
gint
live_game_get_area(const LiveGameUnit *unit);
gfloat
live_game_pit_teams(const LiveGameUnit *unit, gfloat exponent);
void
live_game_injury_get_player(void);
void
live_game_resume(void);
void
live_game_event_substitution(gint team_number, gint sub_in, gint sub_out);
void
live_game_event_team_change(gint team_number, gint event_type);
void
live_game_finish_unit(void);
LiveGameUnit*
live_game_unit_before(const LiveGameUnit* unit, gint gap);
gint
live_game_event_get_verbosity(gint event_type);
void
live_game_unit_result_to_buf(const LiveGameUnit *unit, gchar *buf, gboolean swap);
gint
live_game_penalties_taken(void);
#endif

View File

@ -0,0 +1,231 @@
/*
live_game_struct.h
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
http://bygfoot.sourceforge.net
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef LIVE_GAME_STRUCT_H
#define LIVE_GAME_STRUCT_H
#include "bygfoot.h"
#include "fixture_struct.h"
/** Events happening during a live game.
@see #LiveGameEvent
@see #LiveGameUnit */
enum LiveGameEventType
{
/** This is the 'main' event, nothing in
particular is happening; one of the teams
is in possession of the ball. */
LIVE_GAME_EVENT_GENERAL = 0, /* 0 */
LIVE_GAME_EVENT_START_MATCH, /* 1 */
LIVE_GAME_EVENT_HALF_TIME, /* 2 */
LIVE_GAME_EVENT_EXTRA_TIME, /* 3 */
LIVE_GAME_EVENT_END_MATCH, /* 4 */
LIVE_GAME_EVENT_LOST_POSSESSION, /* 5 */
LIVE_GAME_EVENT_SCORING_CHANCE, /* 6 */
LIVE_GAME_EVENT_HEADER, /* 7 */
LIVE_GAME_EVENT_PENALTY, /* 8 */
LIVE_GAME_EVENT_FREE_KICK, /* 9 */
LIVE_GAME_EVENT_GOAL, /* 10 */
LIVE_GAME_EVENT_OWN_GOAL, /* 11 */
LIVE_GAME_EVENT_POST, /* 12 */
LIVE_GAME_EVENT_MISS, /* 13 */
LIVE_GAME_EVENT_SAVE, /* 14 */
LIVE_GAME_EVENT_CROSS_BAR, /* 15 */
LIVE_GAME_EVENT_FOUL, /* 16 */
LIVE_GAME_EVENT_FOUL_YELLOW, /* 17 */
LIVE_GAME_EVENT_FOUL_RED, /* 18 */
LIVE_GAME_EVENT_FOUL_RED_INJURY, /* 19 */
LIVE_GAME_EVENT_SEND_OFF, /* 20 */
LIVE_GAME_EVENT_INJURY, /* 21 */
/** An injury that permits the player to
continue after some brief time. */
LIVE_GAME_EVENT_TEMP_INJURY, /* 22 */
LIVE_GAME_EVENT_PENALTIES, /* 23 */
LIVE_GAME_EVENT_STADIUM, /* 24 */
LIVE_GAME_EVENT_STADIUM_BREAKDOWN, /* 25 */
LIVE_GAME_EVENT_STADIUM_RIOTS, /* 26 */
LIVE_GAME_EVENT_STADIUM_FIRE, /* 27 */
LIVE_GAME_EVENT_SUBSTITUTION, /* 28 */
LIVE_GAME_EVENT_STRUCTURE_CHANGE, /* 29 */
LIVE_GAME_EVENT_STYLE_CHANGE_ALL_OUT_DEFEND, /* 30 */
LIVE_GAME_EVENT_STYLE_CHANGE_DEFEND, /* 31 */
LIVE_GAME_EVENT_STYLE_CHANGE_BALANCED, /* 32 */
LIVE_GAME_EVENT_STYLE_CHANGE_ATTACK, /* 33 */
LIVE_GAME_EVENT_STYLE_CHANGE_ALL_OUT_ATTACK, /* 34 */
LIVE_GAME_EVENT_BOOST_CHANGE_ANTI, /* 35 */
LIVE_GAME_EVENT_BOOST_CHANGE_OFF, /* 36 */
LIVE_GAME_EVENT_BOOST_CHANGE_ON, /* 37 */
LIVE_GAME_EVENT_END
};
enum LiveGameUnitArea
{
LIVE_GAME_UNIT_AREA_DEFEND = 0,
LIVE_GAME_UNIT_AREA_MIDFIELD,
LIVE_GAME_UNIT_AREA_ATTACK,
LIVE_GAME_UNIT_AREA_END
};
/** Indices for the time variable of th
#LiveGameUnit struct. */
enum LiveGameUnitTime
{
LIVE_GAME_UNIT_TIME_FIRST_HALF = 0,
LIVE_GAME_UNIT_TIME_SECOND_HALF,
LIVE_GAME_UNIT_TIME_EXTRA_TIME,
LIVE_GAME_UNIT_TIME_PENALTIES,
LIVE_GAME_UNIT_TIME_END
};
/** Indices for the values in #LiveGameStats. */
enum LiveGameStatValue
{
LIVE_GAME_STAT_VALUE_GOALS_REGULAR = 0,
LIVE_GAME_STAT_VALUE_SHOTS,
LIVE_GAME_STAT_VALUE_SHOT_PERCENTAGE,
LIVE_GAME_STAT_VALUE_POSSESSION,
LIVE_GAME_STAT_VALUE_PENALTIES,
LIVE_GAME_STAT_VALUE_FOULS,
LIVE_GAME_STAT_VALUE_CARDS,
LIVE_GAME_STAT_VALUE_REDS,
LIVE_GAME_STAT_VALUE_INJURIES,
LIVE_GAME_STAT_VALUE_END
};
enum LiveGameStatArray
{
LIVE_GAME_STAT_ARRAY_SCORERS = 0,
LIVE_GAME_STAT_ARRAY_YELLOWS,
LIVE_GAME_STAT_ARRAY_REDS,
LIVE_GAME_STAT_ARRAY_INJURED,
LIVE_GAME_STAT_ARRAY_END
};
/** Indices for the team_value array.
@see game_get_values() */
enum GameTeamValue
{
GAME_TEAM_VALUE_GOALIE = 0,
GAME_TEAM_VALUE_DEFEND,
GAME_TEAM_VALUE_MIDFIELD,
GAME_TEAM_VALUE_ATTACK,
GAME_TEAM_VALUE_END
};
/** Some stats for a live game like ball possession,
shots on goal etc. */
typedef struct
{
gfloat possession;
gint values[2][LIVE_GAME_STAT_VALUE_END];
GPtrArray *players[2][LIVE_GAME_STAT_ARRAY_END];
} LiveGameStats;
/** A struct telling us what's happening at
a certain moment in a game. */
typedef struct
{
/** @see #LiveGameEventType */
gint type;
/** Verbosity value. The lower the more important
the event. */
gint verbosity;
/** Information about a team and two players
involved in the event. */
gint team, player, player2;
/** The commentary for the event. */
gchar *commentary;
/** Id of the commentary. */
gint commentary_id;
} LiveGameEvent;
/** A struct representing a fraction of a live game. */
typedef struct
{
/** Tells us which of the teams is in possession
of the ball. */
gint possession;
/** The area of the pitch the ball is currently in. */
gint area;
/** Which minute of the game and which part of
the game. If 'minute' is -1 we have an event
like a substitution that doesn't count as a
match time consuming event. @see #GameUnitTime */
gint minute, time;
/** The match result at the time of this unit. */
gint result[2];
/** The event belonging to the game unit. */
LiveGameEvent event;
} LiveGameUnit;
/** A structure storing team settings during a live game
pause (so that we know what users have changed in pauses. */
typedef struct
{
gint structure, style;
gboolean boost;
gint player_ids[11];
} LiveGameTeamState;
typedef struct
{
/** The fixture that belongs to the game. */
Fixture *fix;
/** Integer determining the fixture (needed because fixture pointers
can change when new fixtures are added to the fixtures array). */
gint fix_id;
/** The names of the teams stored for later use (when the fixture
already got freed). */
gchar *team_names[2];
/** Attendance stored for later use (when the fixture
already got freed). */
gint attendance;
/** Substitutions left for the teams. */
gint subs_left[2];
/** The team that started the game, 0 or 1. */
gint started_game;
/** We keep track of the stadium events because
there shouldn't be more than one of them in a game. */
gint stadium_event;
/** Attacking, defending etc. values for both teams.
@see #GameTeamValue */
gfloat team_values[2][GAME_TEAM_VALUE_END];
/** The home advantage factor. */
gfloat home_advantage;
/** The array of units. @see #GameUnit */
GArray *units;
/** Match statistics. @see #LiveGameStats */
LiveGameStats stats;
LiveGameTeamState team_state[2];
/** Ids of strategy actions applied.
Actions only get applied once. */
GArray *action_ids[2];
} LiveGame;
#endif

Some files were not shown because too many files have changed in this diff Show More