-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMultiGameDialog.cpp
79 lines (73 loc) · 2.17 KB
/
CMultiGameDialog.cpp
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "stdafx.h"
#include "Resource.h"
#include <mmsystem.h>
#include <ddraw.h>
#include "gamelib.h"
#include "CMultiGameDialog.h"
namespace game_framework {
/////////////////////////////////////////////////////////////////////////////
// CMultiGameDialog,使用DecorationPattern來讓多Dialog的類別可自動呼叫其滑鼠事件
/////////////////////////////////////////////////////////////////////////////
CMultiGameDialog::CMultiGameDialog(){
subGameDialog.clear();
}
CMultiGameDialog::~CMultiGameDialog(){}
void CMultiGameDialog::OnShow(){
vector<CGameDialog*>::iterator it;
for(it=subGameDialog.begin();it!=subGameDialog.end();it++){
(*it)->OnShow();
}
}
void CMultiGameDialog::OnMove(){
vector<CGameDialog*>::iterator it;
for(it=subGameDialog.begin();it!=subGameDialog.end();it++){
(*it)->OnMove();
}
}
void CMultiGameDialog::OnLeftDown(CMouseState& state){
vector<CGameDialog*>::iterator it;
for(it=subGameDialog.begin();it!=subGameDialog.end();it++){
if((*it)->PtInRect(state.LeftDownPoint())){
(*it)->OnLeftDown(state);
}
}
}
void CMultiGameDialog::OnLeftUp(CMouseState& state){
vector<CGameDialog*>::iterator it;
for(it=subGameDialog.begin();it!=subGameDialog.end();it++){
if((*it)->PtInRect(state.LeftDownPoint())){
(*it)->OnLeftUp(state);
}
}
}
void CMultiGameDialog::OnRightDown(CMouseState& state){
vector<CGameDialog*>::iterator it;
for(it=subGameDialog.begin();it!=subGameDialog.end();it++){
if((*it)->PtInRect(state.RightDownPoint())){
(*it)->OnRightDown(state);
}
}
}
void CMultiGameDialog::OnRightUp(CMouseState& state){
vector<CGameDialog*>::iterator it;
for(it=subGameDialog.begin();it!=subGameDialog.end();it++){
if((*it)->PtInRect(state.RightDownPoint())){
(*it)->OnRightUp(state);
}
}
}
void CMultiGameDialog::OnMouseMove(CMouseState& state){
vector<CGameDialog*>::iterator it;
for(it=subGameDialog.begin();it!=subGameDialog.end();it++){
if((*it)->PtInRect(state.NowPoint())){
(*it)->OnMouseMove(state);
}
}
}
void CMultiGameDialog::AddGameDialog(CGameDialog* gameDialog){
subGameDialog.push_back(gameDialog);
}
void CMultiGameDialog::ClearGameDialog(){
subGameDialog.clear();
}
}