• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

MeltyPlayer / MeltyTool / 23081715917

14 Mar 2026 05:48AM UTC coverage: 41.461% (-0.04%) from 41.505%
23081715917

push

github

MeltyPlayer
Loaded textures with Labyrinth models.

7012 of 18984 branches covered (36.94%)

Branch coverage included in aggregate %.

0 of 76 new or added lines in 2 files covered. (0.0%)

1 existing line in 1 file now uncovered.

29943 of 70148 relevant lines covered (42.69%)

62237.52 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/FinModelUtility/Games/TheLabyrinthPlusEdition/TheLabyrinthPlusEdition/src/api/ScbModelImporter.cs
1
using System.Numerics;
2

3
using fin.data.dictionaries;
4
using fin.io;
5
using fin.model;
6
using fin.model.impl;
7
using fin.model.io;
8
using fin.model.io.importers;
9
using fin.model.util;
10
using fin.util.sets;
11
using fin.util.strings;
12

13
using schema.text.reader;
14

15
using tlpe.scb;
16

17
namespace tlpe.api;
18

NEW
19
public sealed record ScbModelFileBundle(
×
NEW
20
    IReadOnlyTreeFile ScbFile,
×
NEW
21
    IReadOnlyTreeFile BallsFile,
×
NEW
22
    IReadOnlyTreeDirectory TexturesDir)
×
23
    : IModelFileBundle {
24
  public IReadOnlyTreeFile MainFile => this.ScbFile;
×
25
}
26

27
public sealed class ScbModelImporter : IModelImporter<ScbModelFileBundle> {
28
  public IModel Import(ScbModelFileBundle fileBundle) {
×
29
    var scb = fileBundle.ScbFile.ReadNew<Scb>();
×
30

31
    var files = fileBundle.ScbFile.AsFileSet();
×
32
    var finModel = new ModelImpl {
×
33
        FileBundle = fileBundle,
×
34
        Files = files
×
35
    };
×
36

NEW
37
    var allBallAttributes = ReadAllBallAttributes_(fileBundle.BallsFile);
×
NEW
38
    var ballAttributesByGeometry
×
NEW
39
        = allBallAttributes
×
NEW
40
          .Where(a => a.Geometry != null)
×
NEW
41
          .ToListDictionary(a => a.Geometry!.ToLower());
×
42

NEW
43
    var textureFiles = new List<IReadOnlyTreeFile>();
×
NEW
44
    if (ballAttributesByGeometry.TryGetList(
×
NEW
45
            fileBundle.ScbFile.Name.ToString().ToLower(),
×
NEW
46
            out var matchingBallAttributes)) {
×
NEW
47
      foreach (var ballAttributes in matchingBallAttributes) {
×
NEW
48
        if (ballAttributes.Texture != null) {
×
NEW
49
          var textureFile = fileBundle.TexturesDir.AssertGetExistingFile(
×
NEW
50
              ballAttributes.Texture);
×
NEW
51
          textureFiles.Add(textureFile);
×
NEW
52
        }
×
NEW
53
      }
×
NEW
54
    }
×
55

NEW
56
    IMaterial[] textureMaterials
×
NEW
57
        = textureFiles
×
NEW
58
          .Select(textureFile => {
×
NEW
59
            (var finMaterial, _)
×
NEW
60
                = finModel.MaterialManager.AddSimpleTextureMaterialFromFile(
×
NEW
61
                    textureFile);
×
NEW
62
            return finMaterial;
×
NEW
63
          })
×
NEW
64
          .ToArray();
×
65

NEW
66
    var finMaterial = textureMaterials.Length > 0
×
NEW
67
        ? textureMaterials[0]
×
NEW
68
        : finModel.MaterialManager.AddNullMaterial();
×
69

UNCOV
70
    var finSkin = finModel.Skin;
×
71

72
    foreach (var scbSection in scb.Sections) {
×
73
      switch (scbSection) {
×
74
        case MeshSection meshSection: {
×
75
          var finMesh = finSkin.AddMesh();
×
76

77
          var finVertices
×
78
              = meshSection
×
79
                .Vertices.Select(v => {
×
80
                  var finVertex = finSkin.AddVertex(v.Position);
×
81
                  finVertex.SetLocalNormal(v.Normal);
×
82
                  finVertex.SetUv(0, v.Uv0);
×
83
                  finVertex.SetUv(1, v.Uv1);
×
84
                  return finVertex;
×
85
                })
×
86
                .ToArray();
×
87

88
          var triangles
×
89
              = meshSection
×
90
                .Faces.Select(f => {
×
91
                  var v0 = (IReadOnlyVertex) finVertices[f.Vertex0];
×
92
                  var v1 = (IReadOnlyVertex) finVertices[f.Vertex1];
×
93
                  var v2 = (IReadOnlyVertex) finVertices[f.Vertex2];
×
94

×
95
                  return (v0, v1, v2);
×
96
                })
×
97
                .ToArray();
×
98

NEW
99
          var finPrimitive = finMesh.AddTriangles(triangles);
×
NEW
100
          finPrimitive.SetMaterial(finMaterial);
×
101

102
          break;
×
103
        }
104
      }
105
    }
×
106

107
    return finModel;
×
108
  }
×
109

110
  private class BallAttributes {
NEW
111
    public string Id { get; set; }
×
NEW
112
    public string? Geometry { get; set; }
×
NEW
113
    public string? Texture { get; set; }
×
NEW
114
    public bool MapFromFile { get; set; }
×
NEW
115
    public bool NoEnvMap { get; set; }
×
116
  }
117

118
  private static IList<BallAttributes> ReadAllBallAttributes_(
NEW
119
      IReadOnlyTreeFile file) {
×
NEW
120
    using var tr = new SchemaTextReader(file.OpenRead());
×
121

NEW
122
    var allAttributes = new List<BallAttributes>();
×
123

NEW
124
    BallAttributes currentAttributes = default!;
×
NEW
125
    while (!tr.Eof) {
×
NEW
126
      var line = tr.ReadLine().Trim();
×
127

NEW
128
      if (line.StartsWith('[')) {
×
NEW
129
        var id = line[1..].SubstringUpTo(']');
×
NEW
130
        currentAttributes = new BallAttributes { Id = id };
×
NEW
131
        allAttributes.Add(currentAttributes);
×
NEW
132
      } else {
×
NEW
133
        var equalsParts = line.Split('=');
×
NEW
134
        if (equalsParts.Length > 1) {
×
NEW
135
          var before = equalsParts[0].Trim();
×
NEW
136
          var after = equalsParts[1].Trim();
×
137

NEW
138
          switch (before) {
×
NEW
139
            case "Geometry": {
×
NEW
140
              currentAttributes.Geometry = after;
×
NEW
141
              break;
×
142
            }
NEW
143
            case "MapFromFile": {
×
NEW
144
              currentAttributes.MapFromFile = after == "1";
×
NEW
145
              break;
×
146
            }
NEW
147
            case "NoEnvMap": {
×
NEW
148
              currentAttributes.NoEnvMap = after == "1";
×
NEW
149
              break;
×
150
            }
NEW
151
            case "Texture": {
×
NEW
152
              currentAttributes.Texture = after;
×
NEW
153
              break;
×
154
            }
155
          }
NEW
156
        }
×
NEW
157
      }
×
NEW
158
    }
×
159

NEW
160
    return allAttributes;
×
NEW
161
  }
×
162
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc