Started work on a control center

This commit is contained in:
Andrew Pamment 2017-03-27 13:12:46 +10:00
parent 3b1add6a40
commit fdf9470ae7
2 changed files with 139 additions and 0 deletions

39
utils/ccenter/Makefile Normal file
View File

@ -0,0 +1,39 @@
OS := $(shell uname -s)
ifeq ($(OS), FreeBSD)
CC=cc
CFLAGS=-I/usr/local/include
LDFLAGS=-L/usr/local/lib
endif
ifeq ($(OS), NetBSD)
CC=cc
CFLAGS=-I/usr/pkg/include
LDFLAGS=-L/usr/pkg/lib
endif
ifeq ($(OS), Linux)
CC=gcc
CFLAGS=
LDFLAGS=
endif
ifeq ($(OS), Darwin)
CC=cc
CFLAGS=
LDFLAGS=
endif
CC=cc
CFLAGS=-I/usr/local/include
DEPS = main.c
OBJ = main.o
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS) -I../../deps/cdk-5.0-20161210/include/
ccenter: $(OBJ)
$(CC) -o ccenter -o $@ $^ ../../deps/cdk-5.0-20161210/libcdk.a $(CFLAGS) $(LDFLAGS) -lncurses
.PHONY: clean
clean:
rm -f $(OBJ) ccenter

100
utils/ccenter/main.c Normal file
View File

@ -0,0 +1,100 @@
#include <curses.h>
#include <cdk.h>
CDKSCREEN *cdkscreen = 0;
void displayLabel() {
CDKLABEL *label;
char *message[] ={
" ,$.",
" `S$$$S'",
" .$²$. $$",
" `Sn. ' ` $$",
" $$s,sSSsSSSs ,sSSSs. ,4S$$Ss $$ $$$ ,sS$$Ss, $$ $$ ,sSSSs.",
" $$$² $$² $$ `' $$ $$' `$$. $$' $$' `4S $$ $$ `' $$",
" $$ )$ $$ ,$$$$$$ $$ .$$ $$ $$ $$$$ ,$$$$$$",
" $$ $$ $$ $$ $$ `$$$$$$$² $$, $$ ,sS $$ $$ $$ $$",
" $$' $$ `$$$$`SS $$, $$$ `4S$$SS' $$ $$ `$$$$`SS",
" `$$. ,sS$$$s`$$ $$. .,",
" `$Ss $$ $$ sS sS sS$s `$$, ,$$",
" `4$$$$$$$' $$$$. $$$$. $$, ²S$$$$S'",
" $$ $$ $$ $$ `$$",
" $$$$' $$$$' 4$$'"};
label = newCDKLabel(cdkscreen, COLS / 2 - 35, LINES / 2 - 7, message, 14, FALSE, FALSE);
drawCDKLabel(label, FALSE);
}
void displayAbout() {
CDKDIALOG *aboutWindow;
char *message[] = {"<C>Control Centre for MagickaBBS",
"<C>Copyright (c) 2017 Andrew Pamment"};
char *buttons[] = {"OK"};
aboutWindow = newCDKDialog(cdkscreen, 10, 5, message, 2, buttons, 1, 0, TRUE, TRUE, FALSE);
activateCDKDialog(aboutWindow, 0);
destroyCDKDialog(aboutWindow);
}
int main(int argc, char **argv) {
WINDOW *cursesWin = 0;
CDK_PARAMS params;
CDKMENU *mainMenu;
int selection;
int doexit = 0;
char *menuItems[MAX_MENU_ITEMS][MAX_SUB_ITEMS];
int menuLength[] = {7, 2};
menuItems[0][0] = strdup("Main");
menuItems[0][1] = strdup("System Config");
menuItems[0][2] = strdup("System Paths");
menuItems[0][3] = strdup("Mail Conferences");
menuItems[0][4] = strdup("File Directories");
menuItems[0][5] = strdup("Text Files");
menuItems[0][6] = strdup("Exit");
menuItems[1][0] = strdup("Misc");
menuItems[1][1] = strdup("About");
int locations[1] = {LEFT, RIGHT};
CDKparseParams(argc, argv, &params, CDK_CLI_PARAMS);
cursesWin = initscr();
cdkscreen = initCDKScreen(cursesWin);
initCDKColor();
displayLabel();
mainMenu = newCDKMenu(cdkscreen, menuItems, 2, menuLength, locations, TOP, A_NORMAL, A_NORMAL);
setCDKMenuTitleHighlight(mainMenu, A_STANDOUT);
setCDKMenuSubTitleHighlight(mainMenu, A_STANDOUT);
while(!doexit) {
selection = activateCDKMenu(mainMenu, 0);
if (mainMenu->exitType == vESCAPE_HIT) {
doexit = 1;
} else if (mainMenu->exitType == vNORMAL) {
switch(selection / 100) {
case 0:
switch (selection % 100) {
case 5:
doexit = 1;
break;
}
break;
case 1:
switch (selection % 100) {
case 0:
displayAbout();
break;
}
break;
}
}
}
destroyCDKScreen(cdkscreen);
endCDK();
return 0;
}