Crossfire JXClient, Trunk  R20561
PickupOption.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-2011 Andreas Kirschbaum.
20  */
21 
22 package com.realtime.crossfire.jxclient.settings.options;
23 
24 import org.jetbrains.annotations.NotNull;
25 
30 public class PickupOption extends CheckBoxOption {
31 
35  @NotNull
36  private final Pickup pickup;
37 
41  private final long option;
42 
49  public PickupOption(@NotNull final Pickup pickup, final long option, @NotNull final String tooltipText) {
50  super(tooltipText);
51  this.pickup = pickup;
52  this.option = option;
53  }
54 
58  @Override
59  protected void execute(final boolean checked) {
60  pickup.setPickupMode(option, checked);
61  }
62 
66  @Override
67  public boolean isDefaultChecked() {
68  return (Pickup.DEFAULT_PICKUP_MODE&option) == option;
69  }
70 
74  @Override
75  public boolean inhibitSave() {
76  return true;
77  }
78 
83  public void setPickupMode(final long pickupMode) {
84  setChecked((pickupMode&option) == option);
85  }
86 
87 }
static final long DEFAULT_PICKUP_MODE
The default pickup mode.
Definition: Pickup.java:38
void setChecked(final boolean checked)
Sets the current state.
void setPickupMode(final long pickupMode)
Notifies this instance that the pickup mode has changed.
Defines constants for pickup mode.
Definition: Pickup.java:33
void setPickupMode(final long pickupMode, final boolean set)
Sets or unsets the pickup mode.
Definition: Pickup.java:357
final String tooltipText
The tooltip text to explain this option.
PickupOption(@NotNull final Pickup pickup, final long option, @NotNull final String tooltipText)
Creates a new instance.
A CheckBoxOption that toggles a pickup setting.
final Pickup pickup
The pickup instance for modifying the pickup mode.