void parsecmd(int argc,char *argv[]) { char *word; int argch; int16_t arg,i=0,j,speedmul; bool sf, gs, norepf, hasopt; gs = norepf = false; #if defined(UNIX) digger_log = stderr; #else digger_log = fopen("DIGGER.log", "w+"); #endif for (arg=1;arg<argc;arg++) { word=argv[arg]; if (word[0]=='/' || word[0]=='-') { #if defined(UNIX) && defined(_SDL) argch = getarg(word[1], "FOUH?QM2BCKVL:R:P:S:E:G:X:A:I:", &hasopt); #else argch = getarg(word[1], "OUH?QM2BCKVL:R:P:S:E:G:A:I:", &hasopt); #endif i = 2; if (argch != -1 && hasopt && word[2] == ':') { i = 3; } if (argch == 'L') { j=0; while (word[i]!=0) levfname[j++]=word[i++]; levfname[j]=word[i]; levfflag=true; } #if defined(UNIX) && defined(_SDL) if (argch == 'X') { unsigned int x11_parent; x11_parent = strtol (&word[i], 0, 0); sdl_set_x11_parent(x11_parent); } if (argch == 'F') { sdl_enable_fullscreen(); } #endif if (argch =='R') recname(word+i); if (argch =='P' || argch =='E') { maininit(); openplay(word+i); if (escape) norepf=true; } if (argch == 'E') { finish(); if (escape) exit(0); exit(1); } if (argch =='O' && !norepf) { arg=0; continue; } if (argch == 'S') { speedmul=0; while (word[i]!=0) speedmul=10*speedmul+word[i++]-'0'; if (speedmul > 0) { ftime=speedmul*2000l; } else { ftime = 1; } gs=true; } if (argch == 'I') sscanf(word+i,"%hi",&startlev); if (argch == 'U') unlimlives=true; if (argch == '?' || argch == 'H' || argch == -1) { if (argch == -1) { fprintf(stderr, "Unknown option \"%c%c\"\n", word[0], word[1]); } finish(); printf("DIGGER - Copyright (c) 1983 Windmill software\n" "Restored 1998 by AJ Software\n" #ifdef ARM "Acorn port by Julian Brown\n" #endif "http://www.digger.org\n" "Version: "DIGGER_VERSION"\n\n" "Command line syntax:\n" " DIGGER [[/S:]speed] [[/L:]level file] [/C] [/B] [/Q] [/M] " "[/P:playback file]\n" " [/E:playback file] [/R:record file] [/O] [/K[A]] " "[/G[:time]] [/2]\n" " [/A:device,port,irq,dma,rate,length] [/V] [/U] " "[/I:level] " #if defined(UNIX) && defined(_SDL) "[/X:xid]" #endif "\n\n" #ifndef UNIX "/C = Use CGA graphics\n" "/B = Use BIOS palette functions for CGA (slow!)\n" #endif "/Q = Quiet mode (no sound at all) " "/M = No music\n" "/R = Record graphics to file\n" "/P = Playback and restart program " "/E = Playback and exit program\n" "/O = Loop to beginning of command line\n" "/K = Redefine keyboard\n" "/G = Gauntlet mode\n" "/2 = Two player simultaneous mode\n" "/A = Use alternate sound device\n" #ifndef UNIX "/V = Synchronize timing to vertical retrace\n" #endif #if defined(UNIX) && defined(_SDL) "/X = Embed in window\n" #endif "/U = Allow unlimited lives\n" "/I = Start on a level other than 1\n"); exit(1); } if (argch == 'Q') soundflag=false; if (argch == 'M') musicflag=false; if (argch == '2') diggers=2; if (argch == 'B' || argch == 'C') { ddap->ginit=cgainit; ddap->gpal=cgapal; ddap->ginten=cgainten; ddap->gclear=cgaclear; ddap->ggetpix=cgagetpix; ddap->gputi=cgaputi; ddap->ggeti=cgageti; ddap->gputim=cgaputim; ddap->gwrite=cgawrite; ddap->gtitle=cgatitle; if (argch == 'B') biosflag=true; ddap->ginit(); ddap->gpal(0); } if (argch == 'K') { if (word[2]=='A' || word[2]=='a') redefkeyb(true); else redefkeyb(false); } if (argch =='A') sscanf(word+i,"%hu,%hx,%hu,%hu,%hu,%hu",&sound_device,&sound_port,&sound_irq, &sound_dma,&sound_rate,&sound_length); if (argch == 'Q') quiet=true; if (argch == 'V') synchvid=true; if (argch == 'G') { gtime=0; while (word[i]!=0) gtime=10*gtime+word[i++]-'0'; if (gtime>3599) gtime=3599; if (gtime==0) gtime=120; gauntlet=true; } } else { i=strlen(word); if (i<1) continue; sf=true; if (!gs) for (j=0;j<i;j++) if (word[j]<'0' || word[j]>'9') { sf=false; break; } if (sf) { speedmul=0; j=0; while (word[j]!=0) speedmul=10*speedmul+word[j++]-'0'; gs=true; if (speedmul > 0) { ftime=speedmul*2000l; } else { ftime = 1; } } else { j=0; while (word[j]!=0) { levfname[j]=word[j]; j++; } levfname[j]=word[j]; levfflag=true; } } } if (levfflag) { if (read_levf(levfname) != 0) { #if defined(DIGGER_DEBUG) fprintf(digger_log, "levels load error\n"); #endif levfflag = false; } } }
MainWindow::MainWindow() { quitdlg=0; editdlg=0; helpdlg=0; windlg=0; losedlg=0; //QSound::play("C:/Users/Altair/Documents/Qt/Inversion/sound.wav"); QGridLayout* layout1 = new QGridLayout(); QHBoxLayout* layout4 = new QHBoxLayout(); QVBoxLayout *layout3 = new QVBoxLayout; for (int i=0; i < 5; i++) { for (int j=0; j < 5; j++) { b[i][j] = new QPushButton(this); grid[i][j]=1; b[i][j]->setStyleSheet(" QPushButton { border-image: url(C:/Users/Altair/Documents/Qt/Inversion/on.png) 1 1 1 1 ;color: grey;border-top: 3px transparent; border-bottom: 3px transparent;border-right: 10px transparent;border-left: 10px transparent;}"); b[i][j]->setMinimumSize(100, 100); layout1->addWidget(b[i][j], i, j); } } combo= new QComboBox(); QLabel *label = new QLabel("Choose the puzzle :"); label->setFixedSize(40,40); combo->addItem("--"); for (int i=1;i<=10;i++){ combo->addItem("Puzzle "+QString::number(i)); } connect(combo,SIGNAL(currentIndexChanged(int)),this,SLOT(opencombo(int))); combo->setFixedSize(40,40); combo->setStyleSheet("QWidget { background-color: gray;border-style: outset;}"); layout3->addWidget(label); layout3->addWidget(combo); layout4->addLayout(layout3); layout4->addLayout(layout1); QVBoxLayout *layout6= new QVBoxLayout(); gameTurns=0;gameTimes=0; gameScore=0;gamemin=0;gamesec=0; lblTurn = new QLabel(this); lblTurn->setFixedSize(30, 30); layout6->addWidget(lblTurn); lblTimes = new QLabel(this); lblTimes->setFixedSize(30, 30); layout6->addWidget(lblTimes); lblScore = new QLabel(this); lblScore->setFixedSize(30, 30); layout6->addWidget(lblScore); QSound* sound=new QSound("C:/Users/Altair/Documents/Qt/Inversion/sound.wav"); sound->setLoops(-1); soundplay = new QPushButton(this); soundplay->setMaximumSize(100, 100); soundplay->setStyleSheet("QPushButton{border-image: url(C:/Users/Altair/Documents/Qt/Inversion/sound.png)3 10 3 10;color: grey;border-top: 3px transparent; border-bottom: 3px transparent;border-right: 10px transparent;border-left: 10px transparent;}"); QObject::connect(soundplay,SIGNAL(clicked()),sound,SLOT(play())); layout6->addWidget(soundplay); soundstop = new QPushButton(this); soundstop->setMaximumSize(100, 100); soundstop->setStyleSheet("QPushButton{border-image: url(C:/Users/Altair/Documents/Qt/Inversion/mute.png)3 10 3 10;color: grey;border-top: 3px transparent; border-bottom: 3px transparent;border-right: 10px transparent;border-left: 10px transparent;}"); QObject::connect(soundstop,SIGNAL(clicked()),sound,SLOT(stop())); layout6->addWidget(soundstop); layout4->addLayout(layout6); this->setWindowFlags(Qt::FramelessWindowHint); this->setStyleSheet("QWidget {background: url('C:/Users/Altair/Documents/Qt/Inversion/back.png')no-repeat ; border-style: outset; border-width: 2px;border-radius: 10px;border-color: beige;font: bold 14px;min-width: 10em;padding: 6px; }"); QVBoxLayout *layoutPrincipal=new QVBoxLayout(this); QHBoxLayout *layout2=new QHBoxLayout(); quitdlg= new quitdial(this); helpdlg= new helpdial(this); editdlg= new editdial(this); windlg= new windial(this); losedlg= new losedial(this); player= new QPushButton("Play"); player->setCheckable(true); player->setStyleSheet(" QPushButton { border-image: url(C:/Users/Altair/Documents/Qt/Inversion/bouton.png) 3 10 3 10;color: grey;border-top: 3px transparent; border-bottom: 3px transparent;border-right: 10px transparent;border-left: 10px transparent;}"); connect(player, SIGNAL(clicked()), this, SLOT(openplay())); connect(player, SIGNAL(clicked()), this, SLOT(clik2())); player->setMinimumSize(50,50); layout2->addWidget(player); solve = new QPushButton("Solve"); solve->setCheckable(true); solve->setStyleSheet(" QPushButton { border-image: url(C:/Users/Altair/Documents/Qt/Inversion/bouton.png) 3 10 3 10;color: grey;border-top: 3px transparent; border-bottom: 3px transparent;border-right: 10px transparent;border-left: 10px transparent;}"); solve->setMinimumSize(50,50); solve->setEnabled(false); connect(solve, SIGNAL(clicked()), this, SLOT(opensolve())); layout2->addWidget(solve); mix= new QPushButton("Mix"); mix->setStyleSheet(" QPushButton { border-image: url(C:/Users/Altair/Documents/Qt/Inversion/bouton.png) 3 10 3 10;color: grey;border-top: 3px transparent; border-bottom: 3px transparent;border-right: 10px transparent;border-left: 10px transparent;}"); mix->setMinimumSize(50,50); connect(mix, SIGNAL(clicked()), this, SLOT(openmix())); layout2->addWidget(mix); resett = new QPushButton("Reset"); resett->setMinimumSize(50,50); resett->setStyleSheet(" QPushButton { border-image: url(C:/Users/Altair/Documents/Qt/Inversion/bouton.png) 3 10 3 10;color: grey;border-top: 3px transparent; border-bottom: 3px transparent;border-right: 10px transparent;border-left: 10px transparent;}"); connect(resett, SIGNAL(clicked()), this, SLOT(openreset())); layout2->addWidget(resett); edit = new QPushButton("Edit"); edit->setMinimumSize(50,50); edit->setStyleSheet(" QPushButton { border-image: url(C:/Users/Altair/Documents/Qt/Inversion/bouton.png) 3 10 3 10;color: grey;border-top: 3px transparent; border-bottom: 3px transparent;border-right: 10px transparent;border-left: 10px transparent;}"); edit->setCheckable(true); connect(edit, SIGNAL(clicked()), this, SLOT(openedit())); connect(edit, SIGNAL(clicked()), this, SLOT(clik1())); layout2->addWidget(edit); hel = new QPushButton("Help"); hel->setMinimumSize(50,50); hel->setStyleSheet(" QPushButton { border-image: url(C:/Users/Altair/Documents/Qt/Inversion/bouton.png) 3 10 3 10;color: grey;border-top: 3px transparent; border-bottom: 3px transparent;border-right: 10px transparent;border-left: 10px transparent;}"); connect(hel, SIGNAL(clicked()), this, SLOT(openhelp())); layout2->addWidget(hel); boutonQuitter = new QPushButton("Quit"); boutonQuitter->setMinimumSize(50,50); boutonQuitter->setStyleSheet(" QPushButton { border-image: url(C:/Users/Altair/Documents/Qt/Inversion/bouton.png) 3 10 3 10;color: grey;border-top: 3px transparent; border-bottom: 3px transparent;border-right: 10px transparent;border-left: 10px transparent;}"); QWidget::connect(boutonQuitter, SIGNAL(clicked()), this, SLOT(openquit())); layout2->addWidget(boutonQuitter); layoutPrincipal->addLayout(layout2); layoutPrincipal->addLayout(layout4); this->resize(1370,600); setLayout(layoutPrincipal); gameTimer = new QTimer(); gameTimer->setInterval(1000); gameTimer->start(); connect(gameTimer,SIGNAL(timeout()),this,SLOT(gameTimer_timeout())); refreshScore(); }
void parsecmd(int argc,char *argv[]) { char *word; Sint4 arg,i,j,speedmul; bool sf,gs=false,norepf=false; FILE *levf; for (arg=1;arg<argc;arg++) { word=argv[arg]; if (word[0]=='/' || word[0]=='-') { if (word[1]=='L' || word[1]=='l' || word[1]=='R' || word[1]=='r' || word[1]=='P' || word[1]=='p' || word[1]=='S' || word[1]=='s' || word[1]=='E' || word[1]=='e' || word[1]=='G' || word[1]=='g' || word[1]=='A' || word[1]=='a' || word[1]=='I' || word[1]=='i') if (word[2]==':') i=3; else i=2; if (word[1]=='L' || word[1]=='l') { j=0; while (word[i]!=0) levfname[j++]=word[i++]; levfname[j]=word[i]; levfflag=true; } if (word[1]=='R' || word[1]=='r') recname(word+i); if (word[1]=='P' || word[1]=='p' || word[1]=='E' || word[1]=='e') { openplay(word+i); if (escape) norepf=true; } if (word[1]=='E' || word[1]=='e') { finish(); if (escape) exit(0); exit(1); } if ((word[1]=='O' || word[1]=='o') && !norepf) { arg=0; continue; } if (word[1]=='S' || word[1]=='s') { speedmul=0; while (word[i]!=0) speedmul=10*speedmul+word[i++]-'0'; ftime=speedmul*2000l; gs=true; } if (word[1]=='I' || word[1]=='i') sscanf(word+i,"%u",&startlev); if (word[1]=='U' || word[1]=='u') unlimlives=true; if (word[1]=='?' || word[1]=='h' || word[1]=='H') { finish(); printf("DIGGER - Copyright (c) 1983 Windmill software\n" "Restored 1998 by AJ Software\n" "http://www.digger.org\n" "Version: "DIGGER_VERSION"\n\n" "Command line syntax:\n" " DIGGER [[/S:]speed] [[/L:]level file] [/C] [/B] [/Q] [/M] " "[/P:playback file]\n" " [/E:playback file] [/R:record file] [/O] [/K[A]] " "[/G[:time]] [/2]\n" " [/A:device,port,irq,dma,rate,length] [/V] [/U] " "[/I:level]\n\n" "/Q = Quiet mode (no sound at all) " "/M = No music\n" "/R = Record graphics to file\n" "/P = Playback and restart program " "/E = Playback and exit program\n" "/O = Loop to beginning of command line\n" "/K = Redefine keyboard\n" "/G = Gauntlet mode\n" "/2 = Two player simultaneous mode\n" "/A = Use alternate sound device\n" "/U = Allow unlimited lives\n" "/I = Start on a level other than 1\n"); exit(1); } if (word[1]=='Q' || word[1]=='q') soundflag=false; if (word[1]=='M' || word[1]=='m') musicflag=false; if (word[1]=='2') diggers=2; if (word[1]=='K' || word[1]=='k') if (word[2]=='A' || word[2]=='a') redefkeyb(true); else redefkeyb(false); if (word[1]=='A' || word[1]=='a') { sscanf(word+i,"%u,%x,%u,%u,%u,%u",&sound_device,&sound_port,&sound_irq, &sound_dma,&sound_rate,&sound_length); killsound(); volume=1; setupsound=s1setupsound; killsound=s1killsound; fillbuffer=s1fillbuffer; initint8=s1initint8; restoreint8=s1restoreint8; soundoff=s1soundoff; setspkrt2=s1setspkrt2; settimer0=s1settimer0; timer0=s1timer0; settimer2=s1settimer2; timer2=s1timer2; soundinitglob(sound_port,sound_irq,sound_dma,sound_length,sound_rate); initsound(); } if (word[1]=='V' || word[1]=='v') synchvid=true; if (word[1]=='G' || word[1]=='g') { gtime=0; while (word[i]!=0) gtime=10*gtime+word[i++]-'0'; if (gtime>3599) gtime=3599; if (gtime==0) gtime=120; gauntlet=true; } } else { i=strlen(word); if (i<1) continue; sf=true; if (!gs) for (j=0;j<i;j++) if (word[j]<'0' || word[j]>'9') { sf=false; break; } if (sf) { speedmul=0; j=0; while (word[j]!=0) speedmul=10*speedmul+word[j++]-'0'; gs=true; ftime=speedmul*2000l; } else { j=0; while (word[j]!=0) { levfname[j]=word[j]; j++; } levfname[j]=word[j]; levfflag=true; } } } if (levfflag) { levf=fopen(levfname,"rb"); if (levf==NULL) { strcat(levfname,".DLF"); levf=fopen(levfname,"rb"); } if (levf==NULL) levfflag=false; else { fread(&bonusscore,2,1,levf); fread(leveldat,1200,1,levf); fclose(levf); } } }