Would it be possible to move out common functions used in campaign scripts?

Bug #835559 reported by Hans Joachim Desserud
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
widelands
Fix Released
Wishlist
Unassigned

Bug Description

For a while it has annoyed me that some campaign maps show new objectives and similar parts of the text with proper headlines while others merely use dashes (--). Especially since the dashes cause most of the victory messages to end up spanning two lines. So since some of the maps are able to do this I looked into how I could update the other maps to use this as well.

From what I found it looks like the methods for turning things into headlines consists of a small set of identical functions defined in each campaign text. So the easist fix would be to just copy it over and start using it elsewhere. However, this would make it a lot harder to change the different places it is used if we at some point decide to for instance change headline color. So I wondered if it would be possible to place these methods related to campaign story text somewhere common where all the campaings can reach them? That way, they could be defined in one place, the campaigns all import them so they can use them, and in case of any changes they only need to be performed in one place. I realize this would make all campaigns depend on external scripting, but if it ships as part of the Widelands install, this should not be a problem. I would suggest placing these files in a subdirectory of campaigns, such as widelands/campaigns/common or something.

Tags: campaign lua

Related branches

Revision history for this message
Shevonar (shevonar) wrote :

I agree. This was something that I didn't like from the first moment on. I found a common file for formatting. Have a look at /scripting/formatting.lua. These functions are similar or equal to those used in the "well-formatted campaigns". However they should be used in all the campaigns to create some unitary look. I could get started with it in the next days.

Revision history for this message
Shevonar (shevonar) wrote :

I just tried to refactor the first barbarian tutorial and it turned out that it is a lot of work. I have completely rearranged the code to get consitency in file naming between the different campaigns and some more order. Everything looks good now the code as well as the ingame texts but there is a hugh problem: Most of the translations will be broken! I tried to save as many as possible but that will leave some blemish. So my suggestion is: either completely good look and code and the need of retranslation or don't change anything cause it's not worth the work when afterwards there is less then befor (neither a good look nor a complete translation) I'd be happy about some feedback :)

Changed in widelands:
assignee: nobody → Shevonar (shevonar)
status: New → Opinion
Revision history for this message
SirVer (sirver) wrote :

Do not touch it is my proposal. Forcing people to retranslate all and everything is not friendly and purity should not go beyond practice. New campaigns and scenarios are urged to use the auxilary scripts which are documented here:
http://wl.widelands.org/docs/lua/aux_formatting/

I set this to won't fix. Please reopen if you disagree.

Changed in widelands:
status: Opinion → Won't Fix
Revision history for this message
Shevonar (shevonar) wrote :

I think it would be possible to write a script that can change the po-files so they fit the new strings, but I'm not sure if it is possible to tell Launchpad about the changed po-files except uploading them manually?
There is also a minor problem with the "aux_formatting": the speech function will automatically add translatable (as stated in the comment) quotation marks but (since the wohle scripting folder is not translated) these quotation marks are not translated. The easiest solution imho is to add the scripting folder to the list of translated folders because other functions like the add_objectives (which contains the "New objectives"-string) could also be included in this file.

Revision history for this message
Shevonar (shevonar) wrote :

Added a blueprint and reopened cause of my previous comment.

Revision history for this message
Shevonar (shevonar) wrote :

Okay I cannot reopen it :(

Revision history for this message
SirVer (sirver) wrote :

i reopened it. Afaik, when hanging the .po files in trunk, they will automatically merged and exported to Launchpad. So careful rewriting of the .po and .pot files should make it possible to keep everything translated and still keep all translations.

A common look of the formatting would be desirable, but consistency just for the sake of it is more trouble than it's worth:each scenario is a logical unit and it doesn't matter as much how the logic was implemented.

Changed in widelands:
status: Won't Fix → Confirmed
Revision history for this message
Venatrix (elisabeth) wrote :

>each scenario is a logical unit and it doesn't matter as much how the logic was implemented.

That may be true. But on the other hand it can be expected that new scenarios will use the new uniform look, so the first ones will one day look out of place. So if it is possible to script the needed changes to the po-files, I think it should be done.

Revision history for this message
GunChleoc (gunchleoc) wrote :

I never saw this and did a separate fix for the formatting with the big i18n changes that are already in trunk, common functions are now in scripting/format_scenario.lua

What I did not fix is the inconsistency in file names.

Revision history for this message
SirVer (sirver) wrote :

> What I did not fix is the inconsistency in file names.

Please elaborate.

Revision history for this message
GunChleoc (gunchleoc) wrote :

I mean the file names of the campaign scripts. e.g. some campaigns have texts.lua, others have mission_thread_texts.lua etc. We wanted to have standard names for these.

Revision history for this message
SirVer (sirver) wrote :

That would be nice, but is not super important. We can move them anytime without much risk though.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Filenames are now renamed except for the main tutorial. We can close this bug as soon as the branch gets merged.

Changed in widelands:
status: Confirmed → In Progress
Revision history for this message
SirVer (sirver) wrote :

Why is the main tutorial not renamed? What is special about it?

Revision history for this message
wl-zocker (wl-zocker) wrote :

I am working on the tutorial(s). Until now, I have not created a branch yet (saves me merging all the time), but I hope to be able to present some results soon.

Revision history for this message
GunChleoc (gunchleoc) wrote :

#15 is what I thought, so I saved myself some work.

Changed in widelands:
assignee: Shevonar (shevonar) → GunChleoc (gunchleoc)
Revision history for this message
SirVer (sirver) wrote :

Fixed in r7244.

Changed in widelands:
status: In Progress → Fix Committed
Changed in widelands:
milestone: none → build19-rc1
GunChleoc (gunchleoc)
Changed in widelands:
assignee: GunChleoc (gunchleoc) → nobody
GunChleoc (gunchleoc)
Changed in widelands:
status: Fix Committed → Fix Released
Revision history for this message
GunChleoc (gunchleoc) wrote :

Fixed in build19-rc1.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related blueprints

Remote bug watches

Bug watches keep track of this bug in other bug trackers.