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.gui.Gui
Combines a list of GUIElements to for a gui.
Definition: Gui.java:49
com.realtime.crossfire.jxclient.skin.skin.GuiFactory.getGui
Gui getGui(@NotNull final AbstractGUIElement element)
Returns the Gui an element is part of.
Definition: GuiFactory.java:110
com.realtime.crossfire.jxclient.gui.commandlist.GUICommand
An executable command.
Definition: GUICommand.java:29
com.realtime.crossfire.jxclient.skin
com.realtime.crossfire.jxclient.gui.commands.AccountPlayCharacterCommand.commandCallback
final CommandCallback commandCallback
The CommandCallback to use.
Definition: AccountPlayCharacterCommand.java:44
com.realtime.crossfire.jxclient.gui.gui.AbstractGUIElement
Abstract base class for GUI elements to be shown in Guis.
Definition: AbstractGUIElement.java:37
com.realtime.crossfire.jxclient.gui.textinput
Definition: ActivateCommandInputCommand.java:23
com.realtime.crossfire.jxclient.gui.commandlist
Definition: CommandList.java:23
com.realtime.crossfire.jxclient.gui.list.GUICharacterList
A GUIList display characters of an account.
Definition: GUICharacterList.java:41
com.realtime.crossfire.jxclient.gui.list
Definition: CharacterCellRenderer.java:23
com.realtime.crossfire.jxclient.account.CharacterInformation.getName
String getName()
Returns the character's name.
Definition: CharacterInformation.java:107
com.realtime.crossfire.jxclient.gui.list.GUICharacterList.getCurrentCharacter
CharacterInformation getCurrentCharacter()
Returns the currently selected character in the list.
Definition: GUICharacterList.java:177
com.realtime.crossfire.jxclient.gui.commands.AccountPlayCharacterCommand
A GUICommand sending a play character request to the server.
Definition: AccountPlayCharacterCommand.java:38
com.realtime.crossfire.jxclient.gui
com.realtime.crossfire.jxclient.gui.commands.AccountPlayCharacterCommand.execute
void execute()
Executes the command.
Definition: AccountPlayCharacterCommand.java:76
com.realtime.crossfire.jxclient.account.CharacterInformation
Information for one character for an account.
Definition: CharacterInformation.java:32
com.realtime.crossfire.jxclient.gui.commands.AccountPlayCharacterCommand.AccountPlayCharacterCommand
AccountPlayCharacterCommand(@NotNull final CommandCallback commandCallback, @NotNull final AbstractGUIElement button, @NotNull final GuiFactory guiFactory)
Creates a new instance.
Definition: AccountPlayCharacterCommand.java:64
com.realtime.crossfire.jxclient.account
Definition: CharacterInformation.java:23
com.realtime.crossfire.jxclient.skin.skin.GuiFactory
Factory for creating Gui instances.
Definition: GuiFactory.java:41
com.realtime.crossfire.jxclient.gui.textinput.CommandCallback.accountPlayCharacter
void accountPlayCharacter(@NotNull String name)
Plays a character from the current account.
com.realtime.crossfire.jxclient.gui.gui
Definition: AbstractGUIElement.java:23
com.realtime.crossfire
com.realtime.crossfire.jxclient.gui.textinput.CommandCallback
Interface that defines callback functions needed by commands.
Definition: CommandCallback.java:33
com.realtime.crossfire.jxclient.gui.commands.AccountPlayCharacterCommand.guiFactory
final GuiFactory guiFactory
The global GuiFactory instance.
Definition: AccountPlayCharacterCommand.java:56
com.realtime.crossfire.jxclient.gui.commands.AccountPlayCharacterCommand.canExecute
boolean canExecute()
Returns whether this command may be executed.
Definition: AccountPlayCharacterCommand.java:71
com.realtime
com
com.realtime.crossfire.jxclient.gui.gui.Gui.getFirstElement
public< T extends GUIElement > T getFirstElement(@NotNull final Class< T > class_)
Returns the first gui element of this gui belonging to the given class.
Definition: Gui.java:291
com.realtime.crossfire.jxclient.gui.commands.AccountPlayCharacterCommand.element
final AbstractGUIElement element
The AbstractGUIElement to find information for account creation.
Definition: AccountPlayCharacterCommand.java:50