Skip to content
This repository has been archived by the owner on Oct 6, 2018. It is now read-only.

Commit

Permalink
Fixed some bugs with recent projects & side panel
Browse files Browse the repository at this point in the history
  • Loading branch information
MightyPork committed Jun 27, 2014
1 parent 616e273 commit 09f4844
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 16 deletions.
4 changes: 3 additions & 1 deletion src/data/changelog/388.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
- Support for streamd sounds in Sound Manager
- Support for streamed sounds in Sound Manager
- Fixed: Recent Projects menu not showing
- Added fancy tree mappings for 14w25b
2 changes: 1 addition & 1 deletion src/net/mightypork/rpw/Const.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

public class Const {

public static final int VERSION_SERIAL = 387;
public static final int VERSION_SERIAL = 388;

public static final String VERSION = VersionUtils.getVersionString(VERSION_SERIAL);
public static final int VERSION_MAJOR = VersionUtils.getVersionMajor(VERSION_SERIAL);
Expand Down
8 changes: 5 additions & 3 deletions src/net/mightypork/rpw/gui/widgets/MenuMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -781,20 +781,22 @@ public void updateRecentProjects()
{
menuRecentProjects.removeAll();

final List<String> recents = Projects.getRecentProjects();

menuRecentProjects.setEnabled(recents.size() > 1);
final List<String> recents = Projects.getRecentProjects();

final Project activeProj = Projects.getActive();
final String activeName = (activeProj == null ? "" : activeProj.getName());

JMenuItem item;
int added = 0;
for (final String s : recents) {
if (s.equalsIgnoreCase(activeName)) continue; // dont show current project in the list
menuRecentProjects.add(item = new JMenuItem(s));
item.setActionCommand(s);
item.addActionListener(openRecentProjectListener);
added++;
}

menuRecentProjects.setEnabled(added > 0);
}


Expand Down
52 changes: 41 additions & 11 deletions src/net/mightypork/rpw/gui/widgets/SidePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,42 @@ public class SidePanel {

public SidePanel()
{
panel = new JXPanel();
panel.setBorder(BorderFactory.createEmptyBorder(Gui.GAP, Gui.GAPL, Gui.GAP, Gui.GAPL));
JXPanel projectCard = new JXPanel();

// project-info card
projectCard.setBorder(BorderFactory.createEmptyBorder(Gui.GAP, Gui.GAPL, Gui.GAP, Gui.GAPL));

panel.setPreferredSize(new Dimension(320, 700));
panel.setMinimumSize(new Dimension(320, 300));
projectCard.setPreferredSize(new Dimension(320, 700));
projectCard.setMinimumSize(new Dimension(320, 300));

panel.add(infoBox = createProjectInfoBox());
projectCard.add(infoBox = createProjectInfoBox());
infoBox.setAlignmentX(0.5f);

panel.add(Box.createRigidArea(new Dimension(300, 20)));
projectCard.add(Box.createRigidArea(new Dimension(300, 20)));

panel.add(previewBox = createPreviewBox());
projectCard.add(previewBox = createPreviewBox());
previewBox.setAlignmentX(0.5f);

panel.add(Box.createVerticalGlue());
projectCard.add(Box.createVerticalGlue());

// no-project-open card
JXPanel empty = new JXPanel();
VBox vb = new VBox();

JLabel l1 = new JLabel("No project active.");
l1.setFont(l1.getFont().deriveFont(20F));

JLabel l2 = new JLabel("Use the menu to open\n or create a project.");
vb.add(l1);
vb.add(l2);

empty.add(vb);


panel = new JXPanel();
panel.setLayout(new CardLayout());
panel.add(projectCard, "project");
panel.add(empty, "empty");

addActions();

Expand All @@ -117,6 +138,13 @@ public SidePanel()
}


public void showCard(String name)
{
CardLayout cl = (CardLayout) (panel.getLayout());
cl.show(panel, name);
}


private Box createPreviewBox()
{
previewBorder = new CompoundBorder(BorderFactory.createLineBorder(new Color(0x666666)), BorderFactory.createEmptyBorder(5, 5, 5, 5));
Expand Down Expand Up @@ -400,6 +428,7 @@ public void updateProjectInfo()
final Project p = Projects.getActive();

if (p != null) {
showCard("project");
String name = p.getTitle();
final int length_name = (panel.getWidth() - 75) / 11;
name = Utils.cropStringAtEnd(name, length_name);
Expand All @@ -414,9 +443,10 @@ public void updateProjectInfo()
infoBox.setVisible(true);

} else {
infoBox.setVisible(false);
previewBox.setVisible(false);
updatePreview(null);
showCard("empty");
// infoBox.setVisible(false);
// previewBox.setVisible(false);
// updatePreview(null);
}
}

Expand Down
9 changes: 9 additions & 0 deletions src/net/mightypork/rpw/project/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,19 @@ public void setSourceForFile(String fileKey, String source)
}


/**
* @param title visual project title
*/
public void setTitle(String title)
{
projectTitle = title;
Projects.markChange();
}


/**
* @return visual project title
*/
public String getTitle()
{
return projectTitle;
Expand Down Expand Up @@ -425,6 +431,9 @@ public File getCustomLangDirectory()
}


/**
* @return project name (save directory name)
*/
public String getName()
{
return projectName;
Expand Down

0 comments on commit 09f4844

Please sign in to comment.