Rename AdvancedListItem

This commit is contained in:
huanghongxun
2018-08-09 20:22:57 +08:00
parent 64092a4bd4
commit 8bf6a9ec9d
4 changed files with 25 additions and 27 deletions

View File

@@ -38,6 +38,7 @@ import org.jackhuang.hmcl.game.AccountHelper;
import org.jackhuang.hmcl.setting.Accounts; import org.jackhuang.hmcl.setting.Accounts;
import org.jackhuang.hmcl.setting.Theme; import org.jackhuang.hmcl.setting.Theme;
import org.jackhuang.hmcl.task.Schedulers; import org.jackhuang.hmcl.task.Schedulers;
import org.jackhuang.hmcl.ui.construct.AdvancedListItem;
import org.jackhuang.hmcl.ui.construct.ComponentList; import org.jackhuang.hmcl.ui.construct.ComponentList;
import org.jackhuang.hmcl.ui.wizard.DecoratorPage; import org.jackhuang.hmcl.ui.wizard.DecoratorPage;
@@ -49,7 +50,7 @@ import java.util.Optional;
public class AccountPage extends StackPane implements DecoratorPage { public class AccountPage extends StackPane implements DecoratorPage {
private final StringProperty title; private final StringProperty title;
private final ObjectProperty<Runnable> onDelete = new SimpleObjectProperty<>(this, "onDelete"); private final ObjectProperty<Runnable> onDelete = new SimpleObjectProperty<>(this, "onDelete");
private final VersionListItem item; private final AdvancedListItem item;
private final Account account; private final Account account;
@FXML @FXML
@@ -73,7 +74,7 @@ public class AccountPage extends StackPane implements DecoratorPage {
@FXML @FXML
private JFXProgressBar progressBar; private JFXProgressBar progressBar;
public AccountPage(Account account, VersionListItem item) { public AccountPage(Account account, AdvancedListItem item) {
this.account = account; this.account = account;
this.item = item; this.item = item;

View File

@@ -49,11 +49,7 @@ import org.jackhuang.hmcl.setting.*;
import org.jackhuang.hmcl.task.Schedulers; import org.jackhuang.hmcl.task.Schedulers;
import org.jackhuang.hmcl.task.Task; import org.jackhuang.hmcl.task.Task;
import org.jackhuang.hmcl.task.TaskExecutor; import org.jackhuang.hmcl.task.TaskExecutor;
import org.jackhuang.hmcl.ui.construct.AdvancedListBox; import org.jackhuang.hmcl.ui.construct.*;
import org.jackhuang.hmcl.ui.construct.ClassTitle;
import org.jackhuang.hmcl.ui.construct.DialogCloseEvent;
import org.jackhuang.hmcl.ui.construct.IconedItem;
import org.jackhuang.hmcl.ui.construct.RipplerContainer;
import org.jackhuang.hmcl.upgrade.UpdateChecker; import org.jackhuang.hmcl.upgrade.UpdateChecker;
import org.jackhuang.hmcl.util.Lang; import org.jackhuang.hmcl.util.Lang;
import org.jackhuang.hmcl.util.MappedObservableList; import org.jackhuang.hmcl.util.MappedObservableList;
@@ -127,7 +123,7 @@ public final class LeftPaneController {
// ==== Accounts ==== // ==== Accounts ====
// Missing account item // Missing account item
VersionListItem missingAccountItem = new VersionListItem(i18n("account.missing"), i18n("message.unknown")); AdvancedListItem missingAccountItem = new AdvancedListItem(i18n("account.missing"), i18n("message.unknown"));
RipplerContainer missingAccountRippler = new RipplerContainer(missingAccountItem); RipplerContainer missingAccountRippler = new RipplerContainer(missingAccountItem);
missingAccountItem.setOnSettingsButtonClicked(e -> addNewAccount()); missingAccountItem.setOnSettingsButtonClicked(e -> addNewAccount());
missingAccountRippler.setOnMouseClicked(e -> addNewAccount()); missingAccountRippler.setOnMouseClicked(e -> addNewAccount());
@@ -162,7 +158,7 @@ public final class LeftPaneController {
} }
private RipplerContainer createAccountItem(Account account) { private RipplerContainer createAccountItem(Account account) {
VersionListItem item = new VersionListItem(account.getCharacter(), accountSubtitle(account)); AdvancedListItem item = new AdvancedListItem(account.getCharacter(), accountSubtitle(account));
RipplerContainer rippler = new RipplerContainer(item); RipplerContainer rippler = new RipplerContainer(item);
item.setOnSettingsButtonClicked(e -> { item.setOnSettingsButtonClicked(e -> {
AccountPage accountPage = new AccountPage(account, item); AccountPage accountPage = new AccountPage(account, item);
@@ -219,7 +215,7 @@ public final class LeftPaneController {
if (node instanceof RipplerContainer && node.getProperties().get("profile") instanceof String) { if (node instanceof RipplerContainer && node.getProperties().get("profile") instanceof String) {
boolean current = Objects.equals(node.getProperties().get("profile"), profile.getName()); boolean current = Objects.equals(node.getProperties().get("profile"), profile.getName());
((RipplerContainer) node).setSelected(current); ((RipplerContainer) node).setSelected(current);
((VersionListItem) ((RipplerContainer) node).getContainer()).setGameVersion(current ? i18n("profile.selected") : ""); ((AdvancedListItem) ((RipplerContainer) node).getContainer()).setSubtitle(current ? i18n("profile.selected") : "");
} }
} }
}); });
@@ -228,7 +224,7 @@ public final class LeftPaneController {
private void onProfilesLoading() { private void onProfilesLoading() {
LinkedList<RipplerContainer> list = new LinkedList<>(); LinkedList<RipplerContainer> list = new LinkedList<>();
for (Profile profile : Settings.instance().getProfiles()) { for (Profile profile : Settings.instance().getProfiles()) {
VersionListItem item = new VersionListItem(Profiles.getProfileDisplayName(profile)); AdvancedListItem item = new AdvancedListItem(Profiles.getProfileDisplayName(profile));
RipplerContainer ripplerContainer = new RipplerContainer(item); RipplerContainer ripplerContainer = new RipplerContainer(item);
item.setOnSettingsButtonClicked(e -> Controllers.getDecorator().showPage(new ProfilePage(profile))); item.setOnSettingsButtonClicked(e -> Controllers.getDecorator().showPage(new ProfilePage(profile)));
ripplerContainer.setOnMouseClicked(e -> Settings.instance().setSelectedProfile(profile)); ripplerContainer.setOnMouseClicked(e -> Settings.instance().setSelectedProfile(profile));

View File

@@ -15,7 +15,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
package org.jackhuang.hmcl.ui; package org.jackhuang.hmcl.ui.construct;
import com.jfoenix.controls.JFXButton; import com.jfoenix.controls.JFXButton;
import javafx.event.EventHandler; import javafx.event.EventHandler;
@@ -26,27 +26,28 @@ import javafx.scene.image.Image;
import javafx.scene.image.ImageView; import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent; import javafx.scene.input.MouseEvent;
import javafx.scene.layout.StackPane; import javafx.scene.layout.StackPane;
import org.jackhuang.hmcl.ui.FXUtils;
public final class VersionListItem extends StackPane { public final class AdvancedListItem extends StackPane {
@FXML @FXML
private StackPane imageViewContainer; private StackPane imageViewContainer;
@FXML @FXML
private Label lblVersionName; private Label lblTitle;
@FXML @FXML
private Label lblGameVersion; private Label lblSubtitle;
@FXML @FXML
private ImageView imageView; private ImageView imageView;
@FXML private JFXButton btnSettings; @FXML private JFXButton btnSettings;
public VersionListItem(String versionName) { public AdvancedListItem(String title) {
this(versionName, ""); this(title, "");
} }
public VersionListItem(String versionName, String gameVersion) { public AdvancedListItem(String title, String subtitle) {
FXUtils.loadFXML(this, "/assets/fxml/version-list-item.fxml"); FXUtils.loadFXML(this, "/assets/fxml/advanced-list-item.fxml");
lblVersionName.setText(versionName); lblTitle.setText(title);
lblGameVersion.setText(gameVersion); lblSubtitle.setText(subtitle);
FXUtils.limitSize(imageView, 32, 32); FXUtils.limitSize(imageView, 32, 32);
} }
@@ -55,12 +56,12 @@ public final class VersionListItem extends StackPane {
btnSettings.setOnMouseClicked(handler); btnSettings.setOnMouseClicked(handler);
} }
public void setVersionName(String versionName) { public void setTitle(String title) {
lblVersionName.setText(versionName); lblTitle.setText(title);
} }
public void setGameVersion(String gameVersion) { public void setSubtitle(String subtitle) {
lblGameVersion.setText(gameVersion); lblSubtitle.setText(subtitle);
} }
public void setImage(Image image, Rectangle2D viewport) { public void setImage(Image image, Rectangle2D viewport) {

View File

@@ -21,10 +21,10 @@
</StackPane> </StackPane>
<BorderPane style="-fx-padding: 0 0 0 10;"> <BorderPane style="-fx-padding: 0 0 0 10;">
<top> <top>
<Label fx:id="lblVersionName" maxWidth="90" style="-fx-font-size: 15;" textAlignment="JUSTIFY" /> <Label fx:id="lblTitle" maxWidth="90" style="-fx-font-size: 15;" textAlignment="JUSTIFY" />
</top> </top>
<bottom> <bottom>
<Label fx:id="lblGameVersion" maxWidth="90" style="-fx-font-size: 10;" textAlignment="JUSTIFY" /> <Label fx:id="lblSubtitle" maxWidth="90" style="-fx-font-size: 10;" textAlignment="JUSTIFY" />
</bottom> </bottom>
</BorderPane> </BorderPane>
</HBox> </HBox>