Line data Source code
1 : package systems
2 :
3 : import (
4 : "fmt"
5 : "image/color"
6 : "math"
7 :
8 : gc "github.com/kijimaD/ruins/internal/components"
9 : "github.com/kijimaD/ruins/internal/consts"
10 : "github.com/kijimaD/ruins/internal/gamelog"
11 : "github.com/kijimaD/ruins/internal/overworld"
12 : "github.com/kijimaD/ruins/internal/rawschema"
13 : "github.com/kijimaD/ruins/internal/render3d"
14 : "github.com/kijimaD/ruins/internal/widgets/hud"
15 : "github.com/kijimaD/ruins/internal/widgets/theme"
16 : w "github.com/kijimaD/ruins/internal/world"
17 :
18 : "github.com/kijimaD/ruins/internal/world/query"
19 : "github.com/mlange-42/ark/ecs"
20 : )
21 :
22 : // ExtractHUDData はworldから全てのHUDデータを抽出する
23 : func ExtractHUDData(world w.World) hud.Data {
24 : // メッセージエリアの高さは右下スタックと左下バッジの下端固定に共通で使う
25 1 : messageAreaHeight := hud.DefaultMessageAreaConfig.Height()
26 1 : return hud.Data{
27 1 : GameInfo: extractGameInfo(world, messageAreaHeight),
28 1 : MacroMap: extractMacroMapData(world),
29 1 : DebugOverlay: extractDebugOverlay(world),
30 1 : MessageData: extractMessageData(world, query.GetGameLog(world)),
31 1 : WeaponSlotsData: extractWeaponSlotsData(world),
32 1 : StatusBadgesData: extractStatusBadgesData(world, messageAreaHeight),
33 1 : }
34 : }
35 :
36 : // extractGameInfo はゲーム基本情報を抽出する。messageAreaHeight は右下スタックの下端固定に使う
37 : func extractGameInfo(world w.World, messageAreaHeight int) hud.GameInfoData {
38 1 : floorNumber := query.GetDungeon(world).CurrentStage.Depth
39 1 :
40 : // プレイヤー情報を抽出する
41 1 : var playerHP, playerMaxHP int
42 1 : var playerWeight, playerMaxWeight consts.Milligram
43 1 : var tempArrow hud.TemperatureArrow
44 1 : var bodyTempRatio float64
45 1 : var bodyTempVisible bool
46 1 : var ambientTemp int
47 1 : var ambientTempVisible bool
48 1 : var ambientTempColor color.RGBA
49 1 : var ambientShelterLabel string
50 1 : var currency consts.Currency
51 1 : playerQuery := ecs.NewFilter3[gc.Player, gc.HP, gc.WeightCapacity](world.ECS).Query()
52 1 : for playerQuery.Next() {
53 1 : entity := playerQuery.Entity()
54 1 : hp := world.Components.HP.Get(entity)
55 1 : cw := world.Components.WeightCapacity.Get(entity)
56 1 : currency = query.GetCurrency(world, entity)
57 1 : playerHP = hp.Current
58 1 : playerMaxHP = hp.Max
59 1 : playerWeight = cw.Current
60 1 : playerMaxWeight = cw.Max
61 1 : tempArrow = temperatureArrow(world, entity)
62 1 : if world.Components.HealthStatus.Has(entity) {
63 : // セーブ由来のオフセットはクランプ幅の外でありうるので、割合を 0..1 に収める
64 1 : offset := world.Components.HealthStatus.Get(entity).BodyTempOffset
65 1 : bodyTempRatio = math.Max(0, math.Min(1, (offset-bodyTempMin)/(bodyTempMax-bodyTempMin)))
66 1 : bodyTempVisible = true
67 1 : }
68 1 : if world.Components.GridElement.Has(entity) {
69 1 : grid := world.Components.GridElement.Get(entity)
70 1 : if temp, err := query.AmbientTemperatureAt(world, grid.X, grid.Y); err == nil {
71 1 : ambientTemp = temp
72 1 : ambientTempVisible = true
73 1 : ambientTempColor = ambientTempDisplayColor(temp)
74 1 : shelter, _ := query.TileEnvironmentAt(world, grid.X, grid.Y)
75 1 : ambientShelterLabel = query.ShelterName(world, shelter)
76 1 : }
77 : }
78 : }
79 :
80 : // 画面サイズを取得
81 1 : screenWidth, screenHeight := world.Resources.GetScreenDimensions()
82 1 :
83 1 : return hud.GameInfoData{
84 1 : FloorNumber: floorNumber,
85 1 : ShowFloor: !query.IsOnOverworld(world),
86 1 : PlayerHP: playerHP,
87 1 : PlayerMaxHP: playerMaxHP,
88 1 : PlayerWeight: playerWeight,
89 1 : PlayerMaxWeight: playerMaxWeight,
90 1 : TempArrow: tempArrow,
91 1 : BodyTempRatio: bodyTempRatio,
92 1 : BodyTempVisible: bodyTempVisible,
93 1 : AmbientTemp: ambientTemp,
94 1 : AmbientTempVisible: ambientTempVisible,
95 1 : AmbientTempColor: ambientTempColor,
96 1 : AmbientShelterLabel: ambientShelterLabel,
97 1 : WeatherName: query.WeatherName(world, query.GetWeather(world).Current),
98 1 : AreaLabel: areaLabel(world),
99 1 : MessageAreaHeight: messageAreaHeight,
100 1 : Currency: currency,
101 1 : ScreenDimensions: hud.ScreenDimensions{
102 1 : Width: screenWidth,
103 1 : Height: screenHeight,
104 1 : },
105 1 : }
106 : }
107 :
108 : // extractMacroMapData は右上のマクロ地図データを抽出する。オーバーワールドにいればプレイヤー近傍の
109 : // チャンク俯瞰モデルを組み、居なければ帯なしフラグだけ立ててウィジェットに地図を描かせない。
110 : func extractMacroMapData(world w.World) hud.MacroMapData {
111 1 : screen := hud.ScreenDimensions{
112 1 : Width: world.Resources.ScreenDimensions.Width,
113 1 : Height: world.Resources.ScreenDimensions.Height,
114 1 : }
115 1 : config := hud.MacroMapConfig{
116 1 : Width: consts.MacroMapWidth,
117 1 : Height: consts.MacroMapHeight,
118 1 : MinGlyphPx: consts.MacroMapMinGlyphPx,
119 1 : }
120 1 : sb := query.GetSeamlessBand(world)
121 1 : if sb == nil || !sb.Active {
122 1 : return hud.MacroMapData{HasBand: false, Config: config, Screen: screen}
123 1 : }
124 : // 近傍だけを大きく見せる。プレイヤーの絶対チャンク行を中心に表示範囲を取る。プレイヤー不在時は帯全体
125 1 : playerTile, hasPlayer := query.PlayerBandTile(world)
126 1 : area := overworld.FullBandRange(sb.NorthIndex, sb.Cols, sb.Rows)
127 1 : if hasPlayer {
128 1 : centerRow := sb.AbsChunkRow(playerTile.Y)
129 1 : area = overworld.PlayerCenteredRange(centerRow, sb.Cols, consts.MacroMapChunkRadius)
130 1 : }
131 : // 徐々に開くフォグ。探索済みチャンクだけを開放する。表示範囲・モデル・フォグは全画面図と共有する
132 1 : view := overworld.BuildMacroView(
133 1 : world.Resources.RawMaster, sb.RunSeed, sb.NorthIndex, sb.SpawnChunkY(), sb.ChunkW, sb.ChunkH,
134 1 : area, playerTile, hasPlayer, query.CubeTiles(world), query.DiscoveredChunks(world, sb),
135 1 : )
136 1 : // カメラ不在時は北を既定にする
137 1 : var facing gc.Orient
138 1 : if cam := query.GetPlayerCamera(world); cam != nil {
139 1 : facing = cam.Orient
140 1 : }
141 1 : return hud.MacroMapData{HasBand: true, View: view, PlayerFacing: facing, Config: config, Screen: screen, Cube: extractCubeStatus(world)}
142 : }
143 :
144 : // extractCubeStatus は地図の下に出すキューブの欄を抽出する。キューブが現ステージにいなければ出さない。
145 : func extractCubeStatus(world w.World) hud.CubeStatusData {
146 1 : cube, ok := query.ActiveCube(world)
147 1 : if !ok {
148 0 : return hud.CubeStatusData{}
149 0 : }
150 1 : return hud.CubeStatusData{
151 1 : Visible: true,
152 1 : Name: query.GetEntityName(cube, world),
153 1 : FuelRatio: query.FuelGaugeRatio(*world.Components.FuelTank.Get(cube)),
154 1 : }
155 : }
156 :
157 : // extractDebugOverlay はデバッグオーバーレイデータを抽出する
158 : func extractDebugOverlay(world w.World) hud.DebugOverlayData {
159 1 : if !world.Resources.Config.ShowAIDebug {
160 1 : return hud.DebugOverlayData{Enabled: false}
161 1 : }
162 :
163 1 : screenDimensions := hud.ScreenDimensions{
164 1 : Width: world.Resources.ScreenDimensions.Width,
165 1 : Height: world.Resources.ScreenDimensions.Height,
166 1 : }
167 : // 世界を描くのと同じ投影を使う。デバッグ表示だけ別の変換に取り残すと、
168 : // それを手本にして古い変換が新しい箇所へ広がる。
169 : // このデバッグ抽出は error を返せないので、投影が組めなければ表示を諦める
170 1 : projector, err := render3d.WorldProjector(world)
171 1 : if err != nil {
172 0 : return hud.DebugOverlayData{Enabled: false}
173 0 : }
174 :
175 : // AI状態情報と視界範囲情報を抽出
176 1 : var aiStates []hud.AIStateInfo
177 1 : var visionRanges []hud.VisionRangeInfo
178 1 : soloAIQuery := query.ActiveFilter2[gc.GridElement, gc.SoloAI](world).Query()
179 1 : for soloAIQuery.Next() {
180 1 : entity := soloAIQuery.Entity()
181 1 : gridElement := world.Components.GridElement.Get(entity)
182 1 : solo := world.Components.SoloAI.Get(entity)
183 1 :
184 1 : screen, ok := projector.BillboardTop(gridElement.Coord)
185 1 : if !ok {
186 0 : continue
187 : }
188 :
189 1 : var stateText string
190 1 : switch solo.SubState {
191 : case gc.AIStateWaiting:
192 0 : stateText = "WAITING"
193 : case gc.AIStateDriving:
194 0 : stateText = "ROAMING"
195 : case gc.AIStateChasing:
196 1 : stateText = "CHASING"
197 : case gc.AIStateFleeing:
198 0 : stateText = "FLEEING"
199 : default:
200 0 : stateText = "UNKNOWN"
201 : }
202 1 : aiStates = append(aiStates, hud.AIStateInfo{
203 1 : Screen: screen,
204 1 : StateText: stateText,
205 1 : })
206 1 :
207 : // 視界円の半径は、足元から視界距離だけ離れたタイルまでの画面上の距離で表す
208 1 : scaledRadius := float32(0)
209 1 : if base, okBase := projector.TileCenter(gridElement.Coord, 0); okBase {
210 1 : edge := gridElement.Add(consts.Coord[consts.Tile]{X: solo.ViewDistance})
211 1 : if far, okFar := projector.TileCenter(edge, 0); okFar {
212 1 : scaledRadius = float32(math.Abs(float64(far.X - base.X)))
213 1 : }
214 : }
215 1 : visionRanges = append(visionRanges, hud.VisionRangeInfo{
216 1 : Screen: screen,
217 1 : ScaledRadius: scaledRadius,
218 1 : })
219 : }
220 :
221 : // HP表示情報を抽出(プレイヤー以外のHPを持つエンティティ)
222 1 : var hpDisplays []hud.HPDisplayInfo
223 1 : hpDisplayQuery := query.ActiveFilter2[gc.GridElement, gc.HP](world).Query()
224 1 : for hpDisplayQuery.Next() {
225 1 : entity := hpDisplayQuery.Entity()
226 1 : // プレイヤーは除外
227 1 : if world.Components.Player.Has(entity) {
228 1 : continue
229 : }
230 :
231 1 : gridElement := world.Components.GridElement.Get(entity)
232 1 : hp := world.Components.HP.Get(entity)
233 1 :
234 : // エンティティ名を取得(デバッグ用)
235 1 : var entityName string
236 1 : if nameComp := world.Components.Name.Get(entity); nameComp != nil {
237 1 : entityName = string(nameComp.Name)
238 1 : } else {
239 0 : entityName = "Unknown"
240 0 : }
241 :
242 1 : screen, ok := projector.BillboardTop(gridElement.Coord)
243 1 : if !ok {
244 0 : continue
245 : }
246 :
247 1 : hpDisplays = append(hpDisplays, hud.HPDisplayInfo{
248 1 : Screen: screen,
249 1 : CurrentHP: hp.Current,
250 1 : MaxHP: hp.Max,
251 1 : EntityName: entityName,
252 1 : })
253 : }
254 :
255 1 : return hud.DebugOverlayData{
256 1 : Enabled: true,
257 1 : AIStates: aiStates,
258 1 : VisionRanges: visionRanges,
259 1 : HPDisplays: hpDisplays,
260 1 : ScreenDimensions: screenDimensions,
261 1 : }
262 : }
263 :
264 : // extractMessageData はメッセージデータを抽出する
265 : func extractMessageData(world w.World, store *gamelog.SafeSlice) hud.MessageData {
266 1 : screenDimensions := hud.ScreenDimensions{
267 1 : Width: world.Resources.ScreenDimensions.Width,
268 1 : Height: world.Resources.ScreenDimensions.Height,
269 1 : }
270 :
271 : // デフォルト設定を使用
272 1 : config := hud.DefaultMessageAreaConfig
273 1 :
274 1 : return hud.MessageData{
275 1 : Messages: store.GetHistory(),
276 1 : ScreenDimensions: screenDimensions,
277 1 : Config: config,
278 1 : }
279 : }
280 :
281 : // extractWeaponSlotsData は武器スロットデータを抽出する
282 : func extractWeaponSlotsData(world w.World) hud.WeaponSlotsData {
283 1 : screenDimensions := hud.ScreenDimensions{
284 1 : Width: world.Resources.ScreenDimensions.Width,
285 1 : Height: world.Resources.ScreenDimensions.Height,
286 1 : }
287 :
288 1 : var slots []hud.WeaponSlotInfo
289 1 : var selectedSlot int
290 1 :
291 : // プレイヤーの武器スロット情報を取得
292 1 : query.Player(world, func(playerEntity ecs.Entity) {
293 1 : weapons := query.GetWeapons(world, playerEntity)
294 1 :
295 : // 5つの武器スロット情報を作成
296 1 : for i := range 5 {
297 1 : slotNumber := gc.EquipmentSlotNumber(int(gc.SlotWeapon1) + i)
298 1 : weapon := weapons[i]
299 1 :
300 1 : var weaponName string
301 1 : var spriteSheet, spriteName string
302 1 :
303 1 : if weapon != nil {
304 : // 武器名を取得
305 1 : if nameComp := world.Components.Name.Get(*weapon); nameComp != nil {
306 1 : weaponName = query.T(world, nameComp.Name)
307 1 : } else {
308 0 : weaponName = "???"
309 0 : }
310 :
311 : // スプライト情報を取得
312 1 : if spriteRender := world.Components.SpriteRender.Get(*weapon); spriteRender != nil {
313 1 : spriteSheet = spriteRender.SpriteSheetName
314 1 : spriteName = spriteRender.SpriteKey
315 1 : }
316 : }
317 :
318 1 : slots = append(slots, hud.WeaponSlotInfo{
319 1 : SlotNumber: slotNumber,
320 1 : WeaponName: weaponName,
321 1 : SpriteSheet: spriteSheet,
322 1 : SpriteName: spriteName,
323 1 : })
324 : }
325 :
326 : // 現在選択中のスロット(1-5)を0ベース配列インデックスに変換
327 1 : selectedSlot = query.GetWeaponSelection(world).Slot - 1
328 : })
329 :
330 1 : return hud.WeaponSlotsData{
331 1 : Slots: slots,
332 1 : SelectedSlot: selectedSlot,
333 1 : ScreenDimensions: screenDimensions,
334 1 : }
335 : }
336 :
337 : // extractStatusBadgesData はステータスバッジデータを抽出する
338 : func extractStatusBadgesData(world w.World, messageAreaHeight int) hud.StatusBadgesData {
339 1 : var badges []hud.StatusBadge
340 1 :
341 1 : hungerQuery := ecs.NewFilter2[gc.Player, gc.Hunger](world.ECS).Query()
342 1 : for hungerQuery.Next() {
343 1 : entity := hungerQuery.Entity()
344 1 : if hunger := world.Components.Hunger.Get(entity); hunger != nil {
345 1 : level := hunger.GetLevel(world.Resources.NeedDefs)
346 1 : if stage, _ := world.Resources.NeedDefs.HungerStageOf(level); stage.Badge != nil {
347 1 : badges = append(badges, hud.StatusBadge{
348 1 : Text: query.HungerName(world, level),
349 1 : Color: *stage.Badge,
350 1 : })
351 1 : }
352 : }
353 : }
354 :
355 1 : fatigueQuery := ecs.NewFilter2[gc.Player, gc.Fatigue](world.ECS).Query()
356 1 : for fatigueQuery.Next() {
357 0 : entity := fatigueQuery.Entity()
358 0 : level := world.Components.Fatigue.Get(entity).GetLevel(world.Resources.NeedDefs)
359 0 : if stage, _ := world.Resources.NeedDefs.FatigueStageOf(level); stage.Badge != nil {
360 0 : badges = append(badges, hud.StatusBadge{
361 0 : Text: query.FatigueName(world, level),
362 0 : Color: *stage.Badge,
363 0 : })
364 0 : }
365 : }
366 :
367 : // プレイヤーの体温バッジと不調バッジ。同じ Player+HealthStatus を1度だけ走査する。
368 : // 低体温は体温バッジが担うので不調バッジには重複させない
369 1 : healthQuery := ecs.NewFilter2[gc.Player, gc.HealthStatus](world.ECS).Query()
370 1 : for healthQuery.Next() {
371 1 : entity := healthQuery.Entity()
372 1 : if badge, ok := temperatureStateBadge(world, entity); ok {
373 1 : badges = append(badges, badge)
374 1 : }
375 1 : badges = append(badges, conditionBadges(world, world.Components.HealthStatus.Get(entity))...)
376 : }
377 :
378 : // 画面サイズを取得
379 1 : screenWidth, screenHeight := world.Resources.GetScreenDimensions()
380 1 :
381 1 : return hud.StatusBadgesData{
382 1 : Badges: badges,
383 1 : MessageAreaHeight: messageAreaHeight,
384 1 : ScreenDimensions: hud.ScreenDimensions{
385 1 : Width: screenWidth,
386 1 : Height: screenHeight,
387 1 : },
388 1 : }
389 : }
390 :
391 : // conditionBadges は低体温を除く不調を種類ごとに1つのバッジへまとめる。最も重い重症度を示し、
392 : // 複数の部位にあれば部位の数を添える。並びは部位を順に見て最初に現れた順
393 : func conditionBadges(world w.World, hs *gc.HealthStatus) []hud.StatusBadge {
394 1 : type summary struct {
395 1 : worst gc.Severity
396 1 : count int
397 1 : }
398 1 : cold := world.Resources.ConditionDefs.ByOnset(rawschema.Cold)
399 1 : var order []gc.ConditionType
400 1 : byType := map[gc.ConditionType]*summary{}
401 1 : for i := range hs.Parts {
402 1 : for j := range hs.Parts[i].Conditions {
403 1 : c := &hs.Parts[i].Conditions[j]
404 1 : if !c.IsActive() || c.Type == cold {
405 1 : continue
406 : }
407 1 : s, ok := byType[c.Type]
408 1 : if !ok {
409 1 : s = &summary{}
410 1 : byType[c.Type] = s
411 1 : order = append(order, c.Type)
412 1 : }
413 1 : s.count++
414 1 : if c.Severity > s.worst {
415 1 : s.worst = c.Severity
416 1 : }
417 : }
418 : }
419 1 : badges := make([]hud.StatusBadge, 0, len(order))
420 1 : for _, ct := range order {
421 1 : s := byType[ct]
422 1 : text := conditionLabel(world, ct, s.worst)
423 1 : if s.count > 1 {
424 1 : text += fmt.Sprintf(" ×%d", s.count)
425 1 : }
426 1 : badges = append(badges, hud.StatusBadge{Text: text, Color: color.RGBA{200, 80, 70, 255}})
427 : }
428 1 : return badges
429 : }
430 :
431 : // conditionLabel は状態の種類と重症度を現在言語で並べた表示名を返す。重症度が無ければ種類だけ
432 : func conditionLabel(world w.World, ct gc.ConditionType, severity gc.Severity) string {
433 1 : name := query.ConditionName(world, ct)
434 1 : if severity == gc.SeverityNone {
435 0 : return name
436 0 : }
437 1 : return name + " " + query.T(world, severity.Name())
438 : }
439 :
440 : // ambientTempDisplayColor は周囲気温の表示色を返す。快適帯の中は白、下回ると青、上回ると赤に寄せる
441 : func ambientTempDisplayColor(temp int) color.RGBA {
442 1 : switch {
443 : case temp < query.ComfortableTempLower:
444 1 : return color.RGBA{150, 190, 255, 255}
445 : case temp > query.ComfortableTempUpper:
446 1 : return color.RGBA{255, 170, 120, 255}
447 : }
448 1 : return color.RGBA{255, 255, 255, 255}
449 : }
450 :
451 : // temperatureSteadyThreshold はこれ以下の変化量を一定とみなし、矢印を出さない境界
452 : const temperatureSteadyThreshold = 0.05
453 :
454 : // temperatureIntensityMax は矢印の色が最も濃くなる変化量
455 : const temperatureIntensityMax = 0.5
456 :
457 : // temperatureStateBadge はプレイヤーの体温状態バッジを返す。低体温の状態があるとき ok=true。
458 : // 表示名で状態と重症度を、色で寒さを示す。変化の向きは矢印が別に担う
459 : func temperatureStateBadge(world w.World, entity ecs.Entity) (hud.StatusBadge, bool) {
460 1 : hs := world.Components.HealthStatus.Get(entity)
461 1 : part := &hs.Parts[gc.BodyPartWholeBody]
462 1 : if cold := part.GetCondition(world.Resources.ConditionDefs.ByOnset(rawschema.Cold)); cold != nil {
463 1 : return hud.StatusBadge{Text: conditionLabel(world, cold.Type, cold.Severity), Color: color.RGBA{80, 140, 235, 255}}, true
464 1 : }
465 1 : return hud.StatusBadge{}, false
466 : }
467 :
468 : // temperatureArrow はプレイヤーの体温変化の矢印を返す。体温がほぼ変わらないときは出さない。
469 : // 温まると赤の上向き、冷えると青の下向き。色の濃さが変化の速さ。
470 : // 変化は実処理と同じ bodyTempRate を読むので、環境が変われば即座に反映される
471 : func temperatureArrow(world w.World, entity ecs.Entity) hud.TemperatureArrow {
472 1 : if !world.Components.HealthStatus.Has(entity) {
473 1 : return hud.TemperatureArrow{}
474 1 : }
475 :
476 1 : delta := bodyTempRate(world, entity)
477 1 :
478 1 : var dir hud.TempDirection
479 1 : switch {
480 : case delta > temperatureSteadyThreshold:
481 1 : dir = hud.TempDirectionUp
482 : case delta < -temperatureSteadyThreshold:
483 1 : dir = hud.TempDirectionDown
484 : default:
485 1 : return hud.TemperatureArrow{}
486 : }
487 1 : return hud.TemperatureArrow{Visible: true, Direction: dir, Color: temperatureDirectionColor(dir, delta)}
488 : }
489 :
490 : // temperatureDirectionColor は変化の向きと速さの色を返す。温まると赤、冷えると青。変化が速いほど濃い
491 : func temperatureDirectionColor(dir hud.TempDirection, delta float64) color.RGBA {
492 1 : intensity := math.Min(math.Abs(delta)/temperatureIntensityMax, 1.0)
493 1 : if dir == hud.TempDirectionUp {
494 1 : return theme.LerpColor(color.RGBA{255, 170, 120, 255}, color.RGBA{230, 50, 40, 255}, intensity)
495 1 : }
496 1 : return theme.LerpColor(color.RGBA{150, 190, 255, 255}, color.RGBA{40, 90, 230, 255}, intensity)
497 : }
498 :
499 : // areaLabel は地上の現在地を「エリア名 / 建物名」で返す。建物が無ければエリア名だけ、地上でなければ空
500 : func areaLabel(world w.World) string {
501 1 : area, ok := overworld.PlayerArea(world)
502 1 : if !ok {
503 1 : return ""
504 1 : }
505 1 : return formatAreaLabel(world, area)
506 : }
507 :
508 : // formatAreaLabel はエリアを「エリア名 / 建物名」に訳して組む。建物が無ければエリア名だけ
509 : func formatAreaLabel(world w.World, area overworld.Area) string {
510 1 : if area.Name == "" {
511 0 : return ""
512 0 : }
513 1 : label := query.T(world, area.Name)
514 1 : if area.Building != "" {
515 1 : label += " / " + query.T(world, area.Building)
516 1 : }
517 1 : return label
518 : }
|