int goc_barListener(GOC_HANDLER uchwyt, GOC_MSG wiesc, void* pBuf, unsigned int nBuf) { if ( wiesc == GOC_MSG_CREATE ) { GOC_StElement* elem = (GOC_StElement*)pBuf; GOC_HANDLER* retuchwyt = (GOC_HANDLER*)nBuf; GOC_StBar* pasek = (GOC_StBar*)malloc(sizeof(GOC_StBar)); memcpy(pasek, elem, sizeof(GOC_StElement)); pasek->tekst = NULL; pasek->nText = 0; pasek->start = 0; pasek->kursor = -1; *retuchwyt = (GOC_HANDLER)pasek; pasek->kolorNieaktywny = GOC_WHITE; pasek->kolorAktywny = pasek->color; pasek->kolorZaznaczony = GOC_WHITE | GOC_FBOLD; pasek->rozmiar = GOC_BAR_COUNTEDSIZE; pasek->color = pasek->kolorNieaktywny; goc_hkAdd(*retuchwyt, 0x600, GOC_EFLAGA_ENABLE | GOC_HKFLAG_SYSTEM, barHotKeyNext); goc_hkAdd(*retuchwyt, 0x601, GOC_EFLAGA_ENABLE | GOC_HKFLAG_SYSTEM, barHotKeyPrev); goc_hkAdd(*retuchwyt, 0x602, GOC_EFLAGA_ENABLE | GOC_HKFLAG_SYSTEM, barHotKeyNext); goc_hkAdd(*retuchwyt, 0x603, GOC_EFLAGA_ENABLE | GOC_HKFLAG_SYSTEM, barHotKeyPrev); return GOC_ERR_OK; } else if ( wiesc == GOC_MSG_DESTROY ) { GOC_StBar *pasek = (GOC_StBar*)uchwyt; int i; for (i=0; i<pasek->nText; i++) free(pasek->tekst[i]); pasek->tekst = goc_tableClear(pasek->tekst, &(pasek->nText)); return goc_elementDestroy(uchwyt); } else if ( wiesc == GOC_MSG_PAINT ) { return barPaint(uchwyt); } else if ( wiesc == GOC_MSG_FOCUS ) { return barFocus(uchwyt); } else if ( wiesc == GOC_MSG_FOCUSFREE ) { return barFreeFocus(uchwyt); } return GOC_ERR_UNKNOWNMSG; }
static int listInit(GOC_HANDLER uchwyt) { GOC_StList *lista = (GOC_StList*)uchwyt; // lista->pText = NULL; // lista->nText = 0; lista->nKolumna = 0; lista->pKolumna = NULL; lista->pTytul = NULL; lista->start = 0; lista->kursor = -1; lista->kolorRamkaAktywny = GOC_WHITE | GOC_FBOLD; lista->kolorRamkaNieaktywny = GOC_WHITE; lista->kolorPoleAktywny = lista->color; lista->kolorPoleNieaktywny = GOC_WHITE; lista->kolorPoleKursor = GOC_WHITE | GOC_FBOLD; lista->color = lista->kolorPoleNieaktywny; lista->kolorRamka = lista->kolorRamkaNieaktywny; goc_hkAdd( uchwyt, 0x600, GOC_EFLAGA_ENABLE | GOC_HKFLAG_SYSTEM, listHotKeyNext ); goc_hkAdd( uchwyt, 0x603, GOC_EFLAGA_ENABLE | GOC_HKFLAG_SYSTEM, listHotKeyPrev ); goc_hkAdd( uchwyt, 0x114, GOC_EFLAGA_ENABLE | GOC_HKFLAG_SYSTEM, lisyHotKeyHome ); goc_hkAdd( uchwyt, 0x117, GOC_EFLAGA_ENABLE | GOC_HKFLAG_SYSTEM, listHotKeyEnd ); goc_hkAdd( uchwyt, 0x118, GOC_EFLAGA_ENABLE | GOC_HKFLAG_SYSTEM, listHotKeyPgUp ); goc_hkAdd( uchwyt, 0x119, GOC_EFLAGA_ENABLE | GOC_HKFLAG_SYSTEM, listHotKeyPgDown ); return GOC_ERR_OK; }
void initSystemDrops(stContext* icontext) { context = icontext; goc_hkAdd(GOC_HANDLER_SYSTEM, ' ', GOC_EFLAGA_ENABLE, hotkeyNextTurnDrops); }
int main(int argc, char **argv) { int nStartPoints = 0; GOC_Arguments* args = NULL; char *levelChars = "signs"; // TODO: for string use stringCopy to alloc int numberOfStartPoints = 20; char* genSystem = "points"; srand(time(NULL)); memset(&context, 0, sizeof(stContext)); context.configuration.maxx = MAXX; context.configuration.maxy = MAXY; context.configuration.maxz = MAXZ; context.configuration.margines = MARGINES; context.configuration.minLandMass = MINLM; context.configuration.maxLandMass = MAXLM; // ustalanie argumentow args = goc_argumentsAdd(args, "-h", "Print this help", goc_argumentHelpFunction, &args); args = goc_argumentsAdd(args, "--help", "Print this help", goc_argumentHelpFunction, &args); args = goc_argumentsAdd(args, "--xsize", "Set x size of map (int:200)", goc_argumentIntFunction, &context.configuration.maxx); args = goc_argumentsAdd(args, "--ysize", "Set y size of map (int:100)", goc_argumentIntFunction, &context.configuration.maxy); args = goc_argumentsAdd(args, "--level", "Set type of level show (signs/numbers)", goc_argumentStringFunction, &levelChars); args = goc_argumentsAdd(args, "--points", "Number of start points [system:civ/points] (int:20)", goc_argumentIntFunction, &numberOfStartPoints); args = goc_argumentsAdd(args, "--system", "Used generation system (points/civ/rain/bactery/drops)", goc_argumentStringFunction, &genSystem); args = goc_argumentsAdd(args, "--minlandmass", "Minimum land mass of generated land [system:civ/rain] (int:10)", goc_argumentIntFunction, &context.configuration.minLandMass); args = goc_argumentsAdd(args, "--maxlandmass", "Maximum land mass of generated land [system:civ/rain] (int:60)", goc_argumentIntFunction, &context.configuration.maxLandMass); args = goc_argumentsAdd(args, "--margines", "Set margines value of random new points [system:civ/points/rain] (int:10)", goc_argumentIntFunction, &context.configuration.margines); systemDropsAddArgs(args); args = goc_argumentsSetUnknownFunction(args, goc_argumentHelpFunction); if ( goc_argumentsParse(args, argc, argv) ) return -1; context.maska = goc_elementCreate(GOC_ELEMENT_MASK, 1, 1, 0, 0, GOC_EFLAGA_PAINTED | GOC_EFLAGA_ENABLE, GOC_WHITE | GOC_FBOLD, GOC_HANDLER_SYSTEM); goc_maskSetRealArea(context.maska, context.configuration.maxx, context.configuration.maxy); context.mapa = goc_elementCreate(GOC_ELEMENT_RAWMAP, 1, 1, context.configuration.maxx, context.configuration.maxy, GOC_EFLAGA_PAINTED | GOC_EFLAGA_ENABLE, GOC_WHITE, context.maska); goc_maskAddMap(context.maska, context.mapa); goc_maparawSetBPV(context.mapa, 4); // maskaUstRodzajWartosci(maska, 4, 1); if ( goc_stringEquals(genSystem, "bactery") ) { setUpBiomeModeView(context.maska); } else if ( goc_stringEquals(levelChars, "numbers") ) { setUpNumericModeView(context.maska); } else if ( goc_stringEquals(levelChars, "signs") ) { setUpCharModeView(context.maska); } if ( goc_stringEquals(genSystem, "drops") ) { setUpBiomeModeView(context.maska); } // petlaGrow(maska, 10); // 10 bez lawirowania, tylko opadanie // petlaCount(maska, generateStartPoints(&nStartPoints), &nStartPoints); if ( goc_stringEquals( genSystem, "points" ) ) { goc_hkAdd(GOC_HANDLER_SYSTEM, 'V', GOC_EFLAGA_ENABLE, hotkeyModeView); goc_hkAdd(GOC_HANDLER_SYSTEM, 'v', GOC_EFLAGA_ENABLE, hotkeyModeView); petlaCount(context.mapa, randomStartPoints(&nStartPoints, numberOfStartPoints), &nStartPoints); } else if ( goc_stringEquals( genSystem, "civ" ) ) { goc_hkAdd(GOC_HANDLER_SYSTEM, 'V', GOC_EFLAGA_ENABLE, hotkeyModeView); goc_hkAdd(GOC_HANDLER_SYSTEM, 'v', GOC_EFLAGA_ENABLE, hotkeyModeView); civGeneration(context.mapa, numberOfStartPoints, context.configuration.minLandMass, context.configuration.maxLandMass, 0, 1); } else if ( goc_stringEquals( genSystem, "rain" ) ) { goc_hkAdd(GOC_HANDLER_SYSTEM, 'V', GOC_EFLAGA_ENABLE, hotkeyModeView); goc_hkAdd(GOC_HANDLER_SYSTEM, 'v', GOC_EFLAGA_ENABLE, hotkeyModeView); rainGeneration(context.mapa, numberOfStartPoints); } else if ( goc_stringEquals( genSystem, "bactery" ) ) { goc_hkAdd(GOC_HANDLER_SYSTEM, ' ', GOC_EFLAGA_ENABLE, hotkeyNextTurnBactery); bacteryGeneration(context.mapa, numberOfStartPoints, 9); } else if ( goc_stringEquals( genSystem, "drops" ) ) { initSystemDrops(&context); } goc_systemFocusOn(context.maska); // goc_systemSendMsg(0, GOC_MGS_PAINT, 0, 0); while (goc_systemCheckMsg( NULL )); return 0; }
int controlInit(int (*fun)(unsigned int, void*)) { if ( fun == NULL ) { fprintf(stderr, "Nie podano funkcji kontrolnej.\n%s:%d\n", __FILE__, __LINE__); exit(1); } doAction = fun; // zainicjowanie systemu okienkoc goc_systemSetListenerFunc( &nasluch ); goc_hkAdd(GOC_HANDLER_SYSTEM, 'n', GOC_EFLAGA_ENABLE, hotKeyNext); goc_hkAdd(GOC_HANDLER_SYSTEM, 'N', GOC_EFLAGA_ENABLE, hotKeyNext); goc_hkAdd(GOC_HANDLER_SYSTEM, 'b', GOC_EFLAGA_ENABLE, hotKeyPrev); goc_hkAdd(GOC_HANDLER_SYSTEM, 'B', GOC_EFLAGA_ENABLE, hotKeyPrev); goc_hkAdd(GOC_HANDLER_SYSTEM, 'i', GOC_EFLAGA_ENABLE, hotKeyInfo); goc_hkAdd(GOC_HANDLER_SYSTEM, 'I', GOC_EFLAGA_ENABLE, hotKeyInfo); goc_hkAdd(GOC_HANDLER_SYSTEM, 'p', GOC_EFLAGA_ENABLE, hotKeyPause); goc_hkAdd(GOC_HANDLER_SYSTEM, 'P', GOC_EFLAGA_ENABLE, hotKeyPause); goc_hkAdd(GOC_HANDLER_SYSTEM, 'h', GOC_EFLAGA_ENABLE, hotKeyHelp); goc_hkAdd(GOC_HANDLER_SYSTEM, 'H', GOC_EFLAGA_ENABLE, hotKeyHelp); goc_hkAdd(GOC_HANDLER_SYSTEM, '?', GOC_EFLAGA_ENABLE, hotKeyHelp); goc_hkAdd(GOC_HANDLER_SYSTEM, 'q', GOC_EFLAGA_ENABLE, hotKeyQuit); goc_hkAdd(GOC_HANDLER_SYSTEM, 'Q', GOC_EFLAGA_ENABLE, hotKeyQuit); goc_hkAdd(GOC_HANDLER_SYSTEM, 's', GOC_EFLAGA_ENABLE, hotKeyStop); goc_hkAdd(GOC_HANDLER_SYSTEM, 'S', GOC_EFLAGA_ENABLE, hotKeyStop); goc_hkAdd(GOC_HANDLER_SYSTEM, 0x114, GOC_EFLAGA_ENABLE, hotKeyHome); goc_hkAdd(GOC_HANDLER_SYSTEM, 0x120, GOC_EFLAGA_ENABLE, hotKeyAumixPlus); goc_hkAdd(GOC_HANDLER_SYSTEM, 0x11f, GOC_EFLAGA_ENABLE, hotKeyAumixMinus); goc_hkAdd(GOC_HANDLER_SYSTEM, '+', GOC_EFLAGA_ENABLE, hotKeyAumixPlus); goc_hkAdd(GOC_HANDLER_SYSTEM, '-', GOC_EFLAGA_ENABLE, hotKeyAumixMinus); goc_hkAdd(GOC_HANDLER_SYSTEM, '*', GOC_EFLAGA_ENABLE, hotKeyAumixNext); goc_hkAdd(GOC_HANDLER_SYSTEM, 'r', GOC_EFLAGA_ENABLE, hotKeyShuffleOn); goc_hkAdd(GOC_HANDLER_SYSTEM, 'R', GOC_EFLAGA_ENABLE, hotKeyShuffleOff); goc_hkAdd(GOC_HANDLER_SYSTEM, 'l', GOC_EFLAGA_ENABLE, hotKeyShowList); goc_hkAdd(GOC_HANDLER_SYSTEM, 'L', GOC_EFLAGA_ENABLE, hotKeyShowList); goc_hkAdd(GOC_HANDLER_SYSTEM, 'a', GOC_EFLAGA_ENABLE, hotKeyAddFolder); goc_hkAdd(GOC_HANDLER_SYSTEM, 'A', GOC_EFLAGA_ENABLE, hotKeyAddFolder); goc_hkAdd(GOC_HANDLER_SYSTEM, 'x', GOC_EFLAGA_ENABLE, hotKeyQueue); goc_hkAdd(GOC_HANDLER_SYSTEM, 'X', GOC_EFLAGA_ENABLE, hotKeyQueue); nTytul = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 1, 0, 1, GOC_EFLAGA_PAINTED | GOC_EFLAGA_CENTER, GOC_WHITE, GOC_HANDLER_SYSTEM); goc_labelSetText(nTytul, "Rojkowy kontroler muzyki. Wersja 0.2 :+)",GOC_FALSE); nMixer = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 8, 8, 1, GOC_EFLAGA_PAINTED | GOC_EFLAGA_LEFT, GOC_WHITE, GOC_HANDLER_SYSTEM); pMixer = goc_elementCreate(GOC_ELEMENT_PRECENT, 9, 8, 0, 1, GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM); goc_precentSetMin(pMixer, 0); goc_precentSetMax(pMixer, 100); nPlik = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 3, 0, 2, GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM); nTitle = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 5, 0, 1, GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM); nArtist = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 6, goc_screenGetWidth()>>1, 1, GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM); nAlbum = goc_elementCreate(GOC_ELEMENT_LABEL, (goc_screenGetWidth()>>1) + 1, 6, 0, 1, GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM); nComment = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 7, goc_screenGetWidth()>>1, 1, GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM); nStatus = goc_elementCreate(GOC_ELEMENT_LABEL, 1, 0, 0, 1, GOC_EFLAGA_PAINTED, GOC_GREEN, GOC_HANDLER_SYSTEM); nYear = goc_elementCreate(GOC_ELEMENT_LABEL, (goc_screenGetWidth()>>1) + 1, 7, 20, 1, GOC_EFLAGA_PAINTED, GOC_WHITE, GOC_HANDLER_SYSTEM); lLista = goc_elementCreate(GOC_ELEMENT_SELLIST, 1, 10, 0, -1, 0, GOC_WHITE, GOC_HANDLER_SYSTEM); pLista = goc_elementCreate(GOC_ELEMENT_FILELIST, 1, 10, 0, -1, 0, GOC_WHITE, GOC_HANDLER_SYSTEM); if ( goc_isFileExists(LOGO_FILE) ) { char *line = NULL; nLogo = goc_elementCreate(GOC_ELEMENT_LABEL, -20, -10, 20, 8, GOC_EFLAGA_PAINTED | GOC_EFLAGA_CENTER, GOC_CYAN, GOC_HANDLER_SYSTEM); GOC_IStream* streamLogo = goc_fileIStreamOpen(LOGO_FILE); while ( (line = goc_isReadLine( streamLogo )) ) { goc_labelAddLine(nLogo, line); line = goc_stringFree( line ); } goc_isClose( streamLogo ); } goc_filelistSetFolder(pLista, "."); goc_hkAdd(pLista, ' ', GOC_EFLAGA_ENABLE, hotKeySelectFolder); goc_elementSetFunc(lLista, GOC_FUNID_LISTENER, nasluch); printMixer(); return 0; }