Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
music.h
Go to the documentation of this file.
1/*
2 * Copyright 2019 Twilight
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15*/
16#pragma once
17
18#include <QObject>
19#include <QJsonValue>
20#include <QVector>
21#include <QString>
22#include <QHash>
23
24#include <pse-common/types.h>
25#include "./db_autoport.h"
26
27struct MapDBEntry;
28class QQmlEngine;
29
39 MusicDBEntry();
40 MusicDBEntry(QJsonValue& data);
41
42 QString name;
43 var8 bank = 0;
44 var8 id = 0;
45
46 QVector<MapDBEntry*> toMaps;
47};
48
56class DB_AUTOPORT MusicDB : public QObject
57{
58 Q_OBJECT
59 Q_PROPERTY(int getStoreSize READ getStoreSize CONSTANT)
60
61public:
62 static MusicDB* inst();
63
64 [[nodiscard]] const QVector<MusicDBEntry*> getStore() const;
65 [[nodiscard]] const QHash<QString, MusicDBEntry*> getInd() const;
66 [[nodiscard]] int getStoreSize() const;
67
68 Q_INVOKABLE MusicDBEntry* getStoreAt(int idx) const;
69 Q_INVOKABLE MusicDBEntry* getIndAt(const QString& key) const;
70
71public slots:
72 void load();
73 void index();
74 void qmlProtect(const QQmlEngine* const engine) const;
75
76private slots:
77 void qmlRegister() const;
78
79private:
80 MusicDB();
81
82 QVector<MusicDBEntry*> store;
83 QHash<QString, MusicDBEntry*> ind;
84};
const QVector< MusicDBEntry * > getStore() const
All tracks.
Definition music.cpp:43
MusicDBEntry * getStoreAt(int idx) const
Track by store index (for QML).
Definition music.cpp:47
const QHash< QString, MusicDBEntry * > getInd() const
Name->entry index.
Definition music.cpp:44
void load()
Load tracks from JSON.
Definition music.cpp:58
int getStoreSize() const
Track count.
Definition music.cpp:45
void index()
Build the name->entry index.
Definition music.cpp:68
MusicDBEntry * getIndAt(const QString &key) const
Track by name key (for QML).
Definition music.cpp:53
static MusicDB * inst()
< Number of tracks.
Definition music.cpp:37
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
Definition music.cpp:79
Project-wide fixed-width integer aliases (var8, var16, ...).
var8e var8
Everyday 8-bit alias. Exact (not "fastest") to dodge the pointer-width bug noted above.
Definition types.h:124
Import/export macro for the db library, plus the central list of DB entry pointer types declared opaq...
#define DB_AUTOPORT
Expands to the correct dllexport/dllimport decoration for this library.
Definition db_autoport.h:37
One map's complete static definition – the root of the MapDBEntry family.
Definition mapdbentry.h:56
One music track: its name and bank/id, plus the maps that use it.
Definition music.h:38
QVector< MapDBEntry * > toMaps
Maps that play this track (back-ref, set by MapsDB).
Definition music.h:46
var8 bank
Audio bank.
Definition music.h:43
MusicDBEntry()
Empty entry.
Definition music.cpp:29
QString name
Track name (key).
Definition music.h:42