diff --git a/src/main/java/org/terasology/dialogs/ChangeDialogEvent.java b/src/main/java/org/terasology/dialogs/ChangeDialogEvent.java index bf00796..ef90956 100644 --- a/src/main/java/org/terasology/dialogs/ChangeDialogEvent.java +++ b/src/main/java/org/terasology/dialogs/ChangeDialogEvent.java @@ -1,23 +1,10 @@ -/* - * Copyright 2015 MovingBlocks - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.dialogs; import org.terasology.engine.entitySystem.entity.EntityRef; -import org.terasology.engine.entitySystem.event.Event; +import org.terasology.gestalt.entitysystem.event.Event; /** * Fired when the dialog component of an entity should change. diff --git a/src/main/java/org/terasology/dialogs/CloseDialogEvent.java b/src/main/java/org/terasology/dialogs/CloseDialogEvent.java index 1bbeac1..99e54b8 100644 --- a/src/main/java/org/terasology/dialogs/CloseDialogEvent.java +++ b/src/main/java/org/terasology/dialogs/CloseDialogEvent.java @@ -1,22 +1,9 @@ -/* - * Copyright 2015 MovingBlocks - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.dialogs; -import org.terasology.engine.entitySystem.event.Event; +import org.terasology.gestalt.entitysystem.event.Event; /** * Fired when the dialog window should close. diff --git a/src/main/java/org/terasology/dialogs/DefaultTitleParagraphStyle.java b/src/main/java/org/terasology/dialogs/DefaultTitleParagraphStyle.java index f0c5190..e539105 100644 --- a/src/main/java/org/terasology/dialogs/DefaultTitleParagraphStyle.java +++ b/src/main/java/org/terasology/dialogs/DefaultTitleParagraphStyle.java @@ -1,18 +1,5 @@ -/* - * Copyright 2015 MovingBlocks - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.dialogs; import org.terasology.engine.rendering.assets.font.Font; diff --git a/src/main/java/org/terasology/dialogs/DialogScreen.java b/src/main/java/org/terasology/dialogs/DialogScreen.java index 095be53..8bd6211 100644 --- a/src/main/java/org/terasology/dialogs/DialogScreen.java +++ b/src/main/java/org/terasology/dialogs/DialogScreen.java @@ -1,15 +1,15 @@ -// Copyright 2020 The Terasology Foundation +// Copyright 2021 The Terasology Foundation // SPDX-License-Identifier: Apache-2.0 package org.terasology.dialogs; import com.google.common.collect.Lists; -import org.terasology.gestalt.assets.ResourceUrn; import org.terasology.dialogs.action.PlayerAction; import org.terasology.engine.entitySystem.entity.EntityRef; import org.terasology.engine.rendering.assets.texture.TextureRegion; import org.terasology.engine.rendering.nui.CoreScreenLayer; import org.terasology.engine.rendering.nui.widgets.browser.data.html.HTMLDocument; import org.terasology.engine.rendering.nui.widgets.browser.ui.BrowserWidget; +import org.terasology.gestalt.assets.ResourceUrn; import org.terasology.nui.UIWidget; import org.terasology.nui.databinding.ReadOnlyBinding; import org.terasology.nui.layouts.ColumnLayout; @@ -40,10 +40,7 @@ public void initialise() { public boolean isModal() { return true; } - - /** - * @param documentData - */ + public void setDocument(HTMLDocument documentData) { browser.navigateTo(documentData); } @@ -72,7 +69,7 @@ public void addResponseOption(EntityRef charEnt, EntityRef talkTo, String text, newButton.setText(text); newImage.setImage(image); newImage.setFamily("imageColumn"); - newImage.bindVisible(new ReadOnlyBinding() { + newImage.bindVisible(new ReadOnlyBinding<>() { @Override public Boolean get() { return newButton.getMode().equals(UIButton.HOVER_MODE); diff --git a/src/main/java/org/terasology/dialogs/DialogSystem.java b/src/main/java/org/terasology/dialogs/DialogSystem.java index 997b341..c93ef2b 100644 --- a/src/main/java/org/terasology/dialogs/DialogSystem.java +++ b/src/main/java/org/terasology/dialogs/DialogSystem.java @@ -1,4 +1,4 @@ -// Copyright 2020 The Terasology Foundation +// Copyright 2021 The Terasology Foundation // SPDX-License-Identifier: Apache-2.0 package org.terasology.dialogs; @@ -8,7 +8,6 @@ import org.terasology.dialogs.components.DialogResponse; import org.terasology.engine.core.SimpleUri; import org.terasology.engine.entitySystem.entity.EntityRef; -import org.terasology.engine.entitySystem.event.ReceiveEvent; import org.terasology.engine.entitySystem.prefab.Prefab; import org.terasology.engine.entitySystem.systems.BaseComponentSystem; import org.terasology.engine.entitySystem.systems.RegisterMode; @@ -32,6 +31,7 @@ import org.terasology.engine.unicode.EnclosedAlphanumerics; import org.terasology.engine.utilities.Assets; import org.terasology.gestalt.assets.management.AssetManager; +import org.terasology.gestalt.entitysystem.event.ReceiveEvent; import org.terasology.input.Input; import org.terasology.notify.ui.NotificationEvent; import org.terasology.notify.ui.RemoveNotificationEvent; @@ -63,17 +63,11 @@ public class DialogSystem extends BaseComponentSystem { private String talkText; - private ParagraphRenderStyle titleStyle = new DefaultTitleParagraphStyle(); + private final ParagraphRenderStyle titleStyle = new DefaultTitleParagraphStyle(); - private Map mappings = new HashMap(); - private TemplateEngine templateEngine = new TemplateEngineImpl(id -> { - String result = mappings.get(id); - if (result != null) { - return result; - } else { - return "?" + id + "?"; - } - }); + private final Map mappings = new HashMap<>(); + + private final TemplateEngine templateEngine = new TemplateEngineImpl(id -> mappings.getOrDefault(id, "?" + id + "?")); @Override public void initialise() { diff --git a/src/main/java/org/terasology/dialogs/ShowDialogEvent.java b/src/main/java/org/terasology/dialogs/ShowDialogEvent.java index 5e9eed9..53aa3c8 100644 --- a/src/main/java/org/terasology/dialogs/ShowDialogEvent.java +++ b/src/main/java/org/terasology/dialogs/ShowDialogEvent.java @@ -1,35 +1,18 @@ -/* - * Copyright 2015 MovingBlocks - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.dialogs; import org.terasology.dialogs.components.DialogComponent; import org.terasology.engine.entitySystem.entity.EntityRef; -import org.terasology.engine.entitySystem.event.Event; +import org.terasology.gestalt.entitysystem.event.Event; -/** - * TODO Type description - */ public class ShowDialogEvent implements Event { private final String page; private final EntityRef talkTo; /** - * @param dialogComponent * @param talkTo the other entity of the dialog * @param page */ @@ -38,9 +21,6 @@ public ShowDialogEvent(EntityRef talkTo, String page) { this.page = page; } - /** - * @return - */ public DialogComponent getDialog() { return talkTo.getComponent(DialogComponent.class); } diff --git a/src/main/java/org/terasology/dialogs/action/ChangeDialogAction.java b/src/main/java/org/terasology/dialogs/action/ChangeDialogAction.java index ee900b3..0cc0b15 100644 --- a/src/main/java/org/terasology/dialogs/action/ChangeDialogAction.java +++ b/src/main/java/org/terasology/dialogs/action/ChangeDialogAction.java @@ -1,18 +1,5 @@ -/* - * Copyright 2015 MovingBlocks - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.dialogs.action; @@ -24,7 +11,7 @@ */ public class ChangeDialogAction implements PlayerAction { - private String prefab; + private final String prefab; public ChangeDialogAction(String prefab) { this.prefab = prefab; diff --git a/src/main/java/org/terasology/dialogs/action/CloseDialogAction.java b/src/main/java/org/terasology/dialogs/action/CloseDialogAction.java index 6e13e8d..ffbefba 100644 --- a/src/main/java/org/terasology/dialogs/action/CloseDialogAction.java +++ b/src/main/java/org/terasology/dialogs/action/CloseDialogAction.java @@ -1,18 +1,5 @@ -/* - * Copyright 2015 MovingBlocks - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.dialogs.action; diff --git a/src/main/java/org/terasology/dialogs/action/NewDialogAction.java b/src/main/java/org/terasology/dialogs/action/NewDialogAction.java index 7150c9c..b6dba25 100644 --- a/src/main/java/org/terasology/dialogs/action/NewDialogAction.java +++ b/src/main/java/org/terasology/dialogs/action/NewDialogAction.java @@ -1,34 +1,15 @@ -/* - * Copyright 2015 MovingBlocks - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.dialogs.action; import org.terasology.dialogs.ShowDialogEvent; import org.terasology.engine.entitySystem.entity.EntityRef; -/** - * - */ public class NewDialogAction implements PlayerAction { - private String target; + private final String target; - /** - * @param target - */ public NewDialogAction(String target) { this.target = target; } @@ -38,9 +19,6 @@ public void execute(EntityRef charEntity, EntityRef talkTo) { charEntity.send(new ShowDialogEvent(talkTo, target)); } - /** - * @return - */ public String getTarget() { return target; } diff --git a/src/main/java/org/terasology/dialogs/action/PlayerAction.java b/src/main/java/org/terasology/dialogs/action/PlayerAction.java index 44e1737..d85f668 100644 --- a/src/main/java/org/terasology/dialogs/action/PlayerAction.java +++ b/src/main/java/org/terasology/dialogs/action/PlayerAction.java @@ -1,18 +1,5 @@ -/* - * Copyright 2015 MovingBlocks - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.dialogs.action; diff --git a/src/main/java/org/terasology/dialogs/components/DialogResponse.java b/src/main/java/org/terasology/dialogs/components/DialogResponse.java index 2f26110..cdc9aa7 100644 --- a/src/main/java/org/terasology/dialogs/components/DialogResponse.java +++ b/src/main/java/org/terasology/dialogs/components/DialogResponse.java @@ -1,26 +1,13 @@ -/* - * Copyright 2015 MovingBlocks - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.dialogs.components; -import java.util.List; - import org.terasology.dialogs.action.PlayerAction; import org.terasology.reflection.MappedContainer; +import java.util.List; + /** * */ diff --git a/src/main/java/org/terasology/notify/NotificationSystem.java b/src/main/java/org/terasology/notify/NotificationSystem.java index b5da449..f28e7ea 100644 --- a/src/main/java/org/terasology/notify/NotificationSystem.java +++ b/src/main/java/org/terasology/notify/NotificationSystem.java @@ -1,27 +1,14 @@ -/* - * Copyright 2018 MovingBlocks - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.notify; import org.terasology.engine.entitySystem.entity.EntityRef; -import org.terasology.engine.entitySystem.event.ReceiveEvent; import org.terasology.engine.entitySystem.systems.BaseComponentSystem; import org.terasology.engine.entitySystem.systems.RegisterMode; import org.terasology.engine.entitySystem.systems.RegisterSystem; import org.terasology.engine.registry.In; import org.terasology.engine.rendering.nui.NUIManager; +import org.terasology.gestalt.entitysystem.event.ReceiveEvent; import org.terasology.notify.ui.DialogNotificationOverlay; import org.terasology.notify.ui.NotificationEvent; import org.terasology.notify.ui.RemoveNotificationEvent; diff --git a/src/main/java/org/terasology/notify/ui/DialogNotificationOverlay.java b/src/main/java/org/terasology/notify/ui/DialogNotificationOverlay.java index 500dfb8..96ebe3e 100644 --- a/src/main/java/org/terasology/notify/ui/DialogNotificationOverlay.java +++ b/src/main/java/org/terasology/notify/ui/DialogNotificationOverlay.java @@ -1,12 +1,12 @@ -// Copyright 2020 The Terasology Foundation +// Copyright 2021 The Terasology Foundation // SPDX-License-Identifier: Apache-2.0 package org.terasology.notify.ui; -import org.terasology.gestalt.assets.ResourceUrn; import org.terasology.engine.core.Time; import org.terasology.engine.registry.In; import org.terasology.engine.rendering.nui.CoreScreenLayer; +import org.terasology.gestalt.assets.ResourceUrn; import org.terasology.nui.widgets.UIList; import java.util.ArrayList; @@ -19,13 +19,11 @@ public class DialogNotificationOverlay extends CoreScreenLayer { @In private Time time; - private UIList list; - - private List notifications = new ArrayList<>(); + private final List notifications = new ArrayList<>(); @Override public void initialise() { - list = find("notificationList", UIList.class); + UIList list = find("notificationList", UIList.class); list.setList(notifications); list.setItemRenderer(new NotificationRenderer(time)); } diff --git a/src/main/java/org/terasology/notify/ui/Notification.java b/src/main/java/org/terasology/notify/ui/Notification.java index 20912ac..1b52eb0 100644 --- a/src/main/java/org/terasology/notify/ui/Notification.java +++ b/src/main/java/org/terasology/notify/ui/Notification.java @@ -1,18 +1,5 @@ -/* - * Copyright 2015 MovingBlocks - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.notify.ui; @@ -21,8 +8,8 @@ */ final class Notification { - final static long FADE_IN_TIME = 300; - final static long FADE_OUT_TIME = 300; + static final long FADE_IN_TIME = 300; + static final long FADE_OUT_TIME = 300; private final String text; private long timeAdded; @@ -33,9 +20,6 @@ public Notification(String text, long timeAdded) { this.timeAdded = timeAdded; } - /** - * @return - */ public String getText() { return text; } diff --git a/src/main/java/org/terasology/notify/ui/NotificationEvent.java b/src/main/java/org/terasology/notify/ui/NotificationEvent.java index f7e11ca..be8dbd4 100644 --- a/src/main/java/org/terasology/notify/ui/NotificationEvent.java +++ b/src/main/java/org/terasology/notify/ui/NotificationEvent.java @@ -1,25 +1,10 @@ -/* - * Copyright 2015 MovingBlocks - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.notify.ui; -import org.terasology.engine.entitySystem.event.Event; +import org.terasology.gestalt.entitysystem.event.Event; -/** - */ public class NotificationEvent implements Event { private final String text; diff --git a/src/main/java/org/terasology/notify/ui/NotificationRenderer.java b/src/main/java/org/terasology/notify/ui/NotificationRenderer.java index b7ef564..f39e73f 100644 --- a/src/main/java/org/terasology/notify/ui/NotificationRenderer.java +++ b/src/main/java/org/terasology/notify/ui/NotificationRenderer.java @@ -1,4 +1,4 @@ -// Copyright 2020 The Terasology Foundation +// Copyright 2021 The Terasology Foundation // SPDX-License-Identifier: Apache-2.0 package org.terasology.notify.ui; @@ -43,8 +43,7 @@ private float computeAlpha(Notification value) { } if (timeIn < Notification.FADE_IN_TIME) { - float alphaIn = timeIn / (float) Notification.FADE_IN_TIME; - return alphaIn; + return timeIn / (float) Notification.FADE_IN_TIME; } return 1f; diff --git a/src/main/java/org/terasology/notify/ui/RemoveNotificationEvent.java b/src/main/java/org/terasology/notify/ui/RemoveNotificationEvent.java index 3e35c6f..652ca15 100644 --- a/src/main/java/org/terasology/notify/ui/RemoveNotificationEvent.java +++ b/src/main/java/org/terasology/notify/ui/RemoveNotificationEvent.java @@ -1,24 +1,9 @@ -/* - * Copyright 2014 MovingBlocks - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2021 The Terasology Foundation +// SPDX-License-Identifier: Apache-2.0 package org.terasology.notify.ui; -import org.terasology.engine.entitySystem.event.Event; +import org.terasology.gestalt.entitysystem.event.Event; -/** - */ public class RemoveNotificationEvent implements Event { private final String text;