/* ************************************************************************************** */ void printBetweenStarLines(const std::string &s) { printScrStarLine(); centerString(s); printScrStarLine(); return; }
/* ************************************************************************************** */ void printHappyEnding(void) { std::cout << "\n\n"; centerString("(-: Normal termination! :-)"); std::cout << "\n\n"; //system("date \"+\%Y\%m\%d-\%H\%M\""); }
//print out each spaces name, centered and ending with a | void Game_Board::printRowWithName(int numSpaces, int firstSpace, bool isReverse){ int padding = SPACE_WIDTH -2; if(!isReverse){ for(int i = 0; i < numSpaces; i++){ Space current = spaces[firstSpace + i]; //gets current space std::cout << "|" << std::left << std::setw(padding) << centerString(current.getName()); } std::cout << "|" << std::endl; // right side ending bracket } else{ for(int i = 0; i < numSpaces; i++){ Space current = spaces[firstSpace - i]; //gets current space std::cout << "|" << std::left << std::setw(padding) << centerString(current.getName()); } std::cout << "|" << std::endl; // right side ending bracket } }
//print out each spaces owner, centered and ending with a | void Game_Board::printRowWithOwner(int numSpaces, int firstSpace, bool isReverse){ int padding = SPACE_WIDTH -2; if(!isReverse){ for(int i = 0; i < numSpaces; i++){ Space current = spaces[firstSpace + i]; //gets current space //only print out if the space is ownable if(current.isOwnable()){ std::string owner = current.getOwner(); std::string ownerLine = "Owner: " + owner; std::cout << "|" << std::left << std::setw(padding) << centerString(ownerLine); }else{ std::cout << "|"; for(int j = 0; j < SPACE_WIDTH - 2; j++){ std::cout << " "; } } } std::cout << "|" << std::endl; // right side ending bracket }else{ for(int i = 0; i < numSpaces; i++){ Space current = spaces[firstSpace - i]; //gets current space //Only print out if the space is ownable if(current.isOwnable()){ std::string owner = current.getOwner(); std::string ownerLine = "Owner: " + owner; std::cout << "|" << std::left << std::setw(padding) << centerString(ownerLine); }else{ std::cout << "|"; for(int j = 0; j < SPACE_WIDTH - 2; j++){ std::cout << " "; } } } std::cout << "|" << std::endl; // right side ending bracket } }
//print out each spaces current players on that space, centered and ending with a | void Game_Board::printRowWithCurrentPlayers(int numSpaces, int firstSpace, bool isReverse){ int padding = SPACE_WIDTH -2; std::stringstream ss; //run in regular order if not printing in reverse if(!isReverse){ for(int i = 0; i < numSpaces; i++){ Space current = spaces[firstSpace + i]; //gets current space std::string result = current.playersOnSpaceToString(); std::cout << "|" << std::left << std::setw(padding) << centerString(result); } std::cout << "|" << std::endl; // right side ending bracket //else print the spaces as if in reverse order }else{ for(int i = 0; i < numSpaces; i++){ Space current = spaces[firstSpace - i]; //gets current space std::string result = current.playersOnSpaceToString(); //gets current players on the space std::cout << "|" << std::left << std::setw(padding) << centerString(result); } std::cout << "|" << std::endl; // right side ending bracket } }
/* ************************************************************************************** */ void printHappyStart(char ** (&argv),const char *vers,const char *contrib) { std::string progname=argv[0]; progname.append(" (-:"); progname.insert(0,":-) "); size_t pos=progname.find("./"); if (pos!=std::string::npos) {progname.erase(pos,2);} setScrGreenBoldFont(); printScrStarLine(); #ifdef _SOL_USE_FIGLET_NAME_ #if _SOL_USE_FIGLET_NAME_ printFigletName(); #endif #endif std::cout << std::endl; centerString(progname); std::cout << std::endl; progname=__DATE__; progname.insert(0,"Compilation date: "); centerString(progname); std::cout << std::endl; progname="Version: "; //progname.append(CURRENTVERSION); progname.append(vers); centerString(progname); std::cout << std::endl; progname=":-) Created by "; //progname.append(PROGRAMCONTRIBUTORS); progname.append(contrib); progname.append(" (-:"); centerString(progname); std::cout << std::endl; printScrStarLine(); setScrNormalFont(); return; }
/* ************************************************************************************** */ void centerString(const char* word) { centerString(std::string(word)); }
//Prints middle row with two spaces on either edge of the baord //those spaces are in spaces[space1Index] and spaces[space2Index] void Game_Board::printMiddleRow(int space1Index, int space2Index){ //print out each spaces name, centered and ending with a | int padding = SPACE_WIDTH-2; for(int i = 0; i < SPACES_IN_ROW; i++){ if(i == 0){ Space current = spaces[space1Index]; std::cout << "|" << std::left << std::setw(padding) << centerString(current.getName()) << "|"; } else if(i == 10){ Space current = spaces[space2Index]; std::cout << "|" << std::left << std::setw(padding) << centerString(current.getName()) << "|"; }else{ int x = 1; if(i == 9) x = 2; for(int j = 0; j < SPACE_WIDTH - x; j++){ std::cout << " "; } } } std::cout << std::endl; // right side ending bracket //print out each spaces Owner, centered and ending with a | for(int i = 0; i < SPACES_IN_ROW; i++){ if(i == 0){ Space current = spaces[space1Index]; if(current.isOwnable()){ std::string owner = current.getOwner(); std::string ownerLine = "Owner: " + owner; std::cout << "|" << std::left << std::setw(padding) << centerString(ownerLine) << "|"; }else{ std::cout << "|"; for(int j = 0; j < SPACE_WIDTH - 2; j++){ std::cout << " "; } std::cout << "|"; } } else if(i == 10){ Space current = spaces[space2Index]; if(current.isOwnable()){ std::string owner = current.getOwner(); std::string ownerLine = "Owner: " + owner; std::cout << "|" << std::left << std::setw(padding) << centerString(ownerLine) << "|"; } else{ std::cout << "|"; for(int j = 0; j < SPACE_WIDTH - 2; j++){ std::cout << " "; } std::cout << "|"; } }else{ int x = 1; if(i == 9) x = 2; for(int j = 0; j < SPACE_WIDTH - x; j++){ std::cout << " "; } } } std::cout << std::endl; for(int i = 0; i < SPACES_IN_ROW; i++){ if(i == 0 || i == 10){ std::cout << "|"; for(int j = 0; j < SPACE_WIDTH-2; j++){ std::cout << " "; } std::cout << "|"; }else{ int x = 1; if(i == 9) x = 2; for(int j = 0; j < SPACE_WIDTH - x; j++){ std::cout << " "; } } } std::cout << std::endl; //Prints out the players currently on each space for(int i = 0; i < SPACES_IN_ROW; i++){ if(i == 0){ Space current = spaces[space1Index]; std::string result = current.playersOnSpaceToString(); std::cout << "|" << std::left << std::setw(padding) << centerString(result) << "|"; } else if(i == 10){ Space current = spaces[space2Index]; std::string result = current.playersOnSpaceToString(); std::cout << "|" << std::left << std::setw(padding) << centerString(result) << "|"; }else{ int x = 1; if(i == 9) x = 2; for(int j = 0; j < SPACE_WIDTH - x; j++){ std::cout << " "; } } } std::cout << std::endl; }
void drawTitleScreen(char* str) { clearScreen(0x00); centerString("HANS",0); renderString(str, 0, 40); }
void LCDST7565::drawValueMenu() { uint8_t strx; uint8_t strline = GUI_VALSTR_LINE; uint8_t slen = 0; char str[19]; clear();/* drawstring(0,0, cSynthVal.name); char c[19]; sprintf(c, "%i%s", cSynthVal.value, cSynthVal.unit);*/ // draw title drawstring( centerString(cSynthVal.name) , 0, cSynthVal.name); invertRect(0,0,128,8); // Draw value bar for floats ints if(cSynthVal.type == VAL_TYPE_INT || cSynthVal.type == VAL_TYPE_FLOAT) { int fillw; if(cSynthVal.type == VAL_TYPE_INT) { int val; if(cSynthVal.min < 0) { val = cSynthVal.value - cSynthVal.min; } else { val = cSynthVal.value; } fillw = (GUI_VALBAR_WIDTH * val) / (cSynthVal.max - cSynthVal.min); } else { fillw = (int) ((GUI_VALBAR_WIDTH * cSynthVal.fvalue) / (cSynthVal.fmax - cSynthVal.fmin)); } drawrect(GUI_VALBAR_X-1, GUI_VALBAR_Y, GUI_VALBAR_WIDTH+2, GUI_VALBAR_HEIGHT, BLACK); fillrect(GUI_VALBAR_X, GUI_VALBAR_Y, fillw, GUI_VALBAR_HEIGHT, BLACK); for(int x = GUI_VALBAR_X + 9; x < GUI_VALBAR_X+GUI_VALBAR_WIDTH-1; x += 10) { setpixel(x, GUI_VALBAR_Y-1, BLACK); setpixel(x, GUI_VALBAR_Y + GUI_VALBAR_HEIGHT, BLACK); } //draw left marker drawline(GUI_VALBAR_X-2, GUI_VALBAR_Y-2, GUI_VALBAR_X-2, GUI_VALBAR_Y + GUI_VALBAR_HEIGHT+1, BLACK); //draw right marker drawline(GUI_VALBAR_X + GUI_VALBAR_WIDTH, GUI_VALBAR_Y-2, GUI_VALBAR_X + GUI_VALBAR_WIDTH, GUI_VALBAR_Y + GUI_VALBAR_HEIGHT+1, BLACK); //draw middle marker //setpixel(GUI_VALBAR_HALF, GUI_VALBAR_Y-1,BLACK); setpixel(GUI_VALBAR_HALF+1, GUI_VALBAR_Y-1, BLACK); setpixel(GUI_VALBAR_HALF+1, GUI_VALBAR_Y + GUI_VALBAR_HEIGHT, BLACK); strline = GUI_VALBAR_STR_LINE; } // draw value string switch(cSynthVal.type) { case VAL_TYPE_MIDI_CHANNEL: case VAL_TYPE_MIDI_CC: case VAL_TYPE_INT: { sprintf(str, "%i%s", cSynthVal.value + cSynthVal.indexOffset, cSynthVal.unit); break; } case VAL_TYPE_MIDI_NOTE: { uint8_t note,octave; octave = cSynthVal.value / 12; note = cSynthVal.value % 12; switch( note ) { case 1: case 3: case 6: case 8: case 10: { sprintf(str, "%c#%i (%i)", midi_note_names[note], octave, cSynthVal.value); break; } default: { sprintf(str, "%c%i (%i)", midi_note_names[note], octave, cSynthVal.value); break; } } break; } case VAL_TYPE_FLOAT: { char fmt[9]; char dig[3]; fmt[0] = 0; strcat(fmt,"%."); sprintf(dig, "%i", cSynthVal.fdigits); strcat(fmt, dig); strcat(fmt, "f%s"); sprintf(str, fmt, cSynthVal.fvalue, cSynthVal.unit); break; } } //strx = GUI_CHARS_PER_LINE / 2 - (strlen(str) * 5) / 2 + 1; strx = centerString(str); drawstring(strx, strline, str); this->drawMenuButton(BUT_DOWN, 0); this->drawMenuButton(BUT_UP, 1); this->drawMenuButton(BUT_BACK, 2); this->drawMenuButton(BUT_OK, 3); display(); }
//========== DRAW ================= DRAW =================== DRAW ==================== void LCDST7565::drawMenu() { uint8_t i, label_len; this->clear(); //this->fillrect(0, 0, 128, 7, BLACK); this->drawstring(centerString(_title), 0, _title); invertRect(0,0,128,8); i=0; while ((i<N_LINES-1) & (i<_n_items)) { this->drawstring(LEFT_MARGIN, i+1, _menu_items[_draw_index+i].label); switch(_menu_items[_draw_index+i].type) { case MENU_ITEM_TYPE_CHECK: { uint8_t y = (i+1) * 8; drawrect(GUI_CHECKBOX_X, y, 7, 7, BLACK); if(_menu_items[_draw_index+i].checked) { drawline(GUI_CHECKBOX_X, y, GUI_CHECKBOX_X + 6, y + 6, BLACK); drawline(GUI_CHECKBOX_X, y + 6, GUI_CHECKBOX_X + 6, y, BLACK); } break; } case MENU_ITEM_TYPE_RADIO: { uint8_t y = (i+1) * 8 + 4; if(_menu_items[_draw_index+i].checked) { fillcircle(GUI_RADIO_X, y, 2, BLACK); } else { drawcircle(GUI_RADIO_X, y, 2, BLACK); } break; } case MENU_ITEM_TYPE_INLINE_INT: { char s[8]; sprintf(s, "%i", _menu_items[_draw_index+i].inlineValue); this->drawstring(122 - strlen(s) * 6, i+1, s); break; } } i++; } /*// Draw arrow to indicate current item: this->drawline(0, 11+(8*_current_line), LEFT_MARGIN-5, 11+(8*_current_line), BLACK); this->drawline(LEFT_MARGIN-5, 8+(8*_current_line), LEFT_MARGIN-2, 11+(8*_current_line), BLACK); this->drawline(LEFT_MARGIN-5, 14+(8*_current_line), LEFT_MARGIN-2, 11+(8*_current_line), BLACK); this->drawline(LEFT_MARGIN-5, 14+(8*_current_line), LEFT_MARGIN-5, 8+(8*_current_line), BLACK);*/ this->drawbitmap(0, 8 * (_current_line+1), menu_arrow, 16, 8, BLACK); // Draw up arrow if there are items above view if (_draw_index > 0) { this->drawline(123, 11, 125, 8, BLACK); this->drawline(127, 11, 125, 8, BLACK); } // Draw down arrow if there are items below view if ((_n_items - _draw_index) >= N_LINES) { this->drawline(123, DOWN_ARROW_Y, 125, DOWN_ARROW_Y + 3, BLACK); this->drawline(127, DOWN_ARROW_Y, 125, DOWN_ARROW_Y + 3, BLACK); } this->drawMenuButton(BUT_DOWN, 0); this->drawMenuButton(BUT_UP, 1); switch( _menu_items[_item_index].type ) { case MENU_ITEM_TYPE_CHECK: case MENU_ITEM_TYPE_RADIO: { this->drawMenuButton(BUT_BACK, 2); this->drawMenuButton(BUT_SET, 3); break; } case MENU_ITEM_TYPE_INLINE_INT: { this->drawMenuButton(BUT_LEFT, 2); this->drawMenuButton(BUT_RIGHT, 3); break; } default: { this->drawMenuButton(BUT_BACK, 2); this->drawMenuButton(BUT_OK, 3); break; } } this->display(); }