Das Forum

[Scripts] Sono Hanabira ni Kuchizuke wo series (1-14)

Visual novel series

Autor Antworten
markingdude Saturday 28 September 2013 at 5:25
markingdudeAnonymous

Sono Hanabira ni Kuchizuke wo 01 - Sono Hanabira ni Kuchizuke wo

Intro:

I have created some PoL/PoM scripts for the Sono Hanabira ni Kuchizuke wo series. This is a series of visual novels released in Japan that has a pretty big following since its debut in 2006.

My goal for this thread is to get feedback on my scripts before I send these for approval. While I have released these publicly on my website already, I would to have additional input on the code from the people here before submitting these.

For more information, you can check out this page here.

Technical information:

These PoM/PoL scripts were written and tested using Mac OS X Snow Leopard (10.6.8) and Mountain Lion (10.8.4). I have not done enough testing on the Linux sides of things except on Ubuntu.

They are made to work with visual novels bought from the English DLsite store and via CD/DVD. Online stores that use DRM protection won't work properly.

For all VNs, nothing special was needed to make these games work. SonoHana 11 uses MPEG-1 for its opening movie, and while it'll work using Wine 1.3, Japanese text won't be displayed properly. This is still being looked into, and isn't included in its script until I figure this out.

SonoHana 13 and 14 have opening movies that play properly, but may randomly crash the visual novel from time to time. If there is something in the code I'm missing that may help, let me know.

How the scripts work:

This is a quick rundown of what the scripts do:
  • Creates virtual drive
  • Installs additional components for movie playback and proper gameplay (SonoHana 13 and 14)
  • Asks user to install via Setup.exe or CD/DVD
  • Provides instructions for installing the VN (since it's all in Japanese)
  • Asks user what language to install VN in (SonoHana 1-8)
  • Asks user to locate and install English translation patch (if user selected English)
  • Installs the fjfix patch (needed to run the visual novels properly)
  • Create shortcuts for easy access

The scripts:

Check the thread. There will be 15 total scripts for this series, haha.

Editiert von: markingdude

markingdude Sunday 29 September 2013 at 16:08
markingdudeAnonymous

01 - その花びらにくちづけを (Sono Hanabira Ni Kuchiduke Wo / A Kiss for the Petals) [2011 Remake only]

This script only works for the 2011 remake available at the English DLsite store. The original 2006 release requires manual installation. Nothing outside of Wine or PlayOnMac/PlayOnLinux was needed.

[code language=playonlinux]
#!/bin/bash
# Date : (2013-03-01)
# Last revision : (2013-07-09)
# Wine version used : 1.6
# Distribution used to test : Mac OS X 10.8.4
# Author : Marking

[ "$PLAYONLINUX" = "" ] && exit 0
source "$PLAYONLINUX/lib/sources"

# Setup some needed variables
TITLE="Sono Hanabira ni Kuchizuke wo"
PREFIX="SonoHana_01"
WINEVERSION="1.6"
EDITOR="Fuguriya"
GAME_URL="http://fuguriya.sakura.ne.jp"
AUTHOR="Marking"

# Download images for installation script
POL_GetSetupImages "http://images.markinglifestyle.com/sonohana_mac/script_icons/SonoHana_01-64x64.png" "http://images.markinglifestyle.com/sonohana_mac/script_banners/SH_01.jpg" "$TITLE"

# Initialize the script, debugging, and set required version
POL_SetupWindow_Init
POL_RequiredVersion "4.1.6" || POL_Debug_Fatal "$APPLICATION_TITLE 4.1.6 is required to install $TITLE"
POL_Debug_Init
 
# Setup presentation window
POL_SetupWindow_presentation "$TITLE" "$EDITOR" "$GAME_URL" "$AUTHOR" "$PREFIX"

# Begin setting up the Wine Prefix
POL_Wine_SelectPrefix "$PREFIX"
POL_Wine_PrefixCreate "$WINEVERSION"
SONOHANA="$WINEPREFIX/drive_c/$PROGRAMFILES/ふぐり屋/その花びらにくちづけを/"
   
# Ask user for either DVD or Local installation
POL_SetupWindow_InstallMethod "LOCAL,DVD"

if [ "$INSTALL_METHOD" = "LOCAL" ]
then
    # Ask user to find "Setup.exe"
    cd "$HOME"
    POL_SetupWindow_browse "$(eval_gettext 'Please locate installation program (Setup.exe)')" "$TITLE"
    LANG="ja_JP.UTF-8" POL_Wine start /unix "$APP_ANSWER"
       
    # Tell user what to do while the installation program is running
    POL_SetupWindow_message "$(eval_gettext 'When the install program starts, click on インストール. When a new window opens, click on インストール. When installation finishes, click on 終了 and then on はい. Click Next when you are done installing.')" "Installation instructions"
       
elif [ "$INSTALL_METHOD" = "DVD" ]
then
    # Launches the installation program from CD/DVD
    POL_SetupWindow_cdrom
    POL_SetupWindow_check_cdrom
    LANG="ja_JP.UTF-8" POL_Wine start /unix "$CDROM/Setup.exe"

    # Tell user what to do while the installation program is running
    POL_SetupWindow_message "$(eval_gettext 'When the install program starts, click on インストール. When a new window opens, click on インストール. When installation finishes, click on 終了 and then on はい. Click Next when you are done installing.')" "Installation instructions"
fi
   
# Renames the main EXE file if installing the 2011 remake
mv "$SONOHANA/HANA1.EXE" "$SONOHANA/HANABIRA.EXE"

# Tells users which language they want to use
POL_SetupWindow_menu "Which language would you like to read this in?" "Select Language" "日本語 (Japanese)|English" "|"

#For Japanese language
if [ "$APP_ANSWER" = "日本語 (Japanese)" ]
then
    # Apply fjfix to fix the visual novel
    FJFIX_PATCH="fjfix.zip"
    cd "$SONOHANA"
    POL_Download "http://files.markinglifestyle.com/sh_files/fjfix.zip" "789634f517003c1619eca669a83306a0"
    POL_System_unzip $FJFIX_PATCH
    POL_Wine_WaitExit "the fjfix patch"    POL_Wine "fjfix.exe" -f MGD
   
    # Create a shortcut for easy access
    POL_Shortcut "HANABIRA.EXE" "その花びらにくちづけを"
    # Insert a command to run as a Japanese application
    POL_Shortcut_InsertBeforeWine "その花びらにくちづけを" "LANG=ja_JP.UTF-8"
   
#For English language   
elif [ "$APP_ANSWER" = "English" ]
then

    # Warn user about applying English patch to unsupported remake
    POL_SetupWindow_message "Please note that while the English patch works with the remake, it is not officially supported by the creators of the patch. Patch at your own risk. Click Next to continue." "Note about the English patch"
   
    #Download and install English translation patch
    EN_PATCH="HANABIRA-EN.zip"
    cd "$SONOHANA"
    POL_Download "http://files.markinglifestyle.com/sh_files/HANABIRA-EN.zip" "94f2e7876f22093f9fefe87451529848"
    POL_System_unzip $EN_PATCH
    mv "$SONOHANA/HANABIRA-EN/MGE" "$SONOHANA/MGE"
    mv "$SONOHANA/HANABIRA-EN/MSE" "$SONOHANA/MSE"
    mv "$SONOHANA/HANABIRA-EN/HANABIRA-EN.EXE" "$SONOHANA/HANABIRA-EN.EXE"
   
    # Apply fjfix to fix the visual novel
    FJFIX_PATCH="fjfix.zip"
    cd "$SONOHANA"
    POL_Download "http://files.markinglifestyle.com/sh_files/fjfix.zip" "789634f517003c1619eca669a83306a0"
    POL_System_unzip $FJFIX_PATCH
    POL_Wine_WaitExit "the fjfix patch"    POL_Wine "fjfix.exe" -f MGE
   
    # Create a shortcut for easy access
    POL_Shortcut "HANABIRA-EN.EXE" "A Kiss for the Petals"
    # Insert a command to run as a Japanese application
    POL_Shortcut_InsertBeforeWine "A Kiss for the Petals" "LANG=ja_JP.UTF-8"
fi
    POL_SetupWindow_Close
exit
[/code]


Images:

Screenshot

22x22 icon

48x48 icon

Top corner image

Left banner

Editiert von: markingdude

petch Sunday 29 September 2013 at 18:29
petch


Hi markingdude,
Sorry for replying a bit late, let's review this first script:

[code language=playonlinux]
SONOHANA="$REPERTOIRE/wineprefix/$PREFIX/drive_c/SonoHana/"
[/code]

Don't assume WIne prefixes are created under $REPERTOIRE/wineprefix/ (or $POL_USER_ROOT/wineprefix/, if you prefer), that may not be true in the future.

Instead use $WINEPREFIX/drive_c/SonoHana/, after the prefix has been selected.


[code language=playonlinux]
POL_SetupWindow_browse "Please locate installation program (Setup.exe)" "$TITLE"
[/code]

A general remark for a user-oriented messages: they must be localizable thru the use of $(eval_gettext ''): http://www.playonlinux.com/en/dev-documentation-10.html

It's also a good idea to use cd "$HOME" before POL_SetupWindow_browse so the file selection starts from user's home directory instead of the random current directory at the time.


[code language=playonlinux]
LANG="ja_JP.UTF-8" POL_Wine start /unix "$APP_ANSWER"
[/code]

start /unix is usually unnecessary, and has a known drawback (the spawned programs are not killed in the installation is aborted by the user); However, from what I understand, you're using the fact the installation script will continue asynchronously to display installation instructions to the user. Not sure if there's a better way to achieve the same effect.


[code language=playonlinux]

cp -r "$REPERTOIRE/wineprefix/$PREFIX/drive_c/Program Files/ふぐり屋/その花びらにくちづけを/" "$SONOHANA"
rm -r "$REPERTOIRE/wineprefix/$PREFIX/drive_c/Program Files/ふぐり屋/"

# Renames the main EXE file if installing the 2011 remake
mv "$SONOHANA/HANA1.EXE" "$SONOHANA/HANABIRA.EXE"
[/code]

What's the reason for copying stuff around, and wouldn't it be faster to move them instead?

Also never use "Program Files", as the exact wording depends on the locale; Always use $PROGRAMFILES instead.


[code language=playonlinux]
POL_Download "http://files.markinglifestyle.com/sh_files/fjfix.zip"
[/code]
It's a good idea to secure downloads by specifying the expected MD5 hash of the file, unless it's updated too often to be maintained.


[code language=playonlinux]
unzip $FJFIX_PATCH

[/code]

Starting with PlayOnLinux/PlayOnMac 4.1.6, you can use POL_System_unzip instead of unzip, it will display a GUI fatal error message in case of error.

If it's a small archive, it may not matter that much though.


[code language=playonlinux]

# Tell user that the installation was successful.

POL_SetupWindow_free_presentation "$TITLE" "Installation is now
complete.nnThanks for using this script! I hope it helps the Mac and
Linux users out!nnPlease post your results, feedback, and/or issues you
have with the script at The Marking Lifestyle.nn--Marking
(http://the.markinglifestyle.com)"
[/code]

As SuperPlumus reminded us recently, "success" ending messages have been deprecated since the addition of an embedded debugger: it will only confuse users if the next message is a debugger error report with the ability to automatically send a bug report.

Editiert von: petch

markingdude Sunday 29 September 2013 at 19:12
markingdudeAnonymous


Don't
assume WIne prefixes are created under $REPERTOIRE/wineprefix/ (or
$POL_USER_ROOT/wineprefix/, if you prefer), that may not be true in the
future.
Instead use $WINEPREFIX/drive_c/SonoHana/, after the prefix has been selected.

Quote from petch

Noted and fixed.



A
general remark for a user-oriented messages: they must be localizable
thru the use of $(eval_gettext ''):
http://www.playonlinux.com/en/dev-documentation-10.html
It's also a
good idea to use cd "$HOME" before POL_SetupWindow_browse so the file
selection starts from user's home directory instead of the random
current directory at the time.

Quote from petch

Didn't think about using "cd $HOME" since this hasn't happened to me as of yet, but it's a good idea nonetheless. Also forgot about "eval_gettext".



start
/unix is usually unnecessary, and has a known drawback (the spawned
programs are not killed in the installation is aborted by the user);
However, from what I understand, you're using the fact the installation
script will continue asynchronously to display installation instructions
to the user. Not sure if there's a better way to achieve the same
effect.

Quote from petch


I see this comment a lot about "start /unix", however this command is included in the Documentation for scripting (http://www.playonlinux.com/en/dev-documentation-5.html). Perhaps it needs to be update to not include that. That being said, yeah this is pretty much the idea, since the installation program is in Japanese and not everyone can read it.



What's the reason for copying stuff around, and wouldn't it be faster to move them instead?

Quote from petch



As we'll see in the next script (and going up to the eighth VN), this is needed for easier management as well as getting the English translation patch to work without the user searching for the game's directory. I tried moving them, but the script only worked if I copied and removed the empty directory. I'll see if I can clean it up better so that this is not needed, but that was the reasoning behind it at the time.


This is no longer needed.



Also never use "Program Files", as the exact wording depends on the locale; Always use $PROGRAMFILES instead.

Quote from petch


Noted and fixed.



It's
a good idea to secure downloads by specifying the expected MD5 hash of
the file, unless it's updated too often to be maintained.

Quote from petch


Noted and done.



Starting
with PlayOnLinux/PlayOnMac 4.1.6, you can use POL_System_unzip instead
of unzip, it will display a GUI fatal error message in case of error.
If it's a small archive, it may not matter that much though.

Quote from petch


Cool. Didn't know this was there. Perhaps the documentation needs to be updated to include updated functions as well since that was what I used to make these scripts at the time.



As SuperPlumus reminded
us recently, "success" ending messages have been deprecated since the
addition of an embedded debugger: it will only confuse users if the next
message is a debugger error report with the ability to automatically
send a bug report.

Quote from petch


Before I decided to submit these scripts for approval, the success message was a way for users to know where to send feedback or issues with the software. However, I see your point now that I'm fixing these and getting them approved officially.

Updated script will be in the next post. Give me a minute...

Editiert von: markingdude

markingdude Sunday 29 September 2013 at 19:52
markingdudeAnonymous

I appreciate the feedback on the first script so far. 

I decided not to move stuff around anymore since the English patch will work with Japanese directories. "start /unix" is still there for the installation program since the instructions are needed for English speakers.

Editiert von: markingdude

petch Sunday 29 September 2013 at 20:54
petch


More comments coming from SuperPlumus:

[code language=playonlinux]
[ "$PLAYONLINUX" = ""] && exit 0
[/code]
Typo, there should be a space before ] for this statement to work correctly

He's also not convinced that the use of Bash functions improves the readability of the script (personally I didn't mention it, as I'm a bit more neutral about this: I like functions in general, but agree that Bash functions are not very good as abstraction tools, since scripting style relying so much on global state).

Same about comments redundant with the code, and I tend to agree with him on this second point, while it may seem like a good idea when writing your first scripts, doubling the number of lines (or more, if you also add empty lines each time) for redundant comments just gets in the way of readability when you have been reading PlayOnLinux/PlayOnMac scripts for a while.
In the end it depends who will have to maintain the scripts...

[code language=playonlinux]
        POL_SetupWindow_cdrom

        # Launches the installation program
        LANG="ja_JP.UTF-8" POL_Wine start /unix "$CDROM/Setup.exe"
[/code]
There should be a POL_SetupWindow_check_cdrom command between the two to test the presence of some file specific to the CDROM and verify that it's the right media; See http://www.playonlinux.com/en/dev-documentation-7.html

[code language=playonlinux]
# Setup presentation window
POL_SetupWindow_free_presentation "$TITLE" "This script will install Fuguriya's first visual novel: Sono Hanabira ni Kuchizuke wo.\\n\\n\\nClick Next to begin."
[/code]
From his point of view it's just as well if such messages are not translated, as they're too specific, and would put more strain on the translation team. Ideally something more "standard" could be used with little loss.

Editiert von: petch

markingdude Sunday 29 September 2013 at 21:19
markingdudeAnonymous


More comments coming from SuperPlumus:
Typo, there should be a space before ] for this statement to work correctly

Quote from petch


Oh, OK. Didn't realize that.


He's also not convinced that the use of Bash functions improves the readability of the script (personally I didn't mention it, as I'm a bit more neutral about this: I like functions in general, but agree that Bash functions are not very good as abstraction tools, since scripting style relying so much on global state).

Quote from petch


The reason for the Bash functions was because the code for the first 11 games (and spinoff) all have similar code, so it was an easy way for me to maintain them all at the time. However, I understand his point about keeping the coding style consistent rather than adding new things to complicate people who wish to read the code.


Same about comments redundant with the code, and I tend to agree with him on this second point, while it may seem like a good idea when writing your first scripts, doubling the number of lines (or more, if you also add empty lines each time) for redundant comments just gets in the way of readability when you have been reading PlayOnLinux/PlayOnMac scripts for a while.
In the end it depends who will have to maintain the scripts...

Quote from petch


I will keep this mind for future scripts (along with the other 14).


There should be a POL_SetupWindow_check_cdrom command between the two to test the presence of some file specific to the CDROM and verify that it's the right media; See http://www.playonlinux.com/en/dev-documentation-7.html

Quote from petch


Noted and fixed.


From his point of view it's just as well if such messages are not translated, as they're too specific, and would put more strain on the translation team. Ideally something more "standard" could be used with little loss.

Quote from petch


Understandable. Again, these were before I decided to start submitting these officially.

Editiert von: markingdude

petch Sunday 29 September 2013 at 21:49
petch

[code language=playonlinux]
    POL_System_unzip $FJFIX_PATCH
[/code]

If you go the POL_System_unzip way, I'd add
[code language=playonlinux]
POL_RequiredVersion "4.1.6" || POL_Debug_Fatal "$APPLICATION_TITLE 4.1.6 is required to install $TITLE"
[/code]
between POL_SetupWindow_Init and POL_Debug_Init so that the script fails early rather than late. Doing it before the debugger is initialized is a trick to avoid this fatal error from being reported as a bug ;)

[code language=playonlinux]
    POL_Shortcut_InsertBeforeWine "A Kiss for the Petals" "LANG="ja_JP.UTF-8""
[/code]
Notice (if anything, looking a syntax highlighting) that double quotes do not nest.
I think it still works, as ja_JP.UTF-8 does not contain any character that deserves quoting to avoid interpretation in a Bash script, but still. Personally I use single quotes for last POL_Shortcut_InsertBeforeWine parameter, to prevent any interpolation of what will be inserted in the shortcut script:
[code language=playonlinux]
    POL_Shortcut_InsertBeforeWine "A Kiss for the Petals" 'LANG="ja_JP.UTF-8"'
[/code]
That usually does exactly what I expected. You can check shells quoting, it's a large topic...

Ok, I think that now, with both my comments and SuperPlumus', we're really done ;)
markingdude Sunday 29 September 2013 at 22:06
markingdudeAnonymous


If you go the POL_System_unzip way, I'd add
[code language=playonlinux]
POL_RequiredVersion "4.1.6" || POL_Debug_Fatal "$APPLICATION_TITLE 4.1.6 is required to install $TITLE"
[/code]
between POL_SetupWindow_Init and POL_Debug_Init so that the script fails early rather than late. Doing it before the debugger is initialized is a trick to avoid this fatal error from being reported as a bug ;)

Quote from petch


Haha, all right. :P


Notice (if anything, looking a syntax highlighting) that double quotes do not nest.
I think it still works, as ja_JP.UTF-8 does not contain any character that deserves quoting to avoid interpretation in a Bash script, but still. Personally I use single quotes for last POL_Shortcut_InsertBeforeWine parameter, to prevent any interpolation of what will be inserted in the shortcut script:

Quote from petch


This for me worked fine (tested both English and Japanese versions:
"LANG=ja_JP.UTF-8"


Ok, I think that now, with both my comments and SuperPlumus', we're really done ;)

Quote from petch


Great! Thanks again to both of you for the feedback on the script. I will hold off on posting the other 14 until they have been edited with the changes I've done with this one. As for this first visual novel, I'll go ahead and submit it. :)
markingdude Tuesday 1 October 2013 at 2:40
markingdudeAnonymous

...

Editiert von: markingdude

petch Tuesday 1 October 2013 at 20:42
petch

Hi,

top gfx should be 64x64 and left gfx should be 150x356 (one pixel too wide - I can probably deal with this one)

Anything more "square" to provide for top gfx?
markingdude Wednesday 2 October 2013 at 1:41
markingdudeAnonymous

Hi,

top gfx should be 64x64 and left gfx should be 150x356 (one pixel too wide - I can probably deal with this one)

Quote from petch

Fixed the images and they should be in the posts with the scripts. Simply click on them to view them. For the 64x64 image, I simply created a 64x64 version of the earlier smaller icons since I couldn't find anything better for the logos.

Editiert von: markingdude

petch Wednesday 2 October 2013 at 20:17
petch

Script validated; The only thing I changed is $TITLE, that must exactly match the script name in the repository (that's a requirement of the debugger support).
markingdude Wednesday 2 October 2013 at 20:38
markingdudeAnonymous

All right, I'll keep that in mind. By the way, I might not have been clear earlier, but those images you used are actually for the second script that I haven't posted yet. The first script's images are in the second post in this thread. Sorry if I wasn't clear in my previous post.

Never mind. It looks like only the 22x22 icon on the installation menu window that was wrong.

Editiert von: markingdude

petch Thursday 3 October 2013 at 0:37
petch

Mmmh I'm confused, I picked the gfxs from the latest links, I hope I got it right this time?
By the way you may have to remove ~/.PlayOnLinux/configurations/setups/Sono\ Hanabira\ ni\ Kuchizuke\ wo\ 01\ -\ Sono\ Hanabira\ ni\ Kuchizuke\ wo/ to see the changes, since the client is caching the resources...
markingdude Thursday 3 October 2013 at 1:06
markingdudeAnonymous

Nevermind, we're good with the images. Thanks for helping me so far.

To make things easier, perhaps I should just make a new thread for every SonoHana visual novel? I'll go ahead and do that with the second VN.

Editiert von: markingdude

markingdude Saturday 26 October 2013 at 4:28
markingdudeAnonymous

This is something I should have done from the start, but when you have a chance, could you add the following to the "Description" field for Sono Hanabira ni Kuchizuke wo 01 - Sono Hanabira ni Kuchizuke wo:

"This installer only supports the 2011 remake release. Manual installation is required for the original 2006 release."

Thanks in advance, and always appreciate the updates for my scripts. :)
petch Saturday 26 October 2013 at 9:53
petch