Skip to content

Commit

Permalink
Removed GmObjectInfoFrame and refactored preferences to allow loading…
Browse files Browse the repository at this point in the history
… libraries

and other things.
  • Loading branch information
RobertBColton committed Jun 6, 2013
1 parent 1415e06 commit 4d271fb
Show file tree
Hide file tree
Showing 22 changed files with 263 additions and 501 deletions.
5 changes: 3 additions & 2 deletions description.jardesc
Expand Up @@ -11,6 +11,7 @@
</sealing>
</manifest>
<selectedElements exportClassFiles="true" exportJavaFiles="true" exportOutputFolder="false">
<javaElement handleIdentifier="=LateralGM/&lt;org.lateralgm.resources.library.libs"/>
<javaElement handleIdentifier="=LateralGM/&lt;org.lateralgm.resources"/>
<javaElement handleIdentifier="=LateralGM/&lt;org.lateralgm.components"/>
<javaElement handleIdentifier="=LateralGM/&lt;org.lateralgm.icons.Calico.restree"/>
Expand All @@ -19,7 +20,7 @@
<javaElement handleIdentifier="=LateralGM/&lt;org.lateralgm.components.visual"/>
<javaElement handleIdentifier="=LateralGM/&lt;org.lateralgm.compare"/>
<javaElement handleIdentifier="=LateralGM/&lt;org.lateralgm.resources.sub"/>
<file path="/LateralGM/lgm1.png"/>
<javaElement handleIdentifier="=LateralGM/&lt;org.lateralgm.resources.library.libs.logic"/>
<javaElement handleIdentifier="=LateralGM/&lt;org.lateralgm.components.mdi"/>
<javaElement handleIdentifier="=LateralGM/&lt;org.lateralgm.file.iconio"/>
<javaElement handleIdentifier="=LateralGM/&lt;org.lateralgm.icons.Swing.actions"/>
Expand All @@ -36,10 +37,10 @@
<javaElement handleIdentifier="=LateralGM/&lt;org.lateralgm.icons.Calico.actions"/>
<javaElement handleIdentifier="=LateralGM/&lt;org.lateralgm.main"/>
<javaElement handleIdentifier="=LateralGM/&lt;org.lateralgm.icons"/>
<javaElement handleIdentifier="=LateralGM/&lt;org.lateralgm.resources.library.lib"/>
<javaElement handleIdentifier="=LateralGM/&lt;org.lateralgm.ui.swing.propertylink"/>
<javaElement handleIdentifier="=LateralGM/&lt;org.lateralgm.joshedit"/>
<javaElement handleIdentifier="=LateralGM/&lt;org.lateralgm.jedit"/>
<folder path="/LateralGM/META-INF"/>
<javaElement handleIdentifier="=LateralGM/&lt;org.lateralgm.resources.library.libs.standard"/>
</selectedElements>
</jardesc>
6 changes: 3 additions & 3 deletions org/lateralgm/file/GmFileReader.java
Expand Up @@ -738,7 +738,7 @@ private static void readScripts(GmFileContext c) throws IOException,GmFormatExce
GmStreamDecoder in = c.in;

int ver = in.read4();
if (ver != 400 && ver != 800) throw versionError(f,"BEFORE","SCR",ver); //$NON-NLS-1$ //$NON-NLS-2$
if (ver != 400 && ver != 800 && ver != 810 && ver != 820) throw versionError(f,"BEFORE","SCR",ver); //$NON-NLS-1$ //$NON-NLS-2$

int noScripts = in.read4();
for (int i = 0; i < noScripts; i++)
Expand All @@ -752,9 +752,9 @@ private static void readScripts(GmFileContext c) throws IOException,GmFormatExce
}
Script scr = f.resMap.getList(Script.class).add();
scr.setName(in.readStr());
if (ver == 800) in.skip(8); //last changed
if (ver >= 800) in.skip(8); //last changed
ver = in.read4();
if (ver != 400 && ver != 800) throw versionError(f,"IN","SCR",i,ver); //$NON-NLS-1$ //$NON-NLS-2$
if (ver != 400 && ver != 800 && ver != 810 && ver != 820) throw versionError(f,"IN","SCR",i,ver); //$NON-NLS-1$ //$NON-NLS-2$
String code = in.readStr();
scr.put(PScript.CODE,code);

Expand Down
65 changes: 35 additions & 30 deletions org/lateralgm/main/LGM.java
Expand Up @@ -24,8 +24,8 @@
package org.lateralgm.main;

import java.awt.BorderLayout;

import java.awt.Color;
import java.awt.Dialog.ModalExclusionType;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
Expand Down Expand Up @@ -70,6 +70,7 @@
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.plaf.metal.DefaultMetalTheme;
import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.tree.DefaultTreeModel;
Expand Down Expand Up @@ -99,6 +100,7 @@
import org.lateralgm.subframes.ResourceFrame;
import org.lateralgm.subframes.ResourceFrame.ResourceFrameFactory;


public final class LGM
{
public static String iconspath = "org/lateralgm/icons/";
Expand Down Expand Up @@ -142,7 +144,7 @@ public final class LGM

public static void SetLookAndFeel(String LOOKANDFEEL)
{
// MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());

if (LOOKANDFEEL.equals(themename))
{
themechanged = false;
Expand Down Expand Up @@ -173,7 +175,7 @@ else if (LOOKANDFEEL.equals("Windows"))
{
lookAndFeel = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
}
else if (LOOKANDFEEL.equals("Motif"))
else if (LOOKANDFEEL.equals("CDE/Motif"))
{
lookAndFeel = "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
}
Expand All @@ -182,7 +184,7 @@ else if (LOOKANDFEEL.equals("Metal"))
lookAndFeel = "javax.swing.plaf.metal.MetalLookAndFeel";
MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
}
else if (LOOKANDFEEL.equals("GTK"))
else if (LOOKANDFEEL.equals("GTK+"))
{
lookAndFeel = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
}
Expand All @@ -192,8 +194,20 @@ else if (LOOKANDFEEL.equals("Custom"))
}
else
{
System.err.println("Unexpected value of LOOKANDFEEL specified: " + LOOKANDFEEL);
lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
// Perhaps we did not get the name right, see if the theme is installed
// and attempt to use it.
boolean foundMatch = false;
LookAndFeelInfo lnfs[] = UIManager.getInstalledLookAndFeels();
for (int i = 0; i < lnfs.length; i++) {
if (LOOKANDFEEL.equals(lnfs[i].getName())) {
lookAndFeel = lnfs[i].getClassName();
foundMatch = true;
}
}
if (!foundMatch) {
System.err.println("Unexpected value of LOOKANDFEEL specified: " + LOOKANDFEEL);
lookAndFeel = UIManager.getCrossPlatformLookAndFeelClassName();
}
}

try
Expand Down Expand Up @@ -227,17 +241,19 @@ else if (LOOKANDFEEL.equals("Custom"))
// this function is for updating the look and feel after its
// already been initialized and all controls created
public static void UpdateLookAndFeel()
{
{
if (!themechanged)
{
return;
}
JFrame.setDefaultLookAndFeelDecorated(true);
SwingUtilities.updateComponentTreeUI(frame);
//SwingUtilities.updateComponentTreeUI(mdi);
//frame.pack();
SwingUtilities.updateComponentTreeUI(tree);
SwingUtilities.updateComponentTreeUI(mdi);
frame.pack();
Window windows[] = frame.getWindows();
}
for(Window i : windows) {
SwingUtilities.updateComponentTreeUI(i);
}
}

public static GameInformationFrame getGameInfo()
{
Expand Down Expand Up @@ -500,7 +516,7 @@ public static void reload(boolean newRoot)
LGM.getGameInfo().resOriginal = LGM.currentFile.gameInfo;
LGM.getGameInfo().revertResource();
LGM.getGameInfo().setVisible(false);

LGM.fireReloadPerformed(newRoot);
}

Expand Down Expand Up @@ -603,6 +619,11 @@ public static void main(String[] args)
if (javaVersion < 10600)
System.out.println("Some program functionality will be limited due to your outdated Java version"); //$NON-NLS-1$

iconspack = Prefs.iconPack;
SetLookAndFeel(Prefs.swingTheme);
JFrame.setDefaultLookAndFeelDecorated(true);
themechanged = false;

SplashProgress splashProgress = new SplashProgress();
splashProgress.start();

Expand All @@ -619,16 +640,9 @@ public static void main(String[] args)
}
}

splashProgress.progress(10,Messages.getString("LGM.SPLASH_THEME"));

iconspack = Prefs.iconPack;
SetLookAndFeel(Prefs.swingTheme);
splashProgress.progress(10,Messages.getString("LGM.SPLASH_LANG"));
Messages.updateLangPack();

//annoyingly, Metal bolds almost all components by default. This unbolds them.
UIManager.put("swing.boldMetal",Boolean.FALSE); //$NON-NLS-1$
themechanged = false;

splashProgress.progress(20,Messages.getString("LGM.SPLASH_LIBS")); //$NON-NLS-1$
LibManager.autoLoad();

Expand Down Expand Up @@ -658,12 +672,6 @@ public static void main(String[] args)
extSet = new ExtensionsFrame(new Extensions());
mdi.add(extSet);

// This code causes a hanging loop and you have to force shutdown
// I advise you not to mess with it
//gameInformationFrameBuilder.start(); //must occur after createMDI
//gameSettingFrameBuilder.start(); //must occur after createMDI
//extensionsFrameBuilder.start(); //must occur after createMDI

splashProgress.progress(50,Messages.getString("LGM.SPLASH_MENU")); //$NON-NLS-1$
frame = new JFrame(Messages.format("LGM.TITLE", //$NON-NLS-1$
Messages.getString("LGM.NEWGAME"))); //$NON-NLS-1$
Expand All @@ -680,9 +688,6 @@ public void windowClosing(WindowEvent winEvt)
}
});

//p.add(tree, BorderLayout.WEST);
//.add(new JButton("fuck you"));
//content.add(BorderLayout.WEST, p);
JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,true,tree,content);
split.setDividerLocation(250);
split.setOneTouchExpandable(true);
Expand Down
27 changes: 25 additions & 2 deletions org/lateralgm/main/Prefs.java
Expand Up @@ -112,8 +112,9 @@ public static void loadPrefs()
enableDragAndDrop = getBoolean("enableDragAndDrop", true);
forceMaximized = getBoolean("forceMaximized", false);
dockEventPanel = getBoolean("dockEventPanel", false);
defaultLibraryPath = getString("defaultLibraryPath","org/lateralgm/resources/library/lib/");
actionLibrary = getString("actionLibrary","Default");
userLibraryPath = getString("userLibraryPath","./lib");

eventKeyInputAddKey = KeyEvent.VK_BACK_SLASH;
actionToolTipColumns = getInt("actionToolTipColumns",30);
actionToolTipLines = getInt("actionToolTipLines",10);
Expand Down Expand Up @@ -157,7 +158,7 @@ public static void loadPrefs()

public static boolean dockEventPanel;
public static boolean enableDragAndDrop;
public static String defaultLibraryPath;
public static String actionLibrary;
public static String userLibraryPath;
public static int actionToolTipColumns;
public static int actionToolTipLines;
Expand All @@ -173,5 +174,27 @@ public static void loadPrefs()
public static String externalScriptExtension;
public static boolean useExternalSoundEditor;
public static String externalSoundEditorCommand;

public static String getActionLibraryPath()
{
String ret;
if (actionLibrary.contains("Custom")) {
ret = userLibraryPath;
} else {
ret = "org/lateralgm/resources/library/libs/";
}
return ret;
}

public static String getActionLibraryFullPath()
{
String ret;
if (actionLibrary.contains("Custom")) {
ret = userLibraryPath;
} else {
ret = "org/lateralgm/resources/library/libs/" + actionLibrary.toLowerCase();
}
return ret;
}

}
54 changes: 54 additions & 0 deletions org/lateralgm/main/PrefsStore.java
Expand Up @@ -71,6 +71,60 @@ public static void setIconPack(String s)
Prefs.iconPack = s;
}

public static void setActionLibrary(String s)
{
PREFS.put("actionLibrary",s);
Prefs.actionLibrary = s;
}

public static void setUserLibraryPath(String s)
{
PREFS.put("userLibraryPath",s);
Prefs.userLibraryPath = s;
}

public static void setSpriteExt(String s)
{
PREFS.put("externalSpriteExtension",s);
Prefs.externalSpriteExtension = s;
}

public static void setBackgroundExt(String s)
{
PREFS.put("externalBackgroundExtension",s);
Prefs.externalBackgroundExtension = s;
}

public static void setScriptExt(String s)
{
PREFS.put("externalScriptExtension",s);
Prefs.externalScriptExtension = s;
}

public static void setBackgroundEditorCommand(String s)
{
PREFS.put("externalBackgroundEditorCommand",s);
Prefs.externalBackgroundEditorCommand = s;
}

public static void setSpriteEditorCommand(String s)
{
PREFS.put("externalSpriteEditorCommand",s);
Prefs.externalSpriteEditorCommand = s;
}

public static void setScriptEditorCommand(String s)
{
PREFS.put("externalScriptEditorCommand",s);
Prefs.externalScriptEditorCommand = s;
}

public static void setSoundEditorCommand(String s)
{
PREFS.put("externalSoundEditorCommand",s);
Prefs.externalSoundEditorCommand = s;
}

public static void setIconPath(String s)
{
PREFS.put("iconPath",s);
Expand Down
2 changes: 1 addition & 1 deletion org/lateralgm/main/preferences.properties
Expand Up @@ -42,7 +42,7 @@ iconPath = icons/

#Library settings
enableDragAndDrop = true
defaultLibraryPath = org/lateralgm/resources/library/lib/
actionLibrary = Standard
userLibraryPath = ./lib
#D&D Actions in objects show a tooltip of their settings. Set these to 0 to disable.
actionToolTipColumns = 30
Expand Down
5 changes: 3 additions & 2 deletions org/lateralgm/messages/messages.properties
Expand Up @@ -264,8 +264,8 @@ LGM.KEEPCHANGES_TITLE=Unsaved Changes
LGM.KEEPCHANGES_MESSAGE=You have not saved your recent changes, would you like to do so before closing?

LGM.SPLASH_START=Calibrating Sensors
LGM.SPLASH_THEME=Brushing my little ponies
LGM.SPLASH_LIBS=Loading library files
LGM.SPLASH_THEME=Articulating Simlish
LGM.SPLASH_LIBS=Grazing the llama's
LGM.SPLASH_TOOLS=Creating Components
LGM.SPLASH_THREAD=Launching into Hyperspace
LGM.SPLASH_MENU=Initiating Menu
Expand Down Expand Up @@ -466,6 +466,7 @@ PreferencesFrame.DEFAULT=Default
PreferencesFrame.SYSTEM=System
PreferencesFrame.CUSTOM=Custom
PreferencesFrame.THEME=Theme
PreferencesFrame.ACTIONLIBRARY=Action Library
PreferencesFrame.LANGUAGE=Language
PreferencesFrame.ICONS=Icons
PreferencesFrame.FIND=Find
Expand Down
18 changes: 10 additions & 8 deletions org/lateralgm/resources/library/LibManager.java
Expand Up @@ -62,20 +62,22 @@ public static LibAction getLibAction(int libraryId, int libActionId)
*/
public static void autoLoad()
{
File defdir = new File(Prefs.defaultLibraryPath);
if (!defdir.exists())
File dir = new File(Prefs.getActionLibraryFullPath());
if (!dir.exists())
{
if (LGM.workDir == null) return;
defdir = new File(LGM.workDir,Prefs.defaultLibraryPath);
if (!defdir.exists()) defdir = LGM.workDir;
dir = new File(LGM.workDir,Prefs.getActionLibraryFullPath());
if (!dir.exists()) dir = LGM.workDir;
}

codeAction = null;

autoLoad(defdir);

if (Prefs.userLibraryPath != null && Prefs.userLibraryPath.length() != 0)
autoLoad(new File(Prefs.userLibraryPath));
if (!Prefs.actionLibrary.contains("Custom"))
autoLoad(dir);

File userLibF = new File(Prefs.userLibraryPath);
if (userLibF.exists())
autoLoad(userLibF);

if (codeAction == null) codeAction = makeCodeAction();
}
Expand Down
Binary file not shown.
Expand Up @@ -4,6 +4,6 @@ Copyright (C) 2007 Quadduc <quadduc@gmail.com>

The corresponding source for these icons is distributed under the GNU
General Public License, version 3 or later, and it is freely available from the
LateralGM repository, currently at: https://opensvn.csie.org/traccgi/LGM/
LateralGM repository, currently at: https://github.com/IsmAvatar/LateralGM
If you can not find the source code at that location, it may have been moved.
In that case, contact Quadduc at quadduc@gmail.com to get the source code.
In that case, contact Quadduc at quadduc@gmail.com or IsmAvatar to get the source code.

0 comments on commit 4d271fb

Please sign in to comment.