소스 검색

Implement the title screen. Click on it to start a game.

legacy
Sam Hocevar sam 14 년 전
부모
커밋
e9583b8a62
2개의 변경된 파일32개의 추가작업 그리고 5개의 파일을 삭제
  1. +31
    -5
      src/input.cpp
  2. +1
    -0
      src/worldentity.h

+ 31
- 5
src/input.cpp 파일 보기

@@ -30,9 +30,10 @@ static class InputData

public:
InputData()
: mouse(-1, -1),
buttons(0, 0, 0),
nentities(0)
: mouse(-1),
buttons(0),
nentities(0),
lastfocus(0)
{ }

private:
@@ -42,6 +43,7 @@ private:
static int const MAX_ENTITIES = 100;
WorldEntity *entities[MAX_ENTITIES];
int nentities;
WorldEntity *lastfocus;
}
inputdata;

@@ -120,23 +122,47 @@ void Input::SetMousePos(int2 coord)
for (int n = 0; n < data->nentities; n++)
{
if (data->entities[n] == best)
{
data->entities[n]->mousepos = (int2)((int3)coord - best->bbox[0]);
if (best != data->lastfocus)
data->entities[n]->pressed = data->buttons;
}
else
{
data->entities[n]->mousepos = int2(-1);
/* FIXME */
data->entities[n]->released = 0;
data->entities[n]->pressed = 0;
data->entities[n]->clicked = 0;
}
}

data->lastfocus = best;
}

void Input::SetMouseButton(int index)
{
data->buttons[index] = 1;

/* FIXME: parse all subscribed entities and update them */
if (data->lastfocus)
{
if (!data->lastfocus->pressed[index])
data->lastfocus->clicked[index] = 1;
data->lastfocus->pressed[index] = 1;
data->lastfocus->released[index] = 0;
}
}

void Input::UnsetMouseButton(int index)
{
data->buttons[index] = 0;

/* FIXME: parse all subscribed entities and update them */
if (data->lastfocus)
{
if (data->lastfocus->pressed[index])
data->lastfocus->released[index] = 1;
data->lastfocus->pressed[index] = 0;
data->lastfocus->clicked[index] = 0;
}
}


+ 1
- 0
src/worldentity.h 파일 보기

@@ -28,6 +28,7 @@ public:

int2 mousepos;
int3 mousebuttons;
int3 pressed, clicked, released;

protected:
WorldEntity();


불러오는 중...
취소
저장