Line data Source code
1 : package messagewindow
2 :
3 : import (
4 : "github.com/kijimaD/ruins/internal/messagedata"
5 : w "github.com/kijimaD/ruins/internal/world"
6 : )
7 :
8 : // choiceOption は選択肢を表す
9 : type choiceOption struct {
10 : Text string
11 : Action func() error // 選択時の処理
12 : }
13 :
14 : // messageContent はメッセージの内容
15 : type messageContent struct {
16 : Choices []choiceOption // 選択肢システム
17 : SpeakerName string // 話者名
18 : TextSegmentLines [][]messagedata.TextSegment // 行ごとの色付きテキストセグメント
19 : }
20 :
21 : // NewWindow はMessageDataからメッセージウィンドウを構築する
22 : func NewWindow(world w.World, initialMessage *messagedata.MessageData) *Window {
23 1 : window := &Window{
24 1 : config: defaultWindowConfig(),
25 1 : world: world,
26 1 : isOpen: true,
27 1 : queueManager: newQueueManager(),
28 1 : currentMessage: initialMessage,
29 1 : }
30 :
31 1 : window.updateContentFromMessage(initialMessage)
32 1 :
33 : // 連鎖メッセージがある場合はキューに追加
34 1 : if initialMessage.HasNextMessages() {
35 1 : window.queueManager.Enqueue(initialMessage.GetNextMessages()...)
36 1 : }
37 :
38 1 : return window
39 : }
|