17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-30 01:37:28 +01:00

fix(editor): the templates looked for in the background from the start, the panels don't wait for them

The include bank read every .inc of the scenery directory on the first use, on the main thread: opening the
switch panel or selecting a switch stopped the editor until all of them were read, which on a large scenery
directory under Windows takes long. The bank now starts looking as the editor starts, in the background,
and the main thread only reads the descriptions once the files are read.

- the switch drives, turntables and signals are read again from the bank when it changes; the panels show
  "Looking for the templates..." meanwhile, only the edits which need the templates wait for them
- the sweep tool takes the templates from the bank instead of looking through the scenery directory again
- a folder linked into one of its own subfolders no longer leads the walk in circles
- the log tells how many templates were found and how long it took
This commit is contained in:
maj00r
2026-10-19 16:21:55 +02:00
parent ff1710d9ea
commit 949965009b
12 changed files with 275 additions and 94 deletions

View File

@@ -114,12 +114,23 @@ struct include_entry
class editorIncludeBank
{
public:
// looks through the scenery directory for the templates, and reads their descriptions
void scan();
~editorIncludeBank();
// starts looking through the scenery directory for the templates in the background, unless they were found already
void start();
// looks through the scenery directory again in the background, for the templates added or changed outside of the editor
void rescan();
// takes the templates found in the background once the search is over; true if it took them
bool poll();
// waits for the templates being looked for, or looks for them if they weren't yet
void wait();
bool scanned() const
{
return m_scanned;
}
bool searching() const
{
return m_search != nullptr;
}
std::vector<include_entry> const &entries() const
{
return m_entries;
@@ -138,8 +149,11 @@ class editorIncludeBank
}
private:
struct search;
void index();
std::shared_ptr<search> m_search; // under way in the background
std::vector<include_entry> m_entries; // sorted by file name
std::vector<std::size_t> m_ready;
bool m_scanned{false};