-
Notifications
You must be signed in to change notification settings - Fork 1
/
AdminPanelWindow.mxml
72 lines (61 loc) · 2.57 KB
/
AdminPanelWindow.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
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" horizontalScrollPolicy="off" verticalScrollPolicy="off" creationComplete="_initWindow();"
paddingLeft="5" paddingBottom="5" paddingRight="5" paddingTop="5" borderAlpha="0.85" showCloseButton="true" close="_close();" >
<mx:Script>
<![CDATA[
import flash.events.Event;
import flash.events.KeyboardEvent;
import mx.controls.*;
import mx.events.MoveEvent;
import mx.managers.PopUpManager;
private var _scrollPos:int;
private var _commandHistory:Array = new Array();
private var _nHistory:int = 0;
private function _initWindow():void {
this.addEventListener("move", _checkMove);
if (InfoFetcher.adminsLv1.indexOf(parentApplication.login_name.toLowerCase()) >= 0) {
adminCommandInput.enabled = true;
broadcastButton.enabled = true;
adminCommandInput.addEventListener(KeyboardEvent.KEY_DOWN, _handleKeyDown);
}
}
private function _checkMove(e:Event):void {
if (this.y < 0) this.y = 0;
}
public function showLog(str:String):void {
_scrollPos = logTextArea.verticalScrollPosition;
logTextArea.text = str;
logTextArea.callLater(_scrollDown);
}
private function _scrollDown():void{
if (scrollCheck.selected) logTextArea.verticalScrollPosition = logTextArea.maxVerticalScrollPosition;
else logTextArea.verticalScrollPosition = _scrollPos;
}
private function _saveHistory():void {
if (adminCommandInput.text != "") {
_commandHistory.unshift(adminCommandInput.text);
_nHistory = 0;
}
}
private function _handleKeyDown(e:KeyboardEvent):void {
if (e.keyCode == 38) {
if (_nHistory < _commandHistory.length) _nHistory += 1;
if (_nHistory > 0) e.currentTarget.text = _commandHistory[_nHistory - 1];
} else if (e.keyCode == 40) {
if (_nHistory > 1) _nHistory -= 1;
if (_nHistory > 0) e.currentTarget.text = _commandHistory[_nHistory - 1];
}
}
private function _close():void {
PopUpManager.removePopUp(this);
}
]]>
</mx:Script>
<mx:HBox>
<mx:TextInput id="adminCommandInput" width="300" enter="_saveHistory();" enabled="false" />
<mx:CheckBox id="scrollCheck" label="Auto-scroll" selected="true" />
<mx:Spacer width="50"/>
<mx:Button id="broadcastButton" label="Broadcast" enabled="false" />
</mx:HBox>
<mx:TextArea id="logTextArea" width="800" height="500" fontFamily="Lucida console" fontSize="11" wordWrap="false" backgroundColor="0x000000" color="0xbbbbbb" />
</mx:TitleWindow>