added cursor and textinputnode in shell
This commit is contained in:
parent
e2b27c8835
commit
8d3b0b527c
@ -93,7 +93,7 @@ void Engine::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update Scene
|
// update Scene
|
||||||
m_scene->update();
|
getScene()->update();
|
||||||
|
|
||||||
// update Display
|
// update Display
|
||||||
if(m_input->isResized())
|
if(m_input->isResized())
|
||||||
@ -105,8 +105,6 @@ void Engine::update()
|
|||||||
void Engine::start()
|
void Engine::start()
|
||||||
{
|
{
|
||||||
m_running = true;
|
m_running = true;
|
||||||
// for(int i = 0;i<5;i++)
|
|
||||||
// m_sparrowshell->scrollUp();
|
|
||||||
while(!m_input->isCloseRequested() && m_running)
|
while(!m_input->isCloseRequested() && m_running)
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@ -126,20 +124,30 @@ unsigned int Engine::getDeltaTime() const
|
|||||||
return m_timeStamp - m_lastTimeStamp;
|
return m_timeStamp - m_lastTimeStamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::setScene(SceneTree *scene)
|
//void Engine::setScene(SceneTree *scene)
|
||||||
|
void Engine::setScene(std::string scene)
|
||||||
{
|
{
|
||||||
|
if(m_current_scene.empty()){
|
||||||
|
m_current_scene = scene;
|
||||||
|
}
|
||||||
|
SceneTree* previous_scene = RESOURCE_GET(SceneTree,m_current_scene);
|
||||||
|
SceneTree* new_scene = RESOURCE_GET(SceneTree,scene);
|
||||||
|
m_current_scene = scene;
|
||||||
|
|
||||||
if(m_physicsDebugNode != nullptr)
|
if(m_physicsDebugNode != nullptr)
|
||||||
{
|
{
|
||||||
m_scene->removeFromIndex(m_physicsDebugNode);
|
previous_scene->removeFromIndex(m_physicsDebugNode);
|
||||||
scene->addToIndex(m_physicsDebugNode);
|
new_scene->addToIndex(m_physicsDebugNode);
|
||||||
|
// m_scene->removeFromIndex(m_physicsDebugNode);
|
||||||
|
// scene->addToIndex(m_physicsDebugNode);
|
||||||
}
|
}
|
||||||
scene->getRootObject()->removeChild(m_sparrowshell);
|
|
||||||
m_scene = scene;
|
previous_scene->getRootObject()->removeChild(m_sparrowshell);
|
||||||
m_renderer->setScene(m_scene);
|
m_renderer->setScene(new_scene);
|
||||||
m_renderer->resizeGL(m_window->getSize().x, m_window->getSize().y);
|
m_renderer->resizeGL(m_window->getSize().x, m_window->getSize().y);
|
||||||
m_sparrowshell->setSceneTree(scene);
|
// m_sparrowshell->setSceneTree(new_scene);
|
||||||
scene->getRootObject()->addChild(m_sparrowshell);
|
new_scene->getRootObject()->addChild(m_sparrowshell);
|
||||||
scene->updateShaders();
|
new_scene->updateShaders();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::enablePhysicsDebug()
|
void Engine::enablePhysicsDebug()
|
||||||
@ -147,10 +155,10 @@ void Engine::enablePhysicsDebug()
|
|||||||
if(m_world != nullptr && m_physicsDebugNode == nullptr)
|
if(m_world != nullptr && m_physicsDebugNode == nullptr)
|
||||||
{
|
{
|
||||||
m_physicsDebugNode = new PhysicsDebugNode();
|
m_physicsDebugNode = new PhysicsDebugNode();
|
||||||
m_scene->addToIndex(m_physicsDebugNode);
|
getScene()->addToIndex(m_physicsDebugNode);
|
||||||
m_world->setDebugDrawer(m_physicsDebugNode);
|
m_world->setDebugDrawer(m_physicsDebugNode);
|
||||||
m_world->getDebugDrawer()->setDebugMode(btIDebugDraw::DBG_DrawWireframe);
|
m_world->getDebugDrawer()->setDebugMode(btIDebugDraw::DBG_DrawWireframe);
|
||||||
m_scene->updateShaders();
|
getScene()->updateShaders();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,7 +167,7 @@ void Engine::disablePhysicsDebug()
|
|||||||
if(m_world != nullptr && m_physicsDebugNode != nullptr)
|
if(m_world != nullptr && m_physicsDebugNode != nullptr)
|
||||||
{
|
{
|
||||||
m_world->setDebugDrawer(nullptr);
|
m_world->setDebugDrawer(nullptr);
|
||||||
m_scene->removeFromIndex(m_physicsDebugNode);
|
getScene()->removeFromIndex(m_physicsDebugNode);
|
||||||
delete m_physicsDebugNode;
|
delete m_physicsDebugNode;
|
||||||
m_physicsDebugNode = nullptr;
|
m_physicsDebugNode = nullptr;
|
||||||
}
|
}
|
||||||
@ -216,8 +224,13 @@ void Engine::checkSpecialInputs()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Engine::createScene(std::string scene_name)
|
||||||
SceneTree* Engine::createScene()
|
|
||||||
{
|
{
|
||||||
return new SceneTree(*this);
|
RESOURCE_ADD(new SceneTree(*this),SceneTree,scene_name);
|
||||||
|
//return new SceneTree(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
SceneTree* Engine::getScene() const
|
||||||
|
{
|
||||||
|
return RESOURCE_GET(SceneTree,m_current_scene);
|
||||||
}
|
}
|
||||||
|
12
src/engine.h
12
src/engine.h
@ -26,7 +26,8 @@ public:
|
|||||||
unsigned int w = 800,
|
unsigned int w = 800,
|
||||||
unsigned int h = 600,
|
unsigned int h = 600,
|
||||||
const std::string &mode = "windowed");
|
const std::string &mode = "windowed");
|
||||||
void setScene(SceneTree *scene);
|
// void setScene(SceneTree *scene);
|
||||||
|
void setScene(std::string scene);
|
||||||
void initPhysics();
|
void initPhysics();
|
||||||
|
|
||||||
void enablePhysicsDebug();
|
void enablePhysicsDebug();
|
||||||
@ -48,12 +49,14 @@ public:
|
|||||||
SparrowRenderer* getRenderer() const {return m_renderer;}
|
SparrowRenderer* getRenderer() const {return m_renderer;}
|
||||||
btDiscreteDynamicsWorld* getPhysics() const {return m_world;}
|
btDiscreteDynamicsWorld* getPhysics() const {return m_world;}
|
||||||
SparrowShell* getShell() const {return m_sparrowshell;}
|
SparrowShell* getShell() const {return m_sparrowshell;}
|
||||||
SceneTree* getScene() const {return m_scene;}
|
SceneTree* getScene() const;
|
||||||
|
|
||||||
unsigned int getTime() const;
|
unsigned int getTime() const;
|
||||||
unsigned int getDeltaTime() const;
|
unsigned int getDeltaTime() const;
|
||||||
|
|
||||||
SceneTree* createScene();
|
// SceneTree* createScene();
|
||||||
|
void createScene(std::string scene_name);
|
||||||
|
//void setCurrentScene(std::string scene_name){m_current_scene = scene_name;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
sf::Clock* m_clock;
|
sf::Clock* m_clock;
|
||||||
@ -64,7 +67,8 @@ private:
|
|||||||
sf::Window* m_window;
|
sf::Window* m_window;
|
||||||
|
|
||||||
Input* m_input;
|
Input* m_input;
|
||||||
SceneTree* m_scene;
|
// SceneTree* m_scene;
|
||||||
|
std::string m_current_scene;
|
||||||
SparrowShell* m_sparrowshell;
|
SparrowShell* m_sparrowshell;
|
||||||
btDiscreteDynamicsWorld* m_world;
|
btDiscreteDynamicsWorld* m_world;
|
||||||
PhysicsDebugNode *m_physicsDebugNode;
|
PhysicsDebugNode *m_physicsDebugNode;
|
||||||
|
@ -6,11 +6,11 @@
|
|||||||
#include "SparrowRenderer/mesh.h"
|
#include "SparrowRenderer/mesh.h"
|
||||||
#include "SparrowRenderer/phongmaterial.h"
|
#include "SparrowRenderer/phongmaterial.h"
|
||||||
|
|
||||||
BackGroundNode::BackGroundNode(glm::vec2 position,glm::vec2 dimension, glm::vec3 color, float opacity,float depth,bool visible):
|
BackGroundNode::BackGroundNode(glm::vec2 dimension, glm::vec3 color, float opacity,float depth,bool visible):
|
||||||
MeshNode(nullptr,visible)
|
MeshNode(nullptr,visible)
|
||||||
{
|
{
|
||||||
Mesh* mesh = new Mesh();
|
Mesh* mesh = new Mesh();
|
||||||
mesh->addRectangle2D(position,dimension);
|
mesh->addRectangle2D(glm::vec2(0),dimension);
|
||||||
PhongMaterial *mat = new PhongMaterial();
|
PhongMaterial *mat = new PhongMaterial();
|
||||||
mat->diffuse = color;
|
mat->diffuse = color;
|
||||||
mat->m_opacity = opacity;
|
mat->m_opacity = opacity;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
class BackGroundNode : public MeshNode
|
class BackGroundNode : public MeshNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BackGroundNode(glm::vec2 position,glm::vec2 dimension, glm::vec3 color, float opacity,float depth,bool visible=true);
|
BackGroundNode(glm::vec2 dimension, glm::vec3 color, float opacity,float depth,bool visible=true);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BACKGROUNDNODE_H
|
#endif // BACKGROUNDNODE_H
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
RectangleButtonShape::RectangleButtonShape(glm::vec2 dimension):ButtonShape(),m_dimension(dimension)
|
RectangleButtonShape::RectangleButtonShape(glm::vec2 dimension):ButtonShape(),m_dimension(dimension)
|
||||||
{
|
{
|
||||||
m_background = new BackGroundNode(glm::vec2(0,0),dimension,glm::vec3(0.2,0.6,0.2),1,0);
|
m_background = new BackGroundNode(dimension,glm::vec3(0.2,0.6,0.2),1,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RectangleButtonShape::hover(glm::vec2 button_position, glm::vec2 mouse_position){
|
bool RectangleButtonShape::hover(glm::vec2 button_position, glm::vec2 mouse_position){
|
||||||
|
122
src/scene/gui/textinputnode.cpp
Normal file
122
src/scene/gui/textinputnode.cpp
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
#include "textinputnode.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "SparrowInput/input.h"
|
||||||
|
|
||||||
|
#include "engine.h"
|
||||||
|
#include "tools/font.h"
|
||||||
|
#include "resourcemanager.h"
|
||||||
|
|
||||||
|
TextInputNode::TextInputNode(glm::vec2 dimension):
|
||||||
|
m_dimension(dimension),
|
||||||
|
m_font_size(16.f),
|
||||||
|
m_text_color(glm::vec3(1,1,1)),
|
||||||
|
m_cursor_pos(0)
|
||||||
|
{
|
||||||
|
// Font *shellfont = RESOURCE_GET(Font,"shellfont");
|
||||||
|
Mesh* mesh = new Mesh();
|
||||||
|
mesh->addRectangle2D(glm::vec2(0),glm::vec2(2, m_font_size));
|
||||||
|
PhongMaterial* mat = new PhongMaterial();
|
||||||
|
mat->diffuse = glm::vec3(1,1,1);
|
||||||
|
mesh->setMaterial(mat);
|
||||||
|
mesh->setDepth(30);
|
||||||
|
mesh->initGL();
|
||||||
|
m_cursor_mesh = new MeshNode(mesh,false);
|
||||||
|
addChild(m_cursor_mesh);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextInputNode::update()
|
||||||
|
{
|
||||||
|
if(!m_hasFocus) return;
|
||||||
|
|
||||||
|
std::wstring text = getEngine().getInput()->getText();
|
||||||
|
bool input_string_updated = false;
|
||||||
|
bool cursor_pos_updated = false;
|
||||||
|
|
||||||
|
auto input = getEngine().getInput();
|
||||||
|
for(auto action : input->getActions()){
|
||||||
|
if (action == m_move_cursor_left){
|
||||||
|
if (m_cursor_pos > 0){
|
||||||
|
m_cursor_pos--;
|
||||||
|
cursor_pos_updated=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(action == m_move_cursor_right){
|
||||||
|
if(m_cursor_pos < m_text.length()){
|
||||||
|
m_cursor_pos++;
|
||||||
|
cursor_pos_updated=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(unsigned int i = 0 ; i < text.length() ; i++){
|
||||||
|
char c = text[i];
|
||||||
|
switch(c){
|
||||||
|
case 8:
|
||||||
|
if(m_cursor_pos > 0)
|
||||||
|
m_text.erase(--m_cursor_pos,1);
|
||||||
|
input_string_updated = true;
|
||||||
|
cursor_pos_updated=true;
|
||||||
|
break;
|
||||||
|
case 13:
|
||||||
|
if (!m_text.empty())
|
||||||
|
{
|
||||||
|
if(m_callback)
|
||||||
|
m_callback->exec();
|
||||||
|
input_string_updated = true;
|
||||||
|
m_cursor_pos = 0;
|
||||||
|
cursor_pos_updated=true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 127:
|
||||||
|
m_text.erase(m_cursor_pos,1);
|
||||||
|
input_string_updated = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
m_text.insert(m_cursor_pos++,std::string(1,c));
|
||||||
|
input_string_updated = true;
|
||||||
|
cursor_pos_updated=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Font *shellfont = RESOURCE_GET(Font,"shellfont");
|
||||||
|
if(cursor_pos_updated){
|
||||||
|
m_cursor_mesh->moveTo2D(glm::vec2(m_cursor_pos*shellfont->getXAdvance()*(m_font_size/shellfont->getLineHeight()),0));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(input_string_updated)
|
||||||
|
{
|
||||||
|
if(m_text_mesh){
|
||||||
|
this->removeChild(m_text_mesh);
|
||||||
|
delete(m_text_mesh);
|
||||||
|
}
|
||||||
|
m_text_mesh = shellfont->getTextNode(m_text,m_text_color,m_font_size,false);
|
||||||
|
if(m_text_mesh){
|
||||||
|
m_text_mesh->setTransform(glm::mat4());
|
||||||
|
m_text_mesh->setDepth(15);
|
||||||
|
this->addChild(m_text_mesh);
|
||||||
|
m_text_mesh->setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GUINode::update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextInputNode::setFocus(bool focus)
|
||||||
|
{
|
||||||
|
m_hasFocus = focus;
|
||||||
|
m_cursor_mesh->setVisible(focus);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextInputNode::setTextColor(glm::vec3 color)
|
||||||
|
{
|
||||||
|
m_text_color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string TextInputNode::getText()
|
||||||
|
{
|
||||||
|
return m_text;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
42
src/scene/gui/textinputnode.h
Normal file
42
src/scene/gui/textinputnode.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
#ifndef TEXTINPUTNODE_H
|
||||||
|
#define TEXTINPUTNODE_H
|
||||||
|
|
||||||
|
#include "scene/gui/guinode.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "scene/textnode.h"
|
||||||
|
#include "scene/gui/callback.h"
|
||||||
|
|
||||||
|
class TextInputNode : public GUINode
|
||||||
|
{
|
||||||
|
glm::vec2 m_dimension;
|
||||||
|
bool m_hasFocus;
|
||||||
|
float m_font_size;
|
||||||
|
|
||||||
|
TextNode* m_text_mesh;
|
||||||
|
std::string m_text;
|
||||||
|
glm::vec3 m_text_color;
|
||||||
|
|
||||||
|
MeshNode* m_cursor_mesh;
|
||||||
|
unsigned int m_cursor_pos;
|
||||||
|
|
||||||
|
int m_move_cursor_left;
|
||||||
|
int m_move_cursor_right;
|
||||||
|
|
||||||
|
CallBack* m_callback;
|
||||||
|
|
||||||
|
public:
|
||||||
|
TextInputNode(glm::vec2 dimension);
|
||||||
|
void update();
|
||||||
|
glm::vec2 getDimension(){return m_dimension;}
|
||||||
|
|
||||||
|
void setFocus(bool focus);
|
||||||
|
void setTextColor(glm::vec3 color);
|
||||||
|
std::string getText();
|
||||||
|
void setCallBack(CallBack* callback){m_callback = callback;}
|
||||||
|
void setMoveCursorLeft(int action){m_move_cursor_left = action;}
|
||||||
|
void setMoveCursorRight(int action){m_move_cursor_right = action;}
|
||||||
|
void clearText(){m_text.clear();}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TEXTINPUTNODE_H
|
@ -39,7 +39,8 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// A SceneTree can only be constructed by the engine by using Engine::createScene()
|
// A SceneTree can only be constructed by the engine by using Engine::createScene()
|
||||||
friend SceneTree* Engine::createScene();
|
//friend SceneTree* Engine::createScene();
|
||||||
|
friend void Engine::createScene(std::string scene_name);
|
||||||
SceneTree(const Engine &engine);
|
SceneTree(const Engine &engine);
|
||||||
|
|
||||||
const Engine &m_engine;
|
const Engine &m_engine;
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
#define TEXTNODE_H
|
#define TEXTNODE_H
|
||||||
|
|
||||||
#include "meshnode.h"
|
#include "meshnode.h"
|
||||||
|
|
||||||
|
#include "SparrowRenderer/mesh.h"
|
||||||
|
#include "SparrowRenderer/phongmaterial.h"
|
||||||
|
|
||||||
#include "glm/vec2.hpp"
|
#include "glm/vec2.hpp"
|
||||||
|
|
||||||
class TextNode : public MeshNode
|
class TextNode : public MeshNode
|
||||||
|
@ -12,7 +12,6 @@ void ShellBuffer::toggleBuffer(){
|
|||||||
|
|
||||||
void ShellBuffer::update()
|
void ShellBuffer::update()
|
||||||
{
|
{
|
||||||
GraphicalContainerNode::update();
|
|
||||||
TextNode* tnode;
|
TextNode* tnode;
|
||||||
glm::vec2 text_pos(0,0);
|
glm::vec2 text_pos(0,0);
|
||||||
|
|
||||||
@ -32,6 +31,7 @@ void ShellBuffer::update()
|
|||||||
tnode->moveTo2D(glm::vec2(-100,-100));
|
tnode->moveTo2D(glm::vec2(-100,-100));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
GUINode::update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShellBuffer::push(TextNode* tnode){
|
void ShellBuffer::push(TextNode* tnode){
|
||||||
@ -51,3 +51,8 @@ void ShellBuffer::push(TextNode* tnode){
|
|||||||
tnode->setParentVisible(isVisible());
|
tnode->setParentVisible(isVisible());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::vec2 ShellBuffer::getDimension(){
|
||||||
|
return glm::vec2(getEngine().getWindow()->getSize().x - SparrowShell::SCROLLBAR_PIXEL_WIDTH,
|
||||||
|
SparrowShell::BUFFER_DISPLAYED_LINES * SparrowShell::DEFAULT_FONT_SIZE);
|
||||||
|
}
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
#ifndef SHELLBUFFER_H
|
#ifndef SHELLBUFFER_H
|
||||||
#define SHELLBUFFER_H
|
#define SHELLBUFFER_H
|
||||||
|
|
||||||
#include "scene/graphicalcontainernode.h"
|
#include "scene/gui/guinode.h"
|
||||||
|
|
||||||
|
|
||||||
class TextNode;
|
class TextNode;
|
||||||
|
|
||||||
class ShellBuffer : public GraphicalContainerNode {
|
class ShellBuffer : public GUINode {
|
||||||
private:
|
private:
|
||||||
unsigned int m_max_size;
|
unsigned int m_max_size;
|
||||||
int m_zero_offset;
|
int m_zero_offset;
|
||||||
@ -28,6 +27,8 @@ public:
|
|||||||
void setFontSize(float font_size){m_font_size = font_size;}
|
void setFontSize(float font_size){m_font_size = font_size;}
|
||||||
float getFontSize(){return m_font_size;}
|
float getFontSize(){return m_font_size;}
|
||||||
|
|
||||||
|
glm::vec2 getDimension();
|
||||||
|
|
||||||
void increaseIndex(){m_index++;}
|
void increaseIndex(){m_index++;}
|
||||||
void decreaseIndex(){m_index--;}
|
void decreaseIndex(){m_index--;}
|
||||||
unsigned int getIndex(){return m_index;}
|
unsigned int getIndex(){return m_index;}
|
||||||
|
@ -41,7 +41,6 @@ void ShellScrollBar::update(){
|
|||||||
if (m_shell->indexMoved())
|
if (m_shell->indexMoved())
|
||||||
{
|
{
|
||||||
m_position.y = cran * indexCursor;
|
m_position.y = cran * indexCursor;
|
||||||
// std::cout << m_position.x << " " << m_position.y << std::endl;
|
|
||||||
moveTo2D(m_position);
|
moveTo2D(m_position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "scene/meshnode.h"
|
#include "scene/meshnode.h"
|
||||||
#include "scene/textnode.h"
|
#include "scene/textnode.h"
|
||||||
#include "scene/gui/backgroundnode.h"
|
#include "scene/gui/backgroundnode.h"
|
||||||
|
#include "scene/gui/textinputnode.h"
|
||||||
#include "scriptnode.h"
|
#include "scriptnode.h"
|
||||||
|
|
||||||
#include "SparrowRenderer/mesh.h"
|
#include "SparrowRenderer/mesh.h"
|
||||||
@ -22,35 +23,51 @@ const float SparrowShell::SHELL_DEPTH = 10;
|
|||||||
const float SparrowShell::DEFAULT_FONT_SIZE = 16.f;
|
const float SparrowShell::DEFAULT_FONT_SIZE = 16.f;
|
||||||
|
|
||||||
SparrowShell::SparrowShell(sf::Window* window):
|
SparrowShell::SparrowShell(sf::Window* window):
|
||||||
m_position(glm::ivec2(0)),
|
|
||||||
m_buffer(new ShellBuffer(BUFFER_MAX_LENGTH)),
|
m_buffer(new ShellBuffer(BUFFER_MAX_LENGTH)),
|
||||||
m_text_color(glm::vec3(0.7,1,0.3)),
|
m_text_color(glm::vec3(0.7,1,0.3))
|
||||||
m_input_cursor_pos(0),
|
|
||||||
m_input_mesh(nullptr)
|
|
||||||
{
|
{
|
||||||
sf::Vector2u size = window->getSize();
|
sf::Vector2u size = window->getSize();
|
||||||
m_dimension = glm::ivec2(size.x,DEFAULT_FONT_SIZE*(BUFFER_DISPLAYED_LINES+1));
|
m_dimension = glm::ivec2(size.x,DEFAULT_FONT_SIZE*(BUFFER_DISPLAYED_LINES+1));
|
||||||
m_buffer->setFontSize(DEFAULT_FONT_SIZE);
|
m_buffer->setFontSize(DEFAULT_FONT_SIZE);
|
||||||
|
|
||||||
moveTo2D(glm::vec2(m_position));
|
setPosition(glm::vec2(0));
|
||||||
|
|
||||||
Font* fonte_des_neiges = Loader::loadFont("../data/consolas.fnt","../data/consolas.png");
|
Font* fonte_des_neiges = Loader::loadFont("../data/consolas.fnt","../data/consolas.png");
|
||||||
RESOURCE_ADD(fonte_des_neiges,Font,"shellfont");
|
RESOURCE_ADD(fonte_des_neiges,Font,"shellfont");
|
||||||
|
|
||||||
//Create mesh for background
|
//Create mesh for background
|
||||||
m_background = new BackGroundNode(glm::vec2(0),m_dimension,glm::vec3(0.1,0.1,0.1),0.75,SHELL_DEPTH,false);
|
m_background = new BackGroundNode(m_dimension,glm::vec3(0.1,0.1,0.1),0.75,SHELL_DEPTH,false);
|
||||||
//Create mesh for scrollbar
|
//Create mesh for scrollbar
|
||||||
m_scrollbar = new ShellScrollBar(this);
|
m_scrollbar = new ShellScrollBar(this);
|
||||||
|
|
||||||
m_script = new ScriptNode();
|
m_script = new ScriptNode();
|
||||||
|
|
||||||
|
m_input_node = new TextInputNode(glm::vec2(m_buffer->getFontSize(),size.y));
|
||||||
|
m_input_node->setPosition(glm::vec2(0,m_buffer->getFontSize()*BUFFER_DISPLAYED_LINES));
|
||||||
|
m_input_node->setVisible(false);
|
||||||
|
m_input_node->setCallBack(new InputCallBack(this,m_input_node));
|
||||||
|
|
||||||
this->addChild(m_background);
|
this->addChild(m_background);
|
||||||
this->addChild(m_buffer);
|
this->addChild(m_buffer);
|
||||||
this->addChild(m_scrollbar);
|
this->addChild(m_scrollbar);
|
||||||
this->addChild(m_script);
|
this->addChild(m_script);
|
||||||
|
this->addChild(m_input_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
// write wstring str in shell
|
SparrowShell::InputCallBack::InputCallBack(SparrowShell* shell,TextInputNode* textinput):
|
||||||
|
m_shell(shell),
|
||||||
|
m_text_input_node(textinput)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SparrowShell::InputCallBack::exec(){
|
||||||
|
std::string text = m_text_input_node->getText();
|
||||||
|
m_shell->out(text);
|
||||||
|
m_shell->m_script->execute(text);
|
||||||
|
m_text_input_node->clearText();
|
||||||
|
}
|
||||||
|
|
||||||
|
// write string str in shell
|
||||||
void SparrowShell::out(std::string str)
|
void SparrowShell::out(std::string str)
|
||||||
{
|
{
|
||||||
out(str,m_text_color);
|
out(str,m_text_color);
|
||||||
@ -58,8 +75,6 @@ void SparrowShell::out(std::string str)
|
|||||||
|
|
||||||
void SparrowShell::out(std::string str,glm::vec3 color)
|
void SparrowShell::out(std::string str,glm::vec3 color)
|
||||||
{
|
{
|
||||||
// std::wstring ws;
|
|
||||||
// ws.assign(str.begin(),str.end());
|
|
||||||
Font *shellfont = RESOURCE_GET(Font,"shellfont");
|
Font *shellfont = RESOURCE_GET(Font,"shellfont");
|
||||||
TextNode* tnode = shellfont->getTextNode(str,color,m_buffer->getFontSize(),false);
|
TextNode* tnode = shellfont->getTextNode(str,color,m_buffer->getFontSize(),false);
|
||||||
tnode->setDepth(SHELL_DEPTH+1);
|
tnode->setDepth(SHELL_DEPTH+1);
|
||||||
@ -67,6 +82,7 @@ void SparrowShell::out(std::string str,glm::vec3 color)
|
|||||||
scrollDown();
|
scrollDown();
|
||||||
if (m_buffer->size() > SparrowShell::BUFFER_DISPLAYED_LINES)
|
if (m_buffer->size() > SparrowShell::BUFFER_DISPLAYED_LINES)
|
||||||
m_resizeBuffer = true;
|
m_resizeBuffer = true;
|
||||||
|
// getEngine().getScene()->updateShaders();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SparrowShell::scrollUp()
|
void SparrowShell::scrollUp()
|
||||||
@ -85,6 +101,16 @@ void SparrowShell::scrollDown()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SparrowShell::setMoveCursorLeftAction(int action)
|
||||||
|
{
|
||||||
|
m_input_node->setMoveCursorLeft(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SparrowShell::setMoveCursorRightAction(int action)
|
||||||
|
{
|
||||||
|
m_input_node->setMoveCursorRight(action);
|
||||||
|
}
|
||||||
|
|
||||||
void SparrowShell::toggleShell()
|
void SparrowShell::toggleShell()
|
||||||
{
|
{
|
||||||
if(m_shellEnabled){
|
if(m_shellEnabled){
|
||||||
@ -96,6 +122,7 @@ void SparrowShell::toggleShell()
|
|||||||
getEngine().getWindow()->setKeyRepeatEnabled(true);
|
getEngine().getWindow()->setKeyRepeatEnabled(true);
|
||||||
}
|
}
|
||||||
m_shellEnabled = !m_shellEnabled;
|
m_shellEnabled = !m_shellEnabled;
|
||||||
|
m_input_node->setFocus(m_shellEnabled);
|
||||||
for(auto child : m_children)
|
for(auto child : m_children)
|
||||||
child->toggleVisibility();
|
child->toggleVisibility();
|
||||||
m_buffer->toggleBuffer();
|
m_buffer->toggleBuffer();
|
||||||
@ -108,69 +135,21 @@ void SparrowShell::update()
|
|||||||
m_indexMoved = false;
|
m_indexMoved = false;
|
||||||
if(m_shellEnabled){
|
if(m_shellEnabled){
|
||||||
auto input = getEngine().getInput();
|
auto input = getEngine().getInput();
|
||||||
for(auto action : input->getActions()){
|
// for(auto action : input->getActions()){
|
||||||
if (action == m_move_cursor_left){
|
/* if (action == m_move_cursor_left){
|
||||||
if (m_input_cursor_pos > 0)
|
if (m_input_cursor_pos > 0)
|
||||||
moveCursorLeft();
|
moveCursorLeft();
|
||||||
}
|
}
|
||||||
else if(action == m_move_cursor_right){
|
else if(action == m_move_cursor_right){
|
||||||
if(m_input_cursor_pos < m_input_string.length())
|
if(m_input_cursor_pos < m_input_string.length())
|
||||||
moveCursorRight();
|
moveCursorRight();
|
||||||
}
|
}*/
|
||||||
}
|
// }
|
||||||
updateTextInput();
|
|
||||||
int scroll = input->getDeltaVerticalScroll();
|
int scroll = input->getDeltaVerticalScroll();
|
||||||
if(scroll < 0)
|
if(scroll < 0)
|
||||||
scrollDown();
|
scrollDown();
|
||||||
else if(scroll > 0)
|
else if(scroll > 0)
|
||||||
scrollUp();
|
scrollUp();
|
||||||
}
|
}
|
||||||
getEngine().getScene()->updateShaders();
|
GUINode::update();
|
||||||
GraphicalContainerNode::update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SparrowShell::updateTextInput()
|
|
||||||
{
|
|
||||||
std::wstring text = getEngine().getInput()->getText();
|
|
||||||
bool input_string_updated = false;
|
|
||||||
if (!m_shellEnabled)
|
|
||||||
return;
|
|
||||||
for(unsigned int i = 0 ; i < text.length() ; i++){
|
|
||||||
char c = text[i];
|
|
||||||
switch(c){
|
|
||||||
case 8:
|
|
||||||
if(m_input_cursor_pos > 0)
|
|
||||||
m_input_string.erase(--m_input_cursor_pos,1);
|
|
||||||
input_string_updated = true;
|
|
||||||
break;
|
|
||||||
case 13:
|
|
||||||
if (!m_input_string.empty()){
|
|
||||||
out(m_input_string);
|
|
||||||
m_script->execute(m_input_string);
|
|
||||||
m_input_string.clear();
|
|
||||||
input_string_updated = true;
|
|
||||||
}
|
|
||||||
m_input_cursor_pos = 0;
|
|
||||||
break;
|
|
||||||
case 127:
|
|
||||||
m_input_string.erase(m_input_cursor_pos,1);
|
|
||||||
input_string_updated = true;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
m_input_string.insert(m_input_cursor_pos++,std::string(1,c));
|
|
||||||
input_string_updated = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Font *shellfont = RESOURCE_GET(Font,"shellfont");
|
|
||||||
if(input_string_updated)
|
|
||||||
{
|
|
||||||
if(m_input_mesh)
|
|
||||||
this->removeChild(m_input_mesh);
|
|
||||||
std::wstring ws;
|
|
||||||
ws.assign(m_input_string.begin(),m_input_string.end());
|
|
||||||
m_input_mesh = shellfont->getTextNode(m_input_string,m_text_color,m_buffer->getFontSize(),false);
|
|
||||||
m_input_mesh->moveTo2D(glm::vec2(0,m_buffer->getFontSize()*BUFFER_DISPLAYED_LINES));
|
|
||||||
this->addChild(m_input_mesh);
|
|
||||||
m_input_mesh->setVisible(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,16 +3,23 @@
|
|||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
#include "scene/scenetree.h"
|
|
||||||
#include "glm/vec2.hpp"
|
#include "glm/vec2.hpp"
|
||||||
|
|
||||||
|
#include "scene/scenetree.h"
|
||||||
|
#include "scene/graphicalcontainernode.h"
|
||||||
|
|
||||||
|
#include "scene/gui/guinode.h"
|
||||||
|
#include "scene/gui/callback.h"
|
||||||
|
|
||||||
#include "sparrowshell/shellbuffer.h"
|
#include "sparrowshell/shellbuffer.h"
|
||||||
#include "sparrowshell/shellscrollbar.h"
|
#include "sparrowshell/shellscrollbar.h"
|
||||||
#include "scene/graphicalcontainernode.h"
|
|
||||||
#include "SparrowInput/keybindings.h"
|
#include "SparrowInput/keybindings.h"
|
||||||
|
|
||||||
class Input;
|
class Input;
|
||||||
class MeshNode;
|
//class MeshNode;
|
||||||
class TextNode;
|
//class TextNode;
|
||||||
|
class TextInputNode;
|
||||||
class ShellBuffer;
|
class ShellBuffer;
|
||||||
class BackGroundNode;
|
class BackGroundNode;
|
||||||
class ScriptNode;
|
class ScriptNode;
|
||||||
@ -21,11 +28,18 @@ namespace sf {
|
|||||||
class Window;
|
class Window;
|
||||||
}
|
}
|
||||||
|
|
||||||
class SparrowShell : public GraphicalContainerNode
|
class SparrowShell : public GUINode
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
glm::ivec2 m_position;
|
class InputCallBack : public CallBack{
|
||||||
glm::ivec2 m_dimension;
|
SparrowShell* m_shell;
|
||||||
|
TextInputNode* m_text_input_node;
|
||||||
|
public:
|
||||||
|
InputCallBack(SparrowShell* shell,TextInputNode* textinput);
|
||||||
|
virtual void exec();
|
||||||
|
};
|
||||||
|
|
||||||
|
glm::vec2 m_dimension;
|
||||||
bool m_shellEnabled = false;
|
bool m_shellEnabled = false;
|
||||||
bool m_resizeBuffer = false;
|
bool m_resizeBuffer = false;
|
||||||
bool m_indexMoved = false;
|
bool m_indexMoved = false;
|
||||||
@ -36,9 +50,7 @@ private:
|
|||||||
ScriptNode * m_script;
|
ScriptNode * m_script;
|
||||||
|
|
||||||
glm::vec3 m_text_color;
|
glm::vec3 m_text_color;
|
||||||
std::string m_input_string;
|
TextInputNode* m_input_node;
|
||||||
unsigned int m_input_cursor_pos;
|
|
||||||
TextNode* m_input_mesh;
|
|
||||||
|
|
||||||
int m_plop_test;
|
int m_plop_test;
|
||||||
int m_move_cursor_left;
|
int m_move_cursor_left;
|
||||||
@ -56,7 +68,6 @@ public:
|
|||||||
SparrowShell(sf::Window*);
|
SparrowShell(sf::Window*);
|
||||||
|
|
||||||
void update();
|
void update();
|
||||||
void updateTextInput();
|
|
||||||
void scrollUp();
|
void scrollUp();
|
||||||
void scrollDown();
|
void scrollDown();
|
||||||
|
|
||||||
@ -64,18 +75,17 @@ public:
|
|||||||
void out(std::string str);
|
void out(std::string str);
|
||||||
void out(std::string str, glm::vec3 color);
|
void out(std::string str, glm::vec3 color);
|
||||||
|
|
||||||
glm::ivec2 getPosition(){return m_position;}
|
glm::vec2 getDimension(){return m_dimension;}
|
||||||
glm::ivec2 getDimension(){return m_dimension;}
|
|
||||||
|
|
||||||
unsigned int getIndex(){return m_buffer->getIndex();}
|
unsigned int getIndex(){return m_buffer->getIndex();}
|
||||||
ShellBuffer* getBuffer(){return m_buffer;}
|
ShellBuffer* getBuffer(){return m_buffer;}
|
||||||
|
|
||||||
void setMoveCursorLeftAction(int action){m_move_cursor_left = action;}
|
void setMoveCursorLeftAction(int action);
|
||||||
void setMoveCursorRightAction(int action){m_move_cursor_right = action;}
|
void setMoveCursorRightAction(int action);
|
||||||
void setClearConsoleAction(int action){m_clear_console_action = action;}
|
void setClearConsoleAction(int action){m_clear_console_action = action;}
|
||||||
|
|
||||||
void moveCursorLeft(){m_input_cursor_pos--;}
|
//void moveCursorLeft(){m_input_cursor_pos--;}
|
||||||
void moveCursorRight(){m_input_cursor_pos++;}
|
//void moveCursorRight(){m_input_cursor_pos++;}
|
||||||
|
|
||||||
bool isEnabled(){return m_shellEnabled;}
|
bool isEnabled(){return m_shellEnabled;}
|
||||||
bool isBufferResized(){return m_resizeBuffer;}
|
bool isBufferResized(){return m_resizeBuffer;}
|
||||||
|
@ -38,6 +38,8 @@
|
|||||||
#include "SparrowSerializer/serializable.h"
|
#include "SparrowSerializer/serializable.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
#include "resourcemanager.h"
|
||||||
|
|
||||||
#include "scene/gui/callback.h"
|
#include "scene/gui/callback.h"
|
||||||
|
|
||||||
class TestGen : public TerrainGenerator
|
class TestGen : public TerrainGenerator
|
||||||
@ -180,21 +182,26 @@ struct Config : public Serializable
|
|||||||
};
|
};
|
||||||
|
|
||||||
class Demo {
|
class Demo {
|
||||||
SceneTree* m_demo_scene;
|
std::string m_demo_scene;
|
||||||
|
Engine* m_engine;
|
||||||
|
Config* m_config;
|
||||||
PlayerCharacterNode* m_player;
|
PlayerCharacterNode* m_player;
|
||||||
public:
|
public:
|
||||||
Demo(Engine* engine,Config* config){
|
Demo(Engine* engine,Config* config):m_demo_scene("demo"),m_engine(engine),m_config(config){
|
||||||
m_demo_scene = engine->createScene();
|
m_engine->createScene(m_demo_scene);
|
||||||
|
}
|
||||||
|
|
||||||
|
void initScene(){
|
||||||
//player
|
//player
|
||||||
m_player = new PlayerCharacterNode(false);
|
m_player = new PlayerCharacterNode(false);
|
||||||
m_player->setInputs(DefaultKeysMap::MOVE_FORWARD, DefaultKeysMap::MOVE_BACKWARD, DefaultKeysMap::STRAFE_LEFT, DefaultKeysMap::STRAFE_RIGHT, DefaultKeysMap::JUMP, DefaultKeysMap::TOGGLE_NOCLIP);
|
m_player->setInputs(DefaultKeysMap::MOVE_FORWARD, DefaultKeysMap::MOVE_BACKWARD, DefaultKeysMap::STRAFE_LEFT, DefaultKeysMap::STRAFE_RIGHT, DefaultKeysMap::JUMP, DefaultKeysMap::TOGGLE_NOCLIP);
|
||||||
m_demo_scene->getRootObject()->addChild(m_player);
|
SceneTree* scene = RESOURCE_GET(SceneTree,m_demo_scene);
|
||||||
m_demo_scene->setMainCamera(m_player);
|
scene->getRootObject()->addChild(m_player);
|
||||||
|
scene->setMainCamera(m_player);
|
||||||
|
|
||||||
//potator
|
//potator
|
||||||
Potator *potator = new Potator(m_player, DefaultKeysMap::MAIN_ACTION, DefaultKeysMap::SECONDARY_ACTION, DefaultKeysMap::TERTIARY_ACTION);
|
Potator *potator = new Potator(m_player, DefaultKeysMap::MAIN_ACTION, DefaultKeysMap::SECONDARY_ACTION, DefaultKeysMap::TERTIARY_ACTION);
|
||||||
m_demo_scene->getRootObject()->addChild(potator);
|
scene->getRootObject()->addChild(potator);
|
||||||
|
|
||||||
//lighting
|
//lighting
|
||||||
LightNode *ambientLight = new LightNode(new AmbientLight(glm::vec3(0.05f)));
|
LightNode *ambientLight = new LightNode(new AmbientLight(glm::vec3(0.05f)));
|
||||||
@ -202,28 +209,29 @@ public:
|
|||||||
DirectionnalLight* sun = new DirectionnalLight(glm::vec3(5, 8, -2), glm::vec3(0.9f));
|
DirectionnalLight* sun = new DirectionnalLight(glm::vec3(5, 8, -2), glm::vec3(0.9f));
|
||||||
LightNode *sunLight = new LightNode(sun);
|
LightNode *sunLight = new LightNode(sun);
|
||||||
|
|
||||||
m_demo_scene->getRootObject()->addChild(ambientLight);
|
scene->getRootObject()->addChild(ambientLight);
|
||||||
m_demo_scene->getRootObject()->addChild(sunLight);
|
scene->getRootObject()->addChild(sunLight);
|
||||||
|
|
||||||
if(config->scene == "sponza")
|
if(m_config->scene == "sponza")
|
||||||
{
|
{
|
||||||
sun->initShadowMap(4096);
|
sun->initShadowMap(4096);
|
||||||
generateSponza(m_demo_scene, engine->getPhysics());
|
generateSponza(scene, m_engine->getPhysics());
|
||||||
m_demo_scene->getRootObject()->addChild(new LightNode(new PointLight(glm::vec3(-3.5, 2, 1.8), 15, glm::vec3(0.35f))));
|
scene->getRootObject()->addChild(new LightNode(new PointLight(glm::vec3(-3.5, 2, 1.8), 15, glm::vec3(0.35f))));
|
||||||
m_demo_scene->getRootObject()->addChild(new LightNode(new PointLight(glm::vec3(-5, 6, 2), 15, glm::vec3(0.35f))));
|
scene->getRootObject()->addChild(new LightNode(new PointLight(glm::vec3(-5, 6, 2), 15, glm::vec3(0.35f))));
|
||||||
m_player->setPosition(0.f, 2.f, 0.f);
|
m_player->setPosition(0.f, 2.f, 0.f);
|
||||||
sun->setShadowView(glm::vec3(30, 30, 50));
|
sun->setShadowView(glm::vec3(30, 30, 50));
|
||||||
}
|
}
|
||||||
else if(config->scene == "terrain")
|
else if(m_config->scene == "terrain")
|
||||||
{
|
{
|
||||||
sun->initShadowMap(4096);
|
sun->initShadowMap(4096);
|
||||||
generateTerrain(m_demo_scene, engine->getPhysics());
|
generateTerrain(scene, m_engine->getPhysics());
|
||||||
m_player->setPosition(0.f, 15.f, 0.f);
|
m_player->setPosition(0.f, 15.f, 0.f);
|
||||||
sun->setShadowView(glm::vec3(130, 130, 70));
|
sun->setShadowView(glm::vec3(130, 130, 70));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneTree* getScene(){return m_demo_scene;}
|
std::string getScene(){return m_demo_scene;}
|
||||||
PlayerCharacterNode* getPlayer(){return m_player;}
|
PlayerCharacterNode* getPlayer(){return m_player;}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -235,6 +243,7 @@ public:
|
|||||||
ButtonDemoCallBack(Engine* engine, Demo* demo):m_engine(engine),m_demo(demo){}
|
ButtonDemoCallBack(Engine* engine, Demo* demo):m_engine(engine),m_demo(demo){}
|
||||||
|
|
||||||
void exec(){
|
void exec(){
|
||||||
|
m_demo->initScene();
|
||||||
m_engine->setScene(m_demo->getScene());
|
m_engine->setScene(m_demo->getScene());
|
||||||
m_engine->getInput()->setCurrentContext("default");
|
m_engine->getInput()->setCurrentContext("default");
|
||||||
m_engine->getInput()->setMouseGrabbed(true);
|
m_engine->getInput()->setMouseGrabbed(true);
|
||||||
@ -246,14 +255,15 @@ public:
|
|||||||
class Menu {
|
class Menu {
|
||||||
int m_left_click_action;
|
int m_left_click_action;
|
||||||
ButtonNode* m_button_demo;
|
ButtonNode* m_button_demo;
|
||||||
SceneTree* m_menu_scene;
|
std::string m_menu_scene;
|
||||||
public:
|
public:
|
||||||
Menu(Engine* engine,Config* config){
|
Menu(Engine* engine,Config* config):m_menu_scene("menu"){
|
||||||
m_menu_scene = engine->createScene();
|
engine->createScene(m_menu_scene);
|
||||||
|
SceneTree* scene = RESOURCE_GET(SceneTree,m_menu_scene);
|
||||||
m_button_demo = new ButtonNode(new RectangleButtonShape(glm::vec2(300,100)));
|
m_button_demo = new ButtonNode(new RectangleButtonShape(glm::vec2(300,100)));
|
||||||
m_button_demo->getLabel()->setText("Start DEMO");
|
m_button_demo->getLabel()->setText("Start DEMO");
|
||||||
m_button_demo->getLabel()->setColor(glm::vec3(0.9,0.4,0.3));
|
m_button_demo->getLabel()->setColor(glm::vec3(0.9,0.4,0.3));
|
||||||
m_menu_scene->getRootObject()->addChild(m_button_demo);
|
scene->getRootObject()->addChild(m_button_demo);
|
||||||
sf::Vector2u size = engine->getWindow()->getSize();
|
sf::Vector2u size = engine->getWindow()->getSize();
|
||||||
glm::vec2 pos = glm::vec2(size.x,size.y)/glm::vec2(2,2) - m_button_demo->getDimension()/glm::vec2(2,2);
|
glm::vec2 pos = glm::vec2(size.x,size.y)/glm::vec2(2,2) - m_button_demo->getDimension()/glm::vec2(2,2);
|
||||||
m_button_demo->setPosition(pos);
|
m_button_demo->setPosition(pos);
|
||||||
@ -269,7 +279,7 @@ public:
|
|||||||
m_button_demo->setCallBack(button_callback);
|
m_button_demo->setCallBack(button_callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
SceneTree* getScene(){return m_menu_scene;}
|
std::string getScene(){return m_menu_scene;}
|
||||||
};
|
};
|
||||||
|
|
||||||
INIT_SERIALIZABLE(Config)
|
INIT_SERIALIZABLE(Config)
|
||||||
|
@ -10,6 +10,8 @@ Font::Font()
|
|||||||
|
|
||||||
TextNode* Font::getTextNode(std::string s, glm::vec3 color, float font_size,bool visible)
|
TextNode* Font::getTextNode(std::string s, glm::vec3 color, float font_size,bool visible)
|
||||||
{
|
{
|
||||||
|
if(s.empty()) return nullptr;
|
||||||
|
|
||||||
std::wstring ws;
|
std::wstring ws;
|
||||||
ws.assign(s.begin(),s.end());
|
ws.assign(s.begin(),s.end());
|
||||||
Mesh* textmesh = new Mesh();
|
Mesh* textmesh = new Mesh();
|
||||||
|
@ -26,6 +26,7 @@ public:
|
|||||||
void setNbChar(int nbchar){m_nbChar =nbchar;}
|
void setNbChar(int nbchar){m_nbChar =nbchar;}
|
||||||
void setLineHeight(float line_h){m_defaultLineHeight = line_h;}
|
void setLineHeight(float line_h){m_defaultLineHeight = line_h;}
|
||||||
float getLineHeight(){return m_defaultLineHeight;}
|
float getLineHeight(){return m_defaultLineHeight;}
|
||||||
|
float getXAdvance(){return (m_charTable['a']).xadvance;}
|
||||||
void setBase(float base){m_base = base;}
|
void setBase(float base){m_base = base;}
|
||||||
void setAntiAnliasing(bool antialiasing){m_antiAliasing = antialiasing;}
|
void setAntiAnliasing(bool antialiasing){m_antiAliasing = antialiasing;}
|
||||||
void setScale(glm::vec2 scale){m_scale = scale;}
|
void setScale(glm::vec2 scale){m_scale = scale;}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user