00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef EASYSOK_MAIN_WINDOW_INC_GUARD_H
00022 #define EASYSOK_MAIN_WINDOW_INC_GUARD_H
00023
00024
00025 #include <vector>
00026
00027 #include <qstring.h>
00028 #include <qstringlist.h>
00029
00030 #include <kmainwindow.h>
00031 #include <kurl.h>
00032
00033
00034 class Collection;
00035 class DuplicateLevelFinder;
00036 class Game;
00037 class KAction;
00038 class KActionMenu;
00039 class KRadioAction;
00040 class KToggleAction;
00041 class KURL;
00042 class Level;
00043 class LevelEditor;
00044 class Map;
00045 class MapWidget;
00046 class MngAnimationStorer;
00047 class Movements;
00048 class Optimizer;
00049 class PixmapProvider;
00050 class ProgressDialog;
00051 class QMessageBox;
00052 class QSignalMapper;
00053 class QTimer;
00054 class Solver;
00055
00056
00057
00058
00066 class MainWindow : public KMainWindow
00067 {
00068 Q_OBJECT
00069
00070 public:
00071
00079 MainWindow(QWidget * parent = 0, char const * name = 0);
00080
00081
00086 virtual ~MainWindow();
00087
00088
00099 void setLevel(int collection_nr, int level_nr, bool force_update = false,
00100 bool dont_save_act_level = false);
00101
00102
00107 enum BookmarkFormat
00108 {
00113 DATE = 1,
00114
00115
00120 DATE_AND_TIME = 2,
00121
00122
00127 COLLECTION = 4,
00128
00129
00134 COLLECTION_AND_LEVEL = 8,
00135
00136
00141 ANNOTATION = 16
00142 };
00143
00144
00145 public slots:
00146
00151 void prevCollection();
00152
00153
00158 void nextCollection();
00159
00160
00165 void prevLevel();
00166
00167
00172 void nextLevel();
00173
00174
00179 void selectLevel();
00180
00181
00186 void firstLevel();
00187
00188
00193 void lastLevel();
00194
00195
00200 void moveLeft();
00201
00202
00207 void moveRight();
00208
00209
00214 void moveUp();
00215
00216
00221 void moveDown();
00222
00223
00228 void moveFarLeft();
00229
00230
00235 void moveFarRight();
00236
00237
00242 void moveFarUp();
00243
00244
00249 void moveFarDown();
00250
00251
00256 void moveVirtualLeft();
00257
00258
00263 void moveVirtualRight();
00264
00265
00270 void moveVirtualUp();
00271
00272
00277 void moveVirtualDown();
00278
00279
00284 void pullMoveLeft();
00285
00286
00291 void pullMoveRight();
00292
00293
00298 void pullMoveUp();
00299
00300
00305 void pullMoveDown();
00306
00307
00314 void moveKeeper(QPoint point);
00315
00316
00321 void moveKeeper(QPoint from, QPoint to);
00322
00323
00331 void moveGem(QPoint from, QPoint to);
00332
00333
00338 void undo();
00339
00340
00345 void redo();
00346
00347
00352 void jumpToStart();
00353
00354
00359 void jumpToEnd();
00360
00361
00366 void loadBestSolution();
00367
00368
00373 void loadASolution();
00374
00375
00380 void annotateSolution();
00381
00382
00389 void setCollection(int index);
00390
00391
00398 void changeAnimations(int speed);
00399
00400
00405 void hideGemsChanged();
00406
00407
00412 void hideGoalsChanged();
00413
00414
00419 void outsideAsWallChanged();
00420
00421
00426 void honorDeadlockChanged();
00427
00428
00435 void setTheme(int theme);
00436
00437
00442 void nextTheme();
00443
00444
00449 void previousTheme();
00450
00451
00456 void importCollection();
00457
00458
00463 void exportGame();
00464
00465
00470 void sendGame();
00471
00472
00477 void importGame();
00478
00479
00484 void exportCollection();
00485
00486
00491 void sendCollection();
00492
00493
00498 void exportSolutions();
00499
00500
00505 void sendSolutions();
00506
00507
00512 void importSolutions();
00513
00514
00519 void playMoves();
00520
00521
00526 void showKeyDialog();
00527
00528
00533 void showToolbarDialog();
00534
00535
00540 void updateToolbar();
00541
00542
00547 void showSolutions();
00548
00549
00554 void showHighscores();
00555
00556
00561 void showPushesChanged();
00562
00563
00570 void setBookmark(int index);
00571
00572
00579 void gotoBookmark(int index);
00580
00581
00588 void annotateBookmark(int index);
00589
00590
00597 void importKSokobanBookmark(int index);
00598
00599
00604 void showOptionsDialog();
00605
00606
00611 void minimizeMoves();
00612
00613
00618 void minimizeCollectionMoves();
00619
00620
00625 void minimizeLevelMoves();
00626
00627
00632 void minimizePushes();
00633
00634
00639 void minimizeCollectionPushes();
00640
00641
00646 void minimizeLevelPushes();
00647
00648
00653 void deleteSolutions();
00654
00655
00660 void deleteSolutionsByName();
00661
00662
00667 void stopAnimation();
00668
00669
00674 void solved();
00675
00676
00681 void unsolved();
00682
00683
00688 void solvedByHand();
00689
00690
00695 void updateStatusBar();
00696
00697
00702 void configChanged();
00703
00704
00709 void autoOptChanged();
00710
00711
00716 void retroModeChanged();
00717
00718
00723 void editCurrentLevel();
00724
00725
00730 void insertNewLevel();
00731
00732
00737 void insertNewCollection();
00738
00739
00744 void deleteCurrentLevel();
00745
00746
00751 void deleteCurrentCollection();
00752
00753
00758 void duplicateCurrentLevel();
00759
00760
00765 void duplicateCurrentCollection();
00766
00767
00772 void copyCurrentLevel();
00773
00774
00779 void pasteLevel();
00780
00781
00786 void pasteLevelInNewCollection();
00787
00788
00793 void makeCurrentCollectionNonTemporary();
00794
00795
00800 void solve();
00801
00802
00807 void exportGameImage();
00808
00809
00814 void exportGameAnimation();
00815
00816
00821 void levelInfo();
00822
00823
00828 void collectionInfo();
00829
00830
00835 void findDups();
00836
00837
00842 void performFindDups();
00843
00844
00849 void animationWriteStep();
00850
00851
00856 void isOldPosition();
00857
00858
00863 void forceUpdateCollections();
00864
00865
00870 void tipOfTheDay();
00871
00872
00877 void reorderCollectionsAndLevels();
00878
00879
00886 void setEditedLevel(LevelEditor * level_editor);
00887
00888
00895 void levelEditorExited(LevelEditor * level_editor);
00896
00897
00902 void createUser();
00903
00904
00909 void importUser();
00910
00911
00916 void setUser();
00917
00918
00923 void changeUser();
00924
00925
00930 void autoSendSolutions();
00931
00932
00937 void sendBestSolutionToServer();
00938
00939
00944 void compareSolution();
00945
00946
00951 void getBestSolutionFromServer();
00952
00953
00958 void saveState();
00959
00960
00965 void quit();
00966
00967
00968 protected:
00969
00970
00975 virtual void focusOutEvent(QFocusEvent * event);
00976
00977
00982 virtual void focusInEvent(QFocusEvent * event);
00983
00984
00989 virtual void keyPressEvent(QKeyEvent * event);
00990
00991
00992 private:
00993
00998 void updateUserStatusBar();
00999
01000
01012 void sendSolutionToServer(Map const & map, Movements const & moves, int nr_of_pushes,
01013 int nr_of_linear_pushes, int nr_of_gem_changes, int nr_of_moves);
01014
01015
01024 void createLevelEditor(Level const & level, int collection_nr, int level_nr);
01025
01026
01033 void insertLevelIntoNewCollection(Level const & level);
01034
01035
01042 Level * levelFromClipboard();
01043
01044
01054 QString levelNameAndCollection(Level const & level, int level_nr, Collection const & collection) const;
01055
01056
01061 QString currentGameToText();
01062
01063
01069 QString solutionsText();
01070
01071
01079 KURL getSaveUrl(QString const & dialog_tag, QString const & filter) const;
01080
01081
01089 void saveDataAsXsbFile(QString const & data, QString const & dialog_tag) const;
01090
01091
01098 void mailData(QString const & data) const;
01099
01100
01107 QStringList loadDataFromXsbFile(QString const & dialog_tag) const;
01108
01109
01116 void addCollection(Collection const & collection);
01117
01118
01127 void optimizeSolutions(int from, int to, Optimizer * optimizer);
01128
01129
01134 void updateWasSolvedActions();
01135
01136
01141 void updateUndoRedoActions();
01142
01143
01148 void updateLevelActions();
01149
01150
01155 PixmapProvider * getPixmapProvider();
01156
01157
01162 Collection * actCollection();
01163
01164
01169 Level const & actLevel();
01170
01171
01176 int lastLegalLevel() const;
01177
01178
01183 void saveCurrentLevelState();
01184
01185
01190 void readConfig();
01191
01192
01197 void readChangedOptions();
01198
01199
01204 void writeConfig();
01205
01206
01211 void setupActions();
01212
01213
01218 void setupAccels();
01219
01220
01225 void setupCollectionMenu();
01226
01227
01232 void setupThemeMenu();
01233
01234
01235
01240 void setupBookmarkMenu();
01241
01242
01251 void setupBookmarkMenuEntry(int index);
01252
01253
01260 char const * imageType(KURL const & url) const;
01261
01262
01267 Game * m_game;
01268
01269
01274 Map * m_map;
01275
01276
01281 int m_collection_nr;
01282
01283
01288 int m_level_nr;
01289
01290
01295 int m_best_number_of_pushes;
01296
01297
01302 int m_best_number_of_moves;
01303
01304
01309 int m_is_solved;
01310
01311
01316 bool m_was_solved;
01317
01318
01323 bool m_next_level_when_solved;
01324
01325
01330 bool m_auto_optimize_moves;
01331
01332
01337 bool m_auto_optimize_pushes;
01338
01339
01344 int m_theme;
01345
01346
01351 MapWidget * m_map_widget;
01352
01353
01358 bool m_hide_gems;
01359
01360
01365 bool m_hide_goals;
01366
01367
01372 bool m_outside_as_wall;
01373
01374
01379 bool m_honor_deadlocks;
01380
01381
01386 bool m_show_arrows;
01387
01388
01393 bool m_goto_any_level;
01394
01395
01400 int m_animation_speed;
01401
01402
01407 BookmarkFormat m_bookmark_format;
01408
01409
01414 QTimer * m_animation_timer;
01415
01416
01421 MngAnimationStorer * m_animation_storer;
01422
01423
01428 ProgressDialog * m_progress_dialog;
01429
01430
01435 QTimer * m_find_dups_timer;
01436
01437
01442 DuplicateLevelFinder * m_duplicate_level_finder;
01443
01444
01449 KToggleAction * m_retro_mode_action;
01450
01451
01456 int m_number_of_bookmarks;
01457
01458
01463 KToggleAction * m_hide_gems_action;
01464
01465
01470 KToggleAction * m_hide_goals_action;
01471
01472
01477 KToggleAction * m_outside_as_wall_action;
01478
01479
01484 KToggleAction * m_honor_deadlock_action;
01485
01486
01491 KToggleAction * m_show_arrow_action;
01492
01493
01498 KActionMenu * m_collection_menu;
01499
01500
01505 QSignalMapper * m_collection_mapper;
01506
01507
01512 std::vector<KRadioAction *> m_collection_actions;
01513
01514
01519 KActionMenu * m_collection_by_author_menu;
01520
01521
01526 std::vector<KRadioAction *> m_collection_by_author_actions;
01527
01528
01533 std::vector<KActionMenu *> m_collection_by_author_submenus;
01534
01535
01540 KActionMenu * m_collection_by_difficulty_menu;
01541
01542
01547 std::vector<KRadioAction *> m_collection_by_difficulty_actions;
01548
01549
01554 std::vector<KActionMenu *> m_collection_by_difficulty_submenus;
01555
01556
01561 KActionMenu * m_theme_menu;
01562
01563
01568 QSignalMapper * m_theme_mapper;
01569
01570
01575 std::vector<KRadioAction *> m_theme_actions;
01576
01577
01582 KToggleAction * m_dont_optimize_solutions_action;
01583
01584
01589 KToggleAction * m_auto_optimize_moves_action;
01590
01591
01596 KToggleAction * m_auto_optimize_pushes_action;
01597
01598
01603 KAction * m_undo_action;
01604
01605
01610 KAction * m_redo_action;
01611
01612
01617 KAction * m_play_action;
01618
01619
01624 KAction * m_jump_start_action;
01625
01626
01631 KAction * m_jump_end_action;
01632
01633
01638 KAction * m_load_best_sol_action;
01639
01640
01645 KAction * m_load_sol_action;
01646
01647
01652 KAction * m_annotate_sol_action;
01653
01654
01659 KAction * m_delete_sol_action;
01660
01661
01666 KAction * m_min_moves_action;
01667
01668
01673 KAction * m_min_pushes_action;
01674
01675
01680 KAction * m_prev_level_action;
01681
01682
01687 KAction * m_next_level_action;
01688
01689
01694 KAction * m_first_level_action;
01695
01696
01701 KAction * m_last_level_action;
01702
01703
01708 KActionMenu * m_bookmark_set_menu;
01709
01710
01715 KActionMenu * m_bookmark_goto_menu;
01716
01717
01722 KActionMenu * m_bookmark_annotate_menu;
01723
01724
01729 KActionMenu * m_bookmark_import_menu;
01730
01731
01736 QSignalMapper * m_bookmark_set_mapper;
01737
01738
01743 QSignalMapper * m_bookmark_goto_mapper;
01744
01745
01750 QSignalMapper * m_bookmark_annotate_mapper;
01751
01752
01757 QSignalMapper * m_bookmark_import_mapper;
01758
01759
01764 std::vector<KAction *> m_bookmark_set_actions;
01765
01766
01771 std::vector<KAction *> m_bookmark_goto_actions;
01772
01773
01778 std::vector<KAction *> m_bookmark_annotate_actions;
01779
01780
01785 std::vector<KAction *> m_bookmark_import_actions;
01786
01787
01792 std::vector<KActionMenu *> m_bookmark_set_submenus;
01793
01794
01799 std::vector<KActionMenu *> m_bookmark_goto_submenus;
01800
01801
01806 std::vector<KActionMenu *> m_bookmark_annotate_submenus;
01807
01808
01813 std::vector<KActionMenu *> m_bookmark_import_submenus;
01814
01815
01820 bool m_show_difficulty;
01821
01822
01827 bool m_show_gems_left;
01828
01829
01834 bool m_show_author;
01835
01836
01841 bool m_show_user;
01842
01843
01848 bool m_auto_send_to_server;
01849
01850
01855 KToggleAction * m_auto_send_to_server_action;
01856
01857
01862 std::vector<LevelEditor *> m_editors;
01863
01864
01869 QTimer * m_state_timer;
01870
01871
01876 int m_auto_save_time;
01877 };
01878
01879
01880 #endif