コード例 #1
0
ファイル: ex.c プロジェクト: na94ojt/MyPlayground
///////////////////타이머 생성하기
int MyTimer1()
{
    static long oldT1;
    long newT1;

    if(g_level == 1)
    {
        newT1=_GetTickCount();
        if(1000 <= (newT1-oldT1))
        {
            oldT1=newT1;
            g_time1--;

            if(g_time1 <= 0)
            {
                g_time1 = 0;
                g_level = 2;
            }

            _Invalidate();
        }
    }

    return 0;
}
コード例 #2
0
void
BasicTerminalBuffer::DeleteChars(int32 numChars)
{
	fSoftWrappedCursor = false;

	TerminalLine* line = _LineAt(fCursor.y);
	if (fCursor.x < line->length) {
		if (fCursor.x + numChars < line->length) {
			int32 left = line->length - fCursor.x - numChars;
			memmove(line->cells + fCursor.x, line->cells + fCursor.x + numChars,
				left * sizeof(TerminalCell));
			line->length = fCursor.x + left;
			// process BCE on freed tail cells
			for (int i = 0; i < numChars; i++)
				line->cells[fCursor.x + left + i].attributes = fAttributes;
		} else {
			// process BCE on freed tail cells
			for (int i = 0; i < line->length - fCursor.x; i++)
				line->cells[fCursor.x + i].attributes = fAttributes;
			// remove all remaining chars
			line->length = fCursor.x;
		}

		_Invalidate(fCursor.y, fCursor.y);
	}
}
コード例 #3
0
ファイル: ex.c プロジェクト: na94ojt/MyPlayground
int MyInput1(char key)
{
    int y=0;

    if(SPACE == key)
    {
        if(g_a == 0)
        {
            g_level = 5;
        }
        else
        {
            g_level = 1+ g_a;
        }
    }
    else if(MY_UP == key)
    {
        if(g_a >0)
        {
            g_a--;
        }
    }
    else if(MY_DOWN == key)
    {
        if(g_a < 3)
        {
            g_a++;
        }
    }

    _Invalidate();


    return 0;
}
コード例 #4
0
void
BasicTerminalBuffer::EraseCharsFrom(int32 first, int32 numChars)
{
	TerminalLine* line = _LineAt(fCursor.y);

	int32 end = min_c(first + numChars, fWidth);
	for (int32 i = first; i < end; i++)
		line->cells[i].attributes = fAttributes;

	line->attributes = fAttributes;

	fSoftWrappedCursor = false;

	end = min_c(first + numChars, line->length);
	if (first > 0 && IS_WIDTH(line->cells[first - 1].attributes))
		first--;
	if (end > 0 && IS_WIDTH(line->cells[end - 1].attributes))
		end++;

	for (int32 i = first; i < end; i++) {
		line->cells[i].character = kSpaceChar;
		line->cells[i].attributes = fAttributes;
	}

	_Invalidate(fCursor.y, fCursor.y);
}
コード例 #5
0
ファイル: bwmem.cpp プロジェクト: jjwhg/bwchart
// display player message
void BWMem::DisplayPlayerMessage(HANDLE hProcess, HWND hWndBW, const char *msgtext, int durationS)
{
	// read current message index
	unsigned char index;
	ReadBytes(hProcess, (char*)Addr(MSGINDEX), (char*)&index, sizeof(index));

	// real index
	int realindex = (int)index;
	DWORD adr = Addr(MSGTEXT0)+realindex*218;
	DWORD adrt = Addr(MSGTICK0)+realindex*4;

	// write message time
	DWORD time = GetTickCount() + durationS*1000;
	WriteBytes(hProcess, (char*)adrt, (char*)&time, sizeof(time));

	// write message text
	WriteBytes(hProcess, (char*)adr, msgtext, strlen(msgtext)+1);

	// increment message index
	index = (index+1)%11;
	WriteBytes(hProcess, (char*)Addr(MSGINDEX), (char*)&index, sizeof(index));

	// invalidate screen
	Sleep(100);
	_Invalidate(hWndBW);
}
コード例 #6
0
ファイル: ex.c プロジェクト: na94ojt/MyPlayground
// 타이머
int MyTimer2()                 //적들이 내려오게 하는 타이머
{
    static long oldT1=0;      //이거 저번에 내가 주석달아서 올림
    long newT1;
    int i;

    newT1=_GetTickCount();

    if(100 <= (newT1-oldT1))
    {
        oldT1=newT1;

        for(i=0; i<10; i++)
        {

            if(1 == g_aH[i].life)         //만약 적이 살아있으면
            {
                g_aH[i].y++;              //한칸씩 내려온다

                if(20 <= g_aH[i].y)       //15칸 내려오면
                {
                    g_aH[i].y=0;        //초기화
                }
            }
        }
        _Invalidate();
    }
    return 0;
}
コード例 #7
0
//---------------------------------------------------------
int CSG_Shape_Point::Add_Point(double x, double y, int iPart)
{
	m_Point.x	= x;
	m_Point.y	= y;

	_Invalidate();

	return( 1 );
}
コード例 #8
0
ファイル: ex.c プロジェクト: na94ojt/MyPlayground
int MyInput3(char key)
{
    if(SPACE == key)
    {
        g_level = 1;
    }
    _Invalidate();

    return 0;
}
コード例 #9
0
void
BasicTerminalBuffer::InsertCR()
{
	TerminalLine* line = _LineAt(fCursor.y);

	line->attributes = fAttributes;
	line->softBreak = false;
	fSoftWrappedCursor = false;
	fCursor.x = 0;
	_Invalidate(fCursor.y, fCursor.y);
	_CursorChanged();
}
コード例 #10
0
void
BasicTerminalBuffer::Clear(bool resetCursor)
{
	fSoftWrappedCursor = false;
	fScreenOffset = 0;
	_ClearLines(0, fHeight - 1);

	if (resetCursor)
		fCursor.SetTo(0, 0);

	if (fHistory != NULL)
		fHistory->Clear();

	fDirtyInfo.linesScrolled = 0;
	_Invalidate(0, fHeight - 1);
}
コード例 #11
0
void
BasicTerminalBuffer::DeleteColumnsFrom(int32 first)
{
	fSoftWrappedCursor = false;

	TerminalLine* line = _LineAt(fCursor.y);

	for (int32 i = first; i < fWidth; i++)
		line->cells[i].attributes = fAttributes;

	if (first <= line->length) {
		line->length = first;
		line->attributes = fAttributes;
	}
	_Invalidate(fCursor.y, fCursor.y);
}
コード例 #12
0
ファイル: ex.c プロジェクト: na94ojt/MyPlayground
int MyInput5(char key)
{
    int i;

    if(MY_LEFT == key)                 //왼쪽으로 이동
    {
        g_G.x--;
    }
    else if(MY_RIGHT == key)         //오른쪽으로 이동
    {
        g_G.x++;
    }

    _Invalidate();

    return 0;
}
コード例 #13
0
ファイル: ex.c プロジェクト: na94ojt/MyPlayground
int MyTimer3()
{
    static long oldT=0;
    long newT;

    newT=_GetTickCount();

    if(1000 <= (newT-oldT))
    {
        oldT=newT;

        g_aH[rand()%10].life=1;

        _Invalidate();
    }

    return 0;
}
コード例 #14
0
ファイル: WorkspacesView.cpp プロジェクト: mmanley/Antares
void
WorkspacesView::MouseUp(BMessage* message, BPoint where)
{
	if (!fHasMoved && fSelectedWorkspace >= 0) {
		int32 index;
		_WorkspaceAt(where, index);
		if (index >= 0)
			Window()->Desktop()->SetWorkspaceAsync(index);
	}

	if (fSelectedWindow != NULL) {
		// We need to hide the selection frame again
		_Invalidate();
	}

	fSelectedWindow = NULL;
	fSelectedWorkspace = -1;
}
コード例 #15
0
void
BasicTerminalBuffer::_ClearLines(int32 first, int32 last)
{
	int32 firstCleared = -1;
	int32 lastCleared = -1;

	for (int32 i = first; i <= last; i++) {
		TerminalLine* line = _LineAt(i);
		if (line->length > 0) {
			if (firstCleared == -1)
				firstCleared = i;
			lastCleared = i;
		}

		line->Clear(fAttributes, fWidth);
	}

	if (firstCleared >= 0)
		_Invalidate(firstCleared, lastCleared);
}
コード例 #16
0
ファイル: shape_points.cpp プロジェクト: johanvdw/saga-debian
//---------------------------------------------------------
int CSG_Shape_Points::Del_Part(int del_Part)
{
	if( del_Part >= 0 && del_Part < m_nParts )
	{
		delete(m_pParts[del_Part]);

		m_nParts--;

		for(int iPart=del_Part; iPart<m_nParts; iPart++)
		{
			m_pParts[iPart]	= m_pParts[iPart + 1];
		}

		m_pParts	= (CSG_Shape_Part **)SG_Realloc(m_pParts , m_nParts * sizeof(CSG_Shape_Part *));

		_Invalidate();
	}

	return( m_nParts );
}
コード例 #17
0
void
BasicTerminalBuffer::FillScreen(UTF8Char c, uint32 attributes)
{
	uint32 width = HALF_WIDTH;
	if (c.IsFullWidth()) {
		attributes |= A_WIDTH;
		width = FULL_WIDTH;
	}

	fSoftWrappedCursor = false;

	for (int32 y = 0; y < fHeight; y++) {
		TerminalLine *line = _LineAt(y);
		for (int32 x = 0; x < fWidth / (int32)width; x++) {
			line->cells[x].character = c;
			line->cells[x].attributes = attributes;
		}
		line->length = fWidth / width;
	}

	_Invalidate(0, fHeight - 1);
}
コード例 #18
0
void
BasicTerminalBuffer::InsertSpace(int32 num)
{
// TODO: Deal with full-width chars!
	if (fCursor.x + num > fWidth)
		num = fWidth - fCursor.x;

	if (num > 0) {
		fSoftWrappedCursor = false;
		_PadLineToCursor();
		_InsertGap(num);

		TerminalLine* line = _LineAt(fCursor.y);
		for (int32 i = fCursor.x; i < fCursor.x + num; i++) {
			line->cells[i].character = kSpaceChar;
			line->cells[i].attributes = line->cells[fCursor.x - 1].attributes;
		}
		line->attributes = fAttributes;

		_Invalidate(fCursor.y, fCursor.y);
	}
}
コード例 #19
0
ファイル: ex.c プロジェクト: na94ojt/MyPlayground
void RunKey(char key)
{
    g_key=key;

    _Invalidate();

    if(g_level==1)
    {
        MyInput1(key);
    }
    else if(g_level==2)
    {
        MyInput2(key);
    }
    else if(g_level==3)
    {
        MyInput3(key);
    }
    else if(g_level==5)
    {
        MyInput5(key);
    }
    /*
    else if(g_level==6)
    {
    	Myinput6(key);
    }
    else if(g_level==7)
    {
    	Myinput7(key);
    }
    else if(g_level==8)
    {
    	Myinput8(key);
    }
    */
}
コード例 #20
0
void
BasicTerminalBuffer::InsertChar(UTF8Char c)
{
//debug_printf("BasicTerminalBuffer::InsertChar('%.*s' (%d), %#lx)\n",
//(int)c.ByteCount(), c.bytes, c.bytes[0], attributes);
	int32 width = c.IsFullWidth() ? FULL_WIDTH : HALF_WIDTH;

	if (fSoftWrappedCursor || (fCursor.x + width) > fWidth)
		_SoftBreakLine();
	else
		_PadLineToCursor();

	fSoftWrappedCursor = false;

	if (!fOverwriteMode)
		_InsertGap(width);

	TerminalLine* line = _LineAt(fCursor.y);
	line->cells[fCursor.x].character = c;
	line->cells[fCursor.x].attributes
		= fAttributes | (width == FULL_WIDTH ? A_WIDTH : 0);

	if (line->length < fCursor.x + width)
		line->length = fCursor.x + width;

	_Invalidate(fCursor.y, fCursor.y);

	fCursor.x += width;

// TODO: Deal correctly with full-width chars! We must take care not to
// overwrite half of a full-width char. This holds also for other methods.

	if (fCursor.x == fWidth) {
		fCursor.x -= width;
		fSoftWrappedCursor = true;
	}
}
コード例 #21
0
void
BasicTerminalBuffer::EraseAbove()
{
	// Clear the preceding lines.
	if (fCursor.y > 0)
		_ClearLines(0, fCursor.y - 1);

	fSoftWrappedCursor = false;

	// Delete the chars on the cursor line before (and including) the cursor.
	TerminalLine* line = _LineAt(fCursor.y);
	if (fCursor.x < line->length) {
		int32 to = fCursor.x;
		if (IS_WIDTH(line->cells[fCursor.x].attributes))
			to++;
		for (int32 i = 0; i <= to; i++) {
			line->cells[i].attributes = fAttributes;
			line->cells[i].character = kSpaceChar;
		}
	} else
		line->Clear(fAttributes, fWidth);

	_Invalidate(fCursor.y, fCursor.y);
}
コード例 #22
0
ファイル: WorkspacesView.cpp プロジェクト: mmanley/Antares
void
WorkspacesView::MouseMoved(BMessage* message, BPoint where)
{
	if (fSelectedWindow == NULL && fSelectedWorkspace < 0)
		return;

	// check if the correct mouse button is pressed
	int32 buttons;
	if (message->FindInt32("buttons", &buttons) != B_OK
		|| (buttons & B_PRIMARY_MOUSE_BUTTON) == 0)
		return;

	if (!fHasMoved) {
		Window()->Desktop()->SetMouseEventWindow(Window());
			// don't let us off the mouse
	}

	int32 index;
	BRect workspaceFrame = _WorkspaceAt(where, index);

	if (fSelectedWindow == NULL) {
		if (fSelectedWorkspace >= 0 && fSelectedWorkspace != index) {
			fSelectedWorkspace = index;
			_Invalidate();
		}
		return;
	}

	workspaceFrame.InsetBy(1, 1);

	if (index != fSelectedWorkspace) {
		if (fSelectedWindow->IsNormal() && !fSelectedWindow->InWorkspace(index)) {
			// move window to this new workspace
			uint32 newWorkspaces = (fSelectedWindow->Workspaces()
				& ~(1UL << fSelectedWorkspace)) | (1UL << index);

			Window()->Desktop()->SetWindowWorkspaces(fSelectedWindow,
				newWorkspaces);
		}
		fSelectedWorkspace = index;
	}

	BRect screenFrame = _ScreenFrame(index);
	float left = rintf((where.x - workspaceFrame.left - fLeftTopOffset.x)
		* screenFrame.Width() / workspaceFrame.Width());
	float top = rintf((where.y - workspaceFrame.top - fLeftTopOffset.y)
		* screenFrame.Height() / workspaceFrame.Height());

	BPoint leftTop;
	if (fSelectedWorkspace == Window()->Desktop()->CurrentWorkspace())
		leftTop = fSelectedWindow->Frame().LeftTop();
	else {
		if (fSelectedWindow->Anchor(fSelectedWorkspace).position
				== kInvalidWindowPosition) {
			fSelectedWindow->Anchor(fSelectedWorkspace).position
				= fSelectedWindow->Frame().LeftTop();
		}
		leftTop = fSelectedWindow->Anchor(fSelectedWorkspace).position;
	}

	// Don't treat every little mouse move as a window move - this would
	// make it too hard to activate a workspace.
	float diff = max_c(fabs(fClickPoint.x - where.x),
		fabs(fClickPoint.y - where.y));
	if (!fHasMoved && diff > 2)
		fHasMoved = true;

	if (fHasMoved) {
		Window()->Desktop()->MoveWindowBy(fSelectedWindow, left - leftTop.x,
			top - leftTop.y, fSelectedWorkspace);
	}
}
コード例 #23
0
ファイル: ex.c プロジェクト: na94ojt/MyPlayground
void RunStart()
{
    Mystart();

    _Invalidate();
}
コード例 #24
0
ファイル: WorkspacesView.cpp プロジェクト: mmanley/Antares
void
WorkspacesView::WindowChanged(::Window* window)
{
	// TODO: be smarter about this!
	_Invalidate();
}
コード例 #25
0
void
BasicTerminalBuffer::_Scroll(int32 top, int32 bottom, int32 numLines)
{
	if (numLines == 0)
		return;

	if (numLines > 0) {
		// scroll text up
		if (top == 0) {
			// The lines scrolled out of the screen range are transferred to
			// the history.

			// add the lines to the history
			if (fHistory != NULL) {
				int32 toHistory = min_c(numLines, bottom - top + 1);
				for (int32 i = 0; i < toHistory; i++)
					fHistory->AddLine(_LineAt(i));

				if (toHistory < numLines)
					fHistory->AddEmptyLines(numLines - toHistory);
			}

			if (numLines >= bottom - top + 1) {
				// all lines are scrolled out of range -- just clear them
				_ClearLines(top, bottom);
			} else if (bottom == fHeight - 1) {
				// full screen scroll -- update the screen offset and clear new
				// lines
				fScreenOffset = (fScreenOffset + numLines) % fHeight;
				for (int32 i = bottom - numLines + 1; i <= bottom; i++)
					_LineAt(i)->Clear(fAttributes, fWidth);
			} else {
				// Partial screen scroll. We move the screen offset anyway, but
				// have to move the unscrolled lines to their new location.
				// TODO: It may be more efficient to actually move the scrolled
				// lines only (might depend on the number of scrolled/unscrolled
				// lines).
				for (int32 i = fHeight - 1; i > bottom; i--) {
					std::swap(fScreen[_LineIndex(i)],
						fScreen[_LineIndex(i + numLines)]);
				}

				// update the screen offset and clear the new lines
				fScreenOffset = (fScreenOffset + numLines) % fHeight;
				for (int32 i = bottom - numLines + 1; i <= bottom; i++)
					_LineAt(i)->Clear(fAttributes, fWidth);
			}

			// scroll/extend dirty range

			if (fDirtyInfo.dirtyTop != INT_MAX) {
				// If the top or bottom of the dirty region are above the
				// bottom of the scroll region, we have to scroll them up.
				if (fDirtyInfo.dirtyTop <= bottom) {
					fDirtyInfo.dirtyTop -= numLines;
					if (fDirtyInfo.dirtyBottom <= bottom)
						fDirtyInfo.dirtyBottom -= numLines;
				}

				// numLines above the bottom become dirty
				_Invalidate(bottom - numLines + 1, bottom);
			}

			fDirtyInfo.linesScrolled += numLines;

			// invalidate new empty lines
			_Invalidate(bottom + 1 - numLines, bottom);

			// In case only part of the screen was scrolled, we invalidate also
			// the lines below the scroll region. Those remain unchanged, but
			// we can't convey that they have not been scrolled via
			// TerminalBufferDirtyInfo. So we need to force the view to sync
			// them again.
			if (bottom < fHeight - 1)
				_Invalidate(bottom + 1, fHeight - 1);
		} else if (numLines >= bottom - top + 1) {
			// all lines are completely scrolled out of range -- just clear
			// them
			_ClearLines(top, bottom);
		} else {
			// partial scroll -- clear the lines scrolled out of range and move
			// the other ones
			for (int32 i = top + numLines; i <= bottom; i++) {
				int32 lineToDrop = _LineIndex(i - numLines);
				int32 lineToKeep = _LineIndex(i);
				fScreen[lineToDrop]->Clear(fAttributes, fWidth);
				std::swap(fScreen[lineToDrop], fScreen[lineToKeep]);
			}
			// clear any lines between the two swapped ranges above
			for (int32 i = bottom - numLines + 1; i < top + numLines; i++)
				_LineAt(i)->Clear(fAttributes, fWidth);

			_Invalidate(top, bottom);
		}
	} else {
		// scroll text down
		numLines = -numLines;

		if (numLines >= bottom - top + 1) {
			// all lines are completely scrolled out of range -- just clear
			// them
			_ClearLines(top, bottom);
		} else {
			// partial scroll -- clear the lines scrolled out of range and move
			// the other ones
// TODO: When scrolling the whole screen, we could just update fScreenOffset and
// clear the respective lines.
			for (int32 i = bottom - numLines; i >= top; i--) {
				int32 lineToKeep = _LineIndex(i);
				int32 lineToDrop = _LineIndex(i + numLines);
				fScreen[lineToDrop]->Clear(fAttributes, fWidth);
				std::swap(fScreen[lineToDrop], fScreen[lineToKeep]);
			}
			// clear any lines between the two swapped ranges above
			for (int32 i = bottom - numLines + 1; i < top + numLines; i++)
				_LineAt(i)->Clear(fAttributes, fWidth);

			_Invalidate(top, bottom);
		}
	}
}
コード例 #26
0
ファイル: WorkspacesView.cpp プロジェクト: mmanley/Antares
void
WorkspacesView::MouseDown(BMessage* message, BPoint where)
{
	// reset tracking variables
	fSelectedWorkspace = -1;
	fSelectedWindow = NULL;
	fHasMoved = false;

	// check if the correct mouse button is pressed
	int32 buttons;
	if (message->FindInt32("buttons", &buttons) != B_OK
		|| (buttons & B_PRIMARY_MOUSE_BUTTON) == 0)
		return;

	int32 index;
	BRect workspaceFrame = _WorkspaceAt(where, index);
	if (index < 0)
		return;

	Workspace workspace(*Window()->Desktop(), index);
	workspaceFrame.InsetBy(1, 1);

	BRect screenFrame = _ScreenFrame(index);

	::Window* window;
	BRect windowFrame;
	BPoint leftTop;
	while (workspace.GetPreviousWindow(window, leftTop) == B_OK) {
		BRect frame = _WindowFrame(workspaceFrame, screenFrame, window->Frame(),
			leftTop);
		if (frame.Contains(where) && window->Feel() != kDesktopWindowFeel
			&& window->Feel() != kWindowScreenFeel) {
			fSelectedWindow = window;
			windowFrame = frame;
			break;
		}
	}

	// Some special functionality (clicked with modifiers)

	int32 modifiers;
	if (fSelectedWindow != NULL
		&& message->FindInt32("modifiers", &modifiers) == B_OK) {
		if ((modifiers & B_CONTROL_KEY) != 0) {
			// Activate window if clicked with the control key pressed,
			// minimize it if control+shift - this mirrors Deskbar
			// shortcuts (when pressing a team menu item).
			if ((modifiers & B_SHIFT_KEY) != 0)
				fSelectedWindow->ServerWindow()->NotifyMinimize(true);
			else
				Window()->Desktop()->ActivateWindow(fSelectedWindow);
			fSelectedWindow = NULL;
		} else if ((modifiers & B_OPTION_KEY) != 0) {
			// Also, send window to back if clicked with the option
			// key pressed.
			Window()->Desktop()->SendWindowBehind(fSelectedWindow);
			fSelectedWindow = NULL;
		}
	}

	// If this window is movable, we keep it selected
	// (we prevent our own window from being moved, too)

	if ((fSelectedWindow != NULL
			&& (fSelectedWindow->Flags() & B_NOT_MOVABLE) != 0)
		|| fSelectedWindow == Window()) {
		fSelectedWindow = NULL;
	}

	fLeftTopOffset = where - windowFrame.LeftTop();
	fSelectedWorkspace = index;
	fClickPoint = where;

	if (index >= 0)
		_Invalidate();
}