554
fill3DRect(PanexWidget w, GC gc, GC darkerGC, GC brighterGC,
640
fill3DRect(PanexWidget w, Pixmap dr, GC gc, GC darkerGC, GC brighterGC,
555
641
int x, int y, int width, int height, Boolean raised)
557
643
GC currentGC = (raised) ? gc : darkerGC;
559
645
if (width > 2 && height > 2)
560
FILLRECTANGLE(w, currentGC,
646
FILLRECTANGLE(w, dr, currentGC,
561
647
x + 1, y + 1, width - 2, height - 2);
562
648
currentGC = (raised) ? brighterGC : darkerGC;
563
FILLRECTANGLE(w, currentGC,
649
FILLRECTANGLE(w, dr, currentGC,
564
650
x, y, 1, height);
566
FILLRECTANGLE(w, currentGC,
652
FILLRECTANGLE(w, dr, currentGC,
567
653
x + 1, y, width - 1, 1);
568
FILLRECTANGLE(w, currentGC,
654
FILLRECTANGLE(w, dr, currentGC,
569
655
x + 1, y, 1, height);
571
FILLRECTANGLE(w, currentGC,
657
FILLRECTANGLE(w, dr, currentGC,
572
658
x + 2, y + 1, width - 2, 1);
573
659
currentGC = (raised) ? darkerGC : gc;
574
660
if (width > 1 && height > 1)
575
FILLRECTANGLE(w, currentGC,
661
FILLRECTANGLE(w, dr, currentGC,
576
662
x + 1, y + height - 1, width - 1, 1);
577
663
if (width > 1 && height > 1)
578
FILLRECTANGLE(w, currentGC,
664
FILLRECTANGLE(w, dr, currentGC,
579
665
x + width - 1, y, 1, height - 1);
580
666
if (width > 3 && height > 2)
581
FILLRECTANGLE(w, currentGC,
667
FILLRECTANGLE(w, dr, currentGC,
582
668
x + 2, y + height - 2, width - 3, 1);
583
669
if (width > 2 && height > 3)
584
FILLRECTANGLE(w, currentGC,
670
FILLRECTANGLE(w, dr, currentGC,
585
671
x + width - 2, y + 1, 1, height - 3);
589
drawShadow(PanexWidget w, GC gc, int startX, int startY,
675
drawShadow(PanexWidget w, Pixmap dr, GC gc, int startX, int startY,
590
676
int sizeX, int sizeY)
593
startX, startY, sizeX, 1);
595
startX, startY, 1, sizeY);
678
FILLRECTANGLE(w, dr, gc, startX, startY, sizeX, 1);
679
FILLRECTANGLE(w, dr, gc, startX, startY, 1, sizeY);
599
DrawPyramid(PanexWidget w, int color, int i, int j, int size,
683
DrawPyramid(PanexWidget w, Pixmap dr, int color, int i, int j, int size,
600
684
int offsetPosition)
602
Point trapazoidList[5];
686
Point trapazoidList[5];
606
690
for (k = 0; k <= 4; k++) {
607
691
if (ABS(trapazoidUnit[k].x) == 3)
650
734
w->panex.pyramidName[color][0];
652
DRAWTEXT(w, (offsetPosition) ? w->panex.borderGC :
654
k - w->panex.letterOffset.x, trapazoidList[0].y +
655
w->panex.tileSize.y / 2 + w->panex.letterOffset.y, buf, 1);
660
DrawTile(PanexWidget w, int i, int j, Boolean erase, int offsetPosition)
736
DRAWTEXT(w, dr, (offsetPosition) ? w->panex.borderGC :
738
k - w->panex.letterOffset.x, trapazoidList[0].y +
739
w->panex.tileSize.y / 2 + w->panex.letterOffset.y, buf, 1);
744
FillRectClip(PanexWidget w, Pixmap dr, GC gc, int dx, int dy, int sx, int sy,
745
int wdx, int wdy, int wsx, int wsy)
747
int ndx = wdx, nsx = wsx, ndy = wdy, nsy = wsy;
749
/* w is the clipping window */
750
if (dx + sx < wdx || dx > wdx + wsx ||
751
dy + sy < wdy || dy > wdy + wsy ||
752
sx <= 0 || sy <= 0 || wsx <= 0 || wsy <= 0) {
757
nsx = wsx - dx + wdx;
761
nsy = wsy - dy + wdy;
763
if (ndx + nsx > dx + sx) {
766
if (ndy + nsy > dy + sy) {
769
FILLRECTANGLE(w, dr, gc, ndx, ndy, nsx, nsy);
773
DrawSlot(PanexWidget w, int stack, int x, int y, int width, int height)
776
GC gc = w->panex.inverseGC;
777
int sizex = w->panex.tileSize.x / 3;
778
int sizey = w->panex.tileSize.y / 3;
780
FILLRECTANGLE(w, dr, gc, x, y, width, height);
781
FillRectClip(w, dr, w->panex.borderGC,
782
sizex + w->panex.delta.x +
783
w->panex.puzzleOffset.x,
784
w->panex.delta.y / 2 + w->panex.puzzleOffset.y + sizey,
785
sizex + (MAXSTACKS - 1) * w->panex.pos.x,
787
x, y, width, height);
788
FillRectClip(w, dr, w->panex.borderGC,
789
sizex + w->panex.delta.x +
790
w->panex.puzzleOffset.x + stack * w->panex.pos.x,
791
w->panex.delta.y / 2 + w->panex.puzzleOffset.y + sizey,
793
(w->panex.tiles + 1) * w->panex.pos.y + w->panex.delta.y -
795
x, y, width, height);
796
FillRectClip(w, dr, w->panex.borderGC,
797
sizex + w->panex.delta.x +
798
w->panex.puzzleOffset.x + w->panex.pos.x,
799
w->panex.delta.y / 2 + w->panex.puzzleOffset.y + sizey,
801
(w->panex.tiles + 1) * w->panex.pos.y + w->panex.delta.y -
803
x, y, width, height);
807
DrawTile(PanexWidget w, int i, int j, Boolean erase, int pressedOffset,
808
int offsetX, int offsetY)
811
int tileI = w->panex.tileOfPosition[i][j].stack;
812
int tileJ = w->panex.tileOfPosition[i][j].loc;
815
dx = CartesianX(w, i) + pressedOffset + offsetX;
816
dy = CartesianY(w, j) + pressedOffset + offsetY;
817
sx = CartesianX(w, tileI);
818
sy = CartesianY(w, tileJ);
666
tileGC = w->panex.inverseGC;
667
borderGC = w->panex.borderGC;
669
tileGC = w->panex.tileGC;
670
borderGC = w->panex.borderGC;
672
dx = i * w->panex.pos.x + w->panex.delta.x + w->panex.puzzleOffset.x;
673
dy = j * w->panex.pos.y + w->panex.delta.y + w->panex.puzzleOffset.y;
676
FILLRECTANGLE(w, tileGC,
677
dx + offsetPosition, dy + offsetPosition,
821
FILLRECTANGLE(w, dr, w->panex.inverseGC,
678
823
w->panex.tileSize.x, w->panex.tileSize.y);
681
FILLRECTANGLE(w, borderGC,
682
dx + w->panex.tileSize.x / 3 + offsetPosition,
683
dy + w->panex.tileSize.y / 3 - 1,
826
FILLRECTANGLE(w, dr, w->panex.borderGC,
827
dx + w->panex.tileSize.x / 3,
828
dy + w->panex.tileSize.y / 3 - 1 -
684
830
2 * w->panex.tileSize.x / 3 + 2,
685
831
w->panex.tileSize.y / 3);
686
832
} else if (i == MAXSTACKS - 1) {
687
FILLRECTANGLE(w, borderGC,
689
dy + w->panex.tileSize.y / 3 - 1,
833
FILLRECTANGLE(w, dr, w->panex.borderGC,
835
dy + w->panex.tileSize.y / 3 - 1 -
690
837
2 * w->panex.tileSize.x / 3 - 1,
691
838
w->panex.tileSize.y / 3 +
694
FILLRECTANGLE(w, borderGC,
696
dy + w->panex.tileSize.y / 3 - 1,
841
FILLRECTANGLE(w, dr, w->panex.borderGC,
843
dy + w->panex.tileSize.y / 3 - 1 -
697
845
w->panex.tileSize.x + 1,
698
846
w->panex.tileSize.y / 3);
700
FILLRECTANGLE(w, borderGC,
701
dx + w->panex.tileSize.x / 3,
702
dy + w->panex.tileSize.y / 3 - 1,
848
FILLRECTANGLE(w, dr, w->panex.borderGC,
849
dx + w->panex.tileSize.x / 3 - pressedOffset,
850
dy + w->panex.tileSize.y / 3 - 1 - pressedOffset,
703
851
w->panex.tileSize.x / 3,
704
852
w->panex.tileSize.y - w->panex.tileSize.y / 3 +
705
2 + offsetPosition - 1);
706
854
} else if (j == w->panex.tiles) {
707
FILLRECTANGLE(w, borderGC,
708
dx + w->panex.tileSize.x / 3, dy,
855
FILLRECTANGLE(w, dr, w->panex.borderGC,
856
dx + w->panex.tileSize.x / 3 - pressedOffset,
709
858
w->panex.tileSize.x / 3,
710
859
2 * w->panex.tileSize.y / 3 + 2);
712
FILLRECTANGLE(w, borderGC,
713
dx + w->panex.tileSize.x / 3, dy,
861
FILLRECTANGLE(w, dr, w->panex.borderGC,
862
dx + w->panex.tileSize.x / 3 - pressedOffset,
714
864
w->panex.tileSize.x / 3,
715
w->panex.tileSize.y + offsetPosition);
718
if (offsetPosition != 0) {
719
drawShadow(w, w->panex.tileDarkerGC,
721
w->panex.tileSize.x, w->panex.tileSize.y);
723
dx += offsetPosition;
724
dy += offsetPosition;
726
fill3DRect(w, tileGC,
727
w->panex.tileDarkerGC, w->panex.tileBrighterGC,
728
dx, dy, w->panex.tileSize.x, w->panex.tileSize.y,
729
offsetPosition == 0);
731
w->panex.tileOfPosition[i][j].stack, i, j,
732
w->panex.tileOfPosition[i][j].loc, offsetPosition);
865
w->panex.tileSize.y + pressedOffset);
870
w->panex.hOldBitmap = (HBITMAP) SelectObject(w->panex.memDC,
871
w->panex.bufferTiles[pressedOffset]);
874
w->panex.tileSize.x, w->panex.tileSize.y,
878
SelectObject(w->panex.memDC, w->panex.hOldBitmap);
880
XSetGraphicsExposures(XtDisplay(w), w->panex.tileGC, False);
881
XCopyArea(XtDisplay(w),
882
w->panex.bufferTiles[pressedOffset],
886
w->panex.tileSize.x, w->panex.tileSize.y,
893
DrawBufferedTile(PanexWidget w, int i, int j, int pressedOffset)
899
dr = &(w->panex.bufferTiles[pressedOffset]);
900
tileGC = w->panex.tileGC;
901
dx = CartesianX(w, i) + pressedOffset;
902
dy = CartesianY(w, j) + pressedOffset;
903
if (pressedOffset != 0) {
904
drawShadow(w, *dr, w->panex.tileDarkerGC,
905
dx - pressedOffset, dy - pressedOffset,
906
w->panex.tileSize.x, w->panex.tileSize.y);
908
fill3DRect(w, *dr, tileGC,
909
w->panex.tileDarkerGC, w->panex.tileBrighterGC,
910
dx, dy, w->panex.tileSize.x, w->panex.tileSize.y,
912
if (pressedOffset != 0) {
913
FILLRECTANGLE(w, *dr, w->panex.tileGC,
914
dx + w->panex.tileSize.x - 2, dy - 1, 1, 3);
915
FILLRECTANGLE(w, *dr, w->panex.tileGC,
916
dx - 1, dy + w->panex.tileSize.y - 2, 3, 1);
919
i, i, j, j, pressedOffset);
923
DrawAllBufferedTiles(const PanexWidget w)
927
for (i = 0; i <= w->panex.mode; i++)
928
for (j = 0; j < w->panex.tiles; j++)
929
for (l = 0; l < 2; l++)
930
DrawBufferedTile(w, i, j, l);
737
934
DrawAllTiles(PanexWidget w)
741
for (i = 0; i < MAXSTACKS; i++)
742
for (j = 0; j <= w->panex.tiles; j++)
743
if (w->panex.tileOfPosition[i][j].stack >= 0)
744
DrawTile(w, i, j, False, FALSE);
748
DrawSlots(PanexWidget w)
750
int i, dx, dy, y, sizey;
938
for (i = 0; i <= w->panex.mode; i++)
939
for (j = 0; j < w->panex.tiles; j++)
941
w->panex.positionOfTile[i][j].stack,
942
w->panex.positionOfTile[i][j].loc,
947
AnimateSlide(PanexWidget w, int currentStack, int currentPosition,
948
int nextStack, int nextPosition, int fast)
950
int diffStack = nextStack - currentStack;
951
int diffPosition = nextPosition - currentPosition;
952
int dir = 0, spaces = 0, inc;
953
int gapI = 0, moveI = 0, space;
957
if (diffPosition > 0) {
959
spaces = diffPosition;
960
moveI = w->panex.pos.y;
961
} else if (diffPosition < 0) {
963
spaces = -diffPosition;
964
moveI = w->panex.pos.y;
965
} else if (diffStack > 0) {
968
moveI = w->panex.pos.x;
969
} else if (diffStack < 0) {
972
moveI = w->panex.pos.x;
974
space = spaces * moveI;
975
if ((dir == RIGHT) || (dir == LEFT)) {
976
gapI = w->panex.pos.x * fast / w->panex.numSlices;
977
} else if ((dir == TOP) || (dir == BOTTOM)) {
978
gapI = w->panex.pos.y * fast / w->panex.numSlices;
983
for (inc = 0; inc < space + gapI; inc += gapI) {
987
/* Calculate deltas */
988
dx = CartesianX(w, currentStack);
989
dy = CartesianY(w, currentPosition);
991
if ((dir == RIGHT) || (dir == LEFT)) {
992
ix = ((dir == RIGHT) ? inc : -inc);
994
} else if ((dir == TOP) || (dir == BOTTOM)) {
996
iy = ((dir == BOTTOM) ? inc : -inc);
998
DrawTile(w, currentStack, currentPosition, False,
1000
/* Erase old slivers */
1006
DrawSlot(w, currentStack,
1007
ix, iy + w->panex.tileSize.y,
1008
w->panex.tileSize.x + 1, gapI);
1009
useTimer(w, w->panex.delay);
1012
DrawSlot(w, currentStack,
1014
gapI, w->panex.tileSize.y + 1);
1015
useTimer(w, 3 * w->panex.delay);
1018
DrawSlot(w, currentStack,
1020
w->panex.tileSize.x + 1, gapI);
1021
useTimer(w, w->panex.delay);
1024
DrawSlot(w, currentStack,
1025
ix + w->panex.tileSize.x, iy,
1026
gapI + 1, w->panex.tileSize.y + 1);
1027
useTimer(w, 3 * w->panex.delay);
1034
DrawSlots(PanexWidget w, Pixmap dr)
1036
int i, dx, dy, y, sizex, sizey;
1038
sizex = w->panex.tileSize.x / 3;
752
1039
sizey = w->panex.tileSize.y / 3;
755
dx = w->panex.tileSize.x / 3 + w->panex.delta.x +
756
w->panex.puzzleOffset.x;
1042
dx = sizex + w->panex.delta.x + w->panex.puzzleOffset.x;
757
1043
y = (w->panex.tiles + 1) * w->panex.pos.y + w->panex.delta.y;
758
1044
dy = w->panex.delta.y / 2 + w->panex.puzzleOffset.y + sizey;
759
FILLRECTANGLE(w, w->panex.borderGC, dx, dy,
760
w->panex.tileSize.x / 3 + (MAXSTACKS - 1) * w->panex.pos.x,
761
w->panex.tileSize.y / 3);
1045
FILLRECTANGLE(w, dr, w->panex.borderGC, dx, dy,
1046
sizex + (MAXSTACKS - 1) * w->panex.pos.x,
762
1048
for (i = 0; i < MAXSTACKS; i++) {
763
FILLRECTANGLE(w, w->panex.borderGC, dx, dy,
764
w->panex.tileSize.x / 3, y - 1 - 2 * w->panex.tileSize.y / 3);
1049
FILLRECTANGLE(w, dr, w->panex.borderGC, dx, dy,
1050
sizex, y - 1 - 2 * sizey);
765
1051
dx += w->panex.pos.x;
770
EraseFrame(PanexWidget w, Boolean focus)
1056
EraseFrame(PanexWidget w, Pixmap dr, Boolean focus)
772
DRAWRECTANGLE(w, (focus) ? w->panex.frameGC : w->panex.inverseGC,
1058
DRAWRECTANGLE(w, dr, (focus) ? w->panex.frameGC : w->panex.inverseGC,
773
1059
0, 0, w->core.width - 1, w->core.height - 1);
774
FILLRECTANGLE(w, w->panex.inverseGC,
1060
FILLRECTANGLE(w, dr, w->panex.inverseGC,
775
1061
1, 1, w->core.width - 2, w->core.height - 2);
779
DrawFrame(PanexWidget w, Boolean focus)
1065
DrawFrame(PanexWidget w, Pixmap dr, Boolean focus)
781
DRAWRECTANGLE(w, (focus) ? w->panex.frameGC : w->panex.borderGC,
1067
DRAWRECTANGLE(w, dr, (focus) ? w->panex.frameGC : w->panex.borderGC,
782
1068
0, 0, w->core.width - 1, w->core.height - 1);
1072
MoveNoTiles(PanexWidget w)
1074
SetPanex(w, PANEX_IGNORE);
786
TopOfStack(PanexWidget w, int stack)
1078
TopOfStack(PanexWidget w, int stack, int start)
790
for (i = 0; i <= w->panex.tiles; i++)
1082
for (i = start; i <= w->panex.tiles; i++)
791
1083
if (w->panex.tileOfPosition[stack][i].stack >= 0)
836
1135
else if (i >= MAXSTACKS)
837
1136
i = MAXSTACKS - 1;
839
y -= w->panex.puzzleOffset.y;
840
j = (y - w->panex.delta.y / 2) / w->panex.pos.y;
843
else if (j > w->panex.tiles)
1138
y -= w->panex.puzzleOffset.y;
1139
j = (y - w->panex.delta.y / 2) / w->panex.pos.y;
1142
else if (j > w->panex.tiles)
851
SlideTile(PanexWidget w, int fromStack, int fromPosition, int toStack, int toPosition)
854
int currentStack = fromStack, currentPosition = fromPosition;
855
int nextStack = fromStack, nextPosition = fromPosition;
857
while (currentPosition > 0) {
858
DrawTile(w, currentStack, currentPosition, True, FALSE);
859
top = w->panex.tileOfPosition[currentStack][currentPosition];
860
nextPosition = currentPosition - 1;
861
w->panex.tileOfPosition[nextStack][nextPosition] = top;
862
w->panex.positionOfTile[top.stack][top.loc].stack = nextStack;
863
w->panex.positionOfTile[top.stack][top.loc].loc = nextPosition;
864
w->panex.tileOfPosition[currentStack][currentPosition].stack = -1;
865
currentPosition = nextPosition;
866
DrawTile(w, currentStack, currentPosition, False, FALSE);
868
XFlush(XtDisplay(w));
870
Sleep((unsigned int) w->panex.delay / (w->panex.tiles + MAXSTACKS - 1));
872
while (currentStack != toStack) {
873
DrawTile(w, currentStack, currentPosition, True, FALSE);
874
top = w->panex.tileOfPosition[currentStack][currentPosition];
875
nextStack = (currentStack < toStack) ? currentStack + 1 :
877
w->panex.tileOfPosition[nextStack][nextPosition] = top;
878
w->panex.positionOfTile[top.stack][top.loc].stack = nextStack;
879
w->panex.positionOfTile[top.stack][top.loc].loc = nextPosition;
880
w->panex.tileOfPosition[currentStack][currentPosition].stack = -1;
881
currentStack = nextStack;
882
DrawTile(w, currentStack, currentPosition, False, FALSE);
884
XFlush(XtDisplay(w));
886
Sleep((unsigned int) w->panex.delay / (w->panex.tiles + MAXSTACKS - 1));
888
while (currentPosition < toPosition) {
889
DrawTile(w, currentStack, currentPosition, True, FALSE);
890
top = w->panex.tileOfPosition[currentStack][currentPosition];
891
nextPosition = currentPosition + 1;
892
w->panex.tileOfPosition[nextStack][nextPosition] = top;
893
w->panex.positionOfTile[top.stack][top.loc].stack = nextStack;
894
w->panex.positionOfTile[top.stack][top.loc].loc = nextPosition;
895
w->panex.tileOfPosition[currentStack][currentPosition].stack = -1;
896
currentPosition = nextPosition;
897
DrawTile(w, currentStack, currentPosition, False, FALSE);
899
XFlush(XtDisplay(w));
901
Sleep((unsigned int) w->panex.delay / (w->panex.tiles + MAXSTACKS - 1));
1149
VirtualMove(PanexWidget w, int currentStack, int currentPosition,
1150
int nextStack, int nextPosition)
1154
top = w->panex.tileOfPosition[currentStack][currentPosition];
1155
w->panex.tileOfPosition[nextStack][nextPosition] = top;
1156
w->panex.positionOfTile[top.stack][top.loc].stack = nextStack;
1157
w->panex.positionOfTile[top.stack][top.loc].loc = nextPosition;
1158
w->panex.tileOfPosition[currentStack][currentPosition].stack = -1;
1162
DiscreteMoves(PanexWidget w, int currentStack, int currentPosition,
1163
int nextStack, int nextPosition)
1165
DrawTile(w, currentStack, currentPosition, True, FALSE, 0, 0);
1166
VirtualMove(w, currentStack, currentPosition, nextStack, nextPosition);
1167
DrawTile(w, nextStack, nextPosition, False, FALSE, 0, 0);
1169
XFlush(XtDisplay(w));
1171
Sleep((unsigned int) MULTDELAY * w->panex.delay /
1172
(w->panex.tiles + MAXSTACKS - 1));
1176
SlideTile(PanexWidget w, int fromStack, int fromPosition,
1177
int toStack, int toPosition)
1179
int currentStack = fromStack, currentPosition = fromPosition;
1180
int nextStack = fromStack, nextPosition = fromPosition;
1182
if (currentPosition > 0) {
1183
if (w->panex.delay > 0) {
1185
AnimateSlide(w, currentStack, currentPosition,
1186
nextStack, nextPosition, NORMAL);
1187
VirtualMove(w, currentStack, currentPosition,
1188
nextStack, nextPosition);
1189
currentPosition = nextPosition;
1191
while (currentPosition > 0) {
1192
nextPosition = currentPosition - 1;
1193
DiscreteMoves(w, currentStack, currentPosition,
1194
nextStack, nextPosition);
1195
currentPosition = nextPosition;
1199
if (w->panex.sound) {
1200
playSound((char *) MOVESOUND);
1204
if (currentStack != toStack) {
1205
if (w->panex.delay > 0) {
1206
nextStack = toStack;
1207
AnimateSlide(w, currentStack, currentPosition,
1208
nextStack, nextPosition, NORMAL);
1209
VirtualMove(w, currentStack, currentPosition,
1210
nextStack, nextPosition);
1211
currentStack = nextStack;
1213
while (currentStack != toStack) {
1214
nextStack = (currentStack < toStack) ?
1215
currentStack + 1 : currentStack - 1;
1216
nextPosition = currentPosition;
1217
DiscreteMoves(w, currentStack, currentPosition,
1218
nextStack, nextPosition);
1219
currentStack = nextStack;
1223
if (w->panex.sound) {
1224
playSound((char *) MOVESOUND);
1228
if (currentPosition < toPosition) {
1229
if (w->panex.delay > 0) {
1230
nextPosition = toPosition;
1231
AnimateSlide(w, currentStack, currentPosition,
1232
nextStack, nextPosition, NORMAL);
1233
VirtualMove(w, currentStack, currentPosition,
1234
nextStack, nextPosition);
1235
currentPosition = nextPosition;
1237
while (currentPosition < toPosition) {
1238
nextPosition = currentPosition + 1;
1239
DiscreteMoves(w, currentStack, currentPosition,
1240
nextStack, nextPosition);
1241
currentPosition = nextPosition;
1245
if (w->panex.sound) {
1246
playSound((char *) MOVESOUND);
906
1253
MoveTile(PanexWidget w, int fromStack, int fromPosition, int toStack)
910
1257
if ((toPosition = RequestMove(w, fromStack, fromPosition, toStack)) >= 0)
911
1258
SlideTile(w, fromStack, fromPosition, toStack, toPosition);
912
1259
return toPosition;
1263
MoveTileToLimbo(PanexWidget w, int fromStack, int fromPosition, int toStack)
1267
aMove = (RequestMove(w, fromStack, fromPosition, toStack) >= 0);
1269
SlideTile(w, fromStack, fromPosition, toStack, 0);
916
1274
ResetTiles(PanexWidget w)
921
1279
w->panex.currentStack = -1;
922
1280
for (stack = 0; stack < MAXMODES; stack++) {
1793
int toStack, toPosition;
2285
int toStack, toPosition;
1795
int x = event->xbutton.x;
2287
int x = event->xbutton.x;
1798
2290
if (w->panex.currentStack < 0)
1800
2292
DrawTile(w, w->panex.currentStack, w->panex.currentPosition,
1802
2294
DrawTile(w, w->panex.currentStack, w->panex.currentPosition,
2295
False, FALSE, 0, 0);
1804
2296
if ((toStack = SelectTile(w, x)) >= 0 &&
1805
toStack != w->panex.currentStack) {
1806
if ((toPosition = MovePanex(w, w->panex.currentStack,
2297
((w->panex.previousStack < 0 &&
2298
toStack != w->panex.currentStack) ||
2299
(w->panex.previousStack >= 0))) {
2300
if ((toPosition = MoveTile(w, w->panex.currentStack,
1807
2301
w->panex.currentPosition, toStack)) >= 0) {
1808
if (CheckSolved(w)) {
1809
SetPanex(w, PANEX_SOLVED);
2302
if (w->panex.previousStack != toStack) {
2303
SetPanex(w, PANEX_MOVED);
2304
if (w->panex.previousStack >= 0) {
2305
PutMove(w->panex.previousStack, toStack);
2307
PutMove(w->panex.currentStack, toStack);
2309
if (CheckSolved(w)) {
2310
SetPanex(w, PANEX_SOLVED);
1811
2313
} else if (toPosition == -1) {
1812
SetPanex(w, PANEX_BLOCKED);
2314
SetPanex(w, PANEX_BLOCKED);
2315
if (w->panex.previousStack != -1) {
2316
if ((toPosition = MoveTile(w, w->panex.currentStack,
2317
w->panex.currentPosition,
2318
w->panex.currentStack)) >= 0) {
2319
if (w->panex.previousStack != toStack &&
2320
w->panex.previousStack != w->panex.currentStack) {
2321
SetPanex(w, PANEX_MOVED);
2322
if (w->panex.previousStack >= 0) {
2323
PutMove(w->panex.previousStack, toStack);
2325
PutMove(w->panex.currentStack, toStack);
2327
if (CheckSolved(w)) {
2328
SetPanex(w, PANEX_SOLVED);
1814
SetPanex(w, PANEX_ILLEGAL);
2334
SetPanex(w, PANEX_ILLEGAL);
2335
if (w->panex.previousStack != -1) {
2336
if ((toPosition = MoveTile(w, w->panex.currentStack,
2337
w->panex.currentPosition,
2338
w->panex.currentStack)) >= 0) {
2339
if (w->panex.previousStack != toStack &&
2340
w->panex.previousStack != w->panex.currentStack) {
2341
SetPanex(w, PANEX_MOVED);
2342
if (w->panex.previousStack >= 0) {
2343
PutMove(w->panex.previousStack, toStack);
2345
PutMove(w->panex.currentStack, toStack);
2347
if (CheckSolved(w)) {
2348
SetPanex(w, PANEX_SOLVED);
2355
w->panex.previousStack = -1;
1817
2356
w->panex.currentStack = -1;