From fdf9470ae73881d50084441a53ab35998323798c Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Mon, 27 Mar 2017 13:12:46 +1000 Subject: [PATCH] Started work on a control center --- utils/ccenter/Makefile | 39 ++++++++++++++++ utils/ccenter/main.c | 100 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 utils/ccenter/Makefile create mode 100644 utils/ccenter/main.c diff --git a/utils/ccenter/Makefile b/utils/ccenter/Makefile new file mode 100644 index 0000000..ad0b074 --- /dev/null +++ b/utils/ccenter/Makefile @@ -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 diff --git a/utils/ccenter/main.c b/utils/ccenter/main.c new file mode 100644 index 0000000..6dc824e --- /dev/null +++ b/utils/ccenter/main.c @@ -0,0 +1,100 @@ +#include +#include + +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[] = {"Control Centre for MagickaBBS", + "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, ¶ms, 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; +} \ No newline at end of file