From: <sv...@ww...> - 2008-02-03 09:22:44
|
Author: nsmoooose Date: 2008-02-03 01:22:36 -0800 (Sun, 03 Feb 2008) New Revision: 2213 Added: branches/layout_tool_improvements/csp/tools/layout2/images/splash.png branches/layout_tool_improvements/csp/tools/layout2/scripts/ui/SelectDataDirectoryDialog.py Modified: branches/layout_tool_improvements/csp/tools/layout2/scripts/ui/LayoutApplication.py Log: Added a splash window to the layout tool. The splash window will also force you to select a valid data directory. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=2213 Added: branches/layout_tool_improvements/csp/tools/layout2/images/splash.png =================================================================== (Binary files differ) Property changes on: branches/layout_tool_improvements/csp/tools/layout2/images/splash.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: branches/layout_tool_improvements/csp/tools/layout2/scripts/ui/LayoutApplication.py =================================================================== --- branches/layout_tool_improvements/csp/tools/layout2/scripts/ui/LayoutApplication.py 2008-01-31 07:44:18 UTC (rev 2212) +++ branches/layout_tool_improvements/csp/tools/layout2/scripts/ui/LayoutApplication.py 2008-02-03 09:22:36 UTC (rev 2213) @@ -6,6 +6,7 @@ from csp.tools.layout2.layout_module import * from MainFrame import MainFrame +from SelectDataDirectoryDialog import SelectDataDirectoryDialog class LayoutApplication(wx.App): # wxWindows calls this method to initialize the application @@ -25,28 +26,26 @@ self.Configuration = shelve.open('.csplayout') - defaultDataDirectory = self.Configuration.get('LayoutApplication.DataDirectory', '.') - directoryBrowser = wx.DirDialog(None, 'Select the data directory for your csp application', defaultDataDirectory) - if directoryBrowser.ShowModal() != wx.ID_OK: - return False - dataDirectory = directoryBrowser.GetPath() - self.Configuration['LayoutApplication.DataDirectory'] = dataDirectory - self.Configuration['LayoutApplication.XmlPath'] = os.path.join(dataDirectory, 'xml') + dlg = SelectDataDirectoryDialog(None, wx.ID_ANY, "CSP Theater Layout Tool") + if dlg.ShowModal() == wx.ID_OK: - datadirs = ('images', 'models', 'fonts', 'sounds') - pathlist = os.pathsep.join([os.path.join(dataDirectory, subdir) for subdir in datadirs]) - CspLayoutApplication.setOpenSceneGraphPathList(pathlist.encode('utf8')) - shaderPath = os.path.join(dataDirectory, 'shaders').encode('utf8') - CspLayoutApplication.setShaderPath(shaderPath) + dataDirectory = self.Configuration.get('LayoutApplication.DataDirectory', '.') + datadirs = ('images', 'models', 'fonts', 'sounds') + pathlist = os.pathsep.join([os.path.join(dataDirectory, subdir) for subdir in datadirs]) + CspLayoutApplication.setOpenSceneGraphPathList(pathlist.encode('utf8')) + shaderPath = os.path.join(dataDirectory, 'shaders').encode('utf8') + CspLayoutApplication.setShaderPath(shaderPath) - # Create an instance of our customized Frame class - frame = MainFrame(None, wx.ID_ANY, "CSP Theater Layout Tool") - frame.SetSize(wx.Size(800, 600)) - frame.Show(True) + # Create an instance of our customized Frame class + frame = MainFrame(None, wx.ID_ANY, "CSP Theater Layout Tool") + frame.SetSize(wx.Size(800, 600)) + frame.Show(True) - # Tell wxWindows that this is our main window - self.SetTopWindow(frame) + # Tell wxWindows that this is our main window + self.SetTopWindow(frame) - # Return a success flag - return True + # Return a success flag + return True + else: + return False Added: branches/layout_tool_improvements/csp/tools/layout2/scripts/ui/SelectDataDirectoryDialog.py =================================================================== --- branches/layout_tool_improvements/csp/tools/layout2/scripts/ui/SelectDataDirectoryDialog.py (rev 0) +++ branches/layout_tool_improvements/csp/tools/layout2/scripts/ui/SelectDataDirectoryDialog.py 2008-02-03 09:22:36 UTC (rev 2213) @@ -0,0 +1,95 @@ +#!/usr/bin/env python +import wx +import os + +class SelectDataDirectoryDialog(wx.Dialog): + """A dialog to be used to display a splash window for + this layout tool. You must also select a valid data + directory for this application to work with. After + you press OK the main frame is loaded and you can begin + to edit your layout of CSP.""" + + def __init__(self, parent, id, title): + wx.Dialog.__init__(self, parent, id, title, style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER) + + horizontalSizer = wx.BoxSizer(wx.HORIZONTAL) + + bitmap = wx.Bitmap(os.path.join('images', 'splash.png')) + bitmapControl = wx.StaticBitmap(self, wx.ID_ANY, bitmap) + horizontalSizer.Add(bitmapControl, flag=wx.RIGHT, border=10) + + rightPanel = wx.Panel(self, wx.ID_ANY) + horizontalSizer.Add(rightPanel, flag=wx.TOP|wx.BOTTOM|wx.RIGHT|wx.EXPAND, border=10, proportion=1) + + verticalSizer = wx.BoxSizer(wx.VERTICAL) + cspLabel = wx.StaticText(rightPanel, wx.ID_ANY, 'Combat Simulator Project') + verticalSizer.Add(cspLabel) + + infoLabel = wx.StaticText(rightPanel, wx.ID_ANY, 'Select the data directory of your CSP installation.') + verticalSizer.Add(infoLabel) + + + directoryLabel = wx.StaticText(rightPanel, wx.ID_ANY, 'Directory:') + verticalSizer.Add(directoryLabel, border=5, flag=wx.TOP) + + directoryPanel = wx.Panel(rightPanel, wx.ID_ANY) + directoryText = wx.TextCtrl(directoryPanel, wx.ID_ANY, '') + directoryText.SetMinSize(wx.Size(300, directoryText.GetSize().GetHeight())) + browseDirectoryButton = wx.Button(directoryPanel, 6666, '...', size=wx.Size(20,20)) + directorySizer = wx.BoxSizer(wx.HORIZONTAL) + directorySizer.Add(directoryText, flag=wx.RIGHT, border=5) + directorySizer.Add(browseDirectoryButton, flag=wx.ALIGN_RIGHT) + directoryPanel.SetSizer(directorySizer) + verticalSizer.Add(directoryPanel, flag=wx.EXPAND, proportion=1) + + verticalSizer.AddStretchSpacer() + + buttonPanel = wx.Panel(rightPanel, wx.ID_ANY) + okButton = wx.Button(buttonPanel, wx.ID_OK, 'OK') + cancelButton = wx.Button(buttonPanel, wx.ID_CANCEL, 'Cancel') + buttonSizer = wx.BoxSizer(wx.HORIZONTAL) + buttonSizer.Add(okButton, border=5, flag=wx.RIGHT) + buttonSizer.Add(cancelButton) + buttonPanel.SetSizer(buttonSizer) + verticalSizer.Add(buttonPanel, border=5, flag=wx.TOP) + + rightPanel.SetSizer(verticalSizer) + + # Force the window to resize itself according to its content. + horizontalSizer.SetSizeHints(self) + + self.SetSizer(horizontalSizer) + + # Store a reference to the text control containing + # the selected directory. + self.directoryText = directoryText + application = wx.GetApp() + self.directoryText.SetValue(application.Configuration.get('LayoutApplication.DataDirectory', '.')) + + # Bind events to buttons + wx.EVT_BUTTON(self, wx.ID_OK, self.okButton_Click) + wx.EVT_BUTTON(self, 6666, self.browseDirectoryButton_Click) + + okButton.SetFocus() + + self.SetWindowStyle(wx.DEFAULT_DIALOG_STYLE) + + def browseDirectoryButton_Click(self, event): + # Use the current value in the text box. This will + # be the default directory in the directory browser. + defaultDataDirectory = self.directoryText.GetValue() + + # Show the directory browser. + directoryBrowser = wx.DirDialog(None, 'Select the data directory for your csp application', defaultDataDirectory) + if directoryBrowser.ShowModal() != wx.ID_OK: + return False + + # Set the choosen directory into the text box. + self.directoryText.SetValue(directoryBrowser.GetPath()) + + def okButton_Click(self, event): + dataDirectory = self.directoryText.GetValue() + application = wx.GetApp() + application.Configuration['LayoutApplication.DataDirectory'] = dataDirectory + application.Configuration['LayoutApplication.XmlPath'] = os.path.join(dataDirectory, 'xml') + self.EndModal(wx.ID_OK) \ No newline at end of file |