ソースを参照

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();


読み込み中…
キャンセル
保存