Page 1 of 2

AppLauncher

Posted: 23 Sep 2008, 18:39
by Pxtl
I didn't want to litter Argh's thread with this, since it's a huge post.

I've finished a skinnable version of AppLauncher at lunch today. AppLauncher is handy for modders who want to make a list of buttons to click that launch various command-line programs like spring single-player missions, settings.exe, and so on. It's a .NET 2.0 app that should be useful for really any such purpose. Theoretically it could be ported to Linux, but I haven't tested it and you'd probably have to mangle your command-line commands for the other platform. I've the project source attached, it's MIT license so do whatever you like with it.

See the included AppLauncherConfig.XML file to customize it.

Below is a snipped of the configuration objects code. It's a little confusing if you can't read VB.Net, but all that's really important is the types (ie. Boolean/String/Integer), names (ie. Text, WaitForExit), and comments (starts with '). All the fields become XML Tags except for the ButtonList, which becomes the XML elements of the member. The ButtonXMLList object is a base class of both the ConfigRootXML and the ButtonXML objects, so its members appear in both. If this doesn't make one lick of sense, don't sweat it - read the sample AppLauncherConfig.Xml file and use this code below as reference information about the words you see in there.

Code: Select all

Imports System.Xml.Serialization
Imports System.ComponentModel

'Base class for button and root object.  These members exist at both the root and the button level.
Public Class ButtonXMLList
    'Path to the image at the header - size 384*128
    <XmlAttribute()> _
    Public HeaderImageTarget As String

    'Path to the image at the bottom - size 384*32
    <XmlAttribute()> _
    Public FooterImageTarget As String

    'Text to write into the footer.  Will be rendered in black.
    <XmlAttribute()> _
    Public FooterText As String

    'Path to the image in behind the button list.  Width is 384, height is form height - 160
    <XmlAttribute()> _
    Public ListBackgroundImageTarget As String

    'Text on button to leave page of form (or quit if root page) - invisible if image.
    <XmlAttribute()> _
    Public ExitText As String

    'Tool tip text for button to leave page of form (or quit if root page)
    <XmlAttribute()> _
    Public ExitToolTipText As String

    'Path to image on page-exit button - 256*32.
    <XmlAttribute()> _
    Public ExitIdleImageTarget As String

    'Path to image on page-exit button when clicked - 256*32.
    <XmlAttribute()> _
    Public ExitClickedImageTarget As String

    'List of child buttons.
    <XmlElement("Button")> _
    Public ButtonList As List(Of ButtonXML)
End Class

Code: Select all

Imports System.Xml.Serialization
Imports System.ComponentModel

'Root object of the XML file, listed as AppLauncherConfigRoot in the file.
<XmlRoot("AppLauncherConfigRoot", Namespace:="http://pxtl.livejournal.com")> _
Public Class ConfigRootXML
    Inherits ButtonXMLList

    'Title bar of the form.  Will be used task bar.
    <XmlAttribute()> _
    Public TitleText As String

    'Icon of the form.  Will be used in task bar.  Should be exe, ico, or dll file.
    <XmlAttribute()> _
    Public IconTarget As String

    'Whether or not the list panel should have a border.  Show border if true.
    <XmlAttribute()> _
    <DefaultValue(True)> _
    Public ListPanelBorder As Boolean = True

    'Whether or not the form itself should have a border/titlebar/icon.  Show border if true.  Will not show icon in taskbar if false.
    <XmlAttribute()> _
    <DefaultValue(True)> _
    Public FormBorder As Boolean = True

    'Height of form.
    <XmlAttribute()> _
    Public FormHeight As Integer
End Class

Code: Select all

Imports System.Xml.Serialization
Imports System.ComponentModel

'A button in the AppLauncherConfig xml file.
<XmlType("Button", Namespace:="http://pxtl.livejournal.com")> _
Public Class ButtonXML
    Inherits ButtonXMLList

    'Text to write on the button.  Invisible if image button.
    <XmlAttribute()> _
    Public Text As String

    'The directory to launch the app in.
	<XmlAttribute()> _
    Public WorkingDirectory As String

    'The target app.
    <XmlAttribute()> _
    Public Target As String

    'Tool tip text for the button
    <XmlAttribute()> _
    Public ToolTipText As String

    'Should the applauncher close when the button is clicked, or return to applauncher after the spawned process is closed?
    <DefaultValue(False)> _
    <XmlAttribute()> _
    Public WaitForExit As Boolean

    'Image file to show on the button face - 256*32
    <XmlAttribute()> _
    Public IdleImageTarget As String

    'Image file to show on the button face when clicked - 256*32
    <XmlAttribute()> _
    Public ClickedImageTarget As String
End Class
edit: just noticed I didn't update the XSD file. Don't wanna re-submit the source, so just don't use the XSD file - the app doesn't use it. If you don't know what XSD means, then you're not using it and don't worry.

Re: AppLauncher

Posted: 23 Sep 2008, 19:42
by Argh
Awesome, I'll check it out.

Checked it over- looks like it will work. Do I need to include the downloadable version of the .NET installer for users, to ensure that they don't have problems, or should I assume that I can just tell them that's required?

Re: AppLauncher

Posted: 23 Sep 2008, 20:26
by Pxtl
Argh wrote:Awesome, I'll check it out.

Checked it over- looks like it will work. Do I need to include the downloadable version of the .NET installer for users, to ensure that they don't have problems, or should I assume that I can just tell them that's required?
No idea. I'm pretty sure that they'll get a pop-up explaining they need the .NET framework 2.0 (or newer) to run this if they execute it, but I've always deployed .NET apps using Microsoft's installers which would automatically fetch the framework from MS's website and install it if necessary.

http://www.microsoft.com/downloads/deta ... laylang=en

The installer is like 23 megs, and if you run it when you don't have it, it just gives you an "uninstall or repair" option box.

In hindsight, it might've been better to do this sucker in Python where I could bundle the redistributable into the exe, but it's too late now.

Re: AppLauncher

Posted: 23 Sep 2008, 20:32
by Argh
Ok... I'll just chance that, as I don't have a machine that doesn't have .NET 2.0 Framework on it. Otherwise, this looks like a sweet, dummy-proof little app., I'm lovin' it. I'll get back to this after I've actually configured it and stuff for the first time...

Re: AppLauncher

Posted: 23 Sep 2008, 20:33
by Pxtl
Wait, you use NSIS, right? I just remembered about this:

http://nsis.sourceforge.net/DotNET

A little script you can bundle into an NSIS installer to check/install 2.0 for you.

Re: AppLauncher

Posted: 23 Sep 2008, 21:14
by Argh
Oh, crap! Is there any way to pass commandline arguments? I have to able to open TASClient -server blahblahblah, for example...

Re: AppLauncher

Posted: 23 Sep 2008, 21:16
by Hoi
Why? let people autojoin the main server, so they wont have problems changing to the main one when 0.77 is live.

Re: AppLauncher

Posted: 23 Sep 2008, 21:19
by Argh
Because they can't play on the main server, until 0.77 is released.

Re: AppLauncher

Posted: 23 Sep 2008, 21:21
by Hoi
they'll need to redownload spring, what if you don't make the folder pure, but spring? when 0.77 will go live the test server should offer that file, and hopefully will let the people autoconnect to the main server, without uninstalling pure (installing spring when you already have a spring folder will just overwrite stuff) I think the newest tasclient will be given with 0.77, someone needs to test if you will autoconnect to main server if you reinstall spring over the same folder

Re: AppLauncher

Posted: 23 Sep 2008, 21:29
by Argh
I am sure that when 0.77 is available, I'll offer a patch, etc. to update everybody and keep installs on the same page. I'm not using the /Spring directory because that would mean overwriting people's main Spring installs, which might cause all sorts of bad things to happen. That's not really that important right now- what's important is that there's no way to launch the applications with the appropriate arguments to get them to do what they need to do. Single-player Missions, for example, have to launch as "spring.exe -sometexthere.txt", and I can't do that yet.

Re: AppLauncher

Posted: 23 Sep 2008, 21:37
by Pxtl
...


oops.

New button attribute:

'The arguments for the target
<XmlAttribute()> _
Public Arguments As String

Re: AppLauncher

Posted: 23 Sep 2008, 21:40
by Argh
No oops on your part, man. I'm an idiot, didn't even think about it 'til now :roll:

Re: AppLauncher

Posted: 23 Sep 2008, 21:44
by Hoi
Argh wrote:I am sure that when 0.77 is available, I'll offer a patch, etc. to update everybody and keep installs on the same page. I'm not using the /Spring directory because that would mean overwriting people's main Spring installs, which might cause all sorts of bad things to happen. That's not really that important right now- what's important is that there's no way to launch the applications with the appropriate arguments to get them to do what they need to do. Single-player Missions, for example, have to launch as "spring.exe -sometexthere.txt", and I can't do that yet.
Do you have a way to make sure that everyone will get the patch?

Re: AppLauncher

Posted: 23 Sep 2008, 22:06
by Argh
Drat. Foiled again. Seems Spring won't actually start a SP mission launched like this:

<Button Text="PURE Test"
XmlAttribute="script1.txt"
Target="spring.exe"
WaitForExit="true"
ToolTipText="Launch PURE SP"
WorkingDirectory=""
IdleImageTarget="PlayPURETASClient.PNG"
ClickedImageTarget="Clicked.PNG"/>
/>

script1.txt works, when invoked from a .LNK, but doesn't work this way. Any ideas?

Re: AppLauncher

Posted: 23 Sep 2008, 22:11
by Pxtl
Argh wrote:Drat. Foiled again. Seems Spring won't actually start a SP mission launched like this:

<Button Text="PURE Test"
XmlAttribute="script1.txt"
Target="spring.exe"
WaitForExit="true"
ToolTipText="Launch PURE SP"
WorkingDirectory=""
IdleImageTarget="PlayPURETASClient.PNG"
ClickedImageTarget="Clicked.PNG"/>
/>

script1.txt works, when invoked from a .LNK, but doesn't work this way. Any ideas?
I notice WorkingDirectory is empty. Is applauncher living in the same folder as Spring? What's the error? Spring a-splode, or just "can't find file"?

Frak: just noticed. That parameter name is wrong. It's called "Arguments" not "XmlAttribute". At some point I'll have to make real documentation instead of slapping code into here.

Re: AppLauncher

Posted: 23 Sep 2008, 22:13
by Argh
Applauncher's in the same dir, that way no matter where users decide to install, it should work.

Nothing explodes on AppLauncher's side. That's all fine and dandy, aside from a little weirdness with the graphic for the buttons. Spring runs... but doesn't execute the command-line argument.

Re: AppLauncher

Posted: 23 Sep 2008, 22:14
by Pxtl
In case you missed edit: Arguments, not XmlAttribute

Re: AppLauncher

Posted: 23 Sep 2008, 22:15
by Argh
OH!

Well, I guess I'd better test that now :roll:

BTW, the buttons are supposedly 256/32, but they're being scaled or shifted... it's very odd... I'm pretty sure they're being stretched to the lower-right. Very strange.

[EDIT]IT WORKS!!! Muahahaha... oh, wait, now I have to do actual work now... doh...[/EDIT]

Re: AppLauncher

Posted: 23 Sep 2008, 22:22
by Pxtl
Screenshot of distortion?

Re: AppLauncher

Posted: 23 Sep 2008, 22:30
by Argh
Coming...

Image
You can tell by the fuzziness, it's being stretched. I've verified that that zone is exactly 256/32 already, that's not the problem.