static int listCursorPrev(GOC_HANDLER uchwyt) { GOC_StList *lista = (GOC_StList*)uchwyt; if ( lista->kursor > 0 ) { lista->kursor--; goc_systemSendMsg(uchwyt, GOC_MSG_LISTCHANGE, lista->pKolumna[0]->pText[lista->kursor], lista->kursor); if ( lista->start > lista->kursor ) { // przemaluj calosc, nastapilo przewiniecie strony int n = goc_listGetRowsAmmount(uchwyt); GOC_POSITION height = goc_elementGetHeight(uchwyt); lista->start = listCountStart(lista->kursor, height, n); goc_systemSendMsg(uchwyt, GOC_MSG_PAINT, 0, 0); } if ( lista->flag & GOC_EFLAGA_SHOWN ) { // przemaluj tylko linie nastepna i tam gdzie poszedl kursor listRedrawLine(uchwyt, lista->kursor); listRedrawLine(uchwyt, lista->kursor+1); goc_gotoxy( goc_elementGetScreenX(uchwyt)+1, goc_elementGetScreenY(uchwyt)+(lista->kursor-lista->start) + 1); fflush(stdout); } } return GOC_ERR_OK; }
static int hotKeyShuffleOff( GOC_HANDLER uchwyt, GOC_MSG wiesc, void *pBuf, unsigned int nBuf) { int arg=SHUFFLE_NO; doAction(ACTION_SHUFFLE, &arg); goc_gotoxy(1,9); goc_clearline(); printf("Wy³±czono tryb mieszania.\n"); }
void lista_polecen() { goc_gotoxy(1,9); printf("'q' - Quit program 'h' - Show this help\n"); printf("'i' - Info about song 's' - Stop playing\n"); printf("'p' - (Un)Pause song 'n' - Next song\n"); printf("'b' - Previous song '*' - Next aumix\n"); printf("'+' - Increas aumix '-' - Decreas aumix\n"); printf("'Home' - Jum to begin '->' - Jump forward\n"); printf("'r' - Enable shuffle 'R' - disable shuffle\n"); printf("'l' - List songs 'a' - add folder\n"); printf("'x' - Queue/Unqueue\n"); fflush(stdout); // printf("[l]oad <file> - Load a file to play\n"); // printf("[j]ump <+|->int - Jump inc/dec, or to position\n"); // printf("[j]ump <m>char - Jump to mark position\n"); // printf("[m]ark char - mark position\n"); }
int goc_labelDrawer(GOC_StElement *elem, const char *tekst) { char *line; // line do wypisania unsigned int d; // d³ugo¶æ do kopiowania dla linii do wypisania unsigned int p = 0; // przesuniêcie wzglêdem pocz±tku punktu pisania GOC_POSITION w = goc_elementGetWidth((GOC_HANDLER)elem); line = (char *)malloc(w+1); memset(line, 0, w+1); memset(line, ' ', w); if ( tekst ) d = strlen(tekst) > w ? w : strlen(tekst); else d = w; switch ( elem->flag & COC_EFLAGA_G_JUSTIFY ) { case GOC_EFLAGA_RIGHT: p = w - d; break; case GOC_EFLAGA_LEFT: p = 0; break; case GOC_EFLAGA_CENTER: p = w - d; p >>= 1; break; } if ( tekst ) memcpy( line + p, tekst, d ); goc_gotoxy( goc_elementGetScreenX( (GOC_HANDLER)elem ), goc_elementGetScreenY( (GOC_HANDLER)elem ) ); goc_textallcolor( elem->color ); fputs( line, stdout ); free(line); return GOC_ERR_OK; }
static int hotkeyNextTurnDrops( GOC_HANDLER u, GOC_StMessage* msg) { // TODO: Setting max and min landmass for forest/hills/land seperate GOC_BINFO("Turn: %3d", nBiomeTurn); if ( nBiomeTurn <= 0 ) { // fill up with sea generateFillUp(6); } else if ( nBiomeTurn <= biome.lands ) { int *allowed = malloc(sizeof(int)*1); allowed[0] = 6; generateLandMass(1, allowed, 1); free(allowed); } else if ( nBiomeTurn <= biome.lands + biome.trees ) { int *allowed = malloc(sizeof(int)*1); allowed[0] = 1; generateLandMass(2, allowed, 1); free(allowed); } else if ( nBiomeTurn <= biome.lands + biome.trees + biome.hills ) { int *allowed = malloc(sizeof(int)*1); allowed[0] = 1; generateLandMass(4, allowed, 1); free(allowed); } else if ( nBiomeTurn <= biome.lands + biome.trees + biome.hills + biome.desert ) { int *allowed = malloc(sizeof(int)*1); allowed[0] = 1; generateLandMass(5, allowed, 1); free(allowed); } else if ( nBiomeTurn <= biome.lands + biome.trees + biome.hills + biome.desert + biome.swamp) { int *allowed = malloc(sizeof(int)*1); allowed[0] = 1; generateLandMass(7, allowed, 1); free(allowed); } else { GOC_INFO("This is the end"); // I think it's the end return GOC_ERR_OK; } nBiomeTurn++; GOC_MSG_PAINT( msgPaint ); goc_systemSendMsg(context->mapa, msgPaint); goc_gotoxy(0, 0); goc_textallcolor(GOC_WHITE); printf("%03d", nBiomeTurn); goc_gotoxy(0, 0); fflush(stdout); return GOC_ERR_OK; }
int labelMoveDrawer(GOC_StElement *e, const char *tekst) { if ( wait ) { wait--; return GOC_ERR_OK; } wait = 1; if ( width != goc_elementGetWidth( (GOC_HANDLER)e ) ) { counter = 0; direction = 0; width = goc_elementGetWidth( (GOC_HANDLER)e ); } goc_textallcolor(e->color); if ( width <= strlen( tekst ) ) { char *tekstPisany = (char *)malloc(width+1); memset( tekstPisany, 0, width+1 ); memcpy( tekstPisany, tekst, width ); goc_saveXY(); goc_gotoxy( goc_elementGetScreenX( (GOC_HANDLER)e ), goc_elementGetScreenY( (GOC_HANDLER)e )); puts(tekstPisany); goc_loadXY(); return GOC_ERR_OK; } if ( direction ) { if ( counter > 0 ) { counter--; goc_saveXY(); goc_gotoxy( goc_elementGetScreenX( (GOC_HANDLER)e ) + counter, goc_elementGetScreenY( (GOC_HANDLER)e )); printf("%s ", tekst); goc_loadXY(); } else { direction = 0; } } else { if ( counter < width-strlen(tekst) ) { counter++; goc_saveXY(); goc_gotoxy( goc_elementGetScreenX( (GOC_HANDLER)e ) + counter - 1, goc_elementGetScreenY( (GOC_HANDLER)e )); printf(" %s", tekst); goc_loadXY(); } else { direction = 1; } } return GOC_ERR_OK; }
int main(int argc, char** argv) { // zak³ada siê, ¿e ramka zawiera próbkê, w której // jest d¼wiêk beat-u i cisza do nastêpnego beatu // // // ramka //char *pFrame; // licznik int i; // goc_termInit(); printf(GOC_STRING_WHITE); // Procedury inicjuj±ce GOC_DEBUG("Initializing libao"); ao_initialize(); GOC_DEBUG("Initializing libao Device"); aodriverid = ao_default_driver_id(); if ( aodriverid == -1 ) return -1; openOutputDevice(); params = allocParameters(); if ( argc > 1 ) { if ( interpretArgs(argc, argv, params) < 0 ) endProgram(-1); } GOC_DEBUG("Allocating buffer"); generateBeat(params, BEAT_BASE); generateBeat(params, BEAT_ACCENT); generateBeat(params, BEAT_INTER); generateBeat(params, BEAT_QUIET); // pFrame = malloc(nFrame); // memset(pFrame, 0, nFrame); GOC_BINFO("Tempo: %d Rate: %d Channels: %d Bits: %d", params->tempo, SAMPLE_RATE, SAMPLE_CHANNELS, SAMPLE_BITS); // GOC_BDEBUG("Allocated %d at 0x%X", nFrame, (unsigned int)pFrame); if ( params->flags & FLAG_PRINTCOUNT ) { goc_clearscreen(); goc_gotoxy(1,1); } printf("Playing ... \n"); if ( params->pattern ) printf("Use pattern: %s\n", params->pattern); fflush(stdout); { // to nie do koñca jest liczba ramek - to jest liczba // podstawowych beatów jakie maj± zostaæ zagrane - nie // s± liczone beat-y po¶rednie int nFrames; int imeasure = 0; int iinter; int patternPosition = 0; int patternLen = 0; char *prevString = goc_stringCopy(NULL, ""); char playedPattern = '.'; if ( params->pattern ) { patternLen = strlen(params->pattern); } if ( params->tacts ) // na podstawie liczby podanych taktów nFrames = params->tacts * params->measure; else // na podstawie podanego czasu nFrames = params->tempo * params->pdur / 60; NEXTPATTERN(); // goc_saveXY(); for (i=0; i<nFrames; i++) { if ( imeasure ) { if ( params->flags & FLAG_PRINTCOUNT ) { goc_gotoxy(1, 5); printf("%s%s%s%d%s", GOC_STRING_YELLOW, prevString, GOC_STRING_BWHITE, imeasure + 1, GOC_STRING_YELLOW); prevString = goc_stringAddInt(prevString, imeasure+1); prevString = goc_stringAdd(prevString, " .. "); fflush(stdout); } if ( playedPattern == '.' ) ao_play(aodev, params->pBeat[BEAT_BASE].pFrame, params->pBeat[BEAT_BASE].nFrame); else ao_play(aodev, params->pBeat[BEAT_QUIET].pFrame, params->pBeat[BEAT_QUIET].nFrame); NEXTPATTERN(); } else { if ( params->flags & FLAG_PRINTCOUNT ) { goc_gotoxy(1, 5); printf("%s%s", GOC_STRING_YELLOW, prevString); goc_gotoxy(1, 5); printf("%s%d%s", GOC_STRING_BWHITE, imeasure + 1, GOC_STRING_YELLOW); prevString = goc_stringFree(prevString); prevString = goc_stringAddInt(prevString, imeasure+1); prevString = goc_stringAdd(prevString, " .. "); fflush(stdout); } if ( playedPattern == '.' ) ao_play(aodev, params->pBeat[BEAT_ACCENT].pFrame, params->pBeat[BEAT_ACCENT].nFrame); else ao_play(aodev, params->pBeat[BEAT_QUIET].pFrame, params->pBeat[BEAT_QUIET].nFrame); NEXTPATTERN(); } if ( (iinter = params->inter) ) { while ( iinter-- ) { if ( params->flags & FLAG_PRINTCOUNT ) { goc_gotoxy(1, 5); printf("%s%s%si%s", GOC_STRING_YELLOW, prevString, GOC_STRING_WHITE, GOC_STRING_YELLOW); prevString = goc_stringAdd(prevString, "i .. "); fflush(stdout); } if ( playedPattern == '.' ) ao_play(aodev, params->pBeat[BEAT_INTER].pFrame, params->pBeat[BEAT_INTER].nFrame); else ao_play(aodev, params->pBeat[BEAT_QUIET].pFrame, params->pBeat[BEAT_QUIET].nFrame); NEXTPATTERN(); } } imeasure++; imeasure %= params->measure; } if ( params->flags & FLAG_PRINTCOUNT ) { goc_gotoxy(1, 5); printf("%s%s", GOC_STRING_YELLOW, prevString); } prevString = goc_stringFree(prevString); } printf("%s\nFinish\n", GOC_STRING_WHITE); if ( params->tacts ) { GOC_BINFO("Played %d frames in %d tacts", i, params->tacts); } else { GOC_BINFO("Played %d frames in %d seconds", i, params->pdur); } endProgram(0); return 0; }
static int goc_listPaint(GOC_HANDLER u) { GOC_StList *lista = (GOC_StList*)u; int i; // licznik zdañ int j; // licznik kolumn int n; // maksymalna liczba wierszy GOC_COLUMN *k; GOC_StElement e; GOC_FUN_LABELDRAWER *drawer; if ( !(lista->flag & GOC_EFLAGA_PAINTED) ) return GOC_ERR_OK; drawer = goc_elementGetLabelDrawer(u); memcpy(&e, lista, sizeof(GOC_StElement)); e.color = lista->kolorRamka; goc_elementGetFrameDrawer(u)(&e, "*-*| |*-*"); // rysowanie tytulu, jesli obecny if ( lista->pTytul ) { GOC_StElement elTytul; memcpy( &elTytul, lista, sizeof(GOC_StElement)); elTytul.color = lista->kolorRamka; elTytul.height = 1; elTytul.x += 2; elTytul.flag = GOC_EFLAGA_CENTER; if ( elTytul.width > 2 ) { elTytul.width -= 4; if ( strlen(lista->pTytul)+2 < elTytul.width ) elTytul.width = strlen(lista->pTytul)+2; } else elTytul.width = 0; drawer(&elTytul, lista->pTytul); } n = goc_listGetRowsAmmount(u); j=0; for ( i=lista->start; i<n; i++ ) { if ( i - lista->start > goc_elementGetHeight(u)-3 ) break; goc_systemSendMsg(u, GOC_MSG_LISTSETCOLOR, &(e.color), i); // j %= lista->nKolumna; e.y++; e.x = lista->x; (e.x)++; for ( j = 0; j < lista->nKolumna; j++ ) { k = lista->pKolumna[j]; e.width = k->position; if ( i<k->nText ) drawer(&e, k->pText[i]); else drawer(&e, ""); e.x += k->position; } // if (!j) // { // } // e.width = lista->pKolumna[j]; // j++; } if (lista->kursor != -1) goc_gotoxy( goc_elementGetScreenX(u)+1, goc_elementGetScreenY(u)+(lista->kursor-lista->start) + 1); fflush(stdout); lista->flag |= GOC_EFLAGA_SHOWN; return GOC_ERR_OK; }