Skip to content
This repository
Browse code

flag as part of environment _I think_ works better as global variable

  • Loading branch information...
commit e616ee4c664a9848656c0554a955980db254d32f 1 parent e3d2ef5
Etam etam authored
3  OpenGOO.pro
@@ -74,7 +74,8 @@ SOURCES += \
74 74 mainmenu.cpp \
75 75 stickygoo.cpp \
76 76 backgroundwidget.cpp \
77   - backtracer.cpp
  77 + backtracer.cpp \
  78 + flags.cpp
78 79
79 80
80 81 ##FOR TOUCHPAD COMPILE
3  flags.cpp
... ... @@ -0,0 +1,3 @@
  1 +#include "flags.h"
  2 +
  3 +unsigned char flag = STANDARD;
9 flags.h
@@ -2,10 +2,11 @@
2 2 #define FLAGS_H
3 3
4 4
5   -#define STANDARD 0x0000
6   -#define DEBUG 0x0001
7   -#define OPENGL 0x0010
8   -#define ONLYTEXT 0x0100
  5 +static const unsigned char STANDARD = 0;
  6 +static const unsigned char DEBUG = 1<<0;
  7 +static const unsigned char OPENGL = 1<<1;
  8 +static const unsigned char ONLYTEXT = 1<<2;
9 9
  10 +extern unsigned char flag;
10 11
11 12 #endif // FLAGS_H
8 level.cpp
@@ -19,6 +19,8 @@
19 19 #include "ropejoint.h"
20 20 #include "collisionlistener.h"
21 21
  22 +#include "flags.h"
  23 +
22 24 #include <QPolygon>
23 25 #include <QTextFormat>
24 26
@@ -27,13 +29,11 @@
27 29 #define DELAY 10
28 30
29 31
30   -Level::Level(QRect geometry, QString level,BackGroundWidget *bg,int flag, QWidget *parent) :
  32 +Level::Level(QRect geometry, QString level,BackGroundWidget *bg,QWidget *parent) :
31 33 QWidget(parent), backGroundWidget(bg)
32 34 {
33 35 scale=1.0;
34 36 goal = 100;
35   - //Set enviroment flag
36   - this->flag=flag;
37 37
38 38 //set the display geometry
39 39 this->setGeometry(0,0,geometry.width(),geometry.height());
@@ -87,7 +87,7 @@ Level::Level(QRect geometry, QString level,BackGroundWidget *bg,int flag, QWidge
87 87 if (flag & DEBUG) qWarning()<<"Game variable initialized!";
88 88
89 89
90   - menu=new Menu(geometry,this,flag & DEBUG);
  90 + menu=new Menu(geometry,this);
91 91 onMenu=false;
92 92 mooving=false;
93 93 connect(menu,SIGNAL(eventClose()),this,SLOT(closeAll()));
5 level.h
@@ -28,7 +28,6 @@
28 28 #include "svglevelloader.h"
29 29
30 30 #include "qb2draw.h"
31   -#include "flags.h"
32 31
33 32
34 33 #include "backgroundwidget.h"
@@ -49,7 +48,7 @@ class Level : public QWidget //QWidget <--To use without openGL
49 48 {
50 49 Q_OBJECT
51 50 public:
52   - explicit Level(QRect geometry,QString level,BackGroundWidget *bg,int flag = STANDARD,QWidget *parent = 0); //Geometry is needed to have the display dimension information, level is the level to load
  51 + explicit Level(QRect geometry,QString level,BackGroundWidget *bg,QWidget *parent = 0); //Geometry is needed to have the display dimension information, level is the level to load
53 52 ~Level(){
54 53 clean();
55 54 }
@@ -59,8 +58,6 @@ class Level : public QWidget //QWidget <--To use without openGL
59 58
60 59 private:
61 60 float scale;
62   - //Run type flag
63   - int flag;
64 61 //LOADER
65 62 SvgLevelLoader * loader;
66 63 //PROPERTY
20 main.cpp
@@ -45,16 +45,14 @@ int main(int argc, char *argv[])
45 45 qsrand(QTime().currentTime().toString("hh:mm:ss.zzz").remove(':').toFloat());
46 46
47 47 bool forceScreen=false;
48   - int flag=STANDARD;
49 48 //Default is screen 0
50 49 int screen=0;
51   - QString arg;
52 50 //Check for the run parameters
53 51 for (int i=1;i<argc;i++){
54   - arg=QString::fromAscii(argv[i]);
  52 + QString arg(argv[i]);
55 53 //Check for debug Option
56 54 if (!arg.compare("-Debug",Qt::CaseInsensitive)){
57   - flag=flag|DEBUG;
  55 + flag|=DEBUG;
58 56 qWarning("DEBUG MODE ON");
59 57 }
60 58 //Check for screen force option
@@ -62,17 +60,17 @@ int main(int argc, char *argv[])
62 60 screen=arg.split('=').at(1).toInt(&forceScreen);
63 61 }
64 62 else if (!arg.compare("-opengl",Qt::CaseInsensitive)){
65   - flag=flag|OPENGL;
  63 + flag|=OPENGL;
66 64 }
67 65 else if (!arg.compare("-text",Qt::CaseInsensitive)){
68   - flag=flag|ONLYTEXT|DEBUG;
  66 + flag|=ONLYTEXT|DEBUG;
69 67 }
70 68 }
71   - if (flag & STANDARD ) qWarning("STD MODE");
  69 + if (flag == STANDARD) qWarning("STD MODE");
72 70 if (flag & OPENGL){ qWarning("OPENGL ACTIVATED");
73   - argc+=2;
74   - argv[argc-2]="-graphicssystem";
75   - argv[argc-1]="opengl";
  71 + argc+=2; // TODO: check if it's valid
  72 + argv[argc-2]=strdup("-graphicssystem");
  73 + argv[argc-1]=strdup("opengl");
76 74 }
77 75
78 76
@@ -120,7 +118,7 @@ int main(int argc, char *argv[])
120 118 }
121 119 else if (flag & DEBUG) qWarning()<<"Game dir exist!";
122 120 //Create the main widget in the bigger screen
123   - MainWidget w(a.desktop()->screenGeometry(screen),flag);
  121 + MainWidget w(a.desktop()->screenGeometry(screen));
124 122 w.show();
125 123
126 124 return a.exec();
9 mainwidget.cpp
... ... @@ -1,18 +1,17 @@
1 1 #include "mainwidget.h"
2 2 #include <QDebug>
3 3
4   -
5 4 #include "svglevelloader.h"
6 5
7   -MainWidget::MainWidget(QRect geometry,int flag,QWidget *parent)
  6 +#include "flags.h"
  7 +
  8 +MainWidget::MainWidget(QRect geometry,QWidget *parent)
8 9 : QWidget(parent)
9 10 {
10 11 this->showFullScreen();//To have the game full screen
11 12 this->setGeometry(geometry);
12 13 this->geometry=geometry;
13 14
14   - this->flag=flag;
15   -
16 15 levelS=new LevelSelector(geometry,this);//Create the level selector
17 16 levelS->show();//Show the level selector
18 17 level=NULL;
@@ -55,7 +54,7 @@ void MainWidget::levelSelected()//Create the level selected
55 54 bgWidget->setGeometry(0,0,geometry.width(),geometry.height());
56 55 bgWidget->show();
57 56
58   - level=new Level(geometry,levelS->getLevelSelected(),bgWidget,flag,this); //Create the level
  57 + level=new Level(geometry,levelS->getLevelSelected(),bgWidget,this); //Create the level
59 58 if (flag & DEBUG) qWarning()<<"LEVEL OBJECT INITILIZED";
60 59
61 60
3  mainwidget.h
@@ -13,7 +13,7 @@ class MainWidget : public QWidget
13 13 Q_OBJECT
14 14
15 15 public:
16   - MainWidget(QRect geometry,int flag,QWidget *parent = 0);
  16 + MainWidget(QRect geometry,QWidget *parent = 0);
17 17 ~MainWidget();
18 18 private:
19 19 Level *level;
@@ -21,7 +21,6 @@ class MainWidget : public QWidget
21 21 BackGroundWidget * bgWidget;
22 22
23 23 QRect geometry;
24   - int flag;
25 24 protected:
26 25 void closeEvent(QCloseEvent *);
27 26 private slots:
7 menu.cpp
@@ -6,11 +6,12 @@
@@ -27,7 +28,7 @@ void Menu::paint(QPainter &p){
3  menu.h
@@ -15,7 +15,7 @@ class Menu : public QObject
@@ -24,7 +24,6 @@ class Menu : public QObject

0 comments on commit e616ee4

Please sign in to comment.
Something went wrong with that request. Please try again.