Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prompts with ENTER are consistently coloured #55

Merged
merged 3 commits into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified credits
Binary file not shown.
18 changes: 15 additions & 3 deletions include/general.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,23 @@ extern BYTE _oserror;
#define KASSE_AUTHORS "phil_fry, sECuRE, sur5r, mxf, ada"

#define MENU_KEY(key, label) \
textcolor(TC_YELLOW); \
cprintf(key); \
textcolor(TC_LIGHT_GRAY); \
cprintf(") " label);

#define ERROR(message) \
do { \
textcolor(TC_RED); \
cprintf(message); \
textcolor(TC_LIGHT_GRAY); \
} while (0)

#define GOOD(message) \
do { \
textcolor(TC_YELLOW); \
cprintf(key); \
textcolor(TC_GREEN); \
cprintf(message); \
textcolor(TC_LIGHT_GRAY); \
cprintf(") " label); \
} while (0)

/* C128 color codes, see PDF page 127 of
Expand Down
29 changes: 20 additions & 9 deletions src/credit_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,17 @@ static void print_item(BYTE i) {
cprintf("%2d", i);
textcolor(TC_LIGHT_GRAY);
// TODO: switch to MAX_CREDIT_NAME_LENGTH once that is increased
cprintf(" %-" xstr(MAX_ITEM_NAME_LENGTH) "s \xDD%3s ",
credits.credits[i].nickname, buffer);
if (credit < 0) {
textcolor(TC_LIGHT_RED);
}
cprintf(" %-" xstr(MAX_ITEM_NAME_LENGTH) "s ", credits.credits[i].nickname);
textcolor(TC_LIGHT_GRAY);
cprintf("\xDD");
if (credit < 0) {
textcolor(TC_LIGHT_RED);
}
cprintf("%3s ", buffer);
textcolor(TC_LIGHT_GRAY);
}

static void print_line(BYTE i) {
Expand Down Expand Up @@ -168,7 +177,8 @@ static void deposit_credit_idx(int8_t i) {
credit->credit += (signed int)deposit;

print_the_buffer();
cprintf("\r\nEinzahlung durchgef" uUML "hrt, dr" uUML "cke RETURN...\r\n");
cprintf("\r\n\r\nEinzahlung durchgef" uUML "hrt");
GOOD("\r\nDr" uUML "cke RETURN...\r\n");
cget_return();
}

Expand All @@ -188,8 +198,8 @@ static void new_credit(void) {
int credit;

if (credits.num_items == MAX_CREDIT_ITEMS) {
cprintf("\rEs ist bereits die maximale Anzahl an Eintr" aUML
"gen erreicht, dr" uUML "cke RETURN...\r\n");
ERROR("\rEs ist bereits die maximale Anzahl an Eintr" aUML
"gen erreicht, dr" uUML "cke RETURN...\r\n");
cget_return();
return;
}
Expand All @@ -200,7 +210,7 @@ static void new_credit(void) {
return;

if (find_credit_idx(name) >= 0) {
cprintf("\rNickname existiert bereits, dr" uUML "cke RETURN...\r\n");
ERROR("\r\nNickname existiert bereits, dr" uUML "cke RETURN...\r\n");
cget_return();
return;
}
Expand All @@ -209,6 +219,7 @@ static void new_credit(void) {
credit = cget_number(0);
if (credit < 0) {
cprintf("\r\nLege mit 0 an und verkaufe Waren oder Freitext\r\n");
GOOD("\r\nDr" uUML "cke RETURN...\r\n");
cget_return();
return;
}
Expand Down Expand Up @@ -275,7 +286,7 @@ void credit_manager(void) {
break;
case 's':
save_credits();
cprintf("\r\nDr" uUML "cke RETURN...\r\n");
GOOD("\r\nDr" uUML "cke RETURN...\r\n");
cget_return();
break;
case 'f':
Expand Down Expand Up @@ -306,11 +317,11 @@ void credit_manager(void) {
break;
case 'z':
save_credits();
cprintf("\r\nDr" uUML "cke RETURN...\r\n");
GOOD("\r\nDr" uUML "cke RETURN...\r\n");
cget_return();
return;
default:
cprintf("Unbekannter Befehl, dr" uUML "cke RETURN...\r\n");
ERROR("\r\nUnbekannter Befehl, dr" uUML "cke RETURN...\r\n");
cget_return();
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/itemz.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ static void new_item(void) {
int price, times_sold;

if (status.num_items == MAX_ITEMS) {
cprintf("\rEs ist bereits die maximale Anzahl an Eintr" aUML
"gen erreicht, dr" uUML "cke RETURN...\r\n");
ERROR("\rEs ist bereits die maximale Anzahl an Eintr" aUML
"gen erreicht, dr" uUML "cke RETURN...\r\n");
cget_return();
return;
}
Expand Down Expand Up @@ -142,11 +142,11 @@ void itemz_manager() {
break;
case 'z':
save_items();
cprintf("\r\nDr" uUML "cke RETURN...\r\n");
GOOD("\r\nDr" uUML "cke RETURN...\r\n");
cget_return();
return;
default:
cprintf("Unbekannter Befehl, dr" uUML "cke RETURN...\r\n");
ERROR("\r\nUnbekannter Befehl, dr" uUML "cke RETURN...\r\n");
cget_return();
}
}
Expand Down
40 changes: 22 additions & 18 deletions src/kasse.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ static signed int buy(char *name, int32_t price) {
einheiten = cget_number(1);

if (einheiten > 100 || einheiten < -100 || einheiten == 0) {
cprintf("\r\nEinheit nicht in [-100, 100] oder 0, Abbruch, dr" uUML "cke "
"RETURN...\r\n");
ERROR("\r\n\r\nEinheit nicht in [-100, 100] oder 0, Abbruch");
GOOD("\r\nDr" uUML "cke RETURN...\r\n");
cget_return();
return 1;
}
Expand All @@ -213,9 +213,10 @@ static signed int buy(char *name, int32_t price) {
credit->credit);
exit(1);
}
cprintf("\r\n%s hat nicht genug Geld (%s). e) einzahlen a) abbruch t) "
"trotzdem\r\n",
nickname, rest);
cprintf("\r\n%s hat nicht genug Guthaben (%s)", nickname, rest);
MENU_KEY(" e", "einzahlen");
MENU_KEY(" a", "abbruch");
MENU_KEY(" t", "trotzdem");
c = cgetc();
if (c == 'e') {
deposit_credit(nickname);
Expand All @@ -233,18 +234,15 @@ static signed int buy(char *name, int32_t price) {
exit(1);
}

textcolor(TC_LIGHT_GREEN);
cprintf("\r\nVerbleibendes Guthaben f" uUML "r %s: %s. Dr" uUML
"cke RETURN...\r\n",
nickname, rest);
textcolor(TC_LIGHT_GRAY);
cprintf("\r\n\r\nVerbleibendes Guthaben f" uUML "r %s: %s.", nickname,
rest);
GOOD("\r\nDr" uUML "cke RETURN...\r\n");
cget_return();
matches++;
} else {
textcolor(TC_LIGHT_RED);
cprintf("\r\nNickname nicht gefunden in der Guthabenverwaltung! Abbruch, "
"dr" uUML "cke RETURN...\r\n");
textcolor(TC_LIGHT_GRAY);
ERROR("\r\n\r\nNickname nicht gefunden in der Guthabenverwaltung! "
"Abbruch!");
GOOD("\r\nDr" uUML "cke RETURN...\r\n");
cget_return();
return 0;
}
Expand All @@ -260,7 +258,8 @@ static signed int buy(char *name, int32_t price) {

void buy_stock(BYTE n) {
if (n >= status.num_items || status.status[n].item_name == NULL) {
cprintf("FEHLER: Diese Einheit existiert nicht.\r\n");
ERROR("\r\nDiese Einheit existiert nicht.");
GOOD("\r\nDr" uUML "cke RETURN\r\n");
cget_return();
return;
}
Expand All @@ -283,7 +282,8 @@ void buy_custom(void) {
price = cget_number(0);

if (price == 0) {
cprintf("Kauf abgebrochen, dr" uUML "cke RETURN...\r\n");
ERROR("\r\nKauf abgebrochen");
GOOD("\r\nDr" uUML "cke RETURN\r\n");
cget_return();
return;
}
Expand Down Expand Up @@ -392,7 +392,8 @@ int main(void) {
save_items();
save_credits();
log_flush();
cprintf("\r\nDr" uUML "cke RETURN...\r\n");
GOOD("\r\nDr" uUML "cke RETURN...\r\n");
cget_return();
} else if (*c == 'g') {
credit_manager();
} else if (*c == 'i') {
Expand All @@ -404,9 +405,12 @@ int main(void) {
save_items();
save_credits();
log_flush();
cprintf("\r\nDr" uUML "cke RETURN...\r\n");
GOOD("\r\nDr" uUML "cke RETURN...\r\n");
cget_return();
break;
} else {
ERROR("\r\nUnbekannter Befehl, dr" uUML "cke RETURN...\r\n");
cget_return();
}
}
clrscr();
Expand Down
Loading