Skip to content

Stratkit Presentation Newspaper

This package is responsible for the presentation layer of the Newspaper feature.

Setup

  1. Create a ScriptableObject instance of NewspaperPresentationModule and add it to the BootstrapManager modules.
  2. Create a ScriptableObject instance of ArticleCollectionConfig and add it to the BootstrapManager configs.
  3. Create a ScriptableObject instance of every desired article (e.g. ProvinceCapturedArticleConfig) and link them in the newly created ArticleCollectionConfig.
  4. See Implementing Custom Localization Provider

Usage

Implementing new articles

Articles are currently divided into three parts:

Data

Contains all the information received from the backend regarding the article. e.g. Stratkit.NewspaperStateLoader.ProvinceCapturedArticledata. See the Stratkit Newspaper State Loader package documentation for more details.

Config

ScriptableObjects containing project-dependent configuration for the articles. e.g. ProvinceCapturedArticleConfig.

Presentation

Merges both Data and Config parts into a human-readable article that's ready to be displayed. e.g. ProvinceCapturedArticle.


To create a new article, implement the necessary Data, Config and Presentation classes and assign the Config ScriptableObject instance to the ArticleCollectionConfig.Articles property.

Implementing Custom Localization Provider

This package uses a INewspaperLocalizationProvider instance for localizing common terms for the newspaper articles, like army and province names. This instance needs to be implemented by the project when using this package. To provide custom localizations: - Create a new class inheriting from BaseNewspaperLocalizationProvider. - Create a new ScriptableObject instance from the new class. - Link the newly created ScriptableObject to the ArticleCollectionConfig.LocalizationProvider property.

Implementing Custom Article Merging Strategy

In Bytro's legacy games, the newspaper articles are merged together based on the players involved in it. This package provides a DefaultNewspaperArticleMerger ScriptableObject that replicates this behavior. To change this behavior: - Create a new class inheriting from BaseNewspaperArticleMerger. - Create a new ScriptableObject instance from the new class. - Link the newly created ScriptableObject to the ArticleCollectionConfig.ArticleMergingStrategy property.

Sample

This project comes with a sample Newspaper Screen that's able to display articles and request newspapers from past game days.

To see the sample in action, in addition to the package Setup, follow these steps: 1. Open Unity Package Manager, click this package and import the sample in the Samples tab. 2. Create and add the NewspaperPresentationSampleModule reference to the BootstrapManager modules. 3. Create and add the NewspaperReferenceContainer reference to the BootstrapManager config. 4. Reference the "NewspaperScreen" prefab in NewspaperReferenceContainer. 5. Open the Jahro Cheats menu and click the "Open Current Day Newspaper" button.