Skip to content

Commit

Permalink
V0.6 Update
Browse files Browse the repository at this point in the history
Bug fixes and code refinement
  • Loading branch information
Sunnnix committed Jul 21, 2024
1 parent 0c1c462 commit 849d13e
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 46 deletions.
44 changes: 31 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,31 @@ This game engine was developed to create and play role-playing games with jump-n
The engine is currently still at an early stage, which means that essential functions may still be missing.
A rough overview of the available features can be found in the table below.

To download and try out the editor/engine, you can download it from this website: [Download](https://sunnix.de/downloads).
To download and try out the editor/engine, you can download it from this [repo](https://github.com/Sunnnix/Sunnixs_RPG_Engine/releases/tag/V0.6) or from this website: [Download](https://sunnix.de/downloads).

> [!NOTE]
> The engine does not contain any graphics, music, or sounds; you have to add them yourself!
## Patch Notes

<details>
<summary>V0.6</summary>

- Objects with events and components
- Events
- Move
- Wait
- Message
- Play Sound
- Components
- Render
- Event controlled textbox
- Object animation V1
- Audio System for playing Sounds
- Object states

</details>

<details>
<summary>V0.5</summary>

Expand Down Expand Up @@ -62,23 +80,23 @@ To download and try out the editor/engine, you can download it from this website

## Supported Features

| Description | Since |
|---------------------------------|---------|
| Set BGM from Map | 0.4 |
| Editor multi-language support | 0.4 |
| Load custom tilesets | 0.3 |
| Create 3D maps with walls | 0.2 |
| Start the game from the editor | 0.1 |
| Description | Since |
|------------------------------------------|-------|
| Audio System V2 (playable Sounds) | 0.6 |
| Sprite animation | 0.6 |
| Dynamic Object properties via Components | 0.6 |
| Object control via Events | 0.6 |
| Objects | 0.6 |
| Audio System V1 (only BGM) | 0.4 |
| Editor multi-language support | 0.4 |
| Load custom tilesets | 0.3 |
| Create 3D maps with walls | 0.2 |
| Start the game from the editor | 0.1 |

## Upcoming Features

| Description | Planned | Progress | Priority |
|-------------------------------------------------------|---------|----------|----------|
| Objects with events and components | 0.6 | 90% | High |
| Event controlled textbox | 0.6 | 100% | High |
| Object animation V1 | 0.6 | 100% | High |
| Audio System for playing Sounds | 0.6 | 100% | High |
| Object states | 0.6 | 100% | High |
| Tile animation | 0.7 | 0% | Medium |
| Physics System | 0.7 | 0% | High |
| Map Transition System / Teleporter objects and events | 0.7 | 0% | High |
Expand Down
19 changes: 19 additions & 0 deletions editor/res/de/sunnix/srpge/editor/lang/en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ view.dialog_resources.audio.default_value=Default Volume:
# States View
view.dialog_resources.variables.states.id=ID
view.dialog_resources.variables.states.prio=Priority
view.dialog_resources.variables.states.add_state=Add State
view.dialog_resources.variables.states.remove_state=Remove State

# Dialog Language
dialog.language.reload_editor.text=The new Language Pack has been loaded and is now being used. However, in order to update all texts, you need to restart the editor.
Expand All @@ -268,13 +270,30 @@ dialog.language.no_lang_selected=No Language Pack selected!
dialog.language.lang_not_found=Language Pack not found!
dialog.language.en_fallback=Use English if translation is missing

# Dialog Player
dialog.player.sprite.title=Edit player sprites

# Dialog Objects
dialog_object.title=Edit Object
dialog_object.add_event=Add Event
dialog_object.edit_event=Edit Event
dialog_object.remove_event=Remove Event
dialog_object.remove_component.text=Are you sure you want to delete this component?\nAll settings for this component will be lost
dialog_object.remove_component.title=Delete component
dialog_object.add_component=+ Add Component

# Components
component.render =Renderer
component.render.set_sprite=Set Sprite
component.render.set_state_sprite=Set State Sprites
component.render.state_dialog=State Sprite Editor
component.render.state_dialog.add=Add State
component.render.state_dialog.remove=Remove State
component.render.state_dialog.no_state=No state availible!
component.render.state_dialog.title=States
component.render.state_dialog.select=Select state
component.render.state_dialog.select_sprite.title=Select Sprite
component.render.state_dialog.select_sprite.text=Select Sprite for State:

# Events
event_dialog.edit=Edit %s
Expand Down
1 change: 1 addition & 0 deletions editor/src/de/sunnix/srpge/editor/window/Window.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public class Window extends JFrame {
private boolean showGrid = true;

@Getter
@Setter
private GameObject player;

public Window(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,19 @@
import java.awt.event.WindowListener;

import static de.sunnix.srpge.editor.lang.Language.getString;
import static de.sunnix.srpge.editor.lang.Language.removeLanguagePack;

public class PlayerSpriteManager extends JDialog {

private boolean loopShouldStop;

public PlayerSpriteManager(Window window){
super(window, "Edit player sprites", true);
var mainPanel = new JPanel(new BorderLayout(0, 5));
super(window, getString("dialog.player.sprite.title"), true);
var mainPanel = new JPanel(new BorderLayout(0, 10));
mainPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
setContentPane(mainPanel);

var player = window.getPlayer();
var component = player.getComponent(RenderComponent.class);
var component = player.getComponent(RenderComponent.class).clone();
var centerPanel = new JPanel();
centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.Y_AXIS));
centerPanel.setPreferredSize(new Dimension(180, 250));
Expand All @@ -33,7 +32,8 @@ public PlayerSpriteManager(Window window){
var loop = new Thread(() -> {
while(!loopShouldStop){
try {
loopFunction.run();
if(loopFunction != null)
loopFunction.run();
Thread.sleep(16, 666666);
} catch (InterruptedException e) {
throw new RuntimeException(e);
Expand All @@ -43,6 +43,24 @@ public PlayerSpriteManager(Window window){
loop.setDaemon(true);
loop.start();


var buttonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 0));

var btnApply = new JButton(getString("button.apply"));
btnApply.addActionListener(l -> {
player.getComponents().removeIf(c -> c.ID.equals(component.ID));
player.getComponents().add(component);
window.setProjectChanged();
dispose();
});
var btnCancel = new JButton(getString("button.cancel"));
btnCancel.addActionListener(l -> dispose());

buttonsPanel.add(btnApply);
buttonsPanel.add(btnCancel);

mainPanel.add(buttonsPanel, BorderLayout.SOUTH);

addWindowListener(creatwWindowListener());

setResizable(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private JPanel genTexturePanel(){
setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
public void mousePressed(MouseEvent e) {
var sprite = getCurrentSprite();
if(sprite == null)
return;
Expand Down Expand Up @@ -115,6 +115,7 @@ public void mouseClicked(MouseEvent e) {
mY /= spriteHeight;

sprite.getPattern(direction.getSelectedIndex()).add(mX + mY * texture.getWidth());
window.setProjectChanged();
direction.setSelectedIndex(direction.getSelectedIndex()); // reload list
}
});
Expand Down Expand Up @@ -185,6 +186,7 @@ private JPanel genProperties(){
var split = name.split("/");
c.setSelectedItem(split[0]);
});
addAL(imageCategory, l -> window.setProjectChanged());
pPanel.add(imageCategory, gbc);
gbc.gridy++;
imageResource = createPropertieComp(boxes[1], (c, s) -> {
Expand Down Expand Up @@ -238,7 +240,10 @@ private JPanel genProperties(){
var sprite = getCurrentSprite();
if (sprite == null)
return;
sprite.setDirectionType((Sprite.DirectionType) directionType.getSelectedItem());
if(!sprite.getDirectionType().equals(directionType.getSelectedItem())) {
sprite.setDirectionType((Sprite.DirectionType) directionType.getSelectedItem());
window.setProjectChanged();
}
reloadSprite();
});
animPanel.add(directionType, gbc2);
Expand All @@ -256,7 +261,10 @@ private JPanel genProperties(){
var sprite = getCurrentSprite();
if (sprite == null)
return;
sprite.setAnimationType((Sprite.AnimationType) animType.getSelectedItem());
if(!sprite.getAnimationType().equals(animType.getSelectedItem())) {
sprite.setAnimationType((Sprite.AnimationType) animType.getSelectedItem());
window.setProjectChanged();
}
reloadSprite();
});
animPanel.add(animType, gbc2);
Expand Down Expand Up @@ -296,6 +304,7 @@ public void keyPressed(KeyEvent e) {
return;
sprite.getPattern(direction.getSelectedIndex()).remove(index);
spriteListModel.remove(index);
window.setProjectChanged();
spriteList.setSelectedIndex(index - (spriteListModel.getSize() > index ? 0 : 1));
}
case KeyEvent.VK_UP -> {
Expand All @@ -309,6 +318,7 @@ public void keyPressed(KeyEvent e) {
pattern.add(index - 1, tex);
spriteListModel.remove(index);
spriteListModel.add(index - 1, tex);
window.setProjectChanged();
spriteList.setSelectedIndex(index - 1);
e.consume();
}
Expand All @@ -323,6 +333,7 @@ public void keyPressed(KeyEvent e) {
pattern.add(index + 1, tex);
spriteListModel.remove(index);
spriteListModel.add(index + 1, tex);
window.setProjectChanged();
spriteList.setSelectedIndex(index + 1);
e.consume();
}
Expand Down Expand Up @@ -354,8 +365,6 @@ public void keyPressed(KeyEvent e) {
pPanel.add(showIndex, gbc);
gbc.gridy++;

// pPanel.add(new JLabel(getString("view.dialog_resources.sprite.animation_delay")), gbc);
// gbc.gridy++;
animSpeed = createPropertieComp(new NumberPicker(getString("view.dialog_resources.sprite.animation_speed"), 1, 0, 1, Integer.MAX_VALUE), (c, s) -> {
if(s == null) {
animSpeed.setValue(1, true);
Expand All @@ -368,13 +377,14 @@ public void keyPressed(KeyEvent e) {
if(sprite == null)
return;
sprite.setAnimationSpeed(animSpeed.getValue());
window.setProjectChanged();
});
pPanel.add(animSpeed, gbc);
gbc.gridy++;

var mPanel = new JPanel(new BorderLayout());
var mPanel = new JPanel(new FlowLayout());
mPanel.setPreferredSize(new Dimension(200, 0));
mPanel.add(pPanel, BorderLayout.NORTH);
mPanel.add(pPanel);
var scroll = new JScrollPane(mPanel);
scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@

public class StatesView extends JPanel {

private Window window;

public StatesView(Window window, JPanel parent) {
this.window = window;
setLayout(new BorderLayout());

add(new JScrollPane(createTable()), BorderLayout.CENTER);
Expand Down Expand Up @@ -63,14 +66,18 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole
// sorter.toggleSortOrder(1);

var popupMenu = new JPopupMenu();
var addItem = new JMenuItem("Add State");
var removeItem = new JMenuItem("Remove State");
var addItem = new JMenuItem(getString("view.dialog_resources.variables.states.add_state"));
var removeItem = new JMenuItem(getString("view.dialog_resources.variables.states.remove_state"));

addItem.addActionListener(e -> ((TableModel) table.getModel()).addNewState());
addItem.addActionListener(e -> {
((TableModel) table.getModel()).addNewState();
window.setProjectChanged();
});
removeItem.addActionListener(e -> {
int row = table.getSelectedRow();
if (row != -1) {
((TableModel) table.getModel()).removeState(row);
window.setProjectChanged();
}
});

Expand Down Expand Up @@ -148,9 +155,9 @@ public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
var id = (String) aValue;
if(id.equals(state.id()) || id.isBlank() || states.stream().anyMatch(x -> id.equals(x.id())))
yield state;
yield States.changeStateId(state, id);
yield States.changeStateId(window, state, id);
}
case 1 -> States.changeStatePrio(state, Integer.parseInt((String) aValue));
case 1 -> States.changeStatePrio(window, state, Integer.parseInt((String) aValue));
default -> state;
});
fireTableDataChanged();
Expand All @@ -167,7 +174,7 @@ public void addNewState() {

public void removeState(int row){
var value = (String) getValueAt(row, 0);
states.remove(States.removeState(value));
states.remove(States.removeState(window, value));
fireTableDataChanged();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private JComponent createComponentPanel(){
componentList = new ArrayList<>(object.getComponents().stream().map(Component::clone).toList());
componentsView = panel;

var addbtn = new JButton("+ Add Component");
var addbtn = new JButton(getString("dialog_object.add_component"));
addbtn.setMaximumSize(new Dimension(Integer.MAX_VALUE, addbtn.getMinimumSize().height));
addbtn.addActionListener(a -> {
var component = ComponentCreateDialog.show(this, object);
Expand Down
18 changes: 15 additions & 3 deletions editor/src/de/sunnix/srpge/editor/window/object/States.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.sunnix.srpge.editor.window.object;

import de.sunnix.sdso.DataSaveObject;
import de.sunnix.srpge.editor.window.Window;
import de.sunnix.srpge.engine.ecs.State;

import java.util.ArrayList;
Expand Down Expand Up @@ -53,17 +54,26 @@ public static DataSaveObject save(DataSaveObject dso){
return dso;
}

public static State changeStateId(State state, String newID) {
public static State changeStateId(Window window, State state, String newID) {
newID = newID.toLowerCase();
if(state.id().equals(newID))
return state;
states.remove(state.id());
var newState = new State(newID, state.priority());
states.put(newID, newState);
if(window != null)
window.setProjectChanged();
return newState;
}

public static State changeStatePrio(State state, int newPrio) {
public static State changeStatePrio(Window window, State state, int newPrio) {
var curState = states.get(state.id());
if(curState != null && curState.priority() == newPrio)
return state;
var newState = new State(state.id(), newPrio);
states.put(state.id(), newState);
if(window != null)
window.setProjectChanged();
return newState;
}

Expand All @@ -72,10 +82,12 @@ public static boolean hasStateID(String id) {
return states.containsKey(id);
}

public static State removeState(String id) {
public static State removeState(Window window, String id) {
id = id.toLowerCase();
if(!isRemovable(id))
throw new RuntimeException("State " + id + " can't be removed!");
if(window != null)
window.setProjectChanged();
return states.remove(id);
}
}
Loading

0 comments on commit 849d13e

Please sign in to comment.