implemented context menu in group panel
This commit is contained in:
parent
d57a077272
commit
12c7c94d1e
2 changed files with 68 additions and 3 deletions
|
|
@ -9,18 +9,83 @@
|
|||
* *
|
||||
***************************************************************************/
|
||||
|
||||
import { ui } from "../UI";
|
||||
import { UIComponentEnum } from "../UIComponentEnum";
|
||||
|
||||
import { Component } from "../toolkit/Component";
|
||||
|
||||
import { ActionContextMenu } from "../dialog/ActionContextMenu";
|
||||
import { ChatInputComponent } from "./ChatInputComponent";
|
||||
|
||||
declare let marauroa: any;
|
||||
declare let stendhal: any;
|
||||
|
||||
/**
|
||||
* a group member
|
||||
*/
|
||||
export class GroupMemberComponent extends Component {
|
||||
|
||||
constructor(name: string) {
|
||||
constructor(private memberName: string, private isUserLeader: boolean) {
|
||||
super("group-member-template");
|
||||
this.child(".group-member-name")!.innerText = name;
|
||||
this.child(".group-member-name")!.innerText = memberName;
|
||||
this.componentElement.addEventListener("mouseup", (event) => {
|
||||
this.onMouseUp(event);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
buildActions(actions: any) {
|
||||
let playerName = this.memberName;
|
||||
actions.push({
|
||||
title: "Talk",
|
||||
action: function(_groupMemberComponent: GroupMemberComponent) {
|
||||
(ui.get(UIComponentEnum.ChatInput) as ChatInputComponent).setText("/msg "
|
||||
+ playerName
|
||||
+ " ");
|
||||
}
|
||||
});
|
||||
actions.push({
|
||||
title: "Where",
|
||||
action: function(_groupMemberComponent: GroupMemberComponent) {
|
||||
let action = {
|
||||
"type": "where",
|
||||
"target": playerName,
|
||||
"zone": marauroa.currentZoneName
|
||||
};
|
||||
marauroa.clientFramework.sendAction(action);
|
||||
}
|
||||
});
|
||||
if (this.isUserLeader && (!marauroa.me || this.memberName != marauroa.me["_name"])) {
|
||||
actions.push({
|
||||
title: "Kick",
|
||||
action: function(_groupMemberComponent: GroupMemberComponent) {
|
||||
let action = {
|
||||
"type": "group_management",
|
||||
"action": "kick",
|
||||
"params": playerName,
|
||||
"zone": marauroa.currentZoneName
|
||||
};
|
||||
marauroa.clientFramework.sendAction(action);
|
||||
}
|
||||
});
|
||||
actions.push({
|
||||
title: "Make leader",
|
||||
action: function(_groupMemberComponent: GroupMemberComponent) {
|
||||
let action = {
|
||||
"type": "group_management",
|
||||
"action": "leader",
|
||||
"params": playerName,
|
||||
"zone": marauroa.currentZoneName
|
||||
};
|
||||
marauroa.clientFramework.sendAction(action);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
onMouseUp(event: MouseEvent) {
|
||||
stendhal.ui.actionContextMenu.set(ui.createSingletonFloatingWindow("Action",
|
||||
new ActionContextMenu(this), Math.max(10, event.pageX - 50), event.pageY - 5));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ export class GroupPanelComponent extends Panel {
|
|||
renderGroupMembers() {
|
||||
this.clear();
|
||||
for (let member of Object.keys(stendhal.data.group.members)) {
|
||||
this.add(new GroupMemberComponent(member));
|
||||
this.add(new GroupMemberComponent(member, stendhal.data.group.leader === marauroa.me["_name"]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue