Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37850699
en ru br
ALT Linux repos
S:0.6-alt6

Group :: Graphical desktop/GNUstep
RPM: gnustep-gmastermind

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

gnustep-gmastermind-0.6/000075500000000000000000000000001227734134500153625ustar00rootroot00000000000000gnustep-gmastermind-0.6/COPYING000064400000000000000000000431311227734134500164170ustar00rootroot00000000000000		    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.
gnustep-gmastermind-0.6/ChangeLog000064400000000000000000000012771227734134500171430ustar00rootroot000000000000002011-07-12 Riccardo Mottola <rm@gnu.org> for Sebastian Reitenbach

* Controller.m:
* View.m
* main.m
c99 fixes and warnings

2011-07-12 Riccardo Mottola <rm@gnu.org>

* Controller.m:
Windows portability

2005-02-04 Marko Riedel <mriedel@neuearbeit.de>

* implemented 3D look

2003-07-05 Chea Laurent <laurent@krystale.net>

* Added French translation

2003-07-05 Fabien Vallon <fabien@tuxfamily.org>

* Switch from #import to #include
* Controller.m : save the Window's & palettes's frame postion
* Controller.m, main.m, GNUmakefile : Add localization support
* Controller.m : use tag instead of title in validateMenu
* Add Licence in files
* New files : ChangeLog, README, gpl.txt


gnustep-gmastermind-0.6/Controller.h000064400000000000000000000034111227734134500176550ustar00rootroot00000000000000/*
Controller.h

window controller class

Copyright (C) 2003 Marko Riedel

Author: Marko Riedel <mriedel@bogus.example.com>
Date: 5 July 2003

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:

Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/


#ifndef _MasterMinds_Controller_H
#define _MasterMinds_Controller_H

#include "Views.h"
#include <Foundation/Foundation.h>
#include <AppKit/NSBox.h>
#include <AppKit/NSFont.h>
#include <AppKit/NSWindow.h>
#include <AppKit/NSMenu.h>

typedef enum {
MENU_NEW_WITH_REP = 500,
MENU_NEW_NO_REP,
MENU_COMMIT,
MENU_MOVE
} MENU_TAG;

@interface Controller : NSObject
{
NSWindow *window;
NSWindow *palette;

int currentRow;

DestinationPeg *pegs[8][4];
Result *res[8];
Peg *sol[4];
BOOL done;

BOOL unique;
int combo[4];
}

-(void)applicationDidFinishLaunching:(NSNotification *)aNotification;

- makeGameWindow;
- makeColorPalette;

- evalCombos:(int *)combo1 and:(int *)combo2
white:(int *)wptr black:(int *)bptr;

- newGameUnique:(BOOL)uniq;

- newGameWithRep:(id)sender;
- newGameNoRep:(id)sender;

- commit:(id)sender;
- move:(id)sender;

- (BOOL)validateMenuItem:(id <NSMenuItem>)menuItem;
@end

#endif
gnustep-gmastermind-0.6/Controller.m000064400000000000000000000264471227734134500177000ustar00rootroot00000000000000/*
Controller.m

window controller class

Copyright (C) 2003 Marko Riedel
Copyright (C) 2011 GNUstep Application Team
Riccardo Mottola

Author: Marko Riedel <mriedel@bogus.example.com>
Date: 5 July 2003

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:

Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/

#include <time.h>
#include <AppKit/NSPanel.h>
#include "Controller.h"

#ifdef __MINGW__
#define srand48 srand
#define lrand48 rand
#endif



@implementation Controller

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification;
{
window = nil;

srand48(time(NULL));

[self makeGameWindow];
[self makeColorPalette];

[self newGameUnique:NO];
}

- makeGameWindow
{
NSRect frame;
NSView *view;
int m = NSTitledWindowMask;
int row, col;
NSBox *boardBox, *solBox;
NSRect contentRect, rectForTitle;

view = [[NSView alloc]
initWithFrame:
NSMakeRect(0, 0, PEGDIMENSION*4,PEGDIMENSION*8)];
for(col=0; col<4; col++){
NSPoint spoint =
NSMakePoint(PEGMARGIN+col*PEGDIMENSION, 0);
Peg *speg =
[[Peg alloc] initAtPoint:spoint];
[view addSubview:speg];
sol[col] = speg;
}

solBox = [[NSBox alloc] init];
[solBox setContentView:view];
[solBox setContentViewMargins:NSMakeSize(PEGMARGIN, PEGMARGIN)];
[solBox setTitle:_(@"Answer")];
[solBox setBorderType:NSGrooveBorder];
[solBox sizeToFit];

view = [[NSView alloc]
initWithFrame:
NSMakeRect(0, PEGDIMENSION+PEGMARGIN,
PEGDIMENSION*4,PEGDIMENSION*8)];

for(row=0; row<8; row++){
NSPoint rpoint =
NSMakePoint(PEGMARGIN+4*PEGDIMENSION+SEPARATOR,
PEGMARGIN+row*PEGDIMENSION);
Result *rview =
[[Result alloc] initAtPoint:rpoint];
[view addSubview:rview];
res[row] = rview;

for(col=0; col<4; col++){
NSPoint dpoint =
NSMakePoint(PEGMARGIN+col*PEGDIMENSION,
PEGMARGIN+row*PEGDIMENSION);
DestinationPeg *dpeg =
[[DestinationPeg alloc] initAtPoint:dpoint];
[view addSubview:dpeg];
pegs[row][col] = dpeg;
}
}

boardBox =
[[NSBox alloc]
initWithFrame:
NSMakeRect(0, PEGMARGIN+2*PEGDIMENSION-3*PEGMARGIN/2, 0, 0)];
[boardBox setContentView:view];
[boardBox setContentViewMargins:NSMakeSize(PEGMARGIN, PEGMARGIN)];
[boardBox setTitle:_(@"Board")];
[boardBox setBorderType:NSGrooveBorder];
[boardBox sizeToFit];

rectForTitle = [[boardBox titleFont] boundingRectForFont];

contentRect.origin = NSMakePoint(0, 0);
contentRect.size =
NSMakeSize([boardBox frame].size.width,
[solBox frame].size.height+
PEGMARGIN+
[boardBox frame].size.height+
rectForTitle.size.height);

view = [[NSView alloc] initWithFrame:contentRect];
[view addSubview:boardBox];
[view addSubview:solBox];

frame = [NSWindow frameRectForContentRect:[view frame]
styleMask:m];

window = [[NSWindow alloc] initWithContentRect:frame
styleMask:m
backing: NSBackingStoreRetained
defer:NO];
[window setMinSize:frame.size];
[window setMaxSize:frame.size];

[window setTitle:_(@"Mastermind")];
[window setDelegate:self];
[window setContentView:view];
[window setReleasedWhenClosed:YES];
// [window setFrame:frame display:YES];

[window setFrameUsingName: @"MasterMindsMain"];
[window setFrameAutosaveName: @"MasterMindsMain"];

// [window setBackgroundColor:[NSColor orangeColor]];
[window orderFrontRegardless];
// RELEASE(view);

// [window center];
// [window orderFrontRegardless];
// [window makeKeyWindow];
// [window display];

return self;
}

- makeColorPalette
{
NSRect frame;
NSView *view;

int m = NSTitledWindowMask;
int rcol, gcol, bcol, index;

view = [[NSView alloc]
initWithFrame:
NSMakeRect(0, 0, PEGDIMENSION*3,PEGDIMENSION*2)];
index = 0;

for(rcol=0; rcol<=1; rcol++){
for(gcol=0; gcol<=1; gcol++){
for(bcol=0; bcol<=1; bcol++){
if(0<index && index<7){
int
x = ((index-1)%3)*PEGDIMENSION,
y = ((index-1)%2)*PEGDIMENSION;
NSPoint spoint = NSMakePoint(x, y);
SourcePeg *speg =
[[SourcePeg alloc] initAtPoint:spoint];
NSColor *col =
[NSColor colorWithDeviceRed:(float)rcol
green:(float)gcol
blue:(float)bcol
alpha:1.0];
[speg setColor:col];
[view addSubview:speg];
}
index++;
}
}
}


frame = [NSWindow frameRectForContentRect:[view frame]
styleMask:m];

palette = [[NSWindow alloc] initWithContentRect:frame
styleMask:m
backing: NSBackingStoreRetained
defer:YES];
[palette setMinSize:frame.size];
[palette setTitle:_(@"Palette")];
[palette setDelegate:self];

// [palette setFrame:frame display:YES];
[palette setMaxSize:frame.size];
[palette setContentView:view];
[palette setReleasedWhenClosed:YES];

// RELEASE(view);

// [palette setBackgroundColor:[NSColor orangeColor]];

[palette setFrameUsingName: @"MasterMindsPalette"];
[palette setFrameAutosaveName: @"MasterMindsPalette"];



// [palette center];
[palette orderFrontRegardless];
[palette makeKeyWindow];
// [palette display];

return self;
}

- evalCombos:(int *)combo1 and:(int *)combo2
white:(int *)wptr black:(int *)bptr;
{
int colcount[8][2];
int col, black, white;

for(col=1; col<7; col++){
colcount[col][0] = 0;
colcount[col][1] = 0;
}

for(col=0; col<4; col++){
colcount[combo1[col]][0]++;
colcount[combo2[col]][1]++;
}

white = 0;
for(col=1; col<7; col++){
int smaller =
(colcount[col][0]>colcount[col][1] ? 1 : 0);
white += colcount[col][smaller];
}

black = 0;
for(col=0; col<4; col++){
if(combo1[col]==combo2[col]){
black++;
}
}
white -= black;

*wptr = white;
*bptr = black;

return self;
}

#define DOUBLES(__combo) \
(__combo[0] == __combo[1] || \
__combo[0] == __combo[2] || \
__combo[0] == __combo[3] || \
__combo[1] == __combo[2] || \
__combo[1] == __combo[3] || \
__combo[2] == __combo[3])


- newGameUnique:(BOOL)uniq
{
int row, col;

for(row=0; row<8; row++){
[res[row] setBlack:0 andWhite:0];

for(col=0; col<4; col++){
[pegs[row][col] setColor:nil];
[pegs[row][col] setActive:(row==7 ? YES : NO)];
}
}

for(col=0; col<4; col++){
[sol[col] setColor:nil];
}

currentRow = 7;

do {
combo[0] = 1+(lrand48()%6);
combo[1] = 1+(lrand48()%6);
combo[2] = 1+(lrand48()%6);
combo[3] = 1+(lrand48()%6);
} while(uniq==YES && DOUBLES(combo));

unique = uniq;
done = NO;

[window
setTitle:
(unique==NO ?
_(@"Mastermind (with replacement)") :
_(@"Mastermind (without replacement)"))];

return self;
}

- newGameWithRep:(id)sender
{
return [self newGameUnique:NO];
}

- newGameNoRep:(id)sender
{
return [self newGameUnique:YES];
}


- commit:(id)sender
{
int col;
int aCombo[4];
float thecomps[4];
int white, black;

for(col=0; col<4; col++){
NSColor *color = [pegs[currentRow][col] color];
if(color==nil){
NSRunAlertPanel(_(@"Alert"), _(@"All four colors must be set."),
_(@"OK"), nil, nil);
return self;
}

[color getRed:thecomps green:thecomps+1 blue:thecomps+2
alpha:thecomps+3];
aCombo[col] =
(thecomps[0]==1.0 ? 4 : 0) +
(thecomps[1]==1.0 ? 2 : 0) +
(thecomps[2]==1.0 ? 1 : 0);
}

if(unique==YES && DOUBLES(aCombo)){
NSRunAlertPanel(_(@"Alert"), _(@"No double colors, please."),
_(@"OK"), nil, nil);
return self;
}

for(col=0; col<4; col++){
[pegs[currentRow][col] setActive:NO];
}

[self evalCombos:combo and:aCombo
white:&white black:&black];

[res[currentRow] setBlack:black andWhite:white];

currentRow--;
if(black==4){
done = YES;
NSRunAlertPanel(_(@"Congratulations!"), _(@"You win."),
_(@"OK"), nil, nil);
}
else if(currentRow<0){
done = YES;
NSRunAlertPanel(_(@"Game over."), _(@"You lose."),
_(@"OK"), nil, nil);
}
else{
for(col=0; col<4; col++){
[pegs[currentRow][col] setActive:YES];
}
}

if(done==YES){
for(col=0; col<4; col++){
int c = combo[col];
NSColor *color =
[NSColor colorWithDeviceRed:(float)(c & 4 ? 1 : 0)
green:(float)(c & 2 ? 1 : 0)
blue:(float)(c & 1 ? 1 : 0)
alpha:1.0];
[sol[col] setColor:color];
}
}

return self;
}

- move:(id)sender
{
int upper = 6*6*6*6, current, cur, testit[4], prev[4];
int row, black, white, pblack, pwhite, col;

for(current=0; current<upper; current++){
cur = current;
for(col=0; col<4; col++){
testit[col] = 1+cur%6; cur /= 6;
}

if(unique==YES && DOUBLES(testit)){
continue;
}

for(row=7; row>currentRow; row--){
for(col=0; col<4; col++){
prev[col] = [pegs[row][col] cvalue];
}

[self evalCombos:(int *)testit and:(int *)prev
white:&white black:&black];
[res[row] getBlack:&pblack andWhite:&pwhite];

if(pblack!=black || pwhite!=white){
break;
}
}

if(row==currentRow){
break;
}
}

for(col=0; col<4; col++){
[pegs[currentRow][col] setCValue:testit[col]];
}

[self commit:nil];

return self;
}


- (BOOL)validateMenuItem:(id <NSMenuItem>)menuItem;
{
int tag = [menuItem tag];
if (done == YES &&
( (tag == MENU_MOVE) ||(tag == MENU_COMMIT) ) )
{

return NO;
}

return YES;
}

@end
gnustep-gmastermind-0.6/French.lproj/000075500000000000000000000000001227734134500177145ustar00rootroot00000000000000gnustep-gmastermind-0.6/French.lproj/Localizable.strings000064400000000000000000000035141227734134500235530ustar00rootroot00000000000000/***
French.lproj/Localizable.strings
updated by make_strings 2003-07-05 14:17:43 +0000
add comments above this one
***/


/*** Keys found in multiple places ***/

/* File: Controller.m:298 */
/* Flag: untranslated */
/* File: Controller.m:323 */
/* Flag: untranslated */
/* File: Controller.m:328 */
/* Flag: untranslated */
"OK" = "OK";


/*** Unmatched/untranslated keys ***/

/* File: main.m:73 */
/* Flag: untranslated */
"Game" = "Jeu";

"Mastermind (with replacement)" = "Mastermind (avec replacement)";
"Mastermind (without replacement)" = "Mastermind (sans replacement)";

/*** Strings from Controller.m ***/
/* File: Controller.m:297 */
"Alert" = "Alerte";
/* File: Controller.m:297 */
"All four colors must be set." = "Les 4 couleurs doivent être positionnées.";
"No double colors, please." = "Les 4 couleurs doivent être differentes.";
/* File: Controller.m:72 */
"Answer" = "Réponse";
/* File: Controller.m:107 */
"Board" = "Tableau";
/* File: Controller.m:322 */
"Congratulations!" = "Félicitations!";
/* File: Controller.m:327 */
"Game over." = "Game over.";
/* File: Controller.m:131 */
"Mastermind" = "Mastermind";
/* File: Controller.m:198 */
"Palette" = "Palette";
/* File: Controller.m:327 */
"You lose." = "Vous avez perdu.";
/* File: Controller.m:322 */
"You win." = "Vous avez gagné.";


/*** Strings from main.m ***/
/* File: main.m:85 */
"Commit" = "Essayer";
/* File: main.m:68 */
"Help..." = "Aide...";
/* File: main.m:99 */
"Hide" = "Masquer";
/* File: main.m:57 */
"Info" = "Informations";
/* File: main.m:62 */
"Info Panel..." = "Panneau d'informations...";
/* File: main.m:92 */
"Move" = "Déplacer";
/* File: main.m:79 */
"New game" = "Nouveau jeu";
"With replacement" = "Avec replacement";
"Without replacement" = "Sans replacement";
/* File: main.m:65 */
"Preferences..." = "Préférences...";
/* File: main.m:104 */
"Quit" = "Quitter";
gnustep-gmastermind-0.6/GMastermindInfo.plist000064400000000000000000000006001227734134500214610ustar00rootroot00000000000000{
ApplicationName = "GMastermind";
ApplicationDescription = "GNUstep mastermind game";
ApplicationRelease = "0.6";
FullVersionID = "0.6";
Authors = ("Marko Riedel <mriedel@neuearbeit.de>");
Copyright = "Copyright (C) 2002-2011 Free Software Foundation, Inc.";
CopyrightDescription = "Released under the GNU General Public License 2.0";
NSIcon = "GMastermind.tiff";
}

gnustep-gmastermind-0.6/GNUmakefile000064400000000000000000000012341227734134500174340ustar00rootroot00000000000000
include $(GNUSTEP_MAKEFILES)/common.make

# The application to be compiled
VERSION = 0.6
PACKAGE_NAME = GMastermind
APP_NAME = GMastermind
GMastermind_APPLICATION_ICON = GMastermind.tiff

# The Objective-C source files to be compiled

GMastermind_OBJC_FILES = main.m \
Controller.m \
Views.m


GMastermind_LOCALIZED_RESOURCE_FILES = Localizable.strings

GMastermind_LANGUAGES = French


SHARED_CFLAGS += -g

# The Resource files to be copied into the app's resources directory
GMastermind_RESOURCE_FILES = Resources/*

-include GNUmakefile.preamble

-include GNUmakefile.local

include $(GNUSTEP_MAKEFILES)/application.make

-include GNUmakefile.postamble

gnustep-gmastermind-0.6/README000064400000000000000000000003261227734134500162430ustar00rootroot00000000000000GMasterMind is the classic mastermind
It require GNUstep core ( http://www.gnustep.org )

GMastermind is relased under GNU Gneneral Public Licence 2.0 (see gpl.txt)


INSTALL :
make
make install (su if need)

gnustep-gmastermind-0.6/Resources/000075500000000000000000000000001227734134500173345ustar00rootroot00000000000000gnustep-gmastermind-0.6/Resources/GMastermind.tiff000064400000000000000000000224641227734134500224300ustar00rootroot00000000000000II*$ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ½ºµÿ½¾½ÿ½º½ÿµ¶µÿ­®­ÿ­ª­ÿ¥¢¥ÿ¥¢¥ÿ­ª¥ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­¦œÿ{usÿZYZÿJIJÿJMJÿRQRÿZ]ZÿsqsÿŒŽŒÿ­ª¥ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ½ºµÿÆËÆÿƾ½ÿµ²µÿ­®¥ÿ­ª¥ÿ¥¢¥ÿ”–”ÿ”’”ÿ”–”ÿœš”ÿ¥¢œÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ„‚{ÿBA9ÿ101ÿ),)ÿ9<9ÿJIBÿJMJÿJMJÿJMJÿZYZÿsqsÿœš”ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿ­ª­ÿ­ª­ÿÆýÿÎËÎÿ½¶µÿ”’”ÿJMJÿ!$!ÿÿÿÿ9<9ÿkicÿ{}{ÿ”’Œÿœšœÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª¥ÿkmkÿ),)ÿ! !ÿBABÿ„}sÿ”–”ÿ­¦œÿ­¦œÿ¥ž”ÿŒŽ„ÿkicÿZYZÿkicÿ”’Œÿ­ª­ÿ­ª­ÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿ­ª­ÿÆÇÆÿÞÛÞÿ½¾½ÿcecÿÿÿÿÿÿÿÿÿBABÿsqsÿ„‚{ÿ”’Œÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿkeZÿÿ! ÿceZÿ­ªœÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿŒŠ„ÿkmkÿsusÿœ–Œÿ­ª­ÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿ½ºµÿÎËÆÿÎËÎÿ989ÿÿÿÿÿÿÿÿÿÿÿ! !ÿkqkÿ„‚{ÿœš”ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ„‚{ÿ),)ÿ! !ÿŒ†{ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ¥žœÿ{}{ÿsysÿ¥¢œÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿÎËÆÿ½¶µÿRURÿÿÿÿÿÿÿÿÿÿÿÿÿ),)ÿcecÿ{ysÿ­ª¥ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ªœÿB<9ÿ!$!ÿkmkÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ”šŒÿsusÿŒŽŒÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿµ¶µÿ½¾½ÿ”–”ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿJIJÿkmkÿ”’”ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ„†„ÿ101ÿBA9ÿ­ªœÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿŒŠŒÿ{‚{ÿ¥¦¥ÿÿÿÿÿÿÿÿÿÿÿ½º½ÿµ²­ÿJMJÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ!$!ÿZ]Zÿ{y{ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿcaZÿ101ÿsysÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ¥¢œÿ„†„ÿ¥¢¥ÿÿÿÿÿÿÿÿÿÿÿ½º½ÿ­ª¥ÿ! !ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿRUJÿcecÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿJMJÿ9<9ÿœš”ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª¥ÿ”–”ÿ¥¢¥ÿÿÿÿÿÿÿÿÿÿÿµ¶µÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿJIJÿRURÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿJMJÿJIJÿ­ªœÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ¥¦¥ÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿ­®­ÿ¥¢¥ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿBEBÿJMJÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿRQRÿJMJÿ­ªœÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­®­ÿµ²µÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿ”–”ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ9A9ÿRQRÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿZ]ZÿJQJÿœžœÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­®­ÿ¥¦¥ÿµ²µÿÿÿÿÿÿÿÿÿÿÿ¥¦¥ÿ”’Œÿ9<9ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿB<9ÿcecÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ{ysÿRQJÿ„Ž„ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿµ²­ÿ¥¢¥ÿ½ºµÿÿÿÿÿÿÿÿÿÿÿ¥¦¥ÿ”–”ÿkikÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ! !ÿBEBÿ„†„ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ”’”ÿRYRÿkmkÿ­ª¥ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿµ¶µÿ­ª¥ÿµ¶µÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿœš”ÿ{}{ÿ141ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ1,)ÿJIBÿ­ªœÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª¥ÿsqsÿZ]ZÿŒŠ„ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿµ¶µÿ­®­ÿÆýÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿ¥¢œÿ”ŽŒÿsysÿ! !ÿÿÿÿÿÿÿÿÿÿÿÿÿBEBÿ„‚{ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿœš”ÿkikÿsqsÿ¥žœÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ½ºµÿÎÏÎÿµ¶µÿ½ºµÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿ­ª­ÿœ–”ÿ„‚{ÿcicÿ141ÿÿÿÿÿÿÿÿÿÿÿ!$!ÿkecÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ”Ž„ÿsusÿ{y{ÿ”–Œÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿµºµÿÆÇÆÿÖÓÖÿÆýÿ­ª­ÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿ­ª­ÿ­ª­ÿ”–”ÿ„}{ÿcecÿBIBÿ!$!ÿ ÿÿÿ ÿÿ! !ÿ),)ÿBA9ÿsmkÿ­ª¥ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ”–”ÿ{y{ÿsusÿŒŽŒÿ­¦œÿ­ª¥ÿ­ª­ÿ­ª­ÿ­®­ÿ½¶­ÿµ¶µÿ­®­ÿµ¶µÿƾ½ÿ­ª­ÿ­ª­ÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿœš”ÿ{y{ÿkikÿZ]ZÿRQRÿJIJÿBEBÿ9<9ÿ9<9ÿ9A9ÿJIBÿ„‚{ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ¥¢œÿ”’”ÿ„†„ÿ„†„ÿ”–”ÿ¥¦¥ÿ­®­ÿ­ª¥ÿ¥¢œÿ­®­ÿ½¾½ÿ½ºµÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª¥ÿŒŽŒÿsqsÿcaZÿRURÿRQRÿRMJÿZYZÿ{usÿ­¦œÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª¥ÿ¥¢¥ÿ¥¢¥ÿ¥¦¥ÿ­ª­ÿ­®­ÿµ¶µÿ½º½ÿ½ºµÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ½ºµÿ½¾½ÿ½º½ÿµ¶µÿ­®­ÿ­ª­ÿ¥¢¥ÿ¥¢¥ÿ­ª¥ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ½ºµÿ½¾½ÿ½º½ÿµ¶µÿ­®­ÿ­ª­ÿ¥¢¥ÿ¥¢¥ÿ­ª¥ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ½ºµÿÆËÆÿÎËÆÿÆÇÆÿÆÃÆÿ½º½ÿµ¶µÿµ²­ÿ­ª­ÿ¥¢œÿœš”ÿ¥¢œÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ½ºµÿÆËÆÿÎËÆÿÆÇÆÿÆÃÆÿ½º½ÿµ¶µÿµ²­ÿ­ª­ÿ¥¢œÿœš”ÿ¥¢œÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿ­ª­ÿ­ª­ÿÆýÿÖÏÎÿÞÛÖÿÞßÞÿïëçÿ÷óïÿÿûïÿÿûïÿ÷óçÿÞÛÖÿ½¶­ÿœžœÿ”–Œÿœšœÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿÆýÿÖÏÎÿÞÛÖÿÞßÞÿïëçÿ÷óïÿÿûïÿÿûïÿ÷óçÿÞÛÖÿ½¶­ÿœžœÿ”–Œÿœšœÿ­ª­ÿ­ª­ÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿ­ª­ÿÆÇÆÿçãçÿçãçÿïïçÿÿÿïÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿïÿÎ˽ÿœ–”ÿ„†„ÿ”’Œÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿÆÇÆÿçãçÿçãçÿïïçÿÿÿïÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿïÿÎ˽ÿœ–”ÿ„†„ÿ”’Œÿ­ª­ÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿ½ºµÿÖÏÎÿçãÞÿÿûçÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞßÎÿŒŠ„ÿŒ†„ÿœš”ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ½ºµÿÖÏÎÿçãÞÿÿûçÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞßÎÿŒŠ„ÿŒ†„ÿœš”ÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿÎËÆÿÞ×Öÿ÷ïçÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÎ˵ÿ„†„ÿ{ysÿ­ª¥ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿÎËÆÿÞ×Öÿ÷ïçÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÎ˵ÿ„†„ÿ{ysÿ­ª¥ÿÿÿÿÿÿÿÿÿÿÿµ¶µÿÎÇÆÿÞßÖÿÿÿïÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿïÿ”–”ÿ{usÿ”’”ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿµ¶µÿÎÇÆÿÞßÖÿÿÿïÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿïÿ”–”ÿ{usÿ”’”ÿÿÿÿÿÿÿÿÿÿÿ½º½ÿÆÇÆÿïëçÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÆýÿsusÿ{y{ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ½º½ÿÆÇÆÿïëçÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÆýÿsusÿ{y{ÿÿÿÿÿÿÿÿÿÿÿ½º½ÿÆÃÆÿÿ÷ïÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿçãÞÿkmcÿcecÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ½º½ÿÆÃÆÿÿ÷ïÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿçãÞÿkmcÿcecÿÿÿÿÿÿÿÿÿÿÿµ¶µÿ½º½ÿÿÿïÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿûïÿZ]ZÿRURÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿµ¶µÿ½º½ÿÿÿïÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿûïÿZ]ZÿRURÿÿÿÿÿÿÿÿÿÿÿ­®­ÿµ¶­ÿÿÿïÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿûïÿRURÿJMJÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­®­ÿµ¶­ÿÿÿïÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿûïÿRURÿJMJÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿµ®­ÿïïïÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞßÞÿZYRÿRQRÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿµ®­ÿïïïÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÞßÞÿZYRÿRQRÿÿÿÿÿÿÿÿÿÿÿ¥¦¥ÿ­ª¥ÿÞÛÎÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿµ²¥ÿRURÿcecÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ¥¦¥ÿ­ª¥ÿÞÛÎÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿµ²¥ÿRURÿcecÿÿÿÿÿÿÿÿÿÿÿ¥¦¥ÿ¥žœÿµ²­ÿÿÿïÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿïÿkicÿJMJÿ„†„ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ¥¦¥ÿ¥žœÿµ²­ÿÿÿïÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿïÿkicÿJMJÿ„†„ÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿœš”ÿœžœÿÖÓÆÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ­ª”ÿRMJÿJIBÿ­ªœÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿœš”ÿœžœÿÖÓÆÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ­ª”ÿRMJÿJIBÿ­ªœÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿ¥¢œÿ”’Œÿ”’ŒÿÞßÎÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÆǵÿ141ÿJIJÿ„‚{ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ¥¢œÿ”’Œÿ”’ŒÿÞßÎÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÆǵÿ141ÿJIJÿ„‚{ÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿ­ª­ÿœ–”ÿ„†„ÿŒŽŒÿ½¾µÿÿÿïÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿïÿœš”ÿ9<9ÿ)()ÿkecÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿœ–”ÿ„†„ÿŒŽŒÿ½¾µÿÿÿïÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿïÿœš”ÿ9<9ÿ)()ÿkecÿ­ª­ÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿ­ª­ÿ­ª­ÿ”–”ÿ„†{ÿ„†„ÿ”–ŒÿÆýÿçãÖÿ÷÷ïÿ÷÷ïÿÞÛÖÿµ²­ÿkmkÿJMJÿJIBÿsmkÿ­ª¥ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ”–”ÿ„†{ÿ„†„ÿ”–ŒÿÆýÿçãÖÿ÷÷ïÿ÷÷ïÿÞÛÖÿµ²­ÿkmkÿJMJÿJIBÿsmkÿ­ª¥ÿ­ª­ÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿœš”ÿ{y{ÿsusÿsqsÿkikÿZ]ZÿRUJÿRURÿZUJÿJMJÿJIBÿ„‚{ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿœš”ÿ{y{ÿsusÿsqsÿkikÿZ]ZÿRUJÿRURÿZUJÿJMJÿJIBÿ„‚{ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª¥ÿŒŽŒÿsqsÿcaZÿRURÿRQRÿRMJÿZYZÿ{usÿ­¦œÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª¥ÿŒŽŒÿsqsÿcaZÿRURÿRQRÿRMJÿZYZÿ{usÿ­¦œÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿ­ª­ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿþ00æ$ î$%@$$%,%(R/home/gnustep/GMastermind2.tiffCreated with The GIMPÍûGÍûGgnustep-gmastermind-0.6/Views.h000064400000000000000000000040531227734134500166320ustar00rootroot00000000000000/*
Views.h

Main View class

Copyright (C) 2003 Marko Riedel

Author: Marko Riedel <mriedel@bogus.example.com>
Date: 5 July 2003

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:

Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/

#ifndef _MasterMinds_Views_H
#define _MasterMinds_Views_H

#include <AppKit/NSDragging.h>
#include <AppKit/NSView.h>
#include <AppKit/NSColor.h>


#define PEGDIMENSION 48 // 40
#define DRAGDIMENSION (PEGDIMENSION/2)

#define PEGMARGIN 8 // 6

#define SEPARATOR 60

@interface Result : NSView
{
int black, white;
}

- initAtPoint:(NSPoint)aPoint;

- getBlack:(int *)bptr andWhite:(int *)wptr;
- setBlack:(int)bval andWhite:(int)wval;

- (void)drawRect:(NSRect)aRect;

@end

@interface Peg : NSView
{
NSColor *color;
int cvalue;
}

- initAtPoint:(NSPoint)aPoint;

- color;
- setColor:(NSColor *)aColor;

- (int)cvalue;
- setCValue:(int)cval;

- (void)drawRect:(NSRect)aRect;

@end

@interface SourcePeg : Peg

- (unsigned int)draggingSourceOperationMaskForLocal:(BOOL)flag;

- makeDragImageForColor:(int)val withComponents:(float *)thecomps;

- (void)mouseDown:(NSEvent *)theEvent;

@end

@interface DestinationPeg : SourcePeg
{
BOOL active;
}

- initAtPoint:(NSPoint)aPoint;

- setActive:(BOOL)flag;

- (void)drawRect:(NSRect)aRect;


- (unsigned int)draggingEntered:(id <NSDraggingInfo>)sender;

- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender;
- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender;

@end

#endif

gnustep-gmastermind-0.6/Views.m000064400000000000000000000247251227734134500166470ustar00rootroot00000000000000/*
Views.m

Main View class

Copyright (C) 2003 Marko Riedel

Author: Marko Riedel <mriedel@bogus.example.com>
Date: 5 July 2003

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:

Free Software Foundation, Inc.
59 Temple Place - Suite 330
Boston, MA 02111-1307, USA
*/


#include "Views.h"

#include <AppKit/PSOperators.h>
#include <AppKit/NSGraphics.h>
#include <AppKit/NSBezierPath.h>
#include <AppKit/NSPasteboard.h>
#include <AppKit/NSImage.h>
#include <AppKit/NSEvent.h>

#include <math.h>

void shadow(float x, float y, float r)
{
int angle;
PSsetlinewidth(2.0);

for(angle=132; angle<492; angle+=6){
float gray =
(angle < 312 ? 0.9-(float)(angle-132)/180.0*0.8 :
0.1+(float)(angle-312)/180.0*0.8);
PSsetgray(gray);
PSarc(x, y, r, angle, angle+6);
PSstroke();
}
}

void shadow2(float x, float y, float r)
{
int angle;
PSsetlinewidth(2.0);

for(angle=312; angle<672; angle+=6){
float gray =
(angle < 492 ? 0.9-(float)(angle-312)/180.0*0.8 :
0.1+(float)(angle-492)/180.0*0.8);
PSsetgray(gray);
PSarc(x, y, r, angle, angle+6);
PSstroke();
}
}

void tile(NSRect rect)
{
NSRectEdge sides[] = {
NSMinXEdge, NSMaxXEdge, NSMinYEdge, NSMaxYEdge,
NSMinXEdge, NSMaxXEdge, NSMinYEdge, NSMaxYEdge};
float grays[] = {
NSWhite, NSBlack, NSBlack, NSWhite,
NSWhite, NSBlack, NSBlack, NSWhite};
NSDrawTiledRects(rect, rect, sides, grays, 8);
}

@implementation Result

- initAtPoint:(NSPoint)aPoint
{
NSRect frame;

frame.origin = aPoint;
frame.size.width = frame.size.height = PEGDIMENSION;

[super initWithFrame:frame];

black = white = 0;

return self;
}

- getBlack:(int *)bptr andWhite:(int *)wptr;
{
*bptr = black; *wptr = white;

return self;
}

- setBlack:(int)bval andWhite:(int)wval
{
black = bval; white = wval;
[self setNeedsDisplay:YES];
return self;
}

- (void)drawRect:(NSRect)aRect
{
int index;
tile([self bounds]);

for(index=0; index<4; index++){
float
x = PEGDIMENSION/4+(index%2)*PEGDIMENSION/2,
y = PEGDIMENSION/4+(index/2)*PEGDIMENSION/2;
NSColor *col =
(index<white ?
[NSColor whiteColor] : [NSColor blackColor]);

if(index<white+black){
[col set];
PSarc(x, y, PEGDIMENSION/5, 0, 360);
PSfill();
shadow(x, y, PEGDIMENSION/5);
}
else{
PSsetlinewidth(1.0);
[[NSColor blackColor] set];
PSarc(x, y, PEGDIMENSION/5, 0, 360);
PSstroke();
shadow2(x, y, PEGDIMENSION/5);
}
}
}

@end

@implementation Peg

- initAtPoint:(NSPoint)aPoint
{
NSRect frame;

frame.origin = aPoint;
frame.size.width = frame.size.height = PEGDIMENSION;

[super initWithFrame:frame];

color = nil;

return self;
}

- color
{
return color;
}

- setColor:(NSColor *)aColor
{
float thecomps[4];

if(color!=nil){
[color release];
}
color = aColor;
[color retain];

if(color==nil){
cvalue = 0;
}
else{
[color getRed:thecomps
green:thecomps+1
blue:thecomps+2
alpha:thecomps+3];

cvalue =
(thecomps[0]==1.0 ? 4 : 0) +
(thecomps[1]==1.0 ? 2 : 0) +
(thecomps[2]==1.0 ? 1 : 0);
}

[self setNeedsDisplay:YES];

return self;
}

- (int)cvalue
{
return cvalue;
}

- setCValue:(int)cval
{
float thecomps[3];

if(color!=nil){
[color release];
}

if(!cval){
cvalue = 0;
color = nil;
return self;
}

cvalue = cval;

thecomps[0] = (cvalue & 4 ? 1.0 : 0.0);
thecomps[1] = (cvalue & 2 ? 1.0 : 0.0);
thecomps[2] = (cvalue & 1 ? 1.0 : 0.0);

color = [NSColor colorWithDeviceRed:thecomps[0]
green:thecomps[1]
blue:thecomps[2]
alpha:1.0];

[color retain];

return self;
}


#define RAD2 (PEGDIMENSION-2*PEGMARGIN)
- (void)drawRect:(NSRect)aRect
{
if(color!=nil){
[color set];
PSarc(PEGDIMENSION/2, PEGDIMENSION/2,
PEGDIMENSION/2-PEGMARGIN, 0, 360);
PSfill();

shadow(PEGDIMENSION/2, PEGDIMENSION/2,
PEGDIMENSION/2-PEGMARGIN);
}
else{
shadow2(PEGDIMENSION/2, PEGDIMENSION/2,
PEGDIMENSION/2-PEGMARGIN);
}

tile([self bounds]);
}

@end

@implementation SourcePeg

- (unsigned int)draggingSourceOperationMaskForLocal:(BOOL)flag
{
return NSDragOperationCopy;
}

static NSImage *dragImages[8] = {
nil, nil, nil, nil,
nil, nil, nil, nil
};

- makeDragImageForColor:(int)val withComponents:(float *)thecomps
{
NSImage *dragImage =
[[NSImage alloc]
initWithSize:NSMakeSize(PEGDIMENSION/2, PEGDIMENSION/2)];
NSBitmapImageRep *rep;
unsigned char *base, *data;
int x, y;
float rsq, rsq1, d, dx, dy;

rsq = DRAGDIMENSION/2-2; rsq *= rsq;
rsq1 = DRAGDIMENSION/2; rsq1 *= rsq1;

rep = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:NULL
pixelsWide:DRAGDIMENSION
pixelsHigh:DRAGDIMENSION
bitsPerSample:8
samplesPerPixel:4
hasAlpha:YES
isPlanar:NO
colorSpaceName:NSDeviceRGBColorSpace
bytesPerRow:DRAGDIMENSION*4
bitsPerPixel:32];
data = [rep bitmapData];

for(x=0; x<DRAGDIMENSION; x++){
for(y=0; y<DRAGDIMENSION; y++){
float ccomps[4];

dx = x-DRAGDIMENSION/2;
dy = y-DRAGDIMENSION/2;

d = dx*dx+dy*dy;

if(d<rsq){
ccomps[0] = thecomps[0];
ccomps[1] = thecomps[1];
ccomps[2] = thecomps[2];
ccomps[3] = 1.0;
}
else if(d<rsq1){
float gray;
float angle = (atan2(dy, -dx)+M_PI)/M_PI*180.0;
if(angle<132.0){
angle += 360.0;
}
angle -= (float)(((int)angle)%6);

gray =
(angle < 312.0 ? 0.9-(angle-132.0)/180.0*0.8 :
0.1+(float)(angle-312.0)/180.0*0.8);

ccomps[0] = gray;
ccomps[1] = gray;
ccomps[2] = gray;
ccomps[3] = 1.0;
}
else{
ccomps[0] = 0;
ccomps[1] = 0;
ccomps[2] = 0;
ccomps[3] = 0;
}

base = data+y*DRAGDIMENSION*4+x*4;
base[0] = (int)(ccomps[0]*255.0);
base[1] = (int)(ccomps[1]*255.0);
base[2] = (int)(ccomps[2]*255.0);
base[3] = (int)(ccomps[3]*255.0);
}
}

[dragImage addRepresentation:rep];
[dragImage retain];

dragImages[val] = dragImage;
return self;
}

- (void)mouseDown:(NSEvent *)theEvent
{
NSEventType theType = [theEvent type];
NSPoint startp;
float dx, dy, rsq, thecomps[4];

if(color==nil){
return;
}

startp = [theEvent locationInWindow];
startp = [self convertPoint:startp fromView: nil];

dx = startp.x-PEGDIMENSION/2;
dy = startp.y-PEGDIMENSION/2;

rsq = PEGDIMENSION/2-PEGMARGIN; rsq *= rsq;

if(dx*dx+dy*dy<rsq && theType==NSLeftMouseDown){
NSPasteboard *pboard =
[NSPasteboard pasteboardWithName:NSDragPboard];

[pboard declareTypes:
[NSArray arrayWithObjects:NSColorPboardType, nil]
owner:self];
[color writeToPasteboard:pboard];

thecomps[0] = (cvalue & 4 ? 1.0 : 0.0);
thecomps[1] = (cvalue & 2 ? 1.0 : 0.0);
thecomps[2] = (cvalue & 1 ? 1.0 : 0.0);

if(dragImages[cvalue]==nil){
[self makeDragImageForColor:cvalue
withComponents:thecomps];
}

[self dragImage:dragImages[cvalue]
at:NSMakePoint(PEGDIMENSION/4, PEGDIMENSION/4)
offset:NSMakeSize(0, 0)
event:theEvent
pasteboard:pboard
source:self
slideBack:YES];
}

return;
}

@end

@implementation DestinationPeg

- initAtPoint:(NSPoint)aPoint
{
[super initAtPoint:aPoint];

active = YES;
[self registerForDraggedTypes:
[NSArray arrayWithObjects:NSColorPboardType, nil]];

return self;
}

- setActive:(BOOL)flag
{
if(flag!=active){
[self setNeedsDisplay:YES];
}
active = flag;
return self;
}

- (void)drawRect:(NSRect)aRect
{
[super drawRect:aRect];

if(active==YES){
NSRect bounds = [self bounds];
bounds.origin.x += 2.0;
bounds.origin.y += 2.0;
bounds.size.width -= 4.0;
bounds.size.height -= 4.0;

tile(bounds);
}
}

- (unsigned int)draggingEntered:(id <NSDraggingInfo>)sender
{
NSPasteboard *pb;
NSDragOperation sourceDragMask;

if(active==NO){
return NSDragOperationNone;
}

sourceDragMask = [sender draggingSourceOperationMask];
pb = [sender draggingPasteboard];

if([[pb types] indexOfObject:NSColorPboardType]!=NSNotFound){
if(sourceDragMask & NSDragOperationCopy){
NSColor *col = [NSColor colorFromPasteboard:pb], *rgb;
float ccomps[4];

rgb = [col colorUsingColorSpaceName:NSDeviceRGBColorSpace];

[rgb getRed:ccomps green:ccomps+1 blue:ccomps+2
alpha:ccomps+3];

if((ccomps[0]==0.0 || ccomps[0]==1.0) &&
(ccomps[1]==0.0 || ccomps[1]==1.0) &&
(ccomps[2]==0.0 || ccomps[2]==1.0) &&
ccomps[3]==1.0){
float s = ccomps[0]+ccomps[1]+ccomps[2];
if(s==1.0 || s==2.0){
return NSDragOperationCopy;
}
}
}
}

return NSDragOperationNone;
}

- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
NSPasteboard *pb = [sender draggingPasteboard];
NSColor *rgb;

rgb = [[NSColor colorFromPasteboard:pb]
colorUsingColorSpaceName:NSDeviceRGBColorSpace];
[self setColor:rgb];

return YES;
}



- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
{
return YES;
}


@end
gnustep-gmastermind-0.6/main.m000064400000000000000000000074051227734134500164720ustar00rootroot00000000000000/*
* main.m: main function of Fractal.app
*
* Copyright (c) 2002 Free Software Foundation, Inc.
*
* Author: Marko Riedel
* Date: May 2002
*
* With code fragments from MemoryPanel, ImageViewer, Finger, GDraw
* and GShisen.
*
* This sample program is part of GNUstep.
*
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include <Foundation/Foundation.h>
#include <AppKit/AppKit.h>

#include "Controller.h"

int main(int argc, const char **argv, char** env)
{
NSAutoreleasePool *pool;
NSApplication *app;
NSMenu *mainMenu, *menu, *newGameMenu;
NSMenuItem *menuItem, *gameMenuItem,
*commitMenuItem, *moveMenuItem;
Controller *controller;

pool = [NSAutoreleasePool new];
app = [NSApplication sharedApplication];

//
// Create the Menu
//

// Main Menu
mainMenu = AUTORELEASE ([NSMenu new]);

// Info SubMenu
menuItem = (NSMenuItem *)
[mainMenu addItemWithTitle:_(@"Info")
action:NULL
keyEquivalent: @""];
menu = AUTORELEASE ([NSMenu new]);
[mainMenu setSubmenu:menu forItem:menuItem];
[menu addItemWithTitle: _(@"Info Panel...")
action: @selector (orderFrontStandardInfoPanel:)
keyEquivalent: @""];
[menu addItemWithTitle: _(@"Preferences...")
action: @selector (runPreferencesPanel:)
keyEquivalent: @""];
[menu addItemWithTitle: _(@"Help...")
action: @selector (orderFrontHelpPanel:)
keyEquivalent: @"?"];

// Game SubMenu
menuItem = (NSMenuItem *)
[mainMenu addItemWithTitle: _(@"Game")
action:NULL
keyEquivalent: @""];
menu = AUTORELEASE ([NSMenu new]);
[mainMenu setSubmenu: menu forItem: menuItem];

gameMenuItem = (NSMenuItem *)
[menu addItemWithTitle: _(@"New game")
action:NULL
keyEquivalent: @""];

newGameMenu = AUTORELEASE ([NSMenu new]);
[menu setSubmenu:newGameMenu forItem: gameMenuItem];

[[newGameMenu addItemWithTitle: _(@"With replacement")
action: @selector(newGameWithRep:)
keyEquivalent: @"n"] setTag:MENU_NEW_WITH_REP];
[[newGameMenu addItemWithTitle: _(@"Without replacement")
action: @selector(newGameNoRep:)
keyEquivalent: @"N"] setTag:MENU_NEW_NO_REP];

commitMenuItem = [[NSMenuItem alloc] init];
[commitMenuItem setTag:MENU_COMMIT];
[commitMenuItem setTitle: _(@"Commit")];
[commitMenuItem setKeyEquivalent: @"c"];
[commitMenuItem setAction: @selector(commit:)];
[menu addItem: commitMenuItem];

moveMenuItem = [[NSMenuItem alloc] init];
[moveMenuItem setTag:MENU_MOVE];
[moveMenuItem setTitle: _(@"Move")];
[moveMenuItem setKeyEquivalent: @""];
[moveMenuItem setAction: @selector(move:)];
[menu addItem: moveMenuItem];


// Hide MenuItem
[mainMenu addItemWithTitle: _(@"Hide")
action: @selector (hide:)
keyEquivalent: @"h"];

// Quit MenuItem
[mainMenu addItemWithTitle: _(@"Quit")
action: @selector (terminate:)
keyEquivalent: @"q"];

[app setMainMenu: mainMenu];

controller = [Controller new];
[app setDelegate: controller];

NSApplicationMain(argc, argv);

[[NSUserDefaults standardUserDefaults] synchronize];

// RELEASE (controller);
// RELEASE (pool);
return 0;
}

 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin