Example #1
0
int main()
{
char title[100];
char i=0;
// tolong lah,source udah aku buka,masak mau ambil hak cipta juga
smile emotikon
respect brada
printf("###################################\n");
printf("###### Window Cursor Kuncier ######\n");
printf("##### 2013 Mathew Sanders #####\n");
printf("##### farewell thank you #####\n");
printf("###################################\n\n");

printf("Masukkan nama / title window yang mau di lock : ");

fgets(title, sizeof(title), stdin);

int len = strlen(title);
title[len-1] = '\0';

printf("Memulai mengunci window \"%s\"\n", title);

printf("Tutup window ini buat exit.\n");

while(1)
{
HWND _active = GetForegroundWindow();
HWND _window = FindWindow(NULL, (LPCTSTR)title);

if(_active == _window)
{
if(i == 0)
{
printf("Window aktif - Locked\n");
clip((LPCTSTR)title);
i = 1;
}
else { Sleep(500); }
}
else
{
if(i == 1)
{
printf("Window tidak aktif - Unlocked\n");
unclip();
i = 0;
}
else { Sleep(500); }
}
}
return 0;
}
Example #2
0
static void draw_tile(drawing *dr, game_drawstate *ds, game_state *state,
                      int x, int y, int tile, int flash_colour,
                      struct rotation *rot, unsigned cedges)
{
    int coords[8];
    char str[40];

    /*
     * If we've been passed a rotation region but we're drawing a
     * tile which is outside it, we must draw it normally. This can
     * occur if we're cleaning up after a completion flash while a
     * new move is also being made.
     */
    if (rot && (x < rot->cx || y < rot->cy ||
                x >= rot->cx+rot->cw || y >= rot->cy+rot->ch))
        rot = NULL;

    if (rot)
	clip(dr, rot->cx, rot->cy, rot->cw, rot->ch);

    /*
     * We must draw each side of the tile's highlight separately,
     * because in some cases (during rotation) they will all need
     * to be different colours.
     */

    /* The centre point is common to all sides. */
    coords[4] = x + TILE_SIZE / 2;
    coords[5] = y + TILE_SIZE / 2;
    rotate(coords+4, rot);

    /* Right side. */
    coords[0] = x + TILE_SIZE - 1;
    coords[1] = y + TILE_SIZE - 1;
    rotate(coords+0, rot);
    coords[2] = x + TILE_SIZE - 1;
    coords[3] = y;
    rotate(coords+2, rot);
    draw_polygon(dr, coords, 3, rot ? rot->rc : COL_LOWLIGHT,
		 rot ? rot->rc : (cedges & CUR_RIGHT) ? COL_LOWCURSOR : COL_LOWLIGHT);

    /* Bottom side. */
    coords[2] = x;
    coords[3] = y + TILE_SIZE - 1;
    rotate(coords+2, rot);
    draw_polygon(dr, coords, 3, rot ? rot->bc : COL_LOWLIGHT,
		 rot ? rot->bc : (cedges & CUR_BOTTOM) ? COL_LOWCURSOR : COL_LOWLIGHT);

    /* Left side. */
    coords[0] = x;
    coords[1] = y;
    rotate(coords+0, rot);
    draw_polygon(dr, coords, 3, rot ? rot->lc : COL_HIGHLIGHT,
		 rot ? rot->lc : (cedges & CUR_LEFT) ? COL_HIGHCURSOR : COL_HIGHLIGHT);

    /* Top side. */
    coords[2] = x + TILE_SIZE - 1;
    coords[3] = y;
    rotate(coords+2, rot);
    draw_polygon(dr, coords, 3, rot ? rot->tc : COL_HIGHLIGHT,
		 rot ? rot->tc : (cedges & CUR_TOP) ? COL_HIGHCURSOR : COL_HIGHLIGHT);

    /*
     * Now the main blank area in the centre of the tile.
     */
    if (rot) {
	coords[0] = x + HIGHLIGHT_WIDTH;
	coords[1] = y + HIGHLIGHT_WIDTH;
	rotate(coords+0, rot);
	coords[2] = x + HIGHLIGHT_WIDTH;
	coords[3] = y + TILE_SIZE - 1 - HIGHLIGHT_WIDTH;
	rotate(coords+2, rot);
	coords[4] = x + TILE_SIZE - 1 - HIGHLIGHT_WIDTH;
	coords[5] = y + TILE_SIZE - 1 - HIGHLIGHT_WIDTH;
	rotate(coords+4, rot);
	coords[6] = x + TILE_SIZE - 1 - HIGHLIGHT_WIDTH;
	coords[7] = y + HIGHLIGHT_WIDTH;
	rotate(coords+6, rot);
	draw_polygon(dr, coords, 4, flash_colour, flash_colour);
    } else {
	draw_rect(dr, x + HIGHLIGHT_WIDTH, y + HIGHLIGHT_WIDTH,
		  TILE_SIZE - 2*HIGHLIGHT_WIDTH, TILE_SIZE - 2*HIGHLIGHT_WIDTH,
		  flash_colour);
    }

    /*
     * Next, the triangles for orientation.
     */
    if (state->orientable) {
	int xdx, xdy, ydx, ydy;
	int cx, cy, displ, displ2;
	switch (tile & 3) {
	  case 0:
	    xdx = 1, xdy = 0;
	    ydx = 0, ydy = 1;
	    break;
	  case 1:
	    xdx = 0, xdy = -1;
	    ydx = 1, ydy = 0;
	    break;
	  case 2:
	    xdx = -1, xdy = 0;
	    ydx = 0, ydy = -1;
	    break;
	  default /* case 3 */:
	    xdx = 0, xdy = 1;
	    ydx = -1, ydy = 0;
	    break;
	}

	cx = x + TILE_SIZE / 2;
	cy = y + TILE_SIZE / 2;
	displ = TILE_SIZE / 2 - HIGHLIGHT_WIDTH - 2;
	displ2 = TILE_SIZE / 3 - HIGHLIGHT_WIDTH;

	coords[0] = cx - displ * xdx + displ2 * ydx;
	coords[1] = cy - displ * xdy + displ2 * ydy;
	rotate(coords+0, rot);
	coords[2] = cx + displ * xdx + displ2 * ydx;
	coords[3] = cy + displ * xdy + displ2 * ydy;
	rotate(coords+2, rot);
	coords[4] = cx - displ * ydx;
	coords[5] = cy - displ * ydy;
	rotate(coords+4, rot);
	draw_polygon(dr, coords, 3, COL_LOWLIGHT_GENTLE, COL_LOWLIGHT_GENTLE);
    }

    coords[0] = x + TILE_SIZE/2;
    coords[1] = y + TILE_SIZE/2;
    rotate(coords+0, rot);
    sprintf(str, "%d", tile / 4);
    draw_text(dr, coords[0], coords[1],
	      FONT_VARIABLE, TILE_SIZE/3, ALIGN_VCENTRE | ALIGN_HCENTRE,
	      COL_TEXT, str);

    if (rot)
	unclip(dr);

    draw_update(dr, x, y, TILE_SIZE, TILE_SIZE);
}
Example #3
0
static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
			game_state *state, int dir, game_ui *ui,
			float animtime, float flashtime)
{
    int i, x, y, ts = TILE_SIZE, isflash = 0, force = 0;

    if (flashtime > 0) {
        int frame = (int)(flashtime / FLASH_FRAME);
        isflash = (frame % 2) == 0;
        debug(("game_redraw: flashtime = %f", flashtime));
    }

    if (!ds->started) {
        int x0 = TODRAW(0)-1, y0 = TODRAW(0)-1;
        int x1 = TODRAW(state->w+2), y1 = TODRAW(state->h+2);

        draw_rect(dr, 0, 0,
                  TILE_SIZE * (state->w+3), TILE_SIZE * (state->h+3),
                  COL_BACKGROUND);

        /* clockwise around the outline starting at pt behind (1,1). */
        draw_line(dr, x0+ts, y0+ts, x0+ts, y0,    COL_HIGHLIGHT);
        draw_line(dr, x0+ts, y0,    x1-ts, y0,    COL_HIGHLIGHT);
        draw_line(dr, x1-ts, y0,    x1-ts, y0+ts, COL_LOWLIGHT);
        draw_line(dr, x1-ts, y0+ts, x1,    y0+ts, COL_HIGHLIGHT);
        draw_line(dr, x1,    y0+ts, x1,    y1-ts, COL_LOWLIGHT);
        draw_line(dr, x1,    y1-ts, x1-ts, y1-ts, COL_LOWLIGHT);
        draw_line(dr, x1-ts, y1-ts, x1-ts, y1,    COL_LOWLIGHT);
        draw_line(dr, x1-ts, y1,    x0+ts, y1,    COL_LOWLIGHT);
        draw_line(dr, x0+ts, y1,    x0+ts, y1-ts, COL_HIGHLIGHT);
        draw_line(dr, x0+ts, y1-ts, x0,    y1-ts, COL_LOWLIGHT);
        draw_line(dr, x0,    y1-ts, x0,    y0+ts, COL_HIGHLIGHT);
        draw_line(dr, x0,    y0+ts, x0+ts, y0+ts, COL_HIGHLIGHT);
        /* phew... */

        draw_update(dr, 0, 0,
                    TILE_SIZE * (state->w+3), TILE_SIZE * (state->h+3));
        force = 1;
        ds->started = 1;
    }

    if (isflash != ds->isflash) force = 1;

    /* draw the arena */
    for (x = 0; x < state->w; x++) {
        for (y = 0; y < state->h; y++) {
            draw_arena_tile(dr, state, ds, ui, x, y, force, isflash);
        }
    }

    /* draw the lasers */
    ds->flash_laserno = LASER_EMPTY;
    if (ui->flash_laser == 1)
        ds->flash_laserno = ui->flash_laserno;
    else if (ui->flash_laser == 2 && animtime > 0)
        ds->flash_laserno = ui->flash_laserno;

    for (i = 0; i < 2*(state->w+state->h); i++) {
        draw_laser_tile(dr, state, ds, ui, i, force);
    }

    /* draw the 'finish' button */
    if (CAN_REVEAL(state)) {
        int outline = (ui->cur_visible && ui->cur_x == 0 && ui->cur_y == 0)
            ? COL_CURSOR : COL_BALL;
        clip(dr, TODRAW(0), TODRAW(0), TILE_SIZE-1, TILE_SIZE-1);
        draw_circle(dr, TODRAW(0) + ds->crad, TODRAW(0) + ds->crad, ds->crad,
                    outline, outline);
        draw_circle(dr, TODRAW(0) + ds->crad, TODRAW(0) + ds->crad, ds->crad-2,
                    COL_BUTTON, COL_BUTTON);
	unclip(dr);
    } else {
        draw_rect(dr, TODRAW(0), TODRAW(0),
		  TILE_SIZE-1, TILE_SIZE-1, COL_BACKGROUND);
    }
    draw_update(dr, TODRAW(0), TODRAW(0), TILE_SIZE, TILE_SIZE);
    ds->reveal = state->reveal;
    ds->isflash = isflash;

    {
        char buf[256];

        if (ds->reveal) {
            if (state->nwrong == 0 &&
                state->nmissed == 0 &&
                state->nright >= state->minballs)
                sprintf(buf, _("CORRECT!"));
            else
                sprintf(buf, _("%d wrong and %d missed balls."),
                        state->nwrong, state->nmissed);
        } else if (state->justwrong) {
	    sprintf(buf, _("Wrong! Guess again."));
	} else {
            if (state->nguesses > state->maxballs)
                sprintf(buf, _("%d too many balls marked."),
                        state->nguesses - state->maxballs);
            else if (state->nguesses <= state->maxballs &&
                     state->nguesses >= state->minballs)
                sprintf(buf, _("Click button to verify guesses."));
            else if (state->maxballs == state->minballs)
                sprintf(buf, _("Balls marked: %d / %d"),
                        state->nguesses, state->minballs);
            else
                sprintf(buf, _("Balls marked: %d / %d-%d."),
                        state->nguesses, state->minballs, state->maxballs);
        }
	if (ui->errors) {
	    if (ui->errors == 1) strcpy(buf + strlen(buf), _(" (1 error)"));
	    else sprintf(buf + strlen(buf), _(" (%d errors)"), ui->errors);
	}
        status_bar(dr, buf);
    }
}
Example #4
0
static void game_redraw(drawing *dr, game_drawstate *ds, game_state *oldstate,
			game_state *state, int dir, game_ui *ui,
			float animtime, float flashtime)
{
    int w = state->par.w /*, a = w*w */;
    int i, x, y;

    if (!ds->started) {
	/*
	 * The initial contents of the window are not guaranteed and
	 * can vary with front ends. To be on the safe side, all
	 * games should start by drawing a big background-colour
	 * rectangle covering the whole window.
	 */
	draw_rect(dr, 0, 0, SIZE(w), SIZE(w), COL_BACKGROUND);

	draw_update(dr, 0, 0, SIZE(w), SIZE(w));

	ds->started = TRUE;
    }

    check_errors(state, ds->errtmp);

    /*
     * Work out what data each tile should contain.
     */
    for (i = 0; i < (w+2)*(w+2); i++)
	ds->tiles[i] = 0;	       /* completely blank square */
    /* The clue squares... */
    for (i = 0; i < 4*w; i++) {
	long tile = state->clues->clues[i];

	CLUEPOS(x, y, i, w);

	if (ds->errtmp[(y+1)*(w+2)+(x+1)])
	    tile |= DF_ERROR;

	ds->tiles[(y+1)*(w+2)+(x+1)] = tile;
    }
    /* ... and the main grid. */
    for (y = 0; y < w; y++) {
	for (x = 0; x < w; x++) {
	    long tile = DF_PLAYAREA;

	    if (state->grid[y*w+x])
		tile |= state->grid[y*w+x];
	    else
		tile |= (long)state->pencil[y*w+x] << DF_PENCIL_SHIFT;

	    if (ui->hshow && ui->hx == x && ui->hy == y)
		tile |= (ui->hpencil ? DF_HIGHLIGHT_PENCIL : DF_HIGHLIGHT);

	    if (state->clues->immutable[y*w+x])
		tile |= DF_IMMUTABLE;

            if (flashtime > 0 &&
                (flashtime <= FLASH_TIME/3 ||
                 flashtime >= FLASH_TIME*2/3))
                tile |= DF_HIGHLIGHT;  /* completion flash */

	    if (ds->errtmp[(y+1)*(w+2)+(x+1)])
		tile |= DF_ERROR;

	    ds->tiles[(y+1)*(w+2)+(x+1)] = tile;
	}
    }

    /*
     * Now actually draw anything that needs to be changed.
     */
    for (y = 0; y < w+2; y++) {
	for (x = 0; x < w+2; x++) {
	    long tl, tr, bl, br;
	    int i = y*(w+2)+x;

	    tr = ds->tiles[y*(w+2)+x];
	    tl = (x == 0 ? 0 : ds->tiles[y*(w+2)+(x-1)]);
	    br = (y == w+1 ? 0 : ds->tiles[(y+1)*(w+2)+x]);
	    bl = (x == 0 || y == w+1 ? 0 : ds->tiles[(y+1)*(w+2)+(x-1)]);

	    if (ds->drawn[i*4] != tl || ds->drawn[i*4+1] != tr ||
		ds->drawn[i*4+2] != bl || ds->drawn[i*4+3] != br) {
		clip(dr, COORD(x-1), COORD(y-1), TILESIZE, TILESIZE);

		draw_tile(dr, ds, state->clues, x-1, y-1, tr);
		if (x > 0)
		    draw_tile(dr, ds, state->clues, x-2, y-1, tl);
		if (y <= w)
		    draw_tile(dr, ds, state->clues, x-1, y, br);
		if (x > 0 && y <= w)
		    draw_tile(dr, ds, state->clues, x-2, y, bl);

		unclip(dr);
		draw_update(dr, COORD(x-1), COORD(y-1), TILESIZE, TILESIZE);

		ds->drawn[i*4] = tl;
		ds->drawn[i*4+1] = tr;
		ds->drawn[i*4+2] = bl;
		ds->drawn[i*4+3] = br;
	    }
	}
    }
}
Example #5
0
void
SDL_GUI_MainWindow::draw(SDL_Surface* targetSurface_in,
                         unsigned int offsetX_in,
                         unsigned int offsetY_in)
{
  RPG_TRACE(ACE_TEXT("SDL_GUI_MainWindow::draw"));

  // sanity check(s)
  SDL_Surface* target_surface = (targetSurface_in ? targetSurface_in
                                                  : inherited::screen_);
  ACE_ASSERT(target_surface);
  ACE_ASSERT(static_cast<int>(offsetX_in) <= target_surface->w);
  ACE_ASSERT(static_cast<int>(offsetY_in) <= target_surface->h);

  // *NOTE*: drawBorder() does its own locking
  // step1: draw borders
  drawBorder(target_surface,
             offsetX_in,
             offsetY_in);

  lock();

  // step2: draw title
  drawTitle(myTitleFont,
            title_,
            target_surface);

  // step3: fill central area
  SDL_Rect prev_clip_rect, clip_rect, dirty_region;
  SDL_GetClipRect (target_surface, &prev_clip_rect);
  clip_rect.x = static_cast<Sint16> (offsetX_in + borderLeft_);
  clip_rect.y = static_cast<Sint16> (offsetY_in + borderTop_);
  clip_rect.w = static_cast<Uint16> (target_surface->w               -
                                     offsetX_in                      -
                                     (borderLeft_ + borderRight_));
  clip_rect.h = static_cast<Uint16> (target_surface->h               -
                                     offsetY_in                      -
                                     (borderTop_ + borderBottom_));
  if (!SDL_SetClipRect (target_surface, &clip_rect))
  {
    ACE_DEBUG((LM_ERROR,
               ACE_TEXT("failed to SDL_SetClipRect(): %s, aborting\n"),
               ACE_TEXT(SDL_GetError())));

    // clean up
    unlock();

    return;
  } // end IF
  RPG_Graphics_InterfaceElementsConstIterator_t iterator;
  iterator = myElementGraphics.find(INTERFACEELEMENT_BORDER_CENTER);
  ACE_ASSERT(iterator != myElementGraphics.end());
  for (unsigned int i = (offsetY_in + borderTop_);
       i < (target_surface->h - borderBottom_);
       i += (*iterator).second->h)
    for (unsigned int j = (offsetX_in + borderLeft_);
         j < (target_surface->w - borderRight_);
         j += (*iterator).second->w)
    {
      RPG_Graphics_Surface::put(std::make_pair(j,
                                               i),
                                *(*iterator).second,
                                target_surface,
                                dirty_region);
      invalidate (clip_rect);
    } // end FOR
  if (!SDL_SetClipRect(target_surface, &prev_clip_rect))
  {
    ACE_DEBUG((LM_ERROR,
               ACE_TEXT("failed to SDL_SetClipRect(): %s, aborting\n"),
               ACE_TEXT(SDL_GetError())));

    // clean up
    unlock();

    return;
  } // end IF
  unlock();

  // init clipping
  clip(target_surface,
       offsetX_in,
       offsetY_in);

  // step4: realize hotspots (and any other children)
  for (RPG_Graphics_WindowsIterator_t iterator = children_.begin();
       iterator != children_.end();
       iterator++)
  {
    try
    {
      (*iterator)->draw(target_surface,
                        offsetX_in,
                        offsetY_in);
    }
    catch (...)
    {
      ACE_DEBUG((LM_ERROR,
                 ACE_TEXT("caught exception in RPG_Graphics_IWindow::draw(), continuing\n")));
    }
  } // end FOR

  // restore previous clipping area
  unclip(target_surface);

  // remember position of last realization
  lastAbsolutePosition_ = std::make_pair(offsetX_in,
                                         offsetY_in);
}