made some progress on the DvorakMSDOS remake with the login screen
This commit is contained in:
parent
0976db30e0
commit
95696a0311
1 changed files with 76 additions and 32 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
#include "dvorakmsdos.h"
|
#include "dvorakmsdos.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <conio.h>
|
#include <conio.h>
|
||||||
#define GETCH() _getch()
|
#define GETCH() _getch()
|
||||||
|
|
@ -12,10 +13,7 @@
|
||||||
char getch();
|
char getch();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void msmain() {
|
void loginmenu(int USER, int PASS) {
|
||||||
#ifndef _WIN32
|
|
||||||
while (1) {
|
|
||||||
char GETCH();
|
|
||||||
struct winsize w;
|
struct winsize w;
|
||||||
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
|
ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
|
||||||
// we now use w.ws_col as width and w.ws_row as height
|
// we now use w.ws_col as width and w.ws_row as height
|
||||||
|
|
@ -27,10 +25,18 @@ void msmain() {
|
||||||
printf("Welcome To DvorakMSDOS!");
|
printf("Welcome To DvorakMSDOS!");
|
||||||
repeat++;
|
repeat++;
|
||||||
} else if ((w.ws_row/2+2 == height) && repeat == 1) {
|
} else if ((w.ws_row/2+2 == height) && repeat == 1) {
|
||||||
|
if (USER == 1) {
|
||||||
|
printf("Username: admin ");
|
||||||
|
} else {
|
||||||
printf("Username: ");
|
printf("Username: ");
|
||||||
|
}
|
||||||
repeat++;
|
repeat++;
|
||||||
} else if ((w.ws_row/2+1 == height) && repeat == 2) {
|
} else if ((w.ws_row/2+1 == height) && repeat == 2) {
|
||||||
printf("Password: ████████████████████████████████████████████████████████████████████");
|
if (PASS == 1) {
|
||||||
|
printf("Password: **** █████████████████████████████████████████████████████████████████████");
|
||||||
|
} else {
|
||||||
|
printf("Password: █████████████████████████████████████████████████████████████████████");
|
||||||
|
}
|
||||||
repeat++;
|
repeat++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -38,21 +44,59 @@ void msmain() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void msmain() {
|
||||||
|
int level = 0;
|
||||||
|
int userfail = 0;
|
||||||
|
#ifndef _WIN32
|
||||||
|
while (1) {
|
||||||
|
char GETCH();
|
||||||
|
switch (level) {
|
||||||
|
case 0:
|
||||||
|
loginmenu(0, 0);
|
||||||
|
if (userfail == 0) {
|
||||||
printf("Enter your username: ");
|
printf("Enter your username: ");
|
||||||
char username[13];
|
} else {
|
||||||
while (username != "admin") {
|
printf("Wrong username, Try again: ");
|
||||||
fflush(stdout);
|
|
||||||
while (getchar() != '\n') {}
|
|
||||||
scanf(" %12[^\n]", username);
|
|
||||||
if (username == "admin") {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
system("clear");
|
|
||||||
fflush(stdout); // this forces the buffer to print NOW, fixing the "bug" in which it prints out everything AFTER the next line (scanf)
|
fflush(stdout); // this forces the buffer to print NOW, fixing the "bug" in which it prints out everything AFTER the next line (scanf)
|
||||||
|
char username[13];
|
||||||
|
scanf(" %12[^\n]", username);
|
||||||
|
while (getchar() != '\n') {}
|
||||||
|
if (strcmp(username, "admin") != 0) {
|
||||||
|
userfail = 1;
|
||||||
|
} else {
|
||||||
|
userfail = 0;
|
||||||
|
system("clear");
|
||||||
|
level++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
loginmenu(1, 0);
|
||||||
|
if (userfail == 0) {
|
||||||
|
printf("Enter your password: ");
|
||||||
|
} else {
|
||||||
|
printf("Wrong password, Try again: ");
|
||||||
|
}
|
||||||
|
fflush(stdout); // this forces the buffer to print NOW, fixing the "bug" in which it prints out everything AFTER the next line (scanf)
|
||||||
|
char password[13];
|
||||||
|
scanf(" %12[^\n]", password);
|
||||||
|
while (getchar() != '\n') {}
|
||||||
|
if (strcmp(password, "1234") != 0) {
|
||||||
|
userfail = 1;
|
||||||
|
} else {
|
||||||
|
int userfail = 0;
|
||||||
|
system("clear");
|
||||||
|
level++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
printf("you did it");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
printf("fuck you for using windows get out of here and run this on a better unix system") // ofcourse this is temporary
|
printf("fuck you for using windows get out of here and run this on an unix system") // ofcourse this is temporary
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue