summaryrefslogtreecommitdiffstats
path: root/kenolaba/AbTop.h
blob: 25457733c53ebff37bbf6f8d6be3aae4aed33c72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/* Class AbTop: the toplevel widget of Kenolaba
 *
 * Josef Weidendorfer, 9/97
*/

#ifndef _ABTOP_H_
#define _ABTOP_H_

#include <tdemainwindow.h>

#include "Move.h"


class TQTimer;
class TQPopupMenu;
class TQLabel;

class TDEAction;
class TDEToggleAction;
class TDESelectAction;

class Network;
class Board;
class BoardWidget;
class Move;
class EvalScheme;

#ifdef SPION
class Spy;
#endif



class AbTop: public TDEMainWindow
{
  TQ_OBJECT
  

public:
  AbTop();
  ~AbTop();

  /* timer states */
  enum { noGame, gameOver, notStarted, moveShown,
	 showMove = 100, showSugg=200
  };

  void netPort(int p) { myPort = p; }
  void netHost(char* h) { hosts.append(h); }

protected:
  virtual void saveProperties( TDEConfig * );
  virtual void readProperties( TDEConfig * );


public slots:
  void timerDone();
  void newGame();
  void copy();
  void paste();
  void pastePosition(const char *);
  void stopGame();
  void continueGame();
  bool queryClose();
  void back();
  void forward();
  void suggestion();
  void stopSearch();
  void searchBreak();
  void moveChoosen(Move&);
  void savePosition();
  void restorePosition();
  void setSpy(int);
  void updateSpy(TQString);
  void edited(int);
  void updateBestMove(Move&,int);
  void readConfig();
  void writeConfig();
  void rightButtonPressed(int,const TQPoint&);

  void gameNetwork(bool);
  void editModify(bool);
  void optionMoveSlow(bool);
  void optionRenderBalls(bool);
  void optionShowSpy(bool);
  void toggleMenubar();
  void configure();
  void setLevel(int);
  void setIPlay(int);

private:
  void setupActions();
  void updateStatus();
  void userMove();
  void playGame();
  void loadPixmaps();
  void setupStatusBar();
  void updateActions();
  void setMoveNo(int, bool updateGUI = false);
  bool iPlayNow();
  Move haveHint();
  void readOptions(TDEConfig *);
  void writeOptions(TDEConfig *);

  Move actMove;
  Board* board;
  int actValue;
  BoardWidget *boardWidget;
  EvalScheme* currentEvalScheme;
  TQTimer *timer;
  int timerState;
  int depth, moveNo;
  bool showMoveLong, stop, showSpy;
  bool editMode, renderBalls;
  int spyLevel;
  bool pastePossible, validShown;

  enum IPlay { Red = 0, Yellow, Both, None, Nb_IPlays };
  IPlay iplay;

  int stop_id, back_id, hint_id;
  int easy_id, normal_id, hard_id, challange_id, slow_id, level_id;
  int render_id;
  int yellow_id, red_id, both_id, none_id, iplay_id;
  int spy_id, paste_id, edit_id, forward_id, net_id;

  TQLabel *validLabel, *ballLabel, *moveLabel, *statusLabel;
  TQPixmap warningPix, okPix, redBall, yellowBall, noBall, netPix;
  TQPixmap spy0, spy1, spy2, spy3;

  Network *net;
  int myPort;
  TQStrList hosts;

  TDEAction *newAction, *stopAction, *backAction, *forwardAction, *hintAction, *pasteAction;
  TDEToggleAction *showMenubar, *renderBallsAction, *moveSlowAction,
      *showSpyAction, *editAction;
  TDESelectAction *levelAction, *iplayAction;

  struct Data {
      const char *key, *label;
  };
  enum Level { Easy = 0, Normal, Hard, Challenge, Nb_Levels };
  static const Data LEVEL[Nb_Levels];
  static const Data IPLAY[AbTop::Nb_IPlays];

#ifdef SPION
  Spy* spy;
#endif

};

#endif /* _ABTOP_H_ */