pax_global_header00006660000000000000000000000064134131602640014512gustar00rootroot0000000000000052 comment=86b54d69569beda78ad79958143538889ac95892 pegsolitaire-0.3/000077500000000000000000000000001341316026400140435ustar00rootroot00000000000000pegsolitaire-0.3/.clang-format000066400000000000000000000000421341316026400164120ustar00rootroot00000000000000BasedOnStyle: LLVM IndentWidth: 4 pegsolitaire-0.3/.gitignore000066400000000000000000000001101341316026400160230ustar00rootroot00000000000000pegsolitaire *.o data.h *.desktop *.appdata.xml *.mo *.pot LINGUAS *~ pegsolitaire-0.3/AUTHORS000066400000000000000000000001251341316026400151110ustar00rootroot00000000000000Ben Asselstine Juhani Numminen pegsolitaire-0.3/CHANGELOG000066400000000000000000000024231341316026400152560ustar00rootroot00000000000000Version 0.3 (2019-01-02) ======================== * Increased Makefile compatibility with BSD, GNU conventions. Version 0.2 (2019-01-02) ======================== * Updated gtk2 to gtk3. * The game pieces were made larger and the spaces between them smaller. * Image files are loaded from the executable rather than from the file system. * Removed -x and -y command-line options that set the window position. They were not very useful. * Removed the use of autotools in favor of a single Makefile. Version 0.1.1 (2018-01-16) ========================== * Added CHANGELOG. Version 0.1.0 (2018-01-08) ========================== * Removed usage of deprecated libgnome, libgnomeui and libglade. * Updated gridframe and preimage libraries. New dependency librsvg2. * Enabled new compiler warnings. New dependency autoconf-archive. * Added .desktop, .appdata.xml and manpage. Version 0.0.4 (2008-05-01) ========================== * Updated translation files. * Added German translation. (2007-01-05) ============ * Regenerate files to work with Anjuta version 2.2.0. * src/callbacks.c (on_helpAboutMenuItemActivate): don't just show the pegSolitaireAboutDialog, but run it also so that the `close' button works on the dialog. (2007-01-01) ============ * Initial version. pegsolitaire-0.3/COPYING000066400000000000000000000432541341316026400151060ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser 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. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 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. , 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 Lesser General Public License instead of this License. pegsolitaire-0.3/Makefile000066400000000000000000000061131341316026400155040ustar00rootroot00000000000000package = pegsolitaire version = 0.3 appid = com.github.jnumm.pegsolitaire src = $(wildcard src/*.c) obj = $(src:.c=.o) pofiles = $(wildcard po/*.po) mofiles = $(pofiles:.po=.mo) INSTALL ?= install INSTALL_PROGRAM ?= $(INSTALL) INSTALL_DATA ?= $(INSTALL) -m644 prefix ?= /usr/local bindir ?= $(prefix)/bin mandir ?= $(prefix)/share/man localedir ?= $(prefix)/share/locale desktopdir ?= $(prefix)/share/applications appdatadir ?= $(prefix)/share/metainfo svgicondir ?= $(prefix)/share/icons/hicolor/scalable/apps helpdir ?= $(prefix)/share/gnome/help/$(package)/C deps = gtk+-3.0 gmodule-2.0 librsvg-2.0 # Flags that are more or less required to build pkg_CPPFLAGS = -I. -DPACKAGE='"$(package)"' -DVERSION='"$(version)"' \ -DLOCALEDIR='"$(localedir)"' -DENABLE_NLS pkg_CFLAGS = -Wall -Wextra -Wpedantic -Wmissing-prototypes -Wstrict-prototypes \ -Wunused-macros -Wshadow -Wdouble-promotion -Wno-overlength-strings \ -fvisibility=hidden $(shell pkg-config --cflags $(deps)) pkg_LDLIBS = -Wl,--as-needed $(shell pkg-config --libs $(deps)) # Non-essential default flags CFLAGS ?= -O2 -g .PHONY: all clean install update-po all: pegsolitaire $(mofiles) $(appid).desktop $(appid).appdata.xml %.o: %.c data.h $(CC) $(pkg_CPPFLAGS) $(CPPFLAGS) $(pkg_CFLAGS) $(CFLAGS) -o $@ -c $< pegsolitaire: $(obj) $(CC) $(pkg_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(pkg_LDLIBS) $(LDLIBS) # Embedding the required data files in the executable. data.h: data/pegsolitaire.glade data/hole.svg data/peg.svg ./generate-data-header $^ > $@ $(appid).desktop: data/$(appid).desktop.in po/LINGUAS msgfmt -c --desktop --template $< -o $@ -d po $(appid).appdata.xml: data/$(appid).appdata.xml.in po/LINGUAS msgfmt -c --xml --template $< -o $@ -d po po/LINGUAS: echo $(notdir $(basename $(pofiles))) > $@ %.mo: %.po msgfmt -c -o $@ $< # The first -k disables all default keywords, because we don't want the # value for Icon in the desktop file to be translated. pegsolitaire.pot: xgettext -o $@ -f po/POTFILES.in \ -k -k_ -kN_ -kName -kGenericName -kComment -kKeywords \ --add-comments=TRANSLATORS: \ --package-name=$(package) --package-version=$(version) \ --msgid-bugs-address=https://github.com/jnumm/pegsolitaire/issues update-po: $(addsuffix -update,$(pofiles)) %.po-update: pegsolitaire.pot msgmerge --update $*.po $< clean: rm -f pegsolitaire $(obj) data.h $(appid).desktop $(appid).appdata.xml \ $(mofiles) pegsolitaire.pot po/LINGUAS install: all $(addsuffix -install,$(mofiles)) mkdir -p $(DESTDIR)$(bindir) $(DESTDIR)$(desktopdir) \ $(DESTDIR)$(appdatadir) $(DESTDIR)$(svgicondir) \ $(DESTDIR)$(mandir)/man6 $(DESTDIR)$(helpdir) $(INSTALL_PROGRAM) pegsolitaire $(DESTDIR)$(bindir) $(INSTALL_DATA) $(appid).desktop $(DESTDIR)$(desktopdir) $(INSTALL_DATA) $(appid).appdata.xml $(DESTDIR)$(appdatadir) $(INSTALL_DATA) data/pegsolitaire.svg $(DESTDIR)$(svgicondir) $(INSTALL_DATA) data/pegsolitaire.6 $(DESTDIR)$(mandir)/man6 $(INSTALL_DATA) help/* $(DESTDIR)$(helpdir) %.mo-install: %.mo mkdir -p $(DESTDIR)$(localedir)/$(notdir $*)/LC_MESSAGES $(INSTALL_DATA) $< $(DESTDIR)$(localedir)/$(notdir $*)/LC_MESSAGES/$(package).mo pegsolitaire-0.3/README000066400000000000000000000002201341316026400147150ustar00rootroot00000000000000Peg Solitaire is an educational game similar to Hi-Q. The object is to jump pegs until a single peg is left in the centre of the game board. pegsolitaire-0.3/data/000077500000000000000000000000001341316026400147545ustar00rootroot00000000000000pegsolitaire-0.3/data/com.github.jnumm.pegsolitaire.appdata.xml.in000066400000000000000000000023241341316026400253670ustar00rootroot00000000000000 com.github.jnumm.pegsolitaire FSFAP GPL-2.0+ Peg Solitaire Play an educational puzzle game similar to Hi-Q

Peg Solitaire is a board game for one player involving movement of pegs on a board with holes. The game fills the entire board with pegs except for the central hole. The objective is, making valid moves, to empty the entire board except for a solitary peg in the central hole.

com.github.jnumm.pegsolitaire.desktop https://raw.githubusercontent.com/jnumm/pegsolitaire/screenshots/pegsolitaire-default.png https://github.com/jnumm/pegsolitaire juhaninumminen0@gmail.com pegsolitaire pegsolitaire
pegsolitaire-0.3/data/com.github.jnumm.pegsolitaire.desktop.in000066400000000000000000000004151341316026400246260ustar00rootroot00000000000000[Desktop Entry] Type=Application Name=Peg Solitaire Comment=Play an educational puzzle game similar to Hi-Q Icon=pegsolitaire Exec=pegsolitaire Terminal=false Categories=Game;LogicGame; Keywords=solitaire;peg;brainvita;solo;noble;puzzle;logic;board; StartupNotify=true pegsolitaire-0.3/data/hole.svg000066400000000000000000000167321341316026400164350ustar00rootroot00000000000000 image/svg+xml Media Record Lapo Calamandrei media player record music sound video pegsolitaire-0.3/data/peg.svg000066400000000000000000000237401341316026400162560ustar00rootroot00000000000000 image/svg+xml Media Record Lapo Calamandrei media player record music sound video pegsolitaire-0.3/data/pegsolitaire.6000066400000000000000000000020351341316026400175320ustar00rootroot00000000000000.TH PEGSOLITAIRE 6 "2019-01-01" "pegsolitaire 0.3" "User Commands" .\" Please adjust this date whenever revising the manpage. . .SH NAME pegsolitaire \- puzzle game for one player . .SH SYNOPSIS .B pegsolitaire .RI [ option ...] . .SH DESCRIPTION .B pegsolitaire is an educational puzzle game. .PP The goal of the game is to remove pegs from the board leaving a single peg in the centre hole. Pegs are removed from the board by making jumps. You can jump over a peg with another peg horizontally or vertically, but not diagonally. .PP When you jump over a peg, it is removed from the board. Multiple jumps with one peg are allowed. . .SS "Help Options:" .TP \fB\-h\fR, \fB\-\-help\fR Show help options .TP \fB\-\-help\-all\fR Show all help options .TP \fB\-\-help\-gtk\fR Show GTK+ Options .SS "Application Options:" .TP \fB\-\-display\fR=\fIDISPLAY\fR X display to use . .SH AUTHOR pegsolitaire was written by Ben Asselstine. .PP This manual page was originally written by Barry deFreese for the Debian and Ubuntu distributions. pegsolitaire-0.3/data/pegsolitaire.glade000066400000000000000000000370241341316026400204470ustar00rootroot00000000000000 True False gtk-help True False gtk-refresh True False Peg Solitaire center 500 500 pegsolitaire True False vertical True False True False _Game True True False _Restart True False True stockRefreshImage False True False True False _English Board True True False True False Beginner True True False Intermediate True True False Advanced True True False E_uropean Board True True False True False Beginner True True False Intermediate True True False Advanced True True False gtk-quit True False True True True False _Help True True False Contents True False stockHelpImage False gtk-about True False True True False True 0 True False GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK True True 1 True False True False False False 8 0 True False False False 8 end 1 False True end 2 Peg Solitaire False 5 True pegsolitaire normal pegSolitaireWindow Peg Solitaire © 2007-2008 Ben Asselstine\n © 2017-2018 Juhani Numminen This software is dedicated to Mothers everywhere. https://github.com/jnumm/pegsolitaire Ben Asselstine\n Juhani Numminen translator-credits pegsolitaire gpl-2-0 False False False False 0 pegsolitaire-0.3/data/pegsolitaire.old.png000066400000000000000000000030251341316026400207260ustar00rootroot00000000000000PNG  IHDR00` PLTE'4&=-A1I7 O=&VB%bB$[G*bG(fF'iG#fJ$mK'jM'pN)lO/hR/nQ1oR+sP+qS-wS/tW6xZ3|X3Y/}]1\2^4`5b7a6co>R}PK%bz`|3jyfzFEZ~Nf}?)Tl{uGh|p{tBPvCHn}q}9KCǟvDB8s~v~yFTY/xS;FM0̣yGy|=F2͂~}4?ˆQƦ|J|EKJɃCAUɌ[ËCʭIND̑EOGΖXHϓIКSKў{O}^Vѥ~WWΤyyYZԨvUaϭwcпQ\ӱsdѮueҳuYfӶpghոrmiƖWooqrkřksʛ[tĝguʜivw̞jxΟfyҢb{܀ԣcׂ֥eلچۍۇ܎܏ސߒۓܙݛޜߝޠ袮`tRNS@fbKGDH pHYs  tIME IDATHՔk`ǟG lF)ez IdeEB)RX/JP!RBBJC RJ M#"Þ7|ܚ6l?~4Mϑ6ak`YHH^V `OyM{x=DbtK>Ԉ-LB>]̫-pm{2=0Qi@Q_MP5ɘzh)"ZJ:Huځ'< I{~|nȿ'Ψl?f";)Й鸹Ń395+J3!㙘ޙ@v&joI,) ʷTx[dbs:[vXj?LLMBv$tmG?hb {ª)|=|)B]}쏾ǻ'{>O:WRz<<#Y/Knki7x"4msRR~IENDB`pegsolitaire-0.3/data/pegsolitaire.svg000077700000000000000000000000001341316026400214532peg.svgustar00rootroot00000000000000pegsolitaire-0.3/generate-data-header000077500000000000000000000010271341316026400177200ustar00rootroot00000000000000#!/bin/sh # Embeds the files given as arguments in a C header. # Copyright (C) 2018 Juhani Numminen set -e echo "/* This is an autogenerated file. */" echo "#ifndef DATA_H" echo "#define DATA_H" for f in $@; do token=$(basename $f | tr . _) # Remove \n, remove spaces after >, replace multiple spaces with single one, # escape double quote. escaped=$(tr -d '\n' < $f | sed -E -e 's,>[[:space:]]+,>,g' -e 's,[[:space:]]+, ,g' -e 's,",\\",g') printf '#define %s "%s"\n' "$token" "$escaped" done echo "#endif" pegsolitaire-0.3/help/000077500000000000000000000000001341316026400147735ustar00rootroot00000000000000pegsolitaire-0.3/help/legal.xml000066400000000000000000000071301341316026400166020ustar00rootroot00000000000000 Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License (GFDL), Version 1.1 or any later version published by the Free Software Foundation with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. You can find a copy of the GFDL at this link or in the file COPYING-DOCS distributed with this manual. This manual is part of a collection of GNOME manuals distributed under the GFDL. If you want to distribute this manual separately from the collection, you can do so by adding a copy of the license to the manual, as described in section 6 of the license. Many of the names used by companies to distinguish their products and services are claimed as trademarks. Where those names appear in any GNOME documentation, and the members of the GNOME Documentation Project are made aware of those trademarks, then the names are in capital letters or initial capital letters. DOCUMENT AND MODIFIED VERSIONS OF THE DOCUMENT ARE PROVIDED UNDER THE TERMS OF THE GNU FREE DOCUMENTATION LICENSE WITH THE FURTHER UNDERSTANDING THAT: DOCUMENT IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE DOCUMENT OR MODIFIED VERSION OF THE DOCUMENT IS FREE OF DEFECTS MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY, ACCURACY, AND PERFORMANCE OF THE DOCUMENT OR MODIFIED VERSION OF THE DOCUMENT IS WITH YOU. SHOULD ANY DOCUMENT OR MODIFIED VERSION PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL WRITER, AUTHOR OR ANY CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY DOCUMENT OR MODIFIED VERSION OF THE DOCUMENT IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER; AND UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER IN TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL THE AUTHOR, INITIAL WRITER, ANY CONTRIBUTOR, OR ANY DISTRIBUTOR OF THE DOCUMENT OR MODIFIED VERSION OF THE DOCUMENT, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER DAMAGES OR LOSSES ARISING OUT OF OR RELATING TO USE OF THE DOCUMENT AND MODIFIED VERSIONS OF THE DOCUMENT, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. pegsolitaire-0.3/help/pegsolitaire.xml000066400000000000000000000063421341316026400202110ustar00rootroot00000000000000 Peg Solitaire"> ]>
Peg Solitaire Manual &manrevision; 2007 Ben Asselstine Ben Asselstine &legal; Ben Asselstine Peg Solitaire Development Team
benasselstine@gmail.com
This manual describes version &appversion; of &app;. Feedback Information To report a bug or make a suggestion regarding this application or this documentation, see the GNOME Feedback Page.
Peg Solitaire pegsolitaire Introduction Peg Solitaire is a board game for one player involving movement of pegs on a board with holes. The first evidence of peg solitaire can be traced back to the court of Louis XIV, and the specific date of 1697. It was made popular in more recent history by the board game marketed as Hi-Q. Objective The goal of the game is to remove pegs from the board leaving a single peg in the centre hole. Pegs are removed from the board by making "jumps". You can jump over a peg with another peg horizontally or vertically (not diagonally!). When you jump over a peg, it is removed from the board. Multiple jumps with one peg are allowed. Getting Started You can start &app; from the Applications menu by choosing Games Peg Solitaire .
pegsolitaire-0.3/po/000077500000000000000000000000001341316026400144615ustar00rootroot00000000000000pegsolitaire-0.3/po/POTFILES.in000066400000000000000000000003441341316026400162370ustar00rootroot00000000000000# List of source files containing translatable strings. data/com.github.jnumm.pegsolitaire.desktop.in data/com.github.jnumm.pegsolitaire.appdata.xml.in data/pegsolitaire.glade src/game.c src/callbacks.c src/main.c src/render.c pegsolitaire-0.3/po/de.po000066400000000000000000000110001341316026400154010ustar00rootroot00000000000000# German translation for Pegsolitaire. # Copyright (C) 2008 Ben Asselstine # This file is distributed under the same license as the Pegsolitaire package. # Mario Blättermann , 2008. # msgid "" msgstr "" "Project-Id-Version: pegsolitaire 0.0.4\n" "Report-Msgid-Bugs-To: https://github.com/jnumm/pegsolitaire/issues\n" "POT-Creation-Date: 2019-01-02 00:05+0200\n" "PO-Revision-Date: 2018-01-20 10:39+0100\n" "Last-Translator: Markus Enzenberger \n" "Language-Team: German\n" "Language: de\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "X-Generator: Poedit 2.0.4\n" #: data/com.github.jnumm.pegsolitaire.desktop.in:4 #: data/com.github.jnumm.pegsolitaire.appdata.xml.in:8 #: data/pegsolitaire.glade:19 src/render.c:89 msgid "Peg Solitaire" msgstr "Peg Solitaire" #: data/com.github.jnumm.pegsolitaire.desktop.in:5 #: data/com.github.jnumm.pegsolitaire.appdata.xml.in:9 msgid "Play an educational puzzle game similar to Hi-Q" msgstr "Spiele ein lehrreiches Knobelspiel ähnlich wie Solitär" #: data/com.github.jnumm.pegsolitaire.desktop.in:10 msgid "solitaire;peg;brainvita;solo;noble;puzzle;logic;board;" msgstr "" "Solitär;Solitaire;Steckhalma;Solohalma;Springer;Jumper;Nonnenspiel;" "Einsiedlerspiel;Stift;Einzelspieler;Knobelspiel;Brettspiel;" #: data/com.github.jnumm.pegsolitaire.appdata.xml.in:12 msgid "" "Peg Solitaire is a board game for one player involving movement of pegs on a " "board with holes. The game fills the entire board with pegs except for the " "central hole. The objective is, making valid moves, to empty the entire " "board except for a solitary peg in the central hole." msgstr "" "Peg Solitaire (Solitär) ist ein Brettspiel für eine Person, bei dem Stifte " "auf einem Brett mit Löchern gezogen werden. Zuerst ist das ganze Brett mit " "Stiften gefüllt außer das Loch in der Mitte. Ziel ist es, das ganze Brett " "durch legale Züge zu leeren, sodass nur ein einzelner Stift in der Mitte " "übrigbleibt." #: data/pegsolitaire.glade:38 msgid "_Game" msgstr "_Spiel" #: data/pegsolitaire.glade:46 msgid "_Restart" msgstr "_Neu starten" #: data/pegsolitaire.glade:66 msgid "_English Board" msgstr "_Englisches Brett" #: data/pegsolitaire.glade:76 data/pegsolitaire.glade:117 msgid "Beginner" msgstr "Anfänger" #: data/pegsolitaire.glade:85 data/pegsolitaire.glade:126 msgid "Intermediate" msgstr "Fortgeschritten" #: data/pegsolitaire.glade:94 data/pegsolitaire.glade:135 msgid "Advanced" msgstr "Profi" #: data/pegsolitaire.glade:107 msgid "E_uropean Board" msgstr "E_uropäisches Brett" #: data/pegsolitaire.glade:169 msgid "_Help" msgstr "_Hilfe" #: data/pegsolitaire.glade:177 msgid "Contents" msgstr "Inhalt" #: data/pegsolitaire.glade:274 msgid "This software is dedicated to Mothers everywhere." msgstr "Diese Software ist den Müttern der Welt gewidmet." #. TRANSLATORS: Replace this string with your names, one name per line. #: data/pegsolitaire.glade:278 msgid "translator-credits" msgstr "" "Mario Blättermann \n" "Markus Enzenberger" #: src/game.c:210 msgid "GENIUS!" msgstr "GENIAL!" #: src/game.c:210 msgid "OUTSTANDING!" msgstr "Außergewöhnlich!" #: src/game.c:212 msgid "Sensational!" msgstr "Sensationell!" #: src/game.c:214 msgid "Excellent!" msgstr "Exzellent!" #: src/game.c:216 msgid "Very Good!" msgstr "Sehr gut!" #: src/game.c:218 msgid "Not Bad!" msgstr "Nicht schlecht!" #: src/game.c:220 msgid "Better Luck Next Time!" msgstr "Viel Glück beim nächsten Mal!" #. TRANSLATORS: This is the number of moves the player has made. #: src/callbacks.c:31 #, c-format msgid "Moves: %d" msgstr "Züge: %d" #: src/callbacks.c:83 #, c-format msgid "Cannot show help: %s" msgstr "Hilfe wurde nicht gefunden: %s" #: src/main.c:51 #, c-format msgid "pegsolitaire: Could not initialize GTK+.\n" msgstr "" #: src/render.c:57 #, c-format msgid "The \"%s\" cursor is not available" msgstr "Der Cursor \"%s\" wurde nicht gefunden" #: src/render.c:85 #, c-format msgid "" "Something went wrong.\n" "Could not load internal image data:\n" "%s" msgstr "" #~ msgid "" #~ "Could not find the image:\n" #~ "%s\n" #~ "\n" #~ "Please check that Peg Solitaire is installed correctly." #~ msgstr "" #~ "Konnte Bilddatei nicht finden:\n" #~ "%s\n" #~ "\n" #~ "Bitte überprüfen Sie die korrekte Installation von Peg Solitaire." #~ msgid "The \"%s\" or \"%s\" cursor is not available" #~ msgstr "Der Cursor \"%s\" oder \"%s\" wurde nicht gefunden" pegsolitaire-0.3/src/000077500000000000000000000000001341316026400146325ustar00rootroot00000000000000pegsolitaire-0.3/src/callbacks.c000066400000000000000000000062421341316026400167210ustar00rootroot00000000000000/* * Copyright (C) 2007-2008 Ben Asselstine * Copyright (C) 2017-2018 Juhani Numminen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "callbacks.h" #include #include #include "game.h" #include "i18n.h" #include "share.h" void update_statusbar(void) { // TRANSLATORS: This is the number of moves the player has made. gchar *str = g_strdup_printf(_("Moves: %d"), game_moves); gtk_label_set_text(statusMovesLabel, str); g_free(str); } static void initiate_new_game(int board_type, int board_size) { game_board_type = board_type; game_board_size = board_size; game_new(); gtk_label_set_text(statusMessageLabel, ""); update_statusbar(); gtk_widget_queue_draw(boardDrawingArea); } // Following functions are gtk callbacks and all their parameters are required. #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" void menu_restart(GtkMenuItem *menuitem, gpointer user_data) { initiate_new_game(game_board_type, game_board_size); } void menu_eng_beginner(GtkMenuItem *menuitem, gpointer user_data) { initiate_new_game(BOARD_ENGLISH, BOARD_SIZE_BEGINNER); } void menu_eng_intermediate(GtkMenuItem *menuitem, gpointer user_data) { initiate_new_game(BOARD_ENGLISH, BOARD_SIZE_INTERMEDIATE); } void menu_eng_advanced(GtkMenuItem *menuitem, gpointer user_data) { initiate_new_game(BOARD_ENGLISH, BOARD_SIZE_ADVANCED); } void menu_eur_beginner(GtkMenuItem *menuitem, gpointer user_data) { initiate_new_game(BOARD_EUROPEAN, BOARD_SIZE_BEGINNER); } void menu_eur_intermediate(GtkMenuItem *menuitem, gpointer user_data) { initiate_new_game(BOARD_EUROPEAN, BOARD_SIZE_INTERMEDIATE); } void menu_eur_advanced(GtkMenuItem *menuitem, gpointer user_data) { initiate_new_game(BOARD_EUROPEAN, BOARD_SIZE_ADVANCED); } void menu_help(GtkMenuItem *menuitem, gpointer user_data) { GError *err = NULL; gtk_show_uri_on_window(GTK_WINDOW(pegSolitaireWindow), "ghelp:pegsolitaire", gtk_get_current_event_time(), &err); if (err) { g_warning(_("Cannot show help: %s"), err->message); g_error_free(err); } } void menu_about(GtkMenuItem *menuitem, gpointer user_data) { gtk_dialog_run(GTK_DIALOG(pegSolitaireAboutDialog)); gtk_widget_hide(GTK_WIDGET(pegSolitaireAboutDialog)); } void window_destroy(GObject *object, gpointer user_data) { gtk_main_quit(); } void menu_quit(GtkMenuItem *menuitem, gpointer user_data) { gtk_main_quit(); } #pragma GCC diagnostic pop pegsolitaire-0.3/src/callbacks.h000066400000000000000000000032261341316026400167250ustar00rootroot00000000000000/* * Copyright (C) 2007-2008 Ben Asselstine * Copyright (C) 2017-2018 Juhani Numminen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef PEGSOLITAIRE_CALLBACKS_H #define PEGSOLITAIRE_CALLBACKS_H #include void update_statusbar(void); // The callback functions are explicitly marked for export due to combining // -fvisibility=hidden with -Wl,--export-dynamic. #pragma GCC visibility push(default) void menu_restart(GtkMenuItem *, gpointer); void menu_eng_beginner(GtkMenuItem *, gpointer); void menu_eng_intermediate(GtkMenuItem *, gpointer); void menu_eng_advanced(GtkMenuItem *, gpointer); void menu_eur_beginner(GtkMenuItem *, gpointer); void menu_eur_intermediate(GtkMenuItem *, gpointer); void menu_eur_advanced(GtkMenuItem *, gpointer); void menu_help(GtkMenuItem *, gpointer); void menu_about(GtkMenuItem *, gpointer); void window_destroy(GObject *, gpointer); void menu_quit(GtkMenuItem *, gpointer); #pragma GCC visibility pop #endif // PEGSOLITAIRE_CALLBACKS_H pegsolitaire-0.3/src/game.c000066400000000000000000000157551341316026400157240ustar00rootroot00000000000000/* * Copyright (C) 2007-2008 Ben Asselstine * Copyright (C) 2017-2018 Juhani Numminen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "game.h" #include #include #include #include #include #include #include "i18n.h" #include "share.h" #define DEFAULT_GAME_BOARD_SIZE BOARD_SIZE_BEGINNER #define DEFAULT_GAME_BOARD_TYPE BOARD_ENGLISH bool game_board[BOARD_SIZE_ADVANCED][BOARD_SIZE_ADVANCED] = {false}; // true means there's a peg, false means no peg. bool game_board_mask[BOARD_SIZE_ADVANCED][BOARD_SIZE_ADVANCED] = {false}; // true means it's part of the cross, false means not. // Globals that are exposed through game.h int game_moves = 0; int game_board_size = DEFAULT_GAME_BOARD_SIZE; game_board_enum game_board_type = DEFAULT_GAME_BOARD_TYPE; // End of globals that are exposed through game.h static bool valid_index(int i) { return i >= 0 && i < game_board_size; } static bool valid_cell(GdkPoint cell) { return valid_index(cell.x) && valid_index(cell.y); } // The geometric center between two points. static int halfway(int src, int dst) { return src + ((dst - src) / 2); } static GdkPoint middle(GdkPoint src, GdkPoint dst) { return (GdkPoint){halfway(src.x, dst.x), halfway(src.y, dst.y)}; } static void create_game_board_mask(void) { int n = game_board_size; int m = n / 2; // length of one side of the cross assert(n % 2 == 1); assert(m % 2 == 1); // for those keeping score, this means n=3,7,11,15,19... is valid. // initialize game_board_mask memset(game_board_mask, 0, sizeof game_board_mask); // fill the centre row of the cross for (int i = n / 2 - m / 2; i < n - (n / 2 - m / 2); i++) { for (int j = 0; j < game_board_size; j++) { game_board_mask[i][j] = 1; } } // fill the centre column of the cross for (int i = 0; i < game_board_size; i++) { for (int j = n / 2 - m / 2; j < n - (n / 2 - m / 2); j++) { game_board_mask[i][j] = 1; } } if (game_board_type == BOARD_EUROPEAN) { for (int i = n / 2 - m / 1.666; i < n - (n / 2 - m / 1.666); i++) { for (int j = n / 2 - m / 1.666; j < n - (n / 2 - m / 1.666); j++) { game_board_mask[i][j] = 1; } } } } static void game_init(void) { // setup the shape of the game board create_game_board_mask(); // clear the board of all pegs memset(game_board, 0, sizeof game_board); } /* Clears the number of moves, and places a peg in all holes of the board * except for the middle one. */ static void game_clear(void) { memcpy(game_board, game_board_mask, sizeof game_board); game_board[game_board_size / 2][game_board_size / 2] = false; game_moves = 0; } static int game_count_pegs_on_board(void) { int pegs_left = 0; // find the number of pegs on the board for (int i = 0; i < game_board_size; i++) { for (int j = 0; j < game_board_size; j++) { pegs_left += game_board[i][j]; } } return pegs_left; } void game_new(void) { game_init(); game_clear(); } bool is_game_end(void) { // are there any two pegs adjacent in a row? for (int i = 0; i < game_board_size; i++) { for (int j = 0; j < game_board_size - 1; j++) { if (game_board[i][j] && game_board[i][j + 1]) { // great, but is the entire row filled with pegs? for (int k = 0; k < game_board_size; k++) { if (game_board_mask[i][k] && !game_board[i][k]) { return false; // nope, the game is still on. } } } } } // are there any two pegs adjacent in a column? for (int i = 0; i < game_board_size - 1; i++) { for (int j = 0; j < game_board_size; j++) { if (game_board[i][j] && game_board[i + 1][j]) { // great, but is the entire row filled with pegs? for (int k = 0; k < game_board_size; k++) { if (game_board_mask[k][j] && !game_board[k][j]) { return false; // nope, the game is still on. } } } } } // no pegs adjacent. no more moves means it's game over. return true; } void game_toggle_cell(GdkPoint cell) { if (!valid_cell(cell)) return; if (game_board_mask[cell.y][cell.x]) { game_board[cell.y][cell.x] = !game_board[cell.y][cell.x]; } } bool game_is_peg_at(GdkPoint cell) { return valid_cell(cell) && game_board_mask[cell.y][cell.x] && game_board[cell.y][cell.x]; } static bool is_in_mask(GdkPoint cell) { return valid_cell(cell) && game_board_mask[cell.y][cell.x]; } static bool game_is_valid_move(GdkPoint src, GdkPoint dst) { // is it 2 away with a peg in the middle with a peg in it? bool correct_distance = (dst.x == src.x && abs(dst.y - src.y) == 2) || (dst.y == src.y && abs(dst.x - src.x) == 2); return is_in_mask(src) && is_in_mask(dst) && !game_is_peg_at(src) && !game_is_peg_at(dst) && game_is_peg_at(middle(src, dst)) && correct_distance; } // move peg from src to dst, taking intermediate peg out. // presumes that peg from src is already removed bool game_move(GdkPoint src, GdkPoint dst) { if (game_is_valid_move(src, dst)) { // okay, the peg has been taken out of src_x,src_y and is in the air. // it is placed on dst_x,dst_y, and it's a valid move. // this means that the dst_x,dst_y doesn't have a peg in it. // it also means the one tile we jumped over does have a peg in it. // take the jumped peg out. game_toggle_cell(middle(src, dst)); // put the source peg into the destination spot. game_toggle_cell(dst); game_moves++; return true; } return false; } const char *game_cheese(void) { bool center_peg = game_board[game_board_size / 2][game_board_size / 2]; switch (game_count_pegs_on_board()) { case 1: return center_peg ? _("GENIUS!") : _("OUTSTANDING!"); case 2: return _("Sensational!"); case 3: return _("Excellent!"); case 4: return _("Very Good!"); case 5: return _("Not Bad!"); default: return _("Better Luck Next Time!"); } } pegsolitaire-0.3/src/game.h000066400000000000000000000030321341316026400157120ustar00rootroot00000000000000/* * Copyright (C) 2007-2008 Ben Asselstine * Copyright (C) 2017-2018 Juhani Numminen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef PEGSOLITAIRE_GAME_H #define PEGSOLITAIRE_GAME_H #include #include #include typedef enum { BOARD_ENGLISH, BOARD_EUROPEAN } game_board_enum; #define BOARD_SIZE_BEGINNER 7 #define BOARD_SIZE_INTERMEDIATE 11 #define BOARD_SIZE_ADVANCED 15 extern int game_moves; extern game_board_enum game_board_type; extern int game_board_size; extern bool game_board[BOARD_SIZE_ADVANCED][BOARD_SIZE_ADVANCED]; extern bool game_board_mask[BOARD_SIZE_ADVANCED][BOARD_SIZE_ADVANCED]; void game_new(void); bool is_game_end(void); void game_toggle_cell(GdkPoint cell); bool game_is_peg_at(GdkPoint cell); bool game_move(GdkPoint src, GdkPoint dst); const char *game_cheese(void); #endif // PEGSOLITAIRE_GAME_H pegsolitaire-0.3/src/i18n.h000066400000000000000000000020331341316026400155600ustar00rootroot00000000000000/* i18n.h: Gettext convenience macros. * Copyright (C) 2018 Juhani Numminen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef PEGSOLITAIRE_I18N_H #define PEGSOLITAIRE_I18N_H #ifdef ENABLE_NLS #include #else #define gettext(String) (String) #endif #define _(String) gettext(String) #define N_(String) (String) #endif // PEGSOLITAIRE_I18N_H pegsolitaire-0.3/src/main.c000066400000000000000000000052441341316026400157270ustar00rootroot00000000000000/* * Copyright (C) 2007-2008 Ben Asselstine * Copyright (C) 2017-2018 Juhani Numminen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include #include #include #include "callbacks.h" #include "data.h" #include "game.h" #include "i18n.h" #include "render.h" #include "share.h" // Exposed through share.h GtkWidget *pegSolitaireWindow = NULL; GtkAboutDialog *pegSolitaireAboutDialog = NULL; GtkWidget *boardDrawingArea = NULL; GtkLabel *statusMessageLabel = NULL; GtkLabel *statusMovesLabel = NULL; // End of globals exposed through share.h int main(int argc, char *argv[]) { setlocale(LC_ALL, ""); #ifdef ENABLE_NLS bindtextdomain(PACKAGE, LOCALEDIR); bind_textdomain_codeset(PACKAGE, "UTF-8"); textdomain(PACKAGE); #endif const GOptionEntry app_opts[] = {{NULL}}; GError *err = NULL; if (!gtk_init_with_args(&argc, &argv, "", app_opts, PACKAGE, &err)) { fprintf(stderr, _("pegsolitaire: Could not initialize GTK+.\n")); if (err) fprintf(stderr, "%s\n", err->message); return 1; } game_load_resources(); GtkBuilder *builder = gtk_builder_new_from_string(pegsolitaire_glade, -1); gtk_builder_connect_signals(builder, NULL); pegSolitaireWindow = GTK_WIDGET(gtk_builder_get_object(builder, "pegSolitaireWindow")); pegSolitaireAboutDialog = GTK_ABOUT_DIALOG( gtk_builder_get_object(builder, "pegSolitaireAboutDialog")); gtk_about_dialog_set_version(pegSolitaireAboutDialog, VERSION); statusMessageLabel = GTK_LABEL(gtk_builder_get_object(builder, "statusMessageLabel")); statusMovesLabel = GTK_LABEL(gtk_builder_get_object(builder, "statusMovesLabel")); update_statusbar(); boardDrawingArea = GTK_WIDGET(gtk_builder_get_object(builder, "boardDrawingArea")); init_cursors(); game_new(); gtk_widget_show_all(pegSolitaireWindow); /* main loop */ gtk_main(); /* cleanup */ game_unload_resources(); return 0; } pegsolitaire-0.3/src/render.c000066400000000000000000000165461341316026400162710ustar00rootroot00000000000000/* render.c: functions for rendering a peg solitaire game * Copyright (C) 2018 Juhani Numminen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "render.h" #include #include #include #include #include #include #include "callbacks.h" #include "data.h" #include "game.h" #include "i18n.h" #include "share.h" #define GAME_NOT_DRAGGING -1 static int game_dragging_at_x = GAME_NOT_DRAGGING; static int game_dragging_at_y = GAME_NOT_DRAGGING; static bool button_down = false; static GdkPoint dragging_peg = {0, 0}; static GdkCursor *hand_closed_cursor = NULL; static GdkCursor *hand_open_cursor = NULL; static GdkCursor *default_cursor = NULL; static cairo_pattern_t *hole_pattern = NULL; static cairo_pattern_t *peg_pattern = NULL; static double offset_x = 0, offset_y = 0; static double tile_size = 0; static GdkCursor *try_cursor_names(const char *names[]) { GdkDisplay *display = gtk_widget_get_display(pegSolitaireWindow); GdkCursor *cursor = NULL; for (int i = 0; names[i] && !cursor; i++) cursor = gdk_cursor_new_from_name(display, names[i]); if (!cursor) g_warning(_("The \"%s\" cursor is not available"), names[0]); return cursor; } void init_cursors(void) { default_cursor = try_cursor_names((const char *[]){"default", NULL}); hand_closed_cursor = try_cursor_names((const char *[]){"closedhand", "grabbing", NULL}); hand_open_cursor = try_cursor_names((const char *[]){"openhand", "grab", NULL}); } static void set_cursor(GdkCursor *cursor) { gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(boardDrawingArea)), cursor); } static GdkPoint widget_coords_to_cell(int x, int y) { return (GdkPoint){(x - offset_x) / tile_size, (y - offset_y) / tile_size}; } static RsvgHandle *load_svg(const char *str) { GError *err = NULL; RsvgHandle *svg = rsvg_handle_new_from_data((const guint8 *)str, strlen(str), &err); if (err) { GtkDialog *dialog = GTK_DIALOG(gtk_message_dialog_new( NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, _("Something went wrong.\n" "Could not load internal image data:\n" "%s"), err->message)); gtk_window_set_title(GTK_WINDOW(dialog), _("Peg Solitaire")); gtk_dialog_run(dialog); exit(1); } return svg; } static cairo_pattern_t *rsvg_to_pattern(RsvgHandle *svg) { RsvgDimensionData svg_dimensions; rsvg_handle_get_dimensions(svg, &svg_dimensions); cairo_surface_t *surface = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, svg_dimensions.width, svg_dimensions.height); cairo_t *cr = cairo_create(surface); rsvg_handle_render_cairo(svg, cr); cairo_pattern_t *pattern = cairo_pattern_create_for_surface(surface); cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT); cairo_matrix_t scale; cairo_matrix_init_scale(&scale, svg_dimensions.width, svg_dimensions.height); cairo_pattern_set_matrix(pattern, &scale); cairo_destroy(cr); cairo_surface_destroy(surface); g_object_unref(svg); return pattern; } void game_load_resources(void) { hole_pattern = rsvg_to_pattern(load_svg(hole_svg)); peg_pattern = rsvg_to_pattern(load_svg(peg_svg)); } void game_unload_resources(void) { cairo_pattern_destroy(peg_pattern); cairo_pattern_destroy(hole_pattern); } // Following functions are gtk callbacks and all their parameters are required. #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" gboolean drawarea_draw(GtkWidget *widget, cairo_t *cr, gpointer user_data) { int width = gtk_widget_get_allocated_width(widget); int height = gtk_widget_get_allocated_height(widget); double shorter_side = fmin(width, height); offset_x = 0.5 * (width - shorter_side); offset_y = 0.5 * (height - shorter_side); tile_size = shorter_side / game_board_size; cairo_translate(cr, offset_x, offset_y); cairo_scale(cr, tile_size, tile_size); cairo_set_source(cr, hole_pattern); for (int y = 0; y < game_board_size; y++) for (int x = 0; x < game_board_size; x++) if (game_board_mask[y][x]) cairo_rectangle(cr, x, y, 1, 1); cairo_fill(cr); cairo_set_source(cr, peg_pattern); for (int y = 0; y < game_board_size; y++) for (int x = 0; x < game_board_size; x++) if (game_board[y][x]) cairo_rectangle(cr, x, y, 1, 1); cairo_fill(cr); if (game_dragging_at_x != GAME_NOT_DRAGGING) { cairo_translate(cr, (game_dragging_at_x - offset_x) / tile_size - 0.5, (game_dragging_at_y - offset_y) / tile_size - 0.5); cairo_set_source(cr, peg_pattern); cairo_rectangle(cr, 0, 0, 1, 1); cairo_fill(cr); } return FALSE; } gboolean drawarea_motion(GtkWidget *widget, GdkEventMotion *event, gpointer user_data) { GdkPoint cell = widget_coords_to_cell(event->x, event->y); if (button_down) { game_dragging_at_x = event->x; game_dragging_at_y = event->y; gtk_widget_queue_draw(widget); } else if (game_is_peg_at(cell)) { set_cursor(hand_open_cursor); } else { set_cursor(default_cursor); } return FALSE; } gboolean drawarea_button_press(GtkWidget *widget, GdkEventButton *event, gpointer user_data) { if (event->button == 1 && !button_down /* && !is_game_end()*/) { GdkPoint cell = widget_coords_to_cell(event->x, event->y); if (!game_is_peg_at(cell)) return FALSE; game_dragging_at_x = event->x; game_dragging_at_y = event->y; set_cursor(hand_closed_cursor); dragging_peg = cell; button_down = true; game_toggle_cell(cell); gtk_widget_queue_draw(widget); } return FALSE; } gboolean drawarea_button_release(GtkWidget *widget, GdkEventButton *event, gpointer user_data) { if (event->button == 1 && button_down) { button_down = false; game_dragging_at_x = GAME_NOT_DRAGGING; GdkPoint dest = widget_coords_to_cell(event->x, event->y); // Either execute the move or put the peg back where we started. if (game_move(dragging_peg, dest)) { set_cursor(hand_open_cursor); update_statusbar(); if (is_game_end()) { gtk_label_set_text(statusMessageLabel, game_cheese()); } } else { game_toggle_cell(dragging_peg); } gtk_widget_queue_draw(widget); } return FALSE; } #pragma GCC diagnostic pop pegsolitaire-0.3/src/render.h000066400000000000000000000027371341316026400162730ustar00rootroot00000000000000/* render.h: functions for rendering a peg solitaire game * Copyright (C) 2018 Juhani Numminen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef PEGSOLITAIRE_RENDER_H #define PEGSOLITAIRE_RENDER_H #include void init_cursors(void); void game_load_resources(void); void game_unload_resources(void); // The callback functions are explicitly marked for export due to combining // -fvisibility=hidden with -Wl,--export-dynamic. #pragma GCC visibility push(default) gboolean drawarea_draw(GtkWidget *, cairo_t *, gpointer); gboolean drawarea_motion(GtkWidget *, GdkEventMotion *, gpointer); gboolean drawarea_button_press(GtkWidget *, GdkEventButton *, gpointer); gboolean drawarea_button_release(GtkWidget *, GdkEventButton *, gpointer); #pragma GCC visibility pop #endif // PEGSOLITAIRE_GAME_H pegsolitaire-0.3/src/share.h000066400000000000000000000021761341316026400161130ustar00rootroot00000000000000/* share.h: Global variables of pegsolitaire. * Copyright (C) 2018 Juhani Numminen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef PEGSOLITAIRE_SHARE_H #define PEGSOLITAIRE_SHARE_H #include // defined in main.c extern GtkWidget *pegSolitaireWindow; extern GtkAboutDialog *pegSolitaireAboutDialog; extern GtkWidget *boardDrawingArea; extern GtkLabel *statusMessageLabel; extern GtkLabel *statusMovesLabel; #endif // PEGSOLITAIRE_SHARE_H