-
Notifications
You must be signed in to change notification settings - Fork 1
/
PlayerInfoWindow.mxml
154 lines (139 loc) · 6.29 KB
/
PlayerInfoWindow.mxml
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" fontSize="12" horizontalScrollPolicy="off" verticalScrollPolicy="off" backgroundImage="{IMAGE_DIRECTORY}windowBg.jpg"
paddingLeft="5" paddingBottom="5" paddingRight="5" paddingTop="5" showCloseButton="true" doubleClickEnabled="true" doubleClick="_minmax();" close="_close();"
headerHeight="22" borderThicknessLeft="5" borderThicknessRight="5" title="Player Info" creationComplete="_initWindow();">
<mx:Script>
<![CDATA[
import flash.events.Event;
import mx.controls.*;
import mx.effects.Effect;
import mx.effects.Move;
import mx.managers.PopUpManager;
[Bindable]
private var _user:Object;
[Bindable]
public var pmText:String = "";
private const IMAGE_DIRECTORY:String = "http://49.212.52.151/dojo/images/";
private const MINIMIZED_HEIGHT:int = 29;
private function _initWindow():void {
this.addEventListener("move", _handleMove);
}
private function _handleMove(e:Event):void {
if (this.y < 0) this.y = 0;
}
public function readUser(user:Object):void {
_user = user;
// if (user.monitor_game != "*") {
// _status = "Now monitoring " + user.monitor_game.split("+")[0] + " vs " + user.monitor_game.split("+")[1];
// } else if (user.opponent != "") {
// _status = "Now playing against " + user.opponent;
// } else {
// _status = "";
// }
avatarCanvas.addChild(InfoFetcher.medalCanvas(user));
}
private function _swfError():void {
// flagLoader.source = IMAGE_DIRECTORY + "flags_m/err.swf";
}
public function scrollDown():void{
pmTextArea.verticalScrollPosition = pmTextArea.maxVerticalScrollPosition;
}
public function togglePM():void {
if (pmCheckBox.selected) {
pmTextArea.visible = true;
} else {
pmTextArea.visible = false;
}
}
private function _clearHighlight():void {
pmTextArea.setStyle('backgroundColor', undefined);
pmTextArea.callLater(scrollDown);
}
private function _minmax():void {
if (contentMouseY > 2) return;
if (this.height == MINIMIZED_HEIGHT) {
this.height = undefined;
this.title = "Player Info";
this.setStyle('borderColor', undefined);
this.setStyle('borderAlpha', undefined);
} else {
this.height = MINIMIZED_HEIGHT;
this.title = "Player Info (" + _user.name + ")";
this.setStyle('borderColor', 0xFFAA33);
this.setStyle('borderAlpha', 0.8);
}
}
public function maximize():void {
if (this.height == MINIMIZED_HEIGHT) {
this.height = undefined;
this.title = "Player Info";
this.setStyle('borderColor', undefined);
this.setStyle('borderAlpha', undefined);
}
}
private function _openDetail():void {
dispatchEvent(new Event("open_detail"));
}
private function _close():void {
dispatchEvent(new Event("close_window"));
PopUpManager.removePopUp(this);
}
]]>
</mx:Script>
<mx:Move id="showMove" yFrom="103" yTo="0" duration="200" />
<mx:Move id="hideMove" yFrom="0" yTo="103" duration="150" />
<mx:HBox>
<mx:Canvas id="avatarCanvas" width="128" height="128">
<mx:Image width="128" height="128" source="{_user.avatar}"/>
</mx:Canvas>
<mx:VBox>
<mx:HBox verticalAlign="middle">
<mx:VBox>
<mx:HBox>
<mx:Label id="nameLabel" text="{_user.name}" fontSize="15" fontWeight="bold" />
<mx:Label text="{_user.titleName}" toolTip="{_user.titleSubName}" fontSize="16" fontWeight="bold" color="#FF0000" paddingLeft="-2" paddingRight="-2" />
</mx:HBox>
<mx:Label paddingRight="10" text="{parentApplication.lan.country}: {_user.country}"/>
</mx:VBox>
<mx:SWFLoader id="flagLoader" width="56" height="44" source="{_user.flag_m}" ioError="_swfError();" />
</mx:HBox>
<mx:VBox height="73" horizontalScrollPolicy="off" verticalScrollPolicy="off">
<mx:Label text="{parentApplication.lan.rate}: {_user.rating} ({_user.rank})"/>
<mx:HBox>
<mx:Label text="{_user.wins} {parentApplication.lan.win_small}"/>
<mx:Label text="{_user.losses} {parentApplication.lan.loss_small}"/>
<mx:Label text="({_user.percentage.toFixed(1)}%)"/>
<mx:Label text="{parentApplication.lan.total}: {_user.total}"/>
</mx:HBox>
<mx:HBox>
<mx:Label text="{parentApplication.lan.streak}: {_user.streak_best}"/>
<mx:Label text="({parentApplication.lan.current}: {_user.streak})"/>
</mx:HBox>
</mx:VBox>
</mx:VBox>
</mx:HBox>
<mx:Spacer height="-115"/>
<mx:HBox>
<mx:Spacer width="50"/>
<mx:TextArea id="pmTextArea" htmlText="{pmText}" wordWrap="true" editable="false" width="339" height="103" backgroundAlpha="0.93" showEffect="{showMove}" hideEffect="{hideMove}" visible="false" cornerRadius="5" fontFamily="Meiryo UI" leading="0" />
</mx:HBox>
<mx:HBox>
<mx:Label text="PM:"/>
<mx:TextInput id="directMessage" keyDown="_clearHighlight();" width="360" height="23" fontFamily="Meiryo UI" fontSize="11" />
</mx:HBox>
<mx:HBox width="100%" horizontalAlign="center" verticalAlign="middle" paddingTop="0">
<mx:Button id="detail" label="{parentApplication.lan.detail}" click="_openDetail();" />
<mx:HBox id="othersCommands" visible="false" includeInLayout="false">
<mx:Button id="challenge" click="_close();" label="{parentApplication.lan.challenge}" enabled="false" />
<mx:Button id="favorite" icon="@Embed('images/icon_star.png')" toolTip="{parentApplication.lan.favorite}" />
<mx:Button id="ignore" icon="@Embed('images/icon_block.png')" toolTip="{parentApplication.lan.ignore}" enabled="false"/>
<mx:Button id="allowStudy" label="{parentApplication.lan.allow}" toolTip="Allow to move pieces in study mode" enabled="false"/>
</mx:HBox>
<mx:HBox id="selfCommands" visible="false" includeInLayout="false">
<mx:ComboBox id="setRateCombo" enabled="false" width="80" fontSize="10" />
<mx:Button id="setRateButton" label="{parentApplication.lan.set_rate}" enabled="false" />
</mx:HBox>
<mx:CheckBox id="pmCheckBox" label="" click="togglePM();" paddingRight="-5" toolTip="Open PM window" />
<mx:Image source="@Embed('images/icon_greet.png')" click="pmCheckBox.selected = !pmCheckBox.selected; togglePM();" toolTip="Open PM window" />
</mx:HBox>
</mx:TitleWindow>