Skip to content

Commit

Permalink
Cleaning up menu bar
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaskelly committed Apr 8, 2020
1 parent 3bd6d07 commit ed4aafa
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 17 deletions.
14 changes: 11 additions & 3 deletions DelvEdit/src/com/interrupt/dungeoneer/editor/Editor.java
Expand Up @@ -125,6 +125,8 @@ public void windowClosing(WindowEvent e) {

editorOptions = EditorOptions.fromLocalFiles();
initActions();

setTitle("New Level");
}

private void initActions() {
Expand Down Expand Up @@ -197,7 +199,7 @@ public boolean result(boolean success, FileHandle result) {
currentDirectory = result.file().getParent() + "/";
currentFileName = result.name();

Scene2dMenuBar.setTitleLabel(currentFileName);
setTitle(currentFileName);
}
catch(Exception ex) {
Gdx.app.error("DelvEdit", ex.getMessage());
Expand Down Expand Up @@ -525,7 +527,7 @@ public void actionPerformed(ActionEvent actionEvent) {
public void createdNewLevel() {
currentDirectory = null;
currentFileName = null;
Scene2dMenuBar.setTitleLabel("New Level");
setTitle("New Level");
}

public void openLevel(FileHandle fileHandle) {
Expand All @@ -534,14 +536,16 @@ public void openLevel(FileHandle fileHandle) {
currentFileName = fileHandle.name();
saveMessageTimer.cancel();

setTitle(currentFileName);

String file = currentFileName;
String dir = currentDirectory;

FileHandle level = Gdx.files.getFileHandle(fileHandle.file().getAbsolutePath(), FileType.Absolute);
if(level.exists()) {
editorFrame.curFileName = level.path();

Scene2dMenuBar.setTitleLabel(currentFileName);
setTitle(currentFileName);

if(file.endsWith(".png")) {
String heightFile = dir + file.replace(".png", "-height.png");
Expand Down Expand Up @@ -598,4 +602,8 @@ else if(file.endsWith(".bin")) {
public void dispose() {
EditorOptions.toLocalFiles(editorOptions);
}

public void setTitle(String title) {
Gdx.graphics.setTitle(title + " — DelvEdit");
}
}
12 changes: 12 additions & 0 deletions DelvEdit/src/com/interrupt/dungeoneer/editor/ui/EditorUi.java
Expand Up @@ -11,6 +11,7 @@
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.*;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.viewport.FillViewport;
Expand Down Expand Up @@ -409,6 +410,15 @@ public void actionPerformed(ActionEvent e) {

menuBar.pack();

menuBar.playButton.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
if (event.getType().name().equals("touchUp")) {
editorFrame.testLevel();
}
};
});

mainTable.setZIndex(1000);
mainTable.add(menuBar);

Expand Down Expand Up @@ -513,6 +523,8 @@ public void resize(float width, float height) {
viewport.setWorldSize(width, height);
viewport.update((int)width, (int)height, true);

menuBar.refresh();

mainTable.pack();

if(entityPropertiesPane != null && propertiesMenu != null) {
Expand Down
Expand Up @@ -109,6 +109,10 @@ public void pack() {
}
}

public void refresh() {
refreshDrawables();
}

protected void refreshDrawables() {
clearChildren();

Expand Down
@@ -1,19 +1,17 @@
package com.interrupt.dungeoneer.editor.ui.menu;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.*;
import com.badlogic.gdx.utils.Align;

public class Scene2dMenuBar extends Scene2dMenu {

private static Label titleLabel = null;
public static Button playButton = null;

public Scene2dMenuBar(Skin skin) {
super(skin);
titleLabel = new Label("New Level", skin);
playButton = new Button(skin);
playButton.add(new Image(skin, "menu-arrow")).size(10);
}

@Override
Expand Down Expand Up @@ -56,18 +54,18 @@ protected void refreshDrawables() {
menuTable.setSkin(skin);
addActor(menuTable);

menuTable.add().width(6f);
float r = 0;

// add the rows
for(Actor a : items) {
menuTable.add(a).align(Align.left).fill();
r = a.getRight();
}

menuTable.add(titleLabel).padLeft(50).width(400f).fill();
titleLabel.setColor(Color.GRAY);
menuTable.add().width(getParent().getWidth() - 40 - r);
menuTable.add(playButton).width(30).height(30).align(Align.right).padTop(3).padRight(10).fill();

menuTable.setBackground("menu_default_normal");
menuTable.add().width(4000f).fill();

// add all of the sub menus to this space
for(Actor a : items) {
Expand All @@ -84,8 +82,4 @@ protected void refreshDrawables() {

menuTable.pack();
}

public static void setTitleLabel(String title) {
titleLabel.setText(title);
}
}

0 comments on commit ed4aafa

Please sign in to comment.