The forum

[Script] 3D Train Studio

Author Replies
StefanWerner Thursday 5 March 2015 at 18:53
StefanWernerAnonymous

Hi,

I am the developer of the 3D Train Studio, a software for planning and simulating model railroad layouts on the computer. The software is available as a free standard version and as a commercial professional version. I want to share the installation script for downloading and installing the free standard version.

The application makes heavy use of Direct3D features, so errors might occur on systems without a proper graphics card/driver.

#!/bin/bash
# Date : (2015-03-05 09-05)
# Last revision : (2015-03-05 09-05)
# Wine version used : 1.6.2
# Distribution used to test : Ubuntu 14.04 LTS
# Author : Stefan Werner
[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"

# Define constants
TITLE="3D Train Studio"
PREFIX="TrainStudio"

# Start installation
POL_SetupWindow_Init
POL_Debug_Init
POL_SetupWindow_presentation "$TITLE" "Stefan Werner" "http://www.3d-train.com" "Stefan Werner" "$PREFIX"

# Prepare the wine config
POL_System_SetArch "x86"

POL_Wine_SelectPrefix "$PREFIX"
POL_Wine_PrefixCreate

Set_OS "win7"
POL_Wine_Direct3D "UseGLSL" "disabled"

POL_SetupWindow_wait "$(eval_gettext 'Please wait while installing prerequisites.')" "$TITLE"
POL_Call POL_Install_tahoma2

# Install the main application, either by using a local setup file or by downloading
# the latest setup from the web.
POL_SetupWindow_InstallMethod "LOCAL,DOWNLOAD"
if [ "$INSTALL_METHOD" = "LOCAL" ]
then
    POL_SetupWindow_browse "$(eval_gettext 'Please select the setup file to run.')" "$TITLE"
    POL_Wine_WaitBefore "$TITLE"
    POL_Wine "$APP_ANSWER"
elif [ "$INSTALL_METHOD" = "DOWNLOAD" ]
then
    POL_System_TmpCreate "$PREFIX"    
    cd "$POL_System_TmpDir"
    POL_Download "http://www.3d-modellbahn.de/files/client/SetupTrainStudio.exe"
    POL_Wine_WaitBefore "$TITLE"
    POL_Wine "$POL_System_TmpDir/SetupTrainStudio.exe"
    POL_System_TmpDelete
fi
 
# Finish installation
POL_Shortcut "ModellbahnStudio.exe" "$TITLE"
POL_SetupWindow_Close
exit

Here are some screenshots:

Note: The application is available in English and in German. The German title is "3D Modellbahn Studio".

I've tested the application on an Ubuntu 14.04 image. I don't have access to MacOS X, so I don't know if the app is compatible to PlayOnMac.

Kind regards,

Stefan

Edited by StefanWerner

petch Thursday 5 March 2015 at 19:23
petch

Hi Stefan,

My review of your script:

TITLE="$(eval_gettext '3D Train Studio')"

Don't translate $TITLE, it doesn't make much sense and to make it into the repository it has to match the name of the script anyway, so it must be a constant.

URL="$(eval_gettext 'http://www.3d-train.com')"

Don't translate URLs, doesn't make sense either

POL_SetupWindow_Init

Just after that you should also enable the embedded debugger:

POL_SetupWindow_Init
POL_Debug_Init
# Install mandatory prerequisites
POL_SetupWindow_wait "Please wait while installing prerequisites." "$TITLE"
POL_Call POL_Install_tahoma2

But on the other hand all user-oriented messages have to support translation!
The comment is redundant, so doesn't really improve readability...

POL_SetupWindow_browse "Please select the setup file to run." "$TITLE"
POL_SetupWindow_wait "Please wait while $TITLE is installed." "$TITLE"

Again, translate all user-oriented messages. You can also replace the latter with

POL_Wine_WaitBefore "$TITLE"

that will display this exact standard waiting message.

POL_Wine start /unix "$APP_ANSWER"
POL_Wine_WaitExit "$TITLE"

"start /unix" is not necessary 95% of the time, and it has a bad side effect: the application will not be automatically killed if the installation is aborted from PlayOnLinux/PlayOnMac. So if it's not necessary, remove it.
If it works, you may find that POL_Wine_WaitBefore is sufficient and that you can drop POL_Wine_WaitExit too.

Regards,

Pierre.

Edited by petch

StefanWerner Thursday 5 March 2015 at 20:52
StefanWernerAnonymous

Hi Pierre,

thank you for your first review. I've updated the script in the first post.

The application uses a different title/url per language. Is this not possible with PlayOnLinux?

I cannot find "POL_Wine_WaitBefore" in the list of functions, is this officially supported?

Kind regards,

Stefan

petch Thursday 5 March 2015 at 21:19
petch

thank you for your first review. I've updated the script in the first post.

Looks fine to me, I hope I'm not missing anything...

The application uses a different title/url per language. Is this not possible with PlayOnLinux?

$TITLE has to match the name of the script. You can use a different value in all the statements that need a window title though, if you think it's worth the trouble, and won't be more confusing than anything else.

I'm a bit reluctant to use gettext to translate resources like URL too. That mean that almost 50 people will try to translate it! Maybe you could provide an URL based on $POL_LANG, or even $LANG, if it doesn't add too much complexity to the install script...

I cannot find "POL_Wine_WaitBefore" in the list of functions, is this officially supported?

It exists since PoL/PoM 4.0.15, with a bugfix in 4.0.16, so it's been around for 3 years now, on all still supported versions.

Now that the documentation has been converted to a Wiki, it should be easier to update it ;)

Edited by petch

StefanWerner Thursday 5 March 2015 at 23:41
StefanWernerAnonymous

Hi Pierre,

thanks for the review. I don't need a translation of the title, so I keep it. I have submitted my script to the supported software area.

Kind regards,

Stefan

This site allows content generated by members, and we promptly remove any content that infringes copyright according to our Terms of Service. To report copyright infringement, please send a notice to dmca-notice@playonlinux.com