Opened 7 years ago

Closed 3 years ago

#4387 closed enhancement (fixed)

[PATCH] Implement campaign level selection GUI

Reported by: wraitii Owned by: wraitii
Priority: Must Have Milestone: Alpha 25
Component: UI – Miscellaneous Keywords: patch
Cc: Patch: Phab:D11

Description (last modified by elexis)

Single players campaigns are one of the features we recently felt would be interesting to have for Part A. I have done some work on a github branch, and arrived to something usable, so I'm creating this ticket to get some comments (not necessarily a formal review yet).

Github branch: https://github.com/wraitii/0ad/tree/campaignMode For a readable clean diff, see attached patch, my branch is full of reversions and experiments.

Features are explained in detail in this post https://wildfiregames.com/forum/index.php?/topic/21369-single-player-campaigns/ Also refs #3049.

Basically: -adds a "campaigns" folder to public, with .json files specifying campaigns. -adds necessary GUI files, with a point of separating the interface logic (respectively in simple_campaign and simple_setup) so that this can be easily modded and we can provide several versions for campaigns to choose from -adds a "campaignsaves" folder to the user directory, saving campaign files as JSON -Hooks to session.js/summary.js/GuiInterface to send game data to the campaign state at the end of the game if necessary. -Provides campaign data to games at the start through a custom (and currently very ugly) gameosetup.

Overall the architecture is relatively simple. I'm only implementing simple lists for now. Also so far only scenarios are supported.

Design questions: -should maps only be supported in "maps/campaigns"? -it's slightly annoying that images have to be in art/textures/ui for sprites. -features?

As example, a fake "example" campaign is provided and I added a "tutorial" campaign but it's kind of empty.

Attachments (1)

campaign_V0.patch (66.7 KB ) - added by wraitii 7 years ago.

Download all attachments as: .zip

Change History (15)

by wraitii, 7 years ago

Attachment: campaign_V0.patch added

comment:1 by Vladislav Belov, 7 years ago

Forum returns "You do not have permission to view this content". So I'm not able to see the current feature list.

It's the most desired thing for players, I'm glad to see your patch. My thoughts (only basics, unless patch is unfinished):

  • campaign_io.json => campaign_filesystem.js. IO is any kind of data passing, even mb-ports, but the module only works with files: it loads and saves.
  • why DeleteGame and not just Delete (the same for DeleteCampaignGame)? Load, Save, Delete work with the same objects.
  • maybe prevent hard-coded paths in the js part?

Features:

  • co-op: 2-4 players play in campaigns
  • a data passing between maps: you've captured 10 enemy's units on the first map, you will have this 10 units on the next map.
  • select a campaign not in the list, i.e. on a real map (Europe or something like that).
Last edited 7 years ago by Vladislav Belov (previous) (diff)

comment:2 by wraitii, 7 years ago

Oh, right, that post is staff-only, sorry. Eh, not that important.

Your thoughts make sense. Re "DeleteGame", I've been reusing code from load/save so some of it is an artifact from that, I also don't want to risk running into name collisions (always an issue without modules). And the whole "save game vs campaign game" has me erring on the side of explicitness.

Regarding your features: -co-op is a gamester issue and I don't want to tackle it for now, but it shouldn't be impossible (this was one of leper's concerns in the thread above) -planned -don't understand

comment:3 by Lionkanzen, 7 years ago

The last may be the difference is list like AoE classic list vs a map like RTW 2 or AOK , represented in a map.

in reply to:  2 comment:4 by Vladislav Belov, 7 years ago

Replying to wraitii:

-don't understand

It's more the GUI feature, like @Lionkanzen said, and like this: http://www.selectbutton.com/webhook-uploads/1418609179182_04.jpg, when you're able to select the first place on the map, fight there, and the next place on the map is opening. (By nap I mean no the real 0ad map, but an image or art).

Last edited 7 years ago by Vladislav Belov (previous) (diff)

comment:5 by leper, 7 years ago

Different GUI interfaces for a specific campaign (or even a set of campaigns, in which case one should likely provide a button "other campaigns" which uses the simple list based display without the campaigns in the fancy GUI) can easily be added (new folder with XML and possibly some JS) and specified in the campaign.json file.

The dependency handling for a fancy GUI shouldn't need any extensions if it is only based on what maps have been finished. (That's the code using MatchClassesList.) If that isn't enough a way to handle that would be to allow a map to specify some condition which is just added to the set of finished maps.

A map like GUI might require some XML and graphics, but that is just work someone has to do if they want a fancy GUI. The simple list based one is meant as a fallback that works for most (or all, if you ignore ease of use when dependencies are complex and not explained) campaigns without modders having to create a GUI unless they want to. Most of the code unrelated to lists in the simple list GUI should not be part of that, but available to all possible GUIs (campaigns/common/).

Regarding MP campaigns that is explicitly out-of-scope for this ticket, but we did take some care to reduce artificial limitations (caused by the design) that would make extending this later on a lot harder. However there might be quite some issues we have missed, so in case you find something, please say so.

For passing data between maps there is some campaign specific data passed to each map, and some passed out which can/should be passed to the next map. So creating the same units on the next map should not be a problem and would just require some trigger code that stores templates, health, possibly some other data (upgrades, buffs, carried items) per player (to make possible MP campaigns easier) and another trigger that creates units on the next map based on the saved data. This data (and format) is ATM campaign specific, though we should probably provide a few helper functions/triggers to reduce the amount of work per campaign.

comment:6 by elexis, 7 years ago

Keywords: rfc removed

comment:7 by elexis, 7 years ago

Description: modified (diff)
Milestone: Work In ProgressAlpha 22
Priority: Should HaveMust Have

Once we have the framework, we can actually start making campaigns. Would be grat to be able to start after Alpha 22 with that.

comment:8 by elexis, 7 years ago

Milestone: Alpha 22Alpha 23

comment:9 by elexis, 6 years ago

Summary: [PATCH] Implement Single-Player (SP) campaigns[PATCH] Implement campaign level selection GUI

comment:10 by elexis, 6 years ago

Milestone: Alpha 23Backlog

comment:11 by elexis, 6 years ago

Milestone: BacklogAlpha 24
Patch: Phab:D11

The patch looked nearly acceptable to me last time I checked (even though it is only the first big patch of several things we need for good campaign support.)

comment:12 by Imarok, 5 years ago

Component: UI & SimulationMisc. UI

Move tickets to Misc. UI as "UI & Simulation" got some sub components.

comment:13 by wraitii, 3 years ago

Milestone: Alpha 24Alpha 25

Pushing to A25: we have no campaigns to show for it at the moment. The plan is to merge this early in A25's lifespan and get something out.

comment:14 by wraitii, 3 years ago

Resolution: fixed
Status: newclosed

In 24979:

Implement Single-Player campaigns - Barebones tutorial campaign included.

This implements necessary tooling to create a simple SP campaign.
The architecture is intended to be easily extensible in the future.

'Campaign Run' contains the metadata of a campaign, e.g. maps played/won. It's saved in the user folder under saves/campaigns/*.0adcampaign
Campaign templates are JSON files in campaigns/

Campaigns can specify which Menu interface they will use. This is intended to allow more complex layouts/presentation.
For now, a simple list interface is provided. This allows making campaigns without any fancy art required (and effectively mimics AoE1's campaign interface).

The behaviour on game end is also intended to be extensible, supporting things such as carrying over units between scenarios - for now, it simply records won games.

GameSetup is not available for now - scenarios are triggered with the settings defined in the map/default settings. Improving on this requires refactoring the gamesetup further.

The load/save game page has been extended slightly to support showing/hiding campaign games (campaign gamed are saved under saves/ directly, there is no strong motivation to do otherwise at this point)

Closes #4387

Differential Revision: https://code.wildfiregames.com/D11

Note: See TracTickets for help on using tickets.