Skip to content

Commit

Permalink
feat(gestaltv7-eventsystem): Migration Event and @ReceiveEvent to ges…
Browse files Browse the repository at this point in the history
…talt's (#30)

Co-authored-by: Tobias Nett <skaldarnar@googlemail.com>
  • Loading branch information
DarkWeird and skaldarnar authored Dec 8, 2021
1 parent 8f708f0 commit d510447
Show file tree
Hide file tree
Showing 17 changed files with 54 additions and 258 deletions.
19 changes: 3 additions & 16 deletions src/main/java/org/terasology/dialogs/ChangeDialogEvent.java
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
19 changes: 3 additions & 16 deletions src/main/java/org/terasology/dialogs/CloseDialogEvent.java
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
11 changes: 4 additions & 7 deletions src/main/java/org/terasology/dialogs/DialogScreen.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -40,10 +40,7 @@ public void initialise() {
public boolean isModal() {
return true;
}

/**
* @param documentData
*/

public void setDocument(HTMLDocument documentData) {
browser.navigateTo(documentData);
}
Expand Down Expand Up @@ -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<Boolean>() {
newImage.bindVisible(new ReadOnlyBinding<>() {
@Override
public Boolean get() {
return newButton.getMode().equals(UIButton.HOVER_MODE);
Expand Down
18 changes: 6 additions & 12 deletions src/main/java/org/terasology/dialogs/DialogSystem.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2020 The Terasology Foundation
// Copyright 2021 The Terasology Foundation
// SPDX-License-Identifier: Apache-2.0

package org.terasology.dialogs;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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<String, String> mappings = new HashMap<String, String>();
private TemplateEngine templateEngine = new TemplateEngineImpl(id -> {
String result = mappings.get(id);
if (result != null) {
return result;
} else {
return "?" + id + "?";
}
});
private final Map<String, String> mappings = new HashMap<>();

private final TemplateEngine templateEngine = new TemplateEngineImpl(id -> mappings.getOrDefault(id, "?" + id + "?"));

@Override
public void initialise() {
Expand Down
26 changes: 3 additions & 23 deletions src/main/java/org/terasology/dialogs/ShowDialogEvent.java
Original file line number Diff line number Diff line change
@@ -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

Check warning on line 17 in src/main/java/org/terasology/dialogs/ShowDialogEvent.java

View check run for this annotation

Terasology Jenkins.io / JavaDoc

-

NORMAL: no description for @param
*/
Expand All @@ -38,9 +21,6 @@ public ShowDialogEvent(EntityRef talkTo, String page) {
this.page = page;
}

/**
* @return
*/
public DialogComponent getDialog() {
return talkTo.getComponent(DialogComponent.class);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -24,7 +11,7 @@
*/
public class ChangeDialogAction implements PlayerAction {

private String prefab;
private final String prefab;

public ChangeDialogAction(String prefab) {
this.prefab = prefab;
Expand Down
17 changes: 2 additions & 15 deletions src/main/java/org/terasology/dialogs/action/CloseDialogAction.java
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
28 changes: 3 additions & 25 deletions src/main/java/org/terasology/dialogs/action/NewDialogAction.java
Original file line number Diff line number Diff line change
@@ -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;
}
Expand All @@ -38,9 +19,6 @@ public void execute(EntityRef charEntity, EntityRef talkTo) {
charEntity.send(new ShowDialogEvent(talkTo, target));
}

/**
* @return
*/
public String getTarget() {
return target;
}
Expand Down
17 changes: 2 additions & 15 deletions src/main/java/org/terasology/dialogs/action/PlayerAction.java
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;

/**

Check warning on line 11 in src/main/java/org/terasology/dialogs/components/DialogResponse.java

View check run for this annotation

Terasology Jenkins.io / CheckStyle

RegexpMultilineCheck

NORMAL: Empty JavaDoc
Raw output
<p>Since Checkstyle 5.0</p><p> A check for detecting that matches across multiple lines. Works with any file type. </p><p> Rationale: This check can be used to when the regular expression can be span multiple lines. </p>
*
*/
Expand Down
19 changes: 3 additions & 16 deletions src/main/java/org/terasology/notify/NotificationSystem.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Loading

0 comments on commit d510447

Please sign in to comment.