Latest Posts

Topic: Extending the editor to make screenshots easier

fraang

Topic Opener
Joined: 2010-02-15, 13:13
Posts: 239
Ranking
Widelands-Forum-Junkie
Posted at: 2019-03-28, 13:57

I would like to suggest an extension of the Widelands editor to aid the creation of screenshots. It would make the creation of feature demonstrations and test environments a lot easier and faster:

Add the possibility to place roads and buildings on the map. This way you can control exactly what is put where and can "stage" different situations which would otherwise take a lot of time.


Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 1929
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2019-03-28, 14:38

We already have a small Lua implementation for the editor: https://wl.widelands.org/documentation/autogen_wl_editor/
All the basic place_xxx commands are also available there. I don´t know what this is used for currently though face-wink.png

What is needed is some "Make Infrastructure" tool that allows at least defining the territory of players and placing buildings, ships, flags, roads and perhaps workers and wares.
Such a tool could also be used to easily define additional map-specific starting conditions, and make it easier to define the starting conditions for a scenario.

+1 from me face-smile.png


Top Quote
kaputtnik
Avatar
Joined: 2013-02-18, 20:48
Posts: 2434
OS: Archlinux
Version: current master
Ranking
One Elder of Players
Location: Germany
Posted at: 2019-03-28, 22:06

Afaik in the past the idea to split off the editor code from the widelands code come up. So the editor will be an own executable then. I think this has to be the first goal, e.g. by creating an api which can be used for both parts, the Game and the editor. Doing it like that would make some things easier.

I would love to see an editor with a scripting option, to make creation of scenarios much easier. I guess it should not be that problematic to have a property window of a 'field' (e.g. a tribes starting field) or an action (e.g. create road) which is turned into valid lua commands. But the devil is surely in the details face-smile.png

So +1 also by me, but this has to be seriously considered.


Fight simulator for Widelands:
https://wide-fighter.netlify.app/

Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 15:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2019-03-29, 08:31

Somebody actually took a stab at this once. The code was unmaintained, so we removed it after we did the redesign for the tribes, because it was completely bitrotted.

Yes, it would be very nice to have lots of support for infrastructure and scripting in the editor!


Busy indexing nil values

Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 2646
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2019-03-29, 09:21

It is not exactly what kaputtnik demanded but SirVer has a very old branch which contains a function to actually dump an existing economy from a game that can be reloaded. This can be used to create a Scenario or to save some Mission data.
see https://code.launchpad.net/~widelands-dev/widelands/scenarios
I am actually planning to use this for my next Scenario in the empire campaign.
If I could ask for a new Editor feature this would be to extent an existing map in x and y direction, while keeping the existing part.


Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 1929
OS: Debian Testing
Version: Latest master
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2019-03-29, 09:36

If I could ask for a new Editor feature this would be to extent an existing map in x and y direction, while keeping the existing part

That´s a feature I miss very much face-smile.png

Yes, it would be very nice to have lots of support for infrastructure and scripting in the editor!

Sound like a feature I could implement when all my other open feature branches are merged face-smile.png

Afaik in the past the idea to split off the editor code from the widelands code come up. So the editor will be an own executable then. I think this has to be the first goal, e.g. by creating an api which can be used for both parts, the Game and the editor. Doing it like that would make some things easier.

I´m against this, because this would include lots of code duplication. There is very much common code used both for games and the editor (in EditorGameBase), and all this would have to be duplicated. This would make it much harder IMHO.

I guess it should not be that problematic to have a property window of a 'field' (e.g. a tribes starting field) or an action (e.g. create road) which is turned into valid lua commands. But the devil is surely in the details face-smile.png

It most certainly is face-wink.png

Outline for a possible implementation

Basic tools

  • Scenario options: A dialog to include additional pictures (e.g. for campaign character portraits) and to allow writing scripts (such as a mission_thread) in addition to the ones mentioned below. Including templates for commonly used functionality. And a box for defining texts spoken by campaign characters, with autogeneration of the appropriate speech() functions.
    Tabs: Scripts, Pictures, Characters, Texts

  • Field Groups. A Field Group is a set of fields (corresponding of an array of fields in Lua). The tool allows to add/remove fields from field groups. Field Groups can be used in the scenario to apply an operation (e.g. conquering for a certain player, removing immovables etc) to many fields at once.
    Tool Window: Dropdown box to choose the field group to edit; buttons to add new group, rename active group, delete active group; map-clicking to add/remove(shift)/toggle(ctrl) field under the mouse to/from the active group

  • Set Owner, to conquer certain areas for a certain player at gamestart. A similar tool to give players additional vision.
    Tool Window: Dropdown to choose the player (including entry for none), click the map to conquer a field for the selected player

  • Place Building to place certain buildings for certain players. Corresponding tools for roads, flags etc.

  • Enhance the Player Settings to set teams and attack_forbidden overrides

Interactive tools

  • On Conquer: When the owner of a particular Field Group changes, a certain Lua script is triggered. Similar callback scripts for other events, such as Player has a certain number of certain buildings or Player´s military strength exceeds a limit.
    The On Event tool window contains two dropdowns, one for a field group and one for an event. The multilineeditbox below shows the script that is called when the specified event happens on the chosen field group. A toggle button decides whether the script is called when the event happens for one or for all fields in the group.

Prerequisites

  • Implement the use of "callback" functions, so scripts can define functions that get called by the EGBase when a certain event happens in the game. I´ve been planning to implement this anyway someday…

  • Saving all the Lua scripts, ideally with nice formatting and a syntax check

  • A specialised multilineeditbox with syntax highlighting, automatic indent and perhaps even spell-/syntaxcheck-as-you-type would be great face-smile.png


Top Quote
GunChleoc
Avatar
Joined: 2013-10-07, 15:56
Posts: 3324
Ranking
One Elder of Players
Location: RenderedRect
Posted at: 2019-03-29, 17:23
  • Saving all the Lua scripts, ideally with nice formatting and a syntax check

I have code for writing nice LuaTables in the spritesheet branch. It's in the "website" directory at the moment, but it could be shifted somewhere else for you to reuse.

BTW splitting off a separate binary for the editor won't mean that we will have to duplicate all code. We already have 3 separate binaries - Widelands, and the 2 website utils.


Busy indexing nil values

Top Quote