74 lines
2.5 KiB
C++
74 lines
2.5 KiB
C++
|
/*
|
||
|
MIT License
|
||
|
Copyright (c) 2024 - 2025 René Amthor (tobid7)
|
||
|
|
||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||
|
of this software and associated documentation files (the "Software"), to deal
|
||
|
in the Software without restriction, including without limitation the rights
|
||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||
|
copies of the Software, and to permit persons to whom the Software is
|
||
|
furnished to do so, subject to the following conditions:
|
||
|
|
||
|
The above copyright notice and this permission notice shall be included in all
|
||
|
copies or substantial portions of the Software.
|
||
|
|
||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||
|
SOFTWARE.
|
||
|
*/
|
||
|
|
||
|
#include "pd/ui7/flags.hpp"
|
||
|
#include "pd/ui7/pd_p_api.hpp"
|
||
|
#include <pd/ui7/ui7.hpp>
|
||
|
|
||
|
namespace PD {
|
||
|
namespace UI7 {
|
||
|
PD_UI7_API std::string GetVersion(bool show_build) {
|
||
|
std::stringstream s;
|
||
|
s << ((UI7_VERSION >> 24) & 0xFF) << ".";
|
||
|
s << ((UI7_VERSION >> 16) & 0xFF) << ".";
|
||
|
s << ((UI7_VERSION >> 8) & 0xFF);
|
||
|
if (show_build)
|
||
|
s << "-" << ((UI7_VERSION) & 0xFF);
|
||
|
return s.str();
|
||
|
}
|
||
|
|
||
|
PD_UI7_API void Context::AddViewPort(const ID &id, const ivec4 &vp) {
|
||
|
pIO->AddViewPort(id, vp);
|
||
|
}
|
||
|
|
||
|
PD_UI7_API void Context::UseViewPort(const ID &id) {
|
||
|
if (!pIO->ViewPorts.count(id)) {
|
||
|
return;
|
||
|
}
|
||
|
pIO->CurrentViewPort = pIO->ViewPorts[id]->GetSize();
|
||
|
}
|
||
|
|
||
|
PD_UI7_API bool Context::BeginMenu(const ID &id, UI7MenuFlags flags,
|
||
|
bool *pShow) {
|
||
|
if (pCurrent) {
|
||
|
std::cout << "[UI7] Error: You are already in " << pCurrent->pID.GetName()
|
||
|
<< " Menu" << std::endl;
|
||
|
return false;
|
||
|
}
|
||
|
if (std::find(pCurrentMenus.begin(), pCurrentMenus.end(), (u32)id) !=
|
||
|
pCurrentMenus.end()) {
|
||
|
std::cout << "[UI7] Error: Menu " << id.GetName() << " already exists!"
|
||
|
<< std::endl;
|
||
|
return false;
|
||
|
}
|
||
|
pCurrent = pGetOrCreateMenu(id);
|
||
|
this->pCurrent->pIsShown = pShow;
|
||
|
this->pIO->InputHandler->CurrentMenu = id;
|
||
|
|
||
|
return pCurrent != nullptr;
|
||
|
}
|
||
|
|
||
|
PD_UI7_API void Context::Update() { pIO->Update(); }
|
||
|
} // namespace UI7
|
||
|
} // namespace PD
|