git repos / blockattack-game

commit 3a2f158c

Poul Sander · 2015-12-25 15:52
3a2f158cc708d815f69c9cab2b5a1e58513d1141 patch · browse files
parent 7dbd2cb6e42a9da0b2d34c01250905709b92f17e
parent c18f506d5999216a79b81d13fb04ef42b31676f0

Merge pull request #1 from blockattack/sdl2

Sdl2

Changed files

M .travis.yml before
A Game/data/fonts/freeserif.ttf
A Game/data/fonts/penguin_attack_license.txt
A Game/data/fonts/penguinattack.ttf
A Game/data/music/bgmusic.ogg
A Game/data/music/highbeat.ogg
A Game/data/puzzles/copy
A Game/data/puzzles/puzzle.levels
A Game/data/puzzles/testPuzzles
A Game/data/sounds/applause.ogg
A Game/data/sounds/cameraclick.ogg
A Game/data/sounds/counter.ogg
A Game/data/sounds/counter_final.ogg
A Game/data/sounds/pop.ogg
A Game/data/sounds/typing.ogg
A Game/data/sprites/blockattack.sprite
A Game/data/sprites/blockattack1.sprite
A Game/data/textures/b_blank.png
A Game/data/textures/b_exit.png
A Game/data/textures/b_highscore.png
A Game/data/textures/back_board.png
A Game/data/textures/background.png
A Game/data/textures/ball_blue.png
A Game/data/textures/ball_gray.png
A Game/data/textures/ball_green.png
A Game/data/textures/ball_purple.png
A Game/data/textures/ball_red.png
A Game/data/textures/ball_turkish.png
A Game/data/textures/ball_yellow.png
A Game/data/textures/black_back_ground.png
A Game/data/textures/black_line.png
A Game/data/textures/blue.png
A Game/data/textures/board_back_back.png
A Game/data/textures/bomb.png
A Game/data/textures/chain_frame.png
A Game/data/textures/counter_1.png
A Game/data/textures/counter_2.png
A Game/data/textures/counter_3.png
A Game/data/textures/crossover.png
A Game/data/textures/cursor.png
A Game/data/textures/dialogbox.png
A Game/data/textures/explosion0.png
A Game/data/textures/explosion1.png
A Game/data/textures/explosion2.png
A Game/data/textures/explosion3.png
A Game/data/textures/fallback.png
A Game/data/textures/fileDialogbox.png
A Game/data/textures/garbage_b.png
A Game/data/textures/garbage_bl.png
A Game/data/textures/garbage_br.png
A Game/data/textures/garbage_fill.png
A Game/data/textures/garbage_gm.png
A Game/data/textures/garbage_gml.png
A Game/data/textures/garbage_gmr.png
A Game/data/textures/garbage_l.png
A Game/data/textures/garbage_m.png
A Game/data/textures/garbage_ml.png
A Game/data/textures/garbage_mr.png
A Game/data/textures/garbage_r.png
A Game/data/textures/garbage_t.png
A Game/data/textures/garbage_tl.png
A Game/data/textures/garbage_tr.png
A Game/data/textures/green.png
A Game/data/textures/grey.png
A Game/data/textures/i_check_box_area.png
A Game/data/textures/i_draw.png
A Game/data/textures/i_game_over.png
A Game/data/textures/i_level_check.png
A Game/data/textures/i_level_check_box.png
A Game/data/textures/i_level_check_box_marked.png
A Game/data/textures/i_loser.png
A Game/data/textures/i_stage_clear_limit.png
A Game/data/textures/i_winner.png
A Game/data/textures/icon.png
A Game/data/textures/menu_marked.png
A Game/data/textures/menu_unmarked.png
A Game/data/textures/mouse.png
A Game/data/textures/purple.png
A Game/data/textures/ready.png
A Game/data/textures/red.png
A Game/data/textures/smileys0.png
A Game/data/textures/smileys1.png
A Game/data/textures/smileys2.png
A Game/data/textures/smileys3.png
A Game/data/textures/trans_cover.png
A Game/data/textures/turkish.png
A Game/data/textures/yellow.png
D Game/fonts/FreeSerif.ttf before
D Game/fonts/PenguinAttack.ttf before
D Game/fonts/penguin_attack_license.txt before
D Game/gfx/BackBoard.png before
D Game/gfx/animations/explosion/0.png before
D Game/gfx/animations/explosion/1.png before
D Game/gfx/animations/explosion/2.png before
D Game/gfx/animations/explosion/3.png before
D Game/gfx/b1024.png before
D Game/gfx/bBack.png before
D Game/gfx/bBlank.png before
D Game/gfx/bChange.png before
D Game/gfx/bConfigure.png before
D Game/gfx/bConnect.png before
D Game/gfx/bEndless.png before
D Game/gfx/bExit.png before
D Game/gfx/bForward.png before
D Game/gfx/bHighScore.png before
D Game/gfx/bHost.png before
D Game/gfx/bHowToPlay.png before
D Game/gfx/bInternet.png before
D Game/gfx/bLoad.png before
D Game/gfx/bNetwork.png before
D Game/gfx/bNewGame.png before
D Game/gfx/bNext.png before
D Game/gfx/bOff.png before
D Game/gfx/bOn.png before
D Game/gfx/bOnePlayer.png before
D Game/gfx/bOptions.png before
D Game/gfx/bPuzzle.png before
D Game/gfx/bReplays.png before
D Game/gfx/bRetry.png before
D Game/gfx/bSave.png before
D Game/gfx/bSelectPuzzle.png before
D Game/gfx/bSkip.png before
D Game/gfx/bStageClear.png before
D Game/gfx/bTheme.png before
D Game/gfx/bTimeTrial.png before
D Game/gfx/bTwoPlayers.png before
D Game/gfx/bVsGame.png before
D Game/gfx/bVsGameConfig.png before
D Game/gfx/background.png before
D Game/gfx/balls/ballBlue.png before
D Game/gfx/balls/ballGray.png before
D Game/gfx/balls/ballGreen.png before
D Game/gfx/balls/ballPurple.png before
D Game/gfx/balls/ballRed.png before
D Game/gfx/balls/ballTurkish.png before
D Game/gfx/balls/ballYellow.png before
D Game/gfx/blackBackGround.png before
D Game/gfx/blackLine.png before
D Game/gfx/boardBackBack.png before
D Game/gfx/bricks/blue.png before
D Game/gfx/bricks/green.png before
D Game/gfx/bricks/grey.png before
D Game/gfx/bricks/purple.png before
D Game/gfx/bricks/red.png before
D Game/gfx/bricks/turkish.png before
D Game/gfx/bricks/yellow.png before
D Game/gfx/chainFrame.png before
D Game/gfx/changeButtonsBack.png before
D Game/gfx/changeButtonsBack1.png before
D Game/gfx/counter/1.png before
D Game/gfx/counter/2.png before
D Game/gfx/counter/3.png before
D Game/gfx/crossover.png before
D Game/gfx/dialogbox.png before
D Game/gfx/fileDialogbox.png before
D Game/gfx/garbage/garbageB.png before
D Game/gfx/garbage/garbageBL.png before
D Game/gfx/garbage/garbageBR.png before
D Game/gfx/garbage/garbageFill.png before
D Game/gfx/garbage/garbageGM.png before
D Game/gfx/garbage/garbageGML.png before
D Game/gfx/garbage/garbageGMR.png before
D Game/gfx/garbage/garbageL.png before
D Game/gfx/garbage/garbageM.png before
D Game/gfx/garbage/garbageML.png before
D Game/gfx/garbage/garbageMR.png before
D Game/gfx/garbage/garbageR.png before
D Game/gfx/garbage/garbageT.png before
D Game/gfx/garbage/garbageTL.png before
D Game/gfx/garbage/garbageTR.png before
D Game/gfx/iCheckBoxArea.png before
D Game/gfx/iDraw.png before
D Game/gfx/iGameOver.png before
D Game/gfx/iLevelCheck.png before
D Game/gfx/iLevelCheckBox.png before
D Game/gfx/iLevelCheckBoxMarked.png before
D Game/gfx/iLoser.png before
D Game/gfx/iStageClearLimit.png before
D Game/gfx/iWinner.png before
D Game/gfx/icon.png before
D Game/gfx/menu/marked.png before
D Game/gfx/menu/unmarked.png before
D Game/gfx/mouse.png before
D Game/gfx/options.png before
D Game/gfx/smileys/0.png before
D Game/gfx/smileys/1.png before
D Game/gfx/smileys/2.png before
D Game/gfx/smileys/3.png before
D Game/gfx/transCover.png before
D Game/music/bgMusic.ogg before
D Game/music/highbeat.ogg before
D Game/puzzles/copy before
D Game/puzzles/puzzle.levels before
D Game/puzzles/testPuzzles before
D Game/sound/applause.ogg before
D Game/sound/cameraclick.ogg before
D Game/sound/counter.ogg before
D Game/sound/counterFinal.ogg before
D Game/sound/pop.ogg before
D Game/sound/typing.ogg before
M README.md before
M SConstruct before
M packdata.sh before
M source/AUTH before
M source/code/AUTHORS before
D source/code/CppSdlImageHolder.cpp before
D source/code/CppSdlImageHolder.hpp before
M source/code/Libs/NFont.cpp before
M source/code/Libs/NFont.h before
A source/code/Libs/SDL_FontCache.cpp
A source/code/Libs/SDL_FontCache.h
M source/code/Makefile before
M source/code/MenuSystem.cpp before
M source/code/MenuSystem.h before
M source/code/ReadKeyboard.cpp before
M source/code/ReadKeyboard.h before
M source/code/SConscript before
M source/code/common.cpp before
M source/code/common.h before
M source/code/global.hpp before
M source/code/joypad.cpp before
M source/code/main.cpp before
M source/code/mainVars.hpp before
M source/code/menudef.cpp before
A source/code/sago/LICENSE
A source/code/sago/Makefile.sago
A source/code/sago/SagoDataHolder.cpp
A source/code/sago/SagoDataHolder.hpp
A source/code/sago/SagoMisc.cpp
A source/code/sago/SagoMisc.hpp
A source/code/sago/SagoSprite.cpp
A source/code/sago/SagoSprite.hpp
A source/code/sago/SagoSpriteHolder.cpp
A source/code/sago/SagoSpriteHolder.hpp
M source/code/scopeHelpers.hpp before
D source/code/ttfont.cpp before
D source/code/ttfont.h before
M travis_build.script before
diff --git a/.travis.yml b/.travis.yml index a80311a..fb0a8e1 100644 --- a/.travis.yml +++ b/.travis.yml
@@ -8,14 +8,14 @@ addons:
packages:
- g++-4.9
- build-essential
- - libsdl1.2-dev
- - libsdl-image1.2-dev
- - libsdl-mixer1.2-dev
- - libsdl-ttf2.0-dev
+ - libsdl2-dev
+ - libsdl2-image-dev
+ - libsdl2-mixer-dev
+ - libsdl2-ttf-dev
- libenet-dev
- libphysfs-dev
- libboost1.55-dev
- - scons
+ - libjsoncpp-dev
cache:
apt: true
diff --git a/Game/data/fonts/freeserif.ttf b/Game/data/fonts/freeserif.ttf new file mode 100644 index 0000000..2f3dfc3
Binary files /dev/null and b/Game/data/fonts/freeserif.ttf differ
diff --git a/Game/data/fonts/penguin_attack_license.txt b/Game/data/fonts/penguin_attack_license.txt new file mode 100644 index 0000000..b3e5b5e --- /dev/null +++ b/Game/data/fonts/penguin_attack_license.txt
@@ -0,0 +1,365 @@
+Penguin Attack is Copyright (C) 2002 Dustin Norlander
+Homepage: http://www.cheapskatefonts.com
+email: dustin@dustismo.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.
+
+
+
+-------------------------------------------------------------------------------
+
+
+
+
+
+ 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.
+
+
diff --git a/Game/data/fonts/penguinattack.ttf b/Game/data/fonts/penguinattack.ttf new file mode 100644 index 0000000..622ae2d
Binary files /dev/null and b/Game/data/fonts/penguinattack.ttf differ
diff --git a/Game/data/music/bgmusic.ogg b/Game/data/music/bgmusic.ogg new file mode 100644 index 0000000..562b4bb
Binary files /dev/null and b/Game/data/music/bgmusic.ogg differ
diff --git a/Game/data/music/highbeat.ogg b/Game/data/music/highbeat.ogg new file mode 100644 index 0000000..3d21dae
Binary files /dev/null and b/Game/data/music/highbeat.ogg differ
diff --git a/Game/data/puzzles/copy b/Game/data/puzzles/copy new file mode 100755 index 0000000..9617703 --- /dev/null +++ b/Game/data/puzzles/copy
@@ -0,0 +1,339 @@
+26
+1
+-1 -1 -1 -1 -1 -1
+-1 -1 -1 -1 -1 -1
+-1 -1 -1 -1 -1 -1
+-1 -1 -1 -1 -1 -1
+-1 -1 -1 -1 -1 -1
+-1 -1 -1 -1 -1 -1
+-1 -1 -1 -1 -1 -1
+-1 -1 -1 -1 -1 -1
+-1 -1 -1 -1 -1 -1
+-1 -1 -1 -1 -1 -1
+-1 -1 1 1 -1 -1
+-1 1 0 0 -1 0
+1
+-1 -1 -1 -1 -1 -1
+-1 -1 -1 -1 -1 -1
+-1 -1 -1 -1 -1 -1
+-1 -1 -1 -1 -1 -1
+-1 -1 -1 -1 -1 -1
+-1 -1 -1 -1 -1 -1
+-1 -1 -1 -1 -1 -1
+-1 0 -1 4 -1 -1
+-1 3 4 2 -1 -1
+-1 3 0 0 -1 -1
+-1 0 2 2 -1 -1
+-1 3 0 0 4 -1
+2
+-1 -1 -1 -1 -1 -1
+-1 -1 -1 -1 -1 -1
+-1 -1 -1 -1 -1 -1
+-1 -1 -1 -1 -1 -1
+-1 -1 -1 -1 -1 -1
+-1 -1 -1 -1 -1 -1
+-1 -1 -1 -1 -1 -1
+-1 -1 0 1 -1 -1
+-1 -1 0 1 -1 -1
+-1 -1 1 0 -1 -1
+-1 -1 1 0 -1 -1
+-1 -1 0 1 -1 -1
+2
+-1 -1 -1 -1 -1 -1
+-1 -1 -1 -1 -1 -1
+-1 -1 -1 -1 -1 -1
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1 -1 -1 -1 -1 -1
+-1 -1 -1 -1 -1 -1
+-1 -1 -1 -1 -1 -1
+-1 -1 -1 -1 -1 -1
+-1 -1 -1 3 -1 -1
+-1 -1 -1 1 -1 -1
+-1 -1 1 1 -1 -1
+-1 -1 4 4 -1 -1
+-1 4 0 0 -1 -1
+-1 0 3 3 -1 -1
diff --git a/Game/data/sounds/applause.ogg b/Game/data/sounds/applause.ogg new file mode 100644 index 0000000..39ba789
Binary files /dev/null and b/Game/data/sounds/applause.ogg differ
diff --git a/Game/data/sounds/cameraclick.ogg b/Game/data/sounds/cameraclick.ogg new file mode 100644 index 0000000..0c1f9a9
Binary files /dev/null and b/Game/data/sounds/cameraclick.ogg differ
diff --git a/Game/data/sounds/counter.ogg b/Game/data/sounds/counter.ogg new file mode 100644 index 0000000..0eb3b4d
Binary files /dev/null and b/Game/data/sounds/counter.ogg differ
diff --git a/Game/data/sounds/counter_final.ogg b/Game/data/sounds/counter_final.ogg new file mode 100644 index 0000000..f76ba7c
Binary files /dev/null and b/Game/data/sounds/counter_final.ogg differ
diff --git a/Game/data/sounds/pop.ogg b/Game/data/sounds/pop.ogg new file mode 100644 index 0000000..9e9fc51
Binary files /dev/null and b/Game/data/sounds/pop.ogg differ
diff --git a/Game/data/sounds/typing.ogg b/Game/data/sounds/typing.ogg new file mode 100644 index 0000000..83d95c9
Binary files /dev/null and b/Game/data/sounds/typing.ogg differ
diff --git a/Game/data/sprites/blockattack.sprite b/Game/data/sprites/blockattack.sprite new file mode 100644 index 0000000..db83ba8 --- /dev/null +++ b/Game/data/sprites/blockattack.sprite
@@ -0,0 +1,171 @@
+//This file contains the difinition of all sprites
+//The file is in json-format but with support for C++-style comments
+
+{
+
+//This is the fallback sprite that are used if the game request a sprite not in any file
+"fallback" : {
+ "texture" : "fallback",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 64,
+ "width" : 64,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+
+"backboard" : {
+ "texture" : "back_board",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 600,
+ "width" : 300,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+
+"background" : {
+ "texture" : "background",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 768,
+ "width" : 1024,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+
+"bexit" : {
+ "texture" : "b_exit",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 100,
+ "width" : 100,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+
+"block_blue" : {
+ "texture" : "blue",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+
+"block_bomb" : {
+ "texture" : "bomb",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 2,
+ "frame_time" : 150
+},
+
+"block_green" : {
+ "texture" : "green",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+
+"block_grey" : {
+ "texture" : "grey",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+
+"block_purple" : {
+ "texture" : "purple",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+
+"block_ready" : {
+ "texture" : "ready",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 2,
+ "frame_time" : 500
+},
+
+"block_red" : {
+ "texture" : "red",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+
+"block_trans" : {
+ "texture" : "trans_cover",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+
+"block_turkish" : {
+ "texture" : "turkish",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+
+"block_yellow" : {
+ "texture" : "yellow",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+
+"boardbackback" : {
+ "texture" : "board_back_back",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 699,
+ "width" : 476,
+ "number_of_frames" : 1,
+ "frame_time" : 1,
+ "originx" : 57,
+ "originy" : 72
+},
+
+"cursor" : {
+ "texture" : "cursor",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 58,
+ "width" : 108,
+ "number_of_frames" : 2,
+ "frame_time" : 400,
+ "originx" : 4, //This tells the game that the top left corner is placed a little different
+ "originy" : 4
+}
+
+}
diff --git a/Game/data/sprites/blockattack1.sprite b/Game/data/sprites/blockattack1.sprite new file mode 100644 index 0000000..78b7567 --- /dev/null +++ b/Game/data/sprites/blockattack1.sprite
@@ -0,0 +1,626 @@
+//This file simply contains all the images for now.
+
+{
+"back_board" : {
+ "texture" : "back_board",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 600,
+ "width" : 300,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"background" : {
+ "texture" : "background",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 768,
+ "width" : 1024,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"ball_blue" : {
+ "texture" : "ball_blue",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 16,
+ "width" : 16,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"ball_gray" : {
+ "texture" : "ball_gray",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 16,
+ "width" : 16,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"ball_green" : {
+ "texture" : "ball_green",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 16,
+ "width" : 16,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"ball_purple" : {
+ "texture" : "ball_purple",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 16,
+ "width" : 16,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"ball_red" : {
+ "texture" : "ball_red",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 16,
+ "width" : 16,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"ball_turkish" : {
+ "texture" : "ball_turkish",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 16,
+ "width" : 16,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"ball_yellow" : {
+ "texture" : "ball_yellow",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 16,
+ "width" : 16,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"b_blank" : {
+ "texture" : "b_blank",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 40,
+ "width" : 120,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"b_exit" : {
+ "texture" : "b_exit",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 100,
+ "width" : 100,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"b_highscore" : {
+ "texture" : "b_highscore",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 40,
+ "width" : 120,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"black_back_ground" : {
+ "texture" : "black_back_ground",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 768,
+ "width" : 1024,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"black_line" : {
+ "texture" : "black_line",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 2,
+ "width" : 300,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"blue" : {
+ "texture" : "blue",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"board_back_back" : {
+ "texture" : "board_back_back",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 699,
+ "width" : 476,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"bomb" : {
+ "texture" : "bomb",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 100,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"chain_frame" : {
+ "texture" : "chain_frame",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 25,
+ "width" : 25,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"counter_1" : {
+ "texture" : "counter_1",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 100,
+ "width" : 100,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"counter_2" : {
+ "texture" : "counter_2",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 100,
+ "width" : 100,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"counter_3" : {
+ "texture" : "counter_3",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 100,
+ "width" : 100,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"crossover" : {
+ "texture" : "crossover",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"dialogbox" : {
+ "texture" : "dialogbox",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 200,
+ "width" : 600,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"explosion0" : {
+ "texture" : "explosion0",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 64,
+ "width" : 64,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"explosion1" : {
+ "texture" : "explosion1",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 64,
+ "width" : 64,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"explosion2" : {
+ "texture" : "explosion2",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 64,
+ "width" : 64,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"explosion3" : {
+ "texture" : "explosion3",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 64,
+ "width" : 64,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"fallback" : {
+ "texture" : "fallback",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 64,
+ "width" : 64,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"fileDialogbox" : {
+ "texture" : "fileDialogbox",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 200,
+ "width" : 600,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"garbage_bl" : {
+ "texture" : "garbage_bl",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"garbage_b" : {
+ "texture" : "garbage_b",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"garbage_br" : {
+ "texture" : "garbage_br",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"garbage_fill" : {
+ "texture" : "garbage_fill",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"garbage_gml" : {
+ "texture" : "garbage_gml",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"garbage_gm" : {
+ "texture" : "garbage_gm",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"garbage_gmr" : {
+ "texture" : "garbage_gmr",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"garbage_l" : {
+ "texture" : "garbage_l",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"garbage_ml" : {
+ "texture" : "garbage_ml",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"garbage_m" : {
+ "texture" : "garbage_m",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"garbage_mr" : {
+ "texture" : "garbage_mr",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"garbage_r" : {
+ "texture" : "garbage_r",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"garbage_tl" : {
+ "texture" : "garbage_tl",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"garbage_t" : {
+ "texture" : "garbage_t",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"garbage_tr" : {
+ "texture" : "garbage_tr",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"green" : {
+ "texture" : "green",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"grey" : {
+ "texture" : "grey",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"i_check_box_area" : {
+ "texture" : "i_check_box_area",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 300,
+ "width" : 500,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"icon" : {
+ "texture" : "icon",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 32,
+ "width" : 32,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"i_draw" : {
+ "texture" : "i_draw",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 100,
+ "width" : 300,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"i_game_over" : {
+ "texture" : "i_game_over",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 100,
+ "width" : 300,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"i_level_check_box_marked" : {
+ "texture" : "i_level_check_box_marked",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 30,
+ "width" : 30,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"i_level_check_box" : {
+ "texture" : "i_level_check_box",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 30,
+ "width" : 30,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"i_level_check" : {
+ "texture" : "i_level_check",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 30,
+ "width" : 30,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"i_loser" : {
+ "texture" : "i_loser",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 100,
+ "width" : 300,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"i_stage_clear_limit" : {
+ "texture" : "i_stage_clear_limit",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 140,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"i_winner" : {
+ "texture" : "i_winner",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 100,
+ "width" : 300,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"menu_marked" : {
+ "texture" : "menu_marked",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 60,
+ "width" : 600,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"menu_unmarked" : {
+ "texture" : "menu_unmarked",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 60,
+ "width" : 600,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"mouse" : {
+ "texture" : "mouse",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 32,
+ "width" : 32,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"purple" : {
+ "texture" : "purple",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"ready" : {
+ "texture" : "ready",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 100,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"red" : {
+ "texture" : "red",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"smileys0" : {
+ "texture" : "smileys0",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 100,
+ "width" : 100,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"smileys1" : {
+ "texture" : "smileys1",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 100,
+ "width" : 100,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"smileys2" : {
+ "texture" : "smileys2",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 100,
+ "width" : 100,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"smileys3" : {
+ "texture" : "smileys3",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 100,
+ "width" : 100,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"trans_cover" : {
+ "texture" : "trans_cover",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"turkish" : {
+ "texture" : "turkish",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+},
+"yellow" : {
+ "texture" : "yellow",
+ "topx" : 0,
+ "topy" : 0,
+ "height" : 50,
+ "width" : 50,
+ "number_of_frames" : 1,
+ "frame_time" : 1
+}
+
+}
diff --git a/Game/data/textures/b_blank.png b/Game/data/textures/b_blank.png new file mode 100644 index 0000000..16803bf
Binary files /dev/null and b/Game/data/textures/b_blank.png differ
diff --git a/Game/data/textures/b_exit.png b/Game/data/textures/b_exit.png new file mode 100755 index 0000000..d22bfe3
Binary files /dev/null and b/Game/data/textures/b_exit.png differ
diff --git a/Game/data/textures/b_highscore.png b/Game/data/textures/b_highscore.png new file mode 100755 index 0000000..028611a
Binary files /dev/null and b/Game/data/textures/b_highscore.png differ
diff --git a/Game/data/textures/back_board.png b/Game/data/textures/back_board.png new file mode 100755 index 0000000..1043816
Binary files /dev/null and b/Game/data/textures/back_board.png differ
diff --git a/Game/data/textures/background.png b/Game/data/textures/background.png new file mode 100755 index 0000000..9d48c07
Binary files /dev/null and b/Game/data/textures/background.png differ
diff --git a/Game/data/textures/ball_blue.png b/Game/data/textures/ball_blue.png new file mode 100755 index 0000000..b499d88
Binary files /dev/null and b/Game/data/textures/ball_blue.png differ
diff --git a/Game/data/textures/ball_gray.png b/Game/data/textures/ball_gray.png new file mode 100755 index 0000000..b5cb6c1
Binary files /dev/null and b/Game/data/textures/ball_gray.png differ
diff --git a/Game/data/textures/ball_green.png b/Game/data/textures/ball_green.png new file mode 100755 index 0000000..329873a
Binary files /dev/null and b/Game/data/textures/ball_green.png differ
diff --git a/Game/data/textures/ball_purple.png b/Game/data/textures/ball_purple.png new file mode 100755 index 0000000..fb20f6a
Binary files /dev/null and b/Game/data/textures/ball_purple.png differ
diff --git a/Game/data/textures/ball_red.png b/Game/data/textures/ball_red.png new file mode 100755 index 0000000..4451b21
Binary files /dev/null and b/Game/data/textures/ball_red.png differ
diff --git a/Game/data/textures/ball_turkish.png b/Game/data/textures/ball_turkish.png new file mode 100755 index 0000000..60fb0bf
Binary files /dev/null and b/Game/data/textures/ball_turkish.png differ
diff --git a/Game/data/textures/ball_yellow.png b/Game/data/textures/ball_yellow.png new file mode 100755 index 0000000..7f4720e
Binary files /dev/null and b/Game/data/textures/ball_yellow.png differ
diff --git a/Game/data/textures/black_back_ground.png b/Game/data/textures/black_back_ground.png new file mode 100755 index 0000000..1d13c39
Binary files /dev/null and b/Game/data/textures/black_back_ground.png differ
diff --git a/Game/data/textures/black_line.png b/Game/data/textures/black_line.png new file mode 100755 index 0000000..8fd8d31
Binary files /dev/null and b/Game/data/textures/black_line.png differ
diff --git a/Game/data/textures/blue.png b/Game/data/textures/blue.png new file mode 100755 index 0000000..a6520c9
Binary files /dev/null and b/Game/data/textures/blue.png differ
diff --git a/Game/data/textures/board_back_back.png b/Game/data/textures/board_back_back.png new file mode 100755 index 0000000..df77014
Binary files /dev/null and b/Game/data/textures/board_back_back.png differ
diff --git a/Game/data/textures/bomb.png b/Game/data/textures/bomb.png new file mode 100644 index 0000000..cbd6a8e
Binary files /dev/null and b/Game/data/textures/bomb.png differ
diff --git a/Game/data/textures/chain_frame.png b/Game/data/textures/chain_frame.png new file mode 100755 index 0000000..52aadb6
Binary files /dev/null and b/Game/data/textures/chain_frame.png differ
diff --git a/Game/data/textures/counter_1.png b/Game/data/textures/counter_1.png new file mode 100755 index 0000000..f66e7ee
Binary files /dev/null and b/Game/data/textures/counter_1.png differ
diff --git a/Game/data/textures/counter_2.png b/Game/data/textures/counter_2.png new file mode 100755 index 0000000..eb13c50
Binary files /dev/null and b/Game/data/textures/counter_2.png differ
diff --git a/Game/data/textures/counter_3.png b/Game/data/textures/counter_3.png new file mode 100755 index 0000000..ffa5161
Binary files /dev/null and b/Game/data/textures/counter_3.png differ
diff --git a/Game/data/textures/crossover.png b/Game/data/textures/crossover.png new file mode 100755 index 0000000..14693a7
Binary files /dev/null and b/Game/data/textures/crossover.png differ
diff --git a/Game/data/textures/cursor.png b/Game/data/textures/cursor.png new file mode 100644 index 0000000..2936d40
Binary files /dev/null and b/Game/data/textures/cursor.png differ
diff --git a/Game/data/textures/dialogbox.png b/Game/data/textures/dialogbox.png new file mode 100755 index 0000000..a3e4402
Binary files /dev/null and b/Game/data/textures/dialogbox.png differ
diff --git a/Game/data/textures/explosion0.png b/Game/data/textures/explosion0.png new file mode 100755 index 0000000..750c1ac
Binary files /dev/null and b/Game/data/textures/explosion0.png differ
diff --git a/Game/data/textures/explosion1.png b/Game/data/textures/explosion1.png new file mode 100755 index 0000000..8011847
Binary files /dev/null and b/Game/data/textures/explosion1.png differ
diff --git a/Game/data/textures/explosion2.png b/Game/data/textures/explosion2.png new file mode 100755 index 0000000..6f873ad
Binary files /dev/null and b/Game/data/textures/explosion2.png differ
diff --git a/Game/data/textures/explosion3.png b/Game/data/textures/explosion3.png new file mode 100755 index 0000000..d021f28
Binary files /dev/null and b/Game/data/textures/explosion3.png differ
diff --git a/Game/data/textures/fallback.png b/Game/data/textures/fallback.png new file mode 100644 index 0000000..a4ca1d5
Binary files /dev/null and b/Game/data/textures/fallback.png differ
diff --git a/Game/data/textures/fileDialogbox.png b/Game/data/textures/fileDialogbox.png new file mode 100755 index 0000000..b54d692
Binary files /dev/null and b/Game/data/textures/fileDialogbox.png differ
diff --git a/Game/data/textures/garbage_b.png b/Game/data/textures/garbage_b.png new file mode 100755 index 0000000..e050fd4
Binary files /dev/null and b/Game/data/textures/garbage_b.png differ
diff --git a/Game/data/textures/garbage_bl.png b/Game/data/textures/garbage_bl.png new file mode 100755 index 0000000..4710dc9
Binary files /dev/null and b/Game/data/textures/garbage_bl.png differ
diff --git a/Game/data/textures/garbage_br.png b/Game/data/textures/garbage_br.png new file mode 100755 index 0000000..6e736f6
Binary files /dev/null and b/Game/data/textures/garbage_br.png differ
diff --git a/Game/data/textures/garbage_fill.png b/Game/data/textures/garbage_fill.png new file mode 100755 index 0000000..8882022
Binary files /dev/null and b/Game/data/textures/garbage_fill.png differ
diff --git a/Game/data/textures/garbage_gm.png b/Game/data/textures/garbage_gm.png new file mode 100755 index 0000000..03d737c
Binary files /dev/null and b/Game/data/textures/garbage_gm.png differ
diff --git a/Game/data/textures/garbage_gml.png b/Game/data/textures/garbage_gml.png new file mode 100755 index 0000000..596cf2a
Binary files /dev/null and b/Game/data/textures/garbage_gml.png differ
diff --git a/Game/data/textures/garbage_gmr.png b/Game/data/textures/garbage_gmr.png new file mode 100755 index 0000000..aed2c55
Binary files /dev/null and b/Game/data/textures/garbage_gmr.png differ
diff --git a/Game/data/textures/garbage_l.png b/Game/data/textures/garbage_l.png new file mode 100755 index 0000000..830e44c
Binary files /dev/null and b/Game/data/textures/garbage_l.png differ
diff --git a/Game/data/textures/garbage_m.png b/Game/data/textures/garbage_m.png new file mode 100755 index 0000000..918affd
Binary files /dev/null and b/Game/data/textures/garbage_m.png differ
diff --git a/Game/data/textures/garbage_ml.png b/Game/data/textures/garbage_ml.png new file mode 100755 index 0000000..0a97f62
Binary files /dev/null and b/Game/data/textures/garbage_ml.png differ
diff --git a/Game/data/textures/garbage_mr.png b/Game/data/textures/garbage_mr.png new file mode 100755 index 0000000..6707ecd
Binary files /dev/null and b/Game/data/textures/garbage_mr.png differ
diff --git a/Game/data/textures/garbage_r.png b/Game/data/textures/garbage_r.png new file mode 100755 index 0000000..30958b3
Binary files /dev/null and b/Game/data/textures/garbage_r.png differ
diff --git a/Game/data/textures/garbage_t.png b/Game/data/textures/garbage_t.png new file mode 100755 index 0000000..13e2f1c
Binary files /dev/null and b/Game/data/textures/garbage_t.png differ
diff --git a/Game/data/textures/garbage_tl.png b/Game/data/textures/garbage_tl.png new file mode 100755 index 0000000..cbd8e4e
Binary files /dev/null and b/Game/data/textures/garbage_tl.png differ
diff --git a/Game/data/textures/garbage_tr.png b/Game/data/textures/garbage_tr.png new file mode 100755 index 0000000..e0ed203
Binary files /dev/null and b/Game/data/textures/garbage_tr.png differ
diff --git a/Game/data/textures/green.png b/Game/data/textures/green.png new file mode 100755 index 0000000..79b604a
Binary files /dev/null and b/Game/data/textures/green.png differ
diff --git a/Game/data/textures/grey.png b/Game/data/textures/grey.png new file mode 100755 index 0000000..91451d7
Binary files /dev/null and b/Game/data/textures/grey.png differ
diff --git a/Game/data/textures/i_check_box_area.png b/Game/data/textures/i_check_box_area.png new file mode 100755 index 0000000..66d0fbb
Binary files /dev/null and b/Game/data/textures/i_check_box_area.png differ
diff --git a/Game/data/textures/i_draw.png b/Game/data/textures/i_draw.png new file mode 100755 index 0000000..3881038
Binary files /dev/null and b/Game/data/textures/i_draw.png differ
diff --git a/Game/data/textures/i_game_over.png b/Game/data/textures/i_game_over.png new file mode 100755 index 0000000..0dd2133
Binary files /dev/null and b/Game/data/textures/i_game_over.png differ
diff --git a/Game/data/textures/i_level_check.png b/Game/data/textures/i_level_check.png new file mode 100755 index 0000000..01eb8fe
Binary files /dev/null and b/Game/data/textures/i_level_check.png differ
diff --git a/Game/data/textures/i_level_check_box.png b/Game/data/textures/i_level_check_box.png new file mode 100755 index 0000000..4f0aa0b
Binary files /dev/null and b/Game/data/textures/i_level_check_box.png differ
diff --git a/Game/data/textures/i_level_check_box_marked.png b/Game/data/textures/i_level_check_box_marked.png new file mode 100755 index 0000000..afa580a
Binary files /dev/null and b/Game/data/textures/i_level_check_box_marked.png differ
diff --git a/Game/data/textures/i_loser.png b/Game/data/textures/i_loser.png new file mode 100755 index 0000000..d84fd68
Binary files /dev/null and b/Game/data/textures/i_loser.png differ
diff --git a/Game/data/textures/i_stage_clear_limit.png b/Game/data/textures/i_stage_clear_limit.png new file mode 100755 index 0000000..d70b6ea
Binary files /dev/null and b/Game/data/textures/i_stage_clear_limit.png differ
diff --git a/Game/data/textures/i_winner.png b/Game/data/textures/i_winner.png new file mode 100755 index 0000000..e6b012e
Binary files /dev/null and b/Game/data/textures/i_winner.png differ
diff --git a/Game/data/textures/icon.png b/Game/data/textures/icon.png new file mode 100755 index 0000000..c6d5181
Binary files /dev/null and b/Game/data/textures/icon.png differ
diff --git a/Game/data/textures/menu_marked.png b/Game/data/textures/menu_marked.png new file mode 100644 index 0000000..9ed8a14
Binary files /dev/null and b/Game/data/textures/menu_marked.png differ
diff --git a/Game/data/textures/menu_unmarked.png b/Game/data/textures/menu_unmarked.png new file mode 100644 index 0000000..39132db
Binary files /dev/null and b/Game/data/textures/menu_unmarked.png differ
diff --git a/Game/data/textures/mouse.png b/Game/data/textures/mouse.png new file mode 100755 index 0000000..0ee7026
Binary files /dev/null and b/Game/data/textures/mouse.png differ
diff --git a/Game/data/textures/purple.png b/Game/data/textures/purple.png new file mode 100755 index 0000000..c6c1c87
Binary files /dev/null and b/Game/data/textures/purple.png differ
diff --git a/Game/data/textures/ready.png b/Game/data/textures/ready.png new file mode 100644 index 0000000..de22ef2
Binary files /dev/null and b/Game/data/textures/ready.png differ
diff --git a/Game/data/textures/red.png b/Game/data/textures/red.png new file mode 100755 index 0000000..c8359bf
Binary files /dev/null and b/Game/data/textures/red.png differ
diff --git a/Game/data/textures/smileys0.png b/Game/data/textures/smileys0.png new file mode 100755 index 0000000..7d0c1c6
Binary files /dev/null and b/Game/data/textures/smileys0.png differ
diff --git a/Game/data/textures/smileys1.png b/Game/data/textures/smileys1.png new file mode 100755 index 0000000..be367bd
Binary files /dev/null and b/Game/data/textures/smileys1.png differ
diff --git a/Game/data/textures/smileys2.png b/Game/data/textures/smileys2.png new file mode 100755 index 0000000..636ded7
Binary files /dev/null and b/Game/data/textures/smileys2.png differ
diff --git a/Game/data/textures/smileys3.png b/Game/data/textures/smileys3.png new file mode 100755 index 0000000..aa1d0db
Binary files /dev/null and b/Game/data/textures/smileys3.png differ
diff --git a/Game/data/textures/trans_cover.png b/Game/data/textures/trans_cover.png new file mode 100644 index 0000000..ddbad2f
Binary files /dev/null and b/Game/data/textures/trans_cover.png differ
diff --git a/Game/data/textures/turkish.png b/Game/data/textures/turkish.png new file mode 100755 index 0000000..f59e812
Binary files /dev/null and b/Game/data/textures/turkish.png differ
diff --git a/Game/data/textures/yellow.png b/Game/data/textures/yellow.png new file mode 100755 index 0000000..524ac66
Binary files /dev/null and b/Game/data/textures/yellow.png differ
diff --git a/Game/fonts/FreeSerif.ttf b/Game/fonts/FreeSerif.ttf deleted file mode 100644 index 2f3dfc3..0000000
Binary files a/Game/fonts/FreeSerif.ttf and /dev/null differ
diff --git a/Game/fonts/PenguinAttack.ttf b/Game/fonts/PenguinAttack.ttf deleted file mode 100644 index 622ae2d..0000000
Binary files a/Game/fonts/PenguinAttack.ttf and /dev/null differ
diff --git a/Game/fonts/penguin_attack_license.txt b/Game/fonts/penguin_attack_license.txt deleted file mode 100644 index b3e5b5e..0000000 --- a/Game/fonts/penguin_attack_license.txt +++ /dev/null
@@ -1,365 +0,0 @@
-Penguin Attack is Copyright (C) 2002 Dustin Norlander
-Homepage: http://www.cheapskatefonts.com
-email: dustin@dustismo.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.
-
-
-
--------------------------------------------------------------------------------
-
-
-
-
-
- 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.
-
-
diff --git a/Game/gfx/BackBoard.png b/Game/gfx/BackBoard.png deleted file mode 100755 index 1043816..0000000
Binary files a/Game/gfx/BackBoard.png and /dev/null differ
diff --git a/Game/gfx/animations/explosion/0.png b/Game/gfx/animations/explosion/0.png deleted file mode 100755 index 750c1ac..0000000
Binary files a/Game/gfx/animations/explosion/0.png and /dev/null differ
diff --git a/Game/gfx/animations/explosion/1.png b/Game/gfx/animations/explosion/1.png deleted file mode 100755 index 8011847..0000000
Binary files a/Game/gfx/animations/explosion/1.png and /dev/null differ
diff --git a/Game/gfx/animations/explosion/2.png b/Game/gfx/animations/explosion/2.png deleted file mode 100755 index 6f873ad..0000000
Binary files a/Game/gfx/animations/explosion/2.png and /dev/null differ
diff --git a/Game/gfx/animations/explosion/3.png b/Game/gfx/animations/explosion/3.png deleted file mode 100755 index d021f28..0000000
Binary files a/Game/gfx/animations/explosion/3.png and /dev/null differ
diff --git a/Game/gfx/b1024.png b/Game/gfx/b1024.png deleted file mode 100755 index 5707fb3..0000000
Binary files a/Game/gfx/b1024.png and /dev/null differ
diff --git a/Game/gfx/bBack.png b/Game/gfx/bBack.png deleted file mode 100755 index 9bbe840..0000000
Binary files a/Game/gfx/bBack.png and /dev/null differ
diff --git a/Game/gfx/bBlank.png b/Game/gfx/bBlank.png deleted file mode 100644 index 16803bf..0000000
Binary files a/Game/gfx/bBlank.png and /dev/null differ
diff --git a/Game/gfx/bChange.png b/Game/gfx/bChange.png deleted file mode 100755 index 4db0cf1..0000000
Binary files a/Game/gfx/bChange.png and /dev/null differ
diff --git a/Game/gfx/bConfigure.png b/Game/gfx/bConfigure.png deleted file mode 100755 index 2d69ab9..0000000
Binary files a/Game/gfx/bConfigure.png and /dev/null differ
diff --git a/Game/gfx/bConnect.png b/Game/gfx/bConnect.png deleted file mode 100755 index 2e11b93..0000000
Binary files a/Game/gfx/bConnect.png and /dev/null differ
diff --git a/Game/gfx/bEndless.png b/Game/gfx/bEndless.png deleted file mode 100755 index 2bde2db..0000000
Binary files a/Game/gfx/bEndless.png and /dev/null differ
diff --git a/Game/gfx/bExit.png b/Game/gfx/bExit.png deleted file mode 100755 index d22bfe3..0000000
Binary files a/Game/gfx/bExit.png and /dev/null differ
diff --git a/Game/gfx/bForward.png b/Game/gfx/bForward.png deleted file mode 100755 index fbfcb0b..0000000
Binary files a/Game/gfx/bForward.png and /dev/null differ
diff --git a/Game/gfx/bHighScore.png b/Game/gfx/bHighScore.png deleted file mode 100755 index 028611a..0000000
Binary files a/Game/gfx/bHighScore.png and /dev/null differ
diff --git a/Game/gfx/bHost.png b/Game/gfx/bHost.png deleted file mode 100755 index e68036c..0000000
Binary files a/Game/gfx/bHost.png and /dev/null differ
diff --git a/Game/gfx/bHowToPlay.png b/Game/gfx/bHowToPlay.png deleted file mode 100755 index 8c94b10..0000000
Binary files a/Game/gfx/bHowToPlay.png and /dev/null differ
diff --git a/Game/gfx/bInternet.png b/Game/gfx/bInternet.png deleted file mode 100755 index a47b30f..0000000
Binary files a/Game/gfx/bInternet.png and /dev/null differ
diff --git a/Game/gfx/bLoad.png b/Game/gfx/bLoad.png deleted file mode 100755 index 86f4bb9..0000000
Binary files a/Game/gfx/bLoad.png and /dev/null differ
diff --git a/Game/gfx/bNetwork.png b/Game/gfx/bNetwork.png deleted file mode 100755 index 8f7723f..0000000
Binary files a/Game/gfx/bNetwork.png and /dev/null differ
diff --git a/Game/gfx/bNewGame.png b/Game/gfx/bNewGame.png deleted file mode 100755 index b6e3a40..0000000
Binary files a/Game/gfx/bNewGame.png and /dev/null differ
diff --git a/Game/gfx/bNext.png b/Game/gfx/bNext.png deleted file mode 100644 index c0172dd..0000000
Binary files a/Game/gfx/bNext.png and /dev/null differ
diff --git a/Game/gfx/bOff.png b/Game/gfx/bOff.png deleted file mode 100755 index 3dc5ead..0000000
Binary files a/Game/gfx/bOff.png and /dev/null differ
diff --git a/Game/gfx/bOn.png b/Game/gfx/bOn.png deleted file mode 100755 index ee97b5b..0000000
Binary files a/Game/gfx/bOn.png and /dev/null differ
diff --git a/Game/gfx/bOnePlayer.png b/Game/gfx/bOnePlayer.png deleted file mode 100755 index 6f70e4b..0000000
Binary files a/Game/gfx/bOnePlayer.png and /dev/null differ
diff --git a/Game/gfx/bOptions.png b/Game/gfx/bOptions.png deleted file mode 100755 index fb1ac4a..0000000
Binary files a/Game/gfx/bOptions.png and /dev/null differ
diff --git a/Game/gfx/bPuzzle.png b/Game/gfx/bPuzzle.png deleted file mode 100755 index 0557ab9..0000000
Binary files a/Game/gfx/bPuzzle.png and /dev/null differ
diff --git a/Game/gfx/bReplays.png b/Game/gfx/bReplays.png deleted file mode 100755 index 8871646..0000000
Binary files a/Game/gfx/bReplays.png and /dev/null differ
diff --git a/Game/gfx/bRetry.png b/Game/gfx/bRetry.png deleted file mode 100644 index a54f4e9..0000000
Binary files a/Game/gfx/bRetry.png and /dev/null differ
diff --git a/Game/gfx/bSave.png b/Game/gfx/bSave.png deleted file mode 100755 index 68ccc26..0000000
Binary files a/Game/gfx/bSave.png and /dev/null differ
diff --git a/Game/gfx/bSelectPuzzle.png b/Game/gfx/bSelectPuzzle.png deleted file mode 100755 index bff7802..0000000
Binary files a/Game/gfx/bSelectPuzzle.png and /dev/null differ
diff --git a/Game/gfx/bSkip.png b/Game/gfx/bSkip.png deleted file mode 100644 index 02feb60..0000000
Binary files a/Game/gfx/bSkip.png and /dev/null differ
diff --git a/Game/gfx/bStageClear.png b/Game/gfx/bStageClear.png deleted file mode 100755 index c1e7596..0000000
Binary files a/Game/gfx/bStageClear.png and /dev/null differ
diff --git a/Game/gfx/bTheme.png b/Game/gfx/bTheme.png deleted file mode 100644 index b581ac1..0000000
Binary files a/Game/gfx/bTheme.png and /dev/null differ
diff --git a/Game/gfx/bTimeTrial.png b/Game/gfx/bTimeTrial.png deleted file mode 100755 index 474f06c..0000000
Binary files a/Game/gfx/bTimeTrial.png and /dev/null differ
diff --git a/Game/gfx/bTwoPlayers.png b/Game/gfx/bTwoPlayers.png deleted file mode 100755 index 4296009..0000000
Binary files a/Game/gfx/bTwoPlayers.png and /dev/null differ
diff --git a/Game/gfx/bVsGame.png b/Game/gfx/bVsGame.png deleted file mode 100755 index f50a4ef..0000000
Binary files a/Game/gfx/bVsGame.png and /dev/null differ
diff --git a/Game/gfx/bVsGameConfig.png b/Game/gfx/bVsGameConfig.png deleted file mode 100755 index e582b6f..0000000
Binary files a/Game/gfx/bVsGameConfig.png and /dev/null differ
diff --git a/Game/gfx/background.png b/Game/gfx/background.png deleted file mode 100755 index 9d48c07..0000000
Binary files a/Game/gfx/background.png and /dev/null differ
diff --git a/Game/gfx/balls/ballBlue.png b/Game/gfx/balls/ballBlue.png deleted file mode 100755 index b499d88..0000000
Binary files a/Game/gfx/balls/ballBlue.png and /dev/null differ
diff --git a/Game/gfx/balls/ballGray.png b/Game/gfx/balls/ballGray.png deleted file mode 100755 index b5cb6c1..0000000
Binary files a/Game/gfx/balls/ballGray.png and /dev/null differ
diff --git a/Game/gfx/balls/ballGreen.png b/Game/gfx/balls/ballGreen.png deleted file mode 100755 index 329873a..0000000
Binary files a/Game/gfx/balls/ballGreen.png and /dev/null differ
diff --git a/Game/gfx/balls/ballPurple.png b/Game/gfx/balls/ballPurple.png deleted file mode 100755 index fb20f6a..0000000
Binary files a/Game/gfx/balls/ballPurple.png and /dev/null differ
diff --git a/Game/gfx/balls/ballRed.png b/Game/gfx/balls/ballRed.png deleted file mode 100755 index 4451b21..0000000
Binary files a/Game/gfx/balls/ballRed.png and /dev/null differ
diff --git a/Game/gfx/balls/ballTurkish.png b/Game/gfx/balls/ballTurkish.png deleted file mode 100755 index 60fb0bf..0000000
Binary files a/Game/gfx/balls/ballTurkish.png and /dev/null differ
diff --git a/Game/gfx/balls/ballYellow.png b/Game/gfx/balls/ballYellow.png deleted file mode 100755 index 7f4720e..0000000
Binary files a/Game/gfx/balls/ballYellow.png and /dev/null differ
diff --git a/Game/gfx/blackBackGround.png b/Game/gfx/blackBackGround.png deleted file mode 100755 index 1d13c39..0000000
Binary files a/Game/gfx/blackBackGround.png and /dev/null differ
diff --git a/Game/gfx/blackLine.png b/Game/gfx/blackLine.png deleted file mode 100755 index 8fd8d31..0000000
Binary files a/Game/gfx/blackLine.png and /dev/null differ
diff --git a/Game/gfx/boardBackBack.png b/Game/gfx/boardBackBack.png deleted file mode 100755 index df77014..0000000
Binary files a/Game/gfx/boardBackBack.png and /dev/null differ
diff --git a/Game/gfx/bricks/blue.png b/Game/gfx/bricks/blue.png deleted file mode 100755 index a6520c9..0000000
Binary files a/Game/gfx/bricks/blue.png and /dev/null differ
diff --git a/Game/gfx/bricks/green.png b/Game/gfx/bricks/green.png deleted file mode 100755 index 79b604a..0000000
Binary files a/Game/gfx/bricks/green.png and /dev/null differ
diff --git a/Game/gfx/bricks/grey.png b/Game/gfx/bricks/grey.png deleted file mode 100755 index 91451d7..0000000
Binary files a/Game/gfx/bricks/grey.png and /dev/null differ
diff --git a/Game/gfx/bricks/purple.png b/Game/gfx/bricks/purple.png deleted file mode 100755 index c6c1c87..0000000
Binary files a/Game/gfx/bricks/purple.png and /dev/null differ
diff --git a/Game/gfx/bricks/red.png b/Game/gfx/bricks/red.png deleted file mode 100755 index c8359bf..0000000
Binary files a/Game/gfx/bricks/red.png and /dev/null differ
diff --git a/Game/gfx/bricks/turkish.png b/Game/gfx/bricks/turkish.png deleted file mode 100755 index f59e812..0000000
Binary files a/Game/gfx/bricks/turkish.png and /dev/null differ
diff --git a/Game/gfx/bricks/yellow.png b/Game/gfx/bricks/yellow.png deleted file mode 100755 index 524ac66..0000000
Binary files a/Game/gfx/bricks/yellow.png and /dev/null differ
diff --git a/Game/gfx/chainFrame.png b/Game/gfx/chainFrame.png deleted file mode 100755 index 52aadb6..0000000
Binary files a/Game/gfx/chainFrame.png and /dev/null differ
diff --git a/Game/gfx/changeButtonsBack.png b/Game/gfx/changeButtonsBack.png deleted file mode 100755 index 63986f3..0000000
Binary files a/Game/gfx/changeButtonsBack.png and /dev/null differ
diff --git a/Game/gfx/changeButtonsBack1.png b/Game/gfx/changeButtonsBack1.png deleted file mode 100755 index 349dc1a..0000000
Binary files a/Game/gfx/changeButtonsBack1.png and /dev/null differ
diff --git a/Game/gfx/counter/1.png b/Game/gfx/counter/1.png deleted file mode 100755 index f66e7ee..0000000
Binary files a/Game/gfx/counter/1.png and /dev/null differ
diff --git a/Game/gfx/counter/2.png b/Game/gfx/counter/2.png deleted file mode 100755 index eb13c50..0000000
Binary files a/Game/gfx/counter/2.png and /dev/null differ
diff --git a/Game/gfx/counter/3.png b/Game/gfx/counter/3.png deleted file mode 100755 index ffa5161..0000000
Binary files a/Game/gfx/counter/3.png and /dev/null differ
diff --git a/Game/gfx/crossover.png b/Game/gfx/crossover.png deleted file mode 100755 index 14693a7..0000000
Binary files a/Game/gfx/crossover.png and /dev/null differ
diff --git a/Game/gfx/dialogbox.png b/Game/gfx/dialogbox.png deleted file mode 100755 index a3e4402..0000000
Binary files a/Game/gfx/dialogbox.png and /dev/null differ
diff --git a/Game/gfx/fileDialogbox.png b/Game/gfx/fileDialogbox.png deleted file mode 100755 index b54d692..0000000
Binary files a/Game/gfx/fileDialogbox.png and /dev/null differ
diff --git a/Game/gfx/garbage/garbageB.png b/Game/gfx/garbage/garbageB.png deleted file mode 100755 index e050fd4..0000000
Binary files a/Game/gfx/garbage/garbageB.png and /dev/null differ
diff --git a/Game/gfx/garbage/garbageBL.png b/Game/gfx/garbage/garbageBL.png deleted file mode 100755 index 4710dc9..0000000
Binary files a/Game/gfx/garbage/garbageBL.png and /dev/null differ
diff --git a/Game/gfx/garbage/garbageBR.png b/Game/gfx/garbage/garbageBR.png deleted file mode 100755 index 6e736f6..0000000
Binary files a/Game/gfx/garbage/garbageBR.png and /dev/null differ
diff --git a/Game/gfx/garbage/garbageFill.png b/Game/gfx/garbage/garbageFill.png deleted file mode 100755 index 8882022..0000000
Binary files a/Game/gfx/garbage/garbageFill.png and /dev/null differ
diff --git a/Game/gfx/garbage/garbageGM.png b/Game/gfx/garbage/garbageGM.png deleted file mode 100755 index 03d737c..0000000
Binary files a/Game/gfx/garbage/garbageGM.png and /dev/null differ
diff --git a/Game/gfx/garbage/garbageGML.png b/Game/gfx/garbage/garbageGML.png deleted file mode 100755 index 596cf2a..0000000
Binary files a/Game/gfx/garbage/garbageGML.png and /dev/null differ
diff --git a/Game/gfx/garbage/garbageGMR.png b/Game/gfx/garbage/garbageGMR.png deleted file mode 100755 index aed2c55..0000000
Binary files a/Game/gfx/garbage/garbageGMR.png and /dev/null differ
diff --git a/Game/gfx/garbage/garbageL.png b/Game/gfx/garbage/garbageL.png deleted file mode 100755 index 830e44c..0000000
Binary files a/Game/gfx/garbage/garbageL.png and /dev/null differ
diff --git a/Game/gfx/garbage/garbageM.png b/Game/gfx/garbage/garbageM.png deleted file mode 100755 index 918affd..0000000
Binary files a/Game/gfx/garbage/garbageM.png and /dev/null differ
diff --git a/Game/gfx/garbage/garbageML.png b/Game/gfx/garbage/garbageML.png deleted file mode 100755 index 0a97f62..0000000
Binary files a/Game/gfx/garbage/garbageML.png and /dev/null differ
diff --git a/Game/gfx/garbage/garbageMR.png b/Game/gfx/garbage/garbageMR.png deleted file mode 100755 index 6707ecd..0000000
Binary files a/Game/gfx/garbage/garbageMR.png and /dev/null differ
diff --git a/Game/gfx/garbage/garbageR.png b/Game/gfx/garbage/garbageR.png deleted file mode 100755 index 30958b3..0000000
Binary files a/Game/gfx/garbage/garbageR.png and /dev/null differ
diff --git a/Game/gfx/garbage/garbageT.png b/Game/gfx/garbage/garbageT.png deleted file mode 100755 index 13e2f1c..0000000
Binary files a/Game/gfx/garbage/garbageT.png and /dev/null differ
diff --git a/Game/gfx/garbage/garbageTL.png b/Game/gfx/garbage/garbageTL.png deleted file mode 100755 index cbd8e4e..0000000
Binary files a/Game/gfx/garbage/garbageTL.png and /dev/null differ
diff --git a/Game/gfx/garbage/garbageTR.png b/Game/gfx/garbage/garbageTR.png deleted file mode 100755 index e0ed203..0000000
Binary files a/Game/gfx/garbage/garbageTR.png and /dev/null differ
diff --git a/Game/gfx/iCheckBoxArea.png b/Game/gfx/iCheckBoxArea.png deleted file mode 100755 index 66d0fbb..0000000
Binary files a/Game/gfx/iCheckBoxArea.png and /dev/null differ
diff --git a/Game/gfx/iDraw.png b/Game/gfx/iDraw.png deleted file mode 100755 index 3881038..0000000
Binary files a/Game/gfx/iDraw.png and /dev/null differ
diff --git a/Game/gfx/iGameOver.png b/Game/gfx/iGameOver.png deleted file mode 100755 index 0dd2133..0000000
Binary files a/Game/gfx/iGameOver.png and /dev/null differ
diff --git a/Game/gfx/iLevelCheck.png b/Game/gfx/iLevelCheck.png deleted file mode 100755 index 01eb8fe..0000000
Binary files a/Game/gfx/iLevelCheck.png and /dev/null differ
diff --git a/Game/gfx/iLevelCheckBox.png b/Game/gfx/iLevelCheckBox.png deleted file mode 100755 index 4f0aa0b..0000000
Binary files a/Game/gfx/iLevelCheckBox.png and /dev/null differ
diff --git a/Game/gfx/iLevelCheckBoxMarked.png b/Game/gfx/iLevelCheckBoxMarked.png deleted file mode 100755 index afa580a..0000000
Binary files a/Game/gfx/iLevelCheckBoxMarked.png and /dev/null differ
diff --git a/Game/gfx/iLoser.png b/Game/gfx/iLoser.png deleted file mode 100755 index d84fd68..0000000
Binary files a/Game/gfx/iLoser.png and /dev/null differ
diff --git a/Game/gfx/iStageClearLimit.png b/Game/gfx/iStageClearLimit.png deleted file mode 100755 index d70b6ea..0000000
Binary files a/Game/gfx/iStageClearLimit.png and /dev/null differ
diff --git a/Game/gfx/iWinner.png b/Game/gfx/iWinner.png deleted file mode 100755 index e6b012e..0000000
Binary files a/Game/gfx/iWinner.png and /dev/null differ
diff --git a/Game/gfx/icon.png b/Game/gfx/icon.png deleted file mode 100755 index c6d5181..0000000
Binary files a/Game/gfx/icon.png and /dev/null differ
diff --git a/Game/gfx/menu/marked.png b/Game/gfx/menu/marked.png deleted file mode 100644 index 9ed8a14..0000000
Binary files a/Game/gfx/menu/marked.png and /dev/null differ
diff --git a/Game/gfx/menu/unmarked.png b/Game/gfx/menu/unmarked.png deleted file mode 100644 index 39132db..0000000
Binary files a/Game/gfx/menu/unmarked.png and /dev/null differ
diff --git a/Game/gfx/mouse.png b/Game/gfx/mouse.png deleted file mode 100755 index 0ee7026..0000000
Binary files a/Game/gfx/mouse.png and /dev/null differ
diff --git a/Game/gfx/options.png b/Game/gfx/options.png deleted file mode 100755 index ca9a70a..0000000
Binary files a/Game/gfx/options.png and /dev/null differ
diff --git a/Game/gfx/smileys/0.png b/Game/gfx/smileys/0.png deleted file mode 100755 index 7d0c1c6..0000000
Binary files a/Game/gfx/smileys/0.png and /dev/null differ
diff --git a/Game/gfx/smileys/1.png b/Game/gfx/smileys/1.png deleted file mode 100755 index be367bd..0000000
Binary files a/Game/gfx/smileys/1.png and /dev/null differ
diff --git a/Game/gfx/smileys/2.png b/Game/gfx/smileys/2.png deleted file mode 100755 index 636ded7..0000000
Binary files a/Game/gfx/smileys/2.png and /dev/null differ
diff --git a/Game/gfx/smileys/3.png b/Game/gfx/smileys/3.png deleted file mode 100755 index aa1d0db..0000000
Binary files a/Game/gfx/smileys/3.png and /dev/null differ
diff --git a/Game/gfx/transCover.png b/Game/gfx/transCover.png deleted file mode 100644 index ddbad2f..0000000
Binary files a/Game/gfx/transCover.png and /dev/null differ
diff --git a/Game/music/bgMusic.ogg b/Game/music/bgMusic.ogg deleted file mode 100644 index 562b4bb..0000000
Binary files a/Game/music/bgMusic.ogg and /dev/null differ
diff --git a/Game/music/highbeat.ogg b/Game/music/highbeat.ogg deleted file mode 100644 index 3d21dae..0000000
Binary files a/Game/music/highbeat.ogg and /dev/null differ
diff --git a/Game/puzzles/copy b/Game/puzzles/copy deleted file mode 100755 index 9617703..0000000 --- a/Game/puzzles/copy +++ /dev/null
@@ -1,339 +0,0 @@
-26
-1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 1 1 -1 -1
--1 1 0 0 -1 0
-1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 0 -1 4 -1 -1
--1 3 4 2 -1 -1
--1 3 0 0 -1 -1
--1 0 2 2 -1 -1
--1 3 0 0 4 -1
-2
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 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 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
-2 2 1 1 2 2
-0 3 4 5 3 0
-0 4 3 3 5 0
-1 4 1 1 5 1
-0 2 3 3 2 0
-3
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
-2 -1 2 -1 2 -1
-0 -1 3 -1 0 -1
-1 -1 3 -1 1 -1
-0 -1 4 -1 0 -1
-1 -1 4 -1 4 -1
-0 2 3 2 0 -1
-3
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 2 -1 -1 -1
--1 -1 3 -1 -1 -1
--1 3 1 -1 -1 -1
--1 0 0 -1 -1 -1
--1 1 2 3 -1 -1
--1 0 1 2 -1 -1
-3
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 0 1 0 -1
-1 1 0 1 1 0
-0 2 2 0 2 1
diff --git a/Game/puzzles/puzzle.levels b/Game/puzzles/puzzle.levels deleted file mode 100755 index c53240d..0000000 --- a/Game/puzzles/puzzle.levels +++ /dev/null
@@ -1,352 +0,0 @@
-27
-1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--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1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 0 1 0 -1
-1 1 0 1 1 0
-0 2 2 0 2 1
-1
-0 2 4 3 1 5
-0 2 4 3 1 5
-3 5 1 2 0 4
-3 5 1 2 0 4
-2 4 0 5 3 1
-1 1 2 1 2 2
-2 4 0 5 3 1
-2 4 0 5 3 1
-3 5 1 2 0 4
-3 5 1 2 0 4
-0 2 4 3 1 5
-0 2 4 3 1 5
diff --git a/Game/puzzles/testPuzzles b/Game/puzzles/testPuzzles deleted file mode 100644 index 807500f..0000000 --- a/Game/puzzles/testPuzzles +++ /dev/null
@@ -1,92 +0,0 @@
-7
-1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
-0 0 3 4 0 0
-0 0 3 4 0 0
-3 3 4 3 4 4
-0 0 3 4 0 0
-0 0 3 4 0 0
-2
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 3 -1 -1
--1 -1 -1 0 -1 -1
--1 2 0 1 -1 -1
--1 3 3 0 -1 -1
--1 2 1 3 -1 -1
--1 2 3 1 -1 -1
-2
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 4 0 -1 -1
--1 -1 0 4 3 3
--1 -1 4 0 4 4
--1 -1 0 4 3 3
--1 -1 0 4 3 3
-2
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 5 -1 -1
--1 -1 -1 5 -1 -1
--1 -1 5 3 -1 -1
--1 -1 4 4 -1 -1
--1 -1 3 3 4 -1
-3
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 2 -1 -1 -1 -1
--1 3 -1 -1 -1 -1
--1 2 0 2 -1 -1
--1 2 3 3 -1 -1
--1 0 1 0 -1 -1
--1 0 2 2 -1 -1
--1 3 1 1 -1 -1
--1 3 0 0 -1 -1
-3 0 3 3 -1 -1
-3
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 1 -1 -1 -1 -1
--1 1 4 -1 -1 -1
--1 3 3 1 -1 -1
--1 3 4 4 -1 -1
-2
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 -1 -1 -1
--1 -1 -1 3 -1 -1
--1 -1 -1 1 -1 -1
--1 -1 1 1 -1 -1
--1 -1 4 4 -1 -1
--1 4 0 0 -1 -1
--1 0 3 3 -1 -1
diff --git a/Game/sound/applause.ogg b/Game/sound/applause.ogg deleted file mode 100644 index 39ba789..0000000
Binary files a/Game/sound/applause.ogg and /dev/null differ
diff --git a/Game/sound/cameraclick.ogg b/Game/sound/cameraclick.ogg deleted file mode 100644 index 0c1f9a9..0000000
Binary files a/Game/sound/cameraclick.ogg and /dev/null differ
diff --git a/Game/sound/counter.ogg b/Game/sound/counter.ogg deleted file mode 100644 index 0eb3b4d..0000000
Binary files a/Game/sound/counter.ogg and /dev/null differ
diff --git a/Game/sound/counterFinal.ogg b/Game/sound/counterFinal.ogg deleted file mode 100644 index f76ba7c..0000000
Binary files a/Game/sound/counterFinal.ogg and /dev/null differ
diff --git a/Game/sound/pop.ogg b/Game/sound/pop.ogg deleted file mode 100644 index 9e9fc51..0000000
Binary files a/Game/sound/pop.ogg and /dev/null differ
diff --git a/Game/sound/typing.ogg b/Game/sound/typing.ogg deleted file mode 100644 index 83d95c9..0000000
Binary files a/Game/sound/typing.ogg and /dev/null differ
diff --git a/README.md b/README.md index d099df7..1cb9689 100644 --- a/README.md +++ b/README.md
@@ -5,15 +5,17 @@ A Tetris Attack Clone under the GPL.
# Dependencies
* A version of g++ with C++11 support. Tested on g++-4.9
* libSDL
- * libSDL_image
- * libSDL_mixer
- * libSDL_ttf
+ * libSDL2_image
+ * libSDL2_mixer
+ * libSDL2_ttf
* libenet
* libphysfs
* libboost (only needed for compiling)
* libutfcpp (only needed for compiling)
+ * jsoncpp
# Building
+The only supported build method is using the Makefile
To build do:
```
cd source/code
@@ -21,8 +23,7 @@ make
```
The result should be in the "Game"-folder. To run
```
-cd ../..
-cd Game
+cd ../../Game
./blockattack
```
diff --git a/SConstruct b/SConstruct index eebed40..843d9a7 100644 --- a/SConstruct +++ b/SConstruct
@@ -6,12 +6,17 @@ opts.Add('prefix', 'Destination directory', '/usr/local')
opts.Add('sharedir', 'Directory to use to store data file', '$prefix/share/blockattack')
opts.Add('bindir', 'Directory to use to store data file', '$prefix/bin')
opts.Add('mandir', 'Directory to use to store data file', '$prefix/share/man')
-opts.Add('CXX', 'C++ compiler to use', os.environ['CXX'])
opts.Add('CXXFLAGS', 'C++ flags', "-std=c++11")
+print "Warning: scons is absolutely unsupported for building Block Attack - Rise of the blocks"
+
# Copy Build Environment #
env = Environment(options = opts)
+if 'PATH' in os.environ:
+ env.Append(PATH = os.environ['PATH'])
+if 'CXX' in os.environ:
+ env.Append(CXX = os.environ['CXX'])
Export("env")
SConsignFile()
diff --git a/packdata.sh b/packdata.sh index 73ccd36..0e59663 100755 --- a/packdata.sh +++ b/packdata.sh
@@ -1,10 +1,7 @@
#!/bin/bash
set -e
zip -9rj Game/blockattack.data source/AUTH
-cd Game
-zip -9r blockattack.data gfx -x \*svn*
-zip -9r blockattack.data music -x \*svn*
-zip -9r blockattack.data sound -x \*svn*
-zip -9r blockattack.data fonts -x \*svn*
+cd Game/data
+zip -9r ../blockattack.data * -x \*svn*
exit 0
diff --git a/source/AUTH b/source/AUTH index dc032b2..ea2ec24 100644 --- a/source/AUTH +++ b/source/AUTH
@@ -7,146 +7,93 @@ Data from the OpenArena team is under GPL v2
Data from the Trackballs team is under GPL v2
Poul Sander's files are multi licensed under "GPL v2 or later" OR "CC-BY-SA any version"
-/fonts/
-FreeSerif.ttf Free Software Foundation
-PenguinAttack.ttf Dustin Norlander - GPLv2
-
-/gfx/
-14P_Arial_Angle_Red.png Karl Bartel - http://user.cs.tu-berlin.de/~karlb/sfont/fonts.html
-b1024.png Poul Sander
-bBack.png Poul Sander
-bBlank.png Poul Sander
-bChange.png Poul Sander
-bConnect.png qubodup
-bConfigure.png qubodup
-bEndless.png qubodup
-bExit.png qubodup
-bForward.png Poul Sander
-bHighScore.png qubodup
-bHost.png qubodup
-bHowToPlay.png Poul Sander
-bInternet.png Poul Sander
-bLoad.png qubodup
-bNetwork.png qubodup
-bNewGame.png qubodup
-bNext.png Poul Sander
-bOff.png Poul Sander
-bOn.png Poul Sander
-bOnePlayer.png qubodup
-bOptions.png qubodup
-bPuzzle.png qubodup
-bReplays.png qubodup
-bRetry.png Poul Sander
-bSave.png qubodup
-bSelectPuzzle.png qubodup
-bSkip.png Poul Sander
-bTheme.png Poul Sander (based on qubodup's buttons)
-bVsGameConfig.png Poul Sander (based on qubodup's buttons)
-bTimeTrial.png qubodup
-bVsGame.png qubodup
-bStageClear.png qubodup
-bTwoPlayers.png qubodup
+Misc:
blockAttack.ico Poul Sander
-changeButtonsBack1.png Poul Sander
-iDraw.png Poul Sander
-changeButtonsBack.png Poul Sander
-iGameOver.png Poul Sander
-iLevelCheckBox.png Poul Sander
-iLevelCheckBoxMarked.png Poul Sander
-topscores.png Poul Sander
+
+/fonts/
+freeserif.ttf Free Software Foundation
+penguinattack.ttf Dustin Norlander - GPLv2
+
+/textures/
+back_board.png qubodup
+background.png qubodup
+ball_blue.png qubodup
+ball_gray.png qubodup
+ball_green.png qubodup
+ball_purple.png qubodup
+ball_red.png qubodup
+ball_turkish.png qubodup
+ball_yellow.png qubodup
+b_blank.png Poul Sander
+b_exit.png qubodup
+b_highscore.png qubodup
+black_back_ground.png Poul Sander
+black_line.png Poul Sander
+blue.png qubodup
+board_back_back.png qubodup
+bomb.png Poul Sander
+chain_frame.png Poul Sander
+counter_1.png Poul Sander
+counter_2.png Poul Sander
+counter_3.png Poul Sander
crossover.png Poul Sander
-iLevelCheck.png Poul Sander
-transCover.png Poul Sander
-BackBoard.png qubodup
+cursor.png Poul Sander
dialogbox.png Poul Sander
-iLoser.png Poul Sander
-boardBackBack.png qubodup
+explosion0.png openarena-svn887:/textures/sfx/130boom
+explosion1.png openarena-svn887:/textures/sfx/130boom
+explosion2.png openarena-svn887:/textures/sfx/130boom
+explosion3.png openarena-svn887:/textures/sfx/130boom
+fallback.png Poul Sander
fileDialogbox.png Poul Sander
-iStageClearLimit.png Poul Sander
-background.png qubodup
-iWinner.png Poul Sander
-mouse.png Poul Sander
-blackBackGround.png Poul Sander
-options.png Poul Sander
-blackLine.png Poul Sander
-iCheckBoxArea.png Poul Sander
-chainFrame.png Poul Sander
-icon.png Poul Sander
-
-/gfx/bricks/
-blue.png qubodup
+garbage_bl.png qubodup
+garbage_b.png qubodup
+garbage_br.png qubodup
+garbage_fill.png qubodup
+garbage_gml.png qubodup
+garbage_gm.png qubodup
+garbage_gmr.png qubodup
+garbage_l.png qubodup
+garbage_ml.png qubodup
+garbage_m.png qubodup
+garbage_mr.png qubodup
+garbage_r.png qubodup
+garbage_tl.png qubodup
+garbage_t.png qubodup
+garbage_tr.png qubodup
green.png qubodup
grey.png qubodup
+i_check_box_area.png Poul Sander
+icon.png Poul Sander
+i_draw.png Poul Sander
+i_game_over.png Poul Sander
+i_level_check_box_marked.png Poul Sander
+i_level_check_box.png Poul Sander
+i_level_check.png Poul Sander
+i_loser.png Poul Sander
+i_stage_clear_limit.png Poul Sander
+i_winner.png Poul Sander
+mouse.png Poul Sander
purple.png qubodup
+ready.png Poul Sander
red.png qubodup
+smileys0.png qubodup
+smileys1.png qubodup
+smileys2.png qubodup
+smileys3.png qubodup
+trans_cover.png Poul Sander
turkish.png qubodup
yellow.png qubodup
-/gfx/smileys/
-0.png qubodup
-1.png qubodup
-2.png qubodup
-3.png qubodup
-
-/gfx/animations/bomb/
-bomb_1.png Poul Sander
-bomb_2.png Poul Sander
-
-/gfx/animations/cursor/
-1.png Poul Sander
-2.png Poul Sander
-
-/gfx/animations/explosion/
-0.png openarena-svn887:/textures/sfx/130boom
-1.png openarena-svn887:/textures/sfx/130boom
-2.png openarena-svn887:/textures/sfx/130boom
-3.png openarena-svn887:/textures/sfx/130boom
-
-/gfx/animations/ready/
-ready_1.png Poul Sander
-ready_2.png Poul Sander
-
-/gfx/counter/
-1.png Poul Sander
-2.png Poul Sander
-3.png Poul Sander
-
-/gfx/garbage/
-garbageBL.png qubodup
-garbageBR.png qubodup
-garbageGML.png qubodup
-garbageGMR.png qubodup
-garbageML.png qubodup
-garbageMR.png qubodup
-garbageTL.png qubodup
-garbageTR.png qubodup
-garbageB.png qubodup
-garbageFill.png qubodup
-garbageGM.png qubodup
-garbageL.png qubodup
-garbageM.png qubodup
-garbageR.png qubodup
-garbageT.png qubodup
-
-/gfx/balls/
-ballBlue.png qubodup
-ballGray.png qubodup
-ballGreen.png qubodup
-ballPurple.png qubodup
-ballRed.png qubodup
-ballTurkish.png qubodup
-ballYellow.png qubodup
-
/sound/
pop.ogg openarena-svn887:/sound/weapons/rocket/rockf1a.wav
cameraclick.ogg openarean-svn887:/sound/misc/w_pkup.wav
typing.ogg openarena-svn887:/sound/world/clack.wav
counter.ogg openarena-svn900:/sound/feedback/hitlo.wav
-counterFinal.ogg openarena-svn900:/sound/feedback/hit.wav
+counter_final.ogg openarena-svn900:/sound/feedback/hit.wav
applause.ogg (CC-BY 3.0) Blender Foundation - Cut by LeeZH (http://opengameart.org/content/applause)
/music/
-bgMusic.ogg Trackballs team (http://trackballs.sourceforge.net/) v 1.2 (GPL2), copy of tb_design.ogg
+bgmusic.ogg Trackballs team (http://trackballs.sourceforge.net/) v 1.2 (GPL2), copy of tb_design.ogg
highbeat.ogg Trackballs team (http://trackballs.sourceforge.net/) v 1.2 (GPL2), derived from tb_genesis.ogg
diff --git a/source/code/AUTHORS b/source/code/AUTHORS index ceb6a5e..5fcefaa 100644 --- a/source/code/AUTHORS +++ b/source/code/AUTHORS
@@ -5,8 +5,8 @@ http://blockattack.sf.net
Gonéri Le Bouder
Done some work for making it work with SHAREDIR and all Scons scripts
-Contains SFont - SDL Font Library by
-Karl Bartel <karlb@gmx.net>
+Jonathan Dearborn
+NFont library
Jordà Polo
Two patches
@@ -14,4 +14,6 @@ Two patches
A lot of the 1.4.0 graphics is by
Iwan Gabovitch aka qubodup
+This does not cover non-embedded libraries.
+
Detailed auther information regarding media can be found in the blockattack.data zip-file
diff --git a/source/code/CppSdlImageHolder.cpp b/source/code/CppSdlImageHolder.cpp deleted file mode 100644 index b571449..0000000 --- a/source/code/CppSdlImageHolder.cpp +++ /dev/null
@@ -1,129 +0,0 @@
-/*
-===========================================================================
-blockattack - Block Attack - Rise of the Blocks
-Copyright (C) 2005-2013 Poul Sander
-
-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, see http://www.gnu.org/licenses/
-
-Source information and contacts persons can be found at
-http://blockattack.sf.net
-===========================================================================
-*/
-
-#include "CppSdlImageHolder.hpp"
-#include "SDL_image.h"
-#include <stdexcept>
-
-namespace CppSdl {
-
-CppSdlImageHolder::CppSdlImageHolder() {
- data = nullptr;
-}
-
-CppSdlImageHolder::CppSdlImageHolder(std::string filename) {
- data = IMG_Load(filename.c_str());
- if (!data) {
- //Here we should throw an exception
- throw std::runtime_error(std::string("Could not read file \""+filename+"\""));
- }
- SDL_GetClipRect(data,&area);
- OptimizeForBlit();
-}
-
-CppSdlImageHolder::CppSdlImageHolder(char* rawdata, int datasize) {
- SDL_RWops* rw = SDL_RWFromMem (rawdata, datasize);
-
- //The above might fail and return null.
- if (!rw) {
- throw std::runtime_error(std::string("Could not read raw data"));
- }
-
- data = IMG_Load_RW(rw,true); //the second argument tells the function to free RWops
-
- if (!data) {
- throw std::runtime_error("Could not convert raw data to image");
- }
-
- SDL_GetClipRect(data,&area);
- OptimizeForBlit();
-}
-
-CppSdlImageHolder::~CppSdlImageHolder() {
- MakeNull();
-}
-
-SDL_Surface* CppSdlImageHolder::GetRawDataInsecure() {
- Initialized();
- return data;
-}
-
-Uint32 CppSdlImageHolder::GetWidth() {
- if (IsNull()) {
- return 0;
- }
- return area.w;
-}
-
-Uint32 CppSdlImageHolder::GetHeight() {
- if (IsNull()) {
- return 0;
- }
- return area.h;
-}
-
-void CppSdlImageHolder::PaintTo(SDL_Surface* target, int x, int y) {
- static SDL_Rect dest; //static for reuse
- if (IsNull()) {
- return;
- }
- dest.x = x;
- dest.y = y;
- SDL_BlitSurface(data, &area, target,&dest);
-}
-
-void CppSdlImageHolder::OptimizeForBlit(bool allowAlpha) {
- static SDL_Surface* tmp;
- Initialized();
- if (allowAlpha) {
- tmp = SDL_DisplayFormatAlpha(data);
- }
- else {
- tmp = SDL_DisplayFormat(data);
- }
- SDL_FreeSurface(data);
- data = tmp;
-}
-
-void CppSdlImageHolder::Initialized() {
- if (data == nullptr) {
- throw std::runtime_error("ImageHolder used uninitialized!");
- }
-}
-
-bool CppSdlImageHolder::IsNull() {
- if (data == nullptr ) {
- return true;
- }
- return false;
-}
-
-void CppSdlImageHolder::MakeNull() {
- if (IsNull()) {
- return;
- }
- SDL_FreeSurface(data);
- data = nullptr;
-}
-
-}
diff --git a/source/code/CppSdlImageHolder.hpp b/source/code/CppSdlImageHolder.hpp deleted file mode 100644 index d6c5384..0000000 --- a/source/code/CppSdlImageHolder.hpp +++ /dev/null
@@ -1,99 +0,0 @@
-/*
-===========================================================================
-blockattack - Block Attack - Rise of the Blocks
-Copyright (C) 2005-2012 Poul Sander
-
-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, see http://www.gnu.org/licenses/
-
-Source information and contacts persons can be found at
-http://blockattack.sf.net
-===========================================================================
-*/
-
-#ifndef _CPPSDLIMAGEHOLDER_HPP
-#define _CPPSDLIMAGEHOLDER_HPP
-
-#include "SDL.h"
-#include <string>
-
-namespace CppSdl
-{
-
-class CppSdlImageHolder
-{
-public:
- /**
- * Creates a nulled ImageHolder (without data)
- */
- CppSdlImageHolder();
- /**
- * Creates an image from a file
- * @param filename to be loaded
- */
- CppSdlImageHolder(std::string filename);
- /**
- * Creates a copy. The new copy shares raw data with the original but is otherwise independent.
- * @param orig
- */
- CppSdlImageHolder(const CppSdlImageHolder& orig) = delete;
- CppSdlImageHolder(char *rawdata, int datasize);
- ~CppSdlImageHolder();
- /**
- * This gives access direct access to the internal data.
- * Careful, the data might be shared between multiple ImageHolders,
- * chaing one will change them all.
- * @return A pointer
- */
- SDL_Surface *GetRawDataInsecure();
- CppSdlImageHolder & operator=(const CppSdlImageHolder &rhs) = delete;
- /**
- * The width of the image
- * 0 if the image is nulled
- * @return The width of the image in pizels
- */
- Uint32 GetWidth();
- /**
- * The height of the image
- * 0 if the image is nulled
- * @return The height of the image
- */
- Uint32 GetHeight();
- /**
- * Draws an image to surface at a given position.
- * If the image is nulled nothing is drawn
- * @param target Destination surface
- * @param x horizontal placement on destination surface
- * @param y vertical placement on destination surface
- */
- void PaintTo(SDL_Surface *target, int x, int y);
- void OptimizeForBlit(bool allowAlpha = true);
- /**
- * Tests if there are data in the object
- * @return true if where are data in the object
- */
- bool IsNull();
- /**
- * Removes the data in the object.
- * Once all ImageHolders pointing to the same data has been freed the internal data will be freed too
- */
- void MakeNull();
-private:
- void Initialized(); //throws an exception if *data is null
- SDL_Rect area;
- SDL_Surface *data;
-};
-
-}
-#endif /* _CPPSDLIMAGEHOLDER_HPP */
-
diff --git a/source/code/Libs/NFont.cpp b/source/code/Libs/NFont.cpp index 2ea2ac4..b5023fe 100644 --- a/source/code/Libs/NFont.cpp +++ b/source/code/Libs/NFont.cpp
@@ -1,7 +1,7 @@
/*
-NFont v2.0.0: A bitmap font class for SDL
-by Jonathan Dearborn 2-4-10
-(class adapted from Florian Hufsky)
+NFont v4.0.0: A font class for SDL
+by Jonathan Dearborn
+Dedicated to the memory of Florian Hufsky
License:
The short:
@@ -9,7 +9,7 @@ License:
whenever these files or parts of them are distributed in uncompiled form.
The long:
-Copyright (c) 2010 Jonathan Dearborn
+Copyright (c) 2014 Jonathan Dearborn
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -29,50 +29,63 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
+
#include "NFont.h"
+#include "SDL_FontCache.h"
-char* NFont::buffer = NULL;
-NFont::AnimData NFont::data;
+#include <cmath>
+#include <cstdio>
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
-#define MIN(a,b) (a < b? a : b)
-#define MAX(a,b) (a > b? a : b)
+#include <string>
+#include <cstring>
+#include <list>
+using std::string;
+using std::list;
-// Static setters
-void NFont::setAnimData(void* data) {
- NFont::data.userVar = data;
-}
+#ifdef NFONT_USE_SDL_GPU
+#define NFont_Target GPU_Target
+#define NFont_Image GPU_Image
+#define NFont_Log GPU_LogError
+#else
+#define NFont_Target SDL_Renderer
+#define NFont_Image SDL_Texture
+#define NFont_Log SDL_Log
+#endif
-void NFont::setBuffer(unsigned int size) {
- delete[] buffer;
- if (size > 0) {
- buffer = new char[size];
- }
- else {
- buffer = new char[1024];
- }
+#define MIN(a,b) ((a) < (b)? (a) : (b))
+#define MAX(a,b) ((a) > (b)? (a) : (b))
+
+static inline SDL_Surface* createSurface24(Uint32 width, Uint32 height) {
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+ return SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 24, 0xFF0000, 0x00FF00, 0x0000FF, 0);
+#else
+ return SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 24, 0x0000FF, 0x00FF00, 0xFF0000, 0);
+#endif
}
+static inline SDL_Surface* createSurface32(Uint32 width, Uint32 height) {
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+ return SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
+#else
+ return SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
+#endif
+}
-// Static functions
-char* NFont::copyString(const char* c) {
+static inline char* copyString(const char* c) {
if (c == NULL) {
return NULL;
}
- int count = 0;
- for (; c[count] != '\0'; count++);
-
- char* result = new char[count+1];
+ char* result = new char[strlen(c)+1];
+ strcpy(result, c);
- for (int i = 0; i < count; i++) {
- result[i] = c[i];
- }
-
- result[count] = '\0';
return result;
}
-Uint32 NFont::getPixel(SDL_Surface* Surface, int x, int y) { // No Alpha?
+static inline Uint32 getPixel(SDL_Surface* Surface, int x, int y) {
Uint8* bits;
Uint32 bpp;
@@ -103,619 +116,691 @@ Uint32 NFont::getPixel(SDL_Surface* Surface, int x, int y) { // No Alpha?
break;
}
- return 0; // Best I could do for errors
+ return 0; // FIXME: Handle errors better
+}
+
+static inline void setPixel(SDL_Surface* surface, int x, int y, Uint32 color) {
+ int bpp = surface->format->BytesPerPixel;
+ Uint8* bits = ((Uint8*)surface->pixels) + y*surface->pitch + x*bpp;
+
+ /* Set the pixel */
+ switch (bpp) {
+ case 1:
+ *((Uint8*)(bits)) = (Uint8)color;
+ break;
+ case 2:
+ *((Uint16*)(bits)) = (Uint16)color;
+ break;
+ case 3: { /* Format/endian independent */
+ Uint8 r,g,b;
+ r = (color >> surface->format->Rshift) & 0xFF;
+ g = (color >> surface->format->Gshift) & 0xFF;
+ b = (color >> surface->format->Bshift) & 0xFF;
+ *((bits)+surface->format->Rshift/8) = r;
+ *((bits)+surface->format->Gshift/8) = g;
+ *((bits)+surface->format->Bshift/8) = b;
+ }
+ break;
+ case 4:
+ *((Uint32*)(bits)) = (Uint32)color;
+ break;
+ }
+}
+
+static inline void drawPixel(SDL_Surface* surface, Sint16 x, Sint16 y, Uint32 color, Uint8 alpha) {
+ if (x > surface->clip_rect.x + surface->clip_rect.w || x < surface->clip_rect.x || y > surface->clip_rect.y + surface->clip_rect.h || y < surface->clip_rect.y) {
+ return;
+ }
+
+ switch (surface->format->BytesPerPixel) {
+ case 1: { /* Assuming 8-bpp */
+
+ Uint8* pixel = (Uint8*)surface->pixels + y*surface->pitch + x;
+
+ Uint8 dR = surface->format->palette->colors[*pixel].r;
+ Uint8 dG = surface->format->palette->colors[*pixel].g;
+ Uint8 dB = surface->format->palette->colors[*pixel].b;
+ Uint8 sR = surface->format->palette->colors[color].r;
+ Uint8 sG = surface->format->palette->colors[color].g;
+ Uint8 sB = surface->format->palette->colors[color].b;
+
+ dR = dR + ((sR-dR)*alpha >> 8);
+ dG = dG + ((sG-dG)*alpha >> 8);
+ dB = dB + ((sB-dB)*alpha >> 8);
+
+ *pixel = SDL_MapRGB(surface->format, dR, dG, dB);
+
+ }
+ break;
+
+ case 2: { /* Probably 15-bpp or 16-bpp */
+
+ Uint32 Rmask = surface->format->Rmask, Gmask = surface->format->Gmask, Bmask = surface->format->Bmask, Amask = surface->format->Amask;
+ Uint16* pixel = (Uint16*)surface->pixels + y*surface->pitch/2 + x;
+ Uint32 dc = *pixel;
+ Uint32 R,G,B,A=0;
+
+ R = ((dc & Rmask) + (( (color & Rmask) - (dc & Rmask) ) * alpha >> 8)) & Rmask;
+ G = ((dc & Gmask) + (( (color & Gmask) - (dc & Gmask) ) * alpha >> 8)) & Gmask;
+ B = ((dc & Bmask) + (( (color & Bmask) - (dc & Bmask) ) * alpha >> 8)) & Bmask;
+ if ( Amask ) {
+ A = ((dc & Amask) + (( (color & Amask) - (dc & Amask) ) * alpha >> 8)) & Amask;
+ }
+
+ *pixel= R | G | B | A;
+
+ }
+ break;
+
+ case 3: { /* Slow 24-bpp mode, usually not used */
+ Uint8* pix = (Uint8*)surface->pixels + y * surface->pitch + x*3;
+ Uint8 rshift8=surface->format->Rshift/8;
+ Uint8 gshift8=surface->format->Gshift/8;
+ Uint8 bshift8=surface->format->Bshift/8;
+ Uint8 ashift8=surface->format->Ashift/8;
+
+
+
+ Uint8 dR, dG, dB, dA;
+ Uint8 sR, sG, sB, sA;
+
+ pix = (Uint8*)surface->pixels + y * surface->pitch + x*3;
+
+ dR = *((pix)+rshift8);
+ dG = *((pix)+gshift8);
+ dB = *((pix)+bshift8);
+ dA = *((pix)+ashift8);
+
+ sR = (color>>surface->format->Rshift)&0xff;
+ sG = (color>>surface->format->Gshift)&0xff;
+ sB = (color>>surface->format->Bshift)&0xff;
+ sA = (color>>surface->format->Ashift)&0xff;
+
+ dR = dR + ((sR-dR)*alpha >> 8);
+ dG = dG + ((sG-dG)*alpha >> 8);
+ dB = dB + ((sB-dB)*alpha >> 8);
+ dA = dA + ((sA-dA)*alpha >> 8);
+
+ *((pix)+rshift8) = dR;
+ *((pix)+gshift8) = dG;
+ *((pix)+bshift8) = dB;
+ *((pix)+ashift8) = dA;
+
+ }
+ break;
+
+ case 4: { /* Probably 32-bpp */
+ Uint32 Rmask = surface->format->Rmask, Gmask = surface->format->Gmask, Bmask = surface->format->Bmask, Amask = surface->format->Amask;
+ Uint32* pixel = (Uint32*)surface->pixels + y*surface->pitch/4 + x;
+ Uint32 source = *pixel;
+ Uint32 R,G,B,A;
+ R = color & Rmask;
+ G = color & Gmask;
+ B = color & Bmask;
+ A = 0; // keep this as 0 to avoid corruption of non-alpha surfaces
+
+ // Blend and keep dest alpha
+ if ( alpha != SDL_ALPHA_OPAQUE ) {
+ R = ((source & Rmask) + (( R - (source & Rmask) ) * alpha >> 8)) & Rmask;
+ G = ((source & Gmask) + (( G - (source & Gmask) ) * alpha >> 8)) & Gmask;
+ B = ((source & Bmask) + (( B - (source & Bmask) ) * alpha >> 8)) & Bmask;
+ }
+ if (Amask) {
+ A = (source & Amask);
+ }
+
+ *pixel = R | G | B | A;
+ }
+ break;
+ }
}
-SDL_Rect NFont::rectUnion(const SDL_Rect& A, const SDL_Rect& B) {
- Sint16 x,x2,y,y2;
+static inline NFont::Rectf rectUnion(const NFont::Rectf& A, const NFont::Rectf& B) {
+ float x,x2,y,y2;
x = MIN(A.x, B.x);
y = MIN(A.y, B.y);
x2 = MAX(A.x+A.w, B.x+B.w);
y2 = MAX(A.y+A.h, B.y+B.h);
- SDL_Rect result = {static_cast<Sint16>(x), static_cast<Sint16>(y), static_cast<Uint16>(x2 - x), static_cast<Uint16>(y2 - y)};
+ NFont::Rectf result(x, y, MAX(0, x2 - x), MAX(0, y2 - y));
return result;
}
-SDL_Surface* NFont::copySurface(SDL_Surface* Surface) {
+// Adapted from SDL_IntersectRect
+static inline NFont::Rectf rectIntersect(const NFont::Rectf& A, const NFont::Rectf& B) {
+ NFont::Rectf result;
+ float Amin, Amax, Bmin, Bmax;
+
+ // Horizontal intersection
+ Amin = A.x;
+ Amax = Amin + A.w;
+ Bmin = B.x;
+ Bmax = Bmin + B.w;
+ if (Bmin > Amin) {
+ Amin = Bmin;
+ }
+ result.x = Amin;
+ if (Bmax < Amax) {
+ Amax = Bmax;
+ }
+ result.w = Amax - Amin > 0 ? Amax - Amin : 0;
+
+ // Vertical intersection
+ Amin = A.y;
+ Amax = Amin + A.h;
+ Bmin = B.y;
+ Bmax = Bmin + B.h;
+ if (Bmin > Amin) {
+ Amin = Bmin;
+ }
+ result.y = Amin;
+ if (Bmax < Amax) {
+ Amax = Bmax;
+ }
+ result.h = Amax - Amin > 0 ? Amax - Amin : 0;
+
+ return result;
+}
+
+static inline SDL_Surface* copySurface(SDL_Surface* Surface) {
return SDL_ConvertSurface(Surface, Surface->format, Surface->flags);
}
-SDL_Surface* NFont::verticalGradient(SDL_Surface* targetSurface, Uint32 top, Uint32 bottom, int heightAdjust) {
- SDL_Surface* surface = targetSurface;
- if (surface == NULL) {
- return NULL;
- }
- Uint8 tr, tg, tb;
- SDL_GetRGB(top, surface->format, &tr, &tg, &tb);
- Uint8 br, bg, bb;
- SDL_GetRGB(bottom, surface->format, &br, &bg, &bb);
- bool useCK = (surface->flags & SDL_SRCALPHA) != SDL_SRCALPHA; // colorkey if no alpha
- Uint32 colorkey = surface->format->colorkey;
- Uint8 r, g, b, a;
- float ratio;
- Uint32 color;
- int temp;
- for (int x = 0, y = 0; y < surface->h; x++) {
- if (x >= surface->w) {
- x = 0;
- y++;
- if (y >= surface->h) {
- break;
- }
- }
+NFont::Color::Color()
+ : r(0), g(0), b(0), a(255) {
+}
+NFont::Color::Color(Uint8 r, Uint8 g, Uint8 b)
+ : r(r), g(g), b(b), a(255) {
+}
+NFont::Color::Color(Uint8 r, Uint8 g, Uint8 b, Uint8 a)
+ : r(r), g(g), b(b), a(a) {
+}
+NFont::Color::Color(const SDL_Color& color)
+ : r(color.r), g(color.g), b(color.b), a(color.a) {
+}
- ratio = (y - 2)/float(surface->h - heightAdjust); // the neg 3s are for full color at top and bottom
+NFont::Color& NFont::Color::rgb(Uint8 R, Uint8 G, Uint8 B) {
+ r = R;
+ g = G;
+ b = B;
- if (!useCK) {
- color = getPixel(surface, x, y);
- SDL_GetRGBA(color, surface->format, &r, &g, &b, &a); // just getting alpha
- }
- else {
- a = SDL_ALPHA_OPAQUE;
- }
+ return *this;
+}
- // Get and clamp the new values
- temp = int(tr*(1-ratio) + br*ratio);
- r = temp < 0? 0 : temp > 255? 255 : temp;
+NFont::Color& NFont::Color::rgba(Uint8 R, Uint8 G, Uint8 B, Uint8 A) {
+ r = R;
+ g = G;
+ b = B;
+ a = A;
- temp = int(tg*(1-ratio) + bg*ratio);
- g = temp < 0? 0 : temp > 255? 255 : temp;
+ return *this;
+}
- temp = int(tb*(1-ratio) + bb*ratio);
- b = temp < 0? 0 : temp > 255? 255 : temp;
+NFont::Color& NFont::Color::color(const SDL_Color& color) {
+ r = color.r;
+ g = color.g;
+ b = color.b;
+ a = color.a;
+ return *this;
+}
- color = SDL_MapRGBA(surface->format, r, g, b, a);
+SDL_Color NFont::Color::to_SDL_Color() const {
+ SDL_Color c = {r, g, b, a};
+ return c;
+}
- if (useCK) {
- if (getPixel(surface, x, y) == colorkey) {
- continue;
- }
- if (color == colorkey) {
- color == 0? color++ : color--;
- }
- }
- // make sure it isn't pink
- if (color == SDL_MapRGBA(surface->format, 0xFF, 0, 0xFF, a)) {
- color--;
- }
- if (getPixel(surface, x, y) == SDL_MapRGBA(surface->format, 0xFF, 0, 0xFF, SDL_ALPHA_OPAQUE)) {
- continue;
- }
- int bpp = surface->format->BytesPerPixel;
- Uint8* bits = ((Uint8*)surface->pixels) + y*surface->pitch + x*bpp;
-
- /* Set the pixel */
- switch (bpp) {
- case 1:
- *((Uint8*)(bits)) = (Uint8)color;
- break;
- case 2:
- *((Uint16*)(bits)) = (Uint16)color;
- break;
- case 3: { /* Format/endian independent */
- r = (color >> surface->format->Rshift) & 0xFF;
- g = (color >> surface->format->Gshift) & 0xFF;
- b = (color >> surface->format->Bshift) & 0xFF;
- *((bits)+surface->format->Rshift/8) = r;
- *((bits)+surface->format->Gshift/8) = g;
- *((bits)+surface->format->Bshift/8) = b;
- }
- break;
- case 4:
- *((Uint32*)(bits)) = (Uint32)color;
- break;
- }
+NFont::Rectf::Rectf()
+ : x(0), y(0), w(0), h(0) {
+}
- }
- return surface;
+NFont::Rectf::Rectf(float x, float y)
+ : x(x), y(y), w(0), h(0) {
}
+NFont::Rectf::Rectf(float x, float y, float w, float h)
+ : x(x), y(y), w(w), h(h) {
+}
+
+NFont::Rectf::Rectf(const SDL_Rect& rect)
+ : x(rect.x), y(rect.y), w(rect.w), h(rect.h) {
+}
+
+#ifdef NFONT_USE_SDL_GPU
+NFont::Rectf::Rectf(const GPU_Rect& rect)
+ : x(rect.x), y(rect.y), w(rect.w), h(rect.h) {
+}
+#endif
+
+SDL_Rect NFont::Rectf::to_SDL_Rect() const {
+ SDL_Rect r = {int(x), int(y), int(w), int(h)};
+ return r;
+}
+
+#ifdef NFONT_USE_SDL_GPU
+GPU_Rect NFont::Rectf::to_GPU_Rect() const {
+ return GPU_MakeRect(x, y, w, h);
+}
+#endif
+
+
+
+
+
+
+
+char* NFont::buffer = NULL; // Shared buffer for efficient drawing
+
// Constructors
NFont::NFont() {
init();
}
-NFont::NFont(SDL_Surface* src) {
+NFont::NFont(const NFont& font) {
init();
- load(src);
+ // FIXME: Duplicate font data
}
-NFont::NFont(SDL_Surface* dest, SDL_Surface* src) {
+#ifdef NFONT_USE_SDL_GPU
+NFont::NFont(TTF_Font* ttf) {
init();
- load(src);
- setDest(dest);
+ load(ttf, FC_GetDefaultColor(font));
}
-
-#ifdef NFONT_USE_TTF
-NFont::NFont(TTF_Font* ttf, SDL_Color fg) {
+NFont::NFont(TTF_Font* ttf, const NFont::Color& color) {
init();
- load(ttf, fg);
+ load(ttf, color);
}
-NFont::NFont(TTF_Font* ttf, SDL_Color fg, SDL_Color bg) {
+NFont::NFont(const char* filename_ttf, Uint32 pointSize) {
init();
- load(ttf, fg, bg);
+ load(filename_ttf, pointSize);
}
-NFont::NFont(const char* filename_ttf, Uint32 pointSize, SDL_Color fg, int style) {
+NFont::NFont(const char* filename_ttf, Uint32 pointSize, const NFont::Color& color, int style) {
init();
- load(filename_ttf, pointSize, fg, style);
+ load(filename_ttf, pointSize, color, style);
}
-NFont::NFont(const char* filename_ttf, Uint32 pointSize, SDL_Color fg, SDL_Color bg, int style) {
+NFont::NFont(SDL_RWops* file_rwops_ttf, Uint8 own_rwops, Uint32 pointSize, const NFont::Color& color, int style) {
init();
- load(filename_ttf, pointSize, fg, bg, style);
+ load(file_rwops_ttf, own_rwops, pointSize, color, style);
}
-NFont::NFont(SDL_Surface* dest, TTF_Font* ttf, SDL_Color fg) {
+#else
+
+NFont::NFont(NFont_Target* renderer, TTF_Font* ttf) {
+ init();
+ load(renderer, ttf, FC_GetDefaultColor(font));
+}
+NFont::NFont(NFont_Target* renderer, TTF_Font* ttf, const NFont::Color& color) {
init();
- load(ttf, fg);
- setDest(dest);
+ load(renderer, ttf, color);
}
-NFont::NFont(SDL_Surface* dest, TTF_Font* ttf, SDL_Color fg, SDL_Color bg) {
+NFont::NFont(NFont_Target* renderer, const char* filename_ttf, Uint32 pointSize) {
init();
- load(ttf, fg, bg);
- setDest(dest);
+ load(renderer, filename_ttf, pointSize);
}
-NFont::NFont(SDL_Surface* dest, const char* filename_ttf, Uint32 pointSize, SDL_Color fg, int style) {
+NFont::NFont(NFont_Target* renderer, const char* filename_ttf, Uint32 pointSize, const NFont::Color& color, int style) {
init();
- load(filename_ttf, pointSize, fg, style);
- setDest(dest);
+ load(renderer, filename_ttf, pointSize, color, style);
}
-NFont::NFont(SDL_Surface* dest, const char* filename_ttf, Uint32 pointSize, SDL_Color fg, SDL_Color bg, int style) {
+NFont::NFont(NFont_Target* renderer, SDL_RWops* file_rwops_ttf, Uint8 own_rwops, Uint32 pointSize, const NFont::Color& color, int style) {
init();
- load(filename_ttf, pointSize, fg, bg, style);
- setDest(dest);
+ load(renderer, file_rwops_ttf, own_rwops, pointSize, color, style);
}
#endif
-void NFont::init() {
- src = NULL;
- dest = NULL;
- maxPos = 0;
+NFont::~NFont() {
+ FC_FreeFont(font);
+}
- height = 0; // ascent+descent
- maxWidth = 0;
- baseline = 0;
- ascent = 0;
- descent = 0;
+NFont& NFont::operator=(const NFont& font) {
+ // FIXME: Duplicate font data
+ return *this;
+}
- lineSpacing = 0;
- letterSpacing = 0;
+void NFont::init() {
+ font = FC_CreateFont();
if (buffer == NULL) {
buffer = new char[1024];
}
}
-NFont::~NFont() {
-}
-
-// Loading
-bool NFont::load(SDL_Surface* FontSurface) {
- src = FontSurface;
- if (src == NULL) {
- printf("\n ERROR: NFont given a NULL surface\n");
- return false;
- }
- int x = 1, i = 0;
- // memset would be faster
- for (int j = 0; j < 256; j++) {
- charWidth[j] = 0;
- charPos[j] = 0;
- }
- SDL_LockSurface(src);
-
- Uint32 pixel = SDL_MapRGB(src->format, 255, 0, 255); // pink pixel
-
- maxWidth = 0;
-
- // Get the character positions and widths
- while (x < src->w) {
- if (getPixel(src, x, 0) != pixel) {
- charPos[i] = x;
- charWidth[i] = x;
- while (x < src->w && getPixel(src, x, 0) != pixel) {
- x++;
- }
- charWidth[i] = x - charWidth[i];
- if (charWidth[i] > maxWidth) {
- maxWidth = charWidth[i];
- }
- i++;
- }
-
- x++;
- }
-
- maxPos = x - 1;
-
-
- pixel = getPixel(src, 0, src->h - 1);
- int j;
- setBaseline();
-
- // Get the max ascent
- j = 1;
- while (j < baseline && j < src->h) {
- x = 0;
- while (x < src->w) {
- if (getPixel(src, x, j) != pixel) {
- ascent = baseline - j;
- j = src->h;
- break;
- }
- x++;
- }
- j++;
- }
-
- // Get the max descent
- j = src->h - 1;
- while (j > 0 && j > baseline) {
- x = 0;
- while (x < src->w) {
- if (getPixel(src, x, j) != pixel) {
- descent = j - baseline+1;
- j = 0;
- break;
- }
- x++;
- }
- j--;
- }
-
- height = ascent + descent;
-
-
- if ((src->flags & SDL_SRCALPHA) != SDL_SRCALPHA) {
- pixel = getPixel(src, 0, src->h - 1);
- SDL_UnlockSurface(src);
- SDL_SetColorKey(src, SDL_SRCCOLORKEY, pixel);
- }
- else {
- SDL_UnlockSurface(src);
- }
-
- return true;
+void NFont::setLoadingString(const char* str) {
+ FC_SetLoadingString(font, str);
}
-bool NFont::load(SDL_Surface* destSurface, SDL_Surface* FontSurface) {
- setDest(destSurface);
- return load(FontSurface);
+#ifdef NFONT_USE_SDL_GPU
+bool NFont::load(TTF_Font* ttf)
+#else
+bool NFont::load(NFont_Target* renderer, TTF_Font* ttf)
+#endif
+{
+#ifdef NFONT_USE_SDL_GPU
+ return load(ttf, FC_GetDefaultColor(font));
+#else
+ return load(renderer, ttf, Color(0,0,0,255));
+#endif
}
-#ifdef NFONT_USE_TTF
-bool NFont::load(TTF_Font* ttf, SDL_Color fg, SDL_Color bg) {
+#ifdef NFONT_USE_SDL_GPU
+bool NFont::load(TTF_Font* ttf, const NFont::Color& color)
+#else
+bool NFont::load(NFont_Target* renderer, TTF_Font* ttf, const NFont::Color& color)
+#endif
+{
if (ttf == NULL) {
return false;
}
- SDL_Surface* surfs[127 - 33];
- int width = 0;
- int height = 0;
-
- char buff[2];
- buff[1] = '\0';
- for (int i = 0; i < 127 - 33; i++) {
- buff[0] = i + 33;
- surfs[i] = TTF_RenderText_Shaded(ttf, buff, fg, bg);
- width += surfs[i]->w;
- height = (height < surfs[i]->h)? surfs[i]->h : height;
+
+#ifndef NFONT_USE_SDL_GPU
+ if (renderer == NULL) {
+ return false;
}
+#endif
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- SDL_Surface* result = SDL_CreateRGBSurface(SDL_SWSURFACE,width + 127 - 33 + 1,height,24, 0xFF0000, 0x00FF00, 0x0000FF, 0);
+ FC_ClearFont(font);
+#ifdef NFONT_USE_SDL_GPU
+ return FC_LoadFontFromTTF(font, ttf, color.to_SDL_Color());
#else
- SDL_Surface* result = SDL_CreateRGBSurface(SDL_SWSURFACE,width + 127 - 33 + 1,height,24, 0x0000FF, 0x00FF00, 0xFF0000, 0);
+ return FC_LoadFontFromTTF(font, renderer, ttf, color.to_SDL_Color());
#endif
- Uint32 pink = SDL_MapRGB(result->format, 255, 0, 255);
- Uint32 bgcolor = SDL_MapRGB(result->format, bg.r, bg.g, bg.b);
+}
- SDL_Rect pixel = {1, 0, 1, 1};
- SDL_Rect line = {1, 0, 1, static_cast<Uint16>(result->h)};
+#ifdef NFONT_USE_SDL_GPU
+bool NFont::load(const char* filename_ttf, Uint32 pointSize)
+#else
+bool NFont::load(NFont_Target* renderer, const char* filename_ttf, Uint32 pointSize)
+#endif
+{
+#ifdef NFONT_USE_SDL_GPU
+ return load(filename_ttf, pointSize, Color(0,0,0,255));
+#else
+ return load(renderer, filename_ttf, pointSize, Color(0,0,0,255));
+#endif
+}
- int x = 1;
- SDL_Rect dest = {static_cast<Sint16>(x), 0, 0, 0};
- for (int i = 0; i < 127 - 33; i++) {
- pixel.x = line.x = x-1;
- SDL_FillRect(result, &line, bgcolor);
- SDL_FillRect(result, &pixel, pink);
+#ifdef NFONT_USE_SDL_GPU
+bool NFont::load(const char* filename_ttf, Uint32 pointSize, const NFont::Color& color, int style)
+#else
+bool NFont::load(NFont_Target* renderer, const char* filename_ttf, Uint32 pointSize, const NFont::Color& color, int style)
+#endif
+{
+ FC_ClearFont(font);
+#ifdef NFONT_USE_SDL_GPU
+ return FC_LoadFont(font, filename_ttf, pointSize, color.to_SDL_Color(), style);
+#else
+ return FC_LoadFont(font, renderer, filename_ttf, pointSize, color.to_SDL_Color(), style);
+#endif
+}
- SDL_BlitSurface(surfs[i], NULL, result, &dest);
+#ifdef NFONT_USE_SDL_GPU
+bool NFont::load(SDL_RWops* file_rwops_ttf, Uint8 own_rwops, Uint32 pointSize, const NFont::Color& color, int style)
+#else
+bool NFont::load(NFont_Target* renderer, SDL_RWops* file_rwops_ttf, Uint8 own_rwops, Uint32 pointSize, const NFont::Color& color, int style)
+#endif
+{
+ FC_ClearFont(font);
+#ifdef NFONT_USE_SDL_GPU
+ return FC_LoadFont_RW(font, file_rwops_ttf, own_rwops, pointSize, color.to_SDL_Color(), style);
+#else
+ return FC_LoadFont_RW(font, renderer, file_rwops_ttf, own_rwops, pointSize, color.to_SDL_Color(), style);
+#endif
+}
- x += surfs[i]->w + 1;
- dest.x = x;
- SDL_FreeSurface(surfs[i]);
- }
- pixel.x = line.x = x-1;
- SDL_FillRect(result, &line, bgcolor);
- SDL_FillRect(result, &pixel, pink);
- return load(result);
+void NFont::free() {
+ FC_ClearFont(font);
}
-bool NFont::load(TTF_Font* ttf, SDL_Color fg) {
- if (ttf == NULL) {
- return false;
- }
- SDL_Surface* surfs[127 - 33];
- int width = 0;
- int height = 0;
-
- char buff[2];
- buff[1] = '\0';
- for (int i = 0; i < 127 - 33; i++) {
- buff[0] = i + 33;
- surfs[i] = TTF_RenderText_Blended(ttf, buff, fg);
- width += surfs[i]->w;
- height = (height < surfs[i]->h)? surfs[i]->h : height;
+
+NFont::Rectf NFont::draw(NFont_Target* dest, float x, float y, const char* formatted_text, ...) {
+ if (formatted_text == NULL) {
+ return Rectf(x, y, 0, 0);
}
-#if SDL_BYTEORDER == SDL_BIG_ENDIAN
- SDL_Surface* result = SDL_CreateRGBSurface(SDL_SWSURFACE,width + 127 - 33 + 1,height,32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
-#else
- SDL_Surface* result = SDL_CreateRGBSurface(SDL_SWSURFACE,width + 127 - 33 + 1,height,32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
-#endif
- Uint32 pink = SDL_MapRGBA(result->format, 255, 0, 255, SDL_ALPHA_OPAQUE);
+ va_list lst;
+ va_start(lst, formatted_text);
+ vsprintf(buffer, formatted_text, lst);
+ va_end(lst);
- SDL_SetAlpha(result, 0, SDL_ALPHA_OPAQUE);
+ return FC_Draw(font, dest, x, y, "%s", buffer);
+}
- SDL_Rect pixel = {1, 0, 1, 1};
+/*static int getIndexPastWidth(const char* text, int width, const int* charWidth)
+{
+ int charnum;
+ int len = strlen(text);
- int x = 1;
- SDL_Rect dest = {static_cast<Sint16>(x), 0, 0, 0};
- for (int i = 0; i < 127 - 33; i++) {
- pixel.x = x-1;
- SDL_FillRect(result, &pixel, pink);
+ for (int index = 0; index < len; index++)
+ {
+ char c = text[index];
+ charnum = (unsigned char)(c) - 33;
- SDL_SetAlpha(surfs[i], 0, SDL_ALPHA_OPAQUE);
- SDL_BlitSurface(surfs[i], NULL, result, &dest);
+ // spaces and nonprintable characters
+ if (c == ' ' || charnum > 222)
+ {
+ width -= charWidth[0];
+ }
+ else
+ width -= charWidth[charnum];
- x += surfs[i]->w + 1;
- dest.x = x;
+ if(width <= 0)
+ return index;
+ }
+ return 0;
+}*/
- SDL_FreeSurface(surfs[i]);
- }
- pixel.x = x-1;
- SDL_FillRect(result, &pixel, pink);
- SDL_SetAlpha(result, SDL_SRCALPHA, SDL_ALPHA_OPAQUE);
- return load(result);
-}
+/*static list<string> explode(const string& str, char delimiter)
+{
+ list<string> result;
+ size_t oldPos = 0;
+ size_t pos = str.find_first_of(delimiter);
+ while(pos != string::npos)
+ {
+ result.push_back(str.substr(oldPos, pos - oldPos));
+ oldPos = pos+1;
+ pos = str.find_first_of(delimiter, oldPos);
+ }
-bool NFont::load(const char* filename_ttf, Uint32 pointSize, SDL_Color fg, int style) {
- if (!TTF_WasInit() && TTF_Init() < 0) {
- printf("Unable to initialize SDL_ttf: %s \n", TTF_GetError());
- return false;
- }
+ result.push_back(str.substr(oldPos, string::npos));
- TTF_Font* ttf = TTF_OpenFont(filename_ttf, pointSize);
+ return result;
+}*/
- if (ttf == NULL) {
- printf("Unable to load TrueType font: %s \n", TTF_GetError());
- return false;
+NFont::Rectf NFont::drawBox(NFont_Target* dest, const Rectf& box, const char* formatted_text, ...) {
+ if (formatted_text == NULL) {
+ return Rectf(box.x, box.y, 0, 0);
}
- TTF_SetFontStyle(ttf, style);
- bool result = load(ttf, fg);
- TTF_CloseFont(ttf);
- return result;
-}
-bool NFont::load(const char* filename_ttf, Uint32 pointSize, SDL_Color fg, SDL_Color bg, int style) {
- if (!TTF_WasInit() && TTF_Init() < 0) {
- printf("Unable to initialize SDL_ttf: %s \n", TTF_GetError());
- return false;
- }
+ va_list lst;
+ va_start(lst, formatted_text);
+ vsprintf(buffer, formatted_text, lst);
+ va_end(lst);
- TTF_Font* ttf = TTF_OpenFont(filename_ttf, pointSize);
+#ifdef NFONT_USE_SDL_GPU
+ return FC_DrawBox(font, dest, box.to_GPU_Rect(), "%s", buffer);
+#else
+ return FC_DrawBox(font, dest, box.to_SDL_Rect(), "%s", buffer);
+#endif
+}
- if (ttf == NULL) {
- printf("Unable to load TrueType font: %s \n", TTF_GetError());
- return false;
+static FC_AlignEnum translate_enum_NFont_to_FC(NFont::AlignEnum align) {
+ switch (align) {
+ case NFont::LEFT:
+ return FC_ALIGN_LEFT;
+ case NFont::CENTER:
+ return FC_ALIGN_CENTER;
+ case NFont::RIGHT:
+ return FC_ALIGN_RIGHT;
+ default:
+ return FC_ALIGN_LEFT;
}
- TTF_SetFontStyle(ttf, style);
- bool result = load(ttf, fg, bg);
- TTF_CloseFont(ttf);
- return result;
}
-#endif
-
+NFont::Rectf NFont::drawBox(NFont_Target* dest, const Rectf& box, AlignEnum align, const char* formatted_text, ...) {
+ if (formatted_text == NULL) {
+ return Rectf(box.x, box.y, 0, 0);
+ }
+ va_list lst;
+ va_start(lst, formatted_text);
+ vsprintf(buffer, formatted_text, lst);
+ va_end(lst);
-void NFont::freeSurface() {
- SDL_FreeSurface(src);
+#ifdef NFONT_USE_SDL_GPU
+ return FC_DrawBoxAlign(font, dest, box.to_GPU_Rect(), translate_enum_NFont_to_FC(align), "%s", buffer);
+#else
+ return FC_DrawBoxAlign(font, dest, box.to_SDL_Rect(), translate_enum_NFont_to_FC(align), "%s", buffer);
+#endif
}
+NFont::Rectf NFont::drawBox(NFont_Target* dest, const Rectf& box, const Scale& scale, const char* formatted_text, ...) {
+ if (formatted_text == NULL) {
+ return Rectf(box.x, box.y, 0, 0);
+ }
+ va_list lst;
+ va_start(lst, formatted_text);
+ vsprintf(buffer, formatted_text, lst);
+ va_end(lst);
-// Drawing
-SDL_Rect NFont::drawToSurface(int x, int y, const char* text) const {
- const char* c = text;
- unsigned char num;
- SDL_Rect srcRect, dstRect, copyS, copyD;
- data.dirtyRect = makeRect(x, y, 0, 0);
+#ifdef NFONT_USE_SDL_GPU
+ return FC_DrawBoxScale(font, dest, box.to_GPU_Rect(), FC_MakeScale(scale.x, scale.y), "%s", buffer);
+#else
+ return FC_DrawBoxScale(font, dest, box.to_SDL_Rect(), FC_MakeScale(scale.x, scale.y), "%s", buffer);
+#endif
+}
- if (c == NULL || src == NULL || dest == NULL) {
- return data.dirtyRect;
+NFont::Rectf NFont::drawBox(NFont_Target* dest, const Rectf& box, const Color& color, const char* formatted_text, ...) {
+ if (formatted_text == NULL) {
+ return Rectf(box.x, box.y, 0, 0);
}
- srcRect.y = baseline - ascent;
- srcRect.h = dstRect.h = height;
- dstRect.x = x;
- dstRect.y = y;
+ va_list lst;
+ va_start(lst, formatted_text);
+ vsprintf(buffer, formatted_text, lst);
+ va_end(lst);
- int newlineX = x;
+#ifdef NFONT_USE_SDL_GPU
+ return FC_DrawBoxColor(font, dest, box.to_GPU_Rect(), color.to_SDL_Color(), "%s", buffer);
+#else
+ return FC_DrawBoxColor(font, dest, box.to_SDL_Rect(), color.to_SDL_Color(), "%s", buffer);
+#endif
+}
- for (; *c != '\0'; c++) {
- if (*c == '\n') {
- dstRect.x = newlineX;
- dstRect.y += height + lineSpacing;
- continue;
- }
+NFont::Rectf NFont::drawBox(NFont_Target* dest, const Rectf& box, const Effect& effect, const char* formatted_text, ...) {
+ if (formatted_text == NULL) {
+ return Rectf(box.x, box.y, 0, 0);
+ }
- if (*c == ' ') {
- dstRect.x += charWidth[0] + letterSpacing;
- continue;
- }
- unsigned char ctest = (unsigned char)(*c);
- // Skip bad characters
- if (ctest < 33 || (ctest > 126 && ctest < 161)) {
- continue;
- }
- if (dstRect.x >= dest->w) {
- continue;
- }
- if (dstRect.y >= dest->h) {
- continue;
- }
+ va_list lst;
+ va_start(lst, formatted_text);
+ vsprintf(buffer, formatted_text, lst);
+ va_end(lst);
- num = ctest - 33; // Get array index
- if (num > 126) { // shift the extended characters down to the correct index
- num -= 34;
- }
- srcRect.x = charPos[num];
- srcRect.w = dstRect.w = charWidth[num];
- copyS = srcRect;
- copyD = dstRect;
- SDL_BlitSurface(src, &srcRect, dest, &dstRect);
- if (data.dirtyRect.w == 0 || data.dirtyRect.h == 0) {
- data.dirtyRect = dstRect;
- }
- else {
- data.dirtyRect = rectUnion(data.dirtyRect, dstRect);
- }
- srcRect = copyS;
- dstRect = copyD;
+#ifdef NFONT_USE_SDL_GPU
+ return FC_DrawBoxEffect(font, dest, box.to_GPU_Rect(), FC_MakeEffect(translate_enum_NFont_to_FC(effect.alignment), FC_MakeScale(effect.scale.x, effect.scale.y), effect.color.to_SDL_Color()), "%s", buffer);
+#else
+ return FC_DrawBoxEffect(font, dest, box.to_SDL_Rect(), FC_MakeEffect(translate_enum_NFont_to_FC(effect.alignment), FC_MakeScale(effect.scale.x, effect.scale.y), effect.color.to_SDL_Color()), "%s", buffer);
+#endif
+}
- dstRect.x += dstRect.w + letterSpacing;
+NFont::Rectf NFont::drawColumn(NFont_Target* dest, float x, float y, Uint16 width, const char* formatted_text, ...) {
+ if (formatted_text == NULL) {
+ return Rectf(x, y, 0, 0);
}
- return data.dirtyRect;
-}
+ va_list lst;
+ va_start(lst, formatted_text);
+ vsprintf(buffer, formatted_text, lst);
+ va_end(lst);
-SDL_Rect NFont::drawToSurfacePos(int x, int y, NFont::AnimFn posFn) const {
- data.font = this;
- data.dest = dest;
- data.src = src;
- data.text = buffer; // Buffer for efficient drawing
- data.height = height;
- data.charPos = charPos;
- data.charWidth = charWidth;
- data.maxX = maxPos;
- data.dirtyRect = makeRect(x,y,0,0);
+ return FC_DrawColumn(font, dest, x, y, width, "%s", buffer);
+}
- data.index = -1;
- data.letterNum = 0;
- data.wordNum = 1;
- data.lineNum = 1;
- data.startX = x; // used as reset value for line feed
- data.startY = y;
+NFont::Rectf NFont::drawColumn(NFont_Target* dest, float x, float y, Uint16 width, AlignEnum align, const char* formatted_text, ...) {
+ if (formatted_text == NULL) {
+ return Rectf(x, y, 0, 0);
+ }
- int preFnX = x;
- int preFnY = y;
+ va_list lst;
+ va_start(lst, formatted_text);
+ vsprintf(buffer, formatted_text, lst);
+ va_end(lst);
- const char* c = buffer;
- unsigned char num;
- SDL_Rect srcRect, dstRect, copyS, copyD;
+ return FC_DrawColumnAlign(font, dest, x, y, width, translate_enum_NFont_to_FC(align), "%s", buffer);
+}
- if (c == NULL || src == NULL || dest == NULL) {
- return makeRect(x,y,0,0);
+NFont::Rectf NFont::drawColumn(NFont_Target* dest, float x, float y, Uint16 width, const Scale& scale, const char* formatted_text, ...) {
+ if (formatted_text == NULL) {
+ return Rectf(x, y, 0, 0);
}
- srcRect.y = baseline - ascent;
- srcRect.h = dstRect.h = height;
- dstRect.x = x;
- dstRect.y = y;
-
- for (; *c != '\0'; c++) {
- data.index++;
- data.letterNum++;
-
- if (*c == '\n') {
- data.letterNum = 1;
- data.wordNum = 1;
- data.lineNum++;
+ va_list lst;
+ va_start(lst, formatted_text);
+ vsprintf(buffer, formatted_text, lst);
+ va_end(lst);
- x = data.startX; // carriage return
- y += height + lineSpacing;
- continue;
- }
- if (*c == ' ') {
- data.letterNum = 1;
- data.wordNum++;
+ return FC_DrawColumnScale(font, dest, x, y, width, FC_MakeScale(scale.x, scale.y), "%s", buffer);
+}
- x += charWidth[0] + letterSpacing;
- continue;
- }
- unsigned char ctest = (unsigned char)(*c);
- // Skip bad characters
- if (ctest < 33 || (ctest > 126 && ctest < 161)) {
- continue;
- }
- //if(x >= dest->w) // This shouldn't be used with position control
- // continue;
- num = ctest - 33;
- if (num > 126) { // shift the extended characters down to the array index
- num -= 34;
- }
- srcRect.x = charPos[num];
- srcRect.w = dstRect.w = charWidth[num];
+NFont::Rectf NFont::drawColumn(NFont_Target* dest, float x, float y, Uint16 width, const Color& color, const char* formatted_text, ...) {
+ if (formatted_text == NULL) {
+ return Rectf(x, y, 0, 0);
+ }
- preFnX = x; // Save real position
- preFnY = y;
+ va_list lst;
+ va_start(lst, formatted_text);
+ vsprintf(buffer, formatted_text, lst);
+ va_end(lst);
- // Use function pointer to get final x, y values
- posFn(x, y, data);
+ return FC_DrawColumnColor(font, dest, x, y, width, color.to_SDL_Color(), "%s", buffer);
+}
- dstRect.x = x;
- dstRect.y = y;
+NFont::Rectf NFont::drawColumn(NFont_Target* dest, float x, float y, Uint16 width, const Effect& effect, const char* formatted_text, ...) {
+ if (formatted_text == NULL) {
+ return Rectf(x, y, 0, 0);
+ }
- copyS = srcRect;
- copyD = dstRect;
- SDL_BlitSurface(src, &srcRect, dest, &dstRect);
- if (data.dirtyRect.w == 0 || data.dirtyRect.h == 0) {
- data.dirtyRect = dstRect;
- }
- else {
- data.dirtyRect = rectUnion(data.dirtyRect, dstRect);
- }
- srcRect = copyS;
- dstRect = copyD;
+ va_list lst;
+ va_start(lst, formatted_text);
+ vsprintf(buffer, formatted_text, lst);
+ va_end(lst);
- x = preFnX; // Restore real position
- y = preFnY;
+#ifdef NFONT_USE_SDL_GPU
+ return FC_DrawColumnEffect(font, dest, x, y, width, FC_MakeEffect(translate_enum_NFont_to_FC(effect.alignment), FC_MakeScale(effect.scale.x, effect.scale.y), effect.color.to_SDL_Color()), "%s", buffer);
+#else
+ return FC_DrawColumnEffect(font, dest, x, y, width, FC_MakeEffect(translate_enum_NFont_to_FC(effect.alignment), FC_MakeScale(effect.scale.x, effect.scale.y), effect.color.to_SDL_Color()), "%s", buffer);
+#endif
+}
- x += dstRect.w + letterSpacing;
- }
- return data.dirtyRect;
-}
-SDL_Rect NFont::draw(int x, int y, const char* formatted_text, ...) const {
+NFont::Rectf NFont::draw(NFont_Target* dest, float x, float y, const Scale& scale, const char* formatted_text, ...) {
if (formatted_text == NULL) {
- return makeRect(x, y, 0, 0);
+ return Rectf(x, y, 0, 0);
}
va_list lst;
@@ -723,12 +808,12 @@ SDL_Rect NFont::draw(int x, int y, const char* formatted_text, ...) const {
vsprintf(buffer, formatted_text, lst);
va_end(lst);
- return drawToSurface(x, y, buffer);
+ return FC_DrawScale(font, dest, x, y, FC_MakeScale(scale.x, scale.y), "%s", buffer);
}
-SDL_Rect NFont::drawCenter(int x, int y, const char* formatted_text, ...) const {
+NFont::Rectf NFont::draw(NFont_Target* dest, float x, float y, AlignEnum align, const char* formatted_text, ...) {
if (formatted_text == NULL) {
- return makeRect(x, y, 0, 0);
+ return Rectf(x, y, 0, 0);
}
va_list lst;
@@ -736,34 +821,12 @@ SDL_Rect NFont::drawCenter(int x, int y, const char* formatted_text, ...) const
vsprintf(buffer, formatted_text, lst);
va_end(lst);
- char* str = copyString(buffer);
- char* del = str;
-
- // Go through str, when you find a \n, replace it with \0 and print it
- // then move down, back, and continue.
- for (char* c = str; *c != '\0';) {
- if (*c == '\n') {
- *c = '\0';
- drawToSurface(x - getWidth("%s", str)/2, y, str);
- *c = '\n';
- c++;
- str = c;
- y += height;
- }
- else {
- c++;
- }
- }
- char s[strlen(str)+1];
- strcpy(s, str);
- delete[] del;
-
- return drawToSurface(x - getWidth("%s", s)/2, y, s);
+ return FC_DrawAlign(font, dest, x, y, translate_enum_NFont_to_FC(align), "%s", buffer);
}
-SDL_Rect NFont::drawRight(int x, int y, const char* formatted_text, ...) const {
+NFont::Rectf NFont::draw(NFont_Target* dest, float x, float y, const Color& color, const char* formatted_text, ...) {
if (formatted_text == NULL) {
- return makeRect(x, y, 0, 0);
+ return Rectf(x, y, 0, 0);
}
va_list lst;
@@ -771,63 +834,44 @@ SDL_Rect NFont::drawRight(int x, int y, const char* formatted_text, ...) const {
vsprintf(buffer, formatted_text, lst);
va_end(lst);
- char* str = copyString(buffer);
- char* del = str;
-
- for (char* c = str; *c != '\0';) {
- if (*c == '\n') {
- *c = '\0';
- drawToSurface(x - getWidth("%s", str), y, str);
- *c = '\n';
- c++;
- str = c;
- y += height;
- }
- else {
- c++;
- }
- }
- char s[strlen(str)+1];
- strcpy(s, str);
- delete[] del;
-
- return drawToSurface(x - getWidth("%s", s), y, s);
+ return FC_DrawColor(font, dest, x, y, color.to_SDL_Color(), "%s", buffer);
}
-SDL_Rect NFont::drawPos(int x, int y, NFont::AnimFn posFn, const char* text, ...) const {
- va_list lst;
- va_start(lst, text);
- vsprintf(buffer, text, lst);
- va_end(lst);
- return drawToSurfacePos(x, y, posFn);
-}
+NFont::Rectf NFont::draw(NFont_Target* dest, float x, float y, const Effect& effect, const char* formatted_text, ...) {
+ if (formatted_text == NULL) {
+ return Rectf(x, y, 0, 0);
+ }
-SDL_Rect NFont::drawAll(int x, int y, NFont::AnimFn allFn, const char* text, ...) const {
va_list lst;
- va_start(lst, text);
- vsprintf(buffer, text, lst);
+ va_start(lst, formatted_text);
+ vsprintf(buffer, formatted_text, lst);
va_end(lst);
- allFn(x, y, data);
- return data.dirtyRect;
+ return FC_DrawEffect(font, dest, x, y, FC_MakeEffect(translate_enum_NFont_to_FC(effect.alignment), FC_MakeScale(effect.scale.x, effect.scale.y), effect.color.to_SDL_Color()), "%s", buffer);
}
// Getters
-SDL_Surface* NFont::getDest() const {
- return dest;
+
+
+NFont::FilterEnum NFont::getFilterMode() const {
+ FC_FilterEnum f = FC_GetFilterMode(font);
+ if (f == FC_FILTER_LINEAR) {
+ return NFont::LINEAR;
+ }
+ return NFont::NEAREST;
}
-SDL_Surface* NFont::getSurface() const {
- return src;
+Uint16 NFont::getHeight() const {
+ return FC_GetLineHeight(font);
}
-int NFont::getHeight(const char* formatted_text, ...) const {
+Uint16 NFont::getHeight(const char* formatted_text, ...) const {
if (formatted_text == NULL) {
- return height;
+ return 0;
}
va_list lst;
@@ -835,20 +879,10 @@ int NFont::getHeight(const char* formatted_text, ...) const {
vsprintf(buffer, formatted_text, lst);
va_end(lst);
- int numLines = 1;
- const char* c;
-
- for (c = buffer; *c != '\0'; c++) {
- if (*c == '\n') {
- numLines++;
- }
- }
-
- // Actual height of letter region + line spacing
- return height*numLines + lineSpacing*(numLines - 1); //height*numLines;
+ return FC_GetHeight(font, "%s", buffer);
}
-int NFont::getWidth(const char* formatted_text, ...) const {
+Uint16 NFont::getWidth(const char* formatted_text, ...) {
if (formatted_text == NULL) {
return 0;
}
@@ -858,59 +892,48 @@ int NFont::getWidth(const char* formatted_text, ...) const {
vsprintf(buffer, formatted_text, lst);
va_end(lst);
- const char* c;
- int charnum = 0;
- int width = 0;
- int bigWidth = 0; // Allows for multi-line strings
+ return FC_GetWidth(font, "%s", buffer);
+}
- for (c = buffer; *c != '\0'; c++) {
- charnum = (unsigned char)(*c) - 33;
- // skip spaces and nonprintable characters
- if (*c == '\n') {
- bigWidth = bigWidth >= width? bigWidth : width;
- width = 0;
- }
- else if (*c == ' ' || charnum > 222) {
- width += charWidth[0];
- continue;
- }
-
- width += charWidth[charnum];
+NFont::Rectf NFont::getCharacterOffset(Uint16 position_index, int column_width, const char* formatted_text, ...) {
+ if (formatted_text == NULL) {
+ return Rectf(0,0,0,0);
}
- bigWidth = bigWidth >= width? bigWidth : width;
- return bigWidth;
+ va_list lst;
+ va_start(lst, formatted_text);
+ vsprintf(buffer, formatted_text, lst);
+ va_end(lst);
+
+ return FC_GetCharacterOffset(font, position_index, column_width, "%s", buffer);
}
-int NFont::getAscent(const char character) const {
- unsigned char test = (unsigned char)character;
- if (test < 33 || test > 222 || (test > 126 && test < 161)) {
+
+Uint16 NFont::getColumnHeight(Uint16 width, const char* formatted_text, ...) {
+ if (formatted_text == NULL || width == 0) {
return 0;
}
- unsigned char num = (unsigned char)character - 33;
- // Get the max ascent
- int x = charPos[num];
- int i, j = 1, result = 0;
- Uint32 pixel = getPixel(src, 0, src->h - 1); // bg pixel
- while (j < baseline && j < src->h) {
- i = charPos[num];
- while (i < x + charWidth[num]) {
- if (getPixel(src, i, j) != pixel) {
- result = baseline - j;
- j = src->h;
- break;
- }
- i++;
- }
- j++;
- }
- return result;
+
+ va_list lst;
+ va_start(lst, formatted_text);
+ vsprintf(buffer, formatted_text, lst);
+ va_end(lst);
+
+ return FC_GetColumnHeight(font, width, "%s", buffer);
}
-int NFont::getAscent(const char* formatted_text, ...) const {
+int NFont::getAscent(const char character) {
+ return FC_GetAscent(font, "%c", character);
+}
+
+int NFont::getAscent() const {
+ return FC_GetAscent(font, NULL);
+}
+
+int NFont::getAscent(const char* formatted_text, ...) {
if (formatted_text == NULL) {
- return ascent;
+ return FC_GetAscent(font, NULL);
}
va_list lst;
@@ -918,46 +941,20 @@ int NFont::getAscent(const char* formatted_text, ...) const {
vsprintf(buffer, formatted_text, lst);
va_end(lst);
- int max = 0;
- const char* c = buffer;
+ return FC_GetAscent(font, "%s", buffer);
+}
- for (; *c != '\0'; c++) {
- int asc = getAscent(*c);
- if (asc > max) {
- max = asc;
- }
- }
- return max;
+int NFont::getDescent(const char character) {
+ return FC_GetDescent(font, "%c", character);
}
-int NFont::getDescent(const char character) const {
- unsigned char test = (unsigned char)character;
- if (test < 33 || test > 222 || (test > 126 && test < 161)) {
- return 0;
- }
- unsigned char num = (unsigned char)character - 33;
- // Get the max descent
- int x = charPos[num];
- int i, j = src->h - 1, result = 0;
- Uint32 pixel = getPixel(src, 0, src->h - 1); // bg pixel
- while (j > 0 && j > baseline) {
- i = charPos[num];
- while (i < x + charWidth[num]) {
- if (getPixel(src, i, j) != pixel) {
- result = j - baseline;
- j = 0;
- break;
- }
- i++;
- }
- j--;
- }
- return result;
+int NFont::getDescent() const {
+ return FC_GetDescent(font, NULL);
}
-int NFont::getDescent(const char* formatted_text, ...) const {
+int NFont::getDescent(const char* formatted_text, ...) {
if (formatted_text == NULL) {
- return descent;
+ return FC_GetDescent(font, NULL);
}
va_list lst;
@@ -965,32 +962,27 @@ int NFont::getDescent(const char* formatted_text, ...) const {
vsprintf(buffer, formatted_text, lst);
va_end(lst);
- int max = 0;
- const char* c = buffer;
-
- for (; *c != '\0'; c++) {
- int des = getDescent(*c);
- if (des > max) {
- max = des;
- }
- }
- return max;
+ return FC_GetDescent(font, "%s", buffer);
}
int NFont::getSpacing() const {
- return letterSpacing;
+ return FC_GetSpacing(font);
}
int NFont::getLineSpacing() const {
- return lineSpacing;
+ return FC_GetLineSpacing(font);
+}
+
+Uint16 NFont::getBaseline() const {
+ return FC_GetBaseline(font);
}
-int NFont::getBaseline() const {
- return baseline;
+Uint16 NFont::getMaxWidth() const {
+ return FC_GetMaxWidth(font);
}
-int NFont::getMaxWidth() const {
- return maxWidth;
+NFont::Color NFont::getDefaultColor() const {
+ return FC_GetDefaultColor(font);
}
@@ -998,52 +990,39 @@ int NFont::getMaxWidth() const {
// Setters
+
+void NFont::setFilterMode(NFont::FilterEnum filter) {
+ if (filter == NFont::LINEAR) {
+ FC_SetFilterMode(font, FC_FILTER_LINEAR);
+ }
+ else {
+ FC_SetFilterMode(font, FC_FILTER_NEAREST);
+ }
+}
+
void NFont::setSpacing(int LetterSpacing) {
- letterSpacing = LetterSpacing;
+ FC_SetSpacing(font, LetterSpacing);
}
void NFont::setLineSpacing(int LineSpacing) {
- lineSpacing = LineSpacing;
+ FC_SetLineSpacing(font, LineSpacing);
}
-void NFont::setDest(SDL_Surface* Dest) {
- dest = Dest;
+void NFont::setBaseline() {
+
}
-int NFont::setBaseline(int Baseline) {
- if (Baseline >= 0) {
- baseline = Baseline;
- }
- else {
- // Get the baseline by checking a, b, and c and averaging their lowest y-value.
- // Is there a better way?
- Uint32 pixel = getPixel(src, 0, src->h - 1);
- int heightSum = 0;
- int x, i, j;
- for (unsigned char avgChar = 64; avgChar < 67; avgChar++) {
- x = charPos[avgChar];
-
- j = src->h - 1;
- while (j > 0) {
- i = x;
- while (i - x < charWidth[64]) {
- if (getPixel(src, i, j) != pixel) {
- heightSum += j;
- j = 0;
- break;
- }
- i++;
- }
- j--;
- }
- }
- baseline = int(heightSum/3.0f + 0.5f); // Round up and cast
- }
- return baseline;
+void NFont::setBaseline(Uint16 Baseline) {
+
}
+void NFont::setDefaultColor(const Color& color) {
+ FC_SetDefaultColor(font, color.to_SDL_Color());
+}
+void NFont::enableTTFOwnership() {
+}
diff --git a/source/code/Libs/NFont.h b/source/code/Libs/NFont.h index 0d6d581..9351dd8 100644 --- a/source/code/Libs/NFont.h +++ b/source/code/Libs/NFont.h
@@ -1,224 +1,305 @@
-
-// Define this here or in your project settings if you want to use the SDL_ttf features.
-#define NFONT_USE_TTF
-
-/*
-NFont v2.0.0: A bitmap font class for SDL
-by Jonathan Dearborn 2-4-10
-(class originally adapted from Florian Hufsky)
-
-Requires:
- SDL ("SDL.h") [www.libsdl.org]
-
-Optionally Requires:
- SDL_ttf ("SDL_ttf.h") [www.libsdl.org]
-
-Notes:
- NFont is a bitmap font class with text-block alignment, full
- support for the newline character ('\n'), animation, and extended ASCII
- support. It accepts SDL_Surfaces so that any image format you can load
- can be used as an NFont.
-
- NFont has the ability to animate the font in two ways: It's position or
- it's everything. By using drawPos(), you can use a function you create
- to handle the final positions of the drawn characters. With drawAll(),
- you can handle everything that the font does (please use my
- drawToSurface() function as a reference).
-
- Internally, NFont uses a pointer (SDL_Surface*) to handle the destination
- surface. You have to set the destination before the font can be used. Be
- aware that you will need to use setDest() if you replace the memory that
- it points to (like when using screen = SDL_SetVideoMode()).
-
- NFont can use standard SFont bitmaps or extended bitmaps. The standard bitmaps
- have the following characters (ASCII 33-126) separated by pink (255, 0, 255) pixels in the topmost
- row:
- ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ 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 [ \ ] ^ _ ` 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 { | } ~
-
- And the extended bitmaps have these (ASCII 161-255):
- ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ 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 [ \ ] ^ _ ` 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 { | } ~ � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �
-
- NFont can also load SDL_ttf fonts. Define NFONT_USE_TTF before including
- NFont.h to use the flexibility of NFont with TrueType fonts.
-
- If you come up with something cool using NFont, I'd love to hear about it.
- Any comments can be sent to GrimFang4 [at] gmail [dot] com
-
-License:
- The short:
- Use it however you'd like, but keep the copyright and license notice
- whenever these files or parts of them are distributed in uncompiled form.
-
- The long:
-Copyright (c) 2010 Jonathan Dearborn
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-
-*/
-
-#ifndef _NFONT_H__
-#define _NFONT_H__
-
-#include "SDL.h"
-#include "stdarg.h"
-
-#ifdef NFONT_USE_TTF
-#include "SDL_ttf.h"
-#endif
-
-class NFont
-{
-public:
-
- // Nested struct
- struct AnimData
- {
- const NFont* font;
-
- SDL_Surface* dest;
- SDL_Surface* src;
- char* text; // Buffer for efficient drawing
- int height;
- const int* charPos;
- const int* charWidth;
- int maxX;
-
- int index;
- int letterNum;
- int wordNum;
- int lineNum;
- int startX;
- int startY;
- void* userVar;
-
- SDL_Rect dirtyRect;
- };
-
- // Function pointer
- typedef void (*AnimFn)(int&, int&, AnimData&);
-
-protected:
-
-
- SDL_Surface* src; // bitmap source of characters
- SDL_Surface* dest; // Destination to blit to
-
- int height;
-
- int maxWidth;
- int baseline;
- int ascent;
- int descent;
-
- int lineSpacing;
- int letterSpacing;
-
- int charPos[256];
- int charWidth[256];
- int maxPos;
-
- void init();
-
- SDL_Rect drawToSurface(int x, int y, const char* text) const;
- SDL_Rect drawToSurfacePos(int x, int y, NFont::AnimFn posFn) const;
-
- // Static variables
- static char* buffer; // Buffer for efficient drawing
- static AnimData data; // Data is wrapped in a struct so it can all be passed to
- // the function pointers for animation
-
-public:
-
- // Static functions
- static char* copyString(const char* c);
- static Uint32 getPixel(SDL_Surface *Surface, int x, int y);
- static inline SDL_Rect makeRect(Sint16 x, Sint16 y, Uint16 w, Uint16 h)
- {
- SDL_Rect r = {x, y, w, h};
- return r;
- }
- static SDL_Rect rectUnion(const SDL_Rect& A, const SDL_Rect& B);
- static SDL_Surface* copySurface(SDL_Surface *Surface);
- static SDL_Surface* verticalGradient(SDL_Surface* targetSurface, Uint32 topColor, Uint32 bottomColor, int heightAdjust = 0);
-
- // Static accessors
- static void setAnimData(void* data);
- static void setBuffer(unsigned int size);
-
- // Constructors
- NFont();
- NFont(SDL_Surface* src);
- NFont(SDL_Surface* dest, SDL_Surface* src);
-#ifdef NFONT_USE_TTF
- NFont(TTF_Font* ttf, SDL_Color fg); // Alpha bg
- NFont(TTF_Font* ttf, SDL_Color fg, SDL_Color bg);
- NFont(const char* filename_ttf, Uint32 pointSize, SDL_Color fg, int style = TTF_STYLE_NORMAL); // Alpha bg
- NFont(const char* filename_ttf, Uint32 pointSize, SDL_Color fg, SDL_Color bg, int style = TTF_STYLE_NORMAL);
- NFont(SDL_Surface* dest, TTF_Font* ttf, SDL_Color fg); // Alpha bg
- NFont(SDL_Surface* dest, TTF_Font* ttf, SDL_Color fg, SDL_Color bg);
- NFont(SDL_Surface* dest, const char* filename_ttf, Uint32 pointSize, SDL_Color fg, int style = TTF_STYLE_NORMAL); // Alpha bg
- NFont(SDL_Surface* dest, const char* filename_ttf, Uint32 pointSize, SDL_Color fg, SDL_Color bg, int style = TTF_STYLE_NORMAL);
-#endif
-
- ~NFont();
-
- // Loading
- bool load(SDL_Surface* FontSurface);
- bool load(SDL_Surface* destSurface, SDL_Surface* FontSurface);
-#ifdef NFONT_USE_TTF
- bool load(TTF_Font* ttf, SDL_Color fg); // Alpha bg
- bool load(TTF_Font* ttf, SDL_Color fg, SDL_Color bg);
- bool load(const char* filename_ttf, Uint32 pointSize, SDL_Color fg, int style = TTF_STYLE_NORMAL); // Alpha bg
- bool load(const char* filename_ttf, Uint32 pointSize, SDL_Color fg, SDL_Color bg, int style = TTF_STYLE_NORMAL);
-#endif
-
- void freeSurface();
-
- // Drawing
- SDL_Rect draw(int x, int y, const char* formatted_text, ...) const __attribute__ ((format (printf, 4, 5)));
- SDL_Rect drawCenter(int x, int y, const char* formatted_text, ...) const __attribute__ ((format (printf, 4, 5)));
- SDL_Rect drawRight(int x, int y, const char* formatted_text, ...) const __attribute__ ((format (printf, 4, 5)));
- SDL_Rect drawPos(int x, int y, NFont::AnimFn posFn, const char* text, ...) const __attribute__ ((format (printf, 5, 6)));
- SDL_Rect drawAll(int x, int y, NFont::AnimFn allFn, const char* text, ...) const __attribute__ ((format (printf, 5, 6)));
-
- // Getters
- SDL_Surface* getDest() const;
- SDL_Surface* getSurface() const;
- int getHeight(const char* formatted_text = NULL, ...) const __attribute__ ((format (printf, 2, 3)));
- int getWidth(const char* formatted_text, ...) const __attribute__ ((format (printf, 2, 3)));
- int getSpacing() const;
- int getLineSpacing() const;
- int getBaseline() const;
- int getAscent(const char character) const;
- int getAscent(const char* formatted_text = NULL, ...) const __attribute__ ((format (printf, 2, 3)));
- int getDescent(const char character) const;
- int getDescent(const char* formatted_text = NULL, ...) const __attribute__ ((format (printf, 2, 3)));
- int getMaxWidth() const;
-
- // Setters
- void setDest(SDL_Surface* Dest);
- void setSpacing(int LetterSpacing);
- void setLineSpacing(int LineSpacing);
- int setBaseline(int Baseline = -1);
-
-};
-
-
-
-#endif // _NFONT_H__
+/*
+NFont v4.0.0: A font class for SDL and SDL_Renderer
+by Jonathan Dearborn
+Dedicated to the memory of Florian Hufsky
+
+License:
+ The short:
+ Use it however you'd like, but keep the copyright and license notice
+ whenever these files or parts of them are distributed in uncompiled form.
+
+ The long:
+Copyright (c) 2014 Jonathan Dearborn
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#ifndef _NFONT_H__
+#define _NFONT_H__
+
+#include "SDL.h"
+
+#if defined(FC_USE_SDL_GPU) && !defined(NFONT_USE_SDL_GPU)
+#define NFONT_USE_SDL_GPU
+#endif
+
+#ifdef NFONT_USE_SDL_GPU
+ #include "SDL_gpu.h"
+#endif
+
+#include "stdarg.h"
+
+// Let's pretend this exists...
+#ifndef TTF_STYLE_OUTLINE
+ #define TTF_STYLE_OUTLINE 16
+#endif
+
+struct FC_Font;
+
+typedef struct _TTF_Font TTF_Font;
+
+#if defined(NFONT_DLL) || defined(NFONT_DLL_EXPORT)
+ #ifdef NFONT_DLL_EXPORT
+ #define NFONT_EXPORT __declspec(dllexport)
+ #else
+ #define NFONT_EXPORT __declspec(dllimport)
+ #endif
+#else
+ #define NFONT_EXPORT
+#endif
+
+class NFONT_EXPORT NFont
+{
+ public:
+
+ class NFONT_EXPORT Color
+ {
+ public:
+
+ Uint8 r, g, b, a;
+
+ Color();
+ Color(Uint8 r, Uint8 g, Uint8 b);
+ Color(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
+ Color(const SDL_Color& color);
+
+ Color& rgb(Uint8 R, Uint8 G, Uint8 B);
+ Color& rgba(Uint8 R, Uint8 G, Uint8 B, Uint8 A);
+ Color& color(const SDL_Color& color);
+
+ SDL_Color to_SDL_Color() const;
+ };
+
+ class NFONT_EXPORT Rectf
+ {
+ public:
+ float x, y;
+ float w, h;
+
+ Rectf();
+ Rectf(float x, float y);
+ Rectf(float x, float y, float w, float h);
+ Rectf(const SDL_Rect& rect);
+
+ SDL_Rect to_SDL_Rect() const;
+
+ #ifdef NFONT_USE_SDL_GPU
+ Rectf(const GPU_Rect& rect);
+ GPU_Rect to_GPU_Rect() const;
+ #endif
+ };
+
+
+ enum AlignEnum {LEFT, CENTER, RIGHT};
+ enum FilterEnum {NEAREST, LINEAR};
+
+ class NFONT_EXPORT Scale
+ {
+ public:
+
+ float x;
+ float y;
+
+ enum ScaleTypeEnum {NEAREST};
+ ScaleTypeEnum type;
+
+ Scale()
+ : x(1.0f), y(1.0f), type(NEAREST)
+ {}
+ Scale(float xy)
+ : x(xy), y(xy), type(NEAREST)
+ {}
+ Scale(float xy, ScaleTypeEnum type)
+ : x(xy), y(xy), type(type)
+ {}
+ Scale(float x, float y)
+ : x(x), y(y), type(NEAREST)
+ {}
+ Scale(float x, float y, ScaleTypeEnum type)
+ : x(x), y(y), type(type)
+ {}
+ };
+
+ class NFONT_EXPORT Effect
+ {
+ public:
+ AlignEnum alignment;
+ Scale scale;
+ bool use_color;
+ Color color;
+
+ Effect()
+ : alignment(LEFT), use_color(false), color(255, 255, 255, 255)
+ {}
+
+ Effect(const Scale& scale)
+ : alignment(LEFT), scale(scale), use_color(false), color(255, 255, 255, 255)
+ {}
+ Effect(AlignEnum alignment)
+ : alignment(alignment), use_color(false), color(255, 255, 255, 255)
+ {}
+ Effect(const Color& color)
+ : alignment(LEFT), use_color(true), color(color)
+ {}
+
+ Effect(AlignEnum alignment, const Scale& scale)
+ : alignment(alignment), scale(scale), use_color(false), color(255, 255, 255, 255)
+ {}
+ Effect(AlignEnum alignment, const Color& color)
+ : alignment(alignment), use_color(true), color(color)
+ {}
+ Effect(const Scale& scale, const Color& color)
+ : alignment(LEFT), scale(scale), use_color(true), color(color)
+ {}
+ Effect(AlignEnum alignment, const Scale& scale, const Color& color)
+ : alignment(alignment), scale(scale), use_color(true), color(color)
+ {}
+ };
+
+
+ // Constructors
+ NFont();
+ NFont(const NFont& font);
+ #ifdef NFONT_USE_SDL_GPU
+ NFont(SDL_Surface* src);
+ NFont(TTF_Font* ttf);
+ NFont(TTF_Font* ttf, const NFont::Color& color);
+ NFont(const char* filename_ttf, Uint32 pointSize);
+ NFont(const char* filename_ttf, Uint32 pointSize, const NFont::Color& color, int style = 0);
+ NFont(SDL_RWops* file_rwops_ttf, Uint8 own_rwops, Uint32 pointSize, const NFont::Color& color, int style = 0);
+ #else
+ NFont(SDL_Renderer* renderer, SDL_Surface* src);
+ NFont(SDL_Renderer* renderer, TTF_Font* ttf);
+ NFont(SDL_Renderer* renderer, TTF_Font* ttf, const NFont::Color& color);
+ NFont(SDL_Renderer* renderer, const char* filename_ttf, Uint32 pointSize);
+ NFont(SDL_Renderer* renderer, const char* filename_ttf, Uint32 pointSize, const NFont::Color& color, int style = 0);
+ NFont(SDL_Renderer* renderer, SDL_RWops* file_rwops_ttf, Uint8 own_rwops, Uint32 pointSize, const NFont::Color& color, int style = 0);
+ #endif
+
+ ~NFont();
+
+ NFont& operator=(const NFont& font);
+
+ // Loading
+ void setLoadingString(const char* str);
+
+ #ifdef NFONT_USE_SDL_GPU
+ bool load(SDL_Surface* FontSurface);
+ bool load(TTF_Font* ttf);
+ bool load(TTF_Font* ttf, const NFont::Color& color);
+ bool load(const char* filename_ttf, Uint32 pointSize);
+ bool load(const char* filename_ttf, Uint32 pointSize, const NFont::Color& color, int style = 0);
+ bool load(SDL_RWops* file_rwops_ttf, Uint8 own_rwops, Uint32 pointSize, const NFont::Color& color, int style = 0);
+ #else
+ bool load(SDL_Renderer* renderer, SDL_Surface* FontSurface);
+ bool load(SDL_Renderer* renderer, TTF_Font* ttf);
+ bool load(SDL_Renderer* renderer, TTF_Font* ttf, const NFont::Color& color);
+ bool load(SDL_Renderer* renderer, const char* filename_ttf, Uint32 pointSize);
+ bool load(SDL_Renderer* renderer, const char* filename_ttf, Uint32 pointSize, const NFont::Color& color, int style = 0);
+ bool load(SDL_Renderer* renderer, SDL_RWops* file_rwops_ttf, Uint8 own_rwops, Uint32 pointSize, const NFont::Color& color, int style = 0);
+ #endif
+
+ void free();
+
+ // Drawing
+ #ifdef NFONT_USE_SDL_GPU
+ Rectf draw(GPU_Target* dest, float x, float y, const char* formatted_text, ...);
+ Rectf draw(GPU_Target* dest, float x, float y, AlignEnum align, const char* formatted_text, ...);
+ Rectf draw(GPU_Target* dest, float x, float y, const Scale& scale, const char* formatted_text, ...);
+ Rectf draw(GPU_Target* dest, float x, float y, const Color& color, const char* formatted_text, ...);
+ Rectf draw(GPU_Target* dest, float x, float y, const Effect& effect, const char* formatted_text, ...);
+
+ Rectf drawBox(GPU_Target* dest, const Rectf& box, const char* formatted_text, ...);
+ Rectf drawBox(GPU_Target* dest, const Rectf& box, AlignEnum align, const char* formatted_text, ...);
+ Rectf drawBox(GPU_Target* dest, const Rectf& box, const Scale& scale, const char* formatted_text, ...);
+ Rectf drawBox(GPU_Target* dest, const Rectf& box, const Color& color, const char* formatted_text, ...);
+ Rectf drawBox(GPU_Target* dest, const Rectf& box, const Effect& effect, const char* formatted_text, ...);
+
+ Rectf drawColumn(GPU_Target* dest, float x, float y, Uint16 width, const char* formatted_text, ...);
+ Rectf drawColumn(GPU_Target* dest, float x, float y, Uint16 width, AlignEnum align, const char* formatted_text, ...);
+ Rectf drawColumn(GPU_Target* dest, float x, float y, Uint16 width, const Scale& scale, const char* formatted_text, ...);
+ Rectf drawColumn(GPU_Target* dest, float x, float y, Uint16 width, const Color& color, const char* formatted_text, ...);
+ Rectf drawColumn(GPU_Target* dest, float x, float y, Uint16 width, const Effect& effect, const char* formatted_text, ...);
+ #else
+ Rectf draw(SDL_Renderer* dest, float x, float y, const char* formatted_text, ...);
+ Rectf draw(SDL_Renderer* dest, float x, float y, AlignEnum align, const char* formatted_text, ...);
+ Rectf draw(SDL_Renderer* dest, float x, float y, const Scale& scale, const char* formatted_text, ...);
+ Rectf draw(SDL_Renderer* dest, float x, float y, const Color& color, const char* formatted_text, ...);
+ Rectf draw(SDL_Renderer* dest, float x, float y, const Effect& effect, const char* formatted_text, ...);
+
+ Rectf drawBox(SDL_Renderer* dest, const Rectf& box, const char* formatted_text, ...);
+ Rectf drawBox(SDL_Renderer* dest, const Rectf& box, AlignEnum align, const char* formatted_text, ...);
+ Rectf drawBox(SDL_Renderer* dest, const Rectf& box, const Scale& scale, const char* formatted_text, ...);
+ Rectf drawBox(SDL_Renderer* dest, const Rectf& box, const Color& color, const char* formatted_text, ...);
+ Rectf drawBox(SDL_Renderer* dest, const Rectf& box, const Effect& effect, const char* formatted_text, ...);
+
+ Rectf drawColumn(SDL_Renderer* dest, float x, float y, Uint16 width, const char* formatted_text, ...);
+ Rectf drawColumn(SDL_Renderer* dest, float x, float y, Uint16 width, AlignEnum align, const char* formatted_text, ...);
+ Rectf drawColumn(SDL_Renderer* dest, float x, float y, Uint16 width, const Scale& scale, const char* formatted_text, ...);
+ Rectf drawColumn(SDL_Renderer* dest, float x, float y, Uint16 width, const Color& color, const char* formatted_text, ...);
+ Rectf drawColumn(SDL_Renderer* dest, float x, float y, Uint16 width, const Effect& effect, const char* formatted_text, ...);
+ #endif
+
+ // Getters
+ #ifdef NFONT_USE_SDL_GPU
+ GPU_Image* getImage() const;
+ #else
+ SDL_Texture* getImage() const;
+ #endif
+ SDL_Surface* getSurface() const;
+ FilterEnum getFilterMode() const;
+ Uint16 getHeight() const;
+ Uint16 getHeight(const char* formatted_text, ...) const;
+ Uint16 getWidth(const char* formatted_text, ...);
+ Rectf getCharacterOffset(Uint16 position_index, int column_width, const char* formatted_text, ...);
+ Uint16 getColumnHeight(Uint16 width, const char* formatted_text, ...);
+ int getSpacing() const;
+ int getLineSpacing() const;
+ Uint16 getBaseline() const;
+ int getAscent() const;
+ int getAscent(const char character);
+ int getAscent(const char* formatted_text, ...);
+ int getDescent() const;
+ int getDescent(const char character);
+ int getDescent(const char* formatted_text, ...);
+ Uint16 getMaxWidth() const;
+ Color getDefaultColor() const;
+
+ // Setters
+ void setFilterMode(FilterEnum filter);
+ void setSpacing(int LetterSpacing);
+ void setLineSpacing(int LineSpacing);
+ void setBaseline();
+ void setBaseline(Uint16 Baseline);
+ void setDefaultColor(const Color& color);
+
+ void enableTTFOwnership();
+
+ private:
+
+ static char* buffer;
+ FC_Font* font;
+
+ void init(); // Common constructor
+
+};
+
+
+
+#endif // _NFONT_H__
diff --git a/source/code/Libs/SDL_FontCache.cpp b/source/code/Libs/SDL_FontCache.cpp new file mode 100644 index 0000000..451b937 --- /dev/null +++ b/source/code/Libs/SDL_FontCache.cpp
@@ -0,0 +1,2488 @@
+/*
+SDL_FontCache v0.0.1: A font cache for SDL and SDL_ttf
+by Jonathan Dearborn
+Dedicated to the memory of Florian Hufsky
+
+License:
+ The short:
+ Use it however you'd like, but keep the copyright and license notice
+ whenever these files or parts of them are distributed in uncompiled form.
+
+ The long:
+Copyright (c) 2015 Jonathan Dearborn
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#include "SDL_FontCache.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+// Visual C does not support static inline
+#ifndef static_inline
+#ifdef _MSC_VER
+#define static_inline static
+#else
+#define static_inline static inline
+#endif
+#endif
+
+#if SDL_VERSION_ATLEAST(2,0,0)
+#define FC_GET_ALPHA(sdl_color) ((sdl_color).a)
+#else
+#define FC_GET_ALPHA(sdl_color) ((sdl_color).unused)
+#endif
+
+// Need SDL_RenderIsClipEnabled() for proper clipping support
+#if SDL_VERSION_ATLEAST(2,0,4)
+#define ENABLE_SDL_CLIPPING
+#endif
+
+#define FC_MIN(a,b) ((a) < (b)? (a) : (b))
+#define FC_MAX(a,b) ((a) > (b)? (a) : (b))
+
+
+#define FC_EXTRACT_VARARGS(buffer, start_args) \
+{ \
+ va_list lst; \
+ va_start(lst, start_args); \
+ vsprintf(buffer, start_args, lst); \
+ va_end(lst); \
+}
+
+// Extra pixels of padding around each glyph to avoid linear filtering artifacts
+#define FC_CACHE_PADDING 1
+
+
+
+static Uint8 has_clip(FC_Target* dest) {
+#ifdef FC_USE_SDL_GPU
+ return dest->use_clip_rect;
+#elif defined(ENABLE_SDL_CLIPPING)
+ return SDL_RenderIsClipEnabled(dest);
+#else
+ return 0;
+#endif
+}
+
+static FC_Rect get_clip(FC_Target* dest) {
+#ifdef FC_USE_SDL_GPU
+ return dest->clip_rect;
+#elif defined(ENABLE_SDL_CLIPPING)
+ SDL_Rect r;
+ SDL_RenderGetClipRect(dest, &r);
+ return r;
+#else
+ SDL_Rect r = {0, 0, 0, 0};
+ return r;
+#endif
+}
+
+static void set_clip(FC_Target* dest, FC_Rect* rect) {
+#ifdef FC_USE_SDL_GPU
+ if (rect != NULL) {
+ GPU_SetClipRect(dest, *rect);
+ }
+ else {
+ GPU_UnsetClip(dest);
+ }
+#elif defined(ENABLE_SDL_CLIPPING)
+ SDL_RenderSetClipRect(dest, rect);
+#endif
+}
+
+static void set_color(FC_Image* src, Uint8 r, Uint8 g, Uint8 b, Uint8 a) {
+#ifdef FC_USE_SDL_GPU
+ GPU_SetRGBA(src, r, g, b, a);
+#else
+ SDL_SetTextureColorMod(src, r, g, b);
+ SDL_SetTextureAlphaMod(src, a);
+#endif
+}
+
+
+
+static char* new_concat(const char* a, const char* b) {
+ // Create new buffer
+ unsigned int size = strlen(a) + strlen(b);
+ char* new_string = (char*)malloc(size+1);
+
+ // Concatenate strings in the new buffer
+ strcpy(new_string, a);
+ strcat(new_string, b);
+
+ return new_string;
+}
+
+static char* replace_concat(char** a, const char* b) {
+ char* new_string = new_concat(*a, b);
+ free(*a);
+ *a = new_string;
+ return *a;
+}
+
+
+
+
+
+// Shared buffer for variadic text
+static char* fc_buffer = NULL;
+
+static Uint8 fc_has_render_target_support = 0;
+
+const char* FC_GetStringASCII(void) {
+ static char* buffer = NULL;
+ if (buffer == NULL) {
+ int i;
+ char c;
+ buffer = (char*)malloc(512);
+ memset(buffer, 0, 512);
+ i = 0;
+ c = 32;
+ while (1) {
+ buffer[i] = c;
+ if (c == 126) {
+ break;
+ }
+ ++i;
+ ++c;
+ }
+ }
+ return buffer;
+}
+
+const char* FC_GetStringLatin1(void) {
+ static char* buffer = NULL;
+ if (buffer == NULL) {
+ int i;
+ unsigned char c;
+ buffer = (char*)malloc(512);
+ memset(buffer, 0, 512);
+ i = 0;
+ c = 0xA0;
+ while (1) {
+ buffer[i] = 0xC2;
+ buffer[i+1] = c;
+ if (c == 0xBF) {
+ break;
+ }
+ i += 2;
+ ++c;
+ }
+ i += 2;
+ c = 0x80;
+ while (1) {
+ buffer[i] = 0xC3;
+ buffer[i+1] = c;
+ if (c == 0xBF) {
+ break;
+ }
+ i += 2;
+ ++c;
+ }
+ }
+ return buffer;
+}
+
+const char* FC_GetStringASCII_Latin1(void) {
+ static char* buffer = NULL;
+ if (buffer == NULL) {
+ buffer = new_concat(FC_GetStringASCII(), FC_GetStringLatin1());
+ }
+
+ return buffer;
+}
+
+FC_Rect FC_MakeRect(float x, float y, float w, float h) {
+ FC_Rect r = {x, y, w, h};
+ return r;
+}
+
+FC_Scale FC_MakeScale(float x, float y) {
+ FC_Scale s = {x, y};
+
+ return s;
+}
+
+SDL_Color FC_MakeColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a) {
+ SDL_Color c = {r, g, b, a};
+
+ return c;
+}
+
+FC_Effect FC_MakeEffect(FC_AlignEnum alignment, FC_Scale scale, SDL_Color color) {
+ FC_Effect e;
+
+ e.alignment = alignment;
+ e.scale = scale;
+ e.color = color;
+
+ return e;
+}
+
+FC_GlyphData FC_MakeGlyphData(int cache_level, Sint16 x, Sint16 y, Uint16 w, Uint16 h) {
+ FC_GlyphData gd;
+
+ gd.rect.x = x;
+ gd.rect.y = y;
+ gd.rect.w = w;
+ gd.rect.h = h;
+ gd.cache_level = cache_level;
+
+ return gd;
+}
+
+// Enough to hold all of the ascii characters and some.
+#define FC_DEFAULT_NUM_BUCKETS 300
+
+typedef struct FC_MapNode {
+ Uint32 key;
+ FC_GlyphData value;
+ struct FC_MapNode* next;
+
+} FC_MapNode;
+
+typedef struct FC_Map {
+ int num_buckets;
+ FC_MapNode** buckets;
+} FC_Map;
+
+
+
+static FC_Map* FC_MapCreate(int num_buckets) {
+ int i;
+ FC_Map* map = (FC_Map*)malloc(sizeof(FC_Map));
+
+ map->num_buckets = num_buckets;
+ map->buckets = (FC_MapNode**)malloc(num_buckets * sizeof(FC_MapNode*));
+
+ for (i = 0; i < num_buckets; ++i) {
+ map->buckets[i] = NULL;
+ }
+
+ return map;
+}
+
+/*static void FC_MapClear(FC_Map* map)
+{
+ int i;
+ if(map == NULL)
+ return;
+
+ // Go through each bucket
+ for(i = 0; i < map->num_buckets; ++i)
+ {
+ // Delete the nodes in order
+ FC_MapNode* node = map->buckets[i];
+ while(node != NULL)
+ {
+ FC_MapNode* last = node;
+ node = node->next;
+ free(last);
+ }
+ // Set the bucket to empty
+ map->buckets[i] = NULL;
+ }
+}*/
+
+static void FC_MapFree(FC_Map* map) {
+ int i;
+ if (map == NULL) {
+ return;
+ }
+
+ // Go through each bucket
+ for (i = 0; i < map->num_buckets; ++i) {
+ // Delete the nodes in order
+ FC_MapNode* node = map->buckets[i];
+ while (node != NULL) {
+ FC_MapNode* last = node;
+ node = node->next;
+ free(last);
+ }
+ }
+
+ free(map->buckets);
+ free(map);
+}
+
+// Note: Does not handle duplicates in any special way.
+static FC_GlyphData* FC_MapInsert(FC_Map* map, Uint32 codepoint, FC_GlyphData glyph) {
+ Uint32 index;
+ FC_MapNode* node;
+ if (map == NULL) {
+ return NULL;
+ }
+
+ // Get index for bucket
+ index = codepoint % map->num_buckets;
+
+ // If this bucket is empty, create a node and return its value
+ if (map->buckets[index] == NULL) {
+ node = map->buckets[index] = (FC_MapNode*)malloc(sizeof(FC_MapNode));
+ node->key = codepoint;
+ node->value = glyph;
+ node->next = NULL;
+ return &node->value;
+ }
+
+ for (node = map->buckets[index]; node != NULL; node = node->next) {
+ // Find empty node and add a new one on.
+ if (node->next == NULL) {
+ node->next = (FC_MapNode*)malloc(sizeof(FC_MapNode));
+ node = node->next;
+
+ node->key = codepoint;
+ node->value = glyph;
+ node->next = NULL;
+ return &node->value;
+ }
+ }
+
+ return NULL;
+}
+
+static FC_GlyphData* FC_MapFind(FC_Map* map, Uint32 codepoint) {
+ Uint32 index;
+ FC_MapNode* node;
+ if (map == NULL) {
+ return NULL;
+ }
+
+ // Get index for bucket
+ index = codepoint % map->num_buckets;
+
+ // Go through list until we find a match
+ for (node = map->buckets[index]; node != NULL; node = node->next) {
+ if (node->key == codepoint) {
+ return &node->value;
+ }
+ }
+
+ return NULL;
+}
+
+
+
+struct FC_Font {
+#ifndef FC_USE_SDL_GPU
+ SDL_Renderer* renderer;
+#endif
+
+ TTF_Font* ttf_source; // TTF_Font source of characters
+ Uint8 owns_ttf_source; // Can we delete the TTF_Font ourselves?
+
+ FC_FilterEnum filter;
+
+ SDL_Color default_color;
+ Uint16 height;
+
+ Uint16 maxWidth;
+ Uint16 baseline;
+ int ascent;
+ int descent;
+
+ int lineSpacing;
+ int letterSpacing;
+
+ // Uses 32-bit (4-byte) Unicode codepoints to refer to each glyph
+ // Codepoints are little endian (reversed from UTF-8) so that something like 0x00000005 is ASCII 5 and the map can be indexed by ASCII values
+ FC_Map* glyphs;
+
+ FC_GlyphData last_glyph; // Texture packing cursor
+ int glyph_cache_size;
+ int glyph_cache_count;
+ FC_Image** glyph_cache;
+
+ char* loading_string;
+
+};
+
+// Private
+static FC_GlyphData* FC_PackGlyphData(FC_Font* font, Uint32 codepoint, Uint16 width, Uint16 maxWidth, Uint16 maxHeight);
+
+
+static FC_Rect FC_RenderLeft(FC_Font* font, FC_Target* dest, float x, float y, FC_Scale scale, const char* text);
+static FC_Rect FC_RenderCenter(FC_Font* font, FC_Target* dest, float x, float y, FC_Scale scale, const char* text);
+static FC_Rect FC_RenderRight(FC_Font* font, FC_Target* dest, float x, float y, FC_Scale scale, const char* text);
+
+
+static_inline SDL_Surface* FC_CreateSurface32(Uint32 width, Uint32 height) {
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+ return SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
+#else
+ return SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
+#endif
+}
+
+
+char* U8_alloc(unsigned int size) {
+ char* result;
+ if (size == 0) {
+ return NULL;
+ }
+
+ result = (char*)malloc(size);
+ result[0] = '\0';
+
+ return result;
+}
+
+void U8_free(char* string) {
+ free(string);
+}
+
+char* U8_strdup(const char* string) {
+ char* result;
+ if (string == NULL) {
+ return NULL;
+ }
+
+ result = (char*)malloc(strlen(string)+1);
+ strcpy(result, string);
+
+ return result;
+}
+
+int U8_strlen(const char* string) {
+ int length = 0;
+ if (string == NULL) {
+ return 0;
+ }
+
+ while (*string != '\0') {
+ string = U8_next(string);
+ ++length;
+ }
+
+ return length;
+}
+
+int U8_charsize(const char* character) {
+ if (character == NULL) {
+ return 0;
+ }
+
+ if ((unsigned char)*character <= 0x7F) {
+ return 1;
+ }
+ else if ((unsigned char)*character < 0xE0) {
+ return 2;
+ }
+ else if ((unsigned char)*character < 0xF0) {
+ return 3;
+ }
+ else {
+ return 4;
+ }
+ return 1;
+}
+
+int U8_charcpy(char* buffer, const char* source, int buffer_size) {
+ int charsize;
+ if (buffer == NULL || source == NULL || buffer_size < 1) {
+ return 0;
+ }
+
+ charsize = U8_charsize(source);
+ if (charsize > buffer_size) {
+ return 0;
+ }
+
+ memcpy(buffer, source, charsize);
+ return charsize;
+}
+
+const char* U8_next(const char* string) {
+ return string + U8_charsize(string);
+}
+
+int U8_strinsert(char* string, int position, const char* source, int max_bytes) {
+ int pos_bytes;
+ int len = strlen(string);
+ int add_len = strlen(source);
+ int ulen = U8_strlen(string);
+
+ if (position == -1) {
+ position = ulen;
+ }
+
+ if (string == NULL || source == NULL || position < 0 || position > ulen || len + add_len + 1 > max_bytes) {
+ return 0;
+ }
+
+ // Move string pointer to the proper position
+ pos_bytes = 0;
+ while (*string != '\0' && pos_bytes < position) {
+ string = (char*)U8_next(string);
+ ++pos_bytes;
+ }
+
+ // Move the rest of the string out of the way
+ memmove(string + add_len, string, len - pos_bytes + 1);
+
+ // Copy in the new characters
+ memcpy(string, source, add_len);
+
+ return 1;
+}
+
+void U8_strdel(char* string, int position) {
+ if (string == NULL || position < 0) {
+ return;
+ }
+
+ while (*string != '\0') {
+ if (position == 0) {
+ int chars_to_erase = U8_charsize(string);
+ int remaining_bytes = strlen(string) + 1;
+ memmove(string, string + chars_to_erase, remaining_bytes);
+ break;
+ }
+
+ string = (char*)U8_next(string);
+ --position;
+ }
+}
+
+
+
+
+
+static_inline FC_Rect FC_RectUnion(FC_Rect A, FC_Rect B) {
+ float x,x2,y,y2;
+ x = FC_MIN(A.x, B.x);
+ y = FC_MIN(A.y, B.y);
+ x2 = FC_MAX(A.x+A.w, B.x+B.w);
+ y2 = FC_MAX(A.y+A.h, B.y+B.h);
+ {
+ FC_Rect result = {x, y, FC_MAX(0, x2 - x), FC_MAX(0, y2 - y)};
+ return result;
+ }
+}
+
+// Adapted from SDL_IntersectRect
+static_inline FC_Rect FC_RectIntersect(FC_Rect A, FC_Rect B) {
+ FC_Rect result;
+ float Amin, Amax, Bmin, Bmax;
+
+ // Horizontal intersection
+ Amin = A.x;
+ Amax = Amin + A.w;
+ Bmin = B.x;
+ Bmax = Bmin + B.w;
+ if (Bmin > Amin) {
+ Amin = Bmin;
+ }
+ result.x = Amin;
+ if (Bmax < Amax) {
+ Amax = Bmax;
+ }
+ result.w = Amax - Amin > 0 ? Amax - Amin : 0;
+
+ // Vertical intersection
+ Amin = A.y;
+ Amax = Amin + A.h;
+ Bmin = B.y;
+ Bmax = Bmin + B.h;
+ if (Bmin > Amin) {
+ Amin = Bmin;
+ }
+ result.y = Amin;
+ if (Bmax < Amax) {
+ Amax = Bmax;
+ }
+ result.h = Amax - Amin > 0 ? Amax - Amin : 0;
+
+ return result;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+FC_Rect FC_DefaultRenderCallback(FC_Image* src, FC_Rect* srcrect, FC_Target* dest, float x, float y, float xscale, float yscale) {
+ float w = srcrect->w * xscale;
+ float h = srcrect->h * yscale;
+ FC_Rect result;
+
+ // FIXME: Why does the scaled offset look so wrong?
+#ifdef FC_USE_SDL_GPU
+ {
+ GPU_Rect r = *srcrect;
+ GPU_BlitScale(src, &r, dest, x + xscale*r.w/2.0f, y + r.h/2.0f, xscale, yscale);
+ }
+#else
+ {
+ int flip = SDL_FLIP_NONE;
+ if (xscale < 0) {
+ xscale = -xscale;
+ flip |= SDL_FLIP_HORIZONTAL;
+ }
+ if (yscale < 0) {
+ yscale = -yscale;
+ flip |= SDL_FLIP_VERTICAL;
+ }
+
+ SDL_Rect r = *srcrect;
+ SDL_Rect dr = {(int)x, (int)y, (int)(xscale*r.w), (int)(yscale*r.h)};
+ SDL_RenderCopyEx(dest, src, &r, &dr, 0, NULL, (SDL_RendererFlip)flip);
+ }
+#endif
+
+ result.x = x;
+ result.y = y;
+ result.w = w;
+ result.h = h;
+ return result;
+}
+
+static FC_Rect (*fc_render_callback)(FC_Image* src, FC_Rect* srcrect, FC_Target* dest, float x, float y, float xscale, float yscale) = &FC_DefaultRenderCallback;
+
+void FC_SetRenderCallback(FC_Rect (*callback)(FC_Image* src, FC_Rect* srcrect, FC_Target* dest, float x, float y, float xscale, float yscale)) {
+ if (callback == NULL) {
+ fc_render_callback = &FC_DefaultRenderCallback;
+ }
+ else {
+ fc_render_callback = callback;
+ }
+}
+
+void FC_GetUTF8FromCodepoint(char* result, Uint32 codepoint) {
+ char a, b, c, d;
+
+ if (result == NULL) {
+ return;
+ }
+
+ a = (codepoint >> 24) & 0xFF;
+ b = (codepoint >> 16) & 0xFF;
+ c = (codepoint >> 8) & 0xFF;
+ d = codepoint & 0xFF;
+
+ if (a == 0) {
+ if (b == 0) {
+ if (c == 0) {
+ result[0] = d;
+ result[1] = '\0';
+ }
+ else {
+ result[0] = c;
+ result[1] = d;
+ result[2] = '\0';
+ }
+ }
+ else {
+ result[0] = b;
+ result[1] = c;
+ result[2] = d;
+ result[3] = '\0';
+ }
+ }
+ else {
+ result[0] = a;
+ result[1] = b;
+ result[2] = c;
+ result[3] = d;
+ result[4] = '\0';
+ }
+}
+
+Uint32 FC_GetCodepointFromUTF8(const char** c, Uint8 advance_pointer) {
+ Uint32 result = 0;
+ const char* str;
+ if (c == NULL || *c == NULL) {
+ return 0;
+ }
+
+ str = *c;
+ if ((unsigned char)*str <= 0x7F) {
+ result = *str;
+ }
+ else if ((unsigned char)*str < 0xE0) {
+ result |= (unsigned char)(*str) << 8;
+ result |= (unsigned char)(*(str+1));
+ if (advance_pointer) {
+ *c += 1;
+ }
+ }
+ else if ((unsigned char)*str < 0xF0) {
+ result |= (unsigned char)(*str) << 16;
+ result |= (unsigned char)(*(str+1)) << 8;
+ result |= (unsigned char)(*(str+2));
+ if (advance_pointer) {
+ *c += 2;
+ }
+ }
+ else {
+ result |= (unsigned char)(*str) << 24;
+ result |= (unsigned char)(*(str+1)) << 16;
+ result |= (unsigned char)(*(str+2)) << 8;
+ result |= (unsigned char)(*(str+3));
+ if (advance_pointer) {
+ *c += 3;
+ }
+ }
+ return result;
+}
+
+
+void FC_SetLoadingString(FC_Font* font, const char* string) {
+ if (font == NULL) {
+ return;
+ }
+
+ free(font->loading_string);
+ font->loading_string = U8_strdup(string);
+}
+
+
+void FC_SetBufferSize(unsigned int size) {
+ free(fc_buffer);
+ if (size > 0) {
+ fc_buffer = (char*)malloc(size);
+ }
+ else {
+ fc_buffer = (char*)malloc(1024);
+ }
+}
+
+
+
+
+
+// Constructors
+
+static void FC_Init(FC_Font* font) {
+ if (font == NULL) {
+ return;
+ }
+
+#ifndef FC_USE_SDL_GPU
+ font->renderer = NULL;
+#endif
+
+ font->ttf_source = NULL;
+ font->owns_ttf_source = 0;
+
+ font->filter = FC_FILTER_NEAREST;
+
+ font->default_color.r = 0;
+ font->default_color.g = 0;
+ font->default_color.b = 0;
+ FC_GET_ALPHA(font->default_color) = 255;
+
+ font->height = 0; // ascent+descent
+
+ font->maxWidth = 0;
+ font->baseline = 0;
+ font->ascent = 0;
+ font->descent = 0;
+
+ font->lineSpacing = 0;
+ font->letterSpacing = 0;
+
+ // Give a little offset for when filtering/mipmaps are used. Depending on mipmap level, this will still not be enough.
+ font->last_glyph.rect.x = FC_CACHE_PADDING;
+ font->last_glyph.rect.y = FC_CACHE_PADDING;
+ font->last_glyph.rect.w = 0;
+ font->last_glyph.rect.h = 0;
+ font->last_glyph.cache_level = 0;
+
+ if (font->glyphs != NULL) {
+ FC_MapFree(font->glyphs);
+ }
+
+ font->glyphs = FC_MapCreate(FC_DEFAULT_NUM_BUCKETS);
+
+ font->glyph_cache_size = 3;
+ font->glyph_cache_count = 0;
+
+
+ font->glyph_cache = (FC_Image**)malloc(font->glyph_cache_size * sizeof(FC_Image*));
+
+ if (font->loading_string == NULL) {
+ font->loading_string = U8_strdup(FC_GetStringASCII());
+ }
+
+ if (fc_buffer == NULL) {
+ fc_buffer = (char*)malloc(1024);
+ }
+}
+
+static Uint8 FC_GrowGlyphCache(FC_Font* font) {
+ if (font == NULL) {
+ return 0;
+ }
+#ifdef FC_USE_SDL_GPU
+ GPU_Image* new_level = GPU_CreateImage(font->height * 12, font->height * 12, GPU_FORMAT_RGBA);
+#else
+ SDL_Texture* new_level = SDL_CreateTexture(font->renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, font->height * 12, font->height * 12);
+#endif
+ if (new_level == NULL || !FC_SetGlyphCacheLevel(font, font->glyph_cache_count, new_level)) {
+ FC_Log("Error: SDL_FontCache ran out of packing space and could not add another cache level.\n");
+#ifdef FC_USE_SDL_GPU
+ GPU_FreeImage(new_level);
+#else
+ SDL_DestroyTexture(new_level);
+#endif
+ return 0;
+ }
+ return 1;
+}
+
+static Uint8 FC_UploadGlyphCache(FC_Font* font, int cache_level, SDL_Surface* data_surface) {
+ if (font == NULL || data_surface == NULL) {
+ return 0;
+ }
+#ifdef FC_USE_SDL_GPU
+ GPU_Image* new_level = GPU_CopyImageFromSurface(data_surface);
+ if (FC_GetFilterMode(font) == FC_FILTER_LINEAR) {
+ GPU_SetImageFilter(new_level, GPU_FILTER_LINEAR);
+ }
+ else {
+ GPU_SetImageFilter(new_level, GPU_FILTER_NEAREST);
+ }
+#else
+ SDL_Texture* new_level;
+ if (!fc_has_render_target_support) {
+ new_level = SDL_CreateTextureFromSurface(font->renderer, data_surface);
+ }
+ else {
+ // Must upload with render target enabled so we can put more glyphs on later
+ SDL_Renderer* renderer = font->renderer;
+
+ // Set filter mode for new texture
+ const char* old_filter_mode = SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY);
+ if (FC_GetFilterMode(font) == FC_FILTER_LINEAR) {
+ SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "1");
+ }
+ else {
+ SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0");
+ }
+
+ new_level = SDL_CreateTexture(renderer, data_surface->format->format, SDL_TEXTUREACCESS_TARGET, data_surface->w, data_surface->h);
+ SDL_SetTextureBlendMode(new_level, SDL_BLENDMODE_BLEND);
+
+ // Reset filter mode for the temp texture
+ SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "0");
+
+ {
+ Uint8 r, g, b, a;
+ SDL_Texture* temp = SDL_CreateTextureFromSurface(renderer, data_surface);
+ SDL_SetTextureBlendMode(temp, SDL_BLENDMODE_NONE);
+ SDL_SetRenderTarget(renderer, new_level);
+
+ SDL_GetRenderDrawColor(renderer, &r, &g, &b, &a);
+ SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0);
+ SDL_RenderClear(renderer);
+ SDL_SetRenderDrawColor(renderer, r, g, b, a);
+
+ SDL_RenderCopy(renderer, temp, NULL, NULL);
+ SDL_SetRenderTarget(renderer, NULL);
+
+ SDL_DestroyTexture(temp);
+ }
+
+ // Reset to the old filter value
+ SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, old_filter_mode);
+
+ }
+#endif
+ if (new_level == NULL || !FC_SetGlyphCacheLevel(font, cache_level, new_level)) {
+ FC_Log("Error: SDL_FontCache ran out of packing space and could not add another cache level.\n");
+#ifdef FC_USE_SDL_GPU
+ GPU_FreeImage(new_level);
+#else
+ SDL_DestroyTexture(new_level);
+#endif
+ return 0;
+ }
+ return 1;
+}
+
+static FC_GlyphData* FC_PackGlyphData(FC_Font* font, Uint32 codepoint, Uint16 width, Uint16 maxWidth, Uint16 maxHeight) {
+ FC_Map* glyphs = font->glyphs;
+ FC_GlyphData* last_glyph = &font->last_glyph;
+ Uint16 height = font->height + FC_CACHE_PADDING;
+
+ if (last_glyph->rect.x + last_glyph->rect.w + width >= maxWidth - FC_CACHE_PADDING) {
+ if (last_glyph->rect.y + height + height >= maxHeight - FC_CACHE_PADDING) {
+ // Get ready to pack on the next cache level when it is ready
+ last_glyph->cache_level = font->glyph_cache_count;
+ last_glyph->rect.x = FC_CACHE_PADDING;
+ last_glyph->rect.y = FC_CACHE_PADDING;
+ last_glyph->rect.w = 0;
+ return NULL;
+ }
+ else {
+ // Go to next row
+ last_glyph->rect.x = FC_CACHE_PADDING;
+ last_glyph->rect.y += height;
+ last_glyph->rect.w = 0;
+ }
+ }
+
+ // Move to next space
+ last_glyph->rect.x += last_glyph->rect.w + 1 + FC_CACHE_PADDING;
+ last_glyph->rect.w = width;
+
+ return FC_MapInsert(glyphs, codepoint, FC_MakeGlyphData(last_glyph->cache_level, last_glyph->rect.x, last_glyph->rect.y, last_glyph->rect.w, last_glyph->rect.h));
+}
+
+
+FC_Image* FC_GetGlyphCacheLevel(FC_Font* font, int cache_level) {
+ if (font == NULL || cache_level < 0 || cache_level > font->glyph_cache_count) {
+ return NULL;
+ }
+
+ return font->glyph_cache[cache_level];
+}
+
+Uint8 FC_SetGlyphCacheLevel(FC_Font* font, int cache_level, FC_Image* cache_texture) {
+ if (font == NULL || cache_level < 0) {
+ return 0;
+ }
+
+ // Must be sequentially added
+ if (cache_level > font->glyph_cache_count + 1) {
+ return 0;
+ }
+
+ if (cache_level == font->glyph_cache_count) {
+ font->glyph_cache_count++;
+
+ // Grow cache?
+ if (font->glyph_cache_count > font->glyph_cache_size) {
+ // Copy old cache to new one
+ int i;
+ FC_Image** new_cache;
+ new_cache = (FC_Image**)malloc(font->glyph_cache_count * sizeof(FC_Image*));
+ for (i = 0; i < font->glyph_cache_size; ++i) {
+ new_cache[i] = font->glyph_cache[i];
+ }
+
+ // Save new cache
+ free(font->glyph_cache);
+ font->glyph_cache_size = font->glyph_cache_count;
+ font->glyph_cache = new_cache;
+ }
+ }
+
+ font->glyph_cache[cache_level] = cache_texture;
+ return 1;
+}
+
+
+FC_Font* FC_CreateFont(void) {
+ FC_Font* font;
+
+ font = (FC_Font*)malloc(sizeof(FC_Font));
+ memset(font, 0, sizeof(FC_Font));
+
+ FC_Init(font);
+
+ return font;
+}
+
+
+// Assume this many will be enough...
+#define FC_LOAD_MAX_SURFACES 10
+
+#ifdef FC_USE_SDL_GPU
+Uint8 FC_LoadFontFromTTF(FC_Font* font, TTF_Font* ttf, SDL_Color color)
+#else
+Uint8 FC_LoadFontFromTTF(FC_Font* font, SDL_Renderer* renderer, TTF_Font* ttf, SDL_Color color)
+#endif
+{
+ if (font == NULL || ttf == NULL) {
+ return 0;
+ }
+#ifndef FC_USE_SDL_GPU
+ if (renderer == NULL) {
+ return 0;
+ }
+#endif
+
+ FC_ClearFont(font);
+
+
+ // Might as well check render target support here
+#ifdef FC_USE_SDL_GPU
+ fc_has_render_target_support = GPU_IsFeatureEnabled(GPU_FEATURE_RENDER_TARGETS);
+#else
+ SDL_RendererInfo info;
+ SDL_GetRendererInfo(renderer, &info);
+ fc_has_render_target_support = (info.flags & SDL_RENDERER_TARGETTEXTURE);
+
+ font->renderer = renderer;
+#endif
+
+ font->ttf_source = ttf;
+
+ //font->line_height = TTF_FontLineSkip(ttf);
+ font->height = TTF_FontHeight(ttf);
+ font->ascent = TTF_FontAscent(ttf);
+ font->descent = -TTF_FontDescent(ttf);
+
+ font->baseline = font->height - font->descent;
+
+ font->default_color = color;
+
+ {
+ SDL_Color white = {255, 255, 255, 255};
+ SDL_Surface* glyph_surf;
+ char buff[5];
+ const char* buff_ptr = buff;
+ const char* source_string;
+ Uint8 packed = 0;
+
+ // Copy glyphs from the surface to the font texture and store the position data
+ // Pack row by row into a square texture
+ // Try figuring out dimensions that make sense for the font size.
+ unsigned int w = font->height*12;
+ unsigned int h = font->height*12;
+ SDL_Surface* surfaces[FC_LOAD_MAX_SURFACES];
+ int num_surfaces = 1;
+ surfaces[0] = FC_CreateSurface32(w, h);
+ font->last_glyph.rect.x = FC_CACHE_PADDING;
+ font->last_glyph.rect.y = FC_CACHE_PADDING;
+ font->last_glyph.rect.w = 0;
+ font->last_glyph.rect.h = font->height;
+
+ memset(buff, 0, 5);
+ source_string = font->loading_string;
+ for (; *source_string != '\0'; source_string = U8_next(source_string)) {
+ if (!U8_charcpy(buff, source_string, 5)) {
+ continue;
+ }
+ glyph_surf = TTF_RenderUTF8_Blended(ttf, buff, white);
+ if (glyph_surf == NULL) {
+ continue;
+ }
+
+ // Try packing. If it fails, create a new surface for the next cache level.
+ packed = (FC_PackGlyphData(font, FC_GetCodepointFromUTF8(&buff_ptr, 0), glyph_surf->w, surfaces[num_surfaces-1]->w, surfaces[num_surfaces-1]->h) != NULL);
+ if (!packed) {
+ int i = num_surfaces-1;
+ if (num_surfaces >= FC_LOAD_MAX_SURFACES) {
+ // Can't do any more!
+ FC_Log("SDL_FontCache error: Could not create enough cache surfaces to fit all of the loading string!\n");
+ SDL_FreeSurface(glyph_surf);
+ break;
+ }
+
+ // Upload the current surface to the glyph cache now so we can keep the cache level packing cursor up to date as we go.
+ FC_UploadGlyphCache(font, i, surfaces[i]);
+ SDL_FreeSurface(surfaces[i]);
+#ifndef FC_USE_SDL_GPU
+ SDL_SetTextureBlendMode(font->glyph_cache[i], SDL_BLENDMODE_BLEND);
+#endif
+ // Update the glyph cursor to the new cache level. We need to do this here because the actual cache lags behind our use of the packing above.
+ font->last_glyph.cache_level = num_surfaces;
+
+
+ surfaces[num_surfaces] = FC_CreateSurface32(w, h);
+ num_surfaces++;
+ }
+
+ // Try packing for the new surface, then blit onto it.
+ if (packed || FC_PackGlyphData(font, FC_GetCodepointFromUTF8(&buff_ptr, 0), glyph_surf->w, surfaces[num_surfaces-1]->w, surfaces[num_surfaces-1]->h) != NULL) {
+ SDL_SetSurfaceBlendMode(glyph_surf, SDL_BLENDMODE_NONE);
+ SDL_Rect srcRect = {0, 0, glyph_surf->w, glyph_surf->h};
+ SDL_Rect destrect = font->last_glyph.rect;
+ SDL_BlitSurface(glyph_surf, &srcRect, surfaces[num_surfaces-1], &destrect);
+ }
+
+ SDL_FreeSurface(glyph_surf);
+ }
+
+ {
+ int i = num_surfaces-1;
+ FC_UploadGlyphCache(font, i, surfaces[i]);
+ SDL_FreeSurface(surfaces[i]);
+#ifndef FC_USE_SDL_GPU
+ SDL_SetTextureBlendMode(font->glyph_cache[i], SDL_BLENDMODE_BLEND);
+#endif
+ }
+ }
+
+ return 1;
+}
+
+
+#ifdef FC_USE_SDL_GPU
+Uint8 FC_LoadFont(FC_Font* font, const char* filename_ttf, Uint32 pointSize, SDL_Color color, int style)
+#else
+Uint8 FC_LoadFont(FC_Font* font, FC_Target* renderer, const char* filename_ttf, Uint32 pointSize, SDL_Color color, int style)
+#endif
+{
+ SDL_RWops* rwops;
+
+ if (font == NULL) {
+ return 0;
+ }
+
+ rwops = SDL_RWFromFile(filename_ttf, "rb");
+
+ if (rwops == NULL) {
+ FC_Log("Unable to open file for reading: %s \n", SDL_GetError());
+ return 0;
+ }
+
+#ifdef FC_USE_SDL_GPU
+ return FC_LoadFont_RW(font, rwops, 1, pointSize, color, style);
+#else
+ return FC_LoadFont_RW(font, renderer, rwops, 1, pointSize, color, style);
+#endif
+}
+
+#ifdef FC_USE_SDL_GPU
+Uint8 FC_LoadFont_RW(FC_Font* font, SDL_RWops* file_rwops_ttf, Uint8 own_rwops, Uint32 pointSize, SDL_Color color, int style)
+#else
+Uint8 FC_LoadFont_RW(FC_Font* font, FC_Target* renderer, SDL_RWops* file_rwops_ttf, Uint8 own_rwops, Uint32 pointSize, SDL_Color color, int style)
+#endif
+{
+ Uint8 result;
+ TTF_Font* ttf;
+ Uint8 outline;
+
+ if (font == NULL) {
+ return 0;
+ }
+
+ if (!TTF_WasInit() && TTF_Init() < 0) {
+ FC_Log("Unable to initialize SDL_ttf: %s \n", TTF_GetError());
+ if (own_rwops) {
+ SDL_RWclose(file_rwops_ttf);
+ }
+ return 0;
+ }
+
+ ttf = TTF_OpenFontRW(file_rwops_ttf, own_rwops, pointSize);
+
+ if (ttf == NULL) {
+ FC_Log("Unable to load TrueType font: %s \n", TTF_GetError());
+ if (own_rwops) {
+ SDL_RWclose(file_rwops_ttf);
+ }
+ return 0;
+ }
+
+ outline = (style & TTF_STYLE_OUTLINE);
+ if (outline) {
+ style &= ~TTF_STYLE_OUTLINE;
+ TTF_SetFontOutline(ttf, 1);
+ }
+ TTF_SetFontStyle(ttf, style);
+
+#ifdef FC_USE_SDL_GPU
+ result = FC_LoadFontFromTTF(font, ttf, color);
+#else
+ result = FC_LoadFontFromTTF(font, renderer, ttf, color);
+#endif
+
+ // Can only load new (uncached) glyphs if we can keep the SDL_RWops open.
+ font->owns_ttf_source = own_rwops;
+ if (!own_rwops) {
+ TTF_CloseFont(font->ttf_source);
+ font->ttf_source = NULL;
+ }
+
+ return result;
+}
+
+
+void FC_ClearFont(FC_Font* font) {
+ int i;
+ if (font == NULL) {
+ return;
+ }
+
+ // Release resources
+ if (font->owns_ttf_source) {
+ TTF_CloseFont(font->ttf_source);
+ }
+
+ font->owns_ttf_source = 0;
+ font->ttf_source = NULL;
+
+ // Delete glyph map
+ FC_MapFree(font->glyphs);
+ font->glyphs = NULL;
+
+ // Delete glyph cache
+ for (i = 0; i < font->glyph_cache_count; ++i) {
+#ifdef FC_USE_SDL_GPU
+ GPU_FreeImage(font->glyph_cache[i]);
+#else
+ SDL_DestroyTexture(font->glyph_cache[i]);
+#endif
+ }
+ free(font->glyph_cache);
+ font->glyph_cache = NULL;
+
+ // Reset font
+ FC_Init(font);
+}
+
+
+void FC_FreeFont(FC_Font* font) {
+ int i;
+ if (font == NULL) {
+ return;
+ }
+
+ // Release resources
+ if (font->owns_ttf_source) {
+ TTF_CloseFont(font->ttf_source);
+ }
+
+ // Delete glyph map
+ FC_MapFree(font->glyphs);
+
+ // Delete glyph cache
+ for (i = 0; i < font->glyph_cache_count; ++i) {
+#ifdef FC_USE_SDL_GPU
+ GPU_FreeImage(font->glyph_cache[i]);
+#else
+ SDL_DestroyTexture(font->glyph_cache[i]);
+#endif
+ }
+ free(font->glyph_cache);
+
+ free(font->loading_string);
+
+ free(font);
+}
+
+int FC_GetNumCacheLevels(FC_Font* font) {
+ return font->glyph_cache_count;
+}
+
+Uint8 FC_AddGlyphToCache(FC_Font* font, SDL_Surface* glyph_surface) {
+ if (font == NULL || glyph_surface == NULL) {
+ return 0;
+ }
+
+ SDL_SetSurfaceBlendMode(glyph_surface, SDL_BLENDMODE_NONE);
+ FC_Image* dest = FC_GetGlyphCacheLevel(font, font->last_glyph.cache_level);
+ if (dest == NULL) {
+ return 0;
+ }
+
+#ifdef FC_USE_SDL_GPU
+ {
+ GPU_Target* target = GPU_LoadTarget(dest);
+ if (target == NULL) {
+ return 0;
+ }
+ GPU_Image* img = GPU_CopyImageFromSurface(glyph_surface);
+ GPU_SetImageFilter(img, GPU_FILTER_NEAREST);
+ GPU_SetBlendMode(img, GPU_BLEND_SET);
+
+ SDL_Rect destrect = font->last_glyph.rect;
+ GPU_Blit(img, NULL, target, destrect.x + destrect.w/2, destrect.y + destrect.h/2);
+
+ GPU_FreeImage(img);
+ GPU_FreeTarget(target);
+ }
+#else
+ {
+ SDL_Texture* img = SDL_CreateTextureFromSurface(font->renderer, glyph_surface);
+
+ SDL_Rect destrect = font->last_glyph.rect;
+ SDL_SetRenderTarget(font->renderer, dest);
+ SDL_RenderCopy(font->renderer, img, NULL, &destrect);
+ SDL_SetRenderTarget(font->renderer, NULL);
+ SDL_DestroyTexture(img);
+ }
+#endif
+
+ return 1;
+}
+
+Uint8 FC_GetGlyphData(FC_Font* font, FC_GlyphData* result, Uint32 codepoint) {
+ FC_GlyphData* e = FC_MapFind(font->glyphs, codepoint);
+ if (e == NULL || result == NULL) {
+ char buff[5];
+ int w, h;
+ SDL_Color white = {255, 255, 255, 255};
+ SDL_Surface* surf;
+ FC_Image* cache_image;
+
+ if (font->ttf_source == NULL) {
+ return 0;
+ }
+
+ FC_GetUTF8FromCodepoint(buff, codepoint);
+
+ cache_image = FC_GetGlyphCacheLevel(font, font->last_glyph.cache_level);
+ if (cache_image == NULL) {
+ FC_Log("SDL_FontCache: Failed to load cache image, so cannot add new glyphs!\n");
+ return 0;
+ }
+#ifdef FC_USE_SDL_GPU
+ w = cache_image->w;
+ h = cache_image->h;
+#else
+ SDL_QueryTexture(cache_image, NULL, NULL, &w, &h);
+#endif
+
+ surf = TTF_RenderUTF8_Blended(font->ttf_source, buff, white);
+ if (surf == NULL) {
+ return 0;
+ }
+
+ e = FC_PackGlyphData(font, codepoint, surf->w, w, h);
+ if (e == NULL) {
+ // Grow the cache
+ FC_GrowGlyphCache(font);
+
+ // Try packing again
+ e = FC_PackGlyphData(font, codepoint, surf->w, w, h);
+ if (e == NULL) {
+ SDL_FreeSurface(surf);
+ return 0;
+ }
+ }
+
+ // Render onto the cache texture
+ FC_AddGlyphToCache(font, surf);
+
+ SDL_FreeSurface(surf);
+ }
+
+ if (result != NULL && e != NULL) {
+ *result = *e;
+ }
+
+ return 1;
+}
+
+
+FC_GlyphData* FC_SetGlyphData(FC_Font* font, Uint32 codepoint, FC_GlyphData glyph_data) {
+ return FC_MapInsert(font->glyphs, codepoint, glyph_data);
+}
+
+
+// Drawing
+static FC_Rect FC_RenderLeft(FC_Font* font, FC_Target* dest, float x, float y, FC_Scale scale, const char* text) {
+ const char* c = text;
+ FC_Rect srcRect;
+ FC_Rect dstRect;
+ FC_Rect dirtyRect = FC_MakeRect(x, y, 0, 0);
+
+ FC_GlyphData glyph;
+ Uint32 codepoint;
+
+ float destX = x;
+ float destY = y;
+ float destH;
+ float destLineSpacing;
+ float destLetterSpacing;
+
+ if (font == NULL) {
+ return dirtyRect;
+ }
+
+ destH = font->height * scale.y;
+ destLineSpacing = font->lineSpacing*scale.y;
+ destLetterSpacing = font->letterSpacing*scale.x;
+
+ if (c == NULL || font->glyph_cache_count == 0 || dest == NULL) {
+ return dirtyRect;
+ }
+
+ int newlineX = x;
+
+ for (; *c != '\0'; c++) {
+ if (*c == '\n') {
+ destX = newlineX;
+ destY += destH + destLineSpacing;
+ continue;
+ }
+
+ codepoint = FC_GetCodepointFromUTF8(&c, 1); // Increments 'c' to skip the extra UTF-8 bytes
+ if (!FC_GetGlyphData(font, &glyph, codepoint)) {
+ codepoint = ' ';
+ if (!FC_GetGlyphData(font, &glyph, codepoint)) {
+ continue; // Skip bad characters
+ }
+ }
+
+ if (codepoint == ' ') {
+ destX += glyph.rect.w*scale.x + destLetterSpacing;
+ continue;
+ }
+ /*if(destX >= dest->w)
+ continue;
+ if(destY >= dest->h)
+ continue;*/
+
+#ifdef FC_USE_SDL_GPU
+ srcRect.x = glyph.rect.x;
+ srcRect.y = glyph.rect.y;
+ srcRect.w = glyph.rect.w;
+ srcRect.h = glyph.rect.h;
+#else
+ srcRect = glyph.rect;
+#endif
+ dstRect = fc_render_callback(FC_GetGlyphCacheLevel(font, glyph.cache_level), &srcRect, dest, destX, destY, scale.x, scale.y);
+ if (dirtyRect.w == 0 || dirtyRect.h == 0) {
+ dirtyRect = dstRect;
+ }
+ else {
+ dirtyRect = FC_RectUnion(dirtyRect, dstRect);
+ }
+
+ destX += glyph.rect.w*scale.x + destLetterSpacing;
+ }
+
+ return dirtyRect;
+}
+
+static void set_color_for_all_caches(FC_Font* font, SDL_Color color) {
+ // TODO: How can I predict which glyph caches are to be used?
+ FC_Image* img;
+ int i;
+ int num_levels = FC_GetNumCacheLevels(font);
+ for (i = 0; i < num_levels; ++i) {
+ img = FC_GetGlyphCacheLevel(font, i);
+ set_color(img, color.r, color.g, color.b, FC_GET_ALPHA(color));
+ }
+}
+
+FC_Rect FC_Draw(FC_Font* font, FC_Target* dest, float x, float y, const char* formatted_text, ...) {
+ if (formatted_text == NULL || font == NULL) {
+ return FC_MakeRect(x, y, 0, 0);
+ }
+
+ FC_EXTRACT_VARARGS(fc_buffer, formatted_text);
+
+ set_color_for_all_caches(font, font->default_color);
+
+ return FC_RenderLeft(font, dest, x, y, FC_MakeScale(1,1), fc_buffer);
+}
+
+
+
+typedef struct FC_StringList {
+ char* value;
+ struct FC_StringList* next;
+} FC_StringList;
+
+void FC_StringListFree(FC_StringList* node) {
+ // Delete the nodes in order
+ while (node != NULL) {
+ FC_StringList* last = node;
+ node = node->next;
+
+ free(last->value);
+ free(last);
+ }
+}
+
+FC_StringList** FC_StringListPushBack(FC_StringList** node, char* value, Uint8 copy) {
+ // Get to the last node
+ while (node != NULL && *node != NULL) {
+ node = &(*node)->next;
+ }
+
+ *node = (FC_StringList*)malloc(sizeof(FC_StringList));
+
+ (*node)->value = (copy? U8_strdup(value) : value);
+ (*node)->next = NULL;
+
+ return node;
+}
+
+static FC_StringList* FC_Explode(const char* text, char delimiter) {
+ FC_StringList* head;
+ FC_StringList* new_node;
+ FC_StringList** node;
+ const char* start;
+ const char* end;
+ unsigned int size;
+ if (text == NULL) {
+ return NULL;
+ }
+
+ head = NULL;
+ node = &head;
+
+ // Doesn't technically support UTF-8, but it's probably fine, right?
+ size = 0;
+ start = end = text;
+ while (1) {
+ if (*end == delimiter || *end == '\0') {
+ *node = (FC_StringList*)malloc(sizeof(FC_StringList));
+ new_node = *node;
+
+ new_node->value = (char*)malloc(size + 1);
+ memcpy(new_node->value, start, size);
+ new_node->value[size] = '\0';
+
+ new_node->next = NULL;
+
+ if (*end == '\0') {
+ break;
+ }
+
+ node = &((*node)->next);
+ start = end+1;
+ size = 0;
+ }
+ else {
+ ++size;
+ }
+
+ ++end;
+ }
+
+ return head;
+}
+
+static FC_StringList* FC_ExplodeAndKeep(const char* text, char delimiter) {
+ FC_StringList* head;
+ FC_StringList* new_node;
+ FC_StringList** node;
+ const char* start;
+ const char* end;
+ unsigned int size;
+ if (text == NULL) {
+ return NULL;
+ }
+
+ head = NULL;
+ node = &head;
+
+ // Doesn't technically support UTF-8, but it's probably fine, right?
+ size = 0;
+ start = end = text;
+ while (1) {
+ if (*end == delimiter || *end == '\0') {
+ *node = (FC_StringList*)malloc(sizeof(FC_StringList));
+ new_node = *node;
+
+ new_node->value = (char*)malloc(size + 1);
+ memcpy(new_node->value, start, size);
+ new_node->value[size] = '\0';
+
+ new_node->next = NULL;
+
+ if (*end == '\0') {
+ break;
+ }
+
+ node = &((*node)->next);
+ start = end;
+ size = 1;
+ }
+ else {
+ ++size;
+ }
+
+ ++end;
+ }
+
+ return head;
+}
+
+static void FC_RenderAlign(FC_Font* font, FC_Target* dest, float x, float y, int width, FC_Scale scale, FC_AlignEnum align, const char* text) {
+ switch (align) {
+ case FC_ALIGN_LEFT:
+ FC_RenderLeft(font, dest, x, y, scale, text);
+ break;
+ case FC_ALIGN_CENTER:
+ FC_RenderCenter(font, dest, x + width/2, y, scale, text);
+ break;
+ case FC_ALIGN_RIGHT:
+ FC_RenderRight(font, dest, x + width, y, scale, text);
+ break;
+ }
+}
+
+static FC_StringList* FC_GetBufferFitToColumn(FC_Font* font, int width, FC_Scale scale, Uint8 keep_newlines) {
+ FC_StringList* result = NULL;
+ FC_StringList** current = &result;
+
+ FC_StringList* ls, *iter;
+
+ ls = (keep_newlines? FC_ExplodeAndKeep(fc_buffer, '\n') : FC_Explode(fc_buffer, '\n'));
+ for (iter = ls; iter != NULL; iter = iter->next) {
+ char* line = iter->value;
+
+ // If line is too long, then add words one at a time until we go over.
+ if (width > 0 && FC_GetWidth(font, "%s", line) > width) {
+ FC_StringList* words, *word_iter;
+
+ words = FC_Explode(line, ' ');
+ // Skip the first word for the iterator, so there will always be at least one word per line
+ line = new_concat(words->value, " ");
+ for (word_iter = words->next; word_iter != NULL; word_iter = word_iter->next) {
+ char* line_plus_word = new_concat(line, word_iter->value);
+ char* word_plus_space = new_concat(word_iter->value, " ");
+ if (FC_GetWidth(font, line_plus_word) > width) {
+ current = FC_StringListPushBack(current, line, 0);
+
+ line = word_plus_space;
+ }
+ else {
+ replace_concat(&line, word_plus_space);
+ free(word_plus_space);
+ }
+ free(line_plus_word);
+ }
+ current = FC_StringListPushBack(current, line, 0);
+ FC_StringListFree(words);
+ }
+ else {
+ current = FC_StringListPushBack(current, line, 0);
+ iter->value = NULL;
+ }
+ }
+ FC_StringListFree(ls);
+
+ return result;
+}
+
+static void FC_DrawColumnFromBuffer(FC_Font* font, FC_Target* dest, FC_Rect box, int* total_height, FC_Scale scale, FC_AlignEnum align) {
+ int y = box.y;
+ FC_StringList* ls, *iter;
+
+ ls = FC_GetBufferFitToColumn(font, box.w, scale, 0);
+ for (iter = ls; iter != NULL; iter = iter->next) {
+ FC_RenderAlign(font, dest, box.x, y, box.w, scale, align, iter->value);
+ y += FC_GetLineHeight(font);
+ }
+ FC_StringListFree(ls);
+
+ if (total_height != NULL) {
+ *total_height = y - box.y;
+ }
+}
+
+FC_Rect FC_DrawBox(FC_Font* font, FC_Target* dest, FC_Rect box, const char* formatted_text, ...) {
+ Uint8 useClip;
+ if (formatted_text == NULL || font == NULL) {
+ return FC_MakeRect(box.x, box.y, 0, 0);
+ }
+
+ FC_EXTRACT_VARARGS(fc_buffer, formatted_text);
+
+ useClip = has_clip(dest);
+ FC_Rect oldclip, newclip;
+ if (useClip) {
+ oldclip = get_clip(dest);
+ newclip = FC_RectIntersect(oldclip, box);
+ }
+ else {
+ newclip = box;
+ }
+ set_clip(dest, &newclip);
+
+ set_color_for_all_caches(font, font->default_color);
+
+ FC_DrawColumnFromBuffer(font, dest, box, NULL, FC_MakeScale(1,1), FC_ALIGN_LEFT);
+
+ if (useClip) {
+ set_clip(dest, &oldclip);
+ }
+ else {
+ set_clip(dest, NULL);
+ }
+
+ return box;
+}
+
+FC_Rect FC_DrawBoxAlign(FC_Font* font, FC_Target* dest, FC_Rect box, FC_AlignEnum align, const char* formatted_text, ...) {
+ Uint8 useClip;
+ if (formatted_text == NULL || font == NULL) {
+ return FC_MakeRect(box.x, box.y, 0, 0);
+ }
+
+ FC_EXTRACT_VARARGS(fc_buffer, formatted_text);
+
+ useClip = has_clip(dest);
+ FC_Rect oldclip, newclip;
+ if (useClip) {
+ oldclip = get_clip(dest);
+ newclip = FC_RectIntersect(oldclip, box);
+ }
+ else {
+ newclip = box;
+ }
+ set_clip(dest, &newclip);
+
+ set_color_for_all_caches(font, font->default_color);
+
+ FC_DrawColumnFromBuffer(font, dest, box, NULL, FC_MakeScale(1,1), align);
+
+ if (useClip) {
+ set_clip(dest, &oldclip);
+ }
+ else {
+ set_clip(dest, NULL);
+ }
+
+ return box;
+}
+
+FC_Rect FC_DrawBoxScale(FC_Font* font, FC_Target* dest, FC_Rect box, FC_Scale scale, const char* formatted_text, ...) {
+ Uint8 useClip;
+ if (formatted_text == NULL || font == NULL) {
+ return FC_MakeRect(box.x, box.y, 0, 0);
+ }
+
+ FC_EXTRACT_VARARGS(fc_buffer, formatted_text);
+
+ useClip = has_clip(dest);
+ FC_Rect oldclip, newclip;
+ if (useClip) {
+ oldclip = get_clip(dest);
+ newclip = FC_RectIntersect(oldclip, box);
+ }
+ else {
+ newclip = box;
+ }
+ set_clip(dest, &newclip);
+
+ set_color_for_all_caches(font, font->default_color);
+
+ FC_DrawColumnFromBuffer(font, dest, box, NULL, scale, FC_ALIGN_LEFT);
+
+ if (useClip) {
+ set_clip(dest, &oldclip);
+ }
+ else {
+ set_clip(dest, NULL);
+ }
+
+ return box;
+}
+
+FC_Rect FC_DrawBoxColor(FC_Font* font, FC_Target* dest, FC_Rect box, SDL_Color color, const char* formatted_text, ...) {
+ Uint8 useClip;
+ if (formatted_text == NULL || font == NULL) {
+ return FC_MakeRect(box.x, box.y, 0, 0);
+ }
+
+ FC_EXTRACT_VARARGS(fc_buffer, formatted_text);
+
+ useClip = has_clip(dest);
+ FC_Rect oldclip, newclip;
+ if (useClip) {
+ oldclip = get_clip(dest);
+ newclip = FC_RectIntersect(oldclip, box);
+ }
+ else {
+ newclip = box;
+ }
+ set_clip(dest, &newclip);
+
+ set_color_for_all_caches(font, color);
+
+ FC_DrawColumnFromBuffer(font, dest, box, NULL, FC_MakeScale(1,1), FC_ALIGN_LEFT);
+
+ if (useClip) {
+ set_clip(dest, &oldclip);
+ }
+ else {
+ set_clip(dest, NULL);
+ }
+
+ return box;
+}
+
+FC_Rect FC_DrawBoxEffect(FC_Font* font, FC_Target* dest, FC_Rect box, FC_Effect effect, const char* formatted_text, ...) {
+ Uint8 useClip;
+ if (formatted_text == NULL || font == NULL) {
+ return FC_MakeRect(box.x, box.y, 0, 0);
+ }
+
+ FC_EXTRACT_VARARGS(fc_buffer, formatted_text);
+
+ useClip = has_clip(dest);
+ FC_Rect oldclip, newclip;
+ if (useClip) {
+ oldclip = get_clip(dest);
+ newclip = FC_RectIntersect(oldclip, box);
+ }
+ else {
+ newclip = box;
+ }
+ set_clip(dest, &newclip);
+
+ set_color_for_all_caches(font, effect.color);
+
+ FC_DrawColumnFromBuffer(font, dest, box, NULL, effect.scale, effect.alignment);
+
+ if (useClip) {
+ set_clip(dest, &oldclip);
+ }
+ else {
+ set_clip(dest, NULL);
+ }
+
+ return box;
+}
+
+FC_Rect FC_DrawColumn(FC_Font* font, FC_Target* dest, float x, float y, Uint16 width, const char* formatted_text, ...) {
+ FC_Rect box = {x, y, width, 0};
+ int total_height;
+
+ if (formatted_text == NULL || font == NULL) {
+ return FC_MakeRect(x, y, 0, 0);
+ }
+
+ FC_EXTRACT_VARARGS(fc_buffer, formatted_text);
+
+ set_color_for_all_caches(font, font->default_color);
+
+ FC_DrawColumnFromBuffer(font, dest, box, &total_height, FC_MakeScale(1,1), FC_ALIGN_LEFT);
+
+ return FC_MakeRect(box.x, box.y, width, total_height);
+}
+
+FC_Rect FC_DrawColumnAlign(FC_Font* font, FC_Target* dest, float x, float y, Uint16 width, FC_AlignEnum align, const char* formatted_text, ...) {
+ FC_Rect box = {x, y, width, 0};
+ int total_height;
+
+ if (formatted_text == NULL || font == NULL) {
+ return FC_MakeRect(x, y, 0, 0);
+ }
+
+ FC_EXTRACT_VARARGS(fc_buffer, formatted_text);
+
+ set_color_for_all_caches(font, font->default_color);
+
+ switch (align) {
+ case FC_ALIGN_CENTER:
+ box.x -= width/2;
+ break;
+ case FC_ALIGN_RIGHT:
+ box.x -= width;
+ break;
+ default:
+ break;
+ }
+
+ FC_DrawColumnFromBuffer(font, dest, box, &total_height, FC_MakeScale(1,1), align);
+
+ return FC_MakeRect(box.x, box.y, width, total_height);
+}
+
+FC_Rect FC_DrawColumnScale(FC_Font* font, FC_Target* dest, float x, float y, Uint16 width, FC_Scale scale, const char* formatted_text, ...) {
+ FC_Rect box = {x, y, width, 0};
+ int total_height;
+
+ if (formatted_text == NULL || font == NULL) {
+ return FC_MakeRect(x, y, 0, 0);
+ }
+
+ FC_EXTRACT_VARARGS(fc_buffer, formatted_text);
+
+ set_color_for_all_caches(font, font->default_color);
+
+ FC_DrawColumnFromBuffer(font, dest, box, &total_height, scale, FC_ALIGN_LEFT);
+
+ return FC_MakeRect(box.x, box.y, width, total_height);
+}
+
+FC_Rect FC_DrawColumnColor(FC_Font* font, FC_Target* dest, float x, float y, Uint16 width, SDL_Color color, const char* formatted_text, ...) {
+ FC_Rect box = {x, y, width, 0};
+ int total_height;
+
+ if (formatted_text == NULL || font == NULL) {
+ return FC_MakeRect(x, y, 0, 0);
+ }
+
+ FC_EXTRACT_VARARGS(fc_buffer, formatted_text);
+
+ set_color_for_all_caches(font, color);
+
+ FC_DrawColumnFromBuffer(font, dest, box, &total_height, FC_MakeScale(1,1), FC_ALIGN_LEFT);
+
+ return FC_MakeRect(box.x, box.y, width, total_height);
+}
+
+FC_Rect FC_DrawColumnEffect(FC_Font* font, FC_Target* dest, float x, float y, Uint16 width, FC_Effect effect, const char* formatted_text, ...) {
+ FC_Rect box = {x, y, width, 0};
+ int total_height;
+
+ if (formatted_text == NULL || font == NULL) {
+ return FC_MakeRect(x, y, 0, 0);
+ }
+
+ FC_EXTRACT_VARARGS(fc_buffer, formatted_text);
+
+ set_color_for_all_caches(font, effect.color);
+
+ switch (effect.alignment) {
+ case FC_ALIGN_CENTER:
+ box.x -= width/2;
+ break;
+ case FC_ALIGN_RIGHT:
+ box.x -= width;
+ break;
+ default:
+ break;
+ }
+
+ FC_DrawColumnFromBuffer(font, dest, box, &total_height, effect.scale, effect.alignment);
+
+ return FC_MakeRect(box.x, box.y, width, total_height);
+}
+
+static FC_Rect FC_RenderCenter(FC_Font* font, FC_Target* dest, float x, float y, FC_Scale scale, const char* text) {
+ FC_Rect result = {x, y, 0, 0};
+ if (text == NULL || font == NULL) {
+ return result;
+ }
+
+ char* str = U8_strdup(text);
+ char* del = str;
+ char* c;
+
+ // Go through str, when you find a \n, replace it with \0 and print it
+ // then move down, back, and continue.
+ for (c = str; *c != '\0';) {
+ if (*c == '\n') {
+ *c = '\0';
+ result = FC_RectUnion(FC_RenderLeft(font, dest, x - scale.x*FC_GetWidth(font, "%s", str)/2.0f, y, scale, str), result);
+ *c = '\n';
+ c++;
+ str = c;
+ y += scale.y*font->height;
+ }
+ else {
+ c++;
+ }
+ }
+
+ result = FC_RectUnion(FC_RenderLeft(font, dest, x - scale.x*FC_GetWidth(font, "%s", str)/2.0f, y, scale, str), result);
+
+ free(del);
+ return result;
+}
+
+static FC_Rect FC_RenderRight(FC_Font* font, FC_Target* dest, float x, float y, FC_Scale scale, const char* text) {
+ FC_Rect result = {x, y, 0, 0};
+ if (text == NULL || font == NULL) {
+ return result;
+ }
+
+ char* str = U8_strdup(text);
+ char* del = str;
+ char* c;
+
+ for (c = str; *c != '\0';) {
+ if (*c == '\n') {
+ *c = '\0';
+ result = FC_RectUnion(FC_RenderLeft(font, dest, x - scale.x*FC_GetWidth(font, "%s", str), y, scale, str), result);
+ *c = '\n';
+ c++;
+ str = c;
+ y += scale.y*font->height;
+ }
+ else {
+ c++;
+ }
+ }
+
+ result = FC_RectUnion(FC_RenderLeft(font, dest, x - scale.x*FC_GetWidth(font, "%s", str), y, scale, str), result);
+
+ free(del);
+ return result;
+}
+
+
+
+FC_Rect FC_DrawScale(FC_Font* font, FC_Target* dest, float x, float y, FC_Scale scale, const char* formatted_text, ...) {
+ if (formatted_text == NULL || font == NULL) {
+ return FC_MakeRect(x, y, 0, 0);
+ }
+
+ FC_EXTRACT_VARARGS(fc_buffer, formatted_text);
+
+ set_color_for_all_caches(font, font->default_color);
+
+ return FC_RenderLeft(font, dest, x, y, scale, fc_buffer);
+}
+
+FC_Rect FC_DrawAlign(FC_Font* font, FC_Target* dest, float x, float y, FC_AlignEnum align, const char* formatted_text, ...) {
+ if (formatted_text == NULL || font == NULL) {
+ return FC_MakeRect(x, y, 0, 0);
+ }
+
+ FC_EXTRACT_VARARGS(fc_buffer, formatted_text);
+
+ set_color_for_all_caches(font, font->default_color);
+
+ FC_Rect result;
+ switch (align) {
+ case FC_ALIGN_LEFT:
+ result = FC_RenderLeft(font, dest, x, y, FC_MakeScale(1,1), fc_buffer);
+ break;
+ case FC_ALIGN_CENTER:
+ result = FC_RenderCenter(font, dest, x, y, FC_MakeScale(1,1), fc_buffer);
+ break;
+ case FC_ALIGN_RIGHT:
+ result = FC_RenderRight(font, dest, x, y, FC_MakeScale(1,1), fc_buffer);
+ break;
+ default:
+ result = FC_MakeRect(x, y, 0, 0);
+ break;
+ }
+
+ return result;
+}
+
+FC_Rect FC_DrawColor(FC_Font* font, FC_Target* dest, float x, float y, SDL_Color color, const char* formatted_text, ...) {
+ if (formatted_text == NULL || font == NULL) {
+ return FC_MakeRect(x, y, 0, 0);
+ }
+
+ FC_EXTRACT_VARARGS(fc_buffer, formatted_text);
+
+ set_color_for_all_caches(font, color);
+
+ return FC_RenderLeft(font, dest, x, y, FC_MakeScale(1,1), fc_buffer);
+}
+
+
+FC_Rect FC_DrawEffect(FC_Font* font, FC_Target* dest, float x, float y, FC_Effect effect, const char* formatted_text, ...) {
+ if (formatted_text == NULL || font == NULL) {
+ return FC_MakeRect(x, y, 0, 0);
+ }
+
+ FC_EXTRACT_VARARGS(fc_buffer, formatted_text);
+
+ set_color_for_all_caches(font, effect.color);
+
+ FC_Rect result;
+ switch (effect.alignment) {
+ case FC_ALIGN_LEFT:
+ result = FC_RenderLeft(font, dest, x, y, effect.scale, fc_buffer);
+ break;
+ case FC_ALIGN_CENTER:
+ result = FC_RenderCenter(font, dest, x, y, effect.scale, fc_buffer);
+ break;
+ case FC_ALIGN_RIGHT:
+ result = FC_RenderRight(font, dest, x, y, effect.scale, fc_buffer);
+ break;
+ default:
+ result = FC_MakeRect(x, y, 0, 0);
+ break;
+ }
+
+ return result;
+}
+
+
+
+
+// Getters
+
+
+FC_FilterEnum FC_GetFilterMode(FC_Font* font) {
+ if (font == NULL) {
+ return FC_FILTER_NEAREST;
+ }
+
+ return font->filter;
+}
+
+Uint16 FC_GetLineHeight(FC_Font* font) {
+ if (font == NULL) {
+ return 0;
+ }
+
+ return font->height;
+}
+
+Uint16 FC_GetHeight(FC_Font* font, const char* formatted_text, ...) {
+ if (formatted_text == NULL || font == NULL) {
+ return 0;
+ }
+
+ FC_EXTRACT_VARARGS(fc_buffer, formatted_text);
+
+ Uint16 numLines = 1;
+ const char* c;
+
+ for (c = fc_buffer; *c != '\0'; c++) {
+ if (*c == '\n') {
+ numLines++;
+ }
+ }
+
+ // Actual height of letter region + line spacing
+ return font->height*numLines + font->lineSpacing*(numLines - 1); //height*numLines;
+}
+
+Uint16 FC_GetWidth(FC_Font* font, const char* formatted_text, ...) {
+ if (formatted_text == NULL || font == NULL) {
+ return 0;
+ }
+
+ FC_EXTRACT_VARARGS(fc_buffer, formatted_text);
+
+ const char* c;
+ Uint16 width = 0;
+ Uint16 bigWidth = 0; // Allows for multi-line strings
+
+ for (c = fc_buffer; *c != '\0'; c++) {
+ if (*c == '\n') {
+ bigWidth = bigWidth >= width? bigWidth : width;
+ width = 0;
+ continue;
+ }
+
+ FC_GlyphData glyph;
+ Uint32 codepoint = FC_GetCodepointFromUTF8(&c, 1);
+ if (FC_GetGlyphData(font, &glyph, codepoint) || FC_GetGlyphData(font, &glyph, ' ')) {
+ width += glyph.rect.w;
+ }
+ }
+ bigWidth = bigWidth >= width? bigWidth : width;
+
+ return bigWidth;
+}
+
+// If width == -1, use no width limit
+FC_Rect FC_GetCharacterOffset(FC_Font* font, Uint16 position_index, int column_width, const char* formatted_text, ...) {
+ FC_Rect result = {0, 0, 1, FC_GetLineHeight(font)};
+ FC_StringList* ls, *iter;
+ int num_lines = 0;
+ Uint8 done = 0;
+
+ if (formatted_text == NULL || column_width == 0 || position_index == 0 || font == NULL) {
+ return result;
+ }
+
+ FC_EXTRACT_VARARGS(fc_buffer, formatted_text);
+
+ ls = FC_GetBufferFitToColumn(font, column_width, FC_MakeScale(1,1), 1);
+ for (iter = ls; iter != NULL; iter = iter->next) {
+ char* line;
+ int i = 0;
+
+ ++num_lines;
+ for (line = iter->value; line != NULL && *line != '\0'; line = (char*)U8_next(line)) {
+ ++i;
+ --position_index;
+ if (position_index == 0) {
+ // FIXME: Doesn't handle box-wrapped newlines correctly
+ line = (char*)U8_next(line);
+ line[0] = '\0';
+ result.x = FC_GetWidth(font, "%s", iter->value);
+ done = 1;
+ break;
+ }
+ }
+ if (done) {
+ break;
+ }
+ }
+ FC_StringListFree(ls);
+
+ if (num_lines > 0) {
+ result.y = (num_lines - 1) * FC_GetLineHeight(font);
+ }
+
+ return result;
+}
+
+
+Uint16 FC_GetColumnHeight(FC_Font* font, Uint16 width, const char* formatted_text, ...) {
+ int y = 0;
+
+ FC_StringList* ls, *iter;
+
+ if (font == NULL) {
+ return 0;
+ }
+
+ if (formatted_text == NULL || width == 0) {
+ return font->height;
+ }
+
+ FC_EXTRACT_VARARGS(fc_buffer, formatted_text);
+
+ ls = FC_GetBufferFitToColumn(font, width, FC_MakeScale(1,1), 0);
+ for (iter = ls; iter != NULL; iter = iter->next) {
+ y += FC_GetLineHeight(font);
+ }
+ FC_StringListFree(ls);
+
+ return y;
+}
+
+static int FC_GetAscentFromCodepoint(FC_Font* font, Uint32 codepoint) {
+ FC_GlyphData glyph;
+
+ if (font == NULL) {
+ return 0;
+ }
+
+ // FIXME: Store ascent so we can return it here
+ FC_GetGlyphData(font, &glyph, codepoint);
+ return glyph.rect.h;
+}
+
+static int FC_GetDescentFromCodepoint(FC_Font* font, Uint32 codepoint) {
+ FC_GlyphData glyph;
+
+ if (font == NULL) {
+ return 0;
+ }
+
+ // FIXME: Store descent so we can return it here
+ FC_GetGlyphData(font, &glyph, codepoint);
+ return glyph.rect.h;
+}
+
+int FC_GetAscent(FC_Font* font, const char* formatted_text, ...) {
+ Uint32 codepoint;
+ int max, ascent;
+ const char* c;
+
+ if (font == NULL) {
+ return 0;
+ }
+
+ if (formatted_text == NULL) {
+ return font->ascent;
+ }
+
+ FC_EXTRACT_VARARGS(fc_buffer, formatted_text);
+
+ max = 0;
+ c = fc_buffer;
+
+ while (*c != '\0') {
+ codepoint = FC_GetCodepointFromUTF8(&c, 1);
+ if (codepoint != 0) {
+ ascent = FC_GetAscentFromCodepoint(font, codepoint);
+ if (ascent > max) {
+ max = ascent;
+ }
+ }
+ ++c;
+ }
+ return max;
+}
+
+int FC_GetDescent(FC_Font* font, const char* formatted_text, ...) {
+ Uint32 codepoint;
+ int max, descent;
+ const char* c;
+
+ if (font == NULL) {
+ return 0;
+ }
+
+ if (formatted_text == NULL) {
+ return font->descent;
+ }
+
+ FC_EXTRACT_VARARGS(fc_buffer, formatted_text);
+
+ max = 0;
+ c = fc_buffer;
+
+ while (*c != '\0') {
+ codepoint = FC_GetCodepointFromUTF8(&c, 1);
+ if (codepoint != 0) {
+ descent = FC_GetDescentFromCodepoint(font, codepoint);
+ if (descent > max) {
+ max = descent;
+ }
+ }
+ ++c;
+ }
+ return max;
+}
+
+int FC_GetBaseline(FC_Font* font) {
+ if (font == NULL) {
+ return 0;
+ }
+
+ return font->baseline;
+}
+
+int FC_GetSpacing(FC_Font* font) {
+ if (font == NULL) {
+ return 0;
+ }
+
+ return font->letterSpacing;
+}
+
+int FC_GetLineSpacing(FC_Font* font) {
+ if (font == NULL) {
+ return 0;
+ }
+
+ return font->lineSpacing;
+}
+
+Uint16 FC_GetMaxWidth(FC_Font* font) {
+ if (font == NULL) {
+ return 0;
+ }
+
+ return font->maxWidth;
+}
+
+SDL_Color FC_GetDefaultColor(FC_Font* font) {
+ if (font == NULL) {
+ SDL_Color c = {0,0,0,255};
+ return c;
+ }
+
+ return font->default_color;
+}
+
+
+Uint8 FC_InRect(float x, float y, FC_Rect input_rect) {
+ return (input_rect.x <= x && x <= input_rect.x + input_rect.w && input_rect.y <= y && y <= input_rect.y + input_rect.h);
+}
+
+// TODO: Make it work with alignment
+Uint16 FC_GetPositionFromOffset(FC_Font* font, float x, float y, int column_width, FC_AlignEnum align, const char* formatted_text, ...) {
+ FC_StringList* ls, *iter;
+ Uint8 done = 0;
+ int height = FC_GetLineHeight(font);
+ Uint16 position = 0;
+ int current_x = 0;
+ int current_y = 0;
+ FC_GlyphData glyph_data;
+
+ if (formatted_text == NULL || column_width == 0 || font == NULL) {
+ return 0;
+ }
+
+ FC_EXTRACT_VARARGS(fc_buffer, formatted_text);
+
+ ls = FC_GetBufferFitToColumn(font, column_width, FC_MakeScale(1,1), 1);
+ for (iter = ls; iter != NULL; iter = iter->next) {
+ char* line;
+
+ for (line = iter->value; line != NULL && *line != '\0'; line = (char*)U8_next(line)) {
+ if (FC_GetGlyphData(font, &glyph_data, FC_GetCodepointFromUTF8((const char**)&line, 0))) {
+ if (FC_InRect(x, y, FC_MakeRect(current_x, current_y, glyph_data.rect.w, glyph_data.rect.h))) {
+ done = 1;
+ break;
+ }
+
+ current_x += glyph_data.rect.w;
+ }
+ position++;
+ }
+ if (done) {
+ break;
+ }
+
+ current_x = 0;
+ current_y += height;
+ if (y < current_y) {
+ break;
+ }
+ }
+ FC_StringListFree(ls);
+
+ return position;
+}
+
+
+
+
+// Setters
+
+
+void FC_SetFilterMode(FC_Font* font, FC_FilterEnum filter) {
+ if (font == NULL) {
+ return;
+ }
+
+ if (font->filter != filter) {
+ font->filter = filter;
+
+#ifdef FC_USE_SDL_GPU
+ // Update each texture to use this filter mode
+ {
+ int i;
+ GPU_FilterEnum gpu_filter = GPU_FILTER_NEAREST;
+ if (FC_GetFilterMode(font) == FC_FILTER_LINEAR) {
+ gpu_filter = GPU_FILTER_LINEAR;
+ }
+
+ for (i = 0; i < font->glyph_cache_count; ++i) {
+ GPU_SetImageFilter(font->glyph_cache[i], gpu_filter);
+ }
+ }
+#endif
+ }
+}
+
+
+void FC_SetSpacing(FC_Font* font, int LetterSpacing) {
+ if (font == NULL) {
+ return;
+ }
+
+ font->letterSpacing = LetterSpacing;
+}
+
+void FC_SetLineSpacing(FC_Font* font, int LineSpacing) {
+ if (font == NULL) {
+ return;
+ }
+
+ font->lineSpacing = LineSpacing;
+}
+
+void FC_SetDefaultColor(FC_Font* font, SDL_Color color) {
+ if (font == NULL) {
+ return;
+ }
+
+ font->default_color = color;
+}
+
+
+
+
+
+
diff --git a/source/code/Libs/SDL_FontCache.h b/source/code/Libs/SDL_FontCache.h new file mode 100644 index 0000000..cd0d0e5 --- /dev/null +++ b/source/code/Libs/SDL_FontCache.h
@@ -0,0 +1,298 @@
+/*
+SDL_FontCache v0.0.1: A font cache for SDL and SDL_ttf
+by Jonathan Dearborn
+Dedicated to the memory of Florian Hufsky
+
+License:
+ The short:
+ Use it however you'd like, but keep the copyright and license notice
+ whenever these files or parts of them are distributed in uncompiled form.
+
+ The long:
+Copyright (c) 2015 Jonathan Dearborn
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+*/
+
+#ifndef _SDL_FONTCACHE_H__
+#define _SDL_FONTCACHE_H__
+
+#include "SDL.h"
+#include "SDL_ttf.h"
+
+#ifdef FC_USE_SDL_GPU
+ #include "SDL_gpu.h"
+#endif
+
+
+#include <stdarg.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+// Let's pretend this exists...
+#define TTF_STYLE_OUTLINE 16
+
+
+
+// Differences between SDL_Renderer and SDL_gpu
+#ifdef FC_USE_SDL_GPU
+#define FC_Rect GPU_Rect
+#define FC_Target GPU_Target
+#define FC_Image GPU_Image
+#define FC_Log GPU_LogError
+#else
+#define FC_Rect SDL_Rect
+#define FC_Target SDL_Renderer
+#define FC_Image SDL_Texture
+#define FC_Log SDL_Log
+#endif
+
+
+// SDL_FontCache types
+
+typedef enum
+{
+ FC_ALIGN_LEFT,
+ FC_ALIGN_CENTER,
+ FC_ALIGN_RIGHT
+} FC_AlignEnum;
+
+typedef enum
+{
+ FC_FILTER_NEAREST,
+ FC_FILTER_LINEAR
+} FC_FilterEnum;
+
+typedef struct FC_Scale
+{
+ float x;
+ float y;
+
+} FC_Scale;
+
+typedef struct FC_Effect
+{
+ FC_AlignEnum alignment;
+ FC_Scale scale;
+ SDL_Color color;
+
+} FC_Effect;
+
+// Opaque type
+typedef struct FC_Font FC_Font;
+
+
+typedef struct FC_GlyphData
+{
+ SDL_Rect rect;
+ int cache_level;
+
+} FC_GlyphData;
+
+
+
+
+// Object creation
+
+FC_Rect FC_MakeRect(float x, float y, float w, float h);
+
+FC_Scale FC_MakeScale(float x, float y);
+
+SDL_Color FC_MakeColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a);
+
+FC_Effect FC_MakeEffect(FC_AlignEnum alignment, FC_Scale scale, SDL_Color color);
+
+FC_GlyphData FC_MakeGlyphData(int cache_level, Sint16 x, Sint16 y, Uint16 w, Uint16 h);
+
+
+
+// Font object
+
+FC_Font* FC_CreateFont(void);
+
+#ifdef FC_USE_SDL_GPU
+Uint8 FC_LoadFont(FC_Font* font, const char* filename_ttf, Uint32 pointSize, SDL_Color color, int style);
+
+Uint8 FC_LoadFontFromTTF(FC_Font* font, TTF_Font* ttf, SDL_Color color);
+
+Uint8 FC_LoadFont_RW(FC_Font* font, SDL_RWops* file_rwops_ttf, Uint8 own_rwops, Uint32 pointSize, SDL_Color color, int style);
+#else
+Uint8 FC_LoadFont(FC_Font* font, SDL_Renderer* renderer, const char* filename_ttf, Uint32 pointSize, SDL_Color color, int style);
+
+Uint8 FC_LoadFontFromTTF(FC_Font* font, SDL_Renderer* renderer, TTF_Font* ttf, SDL_Color color);
+
+Uint8 FC_LoadFont_RW(FC_Font* font, SDL_Renderer* renderer, SDL_RWops* file_rwops_ttf, Uint8 own_rwops, Uint32 pointSize, SDL_Color color, int style);
+#endif
+
+void FC_ClearFont(FC_Font* font);
+
+void FC_FreeFont(FC_Font* font);
+
+
+
+// Built-in loading strings
+
+const char* FC_GetStringASCII(void);
+
+const char* FC_GetStringLatin1(void);
+
+const char* FC_GetStringASCII_Latin1(void);
+
+
+// UTF-8 to SDL_FontCache codepoint conversion
+
+/*!
+Returns the Uint32 codepoint (not UTF-32) parsed from the given UTF-8 string.
+\param c A pointer to a string of proper UTF-8 character values.
+\param advance_pointer If true, the source pointer will be incremented to skip the extra bytes from multibyte codepoints.
+*/
+Uint32 FC_GetCodepointFromUTF8(const char** c, Uint8 advance_pointer);
+
+/*!
+Parses the given codepoint and stores the UTF-8 bytes in 'result'. The result is NULL terminated.
+\param result A memory buffer for the UTF-8 values. Must be at least 5 bytes long.
+\param codepoint The Uint32 codepoint to parse (not UTF-32).
+*/
+void FC_GetUTF8FromCodepoint(char* result, Uint32 codepoint);
+
+
+// UTF-8 string operations
+
+/*! Allocates a new string of 'size' bytes that is already NULL-terminated. The NULL byte counts toward the size limit, as usual. Returns NULL if size is 0. */
+char* U8_alloc(unsigned int size);
+
+/*! Deallocates the given string. */
+void U8_free(char* string);
+
+/*! Allocates a copy of the given string. */
+char* U8_strdup(const char* string);
+
+/*! Returns the number of UTF-8 characters in the given string. */
+int U8_strlen(const char* string);
+
+/*! Returns the number of bytes in the UTF-8 multibyte character pointed at by 'character'. */
+int U8_charsize(const char* character);
+
+/*! Copies the source multibyte character into the given buffer without overrunning it. Returns 0 on failure. */
+int U8_charcpy(char* buffer, const char* source, int buffer_size);
+
+/*! Returns a pointer to the next UTF-8 character. */
+const char* U8_next(const char* string);
+
+/*! Inserts a UTF-8 string into 'string' at the given position. Use a position of -1 to append. Returns 0 when unable to insert the string. */
+int U8_strinsert(char* string, int position, const char* source, int max_bytes);
+
+/*! Erases the UTF-8 character at the given position, moving the subsequent characters down. */
+void U8_strdel(char* string, int position);
+
+
+// Internal settings
+
+/*! Sets the string from which to load the initial glyphs. Use this if you need upfront loading for any reason (such as lack of render-target support). */
+void FC_SetLoadingString(FC_Font* font, const char* string);
+
+/*! Changes the size of the internal buffer which is used for unpacking variadic text data. This buffer is shared by all FC_Fonts. */
+void FC_SetBufferSize(unsigned int size);
+
+void FC_SetRenderCallback(FC_Rect (*callback)(FC_Image* src, FC_Rect* srcrect, FC_Target* dest, float x, float y, float xscale, float yscale));
+
+FC_Rect FC_DefaultRenderCallback(FC_Image* src, FC_Rect* srcrect, FC_Target* dest, float x, float y, float xscale, float yscale);
+
+
+// Custom caching
+
+/*! Returns the number of cache levels that are active. */
+int FC_GetNumCacheLevels(FC_Font* font);
+
+/*! Returns the cache source texture at the given cache level. */
+FC_Image* FC_GetGlyphCacheLevel(FC_Font* font, int cache_level);
+
+// TODO: Specify ownership of the texture (should be shareable)
+/*! Sets a cache source texture for rendering. New cache levels must be sequential. */
+Uint8 FC_SetGlyphCacheLevel(FC_Font* font, int cache_level, FC_Image* cache_texture);
+
+/*! Stores the glyph data for the given codepoint in 'result'. Returns 0 if the codepoint was not found in the cache. */
+Uint8 FC_GetGlyphData(FC_Font* font, FC_GlyphData* result, Uint32 codepoint);
+
+/*! Sets the glyph data for the given codepoint. Duplicates are not checked. Returns a pointer to the stored data. */
+FC_GlyphData* FC_SetGlyphData(FC_Font* font, Uint32 codepoint, FC_GlyphData glyph_data);
+
+
+// Rendering
+
+FC_Rect FC_Draw(FC_Font* font, FC_Target* dest, float x, float y, const char* formatted_text, ...);
+FC_Rect FC_DrawAlign(FC_Font* font, FC_Target* dest, float x, float y, FC_AlignEnum align, const char* formatted_text, ...);
+FC_Rect FC_DrawScale(FC_Font* font, FC_Target* dest, float x, float y, FC_Scale scale, const char* formatted_text, ...);
+FC_Rect FC_DrawColor(FC_Font* font, FC_Target* dest, float x, float y, SDL_Color color, const char* formatted_text, ...);
+FC_Rect FC_DrawEffect(FC_Font* font, FC_Target* dest, float x, float y, FC_Effect effect, const char* formatted_text, ...);
+
+FC_Rect FC_DrawBox(FC_Font* font, FC_Target* dest, FC_Rect box, const char* formatted_text, ...);
+FC_Rect FC_DrawBoxAlign(FC_Font* font, FC_Target* dest, FC_Rect box, FC_AlignEnum align, const char* formatted_text, ...);
+FC_Rect FC_DrawBoxScale(FC_Font* font, FC_Target* dest, FC_Rect box, FC_Scale scale, const char* formatted_text, ...);
+FC_Rect FC_DrawBoxColor(FC_Font* font, FC_Target* dest, FC_Rect box, SDL_Color color, const char* formatted_text, ...);
+FC_Rect FC_DrawBoxEffect(FC_Font* font, FC_Target* dest, FC_Rect box, FC_Effect effect, const char* formatted_text, ...);
+
+FC_Rect FC_DrawColumn(FC_Font* font, FC_Target* dest, float x, float y, Uint16 width, const char* formatted_text, ...);
+FC_Rect FC_DrawColumnAlign(FC_Font* font, FC_Target* dest, float x, float y, Uint16 width, FC_AlignEnum align, const char* formatted_text, ...);
+FC_Rect FC_DrawColumnScale(FC_Font* font, FC_Target* dest, float x, float y, Uint16 width, FC_Scale scale, const char* formatted_text, ...);
+FC_Rect FC_DrawColumnColor(FC_Font* font, FC_Target* dest, float x, float y, Uint16 width, SDL_Color color, const char* formatted_text, ...);
+FC_Rect FC_DrawColumnEffect(FC_Font* font, FC_Target* dest, float x, float y, Uint16 width, FC_Effect effect, const char* formatted_text, ...);
+
+
+// Getters
+
+FC_FilterEnum FC_GetFilterMode(FC_Font* font);
+Uint16 FC_GetLineHeight(FC_Font* font);
+Uint16 FC_GetHeight(FC_Font* font, const char* formatted_text, ...);
+Uint16 FC_GetWidth(FC_Font* font, const char* formatted_text, ...);
+
+// Returns a 1-pixel wide box in front of the character in the given position (index)
+FC_Rect FC_GetCharacterOffset(FC_Font* font, Uint16 position_index, int column_width, const char* formatted_text, ...);
+Uint16 FC_GetColumnHeight(FC_Font* font, Uint16 width, const char* formatted_text, ...);
+
+int FC_GetAscent(FC_Font* font, const char* formatted_text, ...);
+int FC_GetDescent(FC_Font* font, const char* formatted_text, ...);
+int FC_GetBaseline(FC_Font* font);
+int FC_GetSpacing(FC_Font* font);
+int FC_GetLineSpacing(FC_Font* font);
+Uint16 FC_GetMaxWidth(FC_Font* font);
+SDL_Color FC_GetDefaultColor(FC_Font* font);
+
+Uint8 FC_InRect(float x, float y, FC_Rect input_rect);
+// Given an offset (x,y) from the text draw position (the upper-left corner), returns the character position (UTF-8 index)
+Uint16 FC_GetPositionFromOffset(FC_Font* font, float x, float y, int column_width, FC_AlignEnum align, const char* formatted_text, ...);
+
+// Setters
+
+void FC_SetFilterMode(FC_Font* font, FC_FilterEnum filter);
+void FC_SetSpacing(FC_Font* font, int LetterSpacing);
+void FC_SetLineSpacing(FC_Font* font, int LineSpacing);
+void FC_SetDefaultColor(FC_Font* font, SDL_Color color);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+
+#endif
diff --git a/source/code/Makefile b/source/code/Makefile index 8a8acf9..f6f228a 100644 --- a/source/code/Makefile +++ b/source/code/Makefile
@@ -2,6 +2,8 @@ GAMEDIR=../../Game/
BINARY=$(GAMEDIR)blockattack
+-include sago/Makefile.sago
+
ifndef CC
CC=gcc
endif
@@ -10,17 +12,17 @@ ifdef CROSS
CXX=$(CROSS)g++
endif
-BASE_CFLAGS=-c $(shell $(CROSS)sdl-config --cflags) -std=c++11
+BASE_CFLAGS=-c $(shell $(CROSS)sdl2-config --cflags) -std=c++11
ifndef BUILDDIR
BUILDDIR=build
endif
-BASE_LIBS=$(shell $(CROSS)sdl-config --libs) -lSDL_ttf $(shell $(CROSS)pkg-config SDL_image SDL_mixer --libs)
+BASE_LIBS=$(shell $(CROSS)sdl2-config --libs) -lSDL2_ttf $(shell $(CROSS)pkg-config SDL2_image SDL2_mixer --libs) $(SAGO_BASE_LIBS)
#For developement only
ifndef DEBUG
-DEBUG=0
+DEBUG=1
endif
ifndef NETWORK
@@ -29,7 +31,7 @@ endif
#Compile with debug information or optimized.
ifeq ($(DEBUG),1)
-BASE_CFLAGS += -g -DDEBUG=1 -Wall
+BASE_CFLAGS += -g -DDEBUG=1 -Wall -Wno-sign-compare
else
BASE_CFLAGS += -O3
endif
@@ -43,7 +45,7 @@ endif
BASE_LIBS += -lphysfs
-OFILES=main.o highscore.o ReadKeyboard.o joypad.o listFiles.o common.o stats.o CppSdlImageHolder.o Libs/NFont.o MenuSystem.o menudef.o puzzlehandler.o
+OFILES=main.o highscore.o ReadKeyboard.o joypad.o listFiles.o common.o stats.o Libs/NFont.o Libs/SDL_FontCache.o MenuSystem.o menudef.o puzzlehandler.o ${SAGO_O_FILES}
ifeq ($(CROSS),i686-pc-mingw32-)
OFILES += winicon.res
@@ -71,7 +73,7 @@ run: $(BINARY)
cd $(GAMEDIR) && ./blockattack
clean:
- rm *.o *.P Libs/*.o Libs/*.P
+ rm *.o *.P Libs/*.o Libs/*.P ; true
SOURCE_FILES = $(OFILES:.o=.cpp)
diff --git a/source/code/MenuSystem.cpp b/source/code/MenuSystem.cpp index 2b0f4d1..5485a71 100644 --- a/source/code/MenuSystem.cpp +++ b/source/code/MenuSystem.cpp
@@ -21,11 +21,9 @@ http://blockattack.sf.net
===========================================================================
*/
-#include <SDL/SDL_events.h>
#include "MenuSystem.h"
#include "common.h"
-#include "CppSdlImageHolder.hpp"
#include "global.hpp"
int mousex;
@@ -33,21 +31,14 @@ int mousey;
using namespace std;
-/*Draws a image from on a given Surface. Takes source image, destination surface and coordinates*/
-inline void DrawIMG(SDL_Surface* img, SDL_Surface* target, int x, int y) {
- SDL_Rect dest;
- dest.x = x;
- dest.y = y;
- SDL_BlitSurface(img, nullptr, target, &dest);
-}
ButtonGfx standardButton;
-void ButtonGfx::setSurfaces(shared_ptr<CppSdl::CppSdlImageHolder> marked, shared_ptr<CppSdl::CppSdlImageHolder> unmarked) {
+void ButtonGfx::setSurfaces(sago::SagoSprite& marked, sago::SagoSprite& unmarked) {
this->marked = marked;
this->unmarked = unmarked;
- xsize=(marked)->GetWidth();
- ysize=(marked)->GetHeight();
+ xsize=(marked).GetWidth();
+ ysize=(marked).GetHeight();
if (verboseLevel) {
cout << "Surfaces set, size: " <<xsize << " , " << ysize << endl;
}
@@ -100,13 +91,12 @@ void Button::drawToScreen() {
//cout << "Painting button: " << label << " at: " << x << "," << y << endl;
#endif
if (marked) {
- gfx->marked->PaintTo(screen, x, y);
+ gfx->marked.Draw(screen, SDL_GetTicks(), x, y);
}
else {
- gfx->unmarked->PaintTo(screen,x,y);
+ gfx->unmarked.Draw(screen, SDL_GetTicks(), x, y);
}
- gfx->thefont.setDest(screen);
- gfx->thefont.drawCenter(x+gfx->xsize/2,y+gfx->ysize/2-gfx->thefont.getHeight("%s", label.c_str())/2, "%s", label.c_str());
+ gfx->thefont->draw(screen, x+gfx->xsize/2,y+gfx->ysize/2-gfx->thefont->getHeight("%s", label.c_str())/2, NFont::CENTER, "%s", label.c_str());
}
void Button::setPopOnRun(bool popOnRun) {
@@ -126,14 +116,14 @@ int Button::getHeight() {
}
void Menu::drawSelf() {
- DrawIMG(backgroundImage,screen,0,0);
+ backgroundImage.Draw(screen, SDL_GetTicks(), 0, 0);
vector<Button*>::iterator it;
for (it = buttons.begin(); it < buttons.end(); it++) {
(*it)->drawToScreen();
}
exit.drawToScreen();
- standardButton.thefont.draw(50, 50, "%s", title.c_str());
- mouse->PaintTo(screen,mousex,mousey);
+ standardButton.thefont->draw(screen, 50, 50, "%s", title.c_str());
+ mouse.Draw(screen, SDL_GetTicks(), mousex, mousey);
}
void Menu::performClick(int x,int y) {
@@ -171,14 +161,14 @@ void Menu::addButton(Button* b) {
placeButtons();
}
-Menu::Menu(SDL_Surface* screen) {
+Menu::Menu(SDL_Renderer* screen) {
this->screen = screen;
buttons = vector<Button*>(10);
isSubmenu = true;
exit.setLabel( _("Back") );
}
-Menu::Menu(SDL_Surface* screen,bool submenu) {
+Menu::Menu(SDL_Renderer* screen,bool submenu) {
this->screen = screen;
buttons = vector<Button*>(0);
isSubmenu = submenu;
@@ -190,7 +180,7 @@ Menu::Menu(SDL_Surface* screen,bool submenu) {
}
}
-Menu::Menu(SDL_Surface* screen, const string& title, bool submenu) {
+Menu::Menu(SDL_Renderer* screen, const string& title, bool submenu) {
this->screen = screen;
buttons = vector<Button*>(0);
isSubmenu = submenu;
@@ -298,6 +288,6 @@ void Menu::run() {
}
drawSelf();
- SDL_Flip(screen);
+ SDL_RenderPresent(screen);
}
}
diff --git a/source/code/MenuSystem.h b/source/code/MenuSystem.h index 342b74e..c90ea85 100644 --- a/source/code/MenuSystem.h +++ b/source/code/MenuSystem.h
@@ -29,22 +29,22 @@ http://blockattack.sf.net
#include "SDL.h"
#include <vector>
#include "Libs/NFont.h"
-#include "CppSdlImageHolder.hpp"
+#include "sago/SagoSprite.hpp"
#include <memory>
//The ButtonGfx object hold common media for all buttons, so we can reskin them by only changeing one pointer
struct ButtonGfx
{
//Holds the graphic for a button that is selected
- std::shared_ptr<CppSdl::CppSdlImageHolder> marked;
+ sago::SagoSprite marked;
//Holds the graphic for a button that is not selected
- std::shared_ptr<CppSdl::CppSdlImageHolder> unmarked;
+ sago::SagoSprite unmarked;
//The size of the buttons, so we don't have to ask w and h from the SDL Surfaces each time
int xsize;
int ysize;
//A TTFont used for writing the label on the buttons
- NFont thefont;
- void setSurfaces(std::shared_ptr<CppSdl::CppSdlImageHolder> marked, std::shared_ptr<CppSdl::CppSdlImageHolder> unmarked);
+ NFont* thefont;
+ void setSurfaces(sago::SagoSprite& marked, sago::SagoSprite& unmarked);
};
extern ButtonGfx standardButton;
@@ -101,7 +101,7 @@ private:
bool isSubmenu; //True if the menu is a submenu
int marked; //The index of the marked button (for keyboard up/down)
bool running; //The menu is running. The menu will terminate then this is false
- SDL_Surface *screen; //Pointer to the screen to draw to
+ SDL_Renderer *screen; //Pointer to the screen to draw to
std::string title;
// SDL_Surface *background; //Pointer to the background image
@@ -111,9 +111,9 @@ private:
public:
//numberOfItems is the expected numberOfItems for vector initialization
//SubMenu is true by default
- Menu(SDL_Surface *screen,bool isSubmenu);
- Menu(SDL_Surface *screen);
- Menu(SDL_Surface *screen, const std::string& title, bool isSubmenu);
+ Menu(SDL_Renderer *screen,bool isSubmenu);
+ Menu(SDL_Renderer *screen);
+ Menu(SDL_Renderer *screen, const std::string& title, bool isSubmenu);
//Add a button to the menu
void addButton(Button *b);
diff --git a/source/code/ReadKeyboard.cpp b/source/code/ReadKeyboard.cpp index 0b70924..0e1b0c9 100644 --- a/source/code/ReadKeyboard.cpp +++ b/source/code/ReadKeyboard.cpp
@@ -23,6 +23,7 @@ http://blockattack.sf.net
#include "ReadKeyboard.h"
#include "utf8.h"
+#include <iostream>
using namespace std;
@@ -34,7 +35,7 @@ ReadKeyboard::ReadKeyboard(void) {
ReadKeyboard::~ReadKeyboard(void) {
}
-Uint8 ReadKeyboard::CharsBeforeCursor() {
+int ReadKeyboard::CharsBeforeCursor() {
return std::distance(text_string.begin(), position);
}
@@ -45,11 +46,20 @@ ReadKeyboard::ReadKeyboard(const char* oldName) {
}
-void ReadKeyboard::putchar(char thing) {
+void ReadKeyboard::putchar(const std::string& thing) {
+ /*for (char a : thing) {
+ std::cout << (int)a;
+ }
+ std::cout << std::endl;
+ cout << "Length (pre): " << std::distance(text_string.begin(), position) << endl;*/
if (text_string.length() < maxLength) {
- text_string.insert(position, thing);
- utf8::advance(position, 1, text_string.end());
+ int oldPostition = utf8::distance(text_string.begin(), position);
+ int lengthOfInsertString = utf8::distance(thing.begin(), thing.end());
+ text_string.insert(position, thing.begin(), thing.end());
+ position = text_string.begin(); //Inserting may destroy our old iterator
+ utf8::advance(position, oldPostition + lengthOfInsertString, text_string.end());
}
+ //cout << "Length (post): " << std::distance(text_string.begin(), position) << endl;
}
@@ -61,25 +71,21 @@ void ReadKeyboard::removeChar() {
}
}
-bool ReadKeyboard::ReadKey(const SDL_keysym& key) {
- if (
- (key.unicode >= 'a' && key.unicode <= 'z') ||
- (key.unicode >= '0' && key.unicode <= '9') ||
- (key.unicode >= 'A' && key.unicode <= 'Z')) {
- ReadKeyboard::putchar(key.unicode);
- return true;
- }
- if (key.unicode == '.' || key.unicode == ',') {
- ReadKeyboard::putchar('.');
+bool ReadKeyboard::ReadKey(const SDL_Event& key) {
+ if (key.type == SDL_TEXTINPUT) {
+ putchar(key.text.text);
+ if (key.text.text[0] != 0) {
+ return true;
+ }
}
- return ReadKey(key.sym);
+ return ReadKey(key.key.keysym.sym);
}
-bool ReadKeyboard::ReadKey(SDLKey keyPressed) {
- if (keyPressed == SDLK_SPACE) {
- ReadKeyboard::putchar(' ');
- return true;
- }
+bool ReadKeyboard::ReadKey(SDL_Keycode keyPressed) {
+ /*if (keyPressed == SDLK_SPACE) {
+ ReadKeyboard::putchar(' ');
+ return true;
+ }*/
if (keyPressed == SDLK_DELETE) {
if ((text_string.length()>0)&& (position<text_string.end())) {
ReadKeyboard::removeChar();
@@ -113,6 +119,6 @@ bool ReadKeyboard::ReadKey(SDLKey keyPressed) {
return true;
}
-const char* ReadKeyboard::GetString() {
- return text_string.c_str();
+const std::string& ReadKeyboard::GetString() const {
+ return text_string;
}
diff --git a/source/code/ReadKeyboard.h b/source/code/ReadKeyboard.h index 36946c9..405e7dc 100644 --- a/source/code/ReadKeyboard.h +++ b/source/code/ReadKeyboard.h
@@ -34,14 +34,14 @@ private:
int maxLength;
std::string::iterator position;
std::string text_string;
- void putchar(char);
+ void putchar(const std::string& );
void removeChar();
public:
ReadKeyboard(void);
~ReadKeyboard(void);
ReadKeyboard(const char*);
- Uint8 CharsBeforeCursor(); //Where should the cursor be placed?
- bool ReadKey(const SDL_keysym&);
- bool ReadKey(SDLKey); //true if key accepted
- const char* GetString(void);
+ int CharsBeforeCursor(); //Where should the cursor be placed?
+ bool ReadKey(const SDL_Event&);
+ bool ReadKey(SDL_Keycode); //true if key accepted
+ const std::string& GetString(void) const;
};
diff --git a/source/code/SConscript b/source/code/SConscript index a81c4b6..632251a 100644 --- a/source/code/SConscript +++ b/source/code/SConscript
@@ -7,6 +7,11 @@ Import('*')
src = Split("""main.cpp
highscore.cpp
Libs/NFont.cpp
+Libs/SDL_FontCache.cpp
+sago/SagoDataHolder.cpp
+sago/SagoMisc.cpp
+sago/SagoSprite.cpp
+sago/SagoSpriteHolder.cpp
ReadKeyboard.cpp
joypad.cpp
listFiles.cpp
@@ -14,13 +19,12 @@ stats.cpp
common.cpp
MenuSystem.cpp
menudef.cpp
-puzzlehandler.cpp
-CppSdlImageHolder.cpp""")
+puzzlehandler.cpp""")
# Modify Build Environment #
-env.ParseConfig('sdl-config --cflags --libs')
+env.ParseConfig('sdl2-config --cflags --libs')
env.Append(CPPDEFINES = [('SHAREDIR', '\\"$sharedir\\"')])
-env.Append(LIBS = ['SDL', 'enet','SDL_image','SDL_mixer','SDL_ttf','physfs'])
+env.Append(LIBS = ['SDL2', 'enet','SDL2_image','SDL2_mixer','SDL2_ttf','physfs','jsoncpp'])
env.Append(LIBPATH = ['/usr/lib'])
# Compile Executable #
diff --git a/source/code/common.cpp b/source/code/common.cpp index 3525c37..f67e43e 100644 --- a/source/code/common.cpp +++ b/source/code/common.cpp
@@ -49,6 +49,13 @@ bool strequals(const char* a, const char* b) {
return strcmp(a,b) == 0;
}
+void dieOnNullptr(bool ptr, const char* msg) {
+ if (!ptr) {
+ cerr << "Fatal error: " << msg << endl;
+ abort();
+ }
+}
+
/**
* str2double parses a string and returns a double with the value of the string.
* if the string is not a double then 0.0 is returned instead of throing an error
diff --git a/source/code/common.h b/source/code/common.h index 01c5f4f..ca985c8 100644 --- a/source/code/common.h +++ b/source/code/common.h
@@ -74,6 +74,8 @@ int str2int(const std::string &str2parse) __attribute__((const));
std::string double2str(double num) __attribute__((const));
+void dieOnNullptr(bool, const char* msg);
+
/**
* str2double parses a string and returns a double with the value of the string.
* if the string is not a double then 0.0 is returned instead of throing an error
diff --git a/source/code/global.hpp b/source/code/global.hpp index 4f9e1c0..e61eda1 100644 --- a/source/code/global.hpp +++ b/source/code/global.hpp
@@ -24,24 +24,24 @@ http://blockattack.sf.net
#ifndef _GLOBAL_HPP
#define _GLOBAL_HPP
-#include "CppSdlImageHolder.hpp"
#include "Libs/NFont.h"
#include <memory>
+#include "sago/SagoSpriteHolder.hpp"
void MainMenu();
void ResetFullscreen();
-extern std::shared_ptr<CppSdl::CppSdlImageHolder> menuMarked;
-extern std::shared_ptr<CppSdl::CppSdlImageHolder> menuUnmarked;
+extern sago::SagoSprite menuMarked;
+extern sago::SagoSprite menuUnmarked;
extern NFont nf_scoreboard_font;
extern bool MusicEnabled; //true if background music is enabled
extern bool SoundEnabled; //true if sound effects is enabled
extern bool bFullscreen; //true if game is running fullscreen
extern std::string player1name;
extern std::string player2name;
-extern SDL_Surface *screen; //The whole screen;
-extern std::shared_ptr<CppSdl::CppSdlImageHolder> mouse;
-extern SDL_Surface* backgroundImage;
+extern SDL_Renderer *screen; //The whole screen;
+extern sago::SagoSprite mouse;
+extern sago::SagoSprite backgroundImage;
extern bool highPriority;
extern int verboseLevel;
diff --git a/source/code/joypad.cpp b/source/code/joypad.cpp index 8c680a2..0219f6d 100644 --- a/source/code/joypad.cpp +++ b/source/code/joypad.cpp
@@ -98,9 +98,9 @@ Joypad::Joypad() {
but1REL=true;
but2REL=true;
int joynum = 0;
- while ((SDL_JoystickOpened(joynum))&&(joynum<Joypad_number)) {
- joynum++;
- }
+ /*while ((SDL_JoystickOpened(joynum))&&(joynum<Joypad_number)) {
+ joynum++;
+ }*/
if (joynum>=Joypad_number) {
working = false;
}
diff --git a/source/code/main.cpp b/source/code/main.cpp index 8f3c394..311713b 100644 --- a/source/code/main.cpp +++ b/source/code/main.cpp
@@ -39,10 +39,7 @@ http://blockattack.sf.net
#define WITH_SDL 1
-//Macros to convert surfaces (ffor faster drawing)
-#define CONVERT(n) tmp = SDL_DisplayFormat(n); SDL_FreeSurface(n); n = tmp
-#define CONVERTA(n) tmp = SDL_DisplayFormatAlpha(n); SDL_FreeSurface(n); n = tmp
-
+#include "sago/SagoSpriteHolder.hpp"
#include <iostream>
#include <stdlib.h>
#include <time.h> //Used for srand()
@@ -60,7 +57,6 @@ http://blockattack.sf.net
#include <SDL/SDL_timer.h>
#include <SDL/SDL_video.h>
#include <SDL/SDL_ttf.h>
-#include "CppSdlImageHolder.hpp"
#include "MenuSystem.h"
#include "puzzlehandler.hpp"
#include <memory>
@@ -95,90 +91,11 @@ http://blockattack.sf.net
using namespace std;
-SDL_Surface* IMG_Load2(const char* path) {
- if (!PHYSFS_exists(path)) {
- cerr << "Error: File not in blockattack.data: " << path << endl;
- return nullptr; //file doesn't exist
- }
-
- PHYSFS_file* myfile = PHYSFS_openRead(path);
-
- // Get the lenght of the file
- unsigned int m_size = PHYSFS_fileLength(myfile);
-
- // Get the file data.
- char* m_data = new char[m_size];
-
- int length_read = PHYSFS_read (myfile, m_data, 1, m_size);
-
- if (length_read != (int)m_size) {
- delete [] m_data;
- m_data = 0;
- PHYSFS_close(myfile);
- cerr << "Error: Curropt data file!" << endl;
- return nullptr;
- }
-
- PHYSFS_close(myfile);
-
-// And this is how you load an image from a memory buffer with SDL
- SDL_RWops* rw = SDL_RWFromMem (m_data, m_size);
-
- //The above might fail an return null.
- if (!rw) {
- delete [] m_data;
- m_data = 0;
- PHYSFS_close(myfile);
- cerr << "Error: Curropt data file!" << endl;
- return nullptr;
- }
-
- SDL_Surface* surface = IMG_Load_RW(rw,true); //the second argument tells the function to three RWops
-
- return surface;
-}
-
-shared_ptr<CppSdl::CppSdlImageHolder> IMG_Load3(string path) {
- if (!PHYSFS_exists(path.c_str())) {
- cerr << "Error: File not in blockattack.data: " << path << endl;
- throw exception();
- }
-
- PHYSFS_file* myfile = PHYSFS_openRead(path.c_str());
-
- // Get the lenght of the file
- unsigned int m_size = PHYSFS_fileLength(myfile);
-
- // Get the file data.
- char* m_data = new char[m_size];
-
- int length_read = PHYSFS_read (myfile, m_data, 1, m_size);
-
- if (length_read != (int)m_size) {
- delete [] m_data;
- m_data = 0;
- PHYSFS_close(myfile);
- cerr << "Error: Curropt data file!" << endl;
- throw exception();
- }
-
- PHYSFS_close(myfile);
-
- shared_ptr<CppSdl::CppSdlImageHolder> surface(new CppSdl::CppSdlImageHolder(m_data, m_size));
-
- return surface;
-}
-
-static void UnloadImages();
-static int InitImages();
+static int InitImages(sago::SagoSpriteHolder& holder);
static string oldThemePath = "default";
-static bool loaded = false;
-void loadTheme(const string& themeName) {
- if (loaded) {
- UnloadImages();
- }
+void loadTheme(sago::SagoSpriteHolder& holder, const string& themeName) {
#if defined(__unix__)
string home = (string)getenv("HOME")+(string)"/.gamesaves/blockattack";
#elif defined(_WIN32)
@@ -189,7 +106,7 @@ void loadTheme(const string& themeName) {
//Look in blockattack.data
PHYSFS_addToSearchPath(((string)SHAREDIR+"/blockattack.data").c_str(), 1);
//Look in folder
- PHYSFS_addToSearchPath(PHYSFS_getBaseDir(), 1);
+ PHYSFS_addToSearchPath( ((string) PHYSFS_getBaseDir()+"/data").c_str(), 1);
//Look in home folder
#if defined(__unix__) || defined(_WIN32)
PHYSFS_addToSearchPath(home.c_str(), 1);
@@ -199,8 +116,7 @@ void loadTheme(const string& themeName) {
Config::getInstance()->setString("themename", themeName);
}
if (themeName.compare("default")==0 || (themeName.compare("start")==0)) {
- InitImages();
- loaded =true;
+ InitImages(holder);
return; //Nothing more to do
}
oldThemePath = "themes/"+themeName;
@@ -208,441 +124,119 @@ void loadTheme(const string& themeName) {
#if defined(__unix__) || defined(_WIN32)
PHYSFS_addToSearchPath((home+(string)"/"+oldThemePath).c_str(), 0);
#endif
- InitImages();
- loaded = true;
+ InitImages(holder);
}
-long NFont_OpenFont(NFont* target, const char* path,int ptsize, SDL_Color color, int style=TTF_STYLE_NORMAL) {
- if (!PHYSFS_exists(path)) {
- cerr << "Error: File not in blockattack.data: " << path << endl;
- return -1; //file doesn't exist
- }
-
- if (!(TTF_WasInit())) {
- TTF_Init();
- }
-
- PHYSFS_file* myfile = PHYSFS_openRead(path);
-
- // Get the lenght of the file
- unsigned int m_size = PHYSFS_fileLength(myfile);
-
- // Get the file data.
- char* m_data = new char[m_size];
- int length_read = PHYSFS_read (myfile, m_data, 1, m_size);
-
- if (length_read != (int)m_size) {
- delete [] m_data;
- m_data = 0;
- PHYSFS_close(myfile);
- cerr << "Error: Curropt data file!" << endl;
- return -3;
- }
-
- PHYSFS_close(myfile);
-
-// And this is how you load from a memory buffer with SDL
- SDL_RWops* rw = SDL_RWFromMem (m_data, m_size);
-
- //The above might fail an return null.
- if (!rw) {
- delete [] m_data;
- m_data = 0;
- PHYSFS_close(myfile);
- cerr << "Error: Curropt data file!" << endl;
- return -2;
- }
-
- TTF_Font* font;
- font=TTF_OpenFontRW(rw, 1, ptsize);
- TTF_SetFontStyle(font,style);
-
- target->load(font,color);
-
- TTF_CloseFont(font); //Once loaded we don't care anymore!
-
- return 0;
-}
-
-
-Mix_Music* Mix_LoadMUS2(string path) {
- if (!PHYSFS_exists(path.c_str())) {
- cerr << "Warning: File not in blockattack.data: " << path << endl;
- return nullptr; //file doesn't exist
- }
-
- PHYSFS_file* myfile = PHYSFS_openRead(path.c_str());
-
- // Get the lenght of the file
- unsigned int m_size = PHYSFS_fileLength(myfile);
-
- // Get the file data.
- char* m_data = new char[m_size];
-
- int length_read = PHYSFS_read (myfile, m_data, 1, m_size);
-
- if (length_read != (int)m_size) {
- delete [] m_data;
- m_data = 0;
- PHYSFS_close(myfile);
- cerr << "Error: Curropt data file!" << endl;
- return nullptr;
- }
-
- PHYSFS_close(myfile);
-
-// And this is how you load from a memory buffer with SDL
- SDL_RWops* rw = SDL_RWFromMem (m_data, m_size);
-
- //The above might fail an return null.
- if (!rw) {
- delete [] m_data;
- m_data = 0;
- PHYSFS_close(myfile);
- cerr << "Error: Curropt data file!" << endl;
- return nullptr;
- }
-
- Mix_Music* ret = Mix_LoadMUS_RW(rw);
-
- return ret;
-}
-
-
-Mix_Chunk* Mix_LoadWAV2(const char* path) {
- if (!PHYSFS_exists(path)) {
- cerr << "Warning: File not in blockattack.data: " << path << endl;
- return nullptr; //file doesn't exist
- }
-
- PHYSFS_file* myfile = PHYSFS_openRead(path);
-
- // Get the lenght of the file
- unsigned int m_size = PHYSFS_fileLength(myfile);
-
- // Get the file data.
- char* m_data = new char[m_size];
-
- int length_read = PHYSFS_read (myfile, m_data, 1, m_size);
-
- if (length_read != (int)m_size) {
- delete [] m_data;
- m_data = 0;
- PHYSFS_close(myfile);
- cerr << "Error: Curropt data file!" << endl;
- return nullptr;
- }
-
- PHYSFS_close(myfile);
-
-// And this is how you load from a memory buffer with SDL
- SDL_RWops* rw = SDL_RWFromMem (m_data, m_size);
-
- //The above might fail an return null.
- if (!rw) {
- delete [] m_data;
- m_data = 0;
- PHYSFS_close(myfile);
- cerr << "Error: Curropt data file!" << endl;
- return nullptr;
- }
-
- Mix_Chunk* ret = Mix_LoadWAV_RW(rw,true); //the second argument tells the function to three RWops
-
- return ret;
-}
-
//Load all image files to memory
-static int InitImages() {
- if (!((backgroundImage = IMG_Load2("gfx/background.png"))
- && (bOptions = IMG_Load2("gfx/bOptions.png"))
- && (bConfigure = IMG_Load2("gfx/bConfigure.png"))
- && (bSelectPuzzle = IMG_Load2("gfx/bSelectPuzzle.png"))
- && (bHighScore = IMG_Load2("gfx/bHighScore.png"))
- && (bBack = IMG_Load2("gfx/bBlank.png"))
- && (bForward = IMG_Load2("gfx/bForward.png"))
- && (blackLine = IMG_Load2("gfx/blackLine.png"))
- && (stageBobble = IMG_Load2("gfx/iStageClearLimit.png"))
- && (bricks[0] = IMG_Load2("gfx/bricks/blue.png"))
- && (bricks[1] = IMG_Load2("gfx/bricks/green.png"))
- && (bricks[2] = IMG_Load2("gfx/bricks/purple.png"))
- && (bricks[3] = IMG_Load2("gfx/bricks/red.png"))
- && (bricks[4] = IMG_Load2("gfx/bricks/turkish.png"))
- && (bricks[5] = IMG_Load2("gfx/bricks/yellow.png"))
- && (bricks[6] = IMG_Load2("gfx/bricks/grey.png"))
- && (crossover = IMG_Load2("gfx/crossover.png"))
- && (balls[0] = IMG_Load2("gfx/balls/ballBlue.png"))
- && (balls[1] = IMG_Load2("gfx/balls/ballGreen.png"))
- && (balls[2] = IMG_Load2("gfx/balls/ballPurple.png"))
- && (balls[3] = IMG_Load2("gfx/balls/ballRed.png"))
- && (balls[4] = IMG_Load2("gfx/balls/ballTurkish.png"))
- && (balls[5] = IMG_Load2("gfx/balls/ballYellow.png"))
- && (balls[6] = IMG_Load2("gfx/balls/ballGray.png"))
- && (cursor[0] = IMG_Load2("gfx/animations/cursor/1.png"))
- && (cursor[1] = IMG_Load2("gfx/animations/cursor/2.png"))
- && (bomb[0] = IMG_Load2("gfx/animations/bomb/bomb_1.png"))
- && (bomb[1] = IMG_Load2("gfx/animations/bomb/bomb_2.png"))
- && (ready[0] = IMG_Load2("gfx/animations/ready/ready_1.png"))
- && (ready[1] = IMG_Load2("gfx/animations/ready/ready_2.png"))
- && (explosion[0] = IMG_Load2("gfx/animations/explosion/0.png"))
- && (explosion[1] = IMG_Load2("gfx/animations/explosion/1.png"))
- && (explosion[2] = IMG_Load2("gfx/animations/explosion/2.png"))
- && (explosion[3] = IMG_Load2("gfx/animations/explosion/3.png"))
- && (counter[0] = IMG_Load2("gfx/counter/1.png"))
- && (counter[1] = IMG_Load2("gfx/counter/2.png"))
- && (counter[2] = IMG_Load2("gfx/counter/3.png"))
- && (backBoard = IMG_Load2("gfx/BackBoard.png")) //not used, we just test if it exists :)
- && (iGameOver = IMG_Load2("gfx/iGameOver.png"))
- && (iWinner = IMG_Load2("gfx/iWinner.png"))
- && (iDraw = IMG_Load2("gfx/iDraw.png"))
- && (iLoser = IMG_Load2("gfx/iLoser.png"))
- && (iChainBack = IMG_Load2("gfx/chainFrame.png"))
-// && (optionsBack = IMG_Load2("gfx/options.png"))
- && (bOn = IMG_Load2("gfx/bOn.png"))
- && (bOff = IMG_Load2("gfx/bOff.png"))
-// && (bChange = IMG_Load2("gfx/bChange.png"))
- && (b1024 = IMG_Load2("gfx/b1024.png"))
- && (dialogBox = IMG_Load2("gfx/dialogbox.png"))
-// && (fileDialogBox = IMG_Load2("gfx/fileDialogbox.png"))
- && (iLevelCheck = IMG_Load2("gfx/iLevelCheck.png"))
- && (iLevelCheckBox = IMG_Load2("gfx/iLevelCheckBox.png"))
- && (iLevelCheckBoxMarked = IMG_Load2("gfx/iLevelCheckBoxMarked.png"))
- && (iCheckBoxArea = IMG_Load2("gfx/iCheckBoxArea.png"))
- && (boardBackBack = IMG_Load2("gfx/boardBackBack.png"))
- && (changeButtonsBack = IMG_Load2("gfx/changeButtonsBack.png"))
- && (garbageTL = IMG_Load2("gfx/garbage/garbageTL.png"))
- && (garbageT = IMG_Load2("gfx/garbage/garbageT.png"))
- && (garbageTR = IMG_Load2("gfx/garbage/garbageTR.png"))
- && (garbageR = IMG_Load2("gfx/garbage/garbageR.png"))
- && (garbageBR = IMG_Load2("gfx/garbage/garbageBR.png"))
- && (garbageB = IMG_Load2("gfx/garbage/garbageB.png"))
- && (garbageBL = IMG_Load2("gfx/garbage/garbageBL.png"))
- && (garbageL = IMG_Load2("gfx/garbage/garbageL.png"))
- && (garbageFill = IMG_Load2("gfx/garbage/garbageFill.png"))
- && (garbageML = IMG_Load2("gfx/garbage/garbageML.png"))
- && (garbageM = IMG_Load2("gfx/garbage/garbageM.png"))
- && (garbageMR = IMG_Load2("gfx/garbage/garbageMR.png"))
- && (garbageGM = IMG_Load2("gfx/garbage/garbageGM.png"))
- && (garbageGML = IMG_Load2("gfx/garbage/garbageGML.png"))
- && (garbageGMR = IMG_Load2("gfx/garbage/garbageGMR.png"))
- && (smiley[0] = IMG_Load2("gfx/smileys/0.png"))
- && (smiley[1] = IMG_Load2("gfx/smileys/1.png"))
- && (smiley[2] = IMG_Load2("gfx/smileys/2.png"))
- && (smiley[3] = IMG_Load2("gfx/smileys/3.png"))
- //new in 1.3.2
- && (transCover = IMG_Load2("gfx/transCover.png"))
- //end new in 1.3.2
- //new in 1.4.0
- && (bSkip = IMG_Load2("gfx/bBlank.png"))
- && (bNext = IMG_Load2("gfx/bBlank.png"))
- && (bRetry = IMG_Load2("gfx/bBlank.png"))
- ))
- //if there was a problem ie. "File not found"
- {
- cerr << "Error: Failed to load image file: " << SDL_GetError() << endl;
- exit(1);
- }
- try {
- bNewGame = IMG_Load3("gfx/bNewGame.png");
- mouse = IMG_Load3("gfx/mouse.png");
- menuMarked = IMG_Load3("gfx/menu/marked.png");
- menuUnmarked = IMG_Load3("gfx/menu/unmarked.png");
- }
- catch (exception& e) {
- cerr << e.what() << endl;
- exit(1);
- }
-
+static int InitImages(sago::SagoSpriteHolder& holder) {
+ bricks[0] = holder.GetSprite("blue");
+ bricks[1] = holder.GetSprite("green");
+ bricks[2] = holder.GetSprite("purple");
+ bricks[3] = holder.GetSprite("red");
+ bricks[4] = holder.GetSprite("turkish");
+ bricks[5] = holder.GetSprite("yellow");
+ bricks[6] = holder.GetSprite("grey");
+ bomb = holder.GetSprite("block_bomb");
+ backgroundImage = holder.GetSprite("background");
+ bHighScore = holder.GetSprite("b_highscore");
+ bBack = holder.GetSprite("b_blank");
+ bForward = holder.GetSprite("b_forward");
+ blackLine = holder.GetSprite("black_line");
+ stageBobble = holder.GetSprite("i_stage_clear_limit");
+ crossover = holder.GetSprite("crossover");
+ balls[0] = holder.GetSprite("ball_blue");
+ balls[1] = holder.GetSprite("ball_green");
+ balls[2] = holder.GetSprite("ball_purple");
+ balls[3] = holder.GetSprite("ball_red");
+ balls[4] = holder.GetSprite("ball_turkish");
+ balls[5] = holder.GetSprite("ball_yellow");
+ balls[6] = holder.GetSprite("ball_gray");
+ cursor = holder.GetSprite("cursor");
+ ready = holder.GetSprite("ready");
+ explosion[0] = holder.GetSprite("explosion0");
+ explosion[1] = holder.GetSprite("explosion1");
+ explosion[2] = holder.GetSprite("explosion2");
+ explosion[3] = holder.GetSprite("explosion3");
+ counter[0] = holder.GetSprite("counter_1");
+ counter[1] = holder.GetSprite("counter_2");
+ counter[2] = holder.GetSprite("counter_3");
+ iGameOver = holder.GetSprite("i_game_over");
+ iWinner = holder.GetSprite("i_winner");
+ iDraw = holder.GetSprite("i_draw");
+ iLoser = holder.GetSprite("i_loser");
+ iChainFrame = holder.GetSprite("chain_frame");
+ dialogBox = holder.GetSprite("dialogbox");
+ iLevelCheck = holder.GetSprite("i_level_check");
+ iLevelCheckBox = holder.GetSprite("i_level_check_box");
+ iLevelCheckBoxMarked = holder.GetSprite("i_level_check_box_marked");
+ iCheckBoxArea = holder.GetSprite("i_check_box_area");
+ boardBackBack = holder.GetSprite("board_back_back");
+ garbageTL = holder.GetSprite("garbage_tl");
+ garbageT = holder.GetSprite("garbage_t");
+ garbageTR = holder.GetSprite("garbage_tr");
+ garbageR = holder.GetSprite("garbage_r");
+ garbageBR = holder.GetSprite("garbage_br");
+ garbageB = holder.GetSprite("garbage_b");
+ garbageBL = holder.GetSprite("garbage_bl");
+ garbageL = holder.GetSprite("garbage_l");
+ garbageFill = holder.GetSprite("garbage_fill");
+ garbageML = holder.GetSprite("garbage_ml");
+ garbageM = holder.GetSprite("garbage_m");
+ garbageMR = holder.GetSprite("garbage_mr");
+ garbageGM = holder.GetSprite("garbage_gm");
+ garbageGML = holder.GetSprite("garbage_gml");
+ garbageGMR = holder.GetSprite("garbage_gmr");
+ smiley[0] = holder.GetSprite("smileys0");
+ smiley[1] = holder.GetSprite("smileys1");
+ smiley[2] = holder.GetSprite("smileys2");
+ smiley[3] = holder.GetSprite("smileys3");
+ transCover = holder.GetSprite("trans_cover");
+ bSkip = holder.GetSprite("b_blank");
+ bNext = holder.GetSprite("b_blank");
+ bRetry = holder.GetSprite("b_blank");
+ mouse = holder.GetSprite("mouse");
+ menuMarked = holder.GetSprite("menu_marked");
+ menuUnmarked = holder.GetSprite("menu_unmarked");
+ backBoard = holder.GetSprite("back_board");
- //Prepare for fast blittering!
- CONVERT(backgroundImage);
- CONVERT(bOptions);
- CONVERTA(bConfigure);
- CONVERTA(bSelectPuzzle);
- CONVERTA(bSkip);
- CONVERTA(bRetry);
- CONVERTA(bNext);
- CONVERT(bHighScore);
- CONVERTA(boardBackBack);
- CONVERT(backBoard);
- CONVERT(blackLine);
- CONVERTA(changeButtonsBack);
- CONVERTA(cursor[0]);
- CONVERTA(cursor[1]);
- CONVERTA(counter[0]);
- CONVERTA(counter[1]);
- CONVERTA(counter[2]);
- CONVERT(bOn);
- CONVERT(bOff);
- CONVERT(b1024);
- CONVERTA(dialogBox);
-// CONVERTA(fileDialogBox);
- CONVERTA(iLevelCheck);
- CONVERT(iLevelCheckBox);
- CONVERT(iLevelCheckBoxMarked);
- CONVERTA(iCheckBoxArea);
- for (int i = 0; i<4; i++) {
- CONVERTA(explosion[i]);
- }
- for (int i = 0; i<7; i++) {
- CONVERTA(bricks[i]);
- CONVERTA(balls[i]);
- }
- CONVERTA(crossover);
- CONVERTA(garbageTL);
- CONVERTA(garbageT);
- CONVERTA(garbageTR);
- CONVERTA(garbageR);
- CONVERTA(garbageBR);
- CONVERTA(garbageB);
- CONVERTA(garbageBL);
- CONVERTA(garbageL);
- CONVERTA(garbageFill);
- CONVERTA(garbageML);
- CONVERTA(garbageMR);
- CONVERTA(garbageM);
- CONVERTA(garbageGML);
- CONVERTA(garbageGMR);
- CONVERTA(garbageGM);
- CONVERTA(smiley[0]);
- CONVERTA(smiley[1]);
- CONVERTA(smiley[2]);
- CONVERTA(smiley[3]);
- CONVERTA(iWinner);
- CONVERTA(iDraw);
- CONVERTA(iLoser);
- CONVERTA(iChainBack);
- CONVERTA(iGameOver);
- mouse->OptimizeForBlit(true);
- bNewGame->OptimizeForBlit(true);
- CONVERTA(stageBobble);
- CONVERTA(transCover);
SDL_Color nf_button_color, nf_standard_blue_color, nf_standard_small_color;
memset(&nf_button_color,0,sizeof(SDL_Color));
nf_button_color.b = 255;
nf_button_color.g = 255;
nf_button_color.r = 255;
+ nf_button_color.a = 255;
nf_standard_blue_color.b = 255;
nf_standard_blue_color.g = 0;
nf_standard_blue_color.r = 0;
+ nf_standard_blue_color.a = 255;
nf_standard_small_color.b = 0;
nf_standard_small_color.g = 0;
nf_standard_small_color.r = 200;
- NFont_OpenFont(&nf_button_font,"fonts/FreeSerif.ttf",24,nf_button_color);
- nf_button_font.setDest(screen);
- NFont_OpenFont(&nf_standard_blue_font,"fonts/FreeSerif.ttf",30,nf_standard_blue_color);
- nf_standard_blue_font.setDest(screen);
- NFont_OpenFont(&nf_standard_small_font,"fonts/FreeSerif.ttf",16,nf_standard_small_color);
- nf_standard_small_font.setDest(screen);
- NFont_OpenFont(&nf_scoreboard_font,"fonts/PenguinAttack.ttf",20,nf_button_color);
- nf_scoreboard_font.setDest(screen);
- nf_button_font.setDest(screen);
-
+ nf_standard_small_color.a = 255;
+ nf_button_font.load(screen, holder.GetDataHolder().getFontPtr("freeserif", 24), nf_button_color);
+ nf_standard_blue_font.load(screen, holder.GetDataHolder().getFontPtr("freeserif", 30), nf_standard_blue_color);
+ nf_standard_small_font.load(screen, holder.GetDataHolder().getFontPtr("freeserif", 16), nf_standard_small_color);
+ nf_scoreboard_font.load(screen, holder.GetDataHolder().getFontPtr("penguinattack", 20), nf_button_color);
//Loads the sound if sound present
if (!NoSound) {
//And here the music:
- bgMusic = Mix_LoadMUS2("music/bgMusic.ogg");
- highbeatMusic = Mix_LoadMUS2("music/highbeat.ogg");
+ bgMusic = holder.GetDataHolder().getMusicPtr("bgmusic");
+ highbeatMusic = holder.GetDataHolder().getMusicPtr("highbeat");
//the music... we just hope it exists, else the user won't hear anything
//Same goes for the sounds
- boing = Mix_LoadWAV2("sound/pop.ogg");
- applause = Mix_LoadWAV2("sound/applause.ogg");
- photoClick = Mix_LoadWAV2("sound/cameraclick.ogg");
- typingChunk = Mix_LoadWAV2("sound/typing.ogg");
- counterChunk = Mix_LoadWAV2("sound/counter.ogg");
- counterFinalChunk = Mix_LoadWAV2("sound/counterFinal.ogg");
+ boing = holder.GetDataHolder().getSoundPtr("pop");
+ applause = holder.GetDataHolder().getSoundPtr("applause");
+ photoClick = holder.GetDataHolder().getSoundPtr("cameraclick");
+ typingChunk = holder.GetDataHolder().getSoundPtr("typing");
+ counterChunk = holder.GetDataHolder().getSoundPtr("counter");
+ counterFinalChunk = holder.GetDataHolder().getSoundPtr("counter_final");
} //All sound has been loaded or not
return 0;
} //InitImages()
-//Unload images and fonts and sounds
-void UnloadImages() {
- if (verboseLevel) {
- cout << "Unloading data..." << endl;
- }
- if (!NoSound) { //Only unload then it has been loaded!
- Mix_HaltMusic();
- Mix_FreeMusic(bgMusic);
- Mix_FreeMusic(highbeatMusic);
- Mix_FreeChunk(boing);
- Mix_FreeChunk(applause);
- Mix_FreeChunk(photoClick);
- Mix_FreeChunk(counterChunk);
- Mix_FreeChunk(counterFinalChunk);
- Mix_FreeChunk(typingChunk);
- }
- //Free surfaces:
- //I think this will crash, at least it happend to me...
- //Chrashes no more. Caused by an undocumented double free
- SDL_FreeSurface(backgroundImage);
- SDL_FreeSurface(bOptions);
- SDL_FreeSurface(bConfigure);
- SDL_FreeSurface(bSelectPuzzle);
- SDL_FreeSurface(bHighScore);
- SDL_FreeSurface(blackLine);
- SDL_FreeSurface(stageBobble);
- SDL_FreeSurface(bricks[0]);
- SDL_FreeSurface(bricks[1]);
- SDL_FreeSurface(bricks[2]);
- SDL_FreeSurface(bricks[3]);
- SDL_FreeSurface(bricks[4]);
- SDL_FreeSurface(bricks[5]);
- SDL_FreeSurface(bricks[6]);
- SDL_FreeSurface(crossover);
- SDL_FreeSurface(balls[0]);
- SDL_FreeSurface(balls[1]);
- SDL_FreeSurface(balls[2]);
- SDL_FreeSurface(balls[3]);
- SDL_FreeSurface(balls[4]);
- SDL_FreeSurface(balls[5]);
- SDL_FreeSurface(balls[6]);
- SDL_FreeSurface(cursor[0]);
- SDL_FreeSurface(cursor[1]);
- SDL_FreeSurface(backBoard); //not used, we just test if it exists :)
- SDL_FreeSurface(iGameOver);
- SDL_FreeSurface(iWinner);
- SDL_FreeSurface(iDraw);
- SDL_FreeSurface(iLoser);
- SDL_FreeSurface(iChainBack);
- SDL_FreeSurface(bOn);
- SDL_FreeSurface(bOff);
- SDL_FreeSurface(b1024);
- SDL_FreeSurface(dialogBox);
- //SDL_FreeSurface(fileDialogBox);
- SDL_FreeSurface(iLevelCheck);
- SDL_FreeSurface(iLevelCheckBox);
- SDL_FreeSurface(iLevelCheckBoxMarked);
- SDL_FreeSurface(iCheckBoxArea);
- SDL_FreeSurface(boardBackBack);
- SDL_FreeSurface(changeButtonsBack);
- SDL_FreeSurface(garbageTL);
- SDL_FreeSurface(garbageT);
- SDL_FreeSurface(garbageTR);
- SDL_FreeSurface(garbageR);
- SDL_FreeSurface(garbageBR);
- SDL_FreeSurface(garbageB);
- SDL_FreeSurface(garbageBL);
- SDL_FreeSurface(garbageL);
- SDL_FreeSurface(garbageFill);
- SDL_FreeSurface(garbageML);
- SDL_FreeSurface(garbageM);
- SDL_FreeSurface(garbageMR);
- SDL_FreeSurface(garbageGML);
- SDL_FreeSurface(garbageGM);
- SDL_FreeSurface(garbageGMR);
- SDL_FreeSurface(smiley[0]);
- SDL_FreeSurface(smiley[1]);
- SDL_FreeSurface(smiley[2]);
- SDL_FreeSurface(smiley[3]);
- SDL_FreeSurface(transCover);
- mouse->MakeNull();
- bNewGame->MakeNull();
-}
-
-
static stringstream converter;
//Function to convert numbers to string (2 diget)
@@ -657,61 +251,22 @@ static string itoa2(int num) {
}
/*Draws a image from on a given Surface. Takes source image, destination surface and coordinates*/
-void DrawIMG(SDL_Surface* img, SDL_Surface* target, int x, int y) {
- SDL_Rect dest;
- dest.x = x;
- dest.y = y;
- SDL_BlitSurface(img, nullptr, target, &dest);
-}
-
-void DrawIMG_Bounded(SDL_Surface* img, SDL_Surface* target, int x, int y, int minx, int miny, int maxx, int maxy) {
- SDL_Rect dest;
- dest.x = x;
- dest.y = y;
- if (dest.x >= minx && dest.y >= miny && dest.x + img->w <= maxx && dest.y + img->h <= maxy) {
- SDL_BlitSurface(img, nullptr, target, &dest);
- return;
- }
- SDL_Rect dest2;
- dest2.x = 0;
- dest2.y = 0;
- dest2.w = img->w;
- dest2.h = img->h;
- if (dest.x < minx) {
- dest2.x += minx-dest.x;
- dest.x = minx;
- }
- if (dest.y < miny) {
- dest2.y += miny-dest.y;
- dest.y = miny;
- }
- if (dest.y+dest2.h > maxy) {
- dest2.h -= (dest.y+dest2.h - maxy);
- }
- if (dest.x+dest2.w > maxx) {
- dest2.w -= (dest.x+dest2.w - maxx);
- }
- SDL_BlitSurface(img, &dest2, target, &dest);
+void DrawIMG(sago::SagoSprite& sprite, SDL_Renderer* target, int x, int y) {
+ sprite.Draw(target, SDL_GetTicks() ,x,y);
}
-/*Draws a part of an image on a surface of choice*/
-void DrawIMG(SDL_Surface* img, SDL_Surface* target, int x, int y, int w, int h, int x2, int y2) {
- SDL_Rect dest;
- dest.x = x;
- dest.y = y;
- SDL_Rect dest2;
- dest2.x = x2;
- dest2.y = y2;
- dest2.w = w;
- dest2.h = h;
- SDL_BlitSurface(img, &dest2, target, &dest);
+void DrawIMG_Bounded(sago::SagoSprite& sprite, SDL_Renderer* target, int x, int y, int minx, int miny, int maxx, int maxy) {
+ SDL_Rect bounds;
+ bounds.x = minx;
+ bounds.y = miny;
+ bounds.w = maxx-minx;
+ bounds.h = maxy-miny;
+ sprite.DrawBounded(target, SDL_GetTicks(),x,y,bounds);
}
-void NFont_Write(SDL_Surface* target, int x, int y, const string& text) {
- nf_standard_blue_font.setDest(target);
- nf_standard_blue_font.draw(x, y, "%s", text.c_str());
- nf_standard_blue_font.setDest(screen);
+void NFont_Write(SDL_Renderer* target, int x, int y, const string& text) {
+ nf_standard_blue_font.draw(target, x, y, "%s", text.c_str());
}
void ResetFullscreen() {
@@ -724,7 +279,8 @@ void ResetFullscreen() {
}
DrawIMG(background, screen, 0, 0);
#else
- SDL_WM_ToggleFullScreen(screen); //Will only work in Linux
+ //TODO: Find SDL2 alternative
+ //SDL_WM_ToggleFullScreen(screen); //Will only work in Linux
#endif
SDL_ShowCursor(SDL_DISABLE);
}
@@ -1013,17 +569,17 @@ public:
topx = tx;
topy = ty;
}
-
- void DrawImgBoard(SDL_Surface* img, int x, int y) const {
+
+ void DrawImgBoard(sago::SagoSprite& img, int x, int y) const {
DrawIMG(img, screen, x+topx, y+topy);
}
-
- void DrawImgBoardBounded(SDL_Surface* img, int x, int y) const {
- DrawIMG_Bounded(img, screen, x+topx, y+topy, topx, topy, topx + backBoard->w, topy + backBoard->h);
+
+ void DrawImgBoardBounded(sago::SagoSprite& img, int x, int y) const {
+ DrawIMG_Bounded(img, screen, x+topx, y+topy, topx, topy, topx + backBoard.GetWidth(), topy + backBoard.GetHeight());
}
-
+
void PrintTextCenteredBoard(int x, int y, const char* text) {
- nf_button_font.drawCenter(x+topx+60, y+topy+10, "%s", text);
+ nf_button_font.draw(screen, x+topx+60, y+topy+10, NFont::CENTER, "%s", text);
}
int GetTopX() const {
@@ -1090,10 +646,10 @@ private:
if ((board[j][i]%10 != -1) && (board[j][i]%10 < 7) && ((board[j][i]/1000000)%10==0)) {
DrawImgBoardBounded(bricks[board[j][i]%10], j*bsize, bsize*12-i*bsize-pixels);
if ((board[j][i]/BLOCKWAIT)%10==1) {
- DrawImgBoard(bomb[(ticks/BOMBTIME)%2], j*bsize, bsize*12-i*bsize-pixels);
+ DrawImgBoard(bomb, j*bsize, bsize*12-i*bsize-pixels);
}
if ((board[j][i]/BLOCKHANG)%10==1) {
- DrawImgBoardBounded(ready[(ticks/READYTIME)%2], j*bsize, bsize*12-i*bsize-pixels);
+ DrawImgBoardBounded(ready, j*bsize, bsize*12-i*bsize-pixels);
}
}
@@ -1227,13 +783,12 @@ public:
//Draws everything
void DoPaintJob() {
DrawIMG(boardBackBack,screen,this->GetTopX()-60,this->GetTopY()-68);
-
- nf_scoreboard_font.draw(this->GetTopX()+310,this->GetTopY()-68+148,_("Score:") );
- nf_scoreboard_font.draw(this->GetTopX()+310,this->GetTopY()-68+197,_("Time:") );
- nf_scoreboard_font.draw(this->GetTopX()+310,this->GetTopY()-68+246,_("Chain:") );
- nf_scoreboard_font.draw(this->GetTopX()+310,this->GetTopY()-68+295,_("Speed:") );
+
+ nf_scoreboard_font.draw(screen, this->GetTopX()+310,this->GetTopY()-68+148,_("Score:") );
+ nf_scoreboard_font.draw(screen, this->GetTopX()+310,this->GetTopY()-68+197,_("Time:") );
+ nf_scoreboard_font.draw(screen, this->GetTopX()+310,this->GetTopY()-68+246,_("Chain:") );
+ nf_scoreboard_font.draw(screen, this->GetTopX()+310,this->GetTopY()-68+295,_("Speed:") );
DrawImgBoard(backBoard, 0, 0);
- nf_standard_blue_font.setDest(screen); //reset to screen at the end of this funciton!
PaintBricks();
if (stageClear) {
@@ -1242,7 +797,7 @@ public:
if (puzzleMode&&(!bGameOver)) {
//We need to write nr. of moves left!
strHolder = "Moves left: " + itoa(MovesLeft);
- nf_standard_blue_font.draw(topx+5, topy+5, "%s",strHolder.c_str());
+ nf_standard_blue_font.draw(screen, topx+5, topy+5, "%s",strHolder.c_str());
}
if (puzzleMode && stageButtonStatus == SBpuzzleMode) {
@@ -1260,7 +815,7 @@ public:
}
else {
strHolder = "Last puzzle";
- nf_standard_blue_font.draw(topx+5, topy+5, "%s",strHolder.c_str());
+ nf_standard_blue_font.draw(screen, topx+5, topy+5, "%s",strHolder.c_str());
}
}
if (stageClear && stageButtonStatus == SBstageClear) {
@@ -1278,7 +833,7 @@ public:
}
else {
strHolder = "Last stage";
- nf_standard_blue_font.draw(topx+5, topy+5, "%s",strHolder.c_str());
+ nf_standard_blue_font.draw(screen, topx+5, topy+5, "%s",strHolder.c_str());
}
}
@@ -1286,11 +841,11 @@ public:
if (AI_Enabled&&(!bGameOver)) {
strHolder = "AI_status: " + itoa(AIstatus)+ ", "+ itoa(AIlineToClear);
//NFont_Write( 5, 5, strHolder.c_str());
- nf_standard_blue_font.draw(topx+5, topy+5, "%s",strHolder.c_str());
+ nf_standard_blue_font.draw(screen, topx+5, topy+5, "%s",strHolder.c_str());
}
#endif
if (!bGameOver) {
- DrawImgBoard(cursor[(ticks/600)%2],cursorx*bsize-4,11*bsize-cursory*bsize-pixels-4);
+ DrawImgBoard(cursor,cursorx*bsize-4,11*bsize-cursory*bsize-pixels-4);
}
if (ticks<gameStartedAt) {
int currentCounter = abs((int)ticks-(int)gameStartedAt)/1000;
@@ -1343,7 +898,6 @@ public:
}
}
}
- nf_standard_blue_font.setDest(screen);
}
@@ -1381,15 +935,17 @@ void writeScreenShot() {
#else
string buf = "screenshot"+itoa(rightNow)+".bmp";
#endif
- SDL_SaveBMP( screen, buf.c_str() );
- if (!NoSound)
+ //SDL_SaveBMP( screen, buf.c_str() );
+ //TODO: Write screenshot
+ if (!NoSound) {
if (SoundEnabled) {
Mix_PlayChannel(1,photoClick,0);
}
+ }
}
//Function to return the name of a key, to be displayed...
-static string getKeyName(SDLKey key) {
+static string getKeyName(SDL_Keycode key) {
string keyname(SDL_GetKeyName(key));
return keyname;
}
@@ -1399,10 +955,10 @@ static string getKeyName(SDLKey key) {
bool OpenDialogbox(int x, int y, std::string& name) {
bool done = false; //We are done!
bool accept = false; //New name is accepted! (not Cancelled)
+ SDL_TextInput textInputScope;
ReadKeyboard rk = ReadKeyboard(name.c_str());
string strHolder;
DrawIMG(backgroundImage,screen,0,0);
- SDLUnicodeScope unicodeScope;
while (!done && !Config::getInstance()->isShuttingDown()) {
DrawIMG(dialogBox,screen,x,y);
NFont_Write(screen, x+40,y+76,rk.GetString());
@@ -1422,6 +978,12 @@ bool OpenDialogbox(int x, int y, std::string& name) {
accept = false;
}
+ if (event.type == SDL_TEXTINPUT) {
+ if ((rk.ReadKey(event))&&(SoundEnabled)&&(!NoSound)) {
+ Mix_PlayChannel(1,typingChunk,0);
+ }
+ }
+
if ( event.type == SDL_KEYDOWN ) {
if ( (event.key.keysym.sym == SDLK_RETURN)||(event.key.keysym.sym == SDLK_KP_ENTER) ) {
done = true;
@@ -1431,13 +993,8 @@ bool OpenDialogbox(int x, int y, std::string& name) {
done = true;
accept = false;
}
- else if (!(event.key.keysym.sym == SDLK_BACKSPACE)) {
- if ((rk.ReadKey(event.key.keysym))&&(SoundEnabled)&&(!NoSound)) {
- Mix_PlayChannel(1,typingChunk,0);
- }
- }
- else if (event.key.keysym.sym == SDLK_BACKSPACE) {
- if ((rk.ReadKey(event.key.keysym))&&(SoundEnabled)&&(!NoSound)) {
+ else {
+ if ((rk.ReadKey(event))&&(SoundEnabled)&&(!NoSound)) {
Mix_PlayChannel(1,typingChunk,0);
}
}
@@ -1445,12 +1002,11 @@ bool OpenDialogbox(int x, int y, std::string& name) {
} //while(event)
- SDL_Flip(screen); //Update screen
+ SDL_RenderPresent(screen); //Update screen
} //while(!done)
name = rk.GetString();
bScreenLocked = false;
showDialog = false;
- unicodeScope.Release();
return accept;
}
@@ -1458,10 +1014,10 @@ bool OpenDialogbox(int x, int y, std::string& name) {
void DrawHighscores(int x, int y, bool endless) {
DrawIMG(backgroundImage,screen,0,0);
if (endless) {
- nf_standard_blue_font.draw(x+100,y+100, "%s",_("Endless:") );
+ nf_standard_blue_font.draw(screen, x+100,y+100, "%s",_("Endless:") );
}
else {
- nf_standard_blue_font.draw(x+100,y+100, "%s",_("Time Trial:") );
+ nf_standard_blue_font.draw(screen, x+100,y+100, "%s",_("Time Trial:") );
}
for (int i =0; i<10; i++) {
char playerScore[32];
@@ -1478,8 +1034,8 @@ void DrawHighscores(int x, int y, bool endless) {
else {
strcpy(playerName,theTopScoresTimeTrial.getScoreName(i));
}
- nf_standard_blue_font.draw(x+420,y+150+i*35, "%s",playerScore);
- nf_standard_blue_font.draw(x+60,y+150+i*35, "%s",playerName);
+ nf_standard_blue_font.draw(screen, x+420,y+150+i*35, "%s",playerScore);
+ nf_standard_blue_font.draw(screen, x+60,y+150+i*35, "%s",playerName);
}
}
@@ -1574,9 +1130,9 @@ void OpenScoresDisplay() {
//Draw buttons:
DrawIMG(bHighScore,screen,scoreX,scoreY);
DrawIMG(bBack,screen,backX,backY);
- nf_button_font.drawCenter(backX+60,backY+10,_("Back"));
+ nf_button_font.draw(screen, backX+60,backY+10, NFont::CENTER ,_("Back"));
DrawIMG(bNext,screen,nextX,nextY);
- nf_button_font.drawCenter(nextX+60,nextY+10,_("Next"));
+ nf_button_font.draw(screen, nextX+60,nextY+10, NFont::CENTER,_("Next"));
//Draw page number
string pageXofY = (boost::format(_("Page %1% of %2%") )%(page+1)%numberOfPages).str();
@@ -1656,9 +1212,8 @@ void OpenScoresDisplay() {
}
}
- //DrawIMG(mouse,screen,mousex,mousey);
- mouse->PaintTo(screen,mousex,mousey);
- SDL_Flip(screen); //Update screen
+ mouse.Draw(screen, SDL_GetTicks(), mousex, mousey);
+ SDL_RenderPresent(screen);
}
@@ -1682,11 +1237,10 @@ bool OpenFileDialogbox(int x, int y, char* name) {
while (!done && !Config::getInstance()->isShuttingDown()) {
DrawIMG(backgroundImage,screen,0,0);
DrawIMG(bForward,screen,x+460,y+420);
- nf_button_font.drawCenter(x+20+60, y+420+10, _("Forward"));
+ nf_button_font.draw(screen, x+20+60, y+420+10, NFont::CENTER, _("Forward"));
DrawIMG(bBack,screen,x+20,y+420);
- nf_button_font.drawCenter(x+20+60, y+420+10, _("Back"));
+ nf_button_font.draw(screen, x+20+60, y+420+10, NFont::CENTER, _("Back"));
const int nrOfFiles = 10;
- DrawIMG(changeButtonsBack,screen,x,y);
for (int i=0; i<nrOfFiles; i++) {
NFont_Write(screen, x+10,y+10+36*i,lf.getFileName(i).c_str());
}
@@ -1745,9 +1299,8 @@ bool OpenFileDialogbox(int x, int y, char* name) {
}
}
- //DrawIMG(mouse,screen,mousex,mousey);
- mouse->PaintTo(screen,mousex,mousey);
- SDL_Flip(screen); //Update screen
+ mouse.Draw(screen, SDL_GetTicks(), mousex, mousey);
+ SDL_RenderPresent(screen); //Update screen
}
return true;
}
@@ -1766,8 +1319,9 @@ static void DrawBalls() {
//cout << "Printing text: " << theTextManeger.textArray[i].getText() << endl;
int x = theTextManeger.textArray[i].getX()-12;
int y = theTextManeger.textArray[i].getY()-12;
- DrawIMG(iChainBack,screen,x,y);
- nf_standard_small_font.drawCenter(x+12,y+7, "%s",theTextManeger.textArray[i].getText());
+ DrawIMG(iChainFrame,screen,x,y);
+
+ nf_standard_small_font.draw(screen, x+12,y+7, NFont::CENTER, "%s",theTextManeger.textArray[i].getText());
}
} //for
} //DrawBalls
@@ -1967,10 +1521,10 @@ void DrawEverything(int xsize, int ysize,BlockGameSdl* theGame, BlockGameSdl* th
}
//NFont_Write(screen, 800,4,FPS);
- nf_standard_blue_font.draw(800, 4, "%s", FPS);
+ nf_standard_blue_font.draw(screen, 800, 4, "%s", FPS);
#endif
- //SDL_Flip(screen); Update screen is now called outside DrawEvrything, bacause the mouse needs to be painted
+ //SDL_RenderPresent(screen); Update screen is now called outside DrawEvrything, bacause the mouse needs to be painted
}
@@ -2107,7 +1661,7 @@ int PuzzleLevelSelect(int Type) {
}
}
- SDL_GetKeyState(nullptr);
+ SDL_GetKeyboardState(nullptr);
SDL_GetMouseState(&mousex,&mousey);
if (mousex != oldmousex || mousey != oldmousey) {
@@ -2168,9 +1722,8 @@ int PuzzleLevelSelect(int Type) {
NFont_Write(screen, 200,600,totalString.c_str());
}
- //DrawIMG(mouse,screen,mousex,mousey);
- mouse->PaintTo(screen,mousex,mousey);
- SDL_Flip(screen); //draws it all to the screen
+ mouse.Draw(screen, SDL_GetTicks(), mousex, mousey);
+ SDL_RenderPresent(screen); //draws it all to the screen
}
DrawIMG(backgroundImage, screen, 0, 0);
@@ -2441,6 +1994,7 @@ int main(int argc, char* argv[]) {
cerr << "Unable to init SDL: " << SDL_GetError() << endl;
exit(1);
}
+ TTF_Init();
atexit(SDL_Quit); //quits SDL when the game stops for some reason (like you hit exit or Esc)
SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
@@ -2459,7 +2013,7 @@ int main(int argc, char* argv[]) {
NoSound = true; //Tries to stop all sound from playing/loading
}
- SDL_WM_SetCaption("Block Attack - Rise of the Blocks", nullptr); //Sets title line
+ //SDL_WM_SetCaption("Block Attack - Rise of the Blocks", nullptr); //Sets title line
if (verboseLevel) {
//Copyright notice:
@@ -2512,41 +2066,41 @@ int main(int argc, char* argv[]) {
joyplay2 = (bool)configSettings->getInt("joypad2");
if (configSettings->exists("player1keyup")) {
- keySettings[0].up = (SDLKey)configSettings->getInt("player1keyup");
+ keySettings[0].up = (SDL_Keycode)configSettings->getInt("player1keyup");
}
if (configSettings->exists("player1keydown")) {
- keySettings[0].down = (SDLKey)configSettings->getInt("player1keydown");
+ keySettings[0].down = (SDL_Keycode)configSettings->getInt("player1keydown");
}
if (configSettings->exists("player1keyleft")) {
- keySettings[0].left = (SDLKey)configSettings->getInt("player1keyleft");
+ keySettings[0].left = (SDL_Keycode)configSettings->getInt("player1keyleft");
}
if (configSettings->exists("player1keyright")) {
- keySettings[0].right = (SDLKey)configSettings->getInt("player1keyright");
+ keySettings[0].right = (SDL_Keycode)configSettings->getInt("player1keyright");
}
if (configSettings->exists("player1keychange")) {
- keySettings[0].change = (SDLKey)configSettings->getInt("player1keychange");
+ keySettings[0].change = (SDL_Keycode)configSettings->getInt("player1keychange");
}
if (configSettings->exists("player1keypush")) {
- keySettings[0].push = (SDLKey)configSettings->getInt("player1keypush");
+ keySettings[0].push = (SDL_Keycode)configSettings->getInt("player1keypush");
}
if (configSettings->exists("player2keyup")) {
- keySettings[2].up = (SDLKey)configSettings->getInt("player2keyup");
+ keySettings[2].up = (SDL_Keycode)configSettings->getInt("player2keyup");
}
if (configSettings->exists("player2keydown")) {
- keySettings[2].down = (SDLKey)configSettings->getInt("player2keydown");
+ keySettings[2].down = (SDL_Keycode)configSettings->getInt("player2keydown");
}
if (configSettings->exists("player2keyleft")) {
- keySettings[2].left = (SDLKey)configSettings->getInt("player2keyleft");
+ keySettings[2].left = (SDL_Keycode)configSettings->getInt("player2keyleft");
}
if (configSettings->exists("player2keyright")) {
- keySettings[2].right = (SDLKey)configSettings->getInt("player2keyright");
+ keySettings[2].right = (SDL_Keycode)configSettings->getInt("player2keyright");
}
if (configSettings->exists("player2keychange")) {
- keySettings[2].change = (SDLKey)configSettings->getInt("player2keychange");
+ keySettings[2].change = (SDL_Keycode)configSettings->getInt("player2keychange");
}
if (configSettings->exists("player2keypush")) {
- keySettings[2].push = (SDLKey)configSettings->getInt("player2keypush");
+ keySettings[2].push = (SDL_Keycode)configSettings->getInt("player2keypush");
}
if (configSettings->exists("player1name")) {
player1name = configSettings->getString("player1name");
@@ -2579,26 +2133,33 @@ int main(int argc, char* argv[]) {
}
+ // "Block Attack - Rise of the Blocks"
//Open video
+ int createWindowParams = 0;
if ((bFullscreen)&&(!singlePuzzle)) {
- screen=SDL_SetVideoMode(xsize,ysize,32,SDL_SWSURFACE|SDL_FULLSCREEN|SDL_ANYFORMAT);
- }
- else {
- screen=SDL_SetVideoMode(xsize,ysize,32,SDL_SWSURFACE|SDL_ANYFORMAT);
- }
-
- if ( screen == nullptr ) {
- cerr << "Unable to set " << xsize << "x" << ysize << " video: " << SDL_GetError() << endl;
- exit(1);
- }
-
+ createWindowParams |= SDL_WINDOW_FULLSCREEN_DESKTOP;
+ }
+
+ SDL_Window* sdlWindow = SDL_CreateWindow("Block Attack - Rise of the BlocksMy Game Window",
+ SDL_WINDOWPOS_UNDEFINED,
+ SDL_WINDOWPOS_UNDEFINED,
+ xsize, ysize,
+ createWindowParams );
+ dieOnNullptr(sdlWindow, "Unable to create window");
+ SDL_Renderer* renderer = SDL_CreateRenderer(sdlWindow, -1, 0);
+ dieOnNullptr(renderer, "Unable to create render");
+ screen = renderer;
//Init the file system abstraction layer
PHYSFS_init(argv[0]);
+ PHYSFS_addToSearchPath( ((string) PHYSFS_getBaseDir()+"/data").c_str(), 1);
//Load default theme
- loadTheme(Config::getInstance()->getString("themename"));
+ sago::SagoDataHolder d(renderer);
+ sago::SagoSpriteHolder spriteholder(d);
+ loadTheme(spriteholder, Config::getInstance()->getString("themename"));
+
//Now sets the icon:
- SDL_Surface* icon = IMG_Load2("gfx/icon.png");
- SDL_WM_SetIcon(icon,nullptr);
+ //SDL_Surface* icon = IMG_Load2("gfx/icon.png");
+ //SDL_WM_SetIcon(icon,nullptr);
if (verboseLevel) {
cout << "Images loaded" << endl;
@@ -2631,7 +2192,7 @@ int main(int argc, char* argv[]) {
}
DrawIMG(backgroundImage, screen, 0, 0);
DrawEverything(xsize,ysize,&theGame,&theGame2);
- SDL_Flip(screen);
+ SDL_RenderPresent(screen);
//game loop
MainMenu();
@@ -2683,10 +2244,6 @@ int main(int argc, char* argv[]) {
Config::getInstance()->save();
- //Frees memory from music and fonts
- //This is done after writing of configurations and stats since it often crashes the program :(
- UnloadImages();
-
//Close file system Apstraction layer!
PHYSFS_deinit();
return 0;
@@ -2694,7 +2251,6 @@ int main(int argc, char* argv[]) {
int runGame(int gametype, int level) {
- Uint8* keys;
int mousex, mousey; //Mouse coordinates
bScreenLocked = false;
theTopScoresEndless = Highscore(1);
@@ -2704,30 +2260,6 @@ int runGame(int gametype, int level) {
bool weWhereConnected = false;
bool bNearDeath = false; //Play music faster or louder while tru
- //Things used for repeating keystrokes:
- bool repeatingS[2] = {false,false};
- bool repeatingW[2] = {false,false};
- bool repeatingN[2] = {false,false};
- bool repeatingE[2] = {false,false};
- const int startRepeat = 200;
- const int repeatDelay = 100; //Repeating
- unsigned long timeHeldP1N = 0;
- unsigned long timeHeldP1S = 0;
- unsigned long timeHeldP1E = 0;
- unsigned long timeHeldP1W = 0;
- unsigned long timeHeldP2N = 0;
- unsigned long timeHeldP2S = 0;
- unsigned long timeHeldP2E = 0;
- unsigned long timeHeldP2W = 0;
- unsigned long timesRepeatedP1N = 0;
- unsigned long timesRepeatedP1S = 0;
- unsigned long timesRepeatedP1E = 0;
- unsigned long timesRepeatedP1W = 0;
- unsigned long timesRepeatedP2N = 0;
- unsigned long timesRepeatedP2S = 0;
- unsigned long timesRepeatedP2E = 0;
- unsigned long timesRepeatedP2W = 0;
-
theBallManeger = ballManeger();
theExplosionManeger = explosionManeger();
BlockGameSdl theGame = BlockGameSdl(50,100); //creates game objects
@@ -2758,7 +2290,7 @@ int runGame(int gametype, int level) {
bool mustsetupgame = true;
-
+
while (done == 0) {
if (mustsetupgame) {
@@ -2816,7 +2348,7 @@ int runGame(int gametype, int level) {
mustsetupgame = false;
DrawIMG(backgroundImage, screen, 0, 0);
DrawEverything(xsize,ysize,&theGame,&theGame2);
- SDL_Flip(screen);
+ SDL_RenderPresent(screen);
}
if (!(highPriority)) {
@@ -2848,27 +2380,15 @@ int runGame(int gametype, int level) {
//player1:
if ( event.key.keysym.sym == keySettings[player1keys].up ) {
theGame.MoveCursor('N');
- repeatingN[0]=true;
- timeHeldP1N=SDL_GetTicks();
- timesRepeatedP1N=0;
}
if ( event.key.keysym.sym == keySettings[player1keys].down ) {
theGame.MoveCursor('S');
- repeatingS[0]=true;
- timeHeldP1S=SDL_GetTicks();
- timesRepeatedP1S=0;
}
if ( (event.key.keysym.sym == keySettings[player1keys].left) ) {
theGame.MoveCursor('W');
- repeatingW[0]=true;
- timeHeldP1W=SDL_GetTicks();
- timesRepeatedP1W=0;
}
if ( (event.key.keysym.sym == keySettings[player1keys].right) ) {
theGame.MoveCursor('E');
- repeatingE[0]=true;
- timeHeldP1E=SDL_GetTicks();
- timesRepeatedP1E=0;
}
if ( event.key.keysym.sym == keySettings[player1keys].push ) {
theGame.PushLine();
@@ -2881,27 +2401,15 @@ int runGame(int gametype, int level) {
//player2:
if ( event.key.keysym.sym == keySettings[player2keys].up ) {
theGame2.MoveCursor('N');
- repeatingN[1]=true;
- timeHeldP2N=SDL_GetTicks();
- timesRepeatedP2N=0;
}
if ( event.key.keysym.sym == keySettings[player2keys].down ) {
theGame2.MoveCursor('S');
- repeatingS[1]=true;
- timeHeldP2S=SDL_GetTicks();
- timesRepeatedP2S=0;
}
if ( (event.key.keysym.sym == keySettings[player2keys].left) ) {
theGame2.MoveCursor('W');
- repeatingW[1]=true;
- timeHeldP2W=SDL_GetTicks();
- timesRepeatedP2W=0;
}
if ( (event.key.keysym.sym == keySettings[player2keys].right) ) {
theGame2.MoveCursor('E');
- repeatingE[1]=true;
- timeHeldP2E=SDL_GetTicks();
- timesRepeatedP2E=0;
}
if ( event.key.keysym.sym == keySettings[player2keys].push ) {
theGame2.PushLine();
@@ -2941,88 +2449,6 @@ int runGame(int gametype, int level) {
} //while event PollEvent - read keys
/**********************************************************************
- **************************** Repeating start **************************
- **********************************************************************/
-
- keys = SDL_GetKeyState(nullptr);
-//Also the joysticks:
-//Repeating not implemented
-
-//Player 1 start
- if (!(keys[keySettings[player1keys].up])) {
- repeatingN[0]=false;
- }
- while ((repeatingN[0])&&(keys[keySettings[player1keys].up])&&(SDL_GetTicks()>timeHeldP1N+timesRepeatedP1N*repeatDelay+startRepeat)) {
- theGame.MoveCursor('N');
- timesRepeatedP1N++;
- }
-
- if (!(keys[keySettings[player1keys].down])) {
- repeatingS[0]=false;
- }
- while ((repeatingS[0])&&(keys[keySettings[player1keys].down])&&(SDL_GetTicks()>timeHeldP1S+timesRepeatedP1S*repeatDelay+startRepeat)) {
- theGame.MoveCursor('S');
- timesRepeatedP1S++;
- }
-
- if (!(keys[keySettings[player1keys].left])) {
- repeatingW[0]=false;
- }
- while ((repeatingW[0])&&(keys[keySettings[player1keys].left])&&(SDL_GetTicks()>timeHeldP1W+timesRepeatedP1W*repeatDelay+startRepeat)) {
- timesRepeatedP1W++;
- theGame.MoveCursor('W');
- }
-
- if (!(keys[keySettings[player1keys].right])) {
- repeatingE[0]=false;
- }
- while ((repeatingE[0])&&(keys[keySettings[player1keys].right])&&(SDL_GetTicks()>timeHeldP1E+timesRepeatedP1E*repeatDelay+startRepeat)) {
- timesRepeatedP1E++;
- theGame.MoveCursor('E');
- }
-
-//Player 1 end
-
-//Player 2 start
- if (!(keys[keySettings[player2keys].up])) {
- repeatingN[1]=false;
- }
- while ((repeatingN[1])&&(keys[keySettings[player2keys].up])&&(SDL_GetTicks()>timeHeldP2N+timesRepeatedP2N*repeatDelay+startRepeat)) {
- theGame2.MoveCursor('N');
- timesRepeatedP2N++;
- }
-
- if (!(keys[keySettings[player2keys].down])) {
- repeatingS[1]=false;
- }
- while ((repeatingS[1])&&(keys[keySettings[player2keys].down])&&(SDL_GetTicks()>timeHeldP2S+timesRepeatedP2S*repeatDelay+startRepeat)) {
- theGame2.MoveCursor('S');
- timesRepeatedP2S++;
- }
-
- if (!(keys[keySettings[player2keys].left])) {
- repeatingW[1]=false;
- }
- while ((repeatingW[1])&&(keys[keySettings[player2keys].left])&&(SDL_GetTicks()>timeHeldP2W+timesRepeatedP2W*repeatDelay+startRepeat)) {
- theGame2.MoveCursor('W');
- timesRepeatedP2W++;
- }
-
- if (!(keys[keySettings[player2keys].right])) {
- repeatingE[1]=false;
- }
- while ((repeatingE[1])&&(keys[keySettings[player2keys].right])&&(SDL_GetTicks()>timeHeldP2E+timesRepeatedP2E*repeatDelay+startRepeat)) {
- theGame2.MoveCursor('E');
- timesRepeatedP2E++;
- }
-
-//Player 2 end
-
- /**********************************************************************
- **************************** Repeating end ****************************
- **********************************************************************/
-
- /**********************************************************************
***************************** Joypad start ****************************
**********************************************************************/
@@ -3033,27 +2459,15 @@ int runGame(int gametype, int level) {
joypad1.update();
if (joypad1.up) {
theGame.MoveCursor('N');
- repeatingN[0]=true;
- timeHeldP1N=SDL_GetTicks();
- timesRepeatedP1N=0;
}
if (joypad1.down) {
theGame.MoveCursor('S');
- repeatingS[0]=true;
- timeHeldP1S=SDL_GetTicks();
- timesRepeatedP1S=0;
}
if (joypad1.left) {
theGame.MoveCursor('W');
- repeatingW[0]=true;
- timeHeldP1W=SDL_GetTicks();
- timesRepeatedP1W=0;
}
if (joypad1.right) {
theGame.MoveCursor('E');
- repeatingE[0]=true;
- timeHeldP1E=SDL_GetTicks();
- timesRepeatedP1E=0;
}
if (joypad1.but1) {
theGame.SwitchAtCursor();
@@ -3066,27 +2480,15 @@ int runGame(int gametype, int level) {
joypad1.update();
if (joypad1.up) {
theGame2.MoveCursor('N');
- repeatingN[1]=true;
- timeHeldP2N=SDL_GetTicks();
- timesRepeatedP2N=0;
}
if (joypad1.down) {
theGame2.MoveCursor('S');
- repeatingS[1]=true;
- timeHeldP2S=SDL_GetTicks();
- timesRepeatedP2S=0;
}
if (joypad1.left) {
theGame2.MoveCursor('W');
- repeatingW[1]=true;
- timeHeldP2W=SDL_GetTicks();
- timesRepeatedP2W=0;
}
if (joypad1.right) {
theGame2.MoveCursor('E');
- repeatingE[1]=true;
- timeHeldP2E=SDL_GetTicks();
- timesRepeatedP2E=0;
}
if (joypad1.but1) {
theGame2.SwitchAtCursor();
@@ -3101,27 +2503,15 @@ int runGame(int gametype, int level) {
joypad2.update();
if (joypad2.up) {
theGame.MoveCursor('N');
- repeatingN[0]=true;
- timeHeldP1N=SDL_GetTicks();
- timesRepeatedP1N=0;
}
if (joypad2.down) {
theGame.MoveCursor('S');
- repeatingS[0]=true;
- timeHeldP1S=SDL_GetTicks();
- timesRepeatedP1S=0;
}
if (joypad2.left) {
theGame.MoveCursor('W');
- repeatingW[0]=true;
- timeHeldP1W=SDL_GetTicks();
- timesRepeatedP1W=0;
}
if (joypad2.right) {
theGame.MoveCursor('E');
- repeatingE[0]=true;
- timeHeldP1E=SDL_GetTicks();
- timesRepeatedP1E=0;
}
if (joypad2.but1) {
theGame.SwitchAtCursor();
@@ -3134,27 +2524,15 @@ int runGame(int gametype, int level) {
joypad2.update();
if (joypad2.up) {
theGame2.MoveCursor('N');
- repeatingN[1]=true;
- timeHeldP2N=SDL_GetTicks();
- timesRepeatedP2N=0;
}
if (joypad2.down) {
theGame2.MoveCursor('S');
- repeatingS[1]=true;
- timeHeldP2S=SDL_GetTicks();
- timesRepeatedP2S=0;
}
if (joypad2.left) {
theGame2.MoveCursor('W');
- repeatingW[1]=true;
- timeHeldP2W=SDL_GetTicks();
- timesRepeatedP2W=0;
}
if (joypad2.right) {
theGame2.MoveCursor('E');
- repeatingE[1]=true;
- timeHeldP2E=SDL_GetTicks();
- timesRepeatedP2E=0;
}
if (joypad2.but1) {
theGame2.SwitchAtCursor();
@@ -3170,9 +2548,6 @@ int runGame(int gametype, int level) {
***************************** Joypad end ******************************
**********************************************************************/
-
- SDL_GetKeyState(nullptr);
-
SDL_GetMouseState(&mousex,&mousey);
/********************************************************************
@@ -3372,7 +2747,7 @@ int runGame(int gametype, int level) {
//twoPlayers = false;
}
}
-
+
if (theGame.isGameOver() && registerTTHighscorePlayer1) {
registerTTHighscorePlayer1 = false;
theTopScoresTimeTrial.addScore(theGame.name, theGame.GetScore());
@@ -3394,8 +2769,8 @@ int runGame(int gametype, int level) {
oldMousex = mousex;
oldMousey = mousey;
//Draw the mouse:
- mouse->PaintTo(screen,mousex,mousey);
- SDL_Flip(screen);
+ mouse.Draw(screen, SDL_GetTicks(), mousex, mousey);
+ SDL_RenderPresent(screen);
} //game loop
return 0;
}
diff --git a/source/code/mainVars.hpp b/source/code/mainVars.hpp index b618eea..9e28c16 100644 --- a/source/code/mainVars.hpp +++ b/source/code/mainVars.hpp
@@ -25,6 +25,9 @@ http://blockattack.sf.net
#ifndef _MAINVARS_HPP
#define _MAINVARS_HPP
+#include "sago/SagoSprite.hpp"
+
+
//main variables and constants
@@ -33,93 +36,87 @@ http://blockattack.sf.net
#define BOMBTIME 200
#define CURSORTIME 200
+#ifndef SHAREDIR
+#define SHAREDIR "."
+#endif
+
const char sharedir[] = SHAREDIR;
//All graphic in the game (as pointers):
-SDL_Surface *backgroundImage; //Stores the background image
-static SDL_Surface *backBoard; //Stores the background to the board
-static std::shared_ptr<CppSdl::CppSdlImageHolder> bNewGame; //The New Game botton
-static SDL_Surface *bOptions; //The Options botton
-static SDL_Surface *bConfigure; //The configure button
-static SDL_Surface *bSelectPuzzle; //The Select Puzzle Button
-static SDL_Surface *bBack; //The "Back" button
-static SDL_Surface *bForward; //The "forward" button
-static SDL_Surface *iChainBack;
+sago::SagoSprite backgroundImage; //Stores the background image
+static sago::SagoSprite backBoard; //Stores the background to the board
+static sago::SagoSprite bBack; //The "Back" button
+static sago::SagoSprite bForward; //The "forward" button
#if NETWORK
-//static SDL_Surface *bNetwork;
-//static SDL_Surface *bConnect;
-//static SDL_Surface *bHost;
+//static sago::SagoSprite bNetwork;
+//static sago::SagoSprite bConnect;
+//static sago::SagoSprite bHost;
#endif
-static SDL_Surface *bHighScore; //The High Score botton
-static SDL_Surface *blackLine; //The seperator in stage clear
-static SDL_Surface *stageBobble; //The bobble instage clear
-SDL_Surface *screen; //The whole screen;
-static SDL_Surface *iGameOver; //The gameOver image
-static SDL_Surface *iWinner; //the "winner" image
-static SDL_Surface *iDraw; //the "draw" image
-static SDL_Surface *iLoser; //the "loser" image
+static sago::SagoSprite bHighScore; //The High Score botton
+static sago::SagoSprite blackLine; //The seperator in stage clear
+static sago::SagoSprite stageBobble; //The bobble instage clear
+SDL_Renderer *screen; //The whole screen;
+static sago::SagoSprite iGameOver; //The gameOver image
+static sago::SagoSprite iWinner; //the "winner" image
+static sago::SagoSprite iDraw; //the "draw" image
+static sago::SagoSprite iLoser; //the "loser" image
+static sago::SagoSprite iChainFrame;
//Animations:
-static SDL_Surface *cursor[2]; //The animated cursor
-static SDL_Surface *bomb[2]; //Bomb then the bricks should blow
-static SDL_Surface *ready[2]; //Before the blocks fall
-static SDL_Surface *explosion[4]; //Then a block explodes
+static sago::SagoSprite cursor; //The animated cursor
+static sago::SagoSprite bomb;
+static sago::SagoSprite ready; //Before the blocks fall
+static sago::SagoSprite explosion[4]; //Then a block explodes
//Animations end
-static SDL_Surface *counter[3]; //Counts down from 3
-static SDL_Surface *bricks[7]; //The bricks, saved in an array of pointers
-static SDL_Surface *crossover; //Cross the bricks that will be cleared soon
-static SDL_Surface *balls[7]; //The balls (the small ones that jump around)
-static SDL_Surface *changeButtonsBack;
-static SDL_Surface *dialogBox;
-static SDL_Surface *bOn;
-static SDL_Surface *bOff;
-static SDL_Surface *b1024;
-static SDL_Surface *iLevelCheck; //To the level select screen
-static SDL_Surface *iLevelCheckBox;
-static SDL_Surface *iLevelCheckBoxMarked;
-static SDL_Surface *iCheckBoxArea;
-static SDL_Surface *boardBackBack;
-static SDL_Surface *garbageTL; //the Garbage Blocks
-static SDL_Surface *garbageT;
-static SDL_Surface *garbageTR;
-static SDL_Surface *garbageR;
-static SDL_Surface *garbageBR;
-static SDL_Surface *garbageB;
-static SDL_Surface *garbageBL;
-static SDL_Surface *garbageL;
-static SDL_Surface *garbageFill;
-static SDL_Surface *garbageM;
-static SDL_Surface *garbageML;
-static SDL_Surface *garbageMR;
-static SDL_Surface *smiley[4];
-static SDL_Surface *garbageGM;
-static SDL_Surface *garbageGML;
-static SDL_Surface *garbageGMR;
-static SDL_Surface *transCover; //The transperant block, covers the upcomming
+static sago::SagoSprite counter[3]; //Counts down from 3
+static sago::SagoSprite bricks[7]; //The bricks, saved in an array of pointers
+static sago::SagoSprite crossover; //Cross the bricks that will be cleared soon
+static sago::SagoSprite balls[7]; //The balls (the small ones that jump around)
+static sago::SagoSprite dialogBox;
+static sago::SagoSprite iLevelCheck; //To the level select screen
+static sago::SagoSprite iLevelCheckBox;
+static sago::SagoSprite iLevelCheckBoxMarked;
+static sago::SagoSprite iCheckBoxArea;
+static sago::SagoSprite boardBackBack;
+static sago::SagoSprite garbageTL; //the Garbage Blocks
+static sago::SagoSprite garbageT;
+static sago::SagoSprite garbageTR;
+static sago::SagoSprite garbageR;
+static sago::SagoSprite garbageBR;
+static sago::SagoSprite garbageB;
+static sago::SagoSprite garbageBL;
+static sago::SagoSprite garbageL;
+static sago::SagoSprite garbageFill;
+static sago::SagoSprite garbageM;
+static sago::SagoSprite garbageML;
+static sago::SagoSprite garbageMR;
+static sago::SagoSprite smiley[4];
+static sago::SagoSprite garbageGM;
+static sago::SagoSprite garbageGML;
+static sago::SagoSprite garbageGMR;
+static sago::SagoSprite transCover; //The transperant block, covers the upcomming
#if LEVELEDITOR
-static SDL_Surface *bCreateFile;
-static SDL_Surface *bDeletePuzzle;
-static SDL_Surface *bLoadFile;
-static SDL_Surface *bMoveBack;
-static SDL_Surface *bMoveDown;
-static SDL_Surface *bMoveForward;
-static SDL_Surface *bMoveLeft;
-static SDL_Surface *bMoveRight;
-static SDL_Surface *bMoveUp;
-static SDL_Surface *bNewPuzzle;
-static SDL_Surface *bSaveFileAs;
-static SDL_Surface *bSavePuzzle;
-static SDL_Surface *bSaveToFile;
-static SDL_Surface *bTestPuzzle;
+static sago::SagoSprite bCreateFile;
+static sago::SagoSprite bDeletePuzzle;
+static sago::SagoSprite bLoadFile;
+static sago::SagoSprite bMoveBack;
+static sago::SagoSprite bMoveDown;
+static sago::SagoSprite bMoveForward;
+static sago::SagoSprite bMoveLeft;
+static sago::SagoSprite bMoveRight;
+static sago::SagoSprite bMoveUp;
+static sago::SagoSprite bNewPuzzle;
+static sago::SagoSprite bSaveFileAs;
+static sago::SagoSprite bSavePuzzle;
+static sago::SagoSprite bSaveToFile;
+static sago::SagoSprite bTestPuzzle;
#endif
-static SDL_Surface *bSkip;
-static SDL_Surface *bRetry;
-static SDL_Surface *bNext;
-
-std::shared_ptr<CppSdl::CppSdlImageHolder> menuMarked;
-std::shared_ptr<CppSdl::CppSdlImageHolder> menuUnmarked;
-std::shared_ptr<CppSdl::CppSdlImageHolder> mouse;
+static sago::SagoSprite bSkip;
+static sago::SagoSprite bRetry;
+static sago::SagoSprite bNext;
-static SDL_Surface *tmp; //a temporary surface to use DisplayFormat
+sago::SagoSprite menuMarked;
+sago::SagoSprite menuUnmarked;
+sago::SagoSprite mouse;
static NFont nf_button_font; //Font used for buttons!
NFont nf_scoreboard_font;
@@ -153,7 +150,6 @@ static bool bNearDeathPrev; //Near death status last time che
bool bFullscreen; //true if game is running fullscreen
static bool puzzleLoaded; //true if the puzzle levels have been loaded
static bool drawBalls; //if true balls are drawed to the screen, this might lower framerate too much
-static bool standardBackground;
bool highPriority;
static bool editorMode = false;
@@ -213,9 +209,6 @@ static int oldMousex, oldMousey;
//Old Stage Clear Buble
static int oldBubleX, oldBubleY;
-//bool doublebuf = false; //if true, screen is double buffered
-static char forceredraw = 1; //If 1: always redraw, if 2: rarely redraw
-
static bool singlePuzzle = false; //if true we are just in a little 300x600 window
static int singlePuzzleNr = 0;
static std::string singlePuzzleFile;
@@ -238,12 +231,12 @@ bool joyplay2=false; //Player two uses the joypad
//Stores the controls
struct control
{
- SDLKey up;
- SDLKey down;
- SDLKey left;
- SDLKey right;
- SDLKey change;
- SDLKey push;
+ SDL_Keycode up;
+ SDL_Keycode down;
+ SDL_Keycode left;
+ SDL_Keycode right;
+ SDL_Keycode change;
+ SDL_Keycode push;
};
control keySettings[3]; //array to hold the controls (default and two custom)
diff --git a/source/code/menudef.cpp b/source/code/menudef.cpp index 36d33cc..f5e4b22 100644 --- a/source/code/menudef.cpp +++ b/source/code/menudef.cpp
@@ -36,12 +36,12 @@ static void PrintHi(Button* b) {
//Stores the controls
struct control {
- SDLKey up;
- SDLKey down;
- SDLKey left;
- SDLKey right;
- SDLKey change;
- SDLKey push;
+ SDL_Keycode up;
+ SDL_Keycode down;
+ SDL_Keycode left;
+ SDL_Keycode right;
+ SDL_Keycode change;
+ SDL_Keycode push;
};
bool OpenDialogbox(int x, int y, std::string& name);
@@ -49,7 +49,7 @@ void OpenScoresDisplay();
extern control keySettings[3];
//Function to return the name of a key, to be displayed...
-static string getKeyName(SDLKey key) {
+static string getKeyName(SDL_Keycode key) {
string keyname(SDL_GetKeyName(key));
if (verboseLevel) {
cout << key << " translated to " << keyname << endl;
@@ -59,15 +59,15 @@ static string getKeyName(SDLKey key) {
class Button_changekey : public Button {
private:
- SDLKey* m_key2change;
+ SDL_Keycode* m_key2change;
string m_keyname;
public:
- Button_changekey(SDLKey* key, string keyname);
+ Button_changekey(SDL_Keycode* key, string keyname);
void doAction();
};
-Button_changekey::Button_changekey(SDLKey* key, string keyname) {
+Button_changekey::Button_changekey(SDL_Keycode* key, string keyname) {
m_key2change = key;
m_keyname = keyname;
setLabel(m_keyname+" : "+getKeyName(*m_key2change));
@@ -93,7 +93,7 @@ void Button_changekey::doAction() {
void InitMenues() {
standardButton.setSurfaces(menuMarked,menuUnmarked);
- standardButton.thefont = nf_scoreboard_font;
+ standardButton.thefont = &nf_scoreboard_font;
}
void runGame(int gametype,int level);
diff --git a/source/code/sago/LICENSE b/source/code/sago/LICENSE new file mode 100644 index 0000000..fe6d772 --- /dev/null +++ b/source/code/sago/LICENSE
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 Poul Sander
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
diff --git a/source/code/sago/Makefile.sago b/source/code/sago/Makefile.sago new file mode 100644 index 0000000..5e4f0d4 --- /dev/null +++ b/source/code/sago/Makefile.sago
@@ -0,0 +1,4 @@
+
+
+SAGO_BASE_LIBS+= -lphysfs -ljsoncpp
+SAGO_O_FILES+= sago/SagoDataHolder.o sago/SagoSprite.o sago/SagoSpriteHolder.o sago/SagoMisc.o
\ No newline at end of file
diff --git a/source/code/sago/SagoDataHolder.cpp b/source/code/sago/SagoDataHolder.cpp new file mode 100644 index 0000000..e049df2 --- /dev/null +++ b/source/code/sago/SagoDataHolder.cpp
@@ -0,0 +1,239 @@
+/*
+ Copyright (c) 2015 Poul Sander
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+*/
+
+#include "SagoDataHolder.hpp"
+#include <iostream>
+#include <mutex>
+#include <map>
+#include <vector>
+#include <physfs.h>
+#include <memory>
+#include <SDL/SDL_mixer.h>
+
+namespace sago {
+
+struct SagoDataHolder::SagoDataHolderData {
+ std::map<std::string, SDL_Texture*> textures;
+ std::map<std::string, std::map<int, TTF_Font*> > fonts; //font, ptsize
+ std::map<std::string, Mix_Music*> music;
+ std::map<std::string, Mix_Chunk*> sounds;
+ std::vector<SDL_RWops*> rwOpsToFree;
+ std::vector<std::unique_ptr<char[]>> dataToFree;
+ SDL_Renderer* renderer = nullptr;
+};
+
+namespace {
+std::mutex mutex_texture_load;
+} //anonymous namespace
+
+SagoDataHolder::SagoDataHolder(SDL_Renderer* renderer) {
+ data = new SagoDataHolderData();
+ data->renderer = renderer;
+}
+
+SagoDataHolder::~SagoDataHolder() {
+ for (auto& item : data->textures) {
+ SDL_DestroyTexture(item.second);
+ }
+ for (auto& item : data->music) {
+ Mix_FreeMusic(item.second);
+ }
+ for (auto& item : data->sounds) {
+ Mix_FreeChunk(item.second);
+ }
+ for (auto& item : data->fonts) {
+ for (auto& item2 : item.second) {
+ TTF_CloseFont(item2.second);
+ }
+ }
+ for (auto& item : data->rwOpsToFree) {
+ SDL_FreeRW(item);
+ }
+ delete data;
+}
+
+SDL_Texture* SagoDataHolder::getTexturePtr(const std::string& textureName) const {
+ std::lock_guard<std::mutex> guard(mutex_texture_load);
+ SDL_Texture* ret = data->textures[textureName];
+ if (ret) {
+ return ret;
+ }
+ std::string path = "textures/"+textureName+".png";
+ if (!PHYSFS_exists(path.c_str())) {
+ std::cerr << "getTextureFailed - Texture does not exists: " << path << std::endl;
+ exit(1);
+ return ret;
+ }
+ PHYSFS_file* myfile = PHYSFS_openRead(path.c_str());
+ unsigned int m_size = PHYSFS_fileLength(myfile);
+ //char* m_data = new char[m_size];
+ std::unique_ptr<char[]> m_data(new char[m_size]);
+ int length_read = PHYSFS_read (myfile, m_data.get(), 1, m_size);
+ if (length_read != (int)m_size) {
+ PHYSFS_close(myfile);
+ std::cerr << "Error: Curropt data file: " << path << std::endl;
+ return ret;
+ }
+ PHYSFS_close(myfile);
+ SDL_RWops* rw = SDL_RWFromMem (m_data.get(), m_size);
+ //The above might fail an return null.
+ if (!rw) {
+ PHYSFS_close(myfile);
+ std::cerr << "Error. Curropt data file!" << std::endl;
+ return NULL;
+ }
+ SDL_Surface* surface = IMG_Load_RW(rw,true);
+
+ ret = SDL_CreateTextureFromSurface(data->renderer, surface);
+
+ if (!ret) {
+ std::cerr << "getTextureFailed to load " << path << std::endl;
+ }
+ SDL_FreeSurface(surface);
+ std::cerr << path << " loaded" << std::endl;
+ data->textures[textureName] = ret;
+ return ret;
+}
+
+TTF_Font* SagoDataHolder::getFontPtr(const std::string& fontName, int ptsize) const {
+ std::lock_guard<std::mutex> guard(mutex_texture_load);
+ TTF_Font* ret = data->fonts[fontName][ptsize];
+ if (ret) {
+ return ret;
+ }
+ std::string path = "fonts/"+fontName+".ttf";
+ if (!PHYSFS_exists(path.c_str())) {
+ std::cerr << "getFontPtr - Font does not exists: " << path << std::endl;
+ return ret;
+ }
+ PHYSFS_file* myfile = PHYSFS_openRead(path.c_str());
+ unsigned int m_size = PHYSFS_fileLength(myfile);
+ std::unique_ptr<char[]> m_data(new char[m_size]);
+ int length_read = PHYSFS_read (myfile, m_data.get(), 1, m_size);
+ if (length_read != (int)m_size) {
+ PHYSFS_close(myfile);
+ std::cerr << "Error: Curropt data file: " << path << std::endl;
+ return ret;
+ }
+ PHYSFS_close(myfile);
+
+ SDL_RWops* rw = SDL_RWFromMem (m_data.get(), m_size);
+
+ //The above might fail an return null.
+ if (!rw) {
+ PHYSFS_close(myfile);
+ std::cerr << "Error: Curropt data file!" << std::endl;
+ return ret;
+ }
+
+ ret = TTF_OpenFontRW(rw, SDL_FALSE, ptsize);
+ //delete [] m_data;
+ if (!ret) {
+ std::cerr << "Error openening font: " << fontName << " because: " << TTF_GetError() << std::endl;
+ }
+ data->fonts[fontName][ptsize] = ret;
+ data->dataToFree.push_back(std::move(m_data));
+ data->rwOpsToFree.push_back(rw);
+ return ret;
+}
+
+Mix_Music* SagoDataHolder::getMusicPtr(const std::string& musicName) const {
+ std::lock_guard<std::mutex> guard(mutex_texture_load);
+ Mix_Music* ret = data->music[musicName];
+ if (ret) {
+ return ret;
+ }
+ std::string path = "music/"+musicName+".ogg";
+ if (!PHYSFS_exists(path.c_str())) {
+ std::cerr << "getMusicPtr - Music file does not exists: " << path << std::endl;
+ return ret;
+ }
+ PHYSFS_file* myfile = PHYSFS_openRead(path.c_str());
+ unsigned int m_size = PHYSFS_fileLength(myfile);
+ std::unique_ptr<char[]> m_data(new char[m_size]);
+ int length_read = PHYSFS_read (myfile, m_data.get(), 1, m_size);
+ if (length_read != (int)m_size) {
+ PHYSFS_close(myfile);
+ std::cerr << "Error: Curropt data file: " << path << std::endl;
+ return ret;
+ }
+ PHYSFS_close(myfile);
+ SDL_RWops* rw = SDL_RWFromMem (m_data.get(), m_size);
+
+ //The above might fail an return null.
+ if (!rw) {
+ PHYSFS_close(myfile);
+ std::cerr << "Error. Curropt data file!" << std::endl;
+ return NULL;
+ }
+
+ ret = Mix_LoadMUS_RW(rw, SDL_TRUE); //SDL_TRUE causes rw to be freed
+
+ if (!ret) {
+ std::cerr << "getMusicPtr to load " << path << " because: " << Mix_GetError() << std::endl;
+ }
+ std::cout << path << " loaded" << std::endl;
+ data->music[musicName] = ret;
+ return ret;
+}
+
+
+Mix_Chunk* SagoDataHolder::getSoundPtr(const std::string& soundName) const {
+ std::lock_guard<std::mutex> guard(mutex_texture_load);
+ Mix_Chunk* ret = data->sounds[soundName];
+ if (ret) {
+ return ret;
+ }
+ std::string path = "sounds/"+soundName+".ogg";
+ if (!PHYSFS_exists(path.c_str())) {
+ std::cerr << "getSoundPtr - Sound file does not exists: " << path << std::endl;
+ return ret;
+ }
+ PHYSFS_file* myfile = PHYSFS_openRead(path.c_str());
+ unsigned int m_size = PHYSFS_fileLength(myfile);
+ std::unique_ptr<char[]> m_data(new char[m_size]);
+ int length_read = PHYSFS_read (myfile, m_data.get(), 1, m_size);
+ if (length_read != (int)m_size) {
+ PHYSFS_close(myfile);
+ std::cerr << "Error: Curropt data file: " << path << std::endl;
+ return ret;
+ }
+ PHYSFS_close(myfile);
+ SDL_RWops* rw = SDL_RWFromMem (m_data.get(), m_size);
+
+ //The above might fail an return null.
+ if (!rw) {
+ PHYSFS_close(myfile);
+ std::cerr << "Error. Curropt data file!" << std::endl;
+ return NULL;
+ }
+
+ ret = Mix_LoadWAV_RW(rw, SDL_TRUE);
+
+ std::cout << path << " loaded" << std::endl;
+ data->sounds[soundName] = ret;
+ return ret;
+}
+
+} //name space sago
diff --git a/source/code/sago/SagoDataHolder.hpp b/source/code/sago/SagoDataHolder.hpp new file mode 100644 index 0000000..10fb36f --- /dev/null +++ b/source/code/sago/SagoDataHolder.hpp
@@ -0,0 +1,60 @@
+/*
+ Copyright (c) 2015 Poul Sander
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+*/
+
+#include "SDL.h"
+#include <SDL_mixer.h> //Used for sound & music
+#include <SDL_image.h> //To load PNG images!
+#include <SDL_ttf.h>
+#include <physfs.h> //Abstract file system. To use containers
+#include <string>
+
+#ifndef TEXTUREHOLDER_HPP
+#define TEXTUREHOLDER_HPP
+
+namespace sago {
+
+class SagoDataHolder {
+public:
+ SagoDataHolder(SDL_Renderer* renderer);
+ /**
+ * Return a pointer to the given texture. The pointer is valid for the lifetime of SagoDataHolder object it was taken from.
+ * @param textureName Name of the texture
+ * @return Pointer to the loaded texture
+ */
+ SDL_Texture* getTexturePtr(const std::string &textureName) const;
+ TTF_Font* getFontPtr(const std::string &fontName, int ptsize) const;
+ Mix_Music* getMusicPtr(const std::string &musicName) const;
+ Mix_Chunk* getSoundPtr(const std::string &soundName) const;
+ virtual ~SagoDataHolder();
+private:
+ SagoDataHolder(const SagoDataHolder& base) = delete;
+ SagoDataHolder& operator=(const SagoDataHolder& base) = delete;
+ struct SagoDataHolderData;
+ mutable SagoDataHolderData *data;
+};
+
+} //namespace sago
+
+#endif /* TEXTUREHOLDER_HPP */
+
diff --git a/source/code/sago/SagoMisc.cpp b/source/code/sago/SagoMisc.cpp new file mode 100644 index 0000000..cb7ae43 --- /dev/null +++ b/source/code/sago/SagoMisc.cpp
@@ -0,0 +1,85 @@
+/*
+ Copyright (c) 2015 Poul Sander
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+*/
+
+#include "SagoMisc.hpp"
+#include <physfs.h>
+#include <iostream>
+#include <iconv.h>
+#include <string.h>
+#include <memory>
+
+using namespace std;
+
+namespace sago {
+
+
+std::vector<std::string> GetFileList(const char* dir) {
+ std::vector<std::string> ret;
+ char** rc = PHYSFS_enumerateFiles(dir);
+ for (char** i = rc; *i != NULL; i++) {
+ ret.push_back(*i);
+ }
+ PHYSFS_freeList(rc);
+ return ret;
+}
+
+bool FileExists(const char* filename) {
+ return PHYSFS_exists(filename);
+}
+
+std::string GetFileContent(const char* filename) {
+ std::string ret;
+ if (!PHYSFS_exists(filename)) {
+ std::cerr << "GetFileContent - File does not exists: " << filename << std::endl;
+ return ret;
+ }
+ PHYSFS_file* myfile = PHYSFS_openRead(filename);
+ unsigned int m_size = PHYSFS_fileLength(myfile);
+ char* m_data = new char[m_size+1];
+ int length_read = PHYSFS_read (myfile, m_data, 1, m_size);
+ if (length_read != (int)m_size) {
+ delete [] m_data;
+ m_data = nullptr;
+ PHYSFS_close(myfile);
+ std::cerr << "Error: Curropt data file: " << filename << std::endl;
+ return ret;
+ }
+ PHYSFS_close(myfile);
+ m_data[m_size] = 0; //ensure that we are 0 terminated
+ ret = m_data;
+ delete [] m_data;
+ return ret;
+}
+
+void WriteFileContent(const char* filename, const std::string& content) {
+ PHYSFS_file* myfile = PHYSFS_openWrite(filename);
+ if (!myfile) {
+ cerr << "Failed to open file for writing, " << PHYSFS_getLastError() << endl;
+ return;
+ }
+ PHYSFS_write(myfile, content.c_str(), 1, content.length()+1);
+ PHYSFS_close(myfile);
+}
+
+}
diff --git a/source/code/sago/SagoMisc.hpp b/source/code/sago/SagoMisc.hpp new file mode 100644 index 0000000..3a8bf62 --- /dev/null +++ b/source/code/sago/SagoMisc.hpp
@@ -0,0 +1,56 @@
+/*
+ Copyright (c) 2015 Poul Sander
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+*/
+
+#ifndef SAGOMISC_HPP
+#define SAGOMISC_HPP
+
+#include <vector>
+#include <string>
+
+namespace sago {
+
+ /**
+ * Returns a vector with all filenames in a given directory.
+ * PHYSFS must be setup before hand. The directory is relative to the PHYSFS base
+ * @param dir The directory to list
+ * @return A vector with the filenames in the given directory. If empty the directory was empty or did not exist
+ */
+ std::vector<std::string> GetFileList(const char* dir);
+
+ /**
+ * Reads an entire file into memory.
+ * PHYSFS must be setup before hand
+ * @param filename The file to read
+ * @return The content of the file. If empty either the file was empty, did not exist or could not be opened
+ */
+ std::string GetFileContent(const char* filename);
+
+ bool FileExists(const char* filename);
+
+ void WriteFileContent(const char* filename, const std::string& content);
+
+} //namespace sago
+
+#endif /* SAGOMISC_HPP */
+
diff --git a/source/code/sago/SagoSprite.cpp b/source/code/sago/SagoSprite.cpp new file mode 100644 index 0000000..d1da53e --- /dev/null +++ b/source/code/sago/SagoSprite.cpp
@@ -0,0 +1,145 @@
+/*
+ Copyright (c) 2015 Poul Sander
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+*/
+
+#include "SagoSprite.hpp"
+#include <iostream>
+
+namespace sago {
+
+struct SagoSprite::SagoSpriteData {
+ SDL_Texture* tex = nullptr;
+ SDL_Rect imgCord;
+ SDL_Rect origin = {};
+ int aniFrames = 0;
+ int aniFrameTime = 0;
+};
+
+SagoSprite::SagoSprite() {
+ data = new SagoSpriteData();
+}
+
+SagoSprite::SagoSprite(const SagoDataHolder& texHolder, const std::string& texture,const SDL_Rect& initImage,const int animationFrames, const int animationFrameLength) {
+ data = new SagoSpriteData();
+ data->tex = texHolder.getTexturePtr(texture);
+ data->imgCord = initImage;
+ data->aniFrames = animationFrames;
+ data->aniFrameTime = animationFrameLength;
+}
+
+SagoSprite::SagoSprite(const SagoSprite& base) : data(new SagoSpriteData(*base.data)) {
+
+}
+
+SagoSprite& SagoSprite::operator=(const SagoSprite& base) {
+ *data = *base.data;
+ return *this;
+}
+
+SagoSprite::~SagoSprite() {
+ delete data;
+}
+
+void SagoSprite::Draw(SDL_Renderer* target, Sint32 frameTime, int x, int y) const {
+ if (!data->tex) {
+ std::cerr << "Texture is null!" << std::endl;
+ }
+ SDL_Rect rect = data->imgCord;
+ rect.x+=rect.w*((frameTime/data->aniFrameTime)%data->aniFrames);
+ SDL_Rect pos = rect;
+ pos.x = x;
+ pos.y = y;
+ SDL_RenderCopy(target, data->tex, &rect, &pos);
+}
+
+void SagoSprite::Draw(SDL_Renderer* target, Sint32 frameTime, int x, int y, const SDL_Rect& part) const {
+ SDL_Rect rect = data->imgCord;
+ rect.x+=rect.w*((frameTime/data->aniFrameTime)%data->aniFrames);
+ rect.x += part.x;
+ rect.y += part.y;
+ rect.w = part.w;
+ rect.h = part.h;
+ SDL_Rect pos = rect;
+ pos.x = x;
+ pos.y = y;
+ SDL_RenderCopy(target, data->tex, &rect, &pos);
+}
+
+void SagoSprite::DrawBounded(SDL_Renderer* target, Sint32 frameTime, int x, int y, const SDL_Rect& bounds) const {
+ SDL_Rect rect = data->imgCord;
+ rect.x+=rect.w*((frameTime/data->aniFrameTime)%data->aniFrames);
+ SDL_Rect pos = rect;
+ pos.x = x;
+ pos.y = y;
+ if (pos.x > bounds.x+bounds.w) {
+ return;
+ }
+ if (pos.y > bounds.y+bounds.h) {
+ return;
+ }
+ if (pos.x+pos.w < bounds.x) {
+ return;
+ }
+ if (pos.y+pos.h < bounds.y) {
+ return;
+ }
+ if (pos.x < bounds.x) {
+ Sint16 absDiff = bounds.x-pos.x;
+ pos.x+=absDiff;
+ rect.x+=absDiff;
+ pos.w-=absDiff;
+ rect.w-=absDiff;
+ }
+ if (pos.y < bounds.y) {
+ Sint16 absDiff = bounds.y-pos.y;
+ pos.y+=absDiff;
+ rect.y+=absDiff;
+ pos.h-=absDiff;
+ rect.h-=absDiff;
+ }
+ if (pos.x+pos.w > bounds.x+bounds.w) {
+ Sint16 absDiff = pos.x+pos.w-(bounds.x+bounds.w);
+ pos.w -= absDiff;
+ rect.w -= absDiff;
+ }
+ if (pos.y+pos.h > bounds.y+bounds.h) {
+ Sint16 absDiff = pos.y+pos.h-(bounds.y+bounds.h);
+ pos.h -= absDiff;
+ rect.h -= absDiff;
+ }
+
+ SDL_RenderCopy(target, data->tex, &rect, &pos);
+}
+
+void SagoSprite::SetOrigin(const SDL_Rect& newOrigin) {
+ data->origin = newOrigin;
+}
+
+int SagoSprite::GetWidth() const {
+ return data->imgCord.w;
+}
+int SagoSprite::GetHeight() const {
+ return data->imgCord.h;
+}
+
+} //namespace sago
\ No newline at end of file
diff --git a/source/code/sago/SagoSprite.hpp b/source/code/sago/SagoSprite.hpp new file mode 100644 index 0000000..bb7d9ec --- /dev/null +++ b/source/code/sago/SagoSprite.hpp
@@ -0,0 +1,80 @@
+/*
+ Copyright (c) 2015 Poul Sander
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+*/
+
+#ifndef SAGOSPRITE_HPP
+#define SAGOSPRITE_HPP
+
+#include "SagoDataHolder.hpp"
+
+namespace sago {
+
+class SagoSprite {
+public:
+ SagoSprite();
+ SagoSprite(const SagoDataHolder &texHolder, const std::string &texture,const SDL_Rect& initImage,const int animationFrames, const int animationFrameLength);
+ /**
+ * Draws the sprite to a given render window
+ * @param target The render window to draw on
+ * @param frameTime The time in milliseonds since gamestart. Used to determen the place in the animation
+ * @param x Place to draw the sprite
+ * @param y Place to draw the sprite
+ */
+ void Draw(SDL_Renderer* target, Sint32 frameTime, int x, int y) const;
+ /**
+ * Draws part of the sprite to a given render window
+ * @param target The render window to draw on
+ * @param frameTime The time in milliseonds since gamestart. Used to determen the place in the animation
+ * @param x Place to draw the sprite
+ * @param y Place to draw the sprite
+ * @param part the part of the sprite that should be drawn.
+ */
+ void Draw(SDL_Renderer* target, Sint32 frameTime, int x, int y, const SDL_Rect& part) const;
+ /**
+ * Draws the wprite to the given renderer but makes sure to not draw outside th bounds given
+ * @param target The render window to draw on
+ * @param frameTime The time in milliseonds since gamestart. Used to determen the place in the animation
+ * @param x Place to draw the sprite
+ * @param y Place to draw the sprite
+ * @param bounds A recagular area that we must not draw outside.
+ */
+ void DrawBounded(SDL_Renderer* target, Sint32 frameTime, int x, int y, const SDL_Rect& bounds) const;
+ /**
+ * Set a different origin. Normally it is the top left cornor. But in some cases you might want to center the origin or tranform it for other reasons
+ * @param newOrigin the coordinates that should be the new origin. Call with {0,0} to reset to default
+ */
+ void SetOrigin(const SDL_Rect& newOrigin);
+ SagoSprite(const SagoSprite& base);
+ SagoSprite& operator=(const SagoSprite& base);
+ int GetWidth() const;
+ int GetHeight() const;
+ virtual ~SagoSprite();
+private:
+ struct SagoSpriteData;
+ SagoSpriteData *data;
+};
+
+}
+
+#endif /* SAGOSPRITE_HPP */
+
diff --git a/source/code/sago/SagoSpriteHolder.cpp b/source/code/sago/SagoSpriteHolder.cpp new file mode 100644 index 0000000..0c805ee --- /dev/null +++ b/source/code/sago/SagoSpriteHolder.cpp
@@ -0,0 +1,126 @@
+/*
+ Copyright (c) 2015 Poul Sander
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+*/
+
+#include "SagoSpriteHolder.hpp"
+#include "SagoMisc.hpp"
+#include <memory>
+#include <unordered_map>
+#include <jsoncpp/json/json.h>
+#include <iostream>
+#include <string.h>
+#include <boost/algorithm/string/predicate.hpp>
+
+
+//I truely hate the C way of checking for equal. Usually read: "if not X compares to Y then they must be equal"
+#define strequal(X,Y) strcmp(X,Y)==0
+
+using namespace std;
+
+namespace sago {
+
+struct SagoSpriteHolder::SagoSpriteHolderData {
+ const sago::SagoDataHolder* tex;
+ std::unordered_map<std::string,std::shared_ptr<sago::SagoSprite>> sprites;
+ const sago::SagoSprite* defaultSprite;
+};
+
+SagoSpriteHolder::SagoSpriteHolder(const SagoDataHolder& texHolder) {
+ data = new SagoSpriteHolderData();
+ try {
+ data->tex = &texHolder;
+ ReadSprites();
+ data->defaultSprite = new sago::SagoSprite(texHolder,"fallback", {0,0,64,64},1,100);
+ }
+ catch (...) {
+ delete data;
+ }
+}
+
+SagoSpriteHolder::~SagoSpriteHolder() {
+ delete data;
+}
+
+void SagoSpriteHolder::ReadSpriteFile(const std::string& filename) {
+ string fullfile = "sprites/"+filename;
+ string content = sago::GetFileContent(fullfile.c_str());
+ Json::Value root; // will contains the root value after parsing
+ Json::Reader reader;
+ bool parsingSuccessful = reader.parse( content, root );
+ if ( !parsingSuccessful ) {
+ cerr << "Failed to parse: " << fullfile << endl
+ << reader.getFormattedErrorMessages() << endl;
+ return;
+ }
+ for (Json::Value::iterator it = root.begin(); it != root.end() ; ++it) {
+ string spriteName = it.key().asString();
+ Json::Value value = (*it);
+ string textureName = value.get("texture","fallback").asString();
+ int topx = value.get("topx",0).asInt();
+ int topy = value.get("topy",0).asInt();
+ int height = value.get("height",0).asInt();
+ int width = value.get("width",0).asInt();
+ int number_of_frames = value.get("number_of_frames",1).asInt();
+ int frame_time = value.get("frame_time",1).asInt();
+ int originx = value.get("originx",0).asInt();
+ int originy = value.get("originy",0).asInt();
+ if (number_of_frames < 1) {
+ number_of_frames = 1;
+ }
+ if (frame_time < 1) {
+ frame_time = 1;
+ }
+ std::shared_ptr<sago::SagoSprite> ptr(new SagoSprite(*(data->tex),textureName, {topx,topy,width,height},number_of_frames,frame_time));
+ ptr->SetOrigin({originx,originy, 0, 0});
+ this->data->sprites[std::string(spriteName)] = ptr;
+ }
+}
+
+void SagoSpriteHolder::ReadSprites() {
+ std::vector<std::string> spritefiles = GetFileList("sprites");
+ for (std::string& item : spritefiles ) {
+ if (boost::algorithm::ends_with(item,".sprite")) {
+ cout << "Found " << item << endl;
+ ReadSpriteFile(item);
+ }
+ else {
+ cout << "Ignoreing " << item << endl;
+ }
+ }
+}
+
+const sago::SagoSprite& SagoSpriteHolder::GetSprite(const std::string& spritename) const {
+ std::unordered_map<std::string,std::shared_ptr<sago::SagoSprite>>::const_iterator got = data->sprites.find (spritename);
+ if ( got == data->sprites.end() ) {
+ return *data->defaultSprite;
+ }
+ else {
+ return *(got->second);
+ }
+}
+
+const SagoDataHolder& SagoSpriteHolder::GetDataHolder() const {
+ return *data->tex;
+}
+
+}
\ No newline at end of file
diff --git a/source/code/sago/SagoSpriteHolder.hpp b/source/code/sago/SagoSpriteHolder.hpp new file mode 100644 index 0000000..b3c32f9 --- /dev/null +++ b/source/code/sago/SagoSpriteHolder.hpp
@@ -0,0 +1,51 @@
+/*
+ Copyright (c) 2015 Poul Sander
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+*/
+
+#ifndef SAGOSPRITEHOLDER_HPP
+#define SAGOSPRITEHOLDER_HPP
+
+#include "SagoDataHolder.hpp"
+#include "SagoSprite.hpp"
+
+namespace sago {
+
+class SagoSpriteHolder {
+public:
+ SagoSpriteHolder(const SagoDataHolder &texHolder);
+ virtual ~SagoSpriteHolder();
+ void ReadSprites();
+ const sago::SagoSprite& GetSprite(const std::string &spritename) const;
+ const SagoDataHolder& GetDataHolder() const;
+private:
+ SagoSpriteHolder(const SagoSpriteHolder& base) = delete;
+ SagoSpriteHolder& operator=(const SagoSpriteHolder& base) = delete;
+ void ReadSpriteFile(const std::string &filename);
+ struct SagoSpriteHolderData;
+ SagoSpriteHolderData *data;
+};
+
+}
+
+#endif /* SAGOSPRITEHOLDER_HPP */
+
diff --git a/source/code/scopeHelpers.hpp b/source/code/scopeHelpers.hpp index e96e5ea..999f9f5 100644 --- a/source/code/scopeHelpers.hpp +++ b/source/code/scopeHelpers.hpp
@@ -24,20 +24,30 @@ http://www.blockattack.net
#ifndef SCOPEHELPERS_HPP
#define SCOPEHELPERS_HPP
-class SDLUnicodeScope {
-private:
- int oldStatus;
+#include "common.h"
+
+
+class SDL_RendererHolder {
+ SDL_Renderer* ptr;
public:
- SDLUnicodeScope() {
- oldStatus = SDL_EnableUNICODE(SDL_ENABLE);
+ SDL_RendererHolder(SDL_Renderer* input) {
+ dieOnNullptr(input, "Failed to get render");
+ ptr = input;
}
- void Release() {
- SDL_EnableUNICODE(oldStatus);
+ ~SDL_RendererHolder() {
+ SDL_DestroyRenderer(ptr);
+ }
+};
+
+class SDL_TextInput {
+public:
+ SDL_TextInput() {
+ SDL_StartTextInput();
}
- ~SDLUnicodeScope() {
- Release();
+ ~SDL_TextInput() {
+ SDL_StopTextInput();
}
};
diff --git a/source/code/ttfont.cpp b/source/code/ttfont.cpp deleted file mode 100644 index c676abf..0000000 --- a/source/code/ttfont.cpp +++ /dev/null
@@ -1,104 +0,0 @@
-/*
-===========================================================================
-blockattack - Block Attack - Rise of the Blocks
-Copyright (C) 2005-2012 Poul Sander
-
-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, see http://www.gnu.org/licenses/
-
-Source information and contacts persons can be found at
-http://blockattack.sf.net
-===========================================================================
-*/
-
-#include "ttfont.h"
-
-TTFont::TTFont() {
- font = nullptr;
- actualInstance = false;
-}
-
-int TTFont::count = 0;
-
-TTFont::TTFont(TTF_Font *f) {
- if (!(TTF_WasInit())) {
- //Init TTF for the first time
- TTF_Init();
- }
-
-
- if (f == nullptr) {
- cout << "Font was null!" << endl;
- }
-
- actualInstance = false; //We have not yet copied to final location
- font = f;
-
-}
-
-TTFont::~TTFont() {
- if (!actualInstance) {
- return;
- }
-
- cout << "Closing a font" << endl;
-
- TTF_CloseFont(font);
- font = nullptr;
-
- count--;
- if (count==0) {
- TTF_Quit();
- }
-}
-
-//Copy constructor, you cannot copy an actual instance
-TTFont::TTFont(const TTFont &t) {
- if (t.font == nullptr || t.actualInstance) {
- font = nullptr;
- actualInstance = false;
- }
- else {
- font = t.font;
- actualInstance = true;
- count++;
- }
-}
-
-int TTFont::getTextHeight() {
- return TTF_FontHeight(font);
-}
-
-int TTFont::getTextWidth(string text) {
- int width = 0;
- if (TTF_SizeText(font,text.c_str(),&width,nullptr)!=0) {
- cout << "Failed to get text width!" << endl;
- }
- return width;
-}
-
-void TTFont::writeText(string text, SDL_Surface *target, int x, int y) {
- SDL_Surface *text_surface;
- SDL_Color color= {255,255,255};
- if (!(text_surface=TTF_RenderText_Solid(font,text.c_str(), color))) {
- cout << "Error writing text: " << TTF_GetError() << endl;
- }
- else {
- SDL_Rect dest;
- dest.x = x;
- dest.y = y;
- SDL_BlitSurface(text_surface,nullptr,target,&dest);
- SDL_FreeSurface(text_surface);
- }
-}
-
diff --git a/source/code/ttfont.h b/source/code/ttfont.h deleted file mode 100644 index 1d3d652..0000000 --- a/source/code/ttfont.h +++ /dev/null
@@ -1,61 +0,0 @@
-/*
-===========================================================================
-blockattack - Block Attack - Rise of the Blocks
-Copyright (C) 2005-2012 Poul Sander
-
-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, see http://www.gnu.org/licenses/
-
-Source information and contacts persons can be found at
-http://blockattack.sf.net
-===========================================================================
-*/
-
-//
-// File: ttfont.hpp.h
-// Author: poul
-//
-// Created on 25. december 2007, 13:52
-//
-
-#ifndef _TTFONT_H
-#define _TTFONT_H
-
-#include <stdlib.h>
-#include <iostream>
-#include <string>
-#include "SDL.h"
-//#include "SDL_ttf.h" //To use True Type Fonts in SDL
-
-
-class TTFont
-{
-private:
- static int count; //The total number of instances
- TTF_Font *font;
- bool actualInstance;
-
-public:
- TTFont();
- TTFont(TTF_Font *f);
- TTFont(const TTFont &t);
- ~TTFont();
-
- int getTextWidth(string text);
- int getTextHeight();
- void writeText(string text, SDL_Surface *target, int x, int y);
-
-};
-
-#endif /* _TTFONT_H */
-
diff --git a/travis_build.script b/travis_build.script index 1af8ae1..a49a44a 100755 --- a/travis_build.script +++ b/travis_build.script
@@ -5,5 +5,6 @@ cp -r source/misc/travis_help/utf8_v2_3_4/source/utf8 source/code/
make -C source/code -f Makefile
make clean
./packdata.sh
-scons -Q prefix=$HOME -Q sharedir=$HOME/share/
+#I do not support scons.
+#scons -Q prefix=$HOME -Q sharedir=$HOME/share/