コード例 #1
0
ファイル: ex05.cpp プロジェクト: bambams/ma5king
void MyDialog::GetHiscoreName() {
	MAS::Window win;
	Dialog clientArea;
	ClearScreen clr;
	EditBox edit;
	Label l1, l2;
	Button but;

	clientArea.Add(clr);
	win.title.SetText("Game Over!");
	clientArea.Resize(278, 98);

	l1.Setup(10, 10, 200, 16, 0, 0, "You have a high score!", 0);
	l2.Setup(10, 38, 128, 16, 0, 0, "Enter your name:", 0);
	edit.Setup(150, 26, 100, 28, 0, D_EXIT, "player", 8);
	but.Setup(50, 60, 130, 24, ALLEGRO_KEY_O, D_EXIT, "&OK");

	clientArea.Add(l1);
	clientArea.Add(l2);
	clientArea.Add(edit);
	clientArea.Add(but);

	win.SetClientArea(&clientArea);
	win.Centre();
	edit.Select();
   //TODO
	//win.Popup(this, win.x(), win.y(), &edit);
	hsc->Add(edit.GetText(), eScore.GetInt(), eLines.GetInt());
}
コード例 #2
0
ファイル: ex05.cpp プロジェクト: bambams/ma5king
void MyDialog::HandleEvent(Widget &obj, int msg, intptr_t arg1, intptr_t arg2) {
	Dialog::HandleEvent(obj, msg, arg1, arg2);

	switch (msg) {
		case MSG_ACTIVATE:
			if (obj == buttonPlay) {
				buttonPlay.Disable();
				MoveFocusTo(&map);
				map.Play((int)eLevel.GetPosition());
				eLevel.Disable();
				Settings::showMouse = false;
			}
			else if (obj == bScores) {
				ShowScores();
			}
		break;

		case MSG_GAMEOVER: {
			Settings::showMouse = true;

			if (hsc->CanAdd(eScore.GetInt())) {
				GetHiscoreName();
				ShowScores();
			}
			else {
//TODO
#if 0
				MessageBox dlg("Message", "Game over! You lose!", NULL, NULL, "OK", NULL, NULL);
				dlg.Popup(this);
#endif
			}
			buttonPlay.Enable();
			eLevel.Enable();
			nextPiece.piece = NULL;
		}
		break;

		case MSG_UPDATESCORE: {
			eLines.SetNumber((int)arg1);
			eScore.SetNumber((int)arg2);
		}
		break;

		case MSG_INCREASELEVEL: {
			eLevel.Increment();
		}
		break;

		case MSG_NEWPIECE: {
			nextPiece.piece = map.GetNextPiece();
		}
		break;
	};
}