00001 #ifndef __MAIN_H__
00002 #define __MAIN_H__
00003
00004 #include <stdio.h>
00005
00006 #include <QApplication>
00007 #include <QClipboard>
00008 #include <QObject>
00009 #include <QWidget>
00010 #include <QDialog>
00011 #include <QtGlobal>
00012
00013 #include <QDomNode>
00014 #include <QTreeView>
00015 #include <QTextEdit>
00016 #include <QPushButton>
00017 #include <QVBoxLayout>
00018 #include <QSizePolicy>
00019
00020 #include "mainwindow.h"
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067 #define GAME_RELEASE_VERSION 0
00068 #define GAME_RELEASE 114
00069
00070
00071
00072
00073 #define COMPILE_MODE 0
00074
00075 #if (COMPILE_MODE==0)
00076
00077
00078
00079 #define DEBUG_PRINT // for DPF
00080 #else
00081
00082
00083 #endif
00084
00085
00086 #define CURRENT_FORMAT_VERSION 1
00087 #define CURRENT_FORMAT_SUBVERSION 1
00088
00089
00090 #ifdef DEBUG_PRINT
00091 #define DPF(X) logprint X
00092 #else
00093 #define DPF(X)
00094 #endif
00095
00096
00097 void logprint(char *lpszText, ...);
00098 void critical_error(QString message);
00099 void info_window(QString i);
00100 QString xmlnode_to_string(QDomNode xmldata);
00101 QString convert_to_lastnumformat(int n);
00102 void remove_dir(QString namedirfrom);
00103 void print_object_tree(void);
00104 bool compare_QStringList_len(const QStringList &list1, const QStringList &list2);
00105 int imax(int x1, int x2);
00106 int imin(int x1, int x2);
00107
00108
00109
00110
00111
00112 template <class X> inline X *find_object(QString n)
00113 {
00114 QObject *findobj;
00115
00116 extern QObject *mainwindowpointer;
00117
00118
00119 if(n=="mainwindow")
00120 {
00121 QObject *mvp=qobject_cast<X *>(mainwindowpointer);
00122
00123 if(mvp->metaObject()->className()!=mainwindowpointer->metaObject()->className())
00124 {
00125
00126 printf("find_object(): Can't find mainwindow object. Check <type> in function call\n");
00127 exit(1);
00128 return NULL;
00129 }
00130 else
00131 return qobject_cast<X *>(mainwindowpointer);
00132 }
00133
00134
00135 findobj=qFindChild<X *>(mainwindowpointer,n);
00136
00137 if(findobj==NULL)
00138 {
00139
00140 printf("find_object(): Can't find object with name %s\n",qPrintable(n));
00141 exit(1);
00142 return NULL;
00143 }
00144 else
00145 {
00146
00147
00148 X *obj=qobject_cast<X *>(findobj);
00149
00150 if(obj==0)
00151 {
00152
00153 printf("find_object(): Object %s find, but can't convert type. Check <type> in function call\n",qPrintable(n));
00154 exit(1);
00155 return NULL;
00156 }
00157 else
00158 return obj;
00159 }
00160 }
00161
00162
00163 #endif // __MAIN_H__