Example #1
0
//Starts game / stays
static void play_stay()
{
	if(gameRunning == 0 && player_bet >= BET_INCREMENT)
	{
		deal_card(DEALER);
		//Display First Card To All Here
		deal_card(DEALER);

		deal_card(PLAYER);
		//Display First Card To All Here
		deal_card(PLAYER);

		gameRunning = 1;
		msg = NONE;
		change_turn(PLAYER);

		draw_window();
	}else{
		//Stay
		if(gameRunning == 1 && turn == PLAYER)
		{
			player_stay = 1;

			draw_window();

			change_turn(DEALER);
		}
	}
}
Example #2
0
//Check if theres a winner
static void check_win()
{
	winner = NONE;

	//Player out weighs dealer and is not over 21 || dealer is over 21
	if( (player_stay == 1 && dealer_stay == 1 && player_hand <= 21 && player_hand > dealer_hand) || (dealer_hand > 21) )
	{
		msg = NONE;
		winner = PLAYER;

		player_pot += player_bet * 2;

	}

	//Dealer out weighs player and is not over 21 || player is over 21
	if( (player_stay == 1 && dealer_stay == 1 && dealer_hand <= 21 && dealer_hand > player_hand) || (player_hand > 21) )
	{
		msg = NONE;
		winner = DEALER;

		player_pot -= player_bet;
	}

	//Tie Game
	if(player_stay == 1 && dealer_stay == 1 && player_hand == dealer_hand)
	{
		msg = NONE;
		winner = TIE;

		player_pot += player_bet;
	}

	//Winner was found.. Stop the game!
	if(winner != NONE)
	{
		player_bet = 0;

		draw_window();
		usleep(5000000);

		if(player_pot <= 0)
		{
			player_pot = POT_DEFAULT;
			msg = GAMEOVER;

			draw_window();
			usleep(2000000);
		}

		reset();
	}
}
Example #3
0
void kos_Main()
{
	kos_InitHeap();
	load_edit_box();
	init();
	
	for (;;)
	{
		switch (kos_WaitForEvent())
		{
		case 6:
			process_mouse();
			break;
		case 1:
			window_drawall=true;
			draw_window();
			break;
		case 2:
			process_key();
			break;
		case 3:
			process_button();
			break;
		}
	}
}
Example #4
0
File: fdf.c Project: Xethan/fdf
int		key_hook(int keycode, t_env *e)
{
	size_t	i;

	if ((keycode >= 65361 && keycode <= 65364)
		|| keycode == 65451 || keycode == 65453 || keycode == 65293
		|| keycode == 65455 || keycode == 65450 || keycode == 114)
	{
		*e = recompute_map(*e, keycode);
		*e = compute_map(*e);
		mlx_clear_window(e->mlx, e->win);
		draw_window(e);
	}
	if (keycode == 65307)
	{
		i = 0;
		while (i != e->y)
		{
			free(e->map[i]);
			i++;
		}
		free(e->map);
		exit(EXIT_SUCCESS);
	}
	return (0);
}
void draw_window_loop()
{
    while (true)
    {
        draw_window();
    }
}
Example #6
0
void term_redisplay(void)
{
  size_t topline;
  Window *wp;

  cur_topline = topline = 0;

  calculate_start_column(cur_wp);

  for (wp = head_wp; wp != NULL; wp = wp->next) {
    if (wp == cur_wp)
      cur_topline = topline;

    draw_window(topline, wp);

    /* Draw the status line only if there is available space after the
       buffer text space. */
    if (wp->fheight - wp->eheight > 0)
      draw_status_line(topline + wp->eheight, wp);

    topline += wp->fheight;
  }

  term_redraw_cursor();
}
Example #7
0
void render_hud(int width,int height, ApplicationInfo app){
  for(int x = 0;x< app.hud.num_windows;x++){
    if(app.hud.windows[x].on) draw_window(app.hud.windows[x],app);
  }
  draw_fps(width,app);        //Draw last
  draw_userinput(height,app);  //So visible
}
Example #8
0
File: gui.c Project: treejames/xv6
void
draw_again(int id)
{
  draw_background(id);

  unsigned short color = FONT_COLOR;
  if(id >= 3)
    color = 0x0000;
  draw_icon(ICON_FINDER, ICON_X1, ICON_Y);
  draw_string(ICON_X1 + 12, ICON_STRING_Y, "FINDER", color);
  draw_icon(ICON_PHOTO, ICON_X2, ICON_Y);
  draw_string(ICON_X2 + 12, ICON_STRING_Y, "PHOTO", color);
  draw_icon(ICON_TEXT, ICON_X3, ICON_Y);
  draw_string(ICON_X3 + 20, ICON_STRING_Y, "TEXT", color);
  draw_icon(ICON_GAME, ICON_X4, ICON_Y);
  draw_string(ICON_X4 + 17, ICON_STRING_Y, "GAME", color);
  draw_icon(ICON_DRAW, ICON_X5, ICON_Y);
  draw_string(ICON_X5 + 17, ICON_STRING_Y, "DRAW", color);
  draw_icon(ICON_SETTING, ICON_X6, ICON_Y);
  draw_string(ICON_X6 + 8, ICON_STRING_Y, "SETTING", color);

  draw_mouse(ori_x_mouse, ori_y_mouse);

  struct Window* win = Get_LastWindow();
  while(win != 0)
  {
    draw_window(win);
    win = win->pre;
  }
  
  display_to_screen(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
}
Example #9
0
void
EditNotes(	gchar	*title,
		gchar	**notes)
{
	GtkWidget	*NotesWindow;		 /* The main winbdow	      */
	t_winfo		*winfo;			 /* Info for the new window   */

	/* --- First check we're not already editing these notes --- */

	if(!lock4edit(notes, NULL, NULL))	 /* OK to lock ?	      */
		return;				 /* No !!		      */

	if(!(winfo = NEW(t_winfo)))
	{
		msg(MSG_INT_ERR);
		unlock4edit(notes);
		return;
	}

	winfo->notes = notes;

	/* --- Draw window --- */

	NotesWindow = draw_window(title, *notes, winfo);

	lock4edit(notes, GTK_WINDOW(NotesWindow), NULL);

	return;
}						 /* EditNotes()		      */
Example #10
0
win_info_t *change_focus(int x, int y) {

    /* search for the first window that has x & y inside */
    win_info_t *ptr = first;
    win_info_t *prev = NULL;
    while (ptr != NULL) {
        int actual_x = ptr->x-4;
        int actual_y = ptr->y-22;
        int actual_width = ptr->pixbuf->width + 8;
        int actual_height = ptr->pixbuf->height + 22+4;

        if (x >= actual_x && x < (actual_x + actual_width) &&
            y >= actual_y && y < (actual_y + actual_height)) {
            /* found */
            if (prev == NULL) {
                first = ptr->next;
            } else {
                prev->next = ptr->next;
            }
            ptr->next = first;
            first = ptr;
            draw_window(ptr, 1, 1);
            return ptr;
        }

        prev = ptr;
        ptr = ptr->next;
    }

    return first;

}
Example #11
0
void signal_handler(int signum)
{
    if (signum == SIGWINCH) {
        /* Resize */
        draw_window();
    }

}
Example #12
0
void cancel_edit()
{
	if (!is_edit)
		return;
	cell_box.flags &= ~ed_focus;
	memset((Byte*)edit_text,0, 256);
	draw_window();
}
Example #13
0
//Handles input from ipod
static int handle_event(GR_EVENT *event)
{
    switch (event->type)
    {
		case GR_EVENT_TYPE_KEY_UP:
			switch (event->keystroke.ch)
			{

				case 'h': /* Hold switch */
					draw_window();
				break;
			}
		break;

		case GR_EVENT_TYPE_KEY_DOWN:
			switch (event->keystroke.ch)
			{

				case 'h': /* Hold switch */
					draw_help();
				break;

				case 'm': /* Menu button */
					writePot();
					reset();
					pz_close_window (blackjack_wid);

				break;

				case 'l': /* Wheel left */
					dec_bid();
				break;

				case 'r': /* Wheel right */
					inc_bid();
				break;

				case 'w': /* Prev track */
					dec_bid();
				break;

				case 'f': /* Next track */
					inc_bid();
				break;

				case 'd': /* Play */
					play_stay();
				break;

				case '\r': /* Action */
					hit_me();
				break;
			}
		break;
    }
	return 0;
}
Example #14
0
int main(int argc, char* argv[])
{
	SDL_Surface *screen;
	SDL_Event event;

	if (!SDL_Init(SDL_INIT_VIDEO) == 0){
		return 1;
	}

	SDL_WM_SetCaption("SDL Test", "SDL Test");
	
	screen = SDL_SetVideoMode(WIDTH, HEIGTH, DEPTH, 0);
	
	draw_window(screen);

	point p1, p2;
	
	p1.x = 125;
	p1.y = 5;

	p2.x = 135;
	p2.y = 125;
	
	pixel colour;
	colour.r = 255;
	colour.g = 255;
	colour.b = 255;
	colour.a = 255;

	draw_line(screen, p1, p2, colour);

	int quit = 0;

	while((quit == 0) && (SDL_WaitEvent(&event))){
		switch(event.type){
			case SDL_QUIT:
				quit = 1;
				break;
			case SDL_KEYDOWN:
				switch(event.key.keysym.sym){
					case SDLK_ESCAPE:
					case SDLK_q:
						quit = 1;
						break;
					default:
						break;
				}
				break;
			default:
				break;
		}
	}

	SDL_Quit();
	
	return 0;
}
Example #15
0
void pager::add(xwindow *client, bool hlight)   // draw client
{
	QPainter painter(backpix);
	QRect crect;

	// adjust for virtual desktop
	crect.setRect(client->x()+(qapp::adesk*dwidth), client->y(), client->width(), client->height());
	draw_window(&painter, crect, hlight);
	setPixmap(*backpix);
}
Example #16
0
//Deal card to player
static void hit_me()
{
	if(gameRunning == 1 && turn == PLAYER)
	{
		deal_card(PLAYER);

		draw_window();

		change_turn(PLAYER);
	}
}
Example #17
0
int	display_window(int win_id)
{
	if(win_id <=0 || win_id >= windows_list.num_windows)	return -1;
	if(windows_list.window[win_id].window_id != win_id)	return -1;
	// is it active?
	if(windows_list.window[win_id].displayed)
		{
			return(draw_window(&windows_list.window[win_id]));
		}
	return 0;
}
Example #18
0
int def_window_proc(ctrl_t  *ctrl, uint32_t msg, uint32_t arg1, uint32_t arg2)
{
    ctrl_t   *child;

    window_t  *win = (window_t*)ctrl;

    switch(msg)
    {
    case MSG_PAINT:
        draw_window(win);
        break;

    case 2:
        child  = (ctrl_t*)win->child.next;
        while( &child->link != &win->child)
        {
            send_message(child, 2, arg1, arg2);
            child = (ctrl_t*)child->link.next;
        };
        break;

    case MSG_MOUSEMOVE:
        child = win_get_child(win, arg2 & 0xFFFF, (arg2>>16));
        if( win->child_over )
        {
            if(child == win->child_over)
                send_message(child, msg, 0, arg2);
            else
                send_message(win->child_over, MSG_MOUSELEAVE, 0, arg2);
        }
        else if( child )
            send_message(child, MSG_MOUSEENTER, 0, arg2);

        win->child_over = child;
        if( child )
            send_message(child,msg,0,arg2);
        else if(main_cursor != 0)
        {
            set_cursor(0);
            main_cursor = 0;
        }
        break;

    case MSG_SIZE:
        break;

    default:
        child = win_get_child(win, arg2 & 0xFFFF, (arg2>>16));
        win->child_over = child;
        if(child) send_message(child, msg, 0, arg2);
    };

    return 0;
}
Example #19
0
//Lowers bid amount
static void dec_bid()
{
	if(gameRunning == 0)
	{
		if(player_bet >= BET_INCREMENT)
		{
			player_bet -= BET_INCREMENT;
			player_pot += BET_INCREMENT;

			draw_window();
		}
	}
}
Example #20
0
void
term_redisplay (void)
{
  /* Calculate the start column if the line at point has to be truncated. */
  Buffer bp = get_window_bp (cur_wp);
  size_t lastcol = 0, t = tab_width (bp);
  size_t o = window_o (cur_wp);
  size_t lineo = o - get_buffer_line_o (bp);

  col = 0;
  o -= lineo;
  set_window_start_column (cur_wp, 0);

  size_t ew = get_window_ewidth (cur_wp);
  for (size_t lp = lineo; lp != SIZE_MAX; --lp)
    {
      col = 0;
      for (size_t p = lp; p < lineo; ++p)
        {
          char c = get_buffer_char (bp, o + p);
          if (isprint (c))
            col++;
          else
            col += strlen (make_char_printable (get_buffer_char (bp, o + p), col, t));
        }

      if (col >= ew - 1 || (lp / (ew / 3)) + 2 < lineo / (ew / 3))
        {
          set_window_start_column (cur_wp, lp + 1);
          col = lastcol;
          break;
        }

      lastcol = col;
    }

  /* Draw the windows. */
  cur_topline = 0;
  size_t topline = 0;
  for (Window wp = head_wp; wp != NULL; wp = get_window_next (wp))
    {
      if (wp == cur_wp)
        cur_topline = topline;

      draw_window (topline, wp);

      topline += get_window_fheight (wp);
    }

  term_redraw_cursor ();
}
Example #21
0
/* len is in characters, not pixels!!
 */
void TextMan::blit_textbox(const char *p, int y, int x, int len) {
	/* if x | y = -1, then centre the box */
	int xoff, yoff, lin, h, w;
	char *msg, *m;

	debugC(3, kDebugLevelText, "x=%d, y=%d, len=%d", x, y, len);
	if (game.window.active)
		close_window();

	if (x == 0 && y == 0 && len == 0)
		x = y = -1;

	if (len <= 0 || len >= 40)
		len = 32;

	xoff = x * CHAR_COLS;
	yoff = y * CHAR_LINES;
	len--;

	m = msg = word_wrap_string(agi_sprintf(p), &len);

	for (lin = 1; *m; m++) {
		/* Test \r for MacOS 8 */
		if (*m == '\n' || *m == '\r')
			lin++;
	}

	if (lin * CHAR_LINES > GFX_HEIGHT)
		lin = (GFX_HEIGHT / CHAR_LINES);

	w = (len + 2) * CHAR_COLS;
	h = (lin + 2) * CHAR_LINES;

	if (xoff < 0)
		xoff = (GFX_WIDTH - w - CHAR_COLS) / 2;
	else
		xoff -= CHAR_COLS;

	if (yoff < 0)
		yoff = (GFX_HEIGHT - 3 * CHAR_LINES - h) / 2;

	draw_window(xoff, yoff, xoff + w - 1, yoff + h - 1);

	print_text2(2, msg, 0, CHAR_COLS + xoff, CHAR_LINES + yoff,
			len + 1, MSG_BOX_TEXT, MSG_BOX_COLOUR);

	free(msg);

	do_update();
}
Example #22
0
int main(int argc, char *argv[])
{
	if (SDL_Init(SDL_INIT_VIDEO) != 0)
		return 1;

	// Initialize the window.
	struct Window window;	
	if (initialize_window(&window) != 0)
		return 2;

	set_window_title(&window, "Stars and Moons");
	set_window_dimensions(&window, 50, 50, WINDOW_DEFAULT_WIDTH,
		WINDOW_DEFAULT_HEIGHT, WINDOW_DEFAULT_ASPECT_RATIO);

	struct GraphicResources graphic_resources;

	// Provide room for five images.
	if (initialize_graphic_resources(&graphic_resources, 5) != 0)
		return 3;

	load_all_images(5, &graphic_resources);

	// Initialize game data.
	struct GameState game_state;
	if (initialize_game_state(&game_state, BOARD_ROWS, BOARD_COLS) != 0)
		return 4;

	set_game_player(&game_state, STAR);
	set_all_game_matrix_values(&game_state, GAME_STATE_SENTINEL);

	draw_window(&window, &game_state, &graphic_resources);

	SDL_Event event;
	int run_game = 1;
	
	while (run_game == 1)
	{
		process_window_events(&window, &game_state, &graphic_resources);
		if (game_state.run_game == 0)
			run_game = 0;
	}	
	
	SDL_Quit();
	
	destroy_game_state(&game_state);
	destroy_graphic_resources(&graphic_resources);
	destroy_window(&window);

    return 0;
}
Example #23
0
void start_edit(int x, int y)
{

	int ch = 0;
	if (x < scroll_x || x > nx - 1)
	{
		scroll_x = x;
		ch = 1;
	}
	if (y < scroll_y || y > ny - 1)
	{
		scroll_y = y;
		ch = 1;
	}
	if (ch)
	{
		sel_moved = 1;
		draw_window();
	}

	file_box.flags &= ~ed_focus;

	cell_box.flags |= ed_focus;
	cell_box.left = col_left[x] + 1;
	cell_box.top = row_top[y] + 1;
	cell_box.width = col_width[x] - 2;
	//cell_box.height= row_height[y];
	memset((Byte*)edit_text, 0, sizeof(edit_text));
	if (cells[x][y])
	{
		strcpy(edit_text, cells[x][y]);
		edit_text[strlen(cells[x][y]) - 1] = '\0';
	}
	cell_box.pos = cell_box.offset = 0;

	draw_window();
}
Example #24
0
int show_window(window_t *win, int state)
{
    win->win_state = state;

    draw_window(win);

    BeginDraw();
    DrawWindow(win->rc.l, win->rc.t, win->w-1, win->h-1,
               NULL,0,0x41);
    EndDraw();

    blit_caption(&win->caption);
    blit_panel(&win->panel);
//    blit_client(win);
    return 0;
}
Example #25
0
int loadgame_dialog ()
{
	char home[MAX_PATH], path[MAX_PATH];
	int rc, slot = 0;
	int hm, vm, hp, vp;			/* box margins */
	int w;

	hm = 2; vm = 3;
	hp = hm * CHAR_COLS; vp = vm * CHAR_LINES;
	w = (40 - 2 * hm) - 1;

	if (get_app_dir (home, MAX_PATH) < 0) {
		message_box ("Error loading game.");
		return err_BadFileOpen;
	}

	sprintf (path, "%s/" DATA_DIR "/%05X.%s/", home, game.crc, game.id);

	erase_both();
	stop_sound();

	draw_window (hp, vp, GFX_WIDTH - hp, GFX_HEIGHT - vp);
	print_text ("Select a game which you wish to\nrestore:",
		0, hm + 1, vm + 1, w, MSG_BOX_TEXT, MSG_BOX_COLOUR);
	print_text ("Press ENTER to select, ESC cancels",
		0, hm + 1, vm + 17, w, MSG_BOX_TEXT, MSG_BOX_COLOUR);

	slot = select_slot (path);

	if (slot < 0) {
		message_box ("Game NOT restored.");
		return err_OK;
	}

	sprintf(path, "%s/" DATA_DIR "/%05X.%s/%08d.sav",
		home, game.crc, game.id, slot);

	if ((rc = load_game (path)) == err_OK) {
		message_box ("Game restored.");
		game.exit_all_logics = 1;
		menu_enable_all();
	} else {
		message_box ("Error restoring game.");
	}

	return rc;
}
Example #26
0
int main(int argc, char **argv) {

    while(!0) {
        switch(_ksys_wait_for_event(10)) {
        case 2:
            return 0;

        case 3:
            if(_ksys_get_button_id() == 1)return 0;
            break;

        default:
            draw_window();
            break;
        }
    }
}
Example #27
0
int main(int argc, char** argv)
{
  if (2 > argc) {
    std::cout << "\nusage: " << argv[0] << " <term to track> [--full_screen]\n\n";
    return 1;
  }

  tw_term = argv[1];
  std::thread t1(setup_network_stream);

  draw_window(3 == argc);

  io_service.stop();
  t1.detach();

  return 0;
}
Example #28
0
void check_term_size()
{
  int x,y;
  char message[9];
  while (getmaxyx(stdscr, y, x) &&
         (y < MIN_TERM_HEIGHT ||
          x < MIN_TERM_WIDTH))
  {
    wclear(info);
    
    sprintf(message, "min: %dx%d",MIN_TERM_WIDTH, MIN_TERM_HEIGHT);
    draw_window(info,"Size", false);
    mvwprintw(info, 1, 1, message);
    wrefresh(info);
    
    getch();
  }
}
Example #29
0
void pager::draw_pager(void)   // redraw pager and all clients
{
#ifdef DEBUGMSG
	logmsg << "draw pager\n";
#endif	

	backpix->fill(this, 0, 0);
	QPainter painter(backpix);  // painter on background drawable
	
	// fill active desk
	painter.fillRect(qapp::adesk*vw, 0, vw, vh, defaults::pager_active);

	int pos;
	for(int i=1; i < defaults::vdesks; i++)   // draw separator lines
	{
		pos = i*vw;
		painter.drawLine(pos, 0, pos, vh);
	}

	Window w1,w2,*wins;
	uint nwins,i;
	QRect crect;	
	xwindow *client;
	
	if(XQueryTree(QX11Info::display(), QX11Info::appRootWindow(), &w1, &w2, &wins, &nwins) == 0)
		return;
	
	for(i = 0; i < nwins; i++)
	{
		// Qt widgets get their unmap event after the pager is drawn, that's why
		// we check for the unmapped flag too
		
		if((client = qapp::pwindows[wins[i]]) == NULL || ! client->isVisible() || client->is_unmapped())
			continue;

		// adjust for virtual desktop
		crect.setRect(client->x()+(qapp::adesk*dwidth), client->y(), client->width(), client->height());
			
		// draw client window with color set for current or other desktops
		draw_window(&painter, crect);
	}
	XFree(wins);
	setPixmap(*backpix);
}
Example #30
0
File: gui.c Project: treejames/xv6
void
draw_bottom(int id)
{
  /*int i, j;
  for(i = 0; i < SCREEN_WIDTH; ++i)
  {
    for(j = 0; j < SCREEN_HEIGHT; ++j)
    {
      unsigned int offset = j * SCREEN_WIDTH + i;
      *(VESA_ADDR + offset) = RECORD_COLOR[i][j];
    }
  }*/
  draw_background(id);

  unsigned short color = FONT_COLOR;
  if(id >= 3)
    color = 0x0000;
  draw_icon(ICON_FINDER, ICON_X1, ICON_Y);
  draw_string(ICON_X1 + 12, ICON_STRING_Y, "FINDER", color);
  draw_icon(ICON_PHOTO, ICON_X2, ICON_Y);
  draw_string(ICON_X2 + 12, ICON_STRING_Y, "PHOTO", color);
  draw_icon(ICON_TEXT, ICON_X3, ICON_Y);
  draw_string(ICON_X3 + 20, ICON_STRING_Y, "TEXT", color);
  draw_icon(ICON_GAME, ICON_X4, ICON_Y);
  draw_string(ICON_X4 + 17, ICON_STRING_Y, "GAME", color);
  draw_icon(ICON_DRAW, ICON_X5, ICON_Y);
  draw_string(ICON_X5 + 17, ICON_STRING_Y, "DRAW", color);
  draw_icon(ICON_SETTING, ICON_X6, ICON_Y);
  draw_string(ICON_X6 + 8, ICON_STRING_Y, "SETTING", color);

  draw_mouse(ori_x_mouse, ori_y_mouse);

  struct Window* win = Get_LastWindow();
  while(win != 0)
  {
    if(win->pre != 0)
      draw_window(win);
    win = win->pre;
  }
  
  //display_to_screen(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
}