bug with positioning
This commit is contained in:
parent
8ae05e3791
commit
07e65e5713
@ -194,7 +194,9 @@ void Engine::setShowMouseAction(int action)
|
|||||||
|
|
||||||
void Engine::outputShell(std::string str) const
|
void Engine::outputShell(std::string str) const
|
||||||
{
|
{
|
||||||
m_sparrowshell->out(str);
|
std::wstring ws;
|
||||||
|
ws.assign(str.begin(),str.end());
|
||||||
|
m_sparrowshell->out(ws);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::checkSpecialInputs()
|
void Engine::checkSpecialInputs()
|
||||||
|
@ -66,11 +66,6 @@ void GraphicalNode::rotate2D(const glm::vec2 ¢er, float angle)
|
|||||||
setTransform(glm::rotate(m_transform,angle,glm::vec3(0,0,1)));
|
setTransform(glm::rotate(m_transform,angle,glm::vec3(0,0,1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicalNode::setDepth2D(float depth)
|
|
||||||
{
|
|
||||||
// don't have access to depth here? :(
|
|
||||||
}
|
|
||||||
|
|
||||||
// setters
|
// setters
|
||||||
void GraphicalNode::setTransform(const glm::mat4 &transform)
|
void GraphicalNode::setTransform(const glm::mat4 &transform)
|
||||||
{
|
{
|
||||||
|
@ -49,6 +49,7 @@ public:
|
|||||||
void setTransform(const glm::mat4 &transform);
|
void setTransform(const glm::mat4 &transform);
|
||||||
const glm::mat4& getTransform() { return m_transform; }
|
const glm::mat4& getTransform() { return m_transform; }
|
||||||
void setParentTransform(const glm::mat4 &transform);
|
void setParentTransform(const glm::mat4 &transform);
|
||||||
|
const glm::mat4& getParentTransform() { return m_parentTransform; }
|
||||||
|
|
||||||
// visibility methods
|
// visibility methods
|
||||||
bool isVisible(){return m_parentVisible && m_visible;}
|
bool isVisible(){return m_parentVisible && m_visible;}
|
||||||
@ -68,7 +69,6 @@ public:
|
|||||||
void rotate2D(const glm::vec2 ¢er, float angle);
|
void rotate2D(const glm::vec2 ¢er, float angle);
|
||||||
void scale2D(const glm::vec2 scaleFactor);
|
void scale2D(const glm::vec2 scaleFactor);
|
||||||
void resize2D(const glm::vec2 oldDimension, glm::vec2 newDimension);
|
void resize2D(const glm::vec2 oldDimension, glm::vec2 newDimension);
|
||||||
void setDepth2D(float depth);
|
|
||||||
|
|
||||||
// this is used to synchronize a bullet rigidbody's transform with a GraphicalNode transform
|
// this is used to synchronize a bullet rigidbody's transform with a GraphicalNode transform
|
||||||
SparrowMotionState* getMotionState() { return &m_motionState; }
|
SparrowMotionState* getMotionState() { return &m_motionState; }
|
||||||
|
@ -9,9 +9,12 @@
|
|||||||
#include "sparrowshell/sparrowshell.h"
|
#include "sparrowshell/sparrowshell.h"
|
||||||
#include "mesh.h"
|
#include "mesh.h"
|
||||||
#include "phongmaterial.h"
|
#include "phongmaterial.h"
|
||||||
|
#include "tools/font.h"
|
||||||
|
#include "resourcemanager.h"
|
||||||
|
#include "sparrowrenderer.h"
|
||||||
|
|
||||||
ButtonNode::ButtonNode(glm::vec2 position,ButtonShape* shape):
|
ButtonNode::ButtonNode(glm::vec2 position,ButtonShape* shape):
|
||||||
m_position(position),m_shape(shape)
|
m_position(position),m_shape(shape),i(0)
|
||||||
{
|
{
|
||||||
addChild(m_shape->getBackGround());
|
addChild(m_shape->getBackGround());
|
||||||
}
|
}
|
||||||
@ -26,17 +29,31 @@ void ButtonNode::update()
|
|||||||
Input* input = getEngine().getInput();
|
Input* input = getEngine().getInput();
|
||||||
sf::Vector2i v = input->getPosition();
|
sf::Vector2i v = input->getPosition();
|
||||||
glm::vec2 pos = glm::vec2(v.x,v.y);
|
glm::vec2 pos = glm::vec2(v.x,v.y);
|
||||||
PhongMaterial* mat = (PhongMaterial*) m_shape->getBackGround()->getGeometryNode()->mesh->getMaterial();
|
|
||||||
if (m_shape->hover(pos)){
|
if(m_label_updated){
|
||||||
mat->diffuse=glm::vec3(0.2,0.6,0.6);
|
if(m_label_node)
|
||||||
}else{
|
removeChild(m_label_node);
|
||||||
mat->diffuse=glm::vec3(0.6,0.2,0.6);
|
Font* font = RESOURCE_GET(Font,"shellfont");
|
||||||
|
std::wstring ws;
|
||||||
|
ws.assign(m_label.begin(),m_label.end());
|
||||||
|
m_label_node = font->getTextNode(ws,m_label_color,32);
|
||||||
|
addChild(m_label_node);
|
||||||
|
getEngine().getScene()->updateShaders();
|
||||||
|
m_label_updated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(i == 120){
|
||||||
|
glm::vec4 posa = m_transform[3];
|
||||||
|
glm::vec4 posb = getBackGround()->getParentTransform()[3];
|
||||||
|
glm::vec4 posc = m_label_node->getParentTransform()[3];
|
||||||
|
std::cout << posa.x << " " << posa.y <<"\n"<< posb.x << " " << posb.y << "\n" << posc.x << " " << posc.y << "\n"<< std::endl;
|
||||||
|
i=0;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
for (auto action : input->getActions())
|
for (auto action : input->getActions())
|
||||||
{
|
{
|
||||||
if (action == m_action){
|
if (action == m_action){
|
||||||
if (m_shape->hover(pos))
|
if (m_shape->hover(m_position,pos))
|
||||||
m_callback->exec();
|
m_callback->exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "scene/meshnode.h"
|
#include "scene/meshnode.h"
|
||||||
#include "scene/graphicalcontainernode.h"
|
#include "scene/graphicalcontainernode.h"
|
||||||
#include "scene/gui/callback.h"
|
#include "scene/gui/callback.h"
|
||||||
|
#include "scene/textnode.h"
|
||||||
|
|
||||||
class ButtonShape;
|
class ButtonShape;
|
||||||
class BackGroundNode;
|
class BackGroundNode;
|
||||||
@ -14,13 +15,21 @@ class ButtonNode : public GraphicalContainerNode
|
|||||||
glm::vec2 m_position;
|
glm::vec2 m_position;
|
||||||
ButtonShape* m_shape;
|
ButtonShape* m_shape;
|
||||||
CallBack* m_callback;
|
CallBack* m_callback;
|
||||||
// BackGroundNode* m_background;
|
|
||||||
|
std::string m_label;
|
||||||
|
bool m_label_updated;
|
||||||
|
TextNode* m_label_node;
|
||||||
|
glm::vec3 m_label_color;
|
||||||
|
|
||||||
|
int i;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ButtonNode(glm::vec2 m_position, ButtonShape* shape);
|
ButtonNode(glm::vec2 m_position, ButtonShape* shape);
|
||||||
// void setBackGround(BackGroundNode*);
|
|
||||||
MeshNode* getBackGround();
|
MeshNode* getBackGround();
|
||||||
void setCallBack(CallBack* callback){m_callback=callback;}
|
void setCallBack(CallBack* callback){m_callback=callback;}
|
||||||
void setAction(int action){m_action=action;}
|
void setAction(int action){m_action=action;}
|
||||||
|
void setLabel(std::string label){m_label = label; m_label_updated = true;}
|
||||||
|
void setLabelColor(glm::vec3 color){m_label_color=color;}
|
||||||
void update();
|
void update();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,15 +2,14 @@
|
|||||||
#include "glm/common.hpp"
|
#include "glm/common.hpp"
|
||||||
#include "scene/gui/backgroundnode.h"
|
#include "scene/gui/backgroundnode.h"
|
||||||
|
|
||||||
RectangleButtonShape::RectangleButtonShape(glm::vec2 position, glm::vec2 dimension):ButtonShape(position),m_dimension(dimension)
|
RectangleButtonShape::RectangleButtonShape(glm::vec2 dimension):ButtonShape(),m_dimension(dimension)
|
||||||
{
|
{
|
||||||
m_background = new BackGroundNode(position,dimension,glm::vec3(0,0,0),1,0);
|
m_background = new BackGroundNode(glm::vec2(0,0),dimension,glm::vec3(0.2,0.6,0.2),1,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RectangleButtonShape::hover(glm::vec2 mouse_position){
|
bool RectangleButtonShape::hover(glm::vec2 button_position, glm::vec2 mouse_position){
|
||||||
glm::vec2 pos = getPosition();
|
return (mouse_position.x >= button_position.x && mouse_position.x < button_position.x + m_dimension.x)
|
||||||
return (mouse_position.x >= pos.x && mouse_position.x < pos.x + m_dimension.x)
|
&& (mouse_position.y >= button_position.y && mouse_position.y < button_position.y + m_dimension.y);
|
||||||
&& (mouse_position.y >= pos.y && mouse_position.y < pos.y + m_dimension.y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MeshNode* RectangleButtonShape::getBackGround(){
|
MeshNode* RectangleButtonShape::getBackGround(){
|
||||||
|
@ -7,15 +7,14 @@ class MeshNode;
|
|||||||
|
|
||||||
class ButtonShape
|
class ButtonShape
|
||||||
{
|
{
|
||||||
glm::vec2 m_position;
|
|
||||||
protected:
|
protected:
|
||||||
MeshNode* m_background;
|
MeshNode* m_background;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ButtonShape(glm::vec2 position) : m_position(position){}
|
ButtonShape(){}
|
||||||
|
|
||||||
virtual bool hover(glm::vec2 mouse_position) = 0;
|
virtual bool hover(glm::vec2 button_position, glm::vec2 mouse_position) = 0;
|
||||||
glm::vec2 getPosition(){return m_position;}
|
// glm::vec2 getPosition(){return m_position;}
|
||||||
virtual MeshNode* getBackGround() = 0;
|
virtual MeshNode* getBackGround() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -23,8 +22,8 @@ class RectangleButtonShape:public ButtonShape
|
|||||||
{
|
{
|
||||||
glm::vec2 m_dimension;
|
glm::vec2 m_dimension;
|
||||||
public:
|
public:
|
||||||
RectangleButtonShape(glm::vec2, glm::vec2);
|
RectangleButtonShape(glm::vec2);
|
||||||
bool hover(glm::vec2 mouse_position);
|
bool hover(glm::vec2 button_position, glm::vec2 mouse_position);
|
||||||
MeshNode* getBackGround();
|
MeshNode* getBackGround();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6,12 +6,12 @@
|
|||||||
class TextNode : public MeshNode
|
class TextNode : public MeshNode
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
std::string m_string;
|
std::wstring m_string;
|
||||||
float m_fontSize;
|
float m_fontSize;
|
||||||
public:
|
public:
|
||||||
TextNode(Mesh* mesh,std::string s,float fontSize,bool visible = true) : MeshNode(mesh,visible),m_string(s),m_fontSize(fontSize) {}
|
TextNode(Mesh* mesh,std::wstring s,float fontSize,bool visible = true) : MeshNode(mesh,visible),m_string(s),m_fontSize(fontSize) {}
|
||||||
float getFontSize(){return m_fontSize;}
|
float getFontSize(){return m_fontSize;}
|
||||||
std::string getString(){return m_string;}
|
std::wstring getString(){return m_string;}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TEXTNODE_H
|
#endif // TEXTNODE_H
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "sparrowshell/sparrowshell.h"
|
#include "sparrowshell/sparrowshell.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#define LUASETFUN(var) s.set_function(#var,&ScriptNode::var,this)
|
#define LUASETFUN(var) m_script.set_function(#var,&ScriptNode::var,this)
|
||||||
|
|
||||||
ScriptNode::ScriptNode()
|
ScriptNode::ScriptNode()
|
||||||
{
|
{
|
||||||
@ -16,14 +16,21 @@ void ScriptNode::update(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ScriptNode::print(std::string to_print){
|
void ScriptNode::print(std::string to_print){
|
||||||
this->getEngine().getShell()->out(to_print.append("\n"));
|
std::wstring ws;
|
||||||
|
to_print.append("\n");
|
||||||
|
ws.assign(to_print.begin(),to_print.end());
|
||||||
|
this->getEngine().getShell()->out(ws);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptNode::execute(std::wstring to_execute){
|
||||||
void ScriptNode::execute(std::string to_execute){
|
|
||||||
try{
|
try{
|
||||||
s.script(to_execute);
|
std::string str;
|
||||||
|
str.assign(to_execute.begin(),to_execute.end());
|
||||||
|
m_script.script(str);
|
||||||
}catch(sol::error error_lua){
|
}catch(sol::error error_lua){
|
||||||
this->getEngine().getShell()->out(error_lua.what(),glm::vec3(1,0,0));
|
std::string s = error_lua.what();
|
||||||
|
std::wstring ws;
|
||||||
|
ws.assign(s.begin(),s.end());
|
||||||
|
this->getEngine().getShell()->out(ws,glm::vec3(1,0,0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,13 @@
|
|||||||
class ScriptNode : public GraphicalNode
|
class ScriptNode : public GraphicalNode
|
||||||
{
|
{
|
||||||
|
|
||||||
sol::state s;
|
sol::state m_script;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ScriptNode();
|
ScriptNode();
|
||||||
void update();
|
void update();
|
||||||
void print(std::string);
|
void print(std::string);
|
||||||
void execute(std::string);
|
void execute(std::wstring);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SCRIPTNODE_H
|
#endif // SCRIPTNODE_H
|
||||||
|
@ -52,13 +52,13 @@ SparrowShell::SparrowShell(sf::Window* window):
|
|||||||
this->addChild(m_script);
|
this->addChild(m_script);
|
||||||
}
|
}
|
||||||
|
|
||||||
// write string str in shell
|
// write wstring str in shell
|
||||||
void SparrowShell::out(std::string str)
|
void SparrowShell::out(std::wstring str)
|
||||||
{
|
{
|
||||||
out(str,m_text_color);
|
out(str,m_text_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SparrowShell::out(std::string str,glm::vec3 color)
|
void SparrowShell::out(std::wstring str,glm::vec3 color)
|
||||||
{
|
{
|
||||||
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);
|
||||||
@ -109,9 +109,7 @@ void SparrowShell::update()
|
|||||||
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_plop_test){
|
if (action == m_move_cursor_left){
|
||||||
out("Plop");
|
|
||||||
}else if (action == m_move_cursor_left){
|
|
||||||
if (m_input_cursor_pos > 0)
|
if (m_input_cursor_pos > 0)
|
||||||
moveCursorLeft();
|
moveCursorLeft();
|
||||||
}
|
}
|
||||||
@ -133,6 +131,7 @@ void SparrowShell::update()
|
|||||||
void SparrowShell::updateTextInput()
|
void SparrowShell::updateTextInput()
|
||||||
{
|
{
|
||||||
std::wstring text = getEngine().getInput()->getText();
|
std::wstring text = getEngine().getInput()->getText();
|
||||||
|
bool input_string_updated = false;
|
||||||
if (!m_shellEnabled)
|
if (!m_shellEnabled)
|
||||||
return;
|
return;
|
||||||
for(unsigned int i = 0 ; i < text.length() ; i++){
|
for(unsigned int i = 0 ; i < text.length() ; i++){
|
||||||
@ -141,27 +140,31 @@ void SparrowShell::updateTextInput()
|
|||||||
case 8:
|
case 8:
|
||||||
if(m_input_cursor_pos > 0)
|
if(m_input_cursor_pos > 0)
|
||||||
m_input_string.erase(--m_input_cursor_pos,1);
|
m_input_string.erase(--m_input_cursor_pos,1);
|
||||||
|
input_string_updated = true;
|
||||||
break;
|
break;
|
||||||
case 13:
|
case 13:
|
||||||
if (m_input_string != ""){
|
if (!m_input_string.empty()){
|
||||||
out(m_input_string);
|
out(m_input_string);
|
||||||
m_script->execute(m_input_string);
|
m_script->execute(m_input_string);
|
||||||
}
|
|
||||||
m_input_string.clear();
|
m_input_string.clear();
|
||||||
|
input_string_updated = true;
|
||||||
|
}
|
||||||
m_input_cursor_pos = 0;
|
m_input_cursor_pos = 0;
|
||||||
break;
|
break;
|
||||||
case 127:
|
case 127:
|
||||||
m_input_string.erase(m_input_cursor_pos,1);
|
m_input_string.erase(m_input_cursor_pos,1);
|
||||||
|
input_string_updated = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
m_input_string.insert(m_input_cursor_pos++,std::string(1,c));
|
m_input_string.insert(m_input_cursor_pos++,std::wstring(1,c));
|
||||||
|
input_string_updated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Font *shellfont = RESOURCE_GET(Font,"shellfont");
|
Font *shellfont = RESOURCE_GET(Font,"shellfont");
|
||||||
|
if(input_string_updated)
|
||||||
|
{
|
||||||
if(m_input_mesh)
|
if(m_input_mesh)
|
||||||
this->removeChild(m_input_mesh);
|
this->removeChild(m_input_mesh);
|
||||||
if(m_input_string != "")
|
|
||||||
{
|
|
||||||
m_input_mesh = shellfont->getTextNode(m_input_string,m_text_color,m_buffer->getFontSize(),false);
|
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));
|
m_input_mesh->moveTo2D(glm::vec2(0,m_buffer->getFontSize()*BUFFER_DISPLAYED_LINES));
|
||||||
this->addChild(m_input_mesh);
|
this->addChild(m_input_mesh);
|
||||||
|
@ -36,7 +36,7 @@ private:
|
|||||||
ScriptNode * m_script;
|
ScriptNode * m_script;
|
||||||
|
|
||||||
glm::vec3 m_text_color;
|
glm::vec3 m_text_color;
|
||||||
std::string m_input_string;
|
std::wstring m_input_string;
|
||||||
unsigned int m_input_cursor_pos;
|
unsigned int m_input_cursor_pos;
|
||||||
TextNode* m_input_mesh;
|
TextNode* m_input_mesh;
|
||||||
|
|
||||||
@ -61,8 +61,8 @@ public:
|
|||||||
void scrollDown();
|
void scrollDown();
|
||||||
|
|
||||||
void toggleShell();
|
void toggleShell();
|
||||||
void out(std::string str);
|
void out(std::wstring str);
|
||||||
void out(std::string str, glm::vec3 color);
|
void out(std::wstring str, glm::vec3 color);
|
||||||
|
|
||||||
glm::ivec2 getPosition(){return m_position;}
|
glm::ivec2 getPosition(){return m_position;}
|
||||||
glm::ivec2 getDimension(){return m_dimension;}
|
glm::ivec2 getDimension(){return m_dimension;}
|
||||||
@ -72,7 +72,7 @@ public:
|
|||||||
|
|
||||||
void setMoveCursorLeftAction(int action){m_move_cursor_left = action;}
|
void setMoveCursorLeftAction(int action){m_move_cursor_left = action;}
|
||||||
void setMoveCursorRightAction(int action){m_move_cursor_right = action;}
|
void setMoveCursorRightAction(int action){m_move_cursor_right = action;}
|
||||||
void setPlopTest(int action){m_plop_test = action;}
|
// void setPlopTest(int action){m_plop_test = 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--;}
|
||||||
|
@ -250,15 +250,15 @@ class Menu {
|
|||||||
public:
|
public:
|
||||||
Menu(Engine* engine,Config* config){
|
Menu(Engine* engine,Config* config){
|
||||||
m_menu_scene = engine->createScene();
|
m_menu_scene = engine->createScene();
|
||||||
m_button_demo = new ButtonNode(glm::vec2(100,100),new RectangleButtonShape(glm::vec2(100,100),glm::vec2(300,100)));
|
m_button_demo = new ButtonNode(glm::vec2(100,100),new RectangleButtonShape(glm::vec2(300,100)));
|
||||||
//BackGroundNode* bg = new BackGroundNode(glm::vec2(100,100),glm::vec2(300,100),glm::vec3(1,0,0.5),1,11);
|
//BackGroundNode* bg = new BackGroundNode(glm::vec2(100,100),glm::vec2(300,100),glm::vec3(1,0,0.5),1,11);
|
||||||
//m_button_demo->setBackGround(bg);
|
m_button_demo->setLabel("Start DEMO");
|
||||||
// m_button_demo->setAction(m_left_click_action);
|
m_button_demo->setLabelColor(glm::vec3(0.9,0.4,0.3));
|
||||||
m_menu_scene->getRootObject()->addChild(m_button_demo);
|
m_menu_scene->getRootObject()->addChild(m_button_demo);
|
||||||
//m_menu_scene->getRootObject()->addChild(bg);
|
m_button_demo->moveTo2D(glm::vec2(100,100));
|
||||||
//bg->setVisible(true);
|
|
||||||
m_button_demo->setVisible(true);
|
m_button_demo->setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLeftClickAction(int action){
|
void setLeftClickAction(int action){
|
||||||
m_left_click_action = action;
|
m_left_click_action = action;
|
||||||
m_button_demo->setAction(m_left_click_action);
|
m_button_demo->setAction(m_left_click_action);
|
||||||
@ -307,7 +307,7 @@ int main(){
|
|||||||
SparrowShell* shell = engine.getShell();
|
SparrowShell* shell = engine.getShell();
|
||||||
shell->setMoveCursorLeftAction(DefaultKeysMap::MOVE_CURSOR_LEFT);
|
shell->setMoveCursorLeftAction(DefaultKeysMap::MOVE_CURSOR_LEFT);
|
||||||
shell->setMoveCursorRightAction(DefaultKeysMap::MOVE_CURSOR_RIGHT);
|
shell->setMoveCursorRightAction(DefaultKeysMap::MOVE_CURSOR_RIGHT);
|
||||||
shell->setPlopTest(DefaultKeysMap::PLOP_TEST);
|
//shell->setPlopTest(DefaultKeysMap::PLOP_TEST);
|
||||||
shell->setClearConsoleAction(DefaultKeysMap::CLEAR_CONSOLE);
|
shell->setClearConsoleAction(DefaultKeysMap::CLEAR_CONSOLE);
|
||||||
input->addContext(Context("shell",DefaultKeysMap::getShellContext()));
|
input->addContext(Context("shell",DefaultKeysMap::getShellContext()));
|
||||||
input->updateKeyBindings();
|
input->updateKeyBindings();
|
||||||
|
@ -8,13 +8,13 @@ Font::Font()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TextNode* Font::getTextNode(std::string s, glm::vec3 color, float font_size,bool visible)
|
TextNode* Font::getTextNode(std::wstring s, glm::vec3 color, float font_size,bool visible)
|
||||||
{
|
{
|
||||||
|
|
||||||
Mesh* textmesh = new Mesh();
|
Mesh* textmesh = new Mesh();
|
||||||
glm::vec2 current_pos(0.f);
|
glm::vec2 current_pos(0.f);
|
||||||
float sizeRatio = font_size / m_defaultLineHeight;
|
float sizeRatio = font_size / m_defaultLineHeight;
|
||||||
for(char c : s){
|
for(wchar_t c : s){
|
||||||
if(c == '\n')
|
if(c == '\n')
|
||||||
{
|
{
|
||||||
current_pos.x = 0.f; // left alignment -> TODO : be able to center or align right
|
current_pos.x = 0.f; // left alignment -> TODO : be able to center or align right
|
||||||
|
@ -31,7 +31,7 @@ public:
|
|||||||
void setScale(glm::vec2 scale){m_scale = scale;}
|
void setScale(glm::vec2 scale){m_scale = scale;}
|
||||||
void setTexture(Texture *tex){m_tex = tex;}
|
void setTexture(Texture *tex){m_tex = tex;}
|
||||||
|
|
||||||
TextNode* getTextNode(std::string s, glm::vec3 color = glm::vec3(1), float font_size = 64.f, bool visible = true);
|
TextNode* getTextNode(std::wstring s, glm::vec3 color = glm::vec3(1), float font_size = 64.f, bool visible = true);
|
||||||
private:
|
private:
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
Texture *m_tex;
|
Texture *m_tex;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user