#include "newWorld.hpp" #include "game.hpp" #include "mainMenu.hpp" #include "button.hpp" #include "entry.hpp" bool newWorld::game=false; bool newWorld::goBack=false; Button newWorld::createButton; Button newWorld::goBackButton; entry newWorld::worldNameEntry; newWorld::newWorld(GLFWwindow* win){ createButton = Button("Create World", 0, -0.5,0.5,0.25); goBackButton = Button("Go back", -0.5, 0.5, 0.5, 0.25); worldNameEntry = entry(win,-0.5,-0.25,1.0,0.5); worldNameEntry.select(win); //glfwSetWindowUserPointer(win, &worldNameEntry); //glfwSetWindowUserPointer(win, this); //glfwSetCharCallback(win, entry_character_callback); glfwSetMouseButtonCallback(win,MousePressed); game = false; goBack = false; } void newWorld::MousePressed(GLFWwindow* win, int mouse_button, int action, int _){ if(action==GLFW_PRESS && mouse_button==0){ if(createButton.hovering) game=true; if(goBackButton.hovering) goBack=true; } } Control* newWorld::handle(GLFWwindow* win){ if(game){ return(new Game(win,"worlds/"+worldNameEntry.text)); } if(goBack)return(new mainMenu(win)); goBackButton.handle(win); createButton.handle(win); worldNameEntry.handle(win); return NULL; } void newWorld::draw(float screenRatio){ createButton.Draw(screenRatio); goBackButton.Draw(screenRatio); worldNameEntry.Draw(screenRatio); } void newWorld::shutdown(){}