Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
names.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2020 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
21
22#include <QQmlEngine>
23#include <pse-common/utility.h>
24#include "names.h"
25
28
30{
31 static Names* _inst = new Names;
32 return _inst;
33}
34
36{
37 return NamesPlayer::inst();
38}
39
41{
42 return NamesPokemon::inst();
43}
44
45void Names::qmlProtect(const QQmlEngine* const engine) const
46{
47 Utility::qmlProtectUtil(this, engine);
48
51}
52
53void Names::qmlRegister() const
54{
55 static bool once = false;
56 if(once)
57 return;
58
59 qmlRegisterUncreatableType<Names>("PSE.DB.Names", 1, 0, "Names", "Can't instantiate in QML");
60 once = true;
61}
62
63Names::Names()
64{
65 qmlRegister();
66
69}
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
Random player-name source (an AbstractRandomString of player names).
Definition namesplayer.h:34
static NamesPlayer * inst()
The process-wide NamesPlayer singleton.
Random Pokemon-nickname source (an AbstractRandomString of names).
static NamesPokemon * inst()
The process-wide NamesPokemon singleton.
NamesPlayer * player() const
The player-name source (backs player).
Definition names.cpp:35
NamesPokemon * pokemon() const
The Pokemon-name source (backs pokemon).
Definition names.cpp:40
static Names * inst()
< Random player-name source.
Definition names.cpp:29
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
Definition names.cpp:45
static void qmlProtectUtil(const QObject *const obj, const QQmlEngine *const engine)
Pin obj to C++ ownership so the QML engine never garbage-collects it.
Definition utility.cpp:63