forked from ssine/airport-simulator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbutton.cpp
More file actions
61 lines (55 loc) · 1.59 KB
/
Copy pathbutton.cpp
File metadata and controls
61 lines (55 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "stdafx.h"
#include "button.h"
#include "function.h"
#include "glyph.h"
#include "view.h"
#include <GL/glut.h>
#include "globalvar.h"
#include "passengerGenerator.h"
#include <iostream>
using namespace std;
extern texName a;
extern int texId[];
extern CheckPoint* CheckP[20];
extern PassengerGenerator PassengerG;
//构造函数,构造按钮对象
Button::Button(texName name, float x, float y, float width, float height) {
pos.x = x; pos.y = y;
this->width = width; this->height = height;
texId = ::texId[name];
initId = texId;
}
//移动鼠标事件
void Button::mouseMove(int x, int y) {
if(mouseIn(x, y)) {
texId = initId + 1;
} else {
texId = initId;
}
}
//点击鼠标事件
void Button::mouseClick(int btn, int state, int x, int y) {
if(mouseIn(x, y) && state == GLUT_DOWN) {
texId = initId + 2;
//dosomething
if (texId == ::texId[button_normal] + 2) {
//进入动画
aniWindow = true;
} else if(texId == ::texId[arrow_left_normal] + 2) {
//修改参数
if(*corspVar > 1) *corspVar -= 1;
writeSettingFile();
} else if(texId == ::texId[arrow_right_normal] + 2) {
//修改参数
*corspVar += 1;
writeSettingFile();
} else if(texId == ::texId[playAndPause_normal] + 2) {
//改变安检口状态
switchCheckPointState(CheckP, corspCP);
} else if(texId == ::texId[gooff_normal] + 2) {
programEnd(CheckP, &SerpQ);
} else if(texId == ::texId[plus_normal] + 2) {
PassengerG.addSingle();
}
}
}