4 #include <SDL2/SDL_timer.h>
32 e->rootWindow->destroy();
48 primary->
renderer =
static_cast<CEGUI::OpenGL3Renderer*
>(CEGUI::System::getSingleton().getRenderer());
51 primary->
renderer = &CEGUI::OpenGL3Renderer::bootstrapSystem();
57 CEGUI::DefaultResourceProvider* rp =
static_cast<CEGUI::DefaultResourceProvider*
>(CEGUI::System::getSingleton().getResourceProvider());
60 rp->setResourceGroupDirectory(
"imagesets", resourceDirectory +
"/imagesets/");
61 rp->setResourceGroupDirectory(
"schemes", resourceDirectory +
"/schemes/");
62 rp->setResourceGroupDirectory(
"fonts", resourceDirectory +
"/fonts/");
63 rp->setResourceGroupDirectory(
"layouts", resourceDirectory +
"/layouts/");
64 rp->setResourceGroupDirectory(
"looknfeels", resourceDirectory +
"/looknfeel/");
65 rp->setResourceGroupDirectory(
"lua_scripts", resourceDirectory +
"/lua_scripts/");
68 CEGUI::ImageManager::setImagesetDefaultResourceGroup(
"imagesets");
69 CEGUI::Scheme::setDefaultResourceGroup(
"schemes");
70 CEGUI::Font::setDefaultResourceGroup(
"fonts");
71 CEGUI::WindowManager::setDefaultResourceGroup(
"layouts");
72 CEGUI::WidgetLookManager::setDefaultResourceGroup(
"looknfeels");
73 CEGUI::ScriptModule::setDefaultResourceGroup(
"lua_scripts");
77 primary->
context = &CEGUI::System::getSingleton().createGUIContext(primary->
renderer->getDefaultRenderTarget());
79 primary->
rootWindow = CEGUI::WindowManager::getSingleton().createWindow(
"DefaultWindow",
"root");
80 primary->
rootWindow->setSize(CEGUI::USize(cegui_reldim(1.0f), cegui_reldim(1.0f)));
81 primary->
rootWindow->setPosition(CEGUI::UVector2(cegui_reldim(0.0f), cegui_reldim(0.0f)));
89 for(
unsigned int i = 1; i < numContexts; i++) {
91 CEGUI::OpenGL3Renderer* secondaryRenderer = primary->
renderer;
94 CEGUI::GUIContext* secondaryContext = &CEGUI::System::getSingleton().createGUIContext(secondaryRenderer->getDefaultRenderTarget());
97 CEGUI::Window* secondaryRootWindow = CEGUI::WindowManager::getSingleton().createWindow(
"DefaultWindow",
"secondary_root_" + std::to_string(i-1));
98 secondaryRootWindow->setSize(CEGUI::USize(cegui_reldim(1.0f), cegui_reldim(1.0f)));
99 secondaryRootWindow->setPosition(CEGUI::UVector2(cegui_reldim(0.0f), cegui_reldim(0.0f)));
102 secondaryContext->setRootWindow(secondaryRootWindow);
106 secondary->
renderer = secondaryRenderer;
108 secondary->
context = secondaryContext;
115 for(
unsigned int i = 0; i <
m_contexts.size(); i++) {
117 CEGUI::System::getSingleton().destroyGUIContext(*
m_contexts[i]->context);
118 CEGUI::WindowManager::getSingleton().destroyWindow(
m_contexts[i]->rootWindow);
127 glDisable(GL_DEPTH_TEST);
129 glBindTexture(GL_TEXTURE_2D, 0);
131 glActiveTexture(GL_TEXTURE0);
142 glBindVertexArray(0);
144 glDisable(GL_SCISSOR_TEST);
147 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
149 glBindTexture(GL_TEXTURE_2D, 0);
154 unsigned int elapsed;
161 unsigned int nowTime = SDL_GetTicks();
167 for(
unsigned int i = 0; i <
m_contexts.size(); i++) {
169 m_contexts[i]->context->injectTimePulse((
float)elapsed / 1000.0f);
177 Logger::getInstance()->
log(
"WARNING: Access of CEGUI Context with index " + std::to_string(contextIndex) +
" was attempted. This context does not exist.",
true);
195 for(
unsigned int i = 0; i <
m_contexts.size(); i++) {
197 case SDL_MOUSEMOTION:
199 m_contexts[i]->context->injectMousePosition((
float)evnt.motion.x, (
float)evnt.motion.y);
209 case SDL_MOUSEBUTTONDOWN:
213 case SDL_MOUSEBUTTONUP:
219 m_contexts[i]->context->injectMouseWheelChange(evnt.wheel.y);
226 std::string evntText = std::string(evnt.text.text);
228 std::vector<int> utf32result;
230 utf8::utf8to32(evnt.text.text, evnt.text.text + evntText.size(), std::back_inserter(utf32result));
232 CEGUI::utf32 codePoint = (CEGUI::utf32)utf32result[0];
235 m_contexts[i]->context->injectChar(codePoint);
243 CEGUI::SchemeManager::getSingleton().createFromFile(schemeFile);
248 CEGUI::FontManager::getSingleton().createFromFile(fontFile +
".font");
250 for(
unsigned int i = 0; i <
m_contexts.size(); i++) {
251 m_contexts[i]->context->setDefaultFont(fontFile);
255 CEGUI::Window*
BARECEGUI::createWidget(std::string type, glm::vec4 destRectPercent, glm::vec4 destRectPixels, CEGUI::Window* parent, std::string name) {
257 CEGUI::Window* newWindow = CEGUI::WindowManager::getSingleton().createWindow(type, name);
259 newWindow->setPosition(CEGUI::UVector2(CEGUI::UDim(destRectPercent.x, destRectPixels.x), CEGUI::UDim(destRectPercent.y, destRectPixels.y)));
260 newWindow->setSize(CEGUI::USize(CEGUI::UDim(destRectPercent.z, destRectPixels.z), CEGUI::UDim(destRectPercent.w, destRectPixels.w)));
264 parent->addChild(newWindow);
284 using namespace CEGUI;
287 return Key::Backspace;
329 return Key::Semicolon;
332 case SDLK_LEFTBRACKET:
333 return Key::LeftBracket;
335 return Key::Backslash;
336 case SDLK_RIGHTBRACKET:
337 return Key::RightBracket;
396 case SDLK_KP_MULTIPLY:
397 return Key::Multiply;
399 return Key::Subtract;
403 return Key::NumpadEnter;
405 return Key::NumpadEquals;
409 return Key::ArrowDown;
411 return Key::ArrowRight;
413 return Key::ArrowLeft;
423 return Key::PageDown;
455 return Key::RightShift;
457 return Key::LeftShift;
459 return Key::RightControl;
461 return Key::LeftControl;
463 return Key::RightAlt;
479 case SDL_BUTTON_LEFT:
480 return CEGUI::MouseButton::LeftButton;
481 case SDL_BUTTON_MIDDLE:
482 return CEGUI::MouseButton::MiddleButton;
483 case SDL_BUTTON_RIGHT:
484 return CEGUI::MouseButton::RightButton;
486 return CEGUI::MouseButton::X1Button;
488 return CEGUI::MouseButton::X2Button;
490 return CEGUI::MouseButton::NoButton;