Crossfire JXClient, Trunk
AccountPlayCharacterCommand.java
Go to the documentation of this file.
1 /*
2  * This file is part of JXClient, the Fullscreen Java Crossfire Client.
3  *
4  * JXClient is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * JXClient is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with JXClient; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * Copyright (C) 2005-2008 Yann Chachkoff
19  * Copyright (C) 2006-2017,2019-2023 Andreas Kirschbaum
20  * Copyright (C) 2010-2012,2014-2018,2020-2023 Nicolas Weeger
21  */
22 
23 package com.realtime.crossfire.jxclient.gui.commands;
24 
32 import org.jetbrains.annotations.NotNull;
33 
38 public class AccountPlayCharacterCommand implements GUICommand {
39 
43  @NotNull
45 
49  @NotNull
50  private final AbstractGUIElement element;
51 
55  @NotNull
56  private final GuiFactory guiFactory;
57 
64  public AccountPlayCharacterCommand(@NotNull final CommandCallback commandCallback, @NotNull final AbstractGUIElement button, @NotNull final GuiFactory guiFactory) {
65  this.commandCallback = commandCallback;
66  element = button;
67  this.guiFactory = guiFactory;
68  }
69 
70  @Override
71  public boolean canExecute() {
72  return true;
73  }
74 
75  @Override
76  public void execute() {
77  final Gui gui = guiFactory.getGui(element);
78  if (gui == null) {
79  return;
80  }
81 
82  final GUICharacterList charactersList = gui.getFirstElement(GUICharacterList.class, "characters");
83  if (charactersList == null) {
84  return;
85  }
86 
87  final CharacterInformation current = charactersList.getCurrentCharacter();
88  if (current == null) {
89  return;
90  }
91 
93  }
94 
95 }
com.realtime.crossfire.jxclient
com.realtime.crossfire.jxclient.skin.skin
Definition: DefaultJXCSkin.java:23
com.realtime.crossfire.jxclient.gui.commands.AccountPlayCharacterCommand.commandCallback
final CommandCallback commandCallback
Definition: AccountPlayCharacterCommand.java:44
com.realtime.crossfire.jxclient.account.CharacterInformation.getName
String getName()
Definition: CharacterInformation.java:107
com.realtime.crossfire.jxclient.gui.gui.Gui
Definition: Gui.java:49
com.realtime.crossfire.jxclient.skin
com.realtime.crossfire.jxclient.gui.list.GUICharacterList.getCurrentCharacter
CharacterInformation getCurrentCharacter()
Definition: GUICharacterList.java:177
com.realtime.crossfire.jxclient.skin.skin.GuiFactory
Definition: GuiFactory.java:41
com.realtime.crossfire.jxclient.gui.textinput
Definition: ActivateCommandInputCommand.java:23
com.realtime.crossfire.jxclient.gui.commandlist
Definition: CommandList.java:23
com.realtime.crossfire.jxclient.account.CharacterInformation
Definition: CharacterInformation.java:32
com.realtime.crossfire.jxclient.gui.textinput.CommandCallback.accountPlayCharacter
void accountPlayCharacter(@NotNull String name)
com.realtime.crossfire.jxclient.gui.textinput.CommandCallback
Definition: CommandCallback.java:33
com.realtime.crossfire.jxclient.gui.list
Definition: CharacterCellRenderer.java:23
com.realtime.crossfire.jxclient.skin.skin.GuiFactory.getGui
Gui getGui(@NotNull final AbstractGUIElement element)
Definition: GuiFactory.java:110
com.realtime.crossfire.jxclient.gui.commands.AccountPlayCharacterCommand.element
final AbstractGUIElement element
Definition: AccountPlayCharacterCommand.java:50
com.realtime.crossfire.jxclient.gui
com.realtime.crossfire.jxclient.gui.commands.AccountPlayCharacterCommand
Definition: AccountPlayCharacterCommand.java:38
com.realtime.crossfire.jxclient.gui.commands.AccountPlayCharacterCommand.execute
void execute()
Definition: AccountPlayCharacterCommand.java:76
com.realtime.crossfire.jxclient.gui.gui.Gui.getFirstElement
public< T extends GUIElement > T getFirstElement(@NotNull final Class< T > class_)
Definition: Gui.java:300
com.realtime.crossfire.jxclient.account
Definition: CharacterInformation.java:23
com.realtime.crossfire.jxclient.gui.gui
Definition: AbstractGUIElement.java:23
com.realtime.crossfire
com.realtime
com
com.realtime.crossfire.jxclient.gui.commands.AccountPlayCharacterCommand.guiFactory
final GuiFactory guiFactory
Definition: AccountPlayCharacterCommand.java:56
com.realtime.crossfire.jxclient.gui.list.GUICharacterList
Definition: GUICharacterList.java:41
com.realtime.crossfire.jxclient.gui.commands.AccountPlayCharacterCommand.AccountPlayCharacterCommand
AccountPlayCharacterCommand(@NotNull final CommandCallback commandCallback, @NotNull final AbstractGUIElement button, @NotNull final GuiFactory guiFactory)
Definition: AccountPlayCharacterCommand.java:64
com.realtime.crossfire.jxclient.gui.gui.AbstractGUIElement
Definition: AbstractGUIElement.java:37
com.realtime.crossfire.jxclient.gui.commands.AccountPlayCharacterCommand.canExecute
boolean canExecute()
Definition: AccountPlayCharacterCommand.java:71
com.realtime.crossfire.jxclient.gui.commandlist.GUICommand
Definition: GUICommand.java:29