Ven0maus / SOD.Common

A common library for shadows of doubt modding.
MIT License
4 stars 4 forks source link

[FEATURE] UI utilities for tutorial-like dialog windows #7

Open ReveredRedHood opened 8 months ago

ReveredRedHood commented 8 months ago

Introduction Add UI utilities that show in-game dialog windows. These should be similar to the prompts seen during the tutorial section of the game.

Description of the feature image image image

Feature usage Would provide a basic method for mod authors to get input from the player. One example is when a mod needs to get the player's confirmation before doing something. Another would be when a mod needs to show the player a message that is worth pausing the game for (when GameMessage.Broadcast isn't enough).

Dependencies and Prerequisites Does this feature require any new dependencies? No.

Implementation details My gut feeling is that it is going to be difficult to use the game's tutorial dialog system for this... that code is probably coupled to the "case" and "objectives" systems. We'll probably have to create a hacky solution using the game's interface system.

Two possible approaches below, but we can discuss other ideas also.

// Idea 1: Create dialog objects
var dlg = new Dialog("Title", "Question");
var noBtn = dlg.AddResponse(buttonText: "No", Dialog.LeftButtonPosition);
var yesBtn = dlg.AddResponse(buttonText: "Yes", Dialog.RightButtonPosition);
noBtn.OnClicked += SomeAction;
Lib.Interface.ShowDialog(dialog: dlg, pauseWhileShowing: true, destroyAfterResponse: true);
// Idea 2: Create one helper function that handles everything
ShowDialog(string title, string question, string leftButtonText, Action leftButtonClicked, string centerButtonText, Action ...)

Note: Not a priority for v1.1.0

Ven0maus commented 8 months ago

Should also look into: PopupMessageController.PopupMessage