예제 #1
0
void GUI::render_interface() {
    Character* target = game.main_char.get_target();
    int height = 0;
    
    drawStr(UI_START, height, std::string("Main Character").c_str(), ascii, screen, WHITE);

    height = render_stats(&game.main_char, height + 1);
    height ++;
    
    drawStr(UI_START, height, std::string("Target").c_str(), ascii, screen, WHITE);
     
    //Render the current target
    if(target != NULL)
    {       
        height = render_stats(target, height + 1);
    }
    else
    {
        drawStr(UI_START, height + 1, std::string("None").c_str(), ascii, screen, WHITE);
    }

    //Render that you have a level!
    if(game.main_char.get_new_levels() > 0)
    { 
        drawStr(UI_START, SCREEN_HEIGHT - 1, std::string("Level up!").c_str(), ascii, screen, RED);
    }
}
예제 #2
0
void GUI::render_debug()
{
    std::unordered_map<std::string, Tile>* tileset = &Tileset::instance()->get_tileset();
    for(int i=0;i<GAME_WIDTH;i++)
    {
        drawChr(i, GAME_HEIGHT-3, (*tileset)["BLOCK_WALL"].char_count, ascii, screen, BLACK);
        drawChr(i, GAME_HEIGHT-2, (*tileset)["BLOCK_WALL"].char_count, ascii, screen, BLACK);
    }
    drawChr(input.size(), GAME_HEIGHT-2, (*tileset)["BLOCK_WALL"].char_count, ascii, screen, WHITE);
    drawStr(0, GAME_HEIGHT-3, debug.get_message().c_str(), ascii, screen, WHITE);
    drawStr(0, GAME_HEIGHT-2, input.c_str(), ascii, screen, WHITE);
}
예제 #3
0
void GUI::clear_screen()
{
    for(int i =0;i<GAME_WIDTH;i++)
    {
        for(int j=0;j<GAME_HEIGHT;j++)
        {
            drawStr(i, j, std::string(" ").c_str(), ascii, screen, WHITE);
        }
    }
}
예제 #4
0
void GUI::OnRender() {
    if(current_screen == MENU_SCREEN) {
        render_menu(menu);
    } else if(current_screen == MAP_SCREEN) {
        std::vector<std::vector<MapTile> > map_canvas = world_map_gui.get_canvas();
        for(size_t i = 0; i < map_canvas.size(); i++) {
            for(size_t j = 0; j < map_canvas[i].size(); j++) {
                drawChr(j, i, map_canvas[i][j].char_count, ascii, screen, map_canvas[i][j].color);
            }
        }
        drawStr(0, GAME_HEIGHT - 2, std::string("Use the arrow keys to move the cursor.").c_str(),
                ascii, screen, WHITE);
        drawStr(0, GAME_HEIGHT - 1, std::string("Press ENTER to spawn on the selected map tile.").c_str(),
                ascii, screen, WHITE);
    } else if (current_screen == GAME_SCREEN) {
        render_canvas();
        render_target();
        render_characters();
        render_main_char();
        render_animations();
        clear_area(IntPoint(0, UI_START), IntPoint(UI_HEIGHT, UI_WIDTH));
        render_interface();
        render_message();

    } else if(current_screen == DIRECTION_SCREEN)
    {
        drawStr(0, 0, std::string("Pick a direction to perform the action.").c_str(), ascii, screen, WHITE);
    } else if (current_screen == DEATH_SCREEN) {
        clear_screen();
        drawStr(GAME_WIDTH/2 - 12, GAME_HEIGHT/2, std::string("You suck, uninstall bro.").c_str(), ascii, screen, WHITE);
    } else if (current_screen == DEBUG_CONSOLE) {
        render_canvas();
        render_target();
        render_characters();
        render_main_char();
        render_debug();
    }
    if(game.is_paused()) {
        drawStr(GAME_WIDTH-20, 0, std::string("Paused").c_str(), ascii, screen, WHITE);
    }

    SDL_Flip(screen);
}
예제 #5
0
int GUI::render_stats(Character* chara, int height)
{
    for(int i=0;i<NUM_STATS;i++)
    {
        stringstream ss;
        ss << STAT_NAMES[i] << ": " << chara->get_current_stat(i) << "/" << chara->get_stat(i);
        drawStr(UI_START, height, ss.str().c_str(), ascii, screen, WHITE);
        height++;
    }
    return height;
}
예제 #6
0
void updateGraphicBootPrompt(int key)
{
	if ( key == kBackspaceKey )
		prompt[--prompt_pos] = '\0';
	else 
	{
		prompt[prompt_pos] = key;
		prompt_pos++;
		prompt[prompt_pos] = '\0';
	}

	fillPixmapWithColor( gui.bootprompt.pixmap, gui.bootprompt.bgcolor);

	makeRoundedCorners( gui.bootprompt.pixmap);

	position_t p_text = pos( gui.bootprompt.hborder , ( ( gui.bootprompt.height -  font_console.chars[0]->height) ) / 2 );

	// print the boot prompt text
	drawStr(prompt_text, &font_console, gui.bootprompt.pixmap, p_text);
	
	// get the position of the end of the boot prompt text to display user input
	position_t p_prompt = pos( p_text.x + ( ( strlen(prompt_text) ) * font_console.chars[0]->width ), p_text.y );

	// calculate the position of the cursor
	int	offset = (  prompt_pos - ( ( gui.bootprompt.width / font_console.chars[0]->width ) - strlen(prompt_text) - 2 ) );	

	if ( offset < 0)
		offset = 0;
	
	drawStr( prompt+offset, &font_console, gui.bootprompt.pixmap, p_prompt);

	gui.menu.draw = NO;
	gui.bootprompt.draw = YES;
	gui.redraw = YES;
	
	updateVRAM();
	
	return;
}
예제 #7
0
void drawInt(int x, int y, int number, SDL_Surface* source, SDL_Surface* destination, Uint32 color, int size)
{
    // Note that numbers do not erase before redrawing and are left-justified
    // For example, if you print '17', then in the same location print '5',
    // the result will be '57'. To work around this, set the size parameter
    // > 1 and the number will be represented with 'size' digits.

    char buf[size];
    if ( size > 1 ) {
        int exp = 1;
        for ( int i = 0; i < (size-1); i++ ) { 
            exp = exp*10;
        }
        number = number + exp;
    }
    //itoa(number, buf, 10);
    if ( size > 1 ) {
        buf[0] = 48;
    }
    drawStr(x, y, buf, source, destination, color);
}
예제 #8
0
static void moldyn_display_text_(void) {
    char text[MAX_STRING];
    char atom_name[8];
    int i;
    /* GLUT fonts */
    static void *font_12 = GLUT_BITMAP_HELVETICA_12;
    static void *font_18 = GLUT_BITMAP_HELVETICA_18;
    
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    
    glColor3f(0,0,0);
    
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    gluOrtho2D(0.0, 1.0, 0.0, 1.0);
    glMatrixMode(GL_MODELVIEW);
    if (hint) {
        drawStr(0.02, 0.95, "<ESC> Exit", font_12);
        drawStr(0.02, 0.92, "<0> Reset view", font_12);
        
        drawStr(0.02, 0.35, "<a>rt", font_12);
        drawStr(0.02, 0.32, "<b>ack", font_12);
        drawStr(0.02, 0.29, "<c>apture", font_12);
        drawStr(0.02, 0.26, "<h>old", font_12);
        drawStr(0.02, 0.23, "<m>agnify", font_12);
        drawStr(0.02, 0.20, "<n>ext", font_12);
        drawStr(0.02, 0.17, "<p>rint", font_12);
        drawStr(0.02, 0.14, "<r>educe", font_12);
        drawStr(0.02, 0.11, "<s>witch rotate/translate", font_12);
        drawStr(0.02, 0.08, "<t>ext on/off", font_12);
        drawStr(0.02, 0.05, "<?> hints on/off", font_12);
    }
    
    if (format == normal && numbers) {
        sprintf(text, "#%d, E=%f", icycle, energy0 - energy);
        drawStr(0.65, 0.95, text, font_18);
    } else if (numbers) {
        drawStr(1 - strlen(title) / 50.0, 0.95, title, font_18);
    }
    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    if (numbers) {
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        gluPerspective(45.0f, (GLfloat) window_width / (GLfloat) window_height, 0.5, 7.0 * range);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
        glTranslatef(xeye, yeye, zeye);
        
        glRotatef(-rotation, 0.0, 1.0, 0.0);
        glRotatef(tilt, 1.0, 0.0, 0.0);
        for (i = 0; i < num_atoms; i++) {
            if (atom_numbers[i] != 0) {
                char *c;
                if (format == normal) {
                    sprintf(atom_name, "%d.%d", atom_numbers[i], atom_numbers2[i]);
                } else if (format == xyz) {
                    sprintf(atom_name, "%s", atom_names[i]);
                } else {
                    sprintf(atom_name, "%d", atom_numbers[i]);
                }
                
                glPushMatrix();
                glTranslatef(atom_positions[0+3*i], atom_positions[1+3*i], atom_positions[2+3*i]);
                glRotatef(-tilt, 1.0, 0.0, 0.0);
                glRotatef(rotation, 0.0, 1.0, 0.0);
        
                glRasterPos3f(0, 0, atom_radii[i]);
                for (c = atom_name; *c != '\0'; c++) {
                    glutBitmapCharacter(font_12, *c);
                }
                glPopMatrix();
            }
        }
    }
}
예제 #9
0
void PreAgiEngine::clearRow(int row) {
	drawStr(row, 0, IDA_DEFAULT, "                                        ");	// 40 spaces
}
예제 #10
0
void PreAgiEngine::drawStrMiddle(int row, int attr, const char *buffer) {
	int col = (25 / 2) - (strlen(buffer) / 2);	// 25 = 320 / 8 (maximum column)
	drawStr(row, col, attr, buffer);
}
예제 #11
0
void PreAgiEngine::printStr(const char* szMsg) {
	clearTextArea();
	drawStr(21, 0, IDA_DEFAULT, szMsg);
	_gfx->doUpdate();
	_system->updateScreen();
}
예제 #12
0
파일: bs.c 프로젝트: klammerj/iverilog
int main(int argc, char *argv[])
{
	FILE * fp;
	Img40 m;
	uint8_t v;
	int nw,i,j;
	Actx gc;
	char buf[100];
	
	fp=fopen("gi","rt");
	assert(fp);
	
	img40Init(&m,16,16);
	
	v=byte_read(fp);
	assert(0==v);
	
	v=byte_read(fp);
	assert(v==0xb7);
	
	for(i=0;i<4;i++)
	{
		m.cr[i]=byte_read(fp);
	}
//	bs->idunno=byte_read(fp);
	
//	assert(get_cr(28)==0);//reserved==0
	nw=0;
	nw=(byte_read(fp)&0x0ff)<<8;
	nw|=(byte_read(fp)&0x0ff);
	for(i=0;i<nw;i++)
	{
		uint8_t sa[3],ea[3];
		sa[0]=byte_read(fp);
		sa[1]=byte_read(fp);
		sa[2]=byte_read(fp);
		ea[0]=byte_read(fp);
		ea[1]=byte_read(fp);
		ea[2]=byte_read(fp);

		printf("Window %d of %d\n",i,nw-1);
		printf("at line: %d\n",line_idx+1);

		printf("start: ");
		dump_addr(sa);
		printf("\n");

		printf("end: ");
		dump_addr(ea);
		printf("\n");
		img40SA(&m,sa,ea);
		while(!img40Put(&m,byte_read(fp)));
	}
	
	v=byte_read(fp);
	assert(v==0xe7);
	fclose(fp);

	
	sprintf(buf,"cells");
	for(i=0;i<m.rows;i++)
	{
		for(j=0;j<m.cols;j++)
		{
			char nbf[20];
			actxInit(&gc,64,40);
			cellDraw(&gc,0,0,0,get_cell(&m,j,i));
			if((i==0)&&(j==0))
			{
				drawOffs(&gc,0,0);
				drawStr(&gc,0,0,buf);
			}
			sprintf(buf,"cell %.2d %.2d",j,i);
			drawOffs(&gc,0,0);
			drawStr(&gc,0,1,buf);
			csetDraw(&gc,20,0,0,get_cset(&m,j,i));
			sprintf(nbf,"c_dmp");
			actxDump(&gc,nbf,!((i==0)&&(j==0)));
			actxClear(&gc);
		}
	}
	
	sprintf(buf,"sectorsh(vert repeaters)");
	for(i=0;i<(m.rows/4+1);i++)
	{
		for(j=0;j<m.cols;j++)
		{
			char nbf[20];
			actxInit(&gc,20,48);
			sectorDraw(&gc,0,0,0,1,get_hsector(&m,j,i));
			if((i==0)&&(j==0))
			{
				drawOffs(&gc,0,0);
				drawStr(&gc,0,0,buf);
			}
			sprintf(buf,"sector %.2d %.2d",j,i);
			drawOffs(&gc,0,0);
			drawStr(&gc,0,1,buf);
			sprintf(nbf,"c_dmp");
			actxDump(&gc,nbf,1);
			actxClear(&gc);
		}
	}

	sprintf(buf,"sectorsv(hrz repeaters)");
	for(i=0;i<m.rows;i++)
	{
		for(j=0;j<(m.cols/4+1);j++)
		{
			char nbf[20];
			actxInit(&gc,20,48);
			sectorDraw(&gc,0,0,0,0,get_vsector(&m,j,i));
			if((i==0)&&(j==0))
			{
				drawOffs(&gc,0,0);
				drawStr(&gc,0,0,buf);
			}
			sprintf(buf,"sector %.2d %.2d",j,i);
			drawOffs(&gc,0,0);
			drawStr(&gc,0,1,buf);
			sprintf(nbf,"c_dmp");
			actxDump(&gc,nbf,1);
			actxClear(&gc);
		}
	}

	sprintf(buf,"ioh");
	for(i=0;i<m.rows;i++)
	{
		for(j=0;j<2;j++)
		{
			char nbf[20];
			int k;
			uint8_t *p=get_ioh(&m,j,i);
			for(k=0;k<2;k++)
			{
				actxInit(&gc,80,14);
				ioDraw(&gc,0,0,0,p+k*4,k==1);
				if((i==0)&&(j==0)&&(k==0))
				{
					drawOffs(&gc,0,0);
					drawStr(&gc,0,0,buf);
				}
				sprintf(buf,"ioh_%c %.2d %.2d",(k==0)?'p':'s',j,i);
				drawOffs(&gc,0,0);
				drawStr(&gc,0,1,buf);
				sprintf(nbf,"c_dmp");
				actxDump(&gc,nbf,1);
				actxClear(&gc);
			}
		}
	}

	sprintf(buf,"iov");
	for(i=0;i<2;i++)
	{
		for(j=0;j<m.cols;j++)
		{
			char nbf[20];
			int k;
			uint8_t *p=get_iov(&m,j,i);
			for(k=0;k<2;k++)
			{
				actxInit(&gc,80,14);
				ioDraw(&gc,0,0,0,p+k*4,k==1);
				if((i==0)&&(j==0)&&(k==0))
				{
					drawOffs(&gc,0,0);
					drawStr(&gc,0,0,buf);
				}
				sprintf(buf,"iov_%c %.2d %.2d",(k==0)?'p':'s',j,i);
				drawOffs(&gc,0,0);
				drawStr(&gc,0,1,buf);
				sprintf(nbf,"c_dmp");
				actxDump(&gc,nbf,1);
				actxClear(&gc);
			}
		}
	}

	sprintf(buf,"mem");
	for(i=0;i<(m.rows/4);i++)
	{
		for(j=0;j<(m.cols/4);j++)
		{
			char nbf[20];
			uint8_t *p=get_mem(&m,j,i);
			actxInit(&gc,20,8);
			memDraw(&gc,0,0,0,p);
			if((i==0)&&(j==0))
			{
				drawOffs(&gc,0,0);
				drawStr(&gc,0,0,buf);
			}
			sprintf(buf,"mem %.2d %.2d",j,i);
			drawOffs(&gc,0,0);
			drawStr(&gc,0,1,buf);
			sprintf(nbf,"c_dmp");
			actxDump(&gc,nbf,1);
			actxClear(&gc);
		}
	}

	sprintf(buf,"cols");
		for(j=0;j<m.cols;j++)
		{
			char nbf[20];
			uint8_t *p=get_col(&m,j);
			actxInit(&gc,20,10);
			colDraw(&gc,0,0,0,p,0);
			if(j==0)
			{
				drawOffs(&gc,0,0);
				drawStr(&gc,0,0,buf);
			}
			sprintf(buf,"col %.2d",j);
			drawOffs(&gc,0,0);
			drawStr(&gc,0,1,buf);
			sprintf(nbf,"c_dmp");
			actxDump(&gc,nbf,1);
			actxClear(&gc);
			if(j==(m.cols-1))
			{//fclock
				actxInit(&gc,20,10);
				colDraw(&gc,0,0,0,p+1,2);
				sprintf(buf,"auxcol %.2d (fck)",j);
				drawOffs(&gc,0,0);
				drawStr(&gc,0,1,buf);
				sprintf(nbf,"c_dmp");
				actxDump(&gc,nbf,1);
				actxClear(&gc);
//				assert((p[1]&0x0fc)==0x0fc);
			}
			else if(j==0)
			{//fclock
				actxInit(&gc,20,10);
				colDraw(&gc,0,0,0,p+1,1);
				sprintf(buf,"auxcol %.2d (fck)",j);
				drawOffs(&gc,0,0);
				drawStr(&gc,0,1,buf);
				sprintf(nbf,"c_dmp");
				actxDump(&gc,nbf,1);
				actxClear(&gc);
//				assert((p[1]&0x0fc)==0x0fc);
			}
			else if(j==((m.cols/2)-1))
			{//reset input
				actxInit(&gc,20,10);
				colDraw(&gc,0,0,0,p+1,3);
				sprintf(buf,"auxcol %.2d (rst)",j);
				drawOffs(&gc,0,0);
				drawStr(&gc,0,1,buf);
				sprintf(nbf,"c_dmp");
				actxDump(&gc,nbf,1);
				actxClear(&gc);
//				assert((p[1]&0x0f0)==0x0f0);
			}			
//			else
//				assert(p[1]==0xff);
		}

	img40Dump(&m);
	img40Clear(&m);
	return 0;
}
예제 #13
0
void GUI::render_message()
{
    drawStr(0, MESSAGE_HEIGHT, MessageBoard::instance().get_current_message().c_str(), ascii, screen, WHITE);
}
예제 #14
0
//WHEN DID THIS GET SO BIG?? REFACTOR THIS!
void GUI::render_menu(Menu* menu)
{

    //menus will always be rendered in the middle of the screen, fyi
    //clear the background in the specified height/width
    //width is automatically 20
    int height = menu->options.size() + menu->padding;
    int width = utility::get_max_width(menu->options) + menu->padding;
    int start_row = (GAME_HEIGHT - height) / 2;
    int start_col = (GAME_WIDTH - width) / 2;
    int end_row = (GAME_HEIGHT + height) / 2;
    int end_col = (GAME_WIDTH + width) / 2;
 
    int extra_row = start_row - menu->padding;
    int extra_end_row = start_row + menu->num_extra_lines() + menu->padding;
    int extra_width = utility::get_max_width(menu->get_extra_lines()) + menu->padding; 
    int extra_col = (GAME_WIDTH - extra_width)/2;
    int extra_end_col = (GAME_WIDTH + extra_width)/2;
    
    if(menu->num_extra_lines() != 0)
    {
        start_row = start_row + menu->num_extra_lines() + 2;
        end_row = start_row + menu->num_extra_lines() + 2;
        for(int row = extra_row; row <= extra_end_row; row++)
        {
            for(int col = extra_col; col <= extra_end_col; col++)
            {
                drawChr(col, row, menu->border.char_count, ascii, screen, BLACK);
            }
        }
    }

    //draw a box around the menu
    for(int row = start_row; row <= end_row; row++)
    {
        for(int col = start_col; col <= end_col; col++)
        {
            drawChr(col, row, menu->border.char_count, ascii, screen, BLACK);
        }
    }

    //draw a box around the extra lines 

    int starting_col;
    starting_col = (GAME_WIDTH - menu->title.size()) / 2;

    //draw the title
    drawStr(starting_col, (GAME_HEIGHT/4), menu->title.c_str(),
            ascii, screen, RED);
    
    
    int color, string_size;

    //draw the extra lines
    for(int i = 0; i< menu->num_extra_lines(); i++)
    {
        string option = menu->get_extra_lines()[i];
        if(option.size() % 2 != 0)
        {
            option = " " + option;
        }

        color = RED;

        drawStr(extra_col, extra_row + menu->padding + i, option.c_str(), ascii, screen, color);
    }

    //Render selections
    for(int i = 0; i < menu->options.size(); i++) {
        string option = menu->options[i];
        if(option.size() % 2 != 0)
        {
            option = " " + option;
        }
        
        string_size = option.size();
        starting_col = (GAME_WIDTH - string_size) / 2;
        if(menu->selection == i) {
            color = WHITE;
        } else {
            color = DARK_GRAY;
        }

        drawStr(starting_col, start_row + menu->padding + i,
                option.c_str(), ascii, screen, color);
    }

}